@decocms/mesh 1.3.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/client/assets/{AlertCircle-BMr3-fpA.js → AlertCircle-D8Ig6VmI.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-BwQg_SOY.js → ArrowLeft-Dh26Pdy9.js} +1 -1
  3. package/dist/client/assets/{ChevronDown-BjyTHawB.js → ChevronDown-ePEWgGNp.js} +1 -1
  4. package/dist/client/assets/{Clock-BqL_Iy4b.js → Clock-D62M1TNS.js} +1 -1
  5. package/dist/client/assets/{Code01-DkmFiQmz.js → Code01-CEpWMfIN.js} +1 -1
  6. package/dist/client/assets/{Copy01-D2K_Muqy.js → Copy01-Do_2DOpc.js} +1 -1
  7. package/dist/client/assets/{CpuChip02-C_MNm5X3.js → CpuChip02-MwRKuQCg.js} +1 -1
  8. package/dist/client/assets/{DotsVertical-D0NEibaO.js → DotsVertical-DEHJGPWq.js} +1 -1
  9. package/dist/client/assets/{File06-CXgKQ6DN.js → File06-C6gmiM2R.js} +1 -1
  10. package/dist/client/assets/FlipBackward-C_yTzrjj.js +1 -0
  11. package/dist/client/assets/{GitBranch01-BUSTYQYz.js → GitBranch01-BytyqHyB.js} +1 -1
  12. package/dist/client/assets/Grid01-C9Qy-QMm.js +1 -0
  13. package/dist/client/assets/{Inbox01-CBPg2mpL.js → Inbox01-D6ujw7pC.js} +1 -1
  14. package/dist/client/assets/{Key01-BperTm8i.js → Key01-DyKOY05D.js} +1 -1
  15. package/dist/client/assets/LinkExternal01-R8UsBwpd.js +1 -0
  16. package/dist/client/assets/{Loading01-C4j07Rkx.js → Loading01-CYe6KHQ_.js} +1 -1
  17. package/dist/client/assets/{Lock01-CFQ55MXh.js → Lock01-V21nJrKX.js} +1 -1
  18. package/dist/client/assets/{Play-BZ988K1v.js → Play-BbVWnniF.js} +1 -1
  19. package/dist/client/assets/{Plus-mxlUVGel.js → Plus-B_341Z-m.js} +1 -1
  20. package/dist/client/assets/{SearchMd-COBfbXbx.js → SearchMd-CTe41Otq.js} +1 -1
  21. package/dist/client/assets/{Terminal-RcHlyPBU.js → Terminal-D1uJm4u2.js} +1 -1
  22. package/dist/client/assets/{Trash01-CyKI-_BM.js → Trash01-nRDGqZAh.js} +1 -1
  23. package/dist/client/assets/{X-BXO-lbAK.js → X-SbhTNlq-.js} +1 -1
  24. package/dist/client/assets/{XClose-C64sfNMR.js → XClose-UocnKXyW.js} +1 -1
  25. package/dist/client/assets/{alert-dialog-P1n_1JT7.js → alert-dialog-BU4z5vIU.js} +2 -2
  26. package/dist/client/assets/{auth-DP47SEOm.js → auth-DrOI2Q5h.js} +1 -1
  27. package/dist/client/assets/{auth-catchall-CfVXVPNH.js → auth-catchall-hi9HLq14.js} +1 -1
  28. package/dist/client/assets/{avatar-_GsuhjwG.js → avatar-DYifUjuR.js} +1 -1
  29. package/dist/client/assets/{badge-DC5bHjau.js → badge-0sGir89N.js} +1 -1
  30. package/dist/client/assets/{button-dzqjSoP9.js → button-DekBQWZX.js} +1 -1
  31. package/dist/client/assets/{card-C7renjvY.js → card-CjPFi-mt.js} +1 -1
  32. package/dist/client/assets/{checkbox-DAye6Bhs.js → checkbox-DWBjIr3c.js} +1 -1
  33. package/dist/client/assets/collection-detail-CFyCCxRq.js +183 -0
  34. package/dist/client/assets/collection-display-button-CcmMGuN1.js +1 -0
  35. package/dist/client/assets/{collection-header-BmMDhAGN.js → collection-header-BzcsMkVk.js} +1 -1
  36. package/dist/client/assets/{collection-page-Cn_-fCfu.js → collection-page-JhE-nlZe.js} +1 -1
  37. package/dist/client/assets/{collection-search-B8kQUh1o.js → collection-search-D31FObj2.js} +1 -1
  38. package/dist/client/assets/{collection-tab-CuS_mYhN.js → collection-tab-CislJm1o.js} +1 -1
  39. package/dist/client/assets/collection-table-wrapper-DttYG93Q.js +1 -0
  40. package/dist/client/assets/{connection-card-DJnmbeP6.js → connection-card-Po1O1myw.js} +1 -1
  41. package/dist/client/assets/connection-detail-CCe4qpmo.js +1 -0
  42. package/dist/client/assets/connections-CAn295jL.js +1 -0
  43. package/dist/client/assets/constants-BP-f87DW.js +1 -0
  44. package/dist/client/assets/{core-BmgwoN2D.js → core-CQOpJFuu.js} +1 -1
  45. package/dist/client/assets/{create-organization-dialog-C1_fICTk.js → create-organization-dialog-BHcS-HWr.js} +1 -1
  46. package/dist/client/assets/{dialog-CjFuRpNq.js → dialog-B48I0mf9.js} +1 -1
  47. package/dist/client/assets/dropdown-menu-DEOghZY2.js +1 -0
  48. package/dist/client/assets/{empty-state-D7F--R-i.js → empty-state-DPKHlkpV.js} +1 -1
  49. package/dist/client/assets/{env-vars-editor-CA1M7xF4.js → env-vars-editor-siosgJYU.js} +1 -1
  50. package/dist/client/assets/{error-boundary-Kj4QesDI.js → error-boundary-BU7ytqKh.js} +1 -1
  51. package/dist/client/assets/{extract-connection-data-DoCNquGq.js → extract-connection-data-CNwfi3Bj.js} +1 -1
  52. package/dist/client/assets/{form-DNs0FRpn.js → form-idjG_l3J.js} +1 -1
  53. package/dist/client/assets/{formatDistanceToNow-ctvTO9qt.js → formatDistanceToNow-BvbEbggm.js} +1 -1
  54. package/dist/client/assets/gateway-detail-CojPNuj0.js +1 -0
  55. package/dist/client/assets/gateways-BMARnVs9.js +1 -0
  56. package/dist/client/assets/{home-CZCW3yxr.js → home-C44O4JPT.js} +1 -1
  57. package/dist/client/assets/index-BcDKMyjy.css +1 -0
  58. package/dist/client/assets/{index-C5Ye_Yv8.js → index-DRz67w4F.js} +1 -1
  59. package/dist/client/assets/{index-DNNzqGj5.js → index-DajdRBtQ.js} +5 -5
  60. package/dist/client/assets/{index-DYEBIV-t.js → index-IR-O--2-.js} +1 -1
  61. package/dist/client/assets/{index--kROx8O6.js → index-Wt1f1puE.js} +14 -14
  62. package/dist/client/assets/{input-Dos1YqM9.js → input-BKIlqldN.js} +1 -1
  63. package/dist/client/assets/json-DJFsnV6J.js +1 -0
  64. package/dist/client/assets/{json-syntax-highlighter-DOX4DGR6.js → json-syntax-highlighter-iaFBJPMB.js} +2 -2
  65. package/dist/client/assets/{layout-C2pQBqt8.js → layout-DZ2ngf-d.js} +1 -1
  66. package/dist/client/assets/{lazy-highlighter-BeoVpvw-.js → lazy-highlighter-DzPyG_7U.js} +1 -1
  67. package/dist/client/assets/localstorage-keys-DywUtnFx.js +1 -0
  68. package/dist/client/assets/{login-BkePM8bd.js → login-DV7ZXMS3.js} +1 -1
  69. package/dist/client/assets/{mcp-oauth-BAFvA0-x.js → mcp-oauth-CoHdTRs8.js} +1 -1
  70. package/dist/client/assets/members-BSXMpEiy.js +3 -0
  71. package/dist/client/assets/monitoring-jd56r5aO.js +4 -0
  72. package/dist/client/assets/{oauth-callback-Mr11rTZP.js → oauth-callback-DWPZPLpo.js} +1 -1
  73. package/dist/client/assets/{page-BxWTpniF.js → page-8jW60JQy.js} +2 -2
  74. package/dist/client/assets/{pin-to-sidebar-button-DFstuxz9.js → pin-to-sidebar-button-kBAZ-5ye.js} +1 -1
  75. package/dist/client/assets/{popover-Bflc8KYR.js → popover-BOM-Ldjy.js} +1 -1
  76. package/dist/client/assets/prism-light-uO9D9BzO.js +1 -0
  77. package/dist/client/assets/resizable-CJZIf7G0.js +1 -0
  78. package/dist/client/assets/{resource-tabs-C7YApwd6.js → resource-tabs-Ce7H16gk.js} +1 -1
  79. package/dist/client/assets/responsive-select-BwKgIRfG.js +1 -0
  80. package/dist/client/assets/{select-Bd0A4qyi.js → select-BfMeJf3G.js} +1 -1
  81. package/dist/client/assets/settings-3-JCtPNJ.js +1 -0
  82. package/dist/client/assets/shell-layout-CdWK4rD-.js +19 -0
  83. package/dist/client/assets/{spinner-DssEQupg.js → spinner-DRqaN8gi.js} +1 -1
  84. package/dist/client/assets/store-Do1Cu7xx.js +1 -0
  85. package/dist/client/assets/store-app-detail-CTTgc-e9.js +1 -0
  86. package/dist/client/assets/{switch-jY_WtmSF.js → switch-Dw1RG-3y.js} +1 -1
  87. package/dist/client/assets/{textarea-CRl6hqQJ.js → textarea-Bft7ABhA.js} +1 -1
  88. package/dist/client/assets/thread-history-popover-Bi9mj2yY.js +98 -0
  89. package/dist/client/assets/{tools-list-cySZCndz.js → tools-list-Ce6AdOzS.js} +1 -1
  90. package/dist/client/assets/tooltip-TfGvrkSe.js +1 -0
  91. package/dist/client/assets/{types-C2--1o8t.js → types-Cnps3aja.js} +1 -1
  92. package/dist/client/assets/{use-binding-DHbkm4TE.js → use-binding-C0D0SiIL.js} +2 -2
  93. package/dist/client/assets/{use-connection-DwuFVoxD.js → use-connection-Bw5VjMDS.js} +1 -1
  94. package/dist/client/assets/{use-connection-resources-6iOIsQA9.js → use-connection-resources-G46B63hU.js} +1 -1
  95. package/dist/client/assets/{use-gateway-C48kcbNv.js → use-gateway-Bcu8DfzG.js} +1 -1
  96. package/dist/client/assets/{use-list-state-DC-EnrYi.js → use-list-state-BFqdzcLT.js} +1 -1
  97. package/dist/client/assets/{use-mcp-LjTWLNoY.js → use-mcp-BQdB6WDZ.js} +1 -1
  98. package/dist/client/assets/{use-members-k3Q2xXPW.js → use-members-Du1Rfr_g.js} +1 -1
  99. package/dist/client/assets/{use-mobile-Bmxp2FgH.js → use-mobile-DxFWm-MR.js} +1 -1
  100. package/dist/client/assets/{use-organization-settings-0ztRQ3i7.js → use-organization-settings-DNW7rc_y.js} +1 -1
  101. package/dist/client/assets/{use-tool-call-D1etRfCY.js → use-tool-call-D3fXWIz8.js} +1 -1
  102. package/dist/client/assets/useQuery-xVxOaLKm.js +1 -0
  103. package/dist/client/assets/{useSuspenseInfiniteQuery-Br-4aSkX.js → useSuspenseInfiniteQuery-BUiIWXaf.js} +1 -1
  104. package/dist/client/assets/{view-mode-toggle-D13jhPxd.js → view-mode-toggle-CP1Lj0do.js} +1 -1
  105. package/dist/client/assets/workflow-IxqE_uwj.js +1 -0
  106. package/dist/client/index.html +2 -2
  107. package/dist/server/cli.js +1 -1
  108. package/dist/server/server.js +1 -1
  109. package/package.json +1 -1
  110. package/dist/client/assets/InfoCircle-COZlVleH.js +0 -1
  111. package/dist/client/assets/LinkExternal01-CYB_l3HF.js +0 -1
  112. package/dist/client/assets/Upload01-Ck1Svxew.js +0 -1
  113. package/dist/client/assets/assistant-DpkEh-Jl.js +0 -1
  114. package/dist/client/assets/binding-collection-view-MAfjU-3d.js +0 -1
  115. package/dist/client/assets/collection-detail-CCxtFEtB.js +0 -183
  116. package/dist/client/assets/collection-display-button-DuYSBdla.js +0 -1
  117. package/dist/client/assets/collection-table-wrapper-BxibriYd.js +0 -1
  118. package/dist/client/assets/connection-detail-BEAx4Rx8.js +0 -1
  119. package/dist/client/assets/connections-DhcecQtM.js +0 -1
  120. package/dist/client/assets/constants-BVChjGeA.js +0 -1
  121. package/dist/client/assets/dropdown-menu-6B5tpY1h.js +0 -1
  122. package/dist/client/assets/gateway-detail-e5GW9_16.js +0 -1
  123. package/dist/client/assets/gateways-potF35CW.js +0 -1
  124. package/dist/client/assets/index-BtfNSYYi.css +0 -1
  125. package/dist/client/assets/json-BSW9cMnN.js +0 -1
  126. package/dist/client/assets/localstorage-keys-Cl6fG_mC.js +0 -1
  127. package/dist/client/assets/members-DOlpKNSi.js +0 -3
  128. package/dist/client/assets/monitoring-C60hZcZG.js +0 -4
  129. package/dist/client/assets/prism-light-CKgeoQoL.js +0 -1
  130. package/dist/client/assets/resizable-CZ3q7UHO.js +0 -98
  131. package/dist/client/assets/settings-Bzv9x0Xx.js +0 -1
  132. package/dist/client/assets/shell-layout-JAlTNvh1.js +0 -19
  133. package/dist/client/assets/store-DDomUn8i.js +0 -1
  134. package/dist/client/assets/store-app-detail-Cvn5_uEK.js +0 -1
  135. package/dist/client/assets/tooltip-wl_T0hkj.js +0 -1
  136. package/dist/client/assets/useQuery-5Z2U7Q-f.js +0 -1
  137. package/dist/client/assets/workflow-COhnt_Eq.js +0 -1
@@ -1,183 +0,0 @@
1
- import{aw as ut,r as N,c as j,d as _n,j as p,g as ro,as as il,x as up,y as fu,v as dp,w as Vo,i as fp,b as hp,t as hu,F as ee,Q as pp,ax as Ho,ay as pu,a5 as mp,a4 as gp,az as yp,H as ll,a9 as mu,ac as xp,B as zn,E as Ge,$ as al,ad as bp,z as so,aa as kp,Z as cl,aj as vp,ak as wp,al as Sp,aA as ul,aB as Cp,ab as gu,a1 as Np,aC as Ep,L as Tp,aD as Mp,aE as Op}from"./index--kROx8O6.js";import{U as kt,f as dl,d as oo,c as nt,b as fl,I as io,u as Ap,n as Ip}from"./use-connection-DwuFVoxD.js";import{C as st,d as jp,u as Rp,e as Dp,I as Pp,U as Lp,l as ya,G as yu,M as $p,n as _p,m as zp,R as xa,k as Bp}from"./resizable-CZ3q7UHO.js";import{E as Tr}from"./SearchMd-COBfbXbx.js";import{E as pr}from"./error-boundary-Kj4QesDI.js";import{P as lo}from"./pin-to-sidebar-button-DFstuxz9.js";import{u as Fp,L as Vp}from"./localstorage-keys-Cl6fG_mC.js";import{u as Hp,a as Xe,c as Qe,b as Ze,T as et,i as hl}from"./tooltip-wl_T0hkj.js";import{B as ue,c as Z}from"./button-dzqjSoP9.js";import{F as gt,a as xu,b as Bt,c as Mr,d as Bn}from"./form-DNs0FRpn.js";import{I as Or}from"./input-Dos1YqM9.js";import{T as cs}from"./textarea-CRl6hqQJ.js";import{A as Wp,D as Up,u as qp}from"./use-binding-DHbkm4TE.js";import{i as nn}from"./Loading01-C4j07Rkx.js";import{s as ao}from"./Plus-mxlUVGel.js";import{i as Kp}from"./Upload01-Ck1Svxew.js";import{b as On,a as pl,V as co}from"./layout-C2pQBqt8.js";import{i as Jp}from"./AlertCircle-BMr3-fpA.js";import{s as Gp}from"./Clock-BqL_Iy4b.js";import{i as Yp,n as Xp}from"./Code01-DkmFiQmz.js";import{a as Qp}from"./Copy01-D2K_Muqy.js";import{i as ml}from"./Play-BZ988K1v.js";import{s as gl,i as Zp}from"./XClose-C64sfNMR.js";import{u as em,O as tm,M as nm,F as rm,v as sm}from"./index-DNNzqGj5.js";import{u as yl}from"./use-mcp-LjTWLNoY.js";import{J as om}from"./json-syntax-highlighter-DOX4DGR6.js";import{E as im}from"./empty-state-D7F--R-i.js";import{u as lm}from"./use-gateway-C48kcbNv.js";import{S as Fn}from"./spinner-DssEQupg.js";import{V as am}from"./view-mode-toggle-D13jhPxd.js";import{i as cm}from"./GitBranch01-BUSTYQYz.js";import{a as xl,b as bl}from"./use-tool-call-D1etRfCY.js";import{D as um,a as dm,b as fm,f as hm,c as pm,d as mm}from"./dialog-CjFuRpNq.js";import"./index-C5Ye_Yv8.js";import{b as gm,D as ym,a as xm,d as ba,i as bm}from"./dropdown-menu-6B5tpY1h.js";import{B as yn}from"./badge-DC5bHjau.js";import{i as bu}from"./X-BXO-lbAK.js";import"./CpuChip02-C_MNm5X3.js";import"./Terminal-RcHlyPBU.js";import"./connection-card-DJnmbeP6.js";import"./card-C7renjvY.js";import"./LinkExternal01-CYB_l3HF.js";import"./alert-dialog-P1n_1JT7.js";import"./select-Bd0A4qyi.js";import"./ChevronDown-BjyTHawB.js";import"./use-mobile-Bmxp2FgH.js";import"./File06-CXgKQ6DN.js";import"./InfoCircle-COZlVleH.js";import"./use-organization-settings-0ztRQ3i7.js";import"./useQuery-5Z2U7Q-f.js";import"./auth-DP47SEOm.js";import"./ArrowLeft-BwQg_SOY.js";import"./mcp-oauth-BAFvA0-x.js";import"./env-vars-editor-CA1M7xF4.js";import"./Trash01-CyKI-_BM.js";import"./Key01-BperTm8i.js";import"./formatDistanceToNow-ctvTO9qt.js";import"./constants-BVChjGeA.js";import"./registry-utils-ulDDT0d8.js";import"./extract-connection-data-DoCNquGq.js";import"./generate-id-Dyweu44Y.js";import"./index-DYEBIV-t.js";const ku=ut("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 vu=ut("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 wu=ut("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Su=ut("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const km=ut("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const vm=ut("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 Cu=ut("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 Nu=ut("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 Eu=ut("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 Tu=ut("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"}]]),kl=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));kl.displayName="AlertOctagon";const Mu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));Mu.displayName="Box";const Ou=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));Ou.displayName="ClockFastForward";const Au=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Au.displayName="Code02";const ts=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));ts.displayName="Columns01";const Iu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));Iu.displayName="CornerDownRight";const ju=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));ju.displayName="Database01";const Ru=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"M11 4H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 6.28 2 7.12 2 8.8v8.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 22 5.12 22 6.8 22h8.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C20 19.72 20 18.88 20 17.2V13M8 16h1.675c.489 0 .733 0 .963-.055.204-.05.4-.13.579-.24.201-.123.374-.296.72-.642L21.5 5.5a2.121 2.121 0 0 0-3-3l-9.563 9.563c-.346.346-.519.519-.642.72a2 2 0 0 0-.24.579c-.055.23-.055.474-.055.963V16Z"}));Ru.displayName="Edit05";const uo=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"M3 9h13.5a4.5 4.5 0 1 1 0 9H12M3 9l4-4M3 9l4 4"}));uo.displayName="FlipBackward";const Du=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));Du.displayName="Repeat03";const fo=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));fo.displayName="Save02";const Pu=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.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"}));Pu.displayName="Tool01";const ho=({size:t=24,color:e="currentColor",...n})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},N.createElement("path",{d:"M16 3.468a4.5 4.5 0 0 1 0 8.064m2 5.234c1.512.684 2.872 1.799 4 3.234M2 20c1.946-2.477 4.59-4 7.5-4s5.553 1.523 7.5 4M14 7.5a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z"}));ho.displayName="Users02";const{getOwnPropertyNames:wm,getOwnPropertySymbols:Sm}=Object,{hasOwnProperty:Cm}=Object.prototype;function Wo(t,e){return function(r,s,o){return t(r,s,o)&&e(r,s,o)}}function zr(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:o}=s,i=o.get(n),l=o.get(r);if(i&&l)return i===r&&l===n;o.set(n,r),o.set(r,n);const a=t(n,r,s);return o.delete(n),o.delete(r),a}}function Nm(t){return t?.[Symbol.toStringTag]}function ka(t){return wm(t).concat(Sm(t))}const Em=Object.hasOwn||((t,e)=>Cm.call(t,e));function cn(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Tm="__v",Mm="__o",Om="_owner",{getOwnPropertyDescriptor:va,keys:wa}=Object;function Am(t,e){return t.byteLength===e.byteLength&&us(new Uint8Array(t),new Uint8Array(e))}function Im(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function jm(t,e){return t.byteLength===e.byteLength&&us(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Rm(t,e){return cn(t.getTime(),e.getTime())}function Dm(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function Pm(t,e){return t===e}function Sa(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=t.entries();let i,l,a=0;for(;(i=o.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const f=i.value,h=l.value;if(n.equals(f[0],h[0],a,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const Lm=cn;function $m(t,e,n){const r=wa(t);let s=r.length;if(wa(e).length!==s)return!1;for(;s-- >0;)if(!Lu(t,e,n,r[s]))return!1;return!0}function Gn(t,e,n){const r=ka(t);let s=r.length;if(ka(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Lu(t,e,n,o)||(i=va(t,o),l=va(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function _m(t,e){return cn(t.valueOf(),e.valueOf())}function zm(t,e){return t.source===e.source&&t.flags===e.flags}function Ca(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),o=t.values();let i,l;for(;(i=o.next())&&!i.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&n.equals(i.value,l.value,i.value,l.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function us(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function Bm(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Lu(t,e,n,r){return(r===Om||r===Mm||r===Tm)&&(t.$$typeof||e.$$typeof)?!0:Em(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const Fm="[object ArrayBuffer]",Vm="[object Arguments]",Hm="[object Boolean]",Wm="[object DataView]",Um="[object Date]",qm="[object Error]",Km="[object Map]",Jm="[object Number]",Gm="[object Object]",Ym="[object RegExp]",Xm="[object Set]",Qm="[object String]",Zm={"[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},eg="[object URL]",tg=Object.prototype.toString;function ng({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:o,areMapsEqual:i,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:m}){return function(y,x,b){if(y===x)return!0;if(y==null||x==null)return!1;const k=typeof y;if(k!==typeof x)return!1;if(k!=="object")return k==="number"?l(y,x,b):k==="function"?o(y,x,b):!1;const S=y.constructor;if(S!==x.constructor)return!1;if(S===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(S===Date)return r(y,x,b);if(S===RegExp)return u(y,x,b);if(S===Map)return i(y,x,b);if(S===Set)return d(y,x,b);const v=tg.call(y);if(v===Um)return r(y,x,b);if(v===Ym)return u(y,x,b);if(v===Km)return i(y,x,b);if(v===Xm)return d(y,x,b);if(v===Gm)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(v===eg)return h(y,x,b);if(v===qm)return s(y,x,b);if(v===Vm)return a(y,x,b);if(Zm[v])return f(y,x,b);if(v===Fm)return t(y,x,b);if(v===Wm)return n(y,x,b);if(v===Hm||v===Jm||v===Qm)return c(y,x,b);if(m){let C=m[v];if(!C){const w=Nm(y);w&&(C=m[w])}if(C)return C(y,x,b)}return!1}}function rg({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:Am,areArraysEqual:n?Gn:Im,areDataViewsEqual:jm,areDatesEqual:Rm,areErrorsEqual:Dm,areFunctionsEqual:Pm,areMapsEqual:n?Wo(Sa,Gn):Sa,areNumbersEqual:Lm,areObjectsEqual:n?Gn:$m,arePrimitiveWrappersEqual:_m,areRegExpsEqual:zm,areSetsEqual:n?Wo(Ca,Gn):Ca,areTypedArraysEqual:n?Wo(us,Gn):us,areUrlsEqual:Bm,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=zr(r.areArraysEqual),o=zr(r.areMapsEqual),i=zr(r.areObjectsEqual),l=zr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function sg(t){return function(e,n,r,s,o,i,l){return t(e,n,l)}}function og({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,a){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(t)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 ig=Ft();Ft({strict:!0});Ft({circular:!0});Ft({circular:!0,strict:!0});Ft({createInternalComparator:()=>cn});Ft({strict:!0,createInternalComparator:()=>cn});Ft({circular:!0,createInternalComparator:()=>cn});Ft({circular:!0,createInternalComparator:()=>cn,strict:!0});function Ft(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,o=rg(t),i=ng(o),l=n?n(i):sg(i);return og({circular:e,comparator:i,createState:r,equals:l,strict:s})}function lg(t){const e=j.c(3),{gatewayId:n,onSelect:r}=t,{data:s}=Dp(n);if(s.length===0)return null;let o;return e[0]!==r||e[1]!==s?(o=p.jsx(Pp,{prompts:s,onSelect:r,className:"mt-6"}),e[0]=r,e[1]=s,e[2]=o):o=e[2],o}function ag(t){const e=j.c(20),{form:n}=t;let r;e[0]!==n?(r=d=>{const{field:f}=d;return p.jsx(yg,{size:"md",value:f.value,onChange:f.onChange,alt:n.watch("title")})},e[0]=n,e[1]=r):r=e[1];let s;e[2]!==n.control||e[3]!==r?(s=p.jsx(gt,{control:n.control,name:"avatar",render:r}),e[2]=n.control,e[3]=r,e[4]=s):s=e[4];let o;e[5]!==n.control?(o=p.jsxs("div",{className:"flex flex-col gap-3 flex-1 min-w-0",children:[p.jsx(gt,{control:n.control,name:"title",render:hg}),p.jsx(gt,{control:n.control,name:"description",render:fg})]}),e[5]=n.control,e[6]=o):o=e[6];let i;e[7]!==s||e[8]!==o?(i=p.jsxs("div",{className:"flex gap-4 items-start",children:[s,o]}),e[7]=s,e[8]=o,e[9]=i):i=e[9];let l,a;e[10]!==n.control?(l=p.jsxs("div",{className:"flex gap-4",children:[p.jsx(gt,{control:n.control,name:"gateway_id",render:dg}),p.jsx(gt,{control:n.control,name:"model",render:ug})]}),a=p.jsx(gt,{control:n.control,name:"system_prompt",render:cg}),e[10]=n.control,e[11]=l,e[12]=a):(l=e[11],a=e[12]);let c;e[13]!==i||e[14]!==l||e[15]!==a?(c=p.jsxs("div",{className:"h-full py-6 flex flex-col max-w-2xl mx-auto w-full min-w-0 gap-6 overflow-y-auto",children:[i,l,a]}),e[13]=i,e[14]=l,e[15]=a,e[16]=c):c=e[16];let u;return e[17]!==n||e[18]!==c?(u=p.jsx(xu,{...n,children:c}),e[17]=n,e[18]=c,e[19]=u):u=e[19],u}function cg(t){const{field:e}=t;return p.jsxs(Bt,{className:"flex-1 flex flex-col min-h-0",children:[p.jsx(Mr,{className:"text-xs text-muted-foreground",children:"System prompt"}),p.jsx(Bn,{children:p.jsx(cs,{...e,placeholder:"You are a helpful assistant...",className:"flex-1 min-h-[200px] 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 ug(t){const{field:e}=t;return p.jsxs(Bt,{className:"flex-1",children:[p.jsx(Mr,{className:"text-xs text-muted-foreground",children:"Model"}),p.jsx($p,{selectedModel:e.value?{id:e.value.id,connectionId:e.value.connectionId}:void 0,onModelChange:n=>e.onChange({id:n.id,connectionId:n.connectionId}),placeholder:"Select model",variant:"bordered",className:"w-full"})]})}function dg(t){const{field:e}=t;return p.jsxs(Bt,{className:"flex-1",children:[p.jsx(Mr,{className:"text-xs text-muted-foreground",children:"Gateway"}),p.jsx(yu,{selectedGatewayId:e.value,onGatewayChange:e.onChange,placeholder:"Select gateway",variant:"bordered",className:"w-full"})]})}function fg(t){const{field:e}=t;return p.jsxs(Bt,{children:[p.jsx(Mr,{className:"text-xs text-muted-foreground",children:"Description"}),p.jsx(Bn,{children:p.jsx(Or,{...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 hg(t){const{field:e}=t;return p.jsxs(Bt,{children:[p.jsx(Mr,{className:"text-xs text-muted-foreground",children:"Name"}),p.jsx(Bn,{children:p.jsx(Or,{...e,placeholder:"Untitled assistant",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function pg(t){const e=j.c(14),{onSubmit:n,onStop:r,isStreaming:s,disabled:o,usageMessages:i,inputValue:l,setInputValue:a}=t;let c;e[0]!==l||e[1]!==n?(c=async()=>{l.trim()&&await n(l.trim())},e[0]=l,e[1]=n,e[2]=c):c=e[2];const u=o?"Configure model and gateway to start chatting":"Ask anything or @ for context";let d;e[3]!==i?(d=p.jsx(Lp,{messages:i}),e[3]=i,e[4]=d):d=e[4];let f;return e[5]!==o||e[6]!==l||e[7]!==s||e[8]!==r||e[9]!==a||e[10]!==c||e[11]!==u||e[12]!==d?(f=p.jsx(st.Input,{value:l,onChange:a,onSubmit:c,onStop:r,disabled:o,isStreaming:s,placeholder:u,children:d}),e[5]=o,e[6]=l,e[7]=s,e[8]=r,e[9]=a,e[10]=c,e[11]=u,e[12]=d,e[13]=f):f=e[13],f}function mg(t){const e=j.c(92),{activeThreadId:n,setActiveThreadId:r,mode:s,assistant:o,form:i}=t;let l;e[0]!==n||e[1]!==o.system_prompt?(l={threadId:n,systemPrompt:o.system_prompt},e[0]=n,e[1]=o.system_prompt,e[2]=l):l=e[2];const a=jp(l),{inputValue:c,setInputValue:u,branchContext:d,clearBranch:f}=Rp(),{isEmpty:h}=a,m=!!o.gateway_id&&!!o.model?.id&&!!o.model?.connectionId;let g;e[3]!==n||e[4]!==o.gateway_id||e[5]!==o.model||e[6]!==a||e[7]!==f||e[8]!==m||e[9]!==u?(g=async Je=>{if(!m)return;u(""),f();const Kn={created_at:new Date().toISOString(),thread_id:n,model:{id:o.model.id,connectionId:o.model.connectionId},gateway:{id:o.gateway_id??""},user:{name:"you"}};await a.sendMessage(Je,Kn)},e[3]=n,e[4]=o.gateway_id,e[5]=o.model,e[6]=a,e[7]=f,e[8]=m,e[9]=u,e[10]=g):g=e[10];const y=g;let x;e[11]!==d||e[12]!==f||e[13]!==r||e[14]!==u?(x=()=>{d&&(r(d.originalThreadId),f(),u(""))},e[11]=d,e[12]=f,e[13]=r,e[14]=u,e[15]=x):x=e[15];const b=x;let k;e[16]!==o.avatar||e[17]!==o.title?(k=o.avatar?p.jsx("div",{className:"size-[60px] rounded-[18px] border border-border shrink-0 overflow-hidden",children:p.jsx("img",{src:o.avatar,alt:o.title,className:"h-full w-full object-cover"})}):p.jsx("div",{className:"size-[60px] rounded-[18px] border border-border shrink-0 overflow-hidden bg-muted/20 flex items-center justify-center",children:p.jsx(ho,{size:28,className:"text-muted-foreground"})}),e[16]=o.avatar,e[17]=o.title,e[18]=k):k=e[18];let S;e[19]!==o.title?(S=p.jsx("h3",{className:"text-xl font-medium text-foreground",children:o.title}),e[19]=o.title,e[20]=S):S=e[20];let v;e[21]!==o.description?(v=o.description?p.jsx("div",{className:"text-muted-foreground text-center text-sm max-w-md",children:o.description}):null,e[21]=o.description,e[22]=v):v=e[22];let C;e[23]!==k||e[24]!==S||e[25]!==v?(C=p.jsxs("div",{className:"flex flex-col items-center gap-4",children:[k,S,v]}),e[23]=k,e[24]=S,e[25]=v,e[26]=C):C=e[26];let w;e[27]!==o.gateway_id||e[28]!==y?(w=o.gateway_id&&p.jsx(pr,{fallback:null,children:p.jsx(N.Suspense,{fallback:p.jsx("div",{className:"flex justify-center mt-6",children:p.jsx(nn,{size:20,className:"animate-spin text-muted-foreground"})}),children:p.jsx(lg,{gatewayId:o.gateway_id,onSelect:Je=>{y(Je.description??Je.name)}})})}),e[27]=o.gateway_id,e[28]=y,e[29]=w):w=e[29];let M;e[30]!==C||e[31]!==w?(M=p.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-4 text-center",children:[C,w]}),e[30]=C,e[31]=w,e[32]=M):M=e[32];const E=M,A=s==="edit",D=A?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none";let _;e[33]!==D?(_=Z("absolute inset-0 px-2 transition-opacity duration-200 ease-out",D),e[33]=D,e[34]=_):_=e[34];let B;e[35]!==i?(B=p.jsx(ag,{form:i}),e[35]=i,e[36]=B):B=e[36];let z;e[37]!==_||e[38]!==B?(z=p.jsx("div",{className:_,children:B}),e[37]=_,e[38]=B,e[39]=z):z=e[39];const R=A?"opacity-0 pointer-events-none":"opacity-100";let T;e[40]!==R?(T=Z("h-full transition-opacity duration-200 ease-out",R),e[40]=R,e[41]=T):T=e[41];let L;e[42]!==a.messages||e[43]!==a.status||e[44]!==E||e[45]!==h?(L=h?p.jsx(st.EmptyState,{children:E}):p.jsx(st.Messages,{messages:a.messages,status:a.status,minHeightOffset:240}),e[42]=a.messages,e[43]=a.status,e[44]=E,e[45]=h,e[46]=L):L=e[46];let P;e[47]!==T||e[48]!==L?(P=p.jsx("div",{className:T,children:L}),e[47]=T,e[48]=L,e[49]=P):P=e[49];let U;e[50]!==z||e[51]!==P?(U=p.jsxs(st.Main,{className:"h-full relative overflow-hidden",children:[z,P]}),e[50]=z,e[51]=P,e[52]=U):U=e[52];const X=A?"translate-y-full":"translate-y-0";let H;e[53]!==X?(H=Z("transition-transform duration-300 ease-out",X),e[53]=X,e[54]=H):H=e[54];let W;e[55]!==a.error||e[56]!==y?(W=()=>{a.error&&y(`I encountered this error: ${a.error.message}. Can you help me fix it?`)},e[55]=a.error,e[56]=y,e[57]=W):W=e[57];let Q;e[58]!==a.clearError||e[59]!==a.error||e[60]!==W?(Q=p.jsx(st.ErrorBanner,{error:a.error,onFixInChat:W,onDismiss:a.clearError}),e[58]=a.clearError,e[59]=a.error,e[60]=W,e[61]=Q):Q=e[61];let J;e[62]!==y?(J=()=>{y("Please continue.")},e[62]=y,e[63]=J):J=e[63];let K;e[64]!==a.clearFinishReason||e[65]!==a.finishReason||e[66]!==J?(K=p.jsx(st.FinishReasonWarning,{finishReason:a.finishReason,onContinue:J,onDismiss:a.clearFinishReason}),e[64]=a.clearFinishReason,e[65]=a.finishReason,e[66]=J,e[67]=K):K=e[67];let le;e[68]!==d||e[69]!==f||e[70]!==b||e[71]!==u?(le=p.jsx(st.BranchPreview,{branchContext:d,clearBranchContext:f,onGoToOriginalMessage:b,setInputValue:u}),e[68]=d,e[69]=f,e[70]=b,e[71]=u,e[72]=le):le=e[72];const ze=a.status==="submitted"||a.status==="streaming",Wt=!m;let Re;e[73]!==a.messages||e[74]!==a.stop||e[75]!==y||e[76]!==c||e[77]!==u||e[78]!==ze||e[79]!==Wt?(Re=p.jsx(pg,{onSubmit:y,onStop:a.stop,isStreaming:ze,disabled:Wt,usageMessages:a.messages,inputValue:c,setInputValue:u}),e[73]=a.messages,e[74]=a.stop,e[75]=y,e[76]=c,e[77]=u,e[78]=ze,e[79]=Wt,e[80]=Re):Re=e[80];let De;e[81]!==Q||e[82]!==K||e[83]!==le||e[84]!==Re?(De=p.jsx(st.Footer,{children:p.jsxs("div",{className:"max-w-2xl mx-auto w-full min-w-0 flex flex-col gap-2",children:[Q,K,le,Re]})}),e[81]=Q,e[82]=K,e[83]=le,e[84]=Re,e[85]=De):De=e[85];let Pe;e[86]!==H||e[87]!==De?(Pe=p.jsx("div",{className:H,children:De}),e[86]=H,e[87]=De,e[88]=Pe):Pe=e[88];let Ke;return e[89]!==U||e[90]!==Pe?(Ke=p.jsxs(st,{children:[U,Pe]}),e[89]=U,e[90]=Pe,e[91]=Ke):Ke=e[91],Ke}function gg(t){const e=j.c(6),{activeThreadId:n,setActiveThreadId:r,mode:s,assistant:o,form:i}=t;let l;return e[0]!==n||e[1]!==o||e[2]!==i||e[3]!==s||e[4]!==r?(l=p.jsx(st.Provider,{children:p.jsx(mg,{activeThreadId:n,setActiveThreadId:r,mode:s,assistant:o,form:i})}),e[0]=n,e[1]=o,e[2]=i,e[3]=s,e[4]=r,e[5]=l):l=e[5],l}function yg(t){const e=j.c(18),{value:n,onChange:r,alt:s,size:o}=t,i=o===void 0?"md":o,l=N.useRef(null),a=i==="xs"?"h-6 w-6":i==="sm"?"h-8 w-8":"h-16 w-16",c=i==="xs"?"h-3 w-3":i==="sm"?"h-4 w-4":"h-6 w-6",u=i==="xs"?"h-3 w-3":i==="sm"?"h-3.5 w-3.5":"h-5 w-5";let d;e[0]!==r?(d=C=>{const w=C.target.files?.[0];if(!w)return;const M=new FileReader;M.onloadend=()=>{const E=M.result;r(E)},M.readAsDataURL(w)},e[0]=r,e[1]=d):d=e[1];const f=d;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l.current?.click()},e[2]=h):h=e[2];const m=h,g=`relative ${a} shrink-0 cursor-pointer group`;let y;e[3]!==f?(y=p.jsx("input",{type:"file",ref:l,className:"hidden",accept:"image/*",onChange:f}),e[3]=f,e[4]=y):y=e[4];let x;e[5]!==s||e[6]!==c||e[7]!==n?(x=n?p.jsx("img",{src:n,alt:s||"Avatar",className:"w-full h-full object-cover"}):p.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:p.jsx(ho,{className:c})}),e[5]=s,e[6]=c,e[7]=n,e[8]=x):x=e[8];const b=`${u} text-white`;let k;e[9]!==b?(k=p.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center rounded-xl",children:p.jsx(Kp,{className:b})}),e[9]=b,e[10]=k):k=e[10];let S;e[11]!==x||e[12]!==k?(S=p.jsxs("div",{className:"h-full w-full rounded-xl border border-border bg-muted/20 overflow-hidden relative",children:[x,k]}),e[11]=x,e[12]=k,e[13]=S):S=e[13];let v;return e[14]!==g||e[15]!==y||e[16]!==S?(v=p.jsxs("div",{className:g,onClick:m,children:[y,S]}),e[14]=g,e[15]=y,e[16]=S,e[17]=v):v=e[17],v}function xg(t){const e=j.c(57),{providerId:n,assistantId:r,onBack:s}=t,i=ro().location.href,l=il();let a;e[0]!==s||e[1]!==l?(a=s??(()=>l.history.back()),e[0]=s,e[1]=l,e[2]=a):a=e[2];const c=a,{locator:u}=Hp();let d;e[3]!==r||e[4]!==u?(d=Vp.assistantChatActiveThread(u,r),e[3]=r,e[4]=u,e[5]=d):d=e[5];const[f,h]=Fp(d,bg),m=n||kt;let g;e[6]!==m?(g=nt(m),e[6]=m,e[7]=g):g=e[7];const y=g,x=dl(n,"ASSISTANT",r,y),b=oo(n,"ASSISTANT",y),k=b.update.isPending,[S,v]=N.useState(x?.model.id&&x?.gateway_id?"chat":"edit");let C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=up(Wp),e[8]=C):C=e[8];const w=x??void 0;let M;e[9]!==w?(M={resolver:C,values:w},e[9]=w,e[10]=M):M=e[10];const E=fu(M);let A;e[11]!==b.update||e[12]!==r||e[13]!==E?(A=E.handleSubmit(async J=>{const K=await b.update.mutateAsync({id:r,data:J});E.reset(K),v("chat")}),e[11]=b.update,e[12]=r,e[13]=E,e[14]=A):A=e[14];const D=A;if(!x){let J;e[15]===Symbol.for("react.memo_cache_sentinel")?(J=p.jsx(ya,{}),e[15]=J):J=e[15];let K;e[16]===Symbol.for("react.memo_cache_sentinel")?(K=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(Tr,{title:"Assistant not found",description:"This assistant may have been deleted or you may not have access to it."})}),e[16]=K):K=e[16];let le;return e[17]!==c?(le=p.jsx(pr,{children:p.jsx(N.Suspense,{fallback:J,children:p.jsx(On,{onBack:c,children:K})})}),e[17]=c,e[18]=le):le=e[18],le}let _;e[19]===Symbol.for("react.memo_cache_sentinel")?(_=p.jsx(ya,{}),e[19]=_):_=e[19];let B;e[20]!==x.avatar||e[21]!==x.title?(B=p.jsx("div",{className:"h-6 w-6 min-w-6 rounded-lg border border-border bg-muted/20 overflow-hidden shrink-0",children:x.avatar?p.jsx("img",{src:x.avatar,alt:x.title,className:"h-full w-full object-cover"}):p.jsx("div",{className:"h-full w-full flex items-center justify-center text-muted-foreground",children:p.jsx(ho,{size:12,className:"text-muted-foreground"})})}),e[20]=x.avatar,e[21]=x.title,e[22]=B):B=e[22];let z;e[23]!==x.title?(z=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:x.title}),e[23]=x.title,e[24]=z):z=e[24];let R;e[25]!==x.description?(R=x.description?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),p.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:x.description})]}):null,e[25]=x.description,e[26]=R):R=e[26];let T;e[27]!==z||e[28]!==R?(T=p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[z,R]}),e[27]=z,e[28]=R,e[29]=T):T=e[29];let L;e[30]!==B||e[31]!==T?(L=p.jsx(pl,{children:p.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[B,T]})}),e[30]=B,e[31]=T,e[32]=L):L=e[32];const P=x.avatar??"assistant";let U;e[33]!==x.title||e[34]!==P||e[35]!==i?(U=p.jsx(lo,{title:x.title,url:i,icon:P}),e[33]=x.title,e[34]=P,e[35]=i,e[36]=U):U=e[36];let X;e[37]!==E.formState.isDirty||e[38]!==k||e[39]!==S||e[40]!==D||e[41]!==h?(X=S==="chat"?p.jsxs(p.Fragment,{children:[p.jsx(Xe,{children:p.jsxs(Qe,{children:[p.jsx(Ze,{asChild:!0,children:p.jsx(ue,{type:"button",onClick:()=>h(crypto.randomUUID()),"aria-label":"New thread",variant:"outline",size:"icon",className:"size-7 border border-input",children:p.jsx(ao,{size:16})})}),p.jsx(et,{children:"New thread"})]})}),p.jsx(Xe,{children:p.jsxs(Qe,{children:[p.jsx(Ze,{asChild:!0,children:p.jsx(ue,{type:"button",onClick:()=>v("edit"),"aria-label":"Edit",variant:"outline",size:"icon",className:"size-7 border border-input",children:p.jsx(Ru,{size:16})})}),p.jsx(et,{children:"Edit"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:k,onClick:()=>v("chat"),"aria-label":"Cancel",children:p.jsx(uo,{size:14})})})}),p.jsx(et,{side:"bottom",children:"Cancel"})]})}),p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:!E.formState.isDirty||k,onClick:()=>{D()},"aria-label":"Save",children:k?p.jsx(nn,{size:14,className:"animate-spin"}):p.jsx(fo,{size:14})})})}),p.jsx(et,{side:"bottom",children:"Save"})]})})]}),e[37]=E.formState.isDirty,e[38]=k,e[39]=S,e[40]=D,e[41]=h,e[42]=X):X=e[42];let H;e[43]!==U||e[44]!==X?(H=p.jsxs(co,{children:[U,X]}),e[43]=U,e[44]=X,e[45]=H):H=e[45];let W;e[46]!==f||e[47]!==x||e[48]!==E||e[49]!==S||e[50]!==h?(W=p.jsx("div",{className:"h-full",children:p.jsx(gg,{activeThreadId:f,setActiveThreadId:h,mode:S,assistant:x,form:E},E.formState.submitCount)}),e[46]=f,e[47]=x,e[48]=E,e[49]=S,e[50]=h,e[51]=W):W=e[51];let Q;return e[52]!==c||e[53]!==L||e[54]!==H||e[55]!==W?(Q=p.jsx(pr,{children:p.jsx(N.Suspense,{fallback:_,children:p.jsxs(On,{onBack:c,children:[L,H,W]})})}),e[52]=c,e[53]=L,e[54]=H,e[55]=W,e[56]=Q):Q=e[56],Q}function bg(t){return t||crypto.randomUUID()}function kg(t){const e=j.c(6),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=_n(s).connectionId??kt;if(!i||i===kt){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(Tr,{title:"Assistant not found",description:"Missing connection information in the current route."})}),e[1]=a):a=e[1],a}let l;return e[2]!==i||e[3]!==n||e[4]!==r?(l=p.jsx(xg,{providerId:i,assistantId:n,onBack:r}),e[2]=i,e[3]=n,e[4]=r,e[5]=l):l=e[5],l}dp({title:Vo().min(1),description:Vo().nullable(),body:Vo()});function Uo(t){for(const e of t.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function vg(){const t=window.location.pathname.split("/").filter(Boolean),e=t.findIndex(r=>r==="mcps"),n=e>=0?t[e+1]:void 0;return n?decodeURIComponent(n):void 0}function wg(t){const e=j.c(13),{form:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==n.control?(s=p.jsxs("div",{className:"flex flex-col gap-4",children:[r,p.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[p.jsx(gt,{control:n.control,name:"title",render:Ng}),p.jsx(gt,{control:n.control,name:"description",render:Cg})]})]}),e[1]=n.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=p.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]!==n.control?(l=p.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,p.jsx(gt,{control:n.control,name:"body",render:Sg})]}),e[5]=n.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=p.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]!==n||e[11]!==a?(c=p.jsx(xu,{...n,children:a}),e[10]=n,e[11]=a,e[12]=c):c=e[12],c}function Sg(t){const{field:e}=t;return p.jsx(Bt,{children:p.jsx(Bn,{children:p.jsx(cs,{...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 Cg(t){const{field:e}=t;return p.jsxs(Bt,{children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),p.jsx(Bn,{children:p.jsx(Or,{...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 Ng(t){const{field:e}=t;return p.jsxs(Bt,{children:[p.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),p.jsx(Bn,{children:p.jsx(Or,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function Eg(t){const e=j.c(51),{providerId:n,promptId:r,onBack:s}=t,i=ro().location.href,l=n||kt;let a;e[0]!==l?(a=nt(l),e[0]=l,e[1]=a):a=e[1];const c=a,u=dl(n,"PROMPT",r,c),d=oo(n,"PROMPT",c),f=d.update.isPending;let h;e[2]!==u?(h=u?{title:u.title,description:u.description??null,body:Uo(u)}:void 0,e[2]=u,e[3]=h):h=e[3];let m;e[4]!==h?(m={values:h},e[4]=h,e[5]=m):m=e[5];const g=fu(m);let y;e[6]!==g||e[7]!==u?(y=()=>{u&&g.reset({title:u.title,description:u.description??null,body:Uo(u)})},e[6]=g,e[7]=u,e[8]=y):y=e[8];const x=y;let b;e[9]!==d.update||e[10]!==g||e[11]!==r?(b=g.handleSubmit(async W=>{const Q=await d.update.mutateAsync({id:r,data:{title:W.title,description:W.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:W.body}}]}});g.reset({title:Q.title,description:Q.description??null,body:Uo(Q)})}),e[9]=d.update,e[10]=g,e[11]=r,e[12]=b):b=e[12];const k=b;if(!u){let W;return e[13]===Symbol.for("react.memo_cache_sentinel")?(W=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(Tr,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=W):W=e[13],W}let S;e[14]!==u.title?(S=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:u.title}),e[14]=u.title,e[15]=S):S=e[15];let v;e[16]!==u.description?(v=u.description?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),p.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:u.description})]}):null,e[16]=u.description,e[17]=v):v=e[17];let C;e[18]!==S||e[19]!==v?(C=p.jsx(pl,{children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[S,v]})}),e[18]=S,e[19]=v,e[20]=C):C=e[20];let w;e[21]!==u.title||e[22]!==i?(w=p.jsx(lo,{title:u.title,url:i,icon:"description"}),e[21]=u.title,e[22]=i,e[23]=w):w=e[23];const M=!g.formState.isDirty||f;let E;e[24]===Symbol.for("react.memo_cache_sentinel")?(E=p.jsx(uo,{size:14}),e[24]=E):E=e[24];let A;e[25]!==x||e[26]!==M?(A=p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:M,onClick:x,"aria-label":"Cancel",children:E})})}),e[25]=x,e[26]=M,e[27]=A):A=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=p.jsx(et,{side:"bottom",children:"Cancel"}),e[28]=D):D=e[28];let _;e[29]!==A?(_=p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[A,D]})}),e[29]=A,e[30]=_):_=e[30];const B=!g.formState.isDirty||f;let z;e[31]!==k?(z=()=>{k()},e[31]=k,e[32]=z):z=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=p.jsx(fo,{size:14}),e[33]=R):R=e[33];let T;e[34]!==B||e[35]!==z?(T=p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:B,onClick:z,"aria-label":"Save",children:R})})}),e[34]=B,e[35]=z,e[36]=T):T=e[36];let L;e[37]===Symbol.for("react.memo_cache_sentinel")?(L=p.jsx(et,{side:"bottom",children:"Save"}),e[37]=L):L=e[37];let P;e[38]!==T?(P=p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[T,L]})}),e[38]=T,e[39]=P):P=e[39];let U;e[40]!==w||e[41]!==_||e[42]!==P?(U=p.jsxs(co,{children:[w,_,P]}),e[40]=w,e[41]=_,e[42]=P,e[43]=U):U=e[43];let X;e[44]!==g?(X=p.jsx("div",{className:"h-full",children:p.jsx(wg,{form:g})}),e[44]=g,e[45]=X):X=e[45];let H;return e[46]!==s||e[47]!==U||e[48]!==X||e[49]!==C?(H=p.jsxs(On,{onBack:s,children:[C,U,X]}),e[46]=s,e[47]=U,e[48]=X,e[49]=C,e[50]=H):H=e[50],H}function Tg(t){const e=j.c(5),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=vg()??kt,e[0]=s):s=e[0];const o=s;if(!o||o===kt){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(Tr,{title:"Prompt not found",description:"Missing connection information in the current route."})}),e[1]=l):l=e[1],l}let i;return e[2]!==n||e[3]!==r?(i=p.jsx(pr,{children:p.jsx(N.Suspense,{fallback:null,children:p.jsx(Eg,{providerId:o,promptId:n,onBack:r})})}),e[2]=n,e[3]=r,e[4]=i):i=e[4],i}const Mg=fp("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 Og(t){const e=j.c(10);let n,r,s;e[0]!==t?({className:n,variant:s,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);let o;e[4]!==n||e[5]!==s?(o=Z(Mg({variant:s}),n),e[4]=n,e[5]=s,e[6]=o):o=e[6];let i;return e[7]!==r||e[8]!==o?(i=p.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function Ag(t){const e=j.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=Z("line-clamp-1 min-h-4 font-medium tracking-tight",n),e[3]=n,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=p.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function Ig(t){const e=j.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=Z("text-muted-foreground leading-relaxed",n),e[3]=n,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=p.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const jg=t=>t.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function Rg(t){const e=j.c(13),{toolName:n,connectionId:r,onBack:s}=t,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=em(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=p.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?p.jsx(tm,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):p.jsx(nm,{hasReadme:!1})}),e[4]=c.supportsOAuth,e[5]=s,e[6]=f):f=e[6],f}const u=`${r}:${n}`;let d;return e[7]!==r||e[8]!==l||e[9]!==s||e[10]!==u||e[11]!==n?(d=p.jsx(Dg,{toolName:n,connectionId:r,mcpProxyUrl:l,onBack:s},u),e[7]=r,e[8]=l,e[9]=s,e[10]=u,e[11]=n,e[12]=d):d=e[12],d}function Dg({toolName:t,connectionId:e,mcpProxyUrl:n,onBack:r}){const o=ro().location.href,{replayId:i}=hp({strict:!1}),l=(()=>{if(!i)return null;const T=`replay-${i}`,L=sessionStorage.getItem(T);if(!L)return null;sessionStorage.removeItem(T);try{return JSON.parse(L)}catch{return null}})(),a=(()=>{if(!l)return null;const T={};for(const[L,P]of Object.entries(l))P!==null&&typeof P=="object"?T[L]=JSON.stringify(P,null,2):T[L]=P;return T})(),[c,u]=N.useState(a??{}),[d,f]=N.useState(l?JSON.stringify(l,null,2):"{}"),[h,m]=N.useState(null),[g,y]=N.useState(null),[x,b]=N.useState(!1),[k,S]=N.useState(null),v=fl(e),C=yl({url:n.href});N.useEffect(()=>{C.error&&console.error("MCP Error:",C.error)},[C.error]);const w=C.tools?.find(T=>T.name===t),M=w?.inputSchema?.properties,E=M?Object.keys(M):[],A=E.length>0,D={};if(A&&w?.inputSchema?.properties)for(const T of E)D[T]=w.inputSchema.required?.includes(T)?"":void 0;const _=T=>Object.prototype.hasOwnProperty.call(c,T),B=async()=>{b(!0),y(null),m(null),S(null);const T=performance.now(),L=nt(e);try{const P=A?{...D,...c}:(()=>{const J=d.trim();if(!J)return{};const K=JSON.parse(J);if(K&&typeof K=="object")return K;throw new Error("Raw JSON input must be an object.")})();A&&w?.inputSchema?.properties&&Object.entries(w.inputSchema.properties).forEach(([J,K])=>{if((K.type==="object"||K.type==="array")&&typeof P[J]=="string")try{P[J]=JSON.parse(P[J])}catch{}});const U=await L(t,P),X=performance.now(),H=Math.round(X-T);m(U);const W=JSON.stringify(U),Q=new TextEncoder().encode(W).length;S({duration:`${H}ms`,bytes:`${Q} bytes`,tokens:`~${Math.ceil(Q/4)} tokens`,cost:"$0.0000"})}catch(P){const U=P instanceof Error?P.message:String(P);y(U||"Unknown error occurred");const X=performance.now();S({duration:`${Math.round(X-T)}ms`})}finally{b(!1)}},z=(T,L)=>{u(P=>({...P,[T]:L}))},R=()=>{m(null),y(null),S(null)};return p.jsxs(On,{onBack:r,children:[p.jsx(co,{children:p.jsx(lo,{title:w?.name??jg(t),url:o,icon:"build"})}),p.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[p.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:p.jsxs("div",{className:"flex-1 overflow-auto",children:[p.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(io,{icon:v?.icon||null,name:v?.title||t,size:"sm",className:"shadow-sm shrink-0"}),p.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:t}),p.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[C.state==="ready"?p.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):C.state==="connecting"?p.jsx(nn,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):p.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),p.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:C.state.replace("_"," ")})]})]}),p.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:w?.description||"No description available"})]})}),p.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),w?.inputSchema?.required&&w.inputSchema.required.length>0&&p.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),p.jsx("div",{className:"space-y-4",children:A&&w?.inputSchema?.properties?Object.entries(w.inputSchema.properties).map(([T,L])=>p.jsxs("div",{className:"space-y-2",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[T,w.inputSchema?.required?.includes(T)&&p.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),p.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:L.type})]}),L.description&&p.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:L.description}),L.type==="object"||L.type==="array"?p.jsx(cs,{className:"font-mono text-xs",value:_(T)?c[T]??"":D[T]??"",onChange:P=>z(T,P.target.value),placeholder:`Enter ${T} as JSON...`,rows:3}):p.jsx(Or,{value:_(T)?c[T]??"":D[T]??"",onChange:P=>z(T,P.target.value),placeholder:`Enter ${T}...`})]},T)):w?.inputSchema&&!A?p.jsxs("div",{className:"space-y-2",children:[p.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),p.jsx(cs,{className:"font-mono text-xs min-h-[120px]",value:d,onChange:T=>f(T.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):p.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:p.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),p.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[p.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:[p.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),k&&p.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Gp,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:k.duration})]}),k.tokens&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Mu,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:k.tokens})]}),k.bytes&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(ju,{className:"h-3 w-3 text-muted-foreground"}),p.jsx("span",{className:"font-mono text-foreground",children:k.bytes})]}),k.cost&&p.jsx("div",{className:"flex items-center gap-1.5",children:p.jsx("span",{className:"font-mono text-foreground",children:k.cost})})]})]}),p.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:p.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[p.jsx(ue,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:B,disabled:x,children:x?p.jsxs(p.Fragment,{children:[p.jsx(nn,{size:14,className:"animate-spin"}),"Executing..."]}):p.jsxs(p.Fragment,{children:[p.jsx(ml,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),p.jsx(Xe,{children:p.jsxs(Qe,{children:[p.jsx(Ze,{asChild:!0,children:p.jsx(ue,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:R,disabled:!h&&!g,children:p.jsx(gl,{size:14})})}),p.jsx(et,{children:p.jsx("p",{children:"Clear results"})})]})})]})}),g&&p.jsx("div",{className:"px-6 py-4 bg-background",children:p.jsx(Og,{variant:"destructive",children:p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Jp,{className:"h-4 w-4"}),p.jsx(Ag,{className:"mb-0",children:"Execution Failed"})]}),p.jsx(Ig,{className:"text-xs text-destructive",children:g})]})})}),p.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?p.jsxs(p.Fragment,{children:[p.jsx(om,{jsonString:JSON.stringify(h,null,2),padding:"1.5rem"}),p.jsx(ue,{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)),hu.success("Copied to clipboard")},children:p.jsx(Qp,{className:"h-3.5 w-3.5"})})]}):p.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[p.jsx(Yp,{className:"h-12 w-12 mb-3 opacity-40"}),p.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function Pg(t){const e=j.c(7),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const i=_n(s).connectionId??kt;if(!fl(i)){let u;return e[1]===Symbol.for("react.memo_cache_sentinel")?(u=p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[p.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),p.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=u):u=e[1],u}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsx(nn,{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]!==n?(c=p.jsx(N.Suspense,{fallback:a,children:p.jsx(Rg,{toolName:n,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=n,e[6]=c):c=e[6],c}const Na=t=>{let e;const n=new Set,r=(c,u)=>{const d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){const f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(h=>h(e,f))}},s=()=>e,l={setState:r,getState:s,getInitialState:()=>a,subscribe:c=>(n.add(c),()=>n.delete(c))},a=e=t(r,s,l);return l},vl=(t=>t?Na(t):Na),Lg=t=>t;function Ei(t,e=Lg){const n=ee.useSyncExternalStore(t.subscribe,ee.useCallback(()=>e(t.getState()),[t,e]),ee.useCallback(()=>e(t.getInitialState()),[t,e]));return ee.useDebugValue(n),n}const $g=t=>{const e=vl(t),n=r=>Ei(e,r);return Object.assign(n,e),n},_g=(t=>$g);function $u(t,e){let n;try{n=t()}catch{return}return{getItem:s=>{var o;const i=a=>a===null?null:JSON.parse(a,void 0),l=(o=n.getItem(s))!=null?o:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,o)=>n.setItem(s,JSON.stringify(o,void 0)),removeItem:s=>n.removeItem(s)}}const Ti=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(r){return Ti(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Ti(r)(n)}}}},zg=(t,e)=>(n,r,s)=>{let o={storage:$u(()=>localStorage),partialize:g=>g,version:0,merge:(g,y)=>({...y,...g}),...e},i=!1;const l=new Set,a=new Set;let c=o.storage;if(!c)return t((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...g)},r,s);const u=()=>{const g=o.partialize({...r()});return c.setItem(o.name,{state:g,version:o.version})},d=s.setState;s.setState=(g,y)=>(d(g,y),u());const f=t((...g)=>(n(...g),u()),r,s);s.getInitialState=()=>f;let h;const m=()=>{var g,y;if(!c)return;i=!1,l.forEach(b=>{var k;return b((k=r())!=null?k:f)});const x=((y=o.onRehydrateStorage)==null?void 0:y.call(o,(g=r())!=null?g:f))||void 0;return Ti(c.getItem.bind(c))(o.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==o.version){if(o.migrate){const k=o.migrate(b.state,b.version);return k instanceof Promise?k.then(S=>[!0,S]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,b.state];return[!1,void 0]}).then(b=>{var k;const[S,v]=b;if(h=o.merge(v,(k=r())!=null?k:f),n(h,!0),S)return u()}).then(()=>{x?.(h,void 0),h=r(),i=!0,a.forEach(b=>b(h))}).catch(b=>{x?.(void 0,b)})};return s.persist={setOptions:g=>{o={...o,...g},g.storage&&(c=g.storage)},clearStorage:()=>{c?.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>m(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(a.add(g),()=>{a.delete(g)})},o.skipHydration||m(),h||f},_u=zg,{useSyncExternalStoreWithSelector:Bg}=pp,Fg=t=>t;function Vg(t,e=Fg,n){const r=Bg(t.subscribe,t.getState,t.getInitialState,e,n);return ee.useDebugValue(r),r}const Ea=t=>Symbol.iterator in t,Ta=t=>"entries"in t,Ma=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),r=e instanceof Map?e:new Map(e.entries());if(n.size!==r.size)return!1;for(const[s,o]of n)if(!r.has(s)||!Object.is(o,r.get(s)))return!1;return!0},Hg=(t,e)=>{const n=t[Symbol.iterator](),r=e[Symbol.iterator]();let s=n.next(),o=r.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=n.next(),o=r.next()}return!!s.done&&!!o.done};function Wg(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:Ea(t)&&Ea(e)?Ta(t)&&Ta(e)?Ma(t,e):Hg(t,e):Ma({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function Ug(t,e="Output"){if(!t)return`interface ${e} {}`;function n(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?`${n(l)}[]`:"unknown[]"}case"object":return s(o);default:return o.anyOf?o.anyOf.map(n).join(" | "):o.oneOf?o.oneOf.map(n).join(" | "):o.allOf?o.allOf.map(n).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
- ${Object.entries(i).map(([c,u])=>{const d=l.has(c)?"":"?";return`${u.description?` /** ${u.description} */
3
- `:""} ${c}${d}: ${n(u)};`}).join(`
4
- `)}
5
- }`}return`interface ${e} ${n(t)}`}function qo(t,e){const n=t.trim();return e.some(s=>s.name.toLowerCase()===n.toLowerCase())?`${n}_${Math.random().toString(36).substring(2,6)}`:n}function qg(t,e){const n=t.match(/interface\s+Input\s*\{/);if(!n||n.index===void 0)return`${e}
6
-
7
- ${t.trimStart()}`;const r=n.index,s=r+n[0].length-1;let o=1,i=s+1;for(;i<t.length&&o>0;)t[i]==="{"?o++:t[i]==="}"&&o--,i++;return t.slice(0,r)+e+t.slice(i)}function Ko(t,e){switch(t){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...Up,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${t}`)}}const zu=N.createContext(null),Kg=t=>vl()(_u(e=>({...t,actions:{setIsAddingStep:n=>e(r=>({...r,isAddingStep:n})),setCurrentStepTab:n=>e(r=>({...r,currentStepTab:n})),setToolAction:n=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.map(s=>"toolName"in s.action&&s.action.toolName===n.toolName?{...s,action:n}:s)}})),appendStep:({step:n,type:r})=>e(s=>{const o=n??Ko(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:n=>e(r=>({workflow:{...r.workflow,steps:r.workflow.steps.filter(s=>s.name!==n)}})),duplicateStep:n=>e(r=>{const s=r.workflow.steps.findIndex(a=>a.name===n);if(s===-1)return r;const o=r.workflow.steps[s];if(!o)return r;const i={...o,name:qo(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:n=>e(r=>({...r,currentStepName:n})),updateStep:(n,r)=>e(s=>({...s,workflow:{...s.workflow,steps:s.workflow.steps.map(o=>o.name===n?{...o,...r}:o)}})),setTrackingExecutionId:n=>e(r=>({...r,trackingExecutionId:n})),resetToOriginalWorkflow:()=>e(n=>({...n,workflow:n.originalWorkflow})),startAddingStep:n=>e(r=>({...r,isAddingStep:!0,addingStepType:n})),cancelAddingStep:()=>e(n=>({...n,isAddingStep:!1,addingStepType:null,selectedParentSteps:[]})),toggleParentStepSelection:n=>e(r=>{const s=r.selectedParentSteps.includes(n);return{...r,selectedParentSteps:s?r.selectedParentSteps.filter(o=>o!==n):[...r.selectedParentSteps,n]}}),confirmAddCodeStep:()=>e(n=>{const{selectedParentSteps:r,addingStepType:s,workflow:o}=n;if(s!=="code"||r.length===0)return n;const i={};for(const d of r)i[d]=`@${d}`;const l={};for(const d of r){const f=o.steps.find(h=>h.name===d);f?.outputSchema&&(l[d]=f.outputSchema)}const a=Object.keys(l).length>0?{type:"object",properties:l,required:Object.keys(l)}:void 0;let c=Ko("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const d=Ug(a,"Input"),f=c.action,h=qg(f.code,d);c={...c,action:{...f,code:h}}}const u=qo(c.name,o.steps);return{...n,isAddingStep:!1,addingStepType:null,selectedParentSteps:[],workflow:{...o,steps:[...o.steps,{...c,name:u}]},currentStepName:u}}),addToolStep:()=>e(n=>{let r=Ko("tool",Number((Math.random()*1e6).toFixed(0)));const s=qo(r.name,n.workflow.steps);return{...n,isAddingStep:!1,addingStepType:null,workflow:{...n.workflow,steps:[...n.workflow.steps,{...r,name:s}]},currentStepName:s}}),setOriginalWorkflow:n=>e(r=>({...r,originalWorkflow:n})),setWorkflow:n=>e(r=>({...r,workflow:n})),startReplacingTool:n=>e(r=>({...r,replacingToolInfo:{toolName:n}})),cancelReplacingTool:()=>e(n=>({...n,replacingToolInfo:null})),setSelectedGatewayId:n=>e(r=>({...r,selectedGatewayId:n}))}}),{name:`workflow-store-${encodeURIComponent(t.workflow.id)}`,storage:$u(()=>localStorage),version:1,partialize:e=>({workflow:e.workflow,trackingExecutionId:e.trackingExecutionId,currentStepName:e.currentStepName,currentStepTab:e.currentStepTab,originalWorkflow:e.originalWorkflow,isAddingStep:e.isAddingStep,addingStepType:e.addingStepType,selectedParentSteps:e.selectedParentSteps,replacingToolInfo:e.replacingToolInfo,selectedGatewayId:e.selectedGatewayId})}));function Jg(t){const e=j.c(8),{children:n,initialState:r}=t,s=lm();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>Kg({workflow:r.workflow,originalWorkflow: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]=N.useState(o);let l;return e[5]!==n||e[6]!==i?(l=p.jsx(zu.Provider,{value:i,children:n}),e[5]=n,e[6]=i,e[7]=l):l=e[7],l}function Vn(t,e){const n=N.useContext(zu);if(!n)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return Vg(n,t,Wg)}function Hn(){return Vn(Gg)}function Gg(t){return t.workflow}function Oe(){return Vn(Yg)}function Yg(t){return t.actions}function Bu(){const t=Ir();return Vn(Xg)??t[0]?.name}function Xg(t){return t.currentStepName}function Ar(){const t=j.c(5),e=Bu(),n=Ir();let r;if(t[0]!==e||t[1]!==n){let o;t[3]!==e?(o=i=>i.name===e,t[3]=e,t[4]=o):o=t[4],r=n.find(o),t[0]=e,t[1]=n,t[2]=r}else r=t[2];const s=r;return s||n[0]}function Ir(){return Hn().steps}function Fu(){const t=j.c(4),e=Hn(),n=Vn(Qg);let r;t[0]!==e?(r=JSON.stringify(e),t[0]=e,t[1]=r):r=t[1];let s;return t[2]!==n?(s=JSON.stringify(n),t[2]=n,t[3]=s):s=t[3],r!==s}function Qg(t){return t.originalWorkflow}function we(){return Vn(Zg)}function Zg(t){return t.trackingExecutionId}function Wn(){return Vn(e1)}function e1(t){return t.selectedGatewayId}function Oa(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function t1(t){if(Array.isArray(t))return t}function n1(t,e,n){return(e=c1(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function r1(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,s,o,i,l=[],a=!0,c=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(a=(r=o.call(n)).done)&&(l.push(r.value),l.length!==e);a=!0);}catch(u){c=!0,s=u}finally{try{if(!a&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw s}}return l}}function s1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Aa(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Ia(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Aa(Object(n),!0).forEach(function(r){n1(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Aa(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function o1(t,e){if(t==null)return{};var n,r,s=i1(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(s[n]=t[n])}return s}function i1(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function l1(t,e){return t1(t)||r1(t,e)||u1(t,e)||s1()}function a1(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function c1(t){var e=a1(t,"string");return typeof e=="symbol"?e:e+""}function u1(t,e){if(t){if(typeof t=="string")return Oa(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Oa(t,e):void 0}}function d1(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ja(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),n.push.apply(n,r)}return n}function Ra(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ja(Object(n),!0).forEach(function(r){d1(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ja(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function f1(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r){return e.reduceRight(function(s,o){return o(s)},r)}}function Qn(t){return function e(){for(var n=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=t.length?t.apply(this,s):function(){for(var i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return e.apply(n,[].concat(s,l))}}}function ds(t){return{}.toString.call(t).includes("Object")}function h1(t){return!Object.keys(t).length}function mr(t){return typeof t=="function"}function p1(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function m1(t,e){return ds(e)||Rt("changeType"),Object.keys(e).some(function(n){return!p1(t,n)})&&Rt("changeField"),e}function g1(t){mr(t)||Rt("selectorType")}function y1(t){mr(t)||ds(t)||Rt("handlerType"),ds(t)&&Object.values(t).some(function(e){return!mr(e)})&&Rt("handlersType")}function x1(t){t||Rt("initialIsRequired"),ds(t)||Rt("initialType"),h1(t)&&Rt("initialContent")}function b1(t,e){throw new Error(t[e]||t.default)}var k1={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Rt=Qn(b1)(k1),Br={changes:m1,selector:g1,handler:y1,initial:x1};function v1(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Br.initial(t),Br.handler(e);var n={current:t},r=Qn(C1)(n,e),s=Qn(S1)(n),o=Qn(Br.changes)(t),i=Qn(w1)(n);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Br.selector(c),c(n.current)}function a(c){f1(r,s,o,i)(c)}return[l,a]}function w1(t,e){return mr(e)?e(t.current):e}function S1(t,e){return t.current=Ra(Ra({},t.current),e),e}function C1(t,e,n){return mr(e)?e(t.current):Object.keys(n).forEach(function(r){var s;return(s=e[r])===null||s===void 0?void 0:s.call(e,t.current[r])}),n}var N1={create:v1},E1={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function T1(t){return function e(){for(var n=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=t.length?t.apply(this,s):function(){for(var i=arguments.length,l=new Array(i),a=0;a<i;a++)l[a]=arguments[a];return e.apply(n,[].concat(s,l))}}}function M1(t){return{}.toString.call(t).includes("Object")}function O1(t){return t||Da("configIsRequired"),M1(t)||Da("configType"),t.urls?(A1(),{paths:{vs:t.urls.monacoBase}}):t}function A1(){console.warn(Vu.deprecation)}function I1(t,e){throw new Error(t[e]||t.default)}var Vu={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
9
- You are using deprecated way of configuration.
10
-
11
- Instead of using
12
- monaco.config({ urls: { monacoBase: '...' } })
13
- use
14
- monaco.config({ paths: { vs: '...' } })
15
-
16
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
17
- `},Da=T1(I1)(Vu),j1={config:O1},R1=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return function(s){return n.reduceRight(function(o,i){return i(o)},s)}};function Hu(t,e){return Object.keys(e).forEach(function(n){e[n]instanceof Object&&t[n]&&Object.assign(e[n],Hu(t[n],e[n]))}),Ia(Ia({},t),e)}var D1={type:"cancelation",msg:"operation is manually canceled"};function Jo(t){var e=!1,n=new Promise(function(r,s){t.then(function(o){return e?s(D1):r(o)}),t.catch(s)});return n.cancel=function(){return e=!0},n}var P1=["monaco"],L1=N1.create({config:E1,isInitialized:!1,resolve:null,reject:null,monaco:null}),Wu=l1(L1,2),jr=Wu[0],po=Wu[1];function $1(t){var e=j1.config(t),n=e.monaco,r=o1(e,P1);po(function(s){return{config:Hu(s.config,r),monaco:n}})}function _1(){var t=jr(function(e){var n=e.monaco,r=e.isInitialized,s=e.resolve;return{monaco:n,isInitialized:r,resolve:s}});if(!t.isInitialized){if(po({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Jo(Go);if(window.monaco&&window.monaco.editor)return Uu(window.monaco),t.resolve(window.monaco),Jo(Go);R1(z1,F1)(V1)}return Jo(Go)}function z1(t){return document.body.appendChild(t)}function B1(t){var e=document.createElement("script");return t&&(e.src=t),e}function F1(t){var e=jr(function(r){var s=r.config,o=r.reject;return{config:s,reject:o}}),n=B1("".concat(e.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=e.reject,n}function V1(){var t=jr(function(n){var r=n.config,s=n.resolve,o=n.reject;return{config:r,resolve:s,reject:o}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(n){var r=n.m||n;Uu(r),t.resolve(r)},function(n){t.reject(n)})}function Uu(t){jr().monaco||po({monaco:t})}function H1(){return jr(function(t){var e=t.monaco;return e})}var Go=new Promise(function(t,e){return po({resolve:t,reject:e})}),mo={config:$1,init:_1,__getMonacoInstance:H1},W1={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Yo=W1,U1={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},q1=U1;function K1({children:t}){return ee.createElement("div",{style:q1.container},t)}var J1=K1,G1=J1;function Y1({width:t,height:e,isEditorReady:n,loading:r,_ref:s,className:o,wrapperProps:i}){return ee.createElement("section",{style:{...Yo.wrapper,width:t,height:e},...i},!n&&ee.createElement(G1,null,r),ee.createElement("div",{ref:s,style:{...Yo.fullWidth,...!n&&Yo.hide},className:o}))}var X1=Y1,qu=N.memo(X1);function Q1(t){N.useEffect(t,[])}var Ku=Q1;function Z1(t,e,n=!0){let r=N.useRef(!0);N.useEffect(r.current||!n?()=>{r.current=!1}:t,e)}var Le=Z1;function rr(){}function Cn(t,e,n,r){return e0(t,r)||t0(t,e,n,r)}function e0(t,e){return t.editor.getModel(Ju(t,e))}function t0(t,e,n,r){return t.editor.createModel(e,n,r?Ju(t,r):void 0)}function Ju(t,e){return t.Uri.parse(e)}function n0({original:t,modified:e,language:n,originalLanguage:r,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:i,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:a=!1,theme:c="light",loading:u="Loading...",options:d={},height:f="100%",width:h="100%",className:m,wrapperProps:g={},beforeMount:y=rr,onMount:x=rr}){let[b,k]=N.useState(!1),[S,v]=N.useState(!0),C=N.useRef(null),w=N.useRef(null),M=N.useRef(null),E=N.useRef(x),A=N.useRef(y),D=N.useRef(!1);Ku(()=>{let R=mo.init();return R.then(T=>(w.current=T)&&v(!1)).catch(T=>T?.type!=="cancelation"&&console.error("Monaco initialization: error:",T)),()=>C.current?z():R.cancel()}),Le(()=>{if(C.current&&w.current){let R=C.current.getOriginalEditor(),T=Cn(w.current,t||"",r||n||"text",o||"");T!==R.getModel()&&R.setModel(T)}},[o],b),Le(()=>{if(C.current&&w.current){let R=C.current.getModifiedEditor(),T=Cn(w.current,e||"",s||n||"text",i||"");T!==R.getModel()&&R.setModel(T)}},[i],b),Le(()=>{let R=C.current.getModifiedEditor();R.getOption(w.current.editor.EditorOption.readOnly)?R.setValue(e||""):e!==R.getValue()&&(R.executeEdits("",[{range:R.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),R.pushUndoStop())},[e],b),Le(()=>{C.current?.getModel()?.original.setValue(t||"")},[t],b),Le(()=>{let{original:R,modified:T}=C.current.getModel();w.current.editor.setModelLanguage(R,r||n||"text"),w.current.editor.setModelLanguage(T,s||n||"text")},[n,r,s],b),Le(()=>{w.current?.editor.setTheme(c)},[c],b),Le(()=>{C.current?.updateOptions(d)},[d],b);let _=N.useCallback(()=>{if(!w.current)return;A.current(w.current);let R=Cn(w.current,t||"",r||n||"text",o||""),T=Cn(w.current,e||"",s||n||"text",i||"");C.current?.setModel({original:R,modified:T})},[n,e,s,t,r,o,i]),B=N.useCallback(()=>{!D.current&&M.current&&(C.current=w.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...d}),_(),w.current?.editor.setTheme(c),k(!0),D.current=!0)},[d,c,_]);N.useEffect(()=>{b&&E.current(C.current,w.current)},[b]),N.useEffect(()=>{!S&&!b&&B()},[S,b,B]);function z(){let R=C.current?.getModel();l||R?.original?.dispose(),a||R?.modified?.dispose(),C.current?.dispose()}return ee.createElement(qu,{width:h,height:f,isEditorReady:b,loading:u,_ref:M,className:m,wrapperProps:g})}var r0=n0;N.memo(r0);function s0(t){let e=N.useRef();return N.useEffect(()=>{e.current=t},[t]),e.current}var o0=s0,Fr=new Map;function i0({defaultValue:t,defaultLanguage:e,defaultPath:n,value:r,language:s,path:o,theme:i="light",line:l,loading:a="Loading...",options:c={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:h="100%",height:m="100%",className:g,wrapperProps:y={},beforeMount:x=rr,onMount:b=rr,onChange:k,onValidate:S=rr}){let[v,C]=N.useState(!1),[w,M]=N.useState(!0),E=N.useRef(null),A=N.useRef(null),D=N.useRef(null),_=N.useRef(b),B=N.useRef(x),z=N.useRef(),R=N.useRef(r),T=o0(o),L=N.useRef(!1),P=N.useRef(!1);Ku(()=>{let H=mo.init();return H.then(W=>(E.current=W)&&M(!1)).catch(W=>W?.type!=="cancelation"&&console.error("Monaco initialization: error:",W)),()=>A.current?X():H.cancel()}),Le(()=>{let H=Cn(E.current,t||r||"",e||s||"",o||n||"");H!==A.current?.getModel()&&(d&&Fr.set(T,A.current?.saveViewState()),A.current?.setModel(H),d&&A.current?.restoreViewState(Fr.get(o)))},[o],v),Le(()=>{A.current?.updateOptions(c)},[c],v),Le(()=>{!A.current||r===void 0||(A.current.getOption(E.current.editor.EditorOption.readOnly)?A.current.setValue(r):r!==A.current.getValue()&&(P.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),A.current.pushUndoStop(),P.current=!1))},[r],v),Le(()=>{let H=A.current?.getModel();H&&s&&E.current?.editor.setModelLanguage(H,s)},[s],v),Le(()=>{l!==void 0&&A.current?.revealLine(l)},[l],v),Le(()=>{E.current?.editor.setTheme(i)},[i],v);let U=N.useCallback(()=>{if(!(!D.current||!E.current)&&!L.current){B.current(E.current);let H=o||n,W=Cn(E.current,r||t||"",e||s||"",H||"");A.current=E.current?.editor.create(D.current,{model:W,automaticLayout:!0,...c},u),d&&A.current.restoreViewState(Fr.get(H)),E.current.editor.setTheme(i),l!==void 0&&A.current.revealLine(l),C(!0),L.current=!0}},[t,e,n,r,s,o,c,u,d,i,l]);N.useEffect(()=>{v&&_.current(A.current,E.current)},[v]),N.useEffect(()=>{!w&&!v&&U()},[w,v,U]),R.current=r,N.useEffect(()=>{v&&k&&(z.current?.dispose(),z.current=A.current?.onDidChangeModelContent(H=>{P.current||k(A.current.getValue(),H)}))},[v,k]),N.useEffect(()=>{if(v){let H=E.current.editor.onDidChangeMarkers(W=>{let Q=A.current.getModel()?.uri;if(Q&&W.find(J=>J.path===Q.path)){let J=E.current.editor.getModelMarkers({resource:Q});S?.(J)}});return()=>{H?.dispose()}}return()=>{}},[v,S]);function X(){z.current?.dispose(),f?d&&Fr.set(o,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return ee.createElement(qu,{width:h,height:m,isEditorReady:v,loading:a,_ref:D,className:g,wrapperProps:y})}var l0=i0,a0=N.memo(l0),c0=a0;async function u0(t){const e=t.getModel();if(!e)throw new Error("[Monaco] No model found in editor");const n=e.getValue(),s=n.replace(/export default (async )?function/,"export default $1function __default")+`
18
- type __ExpandRecursively<T> = T extends (...args: infer A) => infer R
19
- ? (...args: __ExpandRecursively<A>) => __ExpandRecursively<R>
20
- : T extends object
21
- ? T extends infer O ? { [K in keyof O]: __ExpandRecursively<O[K]> } : never
22
- : T;
23
- type __InferredOutput = __ExpandRecursively<Awaited<ReturnType<typeof __default>>>;
24
- declare const __outputValue: __InferredOutput;
25
- `;e.setValue(s);const o=e.findMatches("__outputValue",!1,!1,!1,null,!1);if(!o||o.length===0)return e.setValue(n),null;const i=o[0];if(!i)return e.setValue(n),null;const l={lineNumber:i.range.startLineNumber,column:i.range.startColumn+1};try{const c=await(await mo.init()).languages.typescript.getTypeScriptWorker();if(!c)return e.setValue(n),null;const u=await c(e.uri);await new Promise(h=>setTimeout(h,100));const d=e.getOffsetAt(l),f=await u.getQuickInfoAtPosition(e.uri.toString(),d);if(e.setValue(n),f){const m=f.displayParts.map(y=>y.text).join("").replace(/^const __outputValue:\s*/,"");return Nn(m)}else return null}catch(a){return e.setValue(n),console.error("Error getting return type:",a),null}}function Nn(t){if(t=t.trim(),t==="string")return{type:"string"};if(t==="number")return{type:"number"};if(t==="boolean")return{type:"boolean"};if(t==="null")return{type:"null"};if(t==="undefined")return{type:"null"};if(t==="unknown"||t==="any")return{};if(t==="never")return{not:{}};if(t.endsWith("[]")){const r=t.slice(0,-2);return{type:"array",items:Nn(r)}}const e=t.match(/^Array<(.+)>$/);if(e&&e[1])return{type:"array",items:Nn(e[1])};const n=t.match(/^Record<(.+),\s*(.+)>$/);if(n&&n[2])return{type:"object",additionalProperties:Nn(n[2].trim())};if(t.includes("|")){const r=d0(t);if(r.length>1)return r.every(o=>/^["']/.test(o.trim()))?{type:"string",enum:r.map(o=>o.trim().replace(/^["']|["']$/g,""))}:{anyOf:r.map(o=>Nn(o.trim()))}}return/^["'].*["']$/.test(t)?{type:"string",const:t.slice(1,-1)}:/^-?\d+(\.\d+)?$/.test(t)?{type:"number",const:parseFloat(t)}:t.startsWith("{")&&t.endsWith("}")?f0(t):{description:`TypeScript type: ${t}`}}function d0(t){const e=[];let n=0,r="";for(let s=0;s<t.length;s++){const o=t[s];if(o==="{"||o==="<"||o==="("||o==="[")n++;else if(o==="}"||o===">"||o===")"||o==="]")n--;else if(o==="|"&&n===0){e.push(r.trim()),r="";continue}r+=o}return r.trim()&&e.push(r.trim()),e}function f0(t){const e=t.slice(1,-1).trim();if(!e)return{type:"object",properties:{}};const n={},r=[];let s=0,o="";for(let l=0;l<e.length;l++){const a=e[l];if(a==="{"||a==="<"||a==="("||a==="[")s++;else if(a==="}"||a===">"||a===")"||a==="]")s--;else if(a===";"&&s===0){o.trim()&&Pa(o.trim(),n,r),o="";continue}o+=a}o.trim()&&Pa(o.trim(),n,r);const i={type:"object",properties:n};return r.length>0&&(i.required=r),i}function Pa(t,e,n){const r=t.match(/^(\w+)(\?)?:\s*(.+)$/s);if(r){const s=r[1],o=r[2],i=r[3];s&&i&&(e[s]=Nn(i.trim()),o||n.push(s))}}class h0 extends N.Component{constructor(e){super(e),this.state={hasError:!1,mountKey:0}}static getDerivedStateFromError(e){if(e.message?.includes("InstantiationService has been disposed"))return{hasError:!0};throw e}componentDidCatch(e){e.message?.includes("InstantiationService has been disposed")&&this.setState(n=>({hasError:!1,mountKey:n.mountKey+1}))}render(){return this.state.hasError?p.jsx("div",{className:"flex items-center justify-center h-full w-full bg-[#1e1e1e] text-gray-400",children:p.jsx(Fn,{size:"sm"})}):N.cloneElement(this.props.children,{mountKey:this.state.mountKey})}}let Vr=null;const p0=async()=>{if(Vr)return Vr;const[t,e,n]=await Promise.all([Ho(()=>import("./standalone-Cva4pL7v.js"),[]),Ho(()=>import("./typescript-Ca_eWjgL.js"),[]),Ho(()=>import("./estree-CwOGYdhi.js"),[])]);return Vr={format:t.format,plugins:[e.default,n.default]},Vr};mo.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});const m0={parser:"typescript",semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",printWidth:80},La={fontSize:13,lineNumbers:"on",scrollBeyondLastLine:!1,automaticLayout:!0,foldingStrategy:"auto",tabSize:2,wordWrap:"on",folding:!0,bracketPairColorization:{enabled:!0},formatOnPaste:!0,formatOnType:!0,suggestOnTriggerCharacters:!0,quickSuggestions:{other:!0,comments:!1,strings:!0},parameterHints:{enabled:!0},inlineSuggest:{enabled:!0},autoClosingBrackets:"always",autoClosingQuotes:"always",autoSurround:"languageDefined",padding:{top:12,bottom:12},scrollbar:{vertical:"auto",horizontal:"auto",verticalScrollbarSize:8,horizontalScrollbarSize:8},theme:"light"},g0=p.jsx("div",{className:"flex items-center justify-center h-full w-full text-gray-400",children:p.jsx(Fn,{size:"sm"})}),y0=N.memo(function({code:e,onChange:n,onSave:r,readOnly:s=!1,height:o=300,language:i="typescript",foldOnMount:l=!1,mountKey:a=0}){const c=N.useRef(null),u=N.useRef(null),d=N.useRef(r);d.current=r;const f=N.useRef(i);f.current=i;const h=N.useId(),m=`${h}-${a}`,g=i==="typescript"?`file:///workflow-${h.replace(/:/g,"-")}-${a}.tsx`:void 0,y=s?{...La,readOnly:!0}:La,x=async k=>{const S=k.getModel();if(!S){console.warn("No model found");return}const v=S.getValue();if(f.current==="json"){try{const w=JSON.parse(v),M=JSON.stringify(w,null,2);if(M!==v){const E=S.getFullModelRange();k.executeEdits("json-format",[{range:E,text:M}])}}catch(w){console.error("JSON formatting failed:",w)}return}try{const{format:w,plugins:M}=await p0(),E=await w(v,{...m0,plugins:M});if(E!==v){const A=S.getFullModelRange();k.executeEdits("prettier",[{range:A,text:E}])}}catch(w){console.error("Prettier formatting failed:",w)}},b=async(k,S)=>{c.current=k,l&&u.current&&(u.current.style.visibility="hidden",await k.getAction("editor.foldLevel2")?.run(),u.current.style.visibility="visible"),i==="typescript"&&(S.languages.typescript.typescriptDefaults.setCompilerOptions({target:S.languages.typescript.ScriptTarget.ESNext,module:S.languages.typescript.ModuleKind.ESNext,moduleResolution:S.languages.typescript.ModuleResolutionKind.NodeJs,allowNonTsExtensions:!0,allowJs:!0,strict:!1,noEmit:!0,esModuleInterop:!0,jsx:S.languages.typescript.JsxEmit.React,allowSyntheticDefaultImports:!0}),S.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!1,noSyntaxValidation:!1})),k.addCommand(S.KeyMod.CtrlCmd|S.KeyCode.KeyS,async()=>{await x(k);const v=await u0(k),C=k.getValue();console.log({value:C,returnType:v}),d.current?.(C,v)})};return p.jsx("div",{ref:u,className:"h-full",children:p.jsx(c0,{height:o,language:i,value:e,path:g,onChange:n,onMount:b,loading:g0,options:y},m)})}),go=N.memo(function(e){const n=j.c(2);let r;return n[0]!==e?(r=p.jsx(h0,{children:p.jsx(y0,{...e})}),n[0]=e,n[1]=r):r=n[1],r});function Un(){const t=j.c(2),e=Ap();let n;t[0]!==e?(n={connections:e,binding:"WORKFLOW"},t[0]=e,t[1]=n):n=t[1];const r=qp(n);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const $a=[1,1e3,2e3,3e3,5e3,1e4];function Rr(t){const e=j.c(15),n=Un();let r;e[0]!==n.id?(r=nt(n.id),e[0]=n.id,e[1]=r):r=e[1];const s=r,o=N.useRef(0);let i;e[2]!==t?(i={id:t},e[2]=t,e[3]=i):i=e[3];const l=!!t;let a;e[4]!==t?(a=t?m=>{const g=m.state?.data?.item?.status;if(g==="running"||g==="enqueued"){const y=$a[o.current]??1;return o.current=(o.current+1)%$a.length,y}return o.current=0,!1}:!1,e[4]=t,e[5]=a):a=e[5];let c;e[6]!==n.id||e[7]!==i||e[8]!==l||e[9]!==a||e[10]!==s?(c={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET",toolInputParams:i,scope:n.id,enabled:l,refetchInterval:a},e[6]=n.id,e[7]=i,e[8]=l,e[9]=a,e[10]=s,e[11]=c):c=e[11];const{data:u,isLoading:d}=xl(c),f=u?.item;let h;return e[12]!==d||e[13]!==f?(h={item:f,isLoading:d},e[12]=d,e[13]=f,e[14]=h):h=e[14],h}function x0(t,e){const n=j.c(14),r=Un();let s;n[0]!==r.id?(s=nt(r.id),n[0]=r.id,n[1]=s):s=n[1];const o=s;let i;n[2]!==t||n[3]!==e?(i={executionId:t,stepId:e},n[2]=t,n[3]=e,n[4]=i):i=n[4];const l=!!t&&!!e;let a;n[5]!==r.id||n[6]!==i||n[7]!==l||n[8]!==o?(a={toolCaller:o,toolName:"COLLECTION_WORKFLOW_EXECUTION_GET_STEP_RESULT",toolInputParams:i,scope:r.id,enabled:l},n[5]=r.id,n[6]=i,n[7]=l,n[8]=o,n[9]=a):a=n[9];const{data:c,isLoading:u}=xl(a),d=c?.output,f=c?.error;let h;return n[10]!==u||n[11]!==d||n[12]!==f?(h={output:d,error:f,isLoading:u},n[10]=u,n[11]=d,n[12]=f,n[13]=h):h=n[13],h}function b0(){const t=j.c(19),e=Un(),n=Hn();let r;t[0]!==e.id?(r=nt(e.id),t[0]=e.id,t[1]=r):r=t[1];const s=r;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=["workflow"],t[2]=o):o=t[2];let i;t[3]!==n.id?(i={field:o,operator:"eq",value:n.id},t[3]=n.id,t[4]=i):i=t[4];let l;t[5]===Symbol.for("react.memo_cache_sentinel")?(l=[{field:["created_at"],direction:"desc"}],t[5]=l):l=t[5];let a;t[6]!==i?(a={where:i,orderBy:l,limit:100},t[6]=i,t[7]=a):a=t[7];const c=`${e.id}-executions-${n.id}`,u=!!n.id;let d;t[8]!==a||t[9]!==c||t[10]!==u||t[11]!==s?(d={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_LIST",toolInputParams:a,scope:c,enabled:u,staleTime:5e3},t[8]=a,t[9]=c,t[10]=u,t[11]=s,t[12]=d):d=t[12];const{data:f,isLoading:h,refetch:m}=xl(d),g=f;let y;t[13]!==g?.items?(y=g?.items??[],t[13]=g?.items,t[14]=y):y=t[14];let x;return t[15]!==h||t[16]!==m||t[17]!==y?(x={executions:y,isLoading:h,refetch:m},t[15]=h,t[16]=m,t[17]=y,t[18]=x):x=t[18],x}function Gu(t){const e=[];function n(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(n):typeof r=="object"&&r!==null&&Object.values(r).forEach(n)}return n(t),[...new Set(e)]}function k0(t){const e=[];for(const n of t){const r=Gu(n.input);e.push(...r)}return[...new Set(e)].filter(n=>n!=="__entire_input__")}function v0(t){for(const e of t)if(Gu(e.input).includes("__entire_input__"))return!0;return!1}function w0(t){const e=k0(t);if(e.length===0)return v0(t)?{type:"object",additionalProperties:!0,description:"Workflow input data"}:null;const n={},r=[];for(const s of e){const o=s.split(".");if(o.length===1)n[s]={type:"string",description:`Input field: ${s}`},r.push(s);else{const i=o[0];i&&!n[i]&&(n[i]={type:"object",description:`Input object: ${i}`,additionalProperties:!0},r.push(i))}}return{type:"object",properties:n,required:r,description:"Workflow execution input"}}function S0(){const t=j.c(2),e=Hn();let n;return t[0]!==e.steps?(n=w0(e.steps),t[0]=e.steps,t[1]=n):n=t[1],n}function C0(){const t=j.c(14),{id:e}=Un(),{setTrackingExecutionId:n}=Oe();let r;t[0]!==e?(r=nt(e),t[0]=e,t[1]=r):r=t[1];const s=r,o=Hn(),i=Wn(),l=S0();let a;t[2]!==s?(a={toolCaller:s,toolName:"COLLECTION_WORKFLOW_EXECUTION_CREATE"},t[2]=s,t[3]=a):a=t[3];const{mutateAsync:c,isPending:u}=bl(a);let d;t[4]!==i||t[5]!==n||t[6]!==c||t[7]!==o?(d=async g=>{const y=g===void 0?{}:g;if(!i)throw new Error("Please select a gateway before running the workflow");const x=Date.now(),b=await c({steps:o.steps,input:y,gateway_id:i,start_at_epoch_ms:x,workflow_collection_id:o.id,timeout_ms:3e4}),k=b.id??b.structuredContent.id;return n(k),k},t[4]=i,t[5]=n,t[6]=c,t[7]=o,t[8]=d):d=t[8];const f=d,h=l!==null;let m;return t[9]!==f||t[10]!==l||t[11]!==u||t[12]!==h?(m={handleRunWorkflow:f,isPending:u,requiresInput:h,inputSchema:l},t[9]=f,t[10]=l,t[11]=u,t[12]=h,t[13]=m):m=t[13],m}function N0(){const t=j.c(9),{id:e}=Un();let n;t[0]!==e?(n=nt(e),t[0]=e,t[1]=n):n=t[1];const r=n;let s;t[2]!==r?(s={toolCaller:r,toolName:"CANCEL_EXECUTION"},t[2]=r,t[3]=s):s=t[3];const{mutateAsync:o,isPending:i}=bl(s);let l;t[4]!==o?(l=async u=>await o({executionId:u}),t[4]=o,t[5]=l):l=t[5];const a=l;let c;return t[6]!==a||t[7]!==i?(c={handleCancelWorkflow:a,isCancelling:i},t[6]=a,t[7]=i,t[8]=c):c=t[8],c}function E0(){const t=j.c(9),{id:e}=Un();let n;t[0]!==e?(n=nt(e),t[0]=e,t[1]=n):n=t[1];const r=n;let s;t[2]!==r?(s={toolCaller:r,toolName:"RESUME_EXECUTION"},t[2]=r,t[3]=s):s=t[3];const{mutateAsync:o,isPending:i}=bl(s);let l;t[4]!==o?(l=async u=>(await o({executionId:u})).success,t[4]=o,t[5]=l):l=t[5];const a=l;let c;return t[6]!==a||t[7]!==i?(c={handleResumeWorkflow:a,isResuming:i},t[6]=a,t[7]=i,t[8]=c):c=t[8],c}function T0(){const t=j.c(3),e=we(),{item:n}=Rr(e);let r;return t[0]!==n||t[1]!==e?(r=e&&n?(()=>{const o={};return n?.input&&(o.input=n.input),o})():void 0,t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function M0(t,e,n,r){if(!e)return[...t].sort(r);const s=n(e);return[...t].sort((o,i)=>{const l=n(o),a=n(i);return l===s?-1:a===s?1:r?r(o,i):0})}const wl=_g()(_u(t=>({viewMode:"visual",setViewMode:e=>t({viewMode:e}),showExecutionsList:!1,setShowExecutionsList:e=>t({showExecutionsList:e}),toggleExecutionsList:()=>t(e=>({showExecutionsList:!e.showExecutionsList}))}),{name:"workflow-view-mode"})),Yu=N.createContext([]);function Xu(){return N.useContext(Yu)}function be(t){this.content=t}be.prototype={constructor:be,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),o=r.content.slice();return s==-1?o.push(n||t,e):(o[s+1]=e,n&&(o[s]=n)),new be(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new be(n)},addToStart:function(t,e){return new be([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new be(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),o=r.find(t);return s.splice(o==-1?s.length:o,0,e,n),new be(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=be.from(t),t.size?new be(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=be.from(t),t.size?new be(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=be.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};be.from=function(t){if(t instanceof be)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new be(e)};function Qu(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),o=e.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)n++;return n}if(s.content.size||o.content.size){let i=Qu(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function Zu(t,e,n,r){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=t.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){n-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:n,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(i.content.size||l.content.size){let c=Zu(i.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class O{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,o){for(let i=0,l=0;l<n;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 u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let o="",i=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-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 n=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new O(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let o=0,i=0;i<n;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,n-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,n-i-1))),r.push(l),s+=l.nodeSize),i=a}return new O(r,s)}cutByIndex(e,n){return e==n?O.empty:e==0&&n==this.content.length?this:new O(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new O(s,o)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Qu(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Zu(this,e,n,r)}findIndex(e){if(e==0)return Hr(0,e);if(e==this.size)return Hr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=e)return o==e?Hr(n+1,o):Hr(n,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,n){if(!n)return O.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let n,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)?(n||(n=e.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new O(n||e,r)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const Xo={index:0,offset:0};function Hr(t,e){return Xo.index=t,Xo.offset=e,Xo}function fs(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!fs(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!fs(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ne=class Mi{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,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))n||(n=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&fs(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Mi.none;if(e instanceof Mi)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};ne.none=[];class hs extends Error{}class ${constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=td(this.content,e+this.openStart,n);return r&&new $(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $(ed(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return $.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new $(O.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new $(e,r,s)}}$.empty=new $(O.empty,0,0);function ed(t,e,n){let{index:r,offset:s}=t.findIndex(e),o=t.maybeChild(r),{index:i,offset:l}=t.findIndex(n);if(s==e||o.isText){if(l!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(ed(o.content,e-s-1,n-s-1)))}function td(t,e,n,r){let{index:s,offset:o}=t.findIndex(e),i=t.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=td(i.content,e-o-1,n,i);return l&&t.replaceChild(s,i.copy(l))}function O0(t,e,n){if(n.openStart>t.depth)throw new hs("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new hs("Inconsistent open depths");return nd(t,e,n,0)}function nd(t,e,n,r){let s=t.index(r),o=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let i=nd(t,e,n,r+1);return o.copy(o.content.replaceChild(s,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let i=t.parent,l=i.content;return Qt(i,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=A0(n,t);return Qt(o,sd(t,i,l,e,r))}else return Qt(o,ps(t,e,r))}function rd(t,e){if(!e.type.compatibleContent(t.type))throw new hs("Cannot join "+e.type.name+" onto "+t.type.name)}function Oi(t,e,n){let r=t.node(n);return rd(r,e.node(n)),r}function Xt(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function sr(t,e,n,r){let s=(e||t).node(n),o=0,i=e?e.index(n):s.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Xt(t.nodeAfter,r),o++));for(let l=o;l<i;l++)Xt(s.child(l),r);e&&e.depth==n&&e.textOffset&&Xt(e.nodeBefore,r)}function Qt(t,e){return t.type.checkContent(e),t.copy(e)}function sd(t,e,n,r,s){let o=t.depth>s&&Oi(t,e,s+1),i=r.depth>s&&Oi(n,r,s+1),l=[];return sr(null,t,s,l),o&&i&&e.index(s)==n.index(s)?(rd(o,i),Xt(Qt(o,sd(t,e,n,r,s+1)),l)):(o&&Xt(Qt(o,ps(t,e,s+1)),l),sr(e,n,s,l),i&&Xt(Qt(i,ps(n,r,s+1)),l)),sr(r,null,s,l),new O(l)}function ps(t,e,n){let r=[];if(sr(null,t,n,r),t.depth>n){let s=Oi(t,e,n+1);Xt(Qt(s,ps(t,e,n+1)),r)}return sr(e,null,n,r),new O(r)}function A0(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)s=e.node(o).copy(O.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class gr{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ne.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);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 n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.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 n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new ms(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,o=n;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 gr(n,r,o)}static resolveCached(e,n){let r=_a.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==n)return i}else _a.set(e,r=new I0);let s=r.elts[r.i]=gr.resolve(e,n);return r.i=(r.i+1)%j0,s}}class I0{constructor(){this.elts=[],this.i=0}}const j0=12,_a=new WeakMap;class ms{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const R0=Object.create(null);class We{constructor(e,n,r,s=ne.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,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,n,r,s){return this.content.textBetween(e,n,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,n,r){return this.type==e&&fs(this.attrs,n||e.defaultAttrs||R0)&&ne.sameSet(this.marks,r||ne.none)}copy(e=null){return e==this.content?this:new We(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new We(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return $.empty;let s=this.resolve(e),o=this.resolve(n),i=r?0:s.sharedDepth(n),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new $(c,s.depth-i,o.depth-i)}replace(e,n,r){return O0(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return gr.resolveCached(this,e)}resolveNoCache(e){return gr.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,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()+")"),od(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=O.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,n);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,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,n);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=ne.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ne.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=O.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,s,r);return o.type.checkAttrs(o.attrs),o}}We.prototype.text=void 0;class gs extends We{constructor(e,n,r,s){if(super(e,n,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):od(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function od(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class rn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new D0(e,n);if(r.next==null)return rn.empty;let s=id(r);r.next&&r.err("Unexpected trailing text");let o=F0(B0(s));return V0(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let o=n;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:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!n||a.validEnd))return O.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=o(d,l.concat(u));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 n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let 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 n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[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 n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(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(`
26
- `)}}rn.empty=new rn(!0);class D0{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function id(t){let e=[];do e.push(P0(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function P0(t){let e=[];do e.push(L0(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function L0(t){let e=z0(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=$0(t,e);else break;return e}function za(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function $0(t,e){let n=za(t),r=n;return t.eat(",")&&(t.next!="}"?r=za(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _0(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let o in n){let i=n[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function z0(t){if(t.eat("(")){let e=id(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=_0(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function B0(t){let e=[[]];return s(o(t,0),n()),e;function n(){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=n())}else if(i.type=="star"){let a=n();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=n();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 u=n();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=n();r(a,u),s(o(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function ld(t,e){return e-t}function Ba(t,e){let n=[];return r(e),n.sort(ld);function r(s){let o=t[s];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&n.indexOf(a)==-1&&r(a)}}}function F0(t){let e=Object.create(null);return n(Ba(t,0));function n(r){let s=[];r.forEach(i=>{t[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Ba(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new rn(r.indexOf(t.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(ld);o.next.push({type:s[i][0],next:e[l.join(",")]||n(l)})}return o}}function V0(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],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 ad(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function cd(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let o=t[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function ud(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let o=t[s];o.validate&&o.validate(e[s])}}function dd(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new W0(t,r,e[r]);return n}let Fa=class fd{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=dd(e,r.attrs),this.defaultAttrs=ad(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==rn.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:cd(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new We(this,this.computeAttrs(e),O.from(n),ne.setFrom(r))}createChecked(e=null,n,r){return n=O.from(n),this.checkContent(n),new We(this,this.computeAttrs(e),n,ne.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=O.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let s=this.contentMatch.matchFragment(n),o=s&&s.fillBefore(O.empty,!0);return o?new We(this,e,n.append(o),ne.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ud(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ne.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,i)=>r[o]=new fd(o,n,i));let s=n.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 H0(t,e,n){let r=n.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 ${t}, got ${o}`)}}class W0{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?H0(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class yo{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=dd(e,s.attrs),this.excluded=null;let o=ad(this.attrs);this.instance=o?new ne(this,o):null}create(e=null){return!e&&this.instance?this.instance:new ne(this,cd(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new yo(o,s++,n,i)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){ud(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class hd{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=be.from(e.nodes),n.marks=be.from(e.marks||{}),this.nodes=Fa.compile(this.spec.nodes,this),this.marks=yo.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]=rn.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?Va(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==""?[]:Va(this,i.split(" "))}this.nodeFromJSON=s=>We.fromJSON(this,s),this.markFromJSON=s=>ne.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Fa){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new gs(r,r.defaultAttrs,e,ne.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Va(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],o=t.marks[s],i=o;if(o)n.push(o);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function U0(t){return t.tag!=null}function q0(t){return t.style!=null}class Dt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(U0(s))this.tags.push(s);else if(q0(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,n={}){let r=new Wa(this,n,!1);return r.addAll(e,ne.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Wa(this,n,!0);return r.addAll(e,ne.none,n.from,n.to),$.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(G0(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,n,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)!=n))){if(i.getAttrs){let a=i.getAttrs(n);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let n=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<n.length;i++){let l=n[i];if((l.priority==null?50:l.priority)<o)break}n.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=Ua(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=Ua(i)),i.node||i.ignore||i.mark||(i.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Dt(e,Dt.schemaRules(e)))}}const pd={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},K0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},md={ol:!0,ul:!0},yr=1,Ai=2,or=4;function Ha(t,e,n){return e!=null?(e?yr:0)|(e==="full"?Ai:0):t&&t.whitespace=="pre"?yr|Ai:n&~or}class Wr{constructor(e,n,r,s,o,i){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=ne.none,this.match=o||(i&or?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(O.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);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&yr)){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 n=O.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!pd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Wa{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,o,i=Ha(null,n.preserveWhitespace,0)|(r?or:0);s?o=new Wr(s.type,s.attrs,ne.none,!0,n.topMatch||s.type.contentMatch,i):r?o=new Wr(null,null,ne.none,!0,null,i):o=new Wr(e.schema.topNodeType,null,ne.none,!0,null,i),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,o=s.options&Ai?"full":this.localPreserveWS||(s.options&yr)>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,`
27
- `);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(),n,!0),l[a]&&this.insertNode(i.text(l[a]),n,!/\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),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,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;md.hasOwnProperty(i)&&this.parser.normalizeLists&&J0(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:K0.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);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,u=this.needsBlock;if(pd.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,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
28
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let 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?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let o,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,n.attrs||null,r,n.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,n,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,n);this.findAtPoint(e,o)}findPlace(e,n,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++)n=this.enterInner(s[i],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=ne.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):qa(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,n,r,s){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,s)),o}enterInner(e,n,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Ha(e,o,i.options);i.options&or&&i.content.length==0&&(l|=or);let a=ne.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):qa(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Wr(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=yr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,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=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function J0(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&md.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function G0(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ua(t){let e={};for(let n in t)e[n]=t[n];return e}function qa(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class un{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Qo(n).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++],u=this.serializeMark(c,i.isInline,n);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=ns(Qo(n),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,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&ns(Qo(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return ns(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new un(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ka(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Ka(e.marks)}}function Ka(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Qo(t){return t.document||window.document}const Ja=new WeakMap;function Y0(t){let e=Ja.get(t);return e===void 0&&Ja.set(t,e=X0(t)),e}function X0(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function ns(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Y0(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&&(n=s.slice(0,i),s=s.slice(i+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:m}=ns(t,f,n,r);if(a.appendChild(h),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:a,contentDOM:l}}const gd=65535,yd=Math.pow(2,16);function Q0(t,e){return t+e*yd}function Ga(t){return t&gd}function Z0(t){return(t-(t&gd))/yd}const xd=1,bd=2,rs=4,kd=8;class Ii{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&kd)>0}get deletedBefore(){return(this.delInfo&(xd|rs))>0}get deletedAfter(){return(this.delInfo&(bd|rs))>0}get deletedAcross(){return(this.delInfo&rs)>0}}class $e{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&$e.empty)return $e.empty}recover(e){let n=0,r=Ga(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Z0(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let 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],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+s+(f<0?0:u);if(r)return h;let m=e==(n<0?a:d)?null:Q0(l/3,e-a),g=e==a?bd:e==d?xd:rs;return(n<0?e!=a:e!=d)&&(g|=kd),new Ii(h,g,m)}s+=u-c}return r?e+s:new Ii(e+s,0,null)}touches(e,n){let r=0,s=Ga(n),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],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let n=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+n],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new $e(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?$e.empty:new $e(e<0?[0,-e,0]:[0,0,e])}}$e.empty=new $e([]);class xr{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new xr(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new xr;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,n);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 Ii(e,s,null)}}const Zo=Object.create(null);class Ee{getMap(){return $e.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Zo[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Zo)throw new RangeError("Duplicate use of step JSON ID "+e);return Zo[e]=n,n.prototype.jsonID=e,n}}class he{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new he(e,null)}static fail(e){return new he(null,e)}static fromReplace(e,n,r,s){try{return he.ok(e.replace(n,r,s))}catch(o){if(o instanceof hs)return he.fail(o.message);throw o}}}function Sl(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(Sl(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return O.fromArray(r)}class At extends Ee{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new $(Sl(n.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,o)}invert(){return new tt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new At(n.pos,r.pos,this.mark)}merge(e){return e instanceof At&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new At(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new At(n.from,n.to,e.markFromJSON(n.mark))}}Ee.jsonID("addMark",At);class tt extends Ee{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new $(Sl(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return he.fromReplace(e,this.from,this.to,r)}invert(){return new At(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new tt(n.pos,r.pos,this.mark)}merge(e){return e instanceof tt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new tt(n.from,n.to,e.markFromJSON(n.mark))}}Ee.jsonID("removeMark",tt);class It extends Ee{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new $(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new It(this.pos,n.marks[s]);return new It(this.pos,this.mark)}}return new sn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new It(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new It(n.pos,e.markFromJSON(n.mark))}}Ee.jsonID("addNodeMark",It);class sn extends Ee{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return he.fromReplace(e,this.pos,this.pos+1,new $(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new It(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new sn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new sn(n.pos,e.markFromJSON(n.mark))}}Ee.jsonID("removeNodeMark",sn);class me extends Ee{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&ji(e,this.from,this.to)?he.fail("Structure replace would overwrite content"):he.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new $e([this.from,this.to-this.from,this.slice.size])}invert(e){return new me(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new me(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof me)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?$.empty:new $(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new me(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?$.empty:new $(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new me(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new me(n.from,n.to,$.fromJSON(e,n.slice),!!n.structure)}}Ee.jsonID("replace",me);class ye extends Ee{constructor(e,n,r,s,o,i,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(ji(e,this.from,this.gapFrom)||ji(e,this.gapTo,this.to)))return he.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return he.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?he.fromReplace(e,this.from,this.to,r):he.fail("Content does not fit in gap")}getMap(){return new $e([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new ye(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new ye(n.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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ye(n.from,n.to,n.gapFrom,n.gapTo,$.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ee.jsonID("replaceAround",ye);function ji(t,e,n){let r=t.resolve(e),s=n-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 ey(t,e,n,r){let s=[],o=[],i,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),m=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(m)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=h:s.push(i=new tt(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new At(f,h,r))}}),s.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function ty(t,e,n,r){let s=[],o=0;t.doc.nodesBetween(e,n,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof yo){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let m=s[h];m.step==o-1&&d.eq(s[h].style)&&(f=m)}f?(f.to=c,f.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>t.step(new tt(i.from,i.to,i.style)))}function Cl(t,e,n,r=n.contentMatch,s=!0){let o=t.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new me(l,u,$.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new tt(l,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,m;for(;f=h.exec(c.text);)m||(m=new $(O.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new me(l+f.index,l+f.index+f[0].length,m))}}l=u}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);t.replace(l,l,new $(a,0,0))}for(let a=i.length-1;a>=0;a--)t.step(i[a])}function ny(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function qn(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,o=0;;--r){let i=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-o;if(r<t.depth&&i.canReplace(l,a,n))return r;if(r==0||i.type.spec.isolating||!ny(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function ry(t,e,n){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,u=O.empty,d=0;for(let m=o,g=!1;m>n;m--)g||r.index(m)>0?(g=!0,u=O.from(r.node(m).copy(u)),d++):a--;let f=O.empty,h=0;for(let m=o,g=!1;m>n;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=O.from(s.node(m).copy(f)),h++):c++;t.step(new ye(a,c,i,l,new $(u.append(f),d,h),u.size-d,!0))}function Nl(t,e,n=null,r=t){let s=sy(t,e),o=s&&oy(r,e);return o?s.map(Ya).concat({type:e,attrs:n}).concat(o.map(Ya)):null}function Ya(t){return{type:t,attrs:null}}function sy(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return n.canReplaceWith(r,s,i)?o:null}function oy(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.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(n.child(c).type);return!a||!a.validEnd?null:i}function iy(t,e,n){let r=O.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let l=n[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=O.from(n[i].type.create(n[i].attrs,r))}let s=e.start,o=e.end;t.step(new ye(s,o,s,o,new $(r,0,0),n.length,!0))}function ly(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&ay(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",m=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!m?c=!1:!h&&m&&(c=!0)}c===!1&&wd(t,i,l,o),Cl(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),d=u.map(l,1),f=u.map(l+i.nodeSize,1);return t.step(new ye(d,f,d+1,f-1,new $(O.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&vd(t,i,l,o),!1}})}function vd(t,e,n,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+o+i.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function wd(t,e,n,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+o);t.replaceWith(i,i+1,e.type.schema.text(`
29
- `))}})}function ay(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function cy(t,e,n,r,s){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let i=n.create(r,null,s||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,i);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ye(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new $(O.from(i),0,0),1,!0))}function xt(t,e,n=1,r){let s=t.resolve(e),o=s.depth-n,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,u=n-2;c>o;c--,u--){let d=s.node(c),f=s.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),m=r&&r[u+1];m&&(h=h.replaceChild(0,m.type.create(m.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.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 uy(t,e,n=1,r){let s=t.doc.resolve(e),o=O.empty,i=O.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){o=O.from(s.node(l).copy(o));let u=r&&r[c];i=O.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}t.step(new me(e,e,new $(o.append(i),n,n),!0))}function Vt(t,e){let n=t.resolve(e),r=n.index();return Sd(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function dy(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function Sd(t,e){return!!(t&&e&&!t.isLeaf&&dy(t,e))}function xo(t,e,n=-1){let r=t.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):n>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&&Sd(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function fy(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,o=t.doc.resolve(e-n),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);wd(t,u.node(),u.before(),l)}i.inlineContent&&Cl(t,e+n-1,i,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new me(c,a.map(e+n,-1),$.empty,!0)),r===!0){let u=t.doc.resolve(c);vd(t,u.node(),u.before(),t.steps.length)}return t}function hy(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))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,n))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,n))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function Cd(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.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),u=!1;if(o==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function bo(t,e,n=e,r=$.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),o=t.resolve(n);return Nd(s,o,r)?new me(e,n,r):new py(s,o,r).fit()}function Nd(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class py{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.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=O.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(),n=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 $(o,i,l);return e>-1?new ye(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new me(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=ei(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],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(O.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ei(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new $(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ei(e,n);if(s.childCount<=1&&n>0){let o=e.size-n<=n+s.size;this.unplaced=new $(Zn(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new $(Zn(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push(Ed(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let m=c==l.childCount;m||(h=-1),this.placed=er(this.placed,n,O.from(u)),this.frontier[n].match=d,m&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<h;g++){let x=y.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),y=x.content}this.unplaced=m?e==0?$.empty:new $(Zn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new $(Zn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!ti(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.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 n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),i=ti(e,n,s,r,o);if(i){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ti(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=er(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.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,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=er(this.placed,this.depth,O.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(O.empty,!0);n.childCount&&(this.placed=er(this.placed,this.frontier.length,n))}}function Zn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Zn(t.firstChild.content,e-1,n)))}function er(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(er(t.lastChild.content,e-1,n)))}function ei(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ed(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Ed(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),t.copy(r)}function ti(t,e,n,r,s){let o=t.node(e),i=s?t.indexAfter(e):t.index(e);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!my(n,o.content,i)?l:null}function my(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function gy(t){return t.spec.defining||t.spec.definingForContent}function yy(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),o=t.doc.resolve(n);if(Nd(s,o,r))return t.step(new me(e,n,r));let i=Md(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 m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let m=f.firstChild;if(c.push(m),h==r.openStart)break;f=m.content}for(let f=u-1;f>=0;f--){let h=c[f],m=gy(h.type);if(m&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(m||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),m=c[h];if(m)for(let g=0;g<i.length;g++){let y=i[(g+a)%i.length],x=!0;y<0&&(x=!1,y=-y);let b=s.node(y-1),k=s.index(y-1);if(b.canReplaceWith(k,k,m.type,m.marks))return t.replace(s.before(y),x?o.after(y):n,new $(Td(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=i.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=i[f];h<0||(e=s.before(h),n=o.after(h))}}function Td(t,e,n,r,s){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(Td(o.content,e+1,n,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(t).append(t);t=i.append(o.matchFragment(i).fillBefore(O.empty,!0))}return t}function xy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=hy(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new $(O.from(r),0,0))}function by(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),o=Md(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 t.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 t.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&&n>r.end(i)&&s.end(i)-n!=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 t.delete(r.before(i),n);t.delete(e,n)}function Md(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let o=t.start(s);if(o<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&n.push(s)}return n}class Tn extends Ee{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return he.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return he.fromReplace(e,this.pos,this.pos+1,new $(O.from(s),0,n.isLeaf?0:1))}getMap(){return $e.empty}invert(e){return new Tn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Tn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Tn(n.pos,n.attr,n.value)}}Ee.jsonID("attr",Tn);class br extends Ee{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return he.ok(r)}getMap(){return $e.empty}invert(e){return new br(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new br(n.attr,n.value)}}Ee.jsonID("docAttr",br);let An=class extends Error{};An=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};An.prototype=Object.create(Error.prototype);An.prototype.constructor=An;An.prototype.name="TransformError";class Od{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new xr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new An(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=$.empty){let s=bo(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new $(O.from(r),0,0))}delete(e,n){return this.replace(e,n,$.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return yy(this,e,n,r),this}replaceRangeWith(e,n,r){return xy(this,e,n,r),this}deleteRange(e,n){return by(this,e,n),this}lift(e,n){return ry(this,e,n),this}join(e,n=1){return fy(this,e,n),this}wrap(e,n){return iy(this,e,n),this}setBlockType(e,n=e,r,s=null){return ly(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return cy(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Tn(e,n,r)),this}setDocAttribute(e,n){return this.step(new br(e,n)),this}addNodeMark(e,n){return this.step(new It(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ne)n.isInSet(r.marks)&&this.step(new sn(e,n));else{let s=r.marks,o,i=[];for(;o=n.isInSet(s);)i.push(new sn(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,n=1,r){return uy(this,e,n,r),this}addMark(e,n,r){return ey(this,e,n,r),this}removeMark(e,n,r){return ty(this,e,n,r),this}clearIncompatible(e,n,r){return Cl(this,e,n,r),this}}const ni=Object.create(null);class Y{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new ky(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=$.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.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],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?$.empty:n),l==0&&Za(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){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),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Za(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new q(e):kn(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=n<0?kn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):kn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new _e(e.node(0))}static atStart(e){return kn(e,e,0,0,1)||new _e(e)}static atEnd(e){return kn(e,e,e.content.size,e.childCount,-1)||new _e(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ni[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ni)throw new RangeError("Duplicate use of selection JSON ID "+e);return ni[e]=n,n.prototype.jsonID=e,n}getBookmark(){return q.between(this.$anchor,this.$head).getBookmark()}}Y.prototype.visible=!0;class ky{constructor(e,n){this.$from=e,this.$to=n}}let Xa=!1;function Qa(t){!Xa&&!t.parent.inlineContent&&(Xa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class q extends Y{constructor(e,n=e){Qa(e),Qa(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Y.near(r);let s=e.resolve(n.map(this.anchor));return new q(s.parent.inlineContent?s:r,r)}replace(e,n=$.empty){if(super.replace(e,n),n==$.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof q&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ko(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new q(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=Y.findFrom(n,r,!0)||Y.findFrom(n,-r,!0);if(o)n=o.$head;else return Y.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Y.findFrom(e,-r,!0)||Y.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new q(e,n)}}Y.jsonID("text",q);class ko{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ko(e.map(this.anchor),e.map(this.head))}resolve(e){return q.between(e.resolve(this.anchor),e.resolve(this.head))}}class V extends Y{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=e.resolve(s);return r?Y.near(o):new V(o)}content(){return new $(O.from(this.node),0,0)}eq(e){return e instanceof V&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new El(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new V(e.resolve(n.anchor))}static create(e,n){return new V(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}V.prototype.visible=!1;Y.jsonID("node",V);class El{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ko(r,r):new El(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&V.isSelectable(r)?new V(n):Y.near(n)}}class _e extends Y{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=$.empty){if(n==$.empty){e.delete(0,e.doc.content.size);let r=Y.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new _e(e)}map(e){return new _e(e)}eq(e){return e instanceof _e}getBookmark(){return vy}}Y.jsonID("all",_e);const vy={map(){return this},resolve(t){return new _e(t)}};function kn(t,e,n,r,s,o=!1){if(e.inlineContent)return q.create(t,n);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&&V.isSelectable(l))return V.create(t,n-(s<0?l.nodeSize:0))}else{let a=kn(t,l,n+s,s<0?l.childCount:0,s,o);if(a)return a}n+=l.nodeSize*s}return null}function Za(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof me||s instanceof ye))return;let o=t.mapping.maps[r],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),t.setSelection(Y.near(t.doc.resolve(i),n))}const ec=1,Ur=2,tc=4;class wy extends Od{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|ec)&~Ur,this.storedMarks=null,this}get selectionSet(){return(this.updated&ec)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ur,this}ensureMarks(e){return ne.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&Ur)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ur,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ne.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(n);o=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,o)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Y.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,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|=tc,this}get scrolledIntoView(){return(this.updated&tc)>0}}function nc(t,e){return!e||!t?t:t.bind(e)}class tr{constructor(e,n,r){this.name=e,this.init=nc(n.init,r),this.apply=nc(n.apply,r)}}const Sy=[new tr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new tr("selection",{init(t,e){return t.selection||Y.atStart(e.doc)},apply(t){return t.selection}}),new tr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new tr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ri{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Sy.slice(),n&&n.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 tr(r.key,r.spec.state,r))})}}class En{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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){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 n=[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,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}s&&(s[i]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new En(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new wy(this)}static create(e){let n=new ri(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new En(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new ri(this.schema,e.plugins),r=n.fields,s=new En(n);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 n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.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&&(n[r]=o.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new ri(e.schema,e.plugins),o=new En(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=We.fromJSON(e.schema,n.doc);else if(i.name=="selection")o.selection=Y.fromJSON(o.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.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(n,l)){o[i.name]=c.fromJSON.call(a,e,n[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Ad(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ad(s,e,{})),n[r]=s}return n}class ie{constructor(e){this.spec=e,this.props={},e.props&&Ad(e.props,this,this.props),this.key=e.key?e.key.key:Id("plugin")}getState(e){return e[this.key]}}const si=Object.create(null);function Id(t){return t in si?t+"$"+ ++si[t]:(si[t]=0,t+"$")}class de{constructor(e="key"){this.key=Id(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Tl=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function jd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Rd=(t,e,n)=>{let r=jd(t,n);if(!r)return!1;let s=Ml(r);if(!s){let i=r.blockRange(),l=i&&qn(i);return l==null?!1:(e&&e(t.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Vd(t,s,e,-1))return!0;if(r.parent.content.size==0&&(In(o,"end")||V.isSelectable(o)))for(let i=r.depth;;i--){let l=bo(t.doc,r.before(i),r.after(i),$.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(In(o,"end")?Y.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):V.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(t.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},Cy=(t,e,n)=>{let r=jd(t,n);if(!r)return!1;let s=Ml(r);return s?Dd(t,s,e):!1},Ny=(t,e,n)=>{let r=Ld(t,n);if(!r)return!1;let s=Ol(r);return s?Dd(t,s,e):!1};function Dd(t,e,n){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=bo(t.doc,o,a,$.empty);if(!c||c.from!=o||c instanceof me&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(q.create(u.doc,o)),n(u.scrollIntoView())}return!0}function In(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Pd=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Ml(r)}let i=o&&o.nodeBefore;return!i||!V.isSelectable(i)?!1:(e&&e(t.tr.setSelection(V.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function Ml(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ld(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const $d=(t,e,n)=>{let r=Ld(t,n);if(!r)return!1;let s=Ol(r);if(!s)return!1;let o=s.nodeAfter;if(Vd(t,s,e,1))return!0;if(r.parent.content.size==0&&(In(o,"start")||V.isSelectable(o))){let i=bo(t.doc,r.before(),r.after(),$.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=t.tr.step(i);l.setSelection(In(o,"start")?Y.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):V.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},_d=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=Ol(r)}let i=o&&o.nodeAfter;return!i||!V.isSelectable(i)?!1:(e&&e(t.tr.setSelection(V.create(t.doc,o.pos)).scrollIntoView()),!0)};function Ol(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const Ey=(t,e)=>{let n=t.selection,r=n instanceof V,s;if(r){if(n.node.isTextblock||!Vt(t.doc,n.from))return!1;s=n.from}else if(s=xo(t.doc,n.from,-1),s==null)return!1;if(e){let o=t.tr.join(s);r&&o.setSelection(V.create(o.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Ty=(t,e)=>{let n=t.selection,r;if(n instanceof V){if(n.node.isTextblock||!Vt(t.doc,n.to))return!1;r=n.to}else if(r=xo(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},My=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),o=s&&qn(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)},zd=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
30
- `).scrollIntoView()),!0)};function Al(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Oy=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=Al(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,i.createAndFill());a.setSelection(Y.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Bd=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof _e||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=Al(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=t.tr.insert(i,o.createAndFill());l.setSelection(q.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Fd=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(xt(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),s=r&&qn(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Ay(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof V&&e.selection.node.isBlock)return!r.parentOffset||!xt(e.doc,r.pos)?!1:(n&&n(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=Al(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 u=e.tr;(e.selection instanceof q||e.selection instanceof _e)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=xt(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=xt(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!a&&c&&r.node(i).type!=l){let h=u.mapping.map(r.before(i)),m=u.doc.resolve(h);l&&r.node(i-1).canReplaceWith(m.index(),m.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return n&&n(u.scrollIntoView()),!0}}const Iy=Ay(),jy=(t,e)=>{let{$from:n,to:r}=t.selection,s,o=n.sharedDepth(r);return o==0?!1:(s=n.before(o),e&&e(t.tr.setSelection(V.create(t.doc,s))),!0)};function Ry(t,e,n){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)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||Vt(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Vd(t,e,n,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&Ry(t,e,n))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(n){let h=e.pos+o.nodeSize,m=O.empty;for(let x=i.length-1;x>=0;x--)m=O.from(i[x].create(null,m));m=O.from(s.copy(m));let g=t.tr.step(new ye(e.pos-1,h,e.pos,h,new $(m,1,0),i.length,!0)),y=g.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Vt(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:Y.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&qn(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&In(o,"start",!0)&&In(s,"end")){let h=s,m=[];for(;m.push(h),!h.isTextblock;)h=h.lastChild;let g=o,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(n){let x=O.empty;for(let k=m.length-1;k>=0;k--)x=O.from(m[k].copy(x));let b=t.tr.step(new ye(e.pos-m.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new $(x,m.length,0),0,!0));n(b.scrollIntoView())}return!0}}return!1}function Hd(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(n&&n(e.tr.setSelection(q.create(e.doc,t<0?s.start(o):s.end(o)))),!0):!1}}const Dy=Hd(-1),Py=Hd(1);function Ly(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),l=i&&Nl(i,t,e);return l?(r&&r(n.tr.wrap(i,l).scrollIntoView()),!0):!1}}function rc(t,e=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let o=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[i];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function Il(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Il(Tl,Rd,Pd);Il(Tl,$d,_d);Il(zd,Bd,Fd,Iy);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function $y(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let l=r?n.tr:null;return _y(l,i,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function _y(t,e,n,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new ms(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ms(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Nl(o,n,r,e);return l?(t&&zy(t,e,l,s,n),!0):!1}function zy(t,e,n,r,s){let o=O.empty;for(let u=n.length-1;u>=0;u--)o=O.from(n[u].type.create(n[u].attrs,o));t.step(new ye(e.start-(r?2:0),e.end,e.start,e.end,new $(o,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)n[u].type==s&&(i=u+1);let l=n.length-i,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&xt(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function By(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?Fy(e,n,t,o):Vy(e,n,o):!0:!1}}function Fy(t,e,n,r){let s=t.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ye(o-1,i,o,i,new $(O.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ms(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=qn(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Vt(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Vy(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,m=n.endIndex-1,g=n.startIndex;m>g;m--)h-=s.child(m).nodeSize,r.delete(h-1,h+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?O.empty:O.from(s))))return!1;let d=o.pos,f=d+i.nodeSize;return r.step(new ye(d-(l?1:0),f+(a?1:0),d+1,f-1,new $((l?O.empty:O.from(s.copy(O.empty))).append(a?O.empty:O.from(s.copy(O.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Hy(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);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!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=O.from(c?t.create():null),d=new $(O.from(t.create(null,O.from(l.type.create(null,u)))),c?3:1,0),f=o.start,h=o.end;n(e.tr.step(new ye(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const ke=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},jn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ri=null;const mt=function(t,e,n){let r=Ri||(Ri=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Wy=function(){Ri=null},on=function(t,e,n,r){return n&&(sc(t,e,n,r,-1)||sc(t,e,n,r,1))},Uy=/^(img|br|input|textarea|hr)$/i;function sc(t,e,n,r,s){for(var o;;){if(t==n&&e==r)return!0;if(e==(s<0?0:He(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Dr(t)||Uy.test(t.nodeName)||t.contentEditable=="false")return!1;e=ke(t)+(s<0?0:1),t=i}else if(t.nodeType==1){let i=t.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 t=i,e=s<0?He(t):0}else return!1}}function He(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function qy(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=He(t)}else if(t.parentNode&&!Dr(t))e=ke(t),t=t.parentNode;else return null}}function Ky(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Dr(t))e=ke(t)+1,t=t.parentNode;else return null}}function Jy(t,e,n){for(let r=e==0,s=e==He(t);r||s;){if(t==n)return!0;let o=ke(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,s=s&&o==He(t)}}function Dr(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const vo=function(t){return t.focusNode&&on(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function qt(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Gy(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Yy(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(He(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(He(r.startContainer),r.startOffset)}}}const at=typeof navigator<"u"?navigator:null,oc=typeof document<"u"?document:null,Ht=at&&at.userAgent||"",Di=/Edge\/(\d+)/.exec(Ht),Wd=/MSIE \d/.exec(Ht),Pi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Ie=!!(Wd||Pi||Di),Pt=Wd?document.documentMode:Pi?+Pi[1]:Di?+Di[1]:0,Ue=!Ie&&/gecko\/(\d+)/i.test(Ht);Ue&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const Li=!Ie&&/Chrome\/(\d+)/.exec(Ht),ge=!!Li,Ud=Li?+Li[1]:0,Ne=!Ie&&!!at&&/Apple Computer/.test(at.vendor),Rn=Ne&&(/Mobile\/\w+/.test(Ht)||!!at&&at.maxTouchPoints>2),Ve=Rn||(at?/Mac/.test(at.platform):!1),qd=at?/Win/.test(at.platform):!1,yt=/Android \d/.test(Ht),Pr=!!oc&&"webkitFontSmoothing"in oc.documentElement.style,Xy=Pr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Qy(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function dt(t,e){return typeof t=="number"?t:t[e]}function Zy(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ic(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let i=n||t.dom;i;){if(i.nodeType!=1){i=jn(i);continue}let l=i,a=l==o.body,c=a?Qy(o):Zy(l),u=0,d=0;if(e.top<c.top+dt(r,"top")?d=-(c.top-e.top+dt(s,"top")):e.bottom>c.bottom-dt(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+dt(s,"top")-c.top:e.bottom-c.bottom+dt(s,"bottom")),e.left<c.left+dt(r,"left")?u=-(c.left-e.left+dt(s,"left")):e.right>c.right-dt(r,"right")&&(u=e.right-c.right+dt(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,m=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-m;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:jn(i)}}function ex(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=n+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=t.root.elementFromPoint(o,i);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Kd(t.dom)}}function Kd(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=jn(r));return e}function tx({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Jd(n,r==0?0:r-e)}function Jd(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:o}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let xn=null;function nx(t){if(t.setActive)return t.setActive();if(xn)return t.focus(xn);let e=Kd(t);t.focus(xn==null?{get preventScroll(){return xn={preventScroll:!0},!0}}:void 0),xn||(xn=!1,Jd(e,0))}function Gd(t,e){let n,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=mt(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let m=f[h];if(m.top<=i&&m.bottom>=l){i=Math.max(m.bottom,i),l=Math.min(m.top,l);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<r){n=u,r=g,s=g&&n.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,u.nodeType==1&&g&&(o=d+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!a&&m.left<=e.left&&m.right>=e.left&&(a=u,c={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!n&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(o=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?rx(n,s):!n||r&&n.nodeType==1?{node:t,offset:o}:Gd(n,s)}function rx(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let i=Ct(r,1);if(i.top!=i.bottom&&jl(e,i)){s={node:t,offset:o+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function jl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function sx(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function ox(t,e,n){let{node:r,offset:s}=Gd(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return t.docView.posFromDOM(r,s,o)}function ix(t,e,n,r){let s=-1;for(let o=e,i=!1;o!=t.dom;){let l=t.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:t.docView.posFromDOM(e,n,-1)}function Yd(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let i=t.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(jl(e,c))return Yd(i,e,c)}}if((o=(o+1)%r)==s)break}return t}function lx(t,e){let n=t.dom.ownerDocument,r,s=0,o=Yy(n,e.left,e.top);o&&({node:r,offset:s}=o);let i=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!i||!t.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=t.dom.getBoundingClientRect();if(!jl(e,c)||(i=Yd(t.dom,e,c),!i))return null}if(Ne)for(let c=i;r&&c;c=jn(c))c.draggable&&(r=void 0);if(i=sx(i,e),r){if(Ue&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Pr&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=ix(t,r,s,e))}l==null&&(l=ox(t,i,e));let a=t.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function lc(t){return t.top<t.bottom||t.left<t.right}function Ct(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(lc(r))return r}return Array.prototype.find.call(n,lc)||t.getBoundingClientRect()}const ax=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Xd(t,e,n){let{node:r,offset:s,atom:o}=t.docView.domFromPos(e,n<0?-1:1),i=Pr||Ue;if(r.nodeType==3)if(i&&(ax.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=Ct(mt(r,s,s),n);if(Ue&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Ct(mt(r,s-1,s-1),-1);if(c.top==a.top){let u=Ct(mt(r,s,s+1),-1);if(u.top!=a.top)return Yn(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Yn(Ct(mt(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==He(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return oi(a.getBoundingClientRect(),!1)}if(o==null&&s<He(r)){let a=r.childNodes[s];if(a.nodeType==1)return oi(a.getBoundingClientRect(),!0)}return oi(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==He(r))){let a=r.childNodes[s-1],c=a.nodeType==3?mt(a,He(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Yn(Ct(c,1),!1)}if(o==null&&s<He(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?mt(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Yn(Ct(c,-1),!0)}return Yn(Ct(r.nodeType==3?mt(r):r,-n),n>=0)}function Yn(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function oi(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Qd(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function cx(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Qd(t,e,()=>{let{node:o}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=Xd(t,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=mt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const ux=/[\u0590-\u08ac]/;function dx(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=t.domSelection();return l?!ux.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:i:Qd(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:m,focusOffset:g}=t.domSelectionRange(),y=m&&!h.contains(m.nodeType==1?m:m.parentNode)||a==m&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):r.pos==r.start()||r.pos==r.end()}let ac=null,cc=null,uc=!1;function fx(t,e,n){return ac==e&&cc==n?uc:(ac=e,cc=n,uc=n=="up"||n=="down"?cx(t,e,n):dx(t,e,n))}const qe=0,dc=1,Kt=2,ct=3;class Lr{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=qe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let s=this.children[n];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,n,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[n-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[n];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=n>ke(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(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&n==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,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!n||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 n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],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,n){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 ef){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Zd&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?ke(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,n):{node:this.contentDOM,offset:o?ke(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,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 u=i+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=i;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=ke(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=ke(d.dom);break}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let o=Math.min(e,n),i=Math.max(e,n);for(let h=0,m=0;h<this.children.length;h++){let g=this.children[h],y=m+g.size;if(o>m&&i<y)return g.setSelection(e-m-g.border,n-m-g.border,r,s);m=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Ue||Ne)&&e==n){let{node:h,offset:m}=l;if(h.nodeType==3){if(d=!!(m&&h.nodeValue[m-1]==`
31
- `),d&&m==h.nodeValue.length)for(let g=h,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:ke(y)+1});break}let x=g.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let g=h.childNodes[m-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Ue&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(s=!0)}if(!(s||d&&Ne)&&on(l.node,l.offset,u.anchorNode,u.anchorOffset)&&on(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&Ue)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let m=l;l=a,a=m}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,n){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&&n>=r:e<i&&n>r){let l=r+o.border,a=i-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==i?Kt:dc,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=ct:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Kt:ct}r=i}this.dirty=Kt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Kt:dc;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Zd extends Lr{constructor(e,n,r,s){let o,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!n.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=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==qe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(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 hx extends Lr{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ln extends Lr{constructor(e,n,r,s,o){super(e,[],r,s),this.mark=n,this.spec=o}static create(e,n,r,s){let o=s.nodeViews[n.type.name],i=o&&o(n,s,r);return(!i||!i.dom)&&(i=un.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new ln(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ct||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ct&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=qe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=qe}}slice(e,n,r){let s=ln.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=_i(o,n,i,r)),e>0&&(o=_i(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 Lt extends Lr{constructor(e,n,r,s,o,i,l,a,c){super(e,[],o,i),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,o,i){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=un.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=rf(u,r,n),c?a=new px(e,n,r,s,u,d||null,f,c,o,i+1):n.isText?new wo(e,n,r,s,u,f,o):new Lt(e,n,r,s,u,d||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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,n,r){return this.dirty==qe&&e.eq(this.node)&&ys(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,o=e.composing?this.localCompositionInfo(e,n):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new gx(this,i&&i.node,e);bx(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?ne.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,s)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Kt)&&(i&&this.protectLocalComposition(e,i),tf(this.contentDOM,this.children,e),Rn&&kx(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof q)||r<n||s>n+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=vx(this.node.content,i,r-n,s-n);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let o=n;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 hx(this,o,n,s);e.input.compositionNodes.push(i),this.children=_i(this.children,r,r+s.length,e,i)}update(e,n,r,s){return this.dirty==ct||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=qe}updateOuterDeco(e){if(ys(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=nf(this.dom,this.nodeDOM,$i(this.outerDeco,this.node,n),$i(e,this.node,n)),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 fc(t,e,n,r,s){rf(r,e,t);let o=new Lt(void 0,t,e,n,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class wo extends Lt{constructor(e,n,r,s,o,i,l){super(e,n,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,n,r,s){return this.dirty==ct||this.dirty!=qe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=qe||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=qe,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),o=document.createTextNode(s.text);return new wo(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ct)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ef extends Lr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class px extends Lt{constructor(e,n,r,s,o,i,l,a,c,u){super(e,n,r,s,o,i,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==ct)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,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 tf(t,e,n){let r=t.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==t){for(;l!=r;)r=hc(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(i instanceof ln){let a=r?r.previousSibling:t.lastChild;tf(i.contentDOM,i.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=hc(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const ir=function(t){t&&(this.nodeName=t)};ir.prototype=Object.create(null);const Jt=[new ir];function $i(t,e,n){if(t.length==0)return Jt;let r=n?Jt[0]:new ir,s=[r];for(let o=0;o<t.length;o++){let i=t[o].type.attrs;if(i){i.nodeName&&s.push(r=new ir(i.nodeName));for(let l in i){let a=i[l];a!=null&&(n&&s.length==1&&s.push(r=new ir(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 nf(t,e,n,r){if(n==Jt&&r==Jt)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=n[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Jt[0]),s=a}mx(s,l||Jt[0],i)}return s}function mx(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&t.classList.add(s[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function rf(t,e,n){return nf(t,t,Jt,$i(e,n,t.nodeType!=1))}function ys(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function hc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class gx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=yx(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,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=qe,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=ln.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,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,n,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,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,s,o){let i=this.top.children[s];return i.dirty==ct&&i.dom==i.contentDOM&&(i.dirty=Kt),i.update(e,n,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==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=n}}updateNextNode(e,n,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Lt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ct&&ys(n,a.outerDeco));if(!f&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Kt,d.updateChildren(s,i+1),d.dirty=qe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,o,i){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!ys(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Lt.create(this.top,n,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,n,r,s,o){let i=Lt.create(this.top,e,n,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,n,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 Zd(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof ln;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof wo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ne||ge)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.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 ef(this.top,[],r,null);n!=this.top?n.children.push(s):n.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 yx(t,e){let n=e,r=n.children.length,s=t.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof ln)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function xx(t,e){return t.type.side-e.type.side}function bx(t,e,n,r){let s=e.locals(t),o=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let y=s[i++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(xx);for(let y=0;y<d.length;y++)n(d[y],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let m=o+f.nodeSize;if(f.isText){let y=m;i<s.length&&s[i].from<y&&(y=s[i].from);for(let x=0;x<l.length;x++)l[x].to<y&&(y=l[x].to);y<m&&(a=f.cut(y-o),f=f.cut(0,y-o),m=y,h=-1)}else for(;i<s.length&&s[i].to<m;)i++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(o,f),h),o=m}}function kx(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function vx(t,e,n,r){for(let s=0,o=0;s<t.childCount&&o<=r;){let i=t.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<t.childCount;){let c=t.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){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>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function _i(t,e,n,r,s){let o=[];for(let i=0,l=0;i<t.length;i++){let a=t[i],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function Rl(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(vo(n)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&V.isSelectable(d)&&s.parent&&!(d.isInline&&Jy(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;c=new V(i==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let h=0;h<n.rangeCount;h++){let m=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(d<0)return null;[a,i]=f==t.state.selection.anchor?[f,d]:[d,f],l=r.resolve(i)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=Dl(t,u,l,d)}return c}function sf(t){return t.editable?t.hasFocus():lf(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function bt(t,e=!1){let n=t.state.selection;if(of(t,n),!!sf(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ge){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&on(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Sx(t);else{let{anchor:r,head:s}=n,o,i;pc&&!(n instanceof q)&&(n.$from.parent.inlineContent||(o=mc(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=mc(t,n.to))),t.docView.setSelection(r,s,t,e),pc&&(o&&gc(o),i&&gc(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wx(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const pc=Ne||ge&&Ud<63;function mc(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(Ne&&s&&s.contentEditable=="false")return ii(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return ii(s);if(o)return ii(o)}}function ii(t){return t.contentEditable="true",Ne&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function gc(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function wx(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!sf(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Sx(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,ke(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ie&&Pt<=11&&(n.disabled=!0,n.disabled=!1)}function of(t,e){if(e instanceof V){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(yc(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else yc(t)}function yc(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Dl(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||q.between(e,n,r)}function xc(t){return t.editable&&!t.hasFocus()?!1:lf(t)}function lf(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Cx(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return on(e.node,e.offset,n.anchorNode,n.anchorOffset)}function zi(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return o&&Y.findFrom(o,e)}function Nt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function bc(t,e,n){let r=t.state.selection;if(r instanceof q)if(n.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=t.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return Nt(t,new q(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=zi(t.state,e);return s&&s instanceof V?Nt(t,s):!1}else if(!(Ve&&n.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=t.docView.descAt(l))&&!i.contentDOM?V.isSelectable(o)?Nt(t,new V(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):Pr?Nt(t,new q(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof V&&r.node.isInline)return Nt(t,new q(e>0?r.$to:r.$from));{let s=zi(t.state,e);return s?Nt(t,s):!1}}}function xs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function lr(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function bn(t,e){return e<0?Nx(t):Ex(t)}function Nx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,o,i=!1;for(Ue&&n.nodeType==1&&r<xs(n)&&lr(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(lr(l,-1))s=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(af(n))break;{let l=n.previousSibling;for(;l&&lr(l,-1);)s=n.parentNode,o=ke(l),l=l.previousSibling;if(l)n=l,r=xs(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Bi(t,n,r):s&&Bi(t,s,o)}function Ex(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=xs(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(lr(l,1))o=n,i=++r;else break}else{if(af(n))break;{let l=n.nextSibling;for(;l&&lr(l,1);)o=l.parentNode,i=ke(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=xs(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&Bi(t,o,i)}function af(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Tx(t,e){for(;t&&e==t.childNodes.length&&!Dr(t);)e=ke(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Mx(t,e){for(;t&&!e&&!Dr(t);)e=ke(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Bi(t,e,n){if(e.nodeType!=3){let o,i;(i=Tx(e,n))?(e=i,n=0):(o=Mx(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(vo(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&bt(t)},50)}function kc(t,e){let n=t.state.doc.resolve(e);if(!(ge||qd)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let o=t.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<n.end()){let o=t.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(t.dom).direction=="rtl"?"rtl":"ltr"}function vc(t,e,n){let r=t.state.selection;if(r instanceof q&&!r.empty||n.indexOf("s")>-1||Ve&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=zi(t.state,e);if(i&&i instanceof V)return Nt(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof _e?Y.near(i,e):Y.findFrom(i,e);return l?Nt(t,l):!1}return!1}function wc(t,e){if(!(t.state.selection instanceof q))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=t.state.tr;return e<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),t.dispatch(i),!0}return!1}function Sc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Ox(t){if(!Ne||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Sc(t,r,"true"),setTimeout(()=>Sc(t,r,"false"),20)}return!1}function Ax(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Ix(t,e){let n=e.keyCode,r=Ax(e);if(n==8||Ve&&n==72&&r=="c")return wc(t,-1)||bn(t,-1);if(n==46&&!e.shiftKey||Ve&&n==68&&r=="c")return wc(t,1)||bn(t,1);if(n==13||n==27)return!0;if(n==37||Ve&&n==66&&r=="c"){let s=n==37?kc(t,t.state.selection.from)=="ltr"?-1:1:-1;return bc(t,s,r)||bn(t,s)}else if(n==39||Ve&&n==70&&r=="c"){let s=n==39?kc(t,t.state.selection.from)=="ltr"?1:-1:1;return bc(t,s,r)||bn(t,s)}else{if(n==38||Ve&&n==80&&r=="c")return vc(t,-1,r)||bn(t,-1);if(n==40||Ve&&n==78&&r=="c")return Ox(t)||vc(t,1,r)||bn(t,1);if(r==(Ve?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Pl(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{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;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=t.someProp("clipboardSerializer")||un.fromSchema(t.state.schema),l=pf(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=hf[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let m=l.createElement(u[h]);for(;a.firstChild;)m.appendChild(a.firstChild);a.appendChild(m),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
32
-
33
- `);return{dom:a,text:f,slice:e}}function cf(t,e,n,r,s){let o=s.parent.type.spec.code,i,l;if(!n&&!e)return null;let a=!!e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,o||r,t)}),o)return l=new $(O.from(t.state.schema.text(e.replace(/\r\n?/g,`
34
- `))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",f=>f(e,s,r,t));if(d)l=d;else{let f=s.marks(),{schema:h}=t.state,m=un.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=Px(n),Pr&&Lx(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Dt.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!jx.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=$x(Cc(l,+u[1],+u[2]),u[4]);else if(l=$.maxOpen(Rx(l.content,s),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Cc(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const jx=/^(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 Rx(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),o,i=[];if(t.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&df(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ff(i[i.length-1],o.length));let u=uf(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return O.from(i)}return t}function uf(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function df(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let o=df(t,e,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(O.from(uf(n,t,s+1))))}}function ff(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,ff(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(O.empty,!0);return t.copy(n.append(r))}function Fi(t,e,n,r,s,o){let i=e<0?t.firstChild:t.lastChild,l=i.content;return t.childCount>1&&(o=0),s<r-1&&(l=Fi(l,e,n,r,s+1,o)),s>=n&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(l))}function Cc(t,e,n){return e<t.openStart&&(t=new $(Fi(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $(Fi(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const hf={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 Nc=null;function pf(){return Nc||(Nc=document.implementation.createHTMLDocument("title"))}let li=null;function Dx(t){let e=window.trustedTypes;return e?(li||(li=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),li.createHTML(t)):t}function Px(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=pf().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&hf[r[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=Dx(t),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;return n}function Lx(t){let e=t.querySelectorAll(ge?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function $x(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:o,openEnd:i}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=O.from(a.create(r[l+1],s)),o++,i++}return new $(s,o,i)}const Te={},Me={},_x={touchstart:!0,touchmove:!0};class zx{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 Bx(t){for(let e in Te){let n=Te[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Vx(t,r)&&!Ll(t,r)&&(t.editable||!(r.type in Me))&&n(t,r)},_x[e]?{passive:!0}:void 0)}Ne&&t.dom.addEventListener("input",()=>null),Vi(t)}function jt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Fx(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Vi(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ll(t,r))})}function Ll(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Vx(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Hx(t,e){!Ll(t,e)&&Te[e.type]&&(t.editable||!(e.type in Me))&&Te[e.type](t,e)}Me.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!gf(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(yt&&ge&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Rn&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,qt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Ix(t,n)?n.preventDefault():jt(t,"key")};Me.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Me.keypress=(t,e)=>{let n=e;if(gf(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ve&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,s,o))&&t.dispatch(o()),n.preventDefault()}};function So(t){return{left:t.clientX,top:t.clientY}}function Wx(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function $l(t,e,n,r,s){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(t.someProp(e,l=>i>o.depth?l(t,n,o.nodeAfter,o.before(i),s,!0):l(t,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function Mn(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Ux(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&V.isSelectable(r)?(Mn(t,new V(n)),!0):!1}function qx(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof V&&(r=n.node);let o=t.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(V.isSelectable(l)){r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?s=o.before(n.$from.depth):s=o.before(i);break}}return s!=null?(Mn(t,V.create(t.state.doc,s)),!0):!1}function Kx(t,e,n,r,s){return $l(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(s?qx(t,n):Ux(t,n))}function Jx(t,e,n,r){return $l(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Gx(t,e,n,r){return $l(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||Yx(t,n,r)}function Yx(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Mn(t,q.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)Mn(t,q.create(r,l+1,l+1+i.content.size));else if(V.isSelectable(i))Mn(t,V.create(r,l));else continue;return!0}}function _l(t){return bs(t)}const mf=Ve?"metaKey":"ctrlKey";Te.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=_l(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&Wx(n,t.input.lastClick)&&!n[mf]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button};let i=t.posAtCoords(So(n));i&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Xx(t,i,n,!!r)):(o=="doubleClick"?Jx:Gx)(t,i.pos,i.inside,n)?n.preventDefault():jt(t,"pointer"))};class Xx{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[mf],this.allowDefault=r.shiftKey;let o,i;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),i=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,i=u.depth?u.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 V&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ue&&!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)),jt(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(()=>bt(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(So(e))),this.updateAllowDefault(e),this.allowDefault||!n?jt(this.view,"pointer"):Kx(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ne&&this.mightDrag&&!this.mightDrag.node.isAtom||ge&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Mn(this.view,Y.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):jt(this.view,"pointer")}move(e){this.updateAllowDefault(e),jt(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)}}Te.touchstart=t=>{t.input.lastTouch=Date.now(),_l(t),jt(t,"pointer")};Te.touchmove=t=>{t.input.lastTouch=Date.now(),jt(t,"pointer")};Te.contextmenu=t=>_l(t);function gf(t,e){return t.composing?!0:Ne&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Qx=yt?5e3:-1;Me.compositionstart=Me.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof q&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ge&&qd&&Zx(t)))t.markCursor=t.state.storedMarks||n.marks(),bs(t,!0),t.markCursor=null;else if(bs(t,!e.selection.empty),Ue&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.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=t.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}t.input.composing=!0}yf(t,Qx)};function Zx(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Me.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,yf(t,20))};function yf(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>bs(t),e))}function xf(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=tb());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function eb(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=qy(e.focusNode,e.focusOffset),r=Ky(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function tb(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function bs(t,e=!1){if(!(yt&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),xf(t),e||t.docView&&t.docView.dirty){let n=Rl(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function nb(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const kr=Ie&&Pt<15||Rn&&Xy<604;Te.copy=Me.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let o=kr?null:n.clipboardData,i=r.content(),{dom:l,text:a}=Pl(t,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):nb(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function rb(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function sb(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?vr(t,r.value,null,s,e):vr(t,r.textContent,r.innerHTML,s,e)},50)}function vr(t,e,n,r,s){let o=cf(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,o||$.empty)))return!0;if(!o)return!1;let i=rb(o),l=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bf(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Me.paste=(t,e)=>{let n=e;if(t.composing&&!yt)return;let r=kr?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&vr(t,bf(r),r.getData("text/html"),s,n)?n.preventDefault():sb(t,n)};class kf{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const ob=Ve?"altKey":"ctrlKey";function vf(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[ob]}Te.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,o=s.empty?null:t.posAtCoords(So(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof V?s.to-1:s.to))){if(r&&r.mightDrag)i=V.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=V.create(t.state.doc,d.posBefore))}}let l=(i||t.state.selection).content(),{dom:a,text:c,slice:u}=Pl(t,l);(!n.dataTransfer.files.length||!ge||Ud>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(kr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",kr||n.dataTransfer.setData("text/plain",c),t.dragging=new kf(u,vf(t,n),i)};Te.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Me.dragover=Me.dragenter=(t,e)=>e.preventDefault();Me.drop=(t,e)=>{try{ib(t,e,t.dragging)}finally{t.dragging=null}};function ib(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(So(e));if(!r)return;let s=t.state.doc.resolve(r.pos),o=n&&n.slice;o?t.someProp("transformPasted",h=>{o=h(o,t,!1)}):o=cf(t,bf(e.dataTransfer),kr?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&vf(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||$.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Cd(t.state.doc,s.pos,o):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(i){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&V.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new V(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((m,g,y,x)=>h=x),a.setSelection(Dl(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Te.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&bt(t)},20))};Te.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Te.beforeinput=(t,e)=>{if(ge&&yt&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,qt(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Me)Te[t]=Me[t];function wr(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ks{constructor(e,n){this.toDOM=e,this.spec=n||Zt,this.side=this.spec.side||0}map(e,n,r,s){let{pos:o,deleted:i}=e.mapResult(n.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 ks&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&wr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $t{constructor(e,n){this.attrs=e,this.spec=n||Zt}map(e,n,r,s){let o=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new Ce(o,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof $t&&wr(this.attrs,e.attrs)&&wr(this.spec,e.spec)}static is(e){return e.type instanceof $t}destroy(){}}class zl{constructor(e,n){this.attrs=e,this.spec=n||Zt}map(e,n,r,s){let o=e.mapResult(n.from+s,1);if(o.deleted)return null;let i=e.mapResult(n.to+s,-1);return i.deleted||i.pos<=o.pos?null:new Ce(o.pos-r,i.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),o;return s==n.from&&!(o=e.child(r)).isText&&s+o.nodeSize==n.to}eq(e){return this==e||e instanceof zl&&wr(this.attrs,e.attrs)&&wr(this.spec,e.spec)}destroy(){}}class Ce{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ce(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Ce(e,e,new ks(n,r))}static inline(e,n,r,s){return new Ce(e,n,new $t(r,s))}static node(e,n,r,s){return new Ce(e,n,new zl(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof $t}get widget(){return this.type instanceof ks}}const vn=[],Zt={};class se{constructor(e,n){this.local=e.length?e:vn,this.children=n.length?n:vn}static create(e,n){return n.length?vs(n,e,0,Zt):Se}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=n&&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]<n&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,n-l,r,s+l,o)}}map(e,n,r){return this==Se||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Zt)}mapInner(e,n,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(n,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?lb(this.children,i||[],e,n,r,s,o):i?new se(i.sort(en),vn):Se}add(e,n){return n.length?this==Se?se.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Sf(n,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,u,c+1):s.splice(o,0,a,a+l.nodeSize,vs(u,l,c+1,Zt)),o+=3}});let i=wf(o?Cf(n):n,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new se(i.length?this.local.concat(i).sort(en):this.local,s||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+n,a=r[o+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=Se?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,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new se(s,r):Se}forChild(e,n){if(this==Se)return this;if(n.isLeaf)return se.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+n.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 $t){let c=Math.max(o,a.from)-o,u=Math.min(i,a.to)-o;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new se(s.sort(en),vn);return r?new Mt([l,r]):l}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof se)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Bl(this.localsInner(e))}localsInner(e){if(this==Se)return vn;if(e.inlineContent||!this.local.some($t.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $t||n.push(this.local[r]);return n}forEachSet(e){e(this)}}se.empty=new se([],[]);se.removeOverlap=Bl;const Se=se.empty;class Mt{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Zt));return Mt.from(r)}forChild(e,n){if(n.isLeaf)return se.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,n);o!=Se&&(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 n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let i=0;i<o.length;i++)n.push(o[i])}}return n?Bl(r?n:n.sort(en)):vn}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new Mt(e.every(n=>n instanceof se)?e:e.reduce((n,r)=>n.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function lb(t,e,n,r,s,o,i){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,m,g)=>{let y=g-m-(h-f);for(let x=0;x<l.length;x+=3){let b=l[x+1];if(b<0||f>b+u-d)continue;let k=l[x]+u-d;h>=k?l[x+1]=f<=k?-2:-1:f>=u&&y&&(l[x]+=y,l[x+1]+=y)}d+=y}),u=n.maps[c].map(u,-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 u=n.map(t[c]+o),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+o,-1),h=f-s,{index:m,offset:g}=r.content.findIndex(d),y=r.maybeChild(m);if(y&&g==d&&g+y.nodeSize==h){let x=l[c+2].mapInner(n,y,u+1,t[c]+o+1,i);x!=Se?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ab(l,t,e,n,s,o,i),u=vs(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new se(e.sort(en),l)}function wf(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Ce(s.from+e,s.to+e,s.type))}return n}function ab(t,e,n,r,s,o,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function Sf(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let o=0,i;o<t.length;o++)(i=t[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),t[o]=null);return s}function Cf(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function vs(t,e,n,r){let s=[],o=!1;e.forEach((l,a)=>{let c=Sf(t,l,a+n);if(c){o=!0;let u=vs(c,l,n+a+1,r);u!=Se&&s.push(a,a+l.nodeSize,u)}});let i=wf(o?Cf(t):t,-n).sort(en);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 se(i,s):Se}function en(t,e){return t.from-e.from||t.to-e.to}function Bl(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[s]=o.copy(o.from,r.to),Ec(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),Ec(e,s,r.copy(o.from,r.to)));break}}}return e}function Ec(t,e,n){for(;e<t.length&&en(n,t[e])>0;)e++;t.splice(e,0,n)}function ai(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Se&&e.push(r)}),t.cursorWrapper&&e.push(se.create(t.state.doc,[t.cursorWrapper.deco])),Mt.from(e)}const cb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ub=Ie&&Pt<=11;class db{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 fb{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new db,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]);Ie&&Pt<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),ub&&(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,cb)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(xc(this.view)){if(this.suppressingSelectionUpdates)return bt(this.view);if(Ie&&Pt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&on(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 n=new Set,r;for(let o=e.focusNode;o;o=jn(o))n.add(o);for(let o=e.anchorNode;o;o=jn(o))if(n.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 n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&xc(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(Ue&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||mb(e,d)!=h)&&f.remove()}}}else if((ge||Ne)&&a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&u.parentNode.removeChild(u)}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&vo(r)&&(c=Rl(e))&&c.eq(Y.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,bt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),hb(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||bt(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.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 u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}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(Ie&&Pt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let i=s&&s.parentNode==e.target?ke(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?ke(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 Tc=new WeakMap,Mc=!1;function hb(t){if(!Tc.has(t)&&(Tc.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ue,Mc)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."),Mc=!0}}function Oc(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return on(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function pb(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Oc(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Oc(t,n):null}function mb(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function gb(t,e,n){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],vo(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ge&&t.input.lastKeyCode===8)for(let y=o;y>s;y--){let x=r.childNodes[y-1],b=x.pmViewDesc;if(x.nodeName=="BR"&&!b){o=y;break}if(!b||b.size)break}let d=t.state.doc,f=t.someProp("domParser")||Dt.fromSchema(t.state.schema),h=d.resolve(i),m=null,g=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:yb,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=y),m={anchor:y+i,head:x+i}}return{doc:g,sel:m,from:i,to:l}}function yb(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ne&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Ne&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xb=/^(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 bb(t,e,n,r,s){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let w=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=Rl(t,w);if(M&&!t.state.selection.eq(M)){if(ge&&yt&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",A=>A(t,qt(13,"Enter"))))return;let E=t.state.tr.setSelection(M);w=="pointer"?E.setMeta("pointer",!0):w=="key"&&E.scrollIntoView(),o&&E.setMeta("composition",o),t.dispatch(E)}return}let i=t.state.doc.resolve(e),l=i.sharedDepth(n);e=i.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=gb(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let m=wb(d.content,c.doc.content,c.from,f,h);if(m&&t.input.domChangeCount++,(Rn&&t.input.lastIOSEnter>Date.now()-225||yt)&&s.some(w=>w.nodeType==1&&!xb.test(w.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",w=>w(t,qt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(r&&a instanceof q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))m={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let w=Ac(t,t.state.doc,c.sel);if(w&&!w.eq(t.state.selection)){let M=t.state.tr.setSelection(w);o&&M.setMeta("composition",o),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof q&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Ie&&Pt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>c.from&&c.doc.textBetween(m.start-c.from-1,m.start-c.from+1)=="  "&&(m.start--,m.endA--,m.endB--);let g=c.doc.resolveNoCache(m.start-c.from),y=c.doc.resolveNoCache(m.endB-c.from),x=u.resolve(m.start),b=g.sameParent(y)&&g.parent.inlineContent&&x.end()>=m.endA;if((Rn&&t.input.lastIOSEnter>Date.now()-225&&(!b||s.some(w=>w.nodeName=="DIV"||w.nodeName=="P"))||!b&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&t.someProp("handleKeyDown",w=>w(t,qt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&vb(u,m.start,m.endA,g,y)&&t.someProp("handleKeyDown",w=>w(t,qt(8,"Backspace")))){yt&&ge&&t.domObserver.suppressSelectionUpdates();return}ge&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),yt&&!b&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==m.endA&&(m.endB-=2,y=c.doc.resolveNoCache(m.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(w){return w(t,qt(13,"Enter"))})},20));let k=m.start,S=m.endA,v=w=>{let M=w||t.state.tr.replace(k,S,c.doc.slice(m.start-c.from,m.endB-c.from));if(c.sel){let E=Ac(t,M.doc,c.sel);E&&!(ge&&t.composing&&E.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(E.head==k||E.head==M.mapping.map(S)-1)||Ie&&E.empty&&E.head==k)&&M.setSelection(E)}return o&&M.setMeta("composition",o),M.scrollIntoView()},C;if(b)if(g.pos==y.pos){Ie&&Pt<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>bt(t),20));let w=v(t.state.tr.delete(k,S)),M=u.resolve(m.start).marksAcross(u.resolve(m.endA));M&&w.ensureMarks(M),t.dispatch(w)}else if(m.endA==m.endB&&(C=kb(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let w=v(t.state.tr);C.type=="add"?w.addMark(k,S,C.mark):w.removeMark(k,S,C.mark),t.dispatch(w)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let w=g.parent.textBetween(g.parentOffset,y.parentOffset),M=()=>v(t.state.tr.insertText(w,k,S));t.someProp("handleTextInput",E=>E(t,k,S,w,M))||t.dispatch(M())}else t.dispatch(v());else t.dispatch(v())}function Ac(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Dl(t,e.resolve(n.anchor),e.resolve(n.head))}function kb(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,o=r,i,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(O.from(c).eq(t))return{mark:l,type:i}}function vb(t,e,n,r,s){if(n-e<=s.pos-r.pos||ci(r,!0,!1)<s.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=t.resolve(ci(o,!0,!0));return!i.parent.isTextblock||i.pos>n||ci(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function ci(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function wb(t,e,n,r,s){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:i,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&t.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&Ic(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<t.size&&Ic(t.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function Ic(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Nf{constructor(e,n){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 zx,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Lc),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=Dc(this),Rc(this),this.nodeViews=Pc(this),this.docView=fc(this.state.doc,jc(this),ai(this),this.dom,this),this.domObserver=new fb(this,(r,s,o,i)=>bb(this,r,s,o,i)),this.domObserver.start(),Bx(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Vi(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Lc),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(xf(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Pc(this);Cb(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Vi(this),this.editable=Dc(this),Rc(this);let a=ai(this),c=jc(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&ex(this);if(i){this.domObserver.stop();let h=d&&(Ie||ge)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Sb(s.selection,e.selection);if(d){let m=ge?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=eb(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=fc(e.doc,c,a,this.dom,this)),m&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Cx(this))?bt(this,h):(of(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),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&tx(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof V){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&ic(this,n.getBoundingClientRect(),e)}else ic(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 n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){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-n.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new kf(e.slice,e.move,s<0?void 0:V.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=n?n(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=n?n(l):l))return s}}hasFocus(){if(Ie){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&&nx(this.dom),bt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return lx(this,e)}coordsAtPos(e,n=1){return Xd(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return fx(this,n||this.state,e)}pasteHTML(e,n){return vr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return vr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Pl(this,e)}destroy(){this.docView&&(Fx(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ai(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Wy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Hx(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ne&&this.root.nodeType===11&&Gy(this.dom.ownerDocument)==this.dom&&pb(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Nf.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function jc(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ce.node(0,t.state.doc.content.size,e)]}function Rc(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ce.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Dc(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Sb(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Pc(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Cb(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Lc(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var _t={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:"'"},ws={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Eb=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)_t[48+ve]=_t[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)_t[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)_t[ve]=String.fromCharCode(ve+32),ws[ve]=String.fromCharCode(ve);for(var ui in _t)ws.hasOwnProperty(ui)||(ws[ui]=_t[ui]);function Tb(t){var e=Nb&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Eb&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ws:_t)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Mb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ob=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ab(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");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))Mb?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Ib(t){let e=Object.create(null);for(let n in t)e[Ab(n)]=t[n];return e}function di(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function jb(t){return new ie({props:{handleKeyDown:Ef(t)}})}function Ef(t){let e=Ib(t);return function(n,r){let s=Tb(r),o,i=e[di(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[di(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ob&&r.ctrlKey&&r.altKey)&&(o=_t[r.keyCode])&&o!=s){let l=e[di(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Rb=Object.defineProperty,Fl=(t,e)=>{for(var n in e)Rb(t,n,{get:e[n],enumerable:!0})};function Co(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;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=n.selection,s=n.doc,o=n.storedMarks,n}}}var No=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([i,l])=>[i,(...c)=>{const u=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,f])=>[d,(...m)=>{const g=this.buildProps(a,e),y=f(...m)(g);return i.push(y),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.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(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i={tr:t,editor:r,view:o,state:Co({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},Tf={};Fl(Tf,{blur:()=>Db,clearContent:()=>Pb,clearNodes:()=>Lb,command:()=>$b,createParagraphNear:()=>_b,cut:()=>zb,deleteCurrentNode:()=>Bb,deleteNode:()=>Fb,deleteRange:()=>Vb,deleteSelection:()=>Hb,enter:()=>Wb,exitCode:()=>Ub,extendMarkRange:()=>qb,first:()=>Kb,focus:()=>Gb,forEach:()=>Yb,insertContent:()=>Xb,insertContentAt:()=>ek,joinBackward:()=>rk,joinDown:()=>nk,joinForward:()=>sk,joinItemBackward:()=>ok,joinItemForward:()=>ik,joinTextblockBackward:()=>lk,joinTextblockForward:()=>ak,joinUp:()=>tk,keyboardShortcut:()=>uk,lift:()=>dk,liftEmptyBlock:()=>fk,liftListItem:()=>hk,newlineInCode:()=>pk,resetAttributes:()=>mk,scrollIntoView:()=>gk,selectAll:()=>yk,selectNodeBackward:()=>xk,selectNodeForward:()=>bk,selectParentNode:()=>kk,selectTextblockEnd:()=>vk,selectTextblockStart:()=>wk,setContent:()=>Sk,setMark:()=>Hk,setMeta:()=>Wk,setNode:()=>Uk,setNodeSelection:()=>qk,setTextDirection:()=>Kk,setTextSelection:()=>Jk,sinkListItem:()=>Gk,splitBlock:()=>Yk,splitListItem:()=>Xk,toggleList:()=>Qk,toggleMark:()=>Zk,toggleNode:()=>ev,toggleWrap:()=>tv,undoInputRule:()=>nv,unsetAllMarks:()=>rv,unsetMark:()=>sv,unsetTextDirection:()=>ov,updateAttributes:()=>iv,wrapIn:()=>lv,wrapInList:()=>av});var Db=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),Pb=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),Lb=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:o,$to:i})=>{t.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const m=qn(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(m||m===0)&&e.lift(h,m)})}),!0},$b=t=>e=>t(e),_b=()=>({state:t,dispatch:e})=>Bd(t,e),zb=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new q(r.doc.resolve(Math.max(i-1,0)))),!0},Bb=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.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);t.delete(l,a).scrollIntoView()}return!0}return!1};function pe(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var Fb=t=>({tr:e,state:n,dispatch:r})=>{const s=pe(t,n.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},Vb=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},Hb=()=>({state:t,dispatch:e})=>Tl(t,e),Wb=()=>({commands:t})=>t.keyboardShortcut("Enter"),Ub=()=>({state:t,dispatch:e})=>Oy(t,e);function Vl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ss(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Vl(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Mf(t,e,n={}){return t.find(r=>r.type===e&&Ss(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function $c(t,e,n={}){return!!Mf(t,e,n)}function Hl(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Mf([...s.node.marks],e,n)))return;let i=s.index,l=t.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&$c([...t.parent.child(i-1).marks],e,n);)i-=1,l-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&$c([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function vt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var qb=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const o=vt(t,r.schema),{doc:i,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=Hl(a,o,e);if(d&&d.from<=c&&d.to>=u){const f=q.create(i,d.from,d.to);n.setSelection(f)}}return!0},Kb=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Of(t){return t instanceof q}function Gt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Af(t,e=null){if(!e)return null;const n=Y.atStart(t),r=Y.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,o=r.to;return e==="all"?q.create(t,Gt(0,s,o),Gt(t.content.size,s,o)):q.create(t,Gt(e,s,o),Gt(e,s,o))}function Hi(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Sr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Jb(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Gb=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(Sr()||Hi())&&r.dom.focus(),Jb()&&!Sr()&&!Hi()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Of(n.state.selection))return i(),!0;const l=Af(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},Yb=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Xb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),If=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&If(r)}return t};function qr(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return If(n)}function Cr(t,e,n){if(t instanceof We||t instanceof O)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return O.fromArray(t.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),Cr("",e,n)}if(s){if(n.errorOnInvalidContent){let i=!1,l="";const a=new hd({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(n.slice?Dt.fromSchema(a).parseSlice(qr(t),n.parseOptions):Dt.fromSchema(a).parse(qr(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=Dt.fromSchema(e);return n.slice?o.parseSlice(qr(t),n.parseOptions).content:o.parse(qr(t),n.parseOptions)}return Cr("",e,n)}function Qb(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof me||s instanceof ye))return;const o=t.mapping.maps[r];let i=0;o.forEach((l,a,c,u)=>{i===0&&(i=u)}),t.setSelection(Y.near(t.doc.resolve(i),n))}var Zb=t=>!("type"in t),ek=(t,e,n)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Cr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=Cr(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((Zb(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof O){let y="";e.forEach(x=>{x.text&&(y+=x.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),x=y.node(),b=y.parentOffset===0,k=x.isText||x.isTextblock,S=x.content.size>0;b&&k&&S&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&Qb(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},tk=()=>({state:t,dispatch:e})=>Ey(t,e),nk=()=>({state:t,dispatch:e})=>Ty(t,e),rk=()=>({state:t,dispatch:e})=>Rd(t,e),sk=()=>({state:t,dispatch:e})=>$d(t,e),ok=()=>({state:t,dispatch:e,tr:n})=>{try{const r=xo(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},ik=()=>({state:t,dispatch:e,tr:n})=>{try{const r=xo(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},lk=()=>({state:t,dispatch:e})=>Cy(t,e),ak=()=>({state:t,dispatch:e})=>Ny(t,e);function jf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function ck(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");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))Sr()||jf()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}var uk=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const o=ck(t).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(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function zt(t,e,n={}){const{from:r,to:s,empty:o}=t.selection,i=e?pe(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),m=Math.min(s,f+d.nodeSize);l.push({node:d,from:h,to:m})});const a=s-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>Ss(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var dk=(t,e={})=>({state:n,dispatch:r})=>{const s=pe(t,n.schema);return zt(n,s,e)?My(n,r):!1},fk=()=>({state:t,dispatch:e})=>Fd(t,e),hk=t=>({state:e,dispatch:n})=>{const r=pe(t,e.schema);return By(r)(e,n)},pk=()=>({state:t,dispatch:e})=>zd(t,e);function Eo(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function _c(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var mk=(t,e)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=Eo(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=pe(t,r.schema)),l==="mark"&&(i=vt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{o&&o===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,_c(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,i.create(_c(f.attrs,e))))})})}),a},gk=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),yk=()=>({tr:t,dispatch:e})=>{if(e){const n=new _e(t.doc);t.setSelection(n)}return!0},xk=()=>({state:t,dispatch:e})=>Pd(t,e),bk=()=>({state:t,dispatch:e})=>_d(t,e),kk=()=>({state:t,dispatch:e})=>jy(t,e),vk=()=>({state:t,dispatch:e})=>Py(t,e),wk=()=>({state:t,dispatch:e})=>Dy(t,e);function Wi(t,e,n={},r={}){return Cr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Sk=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=Wi(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return i&&o.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Rf(t,e){const n=vt(e,t.schema),{from:r,to:s,empty:o}=t.selection,i=[];o?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Df(t,e){const n=new Od(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function Ck(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Nk(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function Ek(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function To(t){return e=>Ek(e.$from,t)}function F(t,e,n){return t.config[e]===void 0&&t.parent?F(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?F(t.parent,e,n):null}):t.config[e]}function Wl(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=F(e,"addExtensions",n);return r?[e,...Wl(r())]:e}).flat(10)}function Ul(t,e){const n=un.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Pf(t){return typeof t=="function"}function te(t,e=void 0,...n){return Pf(t)?e?t.bind(e)(...n):t(...n):t}function Tk(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Dn(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Lf(t){const e=[],{nodeExtensions:n,markExtensions:r}=Dn(t),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage,extensions:s},a=F(i,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...o,...h}})})})})}),s.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage},a=F(i,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...o,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:i.name,name:u,attribute:f})})}),e}function oe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).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(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),l.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[s]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=o}),r},{})}function Pn(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>oe(n,r),{})}function Mk(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function zc(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(n):Mk(n.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function Bc(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Tk(n)?!1:n!=null))}function Fc(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function Ok(t,e){var n;const r=Lf(t),{nodeExtensions:s,markExtensions:o}=Dn(t),i=(n=s.find(c=>F(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(x=>x.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((x,b)=>{const k=F(b,"extendNodeSchema",d);return{...x,...k?k(c):{}}},{}),h=Bc({...f,content:te(F(c,"content",d)),marks:te(F(c,"marks",d)),group:te(F(c,"group",d)),inline:te(F(c,"inline",d)),atom:te(F(c,"atom",d)),selectable:te(F(c,"selectable",d)),draggable:te(F(c,"draggable",d)),code:te(F(c,"code",d)),whitespace:te(F(c,"whitespace",d)),linebreakReplacement:te(F(c,"linebreakReplacement",d)),defining:te(F(c,"defining",d)),isolating:te(F(c,"isolating",d)),attrs:Object.fromEntries(u.map(Fc))}),m=te(F(c,"parseHTML",d));m&&(h.parseDOM=m.map(x=>zc(x,u)));const g=F(c,"renderHTML",d);g&&(h.toDOM=x=>g({node:x,HTMLAttributes:Pn(x,u)}));const y=F(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),a=Object.fromEntries(o.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,x)=>{const b=F(x,"extendMarkSchema",d);return{...y,...b?b(c):{}}},{}),h=Bc({...f,inclusive:te(F(c,"inclusive",d)),excludes:te(F(c,"excludes",d)),group:te(F(c,"group",d)),spanning:te(F(c,"spanning",d)),code:te(F(c,"code",d)),attrs:Object.fromEntries(u.map(Fc))}),m=te(F(c,"parseHTML",d));m&&(h.parseDOM=m.map(y=>zc(y,u)));const g=F(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:Pn(y,u)})),[c.name,h]}));return new hd({topNode:i,nodes:l,marks:a})}function Ak(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Cs(t){return t.sort((n,r)=>{const s=F(n,"priority")||100,o=F(r,"priority")||100;return s>o?-1:s<o?1:0})}function $f(t){const e=Cs(Wl(t)),n=Ak(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function _f(t,e,n){const{from:r,to:s}=e,{blockSeparator:o=`
35
-
36
- `,textSerializers:i={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=o);const h=i?.[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a?.text)==null?void 0:f.slice(Math.max(r,c)-c,s-c))}),l}function Ik(t,e){const n={from:0,to:t.content.size};return _f(t,n,e)}function zf(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function jk(t,e){const n=pe(e,t.schema),{from:r,to:s}=t.selection,o=[];t.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===n.name);return i?{...i.attrs}:{}}function Bf(t,e){const n=Eo(typeof e=="string"?e:e.name,t.schema);return n==="node"?jk(t,e):n==="mark"?Rf(t,e):{}}function Rk(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function Dk(t){const e=Rk(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Ff(t){const{mapping:e,steps:n}=t,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}=n[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),u=e.slice(o).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),Dk(r)}function ql(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const o=n.resolve(t),i=Hl(o,s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(t,e,(s,o)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var Pk=(t,e,n,r=20)=>{const s=t.doc.resolve(n);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 Kr(t,e){return e.nodes[t]||e.marks[t]||null}function ss(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var Lk=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),n};function Ui(t,e,n={}){const{empty:r,ranges:s}=t.selection,o=e?vt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>Ss(d.attrs,n,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,m=f.pos;t.doc.nodesBetween(h,m,(g,y)=>{if(!g.isText&&!g.marks.length)return;const x=Math.max(h,y),b=Math.min(m,y+g.nodeSize),k=b-x;i+=k,l.push(...g.marks.map(S=>({mark:S,from:x,to:b})))})}),i===0)return!1;const a=l.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>Ss(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=i}function $k(t,e,n={}){if(!e)return zt(t,null,n)||Ui(t,null,n);const r=Eo(e,t.schema);return r==="node"?zt(t,e,n):r==="mark"?Ui(t,e,n):!1}var _k=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const o=To(l=>l.type.name===e)(t.selection);if(!o)return!1;const i=t.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},zk=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Vc(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Hc(t,e){const{nodeExtensions:n}=Dn(e),r=n.find(i=>i.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=te(F(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Mo(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(o=>{s!==!1&&(Mo(o,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Vf(t){return t instanceof V}var Hf=class Wf{constructor(e){this.position=e}static fromJSON(e){return new Wf(e.position)}toJSON(){return{position:this.position}}};function Bk(t,e){const n=e.mapping.mapResult(t.position);return{position:new Hf(n.pos),mapResult:n}}function Fk(t){return new Hf(t)}function Vk(t,e,n){var r;const{selection:s}=e;let o=null;if(Of(s)&&(o=s.$cursor),o){const l=(r=t.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),m=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&m}return!c}),c})}var Hk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:l}=o,a=vt(t,r.schema);if(s)if(i){const c=Rf(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const m=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(x=>x.type===a)?f.marks.forEach(x=>{a===x.type&&n.addMark(m,g,a.create({...x.attrs,...e}))}):n.addMark(m,g,a.create(e))})});return Vk(r,n,a)},Wk=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Uk=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const o=pe(t,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>rc(o,{...i,...e})(n)?!0:l.clearNodes()).command(({state:l})=>rc(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},qk=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Gt(t,0,r.content.size),o=V.create(r,s);e.setSelection(o)}return!0},Kk=(t,e)=>({tr:n,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&&n.doc.nodesBetween(i,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},Jk=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:o}=typeof t=="number"?{from:t,to:t}:t,i=q.atStart(r).from,l=q.atEnd(r).to,a=Gt(s,i,l),c=Gt(o,i,l),u=q.create(r,a,c);e.setSelection(u)}return!0},Gk=t=>({state:e,dispatch:n})=>{const r=pe(t,e.schema);return Hy(r)(e,n)};function Wc(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var Yk=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,u=ss(c,l.node().type.name,l.node().attrs);if(o instanceof V&&o.node.isBlock)return!l.parentOffset||!xt(i,l.pos)?!1:(r&&(t&&Wc(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:Ck(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,m=xt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!m&&xt(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(m&&(o instanceof q&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&Wc(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},Xk=(t,e={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const l=pe(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.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=O.empty;const b=a.index(-1)?1:a.index(-2)?2:3;for(let M=a.depth-b;M>=a.depth-3;M-=1)x=O.from(a.node(M).copy(x));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...ss(f,a.node().type.name,a.node().attrs),...e},v=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(S))||void 0;x=x.append(O.from(l.createAndFill(null,v)||void 0));const C=a.before(a.depth-(b-1));n.replace(C,a.after(-k),new $(x,4-b,0));let w=-1;n.doc.nodesBetween(C,n.doc.content.size,(M,E)=>{if(w>-1)return!1;M.isTextblock&&M.content.size===0&&(w=E+1)}),w>-1&&n.setSelection(q.near(n.doc.resolve(w))),n.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,m={...ss(f,d.type.name,d.attrs),...e},g={...ss(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=h?[{type:l,attrs:m},{type:h,attrs:g}]:[{type:l,attrs:m}];if(!xt(n.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:k}=o.extensionManager,S=b||x.$to.parentOffset&&x.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!S||!s)return!0;const v=S.filter(C=>k.includes(C.type.name));n.ensureMarks(v)}return!0},fi=(t,e)=>{const n=To(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&Vt(t.doc,n.pos)&&t.join(n.pos),!0},hi=(t,e)=>{const n=To(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&Vt(t.doc,r)&&t.join(r),!0},Qk=(t,e,n,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=s.extensionManager,h=pe(t,i.schema),m=pe(e,i.schema),{selection:g,storedMarks:y}=i,{$from:x,$to:b}=g,k=x.blockRange(b),S=y||g.$to.parentOffset&&g.$from.marks();if(!k)return!1;const v=To(C=>Hc(C.type.name,d))(g);if(k.depth>=1&&v&&k.depth-v.depth<=1){if(v.node.type===h)return c.liftListItem(m);if(Hc(v.node.type.name,d)&&h.validContent(v.node.content)&&l)return a().command(()=>(o.setNodeMarkup(v.pos,h),!0)).command(()=>fi(o,h)).command(()=>hi(o,h)).run()}return!n||!S||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>fi(o,h)).command(()=>hi(o,h)).run():a().command(()=>{const C=u().wrapInList(h,r),w=S.filter(M=>f.includes(M.type.name));return o.ensureMarks(w),C?!0:c.clearNodes()}).wrapInList(h,r).command(()=>fi(o,h)).command(()=>hi(o,h)).run()},Zk=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=vt(t,r.schema);return Ui(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},ev=(t,e,n={})=>({state:r,commands:s})=>{const o=pe(t,r.schema),i=pe(e,r.schema),l=zt(r,o,n);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,...n})},tv=(t,e={})=>({state:n,commands:r})=>{const s=pe(t,n.schema);return zt(n,s,e)?r.lift(s):r.wrapIn(s,e)},nv=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(t))){if(e){const i=t.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,t.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},rv=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},sv=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=n,a=vt(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&i){let{from:f,to:h}=l;const m=(o=c.marks().find(y=>y.type===a))==null?void 0:o.attrs,g=Hl(c,a,m);g&&(f=g.from,h=g.to),n.removeMark(f,h,a)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},ov=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let o,i;return typeof t=="number"?(o=t,i=t):t&&"from"in t&&"to"in t?(o=t.from,i=t.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},iv=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=Eo(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=pe(t,r.schema)),l==="mark"&&(i=vt(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,m,g;n.selection.empty?r.doc.nodesBetween(u,d,(y,x)=>{o&&o===y.type&&(a=!0,m=Math.max(x,u),g=Math.min(x+y.nodeSize,d),f=x,h=y)}):r.doc.nodesBetween(u,d,(y,x)=>{x<u&&o&&o===y.type&&(a=!0,m=Math.max(x,u),g=Math.min(x+y.nodeSize,d),f=x,h=y),x>=u&&x<=d&&(o&&o===y.type&&(a=!0,s&&n.setNodeMarkup(x,void 0,{...y.attrs,...e})),i&&y.marks.length&&y.marks.forEach(b=>{if(i===b.type&&(a=!0,s)){const k=Math.max(x,u),S=Math.min(x+y.nodeSize,d);n.addMark(k,S,i.create({...b.attrs,...e}))}}))}),h&&(f!==void 0&&s&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(y=>{i===y.type&&s&&n.addMark(m,g,i.create({...y.attrs,...e}))}))}),a},lv=(t,e={})=>({state:n,dispatch:r})=>{const s=pe(t,n.schema);return Ly(s,e)(n,r)},av=(t,e={})=>({state:n,dispatch:r})=>{const s=pe(t,n.schema);return $y(s,e)(n,r)},cv=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Oo=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},uv=(t,e)=>{if(Vl(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Jr(t){var e;const{editor:n,from:r,to:s,text:o,rules:i,plugin:l}=t,{view:a}=n;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 u=!1;const d=Lk(c)+o;return i.forEach(f=>{if(u)return;const h=uv(d,f.find);if(!h)return;const m=a.state.tr,g=Co({state:a.state,transaction:m}),y={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:k}=new No({editor:n,state:g});f.handler({state:g,range:y,match:h,commands:x,chain:b,can:k})===null||!m.steps.length||(f.undoable&&m.setMeta(l,{transform:m,from:r,to:s,text:o}),a.dispatch(m),u=!0)}),u}function dv(t){const{editor:e,rules:n}=t,r=new ie({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:u}=a;typeof u=="string"?u=u:u=Ul(O.from(u),i.schema);const{from:d}=a,f=d+u.length;Jr({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return Jr({editor:e,from:o,to:i,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Jr({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Jr({editor:e,from:i.pos,to:i.pos,text:`
37
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function fv(t){return Object.prototype.toString.call(t).slice(8,-1)}function Gr(t){return fv(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Uf(t,e){const n={...t};return Gr(t)&&Gr(e)&&Object.keys(e).forEach(r=>{Gr(e[r])&&Gr(t[r])?n[r]=Uf(t[r],e[r]):n[r]=e[r]}),n}var Kl=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...te(F(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...te(F(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Uf(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},dn=class qf extends Kl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new qf(n)}static handleExit({editor:e,mark:n}){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===n.name))return!1;const a=i.find(c=>c?.type.name===n.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 n=typeof e=="function"?e():e;return super.extend(n)}};function hv(t){return typeof t=="number"}var pv=class{constructor(t){this.find=t.find,this.handler=t.handler}},mv=(t,e,n)=>{if(Vl(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=t,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 gv(t){const{editor:e,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=t,{commands:a,chain:c,can:u}=new No({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(h,m)=>{var g,y,x,b,k;if((y=(g=h.type)==null?void 0:g.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const S=(k=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?k:0,v=Math.max(r,m),C=Math.min(s,m+S);if(v>=C)return;const w=h.isText?h.text||"":h.textBetween(v-m,C-m,void 0,"");mv(w,o.find,i).forEach(E=>{if(E.index===void 0)return;const A=v+E.index+1,D=A+E[0].length,_={from:n.tr.mapping.map(A),to:n.tr.mapping.map(D)},B=o.handler({state:n,range:_,match:E,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(B)})}),d.every(h=>h!==null)}var Yr=null,yv=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function xv(t){const{editor:e,rules:n}=t;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:u,from:d,to:f,rule:h,pasteEvt:m})=>{const g=u.tr,y=Co({state:u,transaction:g});if(!(!gv({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(u=>new ie({view(d){const f=m=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(m.target)?d.dom.parentElement:null,r&&(Yr=e)},h=()=>{Yr&&(Yr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(o=r===d.dom.parentElement,l=f,!o){const h=Yr;h?.isEditable&&setTimeout(()=>{const m=h.state.selection;m&&h.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(d,f)=>{var h;const m=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!m?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const m=d[0],g=m.getMeta("uiEvent")==="paste"&&!s,y=m.getMeta("uiEvent")==="drop"&&!o,x=m.getMeta("applyPasteRules"),b=!!x;if(!g&&!y&&!b)return;if(b){let{text:v}=x;typeof v=="string"?v=v:v=Ul(O.from(v),h.schema);const{from:C}=x,w=C+v.length,M=yv(v);return a({rule:u,state:h,from:C,to:{b:w},pasteEvt:M})}const k=f.doc.content.findDiffStart(h.doc.content),S=f.doc.content.findDiffEnd(h.doc.content);if(!(!hv(k)||!S||k===S.b))return a({rule:u,state:h,from:k,to:S,pasteEvt:i})}}))}var Ao=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=$f(t),this.schema=Ok(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Kr(e.name,this.schema)},r=F(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Cs([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Kr(r.name,this.schema)},o=[],i=F(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&F(r,"exitable",s)&&(l.ArrowRight=()=>dn.handleExit({editor:t,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,m])=>[h,()=>m({editor:t})]));l={...l,...f}}const a=jb(l);o.push(a);const c=F(r,"addInputRules",s);if(Vc(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=dv({editor:t,rules:f}),m=Array.isArray(h)?h:[h];o.push(...m)}}const u=F(r,"addPasteRules",s);if(Vc(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=xv({editor:t,rules:f});o.push(...h)}}const d=F(r,"addProseMirrorPlugins",s);if(d){const f=d();o.push(...f)}return o})}get attributes(){return Lf(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Dn(this.extensions);return Object.fromEntries(e.filter(n=>!!F(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pe(n.name,this.schema)},o=F(n,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,u,d,f)=>{const h=Pn(a,r);return i({node:a,view:c,getPos:u,decorations:d,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Cs([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Kr(s.name,this.schema)},i=F(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Dn(this.extensions);return Object.fromEntries(e.filter(n=>!!F(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:vt(n.name,this.schema)},o=F(n,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const u=Pn(l,r);return o()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{jv(l,t,d)}})};return[n.name,i]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Kr(e.name,this.schema)};e.type==="mark"&&((n=te(F(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=F(e,"onBeforeCreate",r),o=F(e,"onCreate",r),i=F(e,"onUpdate",r),l=F(e,"onSelectionUpdate",r),a=F(e,"onTransaction",r),c=F(e,"onFocus",r),u=F(e,"onBlur",r),d=F(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),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};Ao.resolve=$f;Ao.sort=Cs;Ao.flatten=Wl;var bv={};Fl(bv,{ClipboardTextSerializer:()=>Jf,Commands:()=>Gf,Delete:()=>Yf,Drop:()=>Xf,Editable:()=>Qf,FocusEvents:()=>eh,Keymap:()=>th,Paste:()=>nh,Tabindex:()=>rh,TextDirection:()=>sh,focusEventsPluginKey:()=>Zf});var fe=class Kf extends Kl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Kf(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Jf=fe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ie({key:new de("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(u=>u.$from.pos)),l=Math.max(...o.map(u=>u.$to.pos)),a=zf(n);return _f(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Gf=fe.create({name:"commands",addCommands(){return{...Tf}}}),Yf=fe.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,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,t))!=null?c:t.getMeta("y-sync$"))return;const u=Df(t.before,[t,...e]);Ff(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(m,g)=>{const y=g+m.nodeSize-2,x=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,m)=>{var g,y;if(h instanceof tt){const x=f.slice(m).map(h.from,-1),b=f.slice(m).map(h.to),k=f.invert().map(x,-1),S=f.invert().map(b),v=(g=u.doc.nodeAt(x-1))==null?void 0:g.marks.some(w=>w.eq(h.mark)),C=(y=u.doc.nodeAt(b))==null?void 0:y.marks.some(w=>w.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:S},newRange:{from:x,to:b},partial:!!(C||v),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),Xf=fe.create({name:"drop",addProseMirrorPlugins(){return[new ie({key:new de("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Qf=fe.create({name:"editable",addProseMirrorPlugins(){return[new ie({key:new de("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Zf=new de("focusEvents"),eh=fe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ie({key:Zf,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),th=fe.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,m=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=m.parent.type.spec.isolating,y=d.pos-d.parentOffset,x=g&&m.parent.childCount===1?y===d.pos:Y.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!x||x&&d.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:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"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 Sr()||jf()?o:s},addProseMirrorPlugins(){return[new ie({key:new de("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=Y.atStart(e.doc).from,c=Y.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!Mo(n.doc))return;const f=n.tr,h=Co({state:n,transaction:f}),{commands:m}=new No({editor:this.editor,state:h});if(m.clearNodes(),!!f.steps.length)return f}})]}}),nh=fe.create({name:"paste",addProseMirrorPlugins(){return[new ie({key:new de("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),rh=fe.create({name:"tabindex",addProseMirrorPlugins(){return[new ie({key:new de("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),sh=fe.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Dn(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ie({key:new de("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),kv=class wn{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,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 n=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}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,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),n=this.resolvedPos.doc.resolve(e);return new wn(n,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 wn(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 wn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.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 wn(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new wn(l,this.editor,s,s?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const o=s.node.attrs,i=Object.keys(n);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(n);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>n[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},vv=`.ProseMirror {
38
- position: relative;
39
- }
40
-
41
- .ProseMirror {
42
- word-wrap: break-word;
43
- white-space: pre-wrap;
44
- white-space: break-spaces;
45
- -webkit-font-variant-ligatures: none;
46
- font-variant-ligatures: none;
47
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
48
- }
49
-
50
- .ProseMirror [contenteditable="false"] {
51
- white-space: normal;
52
- }
53
-
54
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
55
- white-space: pre-wrap;
56
- }
57
-
58
- .ProseMirror pre {
59
- white-space: pre-wrap;
60
- }
61
-
62
- img.ProseMirror-separator {
63
- display: inline !important;
64
- border: none !important;
65
- margin: 0 !important;
66
- width: 0 !important;
67
- height: 0 !important;
68
- }
69
-
70
- .ProseMirror-gapcursor {
71
- display: none;
72
- pointer-events: none;
73
- position: absolute;
74
- margin: 0;
75
- }
76
-
77
- .ProseMirror-gapcursor:after {
78
- content: "";
79
- display: block;
80
- position: absolute;
81
- top: -2px;
82
- width: 20px;
83
- border-top: 1px solid black;
84
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
85
- }
86
-
87
- @keyframes ProseMirror-cursor-blink {
88
- to {
89
- visibility: hidden;
90
- }
91
- }
92
-
93
- .ProseMirror-hideselection *::selection {
94
- background: transparent;
95
- }
96
-
97
- .ProseMirror-hideselection *::-moz-selection {
98
- background: transparent;
99
- }
100
-
101
- .ProseMirror-hideselection * {
102
- caret-color: transparent;
103
- }
104
-
105
- .ProseMirror-focused .ProseMirror-gapcursor {
106
- display: block;
107
- }`;function wv(t,e,n){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=t,document.getElementsByTagName("head")[0].appendChild(s),s}var Sv=class extends cv{constructor(t={}){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:Bk,createMappablePosition:Fk},this.setOptions(t),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(),n=Af(e,this.options.autofocus);this.editorState=En.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){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(t),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 t=this.editorView.dom;t?.editor&&delete t.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(t){console.warn("Failed to remove CSS element:",t)}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=wv(vv,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),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:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,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(t,e){const n=Pf(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const o=typeof s=="string"?`${s}$`:s.key;n=n.filter(i=>!i.key.startsWith(o))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Qf,Jf.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Gf,eh,th,rh,Xf,nh,Yf,sh.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 Ao(r,this)}createCommandManager(){this.commandManager=new No({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Wi(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(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Wi(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new Nf(t,{...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(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=n.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}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||o.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Bf(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return $k(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ul(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
108
-
109
- `,textSerializers:n={}}=t||{};return Ik(this.state.doc,{blockSeparator:e,textSerializers:{...zf(this.schema),...n}})}get isEmpty(){return Mo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new kv(e,this)}get $doc(){return this.$pos(0)}};function Ln(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=te(t.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=n.from+l.indexOf(i),u=c+i.length;if(ql(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+a,c);const f=n.from+a+i.length;o.addMark(n.from+a,f,t.type.create(s||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function Cv(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=te(t.getAttributes,void 0,r)||{},{tr:o}=e,i=n.from;let l=n.to;const a=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?i:i-1;o.insert(c,t.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:t.undoable})}function qi(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),o=te(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function $n(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const o=te(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),a=i.doc.resolve(n.from).blockRange(),c=a&&Nl(a,t.type,o);if(!c)return null;if(i.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,m=f||d.$to.parentOffset&&d.$from.marks();if(m){const g=m.filter(y=>h.includes(y.type.name));i.ensureMarks(g)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Vt(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&i.join(n.from-1)},undoable:t.undoable})}function Nv(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof V){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 Ev(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Tv={};Fl(Tv,{createAtomBlockMarkdownSpec:()=>Mv,createBlockMarkdownSpec:()=>Ov,createInlineMarkdownSpec:()=>oh,parseAttributes:()=>Jl,parseIndentedBlocks:()=>Ki,renderNestedMarkdownContent:()=>Yl,serializeAttributes:()=>Gl});function Jl(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.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,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=n[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(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function Gl(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function Mv(t){const{nodeName:e,name:n,parseAttributes:r=Jl,serializeAttributes:s=Gl,defaultAttributes:o={},requiredAttributes:i=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...o,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=u.match(h);if(!m)return;const g=m[1]||"",y=r(g);if(!i.find(b=>!(b in y)))return{type:e,raw:m[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Ov(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Jl,serializeAttributes:o=Gl,defaultAttributes:i={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const f={};return a.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const g=r(d);h=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const m={...i,...d.attributes};return f.createNode(e,m,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),m=(f=d.match(h))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,h){var m;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=d.match(g);if(!y)return;const[x,b=""]=y,k=s(b);let S=1;const v=x.length;let C="";const w=/^:::([\w-]*)(\s.*)?/gm,M=d.slice(v);for(w.lastIndex=0;;){const E=w.exec(M);if(E===null)break;const A=E.index,D=E[1];if(!((m=E[2])!=null&&m.endsWith(":::"))){if(D)S+=1;else if(S-=1,S===0){const _=M.slice(0,A);C=_.trim();const B=d.slice(0,v+A+E[0].length);let z=[];if(C)if(l==="block")for(z=h.blockTokens(_),z.forEach(R=>{R.text&&(!R.tokens||R.tokens.length===0)&&(R.tokens=h.inlineTokens(R.text))});z.length>0;){const R=z[z.length-1];if(R.type==="paragraph"&&(!R.text||R.text.trim()===""))z.pop();else break}else z=h.inlineTokens(C);return{type:e,raw:B,attributes:k,content:C,tokens:z}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),m=o(h),g=m?` {${m}}`:"",y=f.renderChildren(d.content||[],`
110
-
111
- `);return`:::${c}${g}
112
-
113
- ${y}
114
-
115
- :::`}}}function Av(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,o,i]=r;e[s]=o||i,r=n.exec(t)}return e}function Iv(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function oh(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Av,serializeAttributes:o=Iv,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=f=>{if(!a)return f;const h={};return a.forEach(m=>{const g=typeof m=="string"?m:m.name,y=typeof m=="string"?void 0:m.skipIfDefault;if(g in f){const x=f[g];if(y!==void 0&&x===y)return;h[g]=x}}),h},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const m={...i,...f.attributes};if(l)return h.createNode(e,m);const g=r?r(f):f.content||"";return g?h.createNode(e,m,[h.createTextNode(g)]):h.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),m=f.match(h),g=m?.index;return g!==void 0?g:-1},tokenize(f,h,m){const g=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),y=f.match(g);if(!y)return;let x="",b="";if(l){const[,S]=y;b=S}else{const[,S,v]=y;b=S,x=v||""}const k=s(b.trim());return{type:e,raw:y[0],content:x.trim(),attributes:k}}},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 m=u(f.attrs||{}),g=o(m),y=g?` ${g}`:"";return l?`[${c}${y}]`:`[${c}${y}]${h}[/${c}]`}}}function Ki(t,e,n){var r,s,o,i;const l=t.split(`
116
- `),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const f=l[u],h=f.match(e.itemPattern);if(!h){if(a.length>0)break;if(f.trim()===""){u+=1,c=`${c}${f}
117
- `;continue}else return}const m=e.extractItemData(h),{indentLevel:g,mainContent:y}=m;c=`${c}${f}
118
- `;const x=[y];for(u+=1;u<l.length;){const v=l[u];if(v.trim()===""){const w=l.slice(u+1).findIndex(A=>A.trim()!=="");if(w===-1)break;if((((s=(r=l[u+1+w].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){x.push(v),c=`${c}${v}
119
- `,u+=1;continue}else break}if((((i=(o=v.match(/^(\s*)/))==null?void 0:o[1])==null?void 0:i.length)||0)>g)x.push(v),c=`${c}${v}
120
- `,u+=1;else break}let b;const k=x.slice(1);if(k.length>0){const v=k.map(C=>C.slice(g+d)).join(`
121
- `);v.trim()&&(e.customNestedParser?b=e.customNestedParser(v):b=n.blockTokens(v))}const S=e.createToken(m,b);a.push(S)}if(a.length!==0)return{items:a,raw:c}}function Yl(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[o,...i]=t.content,l=e.renderChildren([o]),a=[`${s}${l}`];return i&&i.length>0&&i.forEach(c=>{const u=e.renderChildren([c]);if(u){const d=u.split(`
122
- `).map(f=>f?e.indent(f):"").join(`
123
- `);a.push(d)}}),a.join(`
124
- `)}function jv(t,e,n={}){const{state:r}=e,{doc:s,tr:o}=r,i=t;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});o.removeMark(c,u,t.type),o.addMark(c,u,h)}}),o.docChanged&&e.view.dispatch(o)}var je=class ih extends Kl{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new ih(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Rv=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,o,i,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const b=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),S=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,v=(i=t.offsetY)!=null?i:(o=t.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+S,f=k.y-b.y+v}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 m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(h),document.body.appendChild(m),(l=t.dataTransfer)==null||l.setDragImage(h,d,f)}finally{m&&setTimeout(()=>{try{m?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=V.create(a.state.doc,g),x=a.state.tr.setSelection(y);a.dispatch(x)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=V.isSelectable(this.node),d=t.type==="copy",f=t.type==="paste",h=t.type==="cut",m=t.type==="mousedown";if(!c&&u&&s&&t.target===this.dom&&t.preventDefault(),c&&s&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&m){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||f||h||m&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Sr()||Hi())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function an(t){return new pv({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const o=te(t.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=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),f=d+l.length;if(ql(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>d).length)return null;f<n.to&&i.delete(f,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+l.length,i.addMark(n.from+u,c,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}var Dv=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},Pv=({contentComponent:t})=>{const e=pu.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return p.jsx(p.Fragment,{children:Object.values(e)})};function Lv(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:yp.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var $v=class extends ee.Component{constructor(t){var e;super(t),this.editorContentRef=ee.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=Lv(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return p.jsxs(p.Fragment,{children:[p.jsx("div",{ref:Dv(e,this.editorContentRef),...n}),t?.contentComponent&&p.jsx(Pv,{contentComponent:t.contentComponent})]})}},_v=N.forwardRef((t,e)=>{const n=ee.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ee.createElement($v,{key:n,innerRef:e,...t})}),zv=ee.memo(_v),Bv=typeof window<"u"?N.useLayoutEffect:N.useEffect,Fv=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function Vv(t){var e;const[n]=N.useState(()=>new Fv(t.editor)),r=gp.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:ig);return Bv(()=>n.watch(t.editor),[t.editor,n]),N.useDebugValue(r),r}var Hv=!1,Ji=typeof window>"u",Wv=Ji||!!(typeof window<"u"&&window.next),Uv=class lh{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Ji||Wv?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 Sv(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=n.extensions)==null?void 0:i[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?lh.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,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function qv(t={},e=[]){const n=N.useRef(t);n.current=t;const[r]=N.useState(()=>new Uv(n)),s=pu.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return N.useDebugValue(s),N.useEffect(r.onRender(e)),Vv({editor:s,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),s}var Kv=N.createContext({editor:null});Kv.Consumer;var ah=N.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Jv=()=>N.useContext(ah),Uc=ee.forwardRef((t,e)=>{const{onDragStart:n}=Jv(),r=t.as||"div";return p.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function qc(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Kc(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function Gv(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function Yv(t){if(qc(t)||Kc(t))return!0;if(Gv(t)){const e=t.type;if(e)return qc(e)||Kc(e)}return!1}function Xv(){try{if(N.version)return parseInt(N.version.split(".")[0],10)>=19}catch{}return!1}var ch=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?mp.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=Xv(),o=Yv(e),i={...n};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=p.jsx(e,{...i}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};ee.createContext({markViewContentRef:()=>{}});var Qv=class extends Rv{constructor(t,e,n){if(super(t,e,n),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 t={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:N.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=N.memo(a=>p.jsx(ah.Provider,{value:r,children:N.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 ch(o,{editor:this.editor,props:t,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.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=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:o,newNode:t,newDecorations:e,oldInnerDecorations:i,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Pn(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function Zv(t,e){return n=>n.editor.contentComponent?new Qv(t,n,e):{}}var Ns=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},ew=/^\s*>\s$/,tw=je.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ns("blockquote",{...oe(this.options.HTMLAttributes,t),children:Ns("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const l=e.renderChildren([s]).split(`
125
- `).map(a=>a.trim()===""?n:`${n} ${a}`);r.push(l.join(`
126
- `))}),r.join(`
127
- ${n}
128
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[$n({find:ew,type:this.type})]}}),nw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,rw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ow=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,iw=dn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Ns("strong",{...oe(this.options.HTMLAttributes,t),children:Ns("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ln({find:nw,type:this.type}),Ln({find:sw,type:this.type})]},addPasteRules(){return[an({find:rw,type:this.type}),an({find:ow,type:this.type})]}}),lw=/(^|[^`])`([^`]+)`(?!`)$/,aw=/(^|[^`])`([^`]+)`(?!`)/g,cw=dn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ln({find:lw,type:this.type})]},addPasteRules(){return[an({find:aw,type:this.type})]}}),pi=4,uw=/^```([a-z]+)?[\s\n]$/,dw=/^~~~([a-z]+)?[\s\n]$/,fw=je.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:pi,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const o=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",oe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
129
- `):r=`\`\`\`${s}
130
-
131
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:pi,{state:r}=t,{selection:s}=r,{$from:o,empty:i}=s;if(o.parent.type!==this.type)return!1;const l=" ".repeat(n);return i?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=s,h=r.doc.textBetween(c,u,`
132
- `,`
133
- `).split(`
134
- `).map(m=>l+m).join(`
135
- `);return a.replaceWith(c,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:pi,{state:r}=t,{selection:s}=r,{$from:o,empty:i}=s;return o.parent.type!==this.type?!1:i?t.commands.command(({tr:l})=>{var a;const{pos:c}=o,u=o.start(),d=o.end(),h=r.doc.textBetween(u,d,`
136
- `,`
137
- `).split(`
138
- `);let m=0,g=0;const y=c-u;for(let C=0;C<h.length;C+=1){if(g+h[C].length>=y){m=C;break}g+=h[C].length+1}const b=((a=h[m].match(/^ */))==null?void 0:a[0])||"",k=Math.min(b.length,n);if(k===0)return!0;let S=u;for(let C=0;C<m;C+=1)S+=h[C].length+1;return l.delete(S,S+k),c-S<=k&&l.setSelection(q.create(l.doc,S)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=s,f=r.doc.textBetween(a,c,`
139
- `,`
140
- `).split(`
141
- `).map(h=>{var m;const g=((m=h.match(/^ */))==null?void 0:m[0])||"",y=Math.min(g.length,n);return h.slice(y)}).join(`
142
- `);return l.replaceWith(a,c,r.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
143
-
144
- `);return!o||!i?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:o}=n;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)?t.commands.command(({tr:c})=>(c.setSelection(Y.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[qi({find:uw,type:this.type,getAttributes:t=>({language:t[1]})}),qi({find:dw,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ie({key:new de("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s?.mode;if(!n||!o)return!1;const{tr:i,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
145
- `));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(q.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),hw=je.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
146
-
147
- `):""}),pw=je.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",oe(this.options.HTMLAttributes,t)]},renderText(){return`
148
- `},renderMarkdown:()=>`
149
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:o}=n;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:u})=>{if(u&&a&&i){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),mw=je.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,oe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>qi({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),gw=je.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",oe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Nv(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Vf(n)?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(q.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(V.create(i.doc,a.pos)):i.setSelection(q.create(i.doc,a.pos));else{const u=o.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(i.insert(c,d),i.setSelection(q.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Cv({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),yw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,bw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,kw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,vw=dn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",oe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ln({find:yw,type:this.type}),Ln({find:bw,type:this.type})]},addPasteRules(){return[an({find:xw,type:this.type}),an({find:kw,type:this.type})]}});const ww="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Sw="ελ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",Gi="numeric",Yi="ascii",Xi="alpha",ar="asciinumeric",nr="alphanumeric",Qi="domain",uh="emoji",Cw="scheme",Nw="slashscheme",mi="whitespace";function Ew(t,e){return t in e||(e[t]=[]),e[t]}function Yt(t,e,n){e[Gi]&&(e[ar]=!0,e[nr]=!0),e[Yi]&&(e[ar]=!0,e[Xi]=!0),e[ar]&&(e[nr]=!0),e[Xi]&&(e[nr]=!0),e[nr]&&(e[Qi]=!0),e[uh]&&(e[Qi]=!0);for(const r in e){const s=Ew(r,n);s.indexOf(t)<0&&s.push(t)}}function Tw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Ae(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Ae.groups={};Ae.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Ae.groups;let s;return e&&e.j?s=e:(s=new Ae(e),n&&r&&Yt(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const o=t.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(t[i]);return s.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||Ae.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const o=e;let i,l=s.go(t);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(Tw(i.t,r),n);Yt(o,a,r)}else n&&Yt(o,n,r);i.t=o}return s.j[t]=i,i}};const G=(t,e,n,r,s)=>t.ta(e,n,r,s),ae=(t,e,n,r,s)=>t.tr(e,n,r,s),Jc=(t,e,n,r,s)=>t.ts(e,n,r,s),I=(t,e,n,r,s)=>t.tt(e,n,r,s),pt="WORD",Zi="UWORD",dh="ASCIINUMERICAL",fh="ALPHANUMERICAL",Nr="LOCALHOST",el="TLD",tl="UTLD",is="SCHEME",Sn="SLASH_SCHEME",Xl="NUM",nl="WS",Ql="NL",cr="OPENBRACE",ur="CLOSEBRACE",Es="OPENBRACKET",Ts="CLOSEBRACKET",Ms="OPENPAREN",Os="CLOSEPAREN",As="OPENANGLEBRACKET",Is="CLOSEANGLEBRACKET",js="FULLWIDTHLEFTPAREN",Rs="FULLWIDTHRIGHTPAREN",Ds="LEFTCORNERBRACKET",Ps="RIGHTCORNERBRACKET",Ls="LEFTWHITECORNERBRACKET",$s="RIGHTWHITECORNERBRACKET",_s="FULLWIDTHLESSTHAN",zs="FULLWIDTHGREATERTHAN",Bs="AMPERSAND",Fs="APOSTROPHE",Vs="ASTERISK",Et="AT",Hs="BACKSLASH",Ws="BACKTICK",Us="CARET",Ot="COLON",Zl="COMMA",qs="DOLLAR",ot="DOT",Ks="EQUALS",ea="EXCLAMATION",Fe="HYPHEN",dr="PERCENT",Js="PIPE",Gs="PLUS",Ys="POUND",fr="QUERY",ta="QUOTE",hh="FULLWIDTHMIDDLEDOT",na="SEMI",it="SLASH",hr="TILDE",Xs="UNDERSCORE",ph="EMOJI",Qs="SYM";var mh=Object.freeze({__proto__:null,ALPHANUMERICAL:fh,AMPERSAND:Bs,APOSTROPHE:Fs,ASCIINUMERICAL:dh,ASTERISK:Vs,AT:Et,BACKSLASH:Hs,BACKTICK:Ws,CARET:Us,CLOSEANGLEBRACKET:Is,CLOSEBRACE:ur,CLOSEBRACKET:Ts,CLOSEPAREN:Os,COLON:Ot,COMMA:Zl,DOLLAR:qs,DOT:ot,EMOJI:ph,EQUALS:Ks,EXCLAMATION:ea,FULLWIDTHGREATERTHAN:zs,FULLWIDTHLEFTPAREN:js,FULLWIDTHLESSTHAN:_s,FULLWIDTHMIDDLEDOT:hh,FULLWIDTHRIGHTPAREN:Rs,HYPHEN:Fe,LEFTCORNERBRACKET:Ds,LEFTWHITECORNERBRACKET:Ls,LOCALHOST:Nr,NL:Ql,NUM:Xl,OPENANGLEBRACKET:As,OPENBRACE:cr,OPENBRACKET:Es,OPENPAREN:Ms,PERCENT:dr,PIPE:Js,PLUS:Gs,POUND:Ys,QUERY:fr,QUOTE:ta,RIGHTCORNERBRACKET:Ps,RIGHTWHITECORNERBRACKET:$s,SCHEME:is,SEMI:na,SLASH:it,SLASH_SCHEME:Sn,SYM:Qs,TILDE:hr,TLD:el,UNDERSCORE:Xs,UTLD:tl,UWORD:Zi,WORD:pt,WS:nl});const ft=/[a-z]/,Xn=new RegExp("\\p{L}","u"),gi=new RegExp("\\p{Emoji}","u"),ht=/\d/,yi=/\s/,Gc="\r",xi=`
150
- `,Mw="️",Ow="‍",bi="";let Xr=null,Qr=null;function Aw(t=[]){const e={};Ae.groups=e;const n=new Ae;Xr==null&&(Xr=Yc(ww)),Qr==null&&(Qr=Yc(Sw)),I(n,"'",Fs),I(n,"{",cr),I(n,"}",ur),I(n,"[",Es),I(n,"]",Ts),I(n,"(",Ms),I(n,")",Os),I(n,"<",As),I(n,">",Is),I(n,"(",js),I(n,")",Rs),I(n,"「",Ds),I(n,"」",Ps),I(n,"『",Ls),I(n,"』",$s),I(n,"<",_s),I(n,">",zs),I(n,"&",Bs),I(n,"*",Vs),I(n,"@",Et),I(n,"`",Ws),I(n,"^",Us),I(n,":",Ot),I(n,",",Zl),I(n,"$",qs),I(n,".",ot),I(n,"=",Ks),I(n,"!",ea),I(n,"-",Fe),I(n,"%",dr),I(n,"|",Js),I(n,"+",Gs),I(n,"#",Ys),I(n,"?",fr),I(n,'"',ta),I(n,"/",it),I(n,";",na),I(n,"~",hr),I(n,"_",Xs),I(n,"\\",Hs),I(n,"・",hh);const r=ae(n,ht,Xl,{[Gi]:!0});ae(r,ht,r);const s=ae(r,ft,dh,{[ar]:!0}),o=ae(r,Xn,fh,{[nr]:!0}),i=ae(n,ft,pt,{[Yi]:!0});ae(i,ht,s),ae(i,ft,i),ae(s,ht,s),ae(s,ft,s);const l=ae(n,Xn,Zi,{[Xi]:!0});ae(l,ft),ae(l,ht,o),ae(l,Xn,l),ae(o,ht,o),ae(o,ft),ae(o,Xn,o);const a=I(n,xi,Ql,{[mi]:!0}),c=I(n,Gc,nl,{[mi]:!0}),u=ae(n,yi,nl,{[mi]:!0});I(n,bi,u),I(c,xi,a),I(c,bi,u),ae(c,yi,u),I(u,Gc),I(u,xi),ae(u,yi,u),I(u,bi,u);const d=ae(n,gi,ph,{[uh]:!0});I(d,"#"),ae(d,gi,d),I(d,Mw,d);const f=I(d,Ow);I(f,"#"),ae(f,gi,d);const h=[[ft,i],[ht,s]],m=[[ft,null],[Xn,l],[ht,o]];for(let g=0;g<Xr.length;g++)wt(n,Xr[g],el,pt,h);for(let g=0;g<Qr.length;g++)wt(n,Qr[g],tl,Zi,m);Yt(el,{tld:!0,ascii:!0},e),Yt(tl,{utld:!0,alpha:!0},e),wt(n,"file",is,pt,h),wt(n,"mailto",is,pt,h),wt(n,"http",Sn,pt,h),wt(n,"https",Sn,pt,h),wt(n,"ftp",Sn,pt,h),wt(n,"ftps",Sn,pt,h),Yt(is,{scheme:!0,ascii:!0},e),Yt(Sn,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],b=t[g][1]?{[Cw]:!0}:{[Nw]:!0};y.indexOf("-")>=0?b[Qi]=!0:ft.test(y)?ht.test(y)?b[ar]=!0:b[Yi]=!0:b[Gi]=!0,Jc(n,y,y,b)}return Jc(n,"localhost",Nr,{ascii:!0}),n.jd=new Ae(Qs),{start:n,tokens:Object.assign({groups:e},mh)}}function gh(t,e){const n=Iw(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let o=0,i=0;for(;i<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(n[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[i].length,f++),c+=n[i].length,o+=n[i].length,i++;o-=d,i-=f,c-=d,s.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function Iw(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),o,i=s<55296||s>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(i),r+=i.length}return e}function wt(t,e,n,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];t.j[a]?o=t.j[a]:(o=new Ae(r),o.jr=s.slice(),t.j[a]=o),t=o}return o=new Ae(n),o.jr=s.slice(),t.j[e[i-1]]=o,o}function Yc(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let o=0;for(;s.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let i=parseInt(t.substring(r,r+o),10);i>0;i--)n.pop();r+=o}else n.push(t[r]),r++}return e}const Er={defaultProtocol:"http",events:null,format:Xc,formatHref:Xc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ra(t,e=null){let n=Object.assign({},Er);t&&(n=Object.assign(n,t instanceof ra?t.o:t));const r=n.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}ra.prototype={o:Er,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Er[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Xc(t){return t}function yh(t,e){this.t="token",this.v=t,this.tk=e}yh.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Er.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),o=this.toFormattedString(t),i={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:s,attributes:i,content:o,eventListeners:d}}};function Io(t,e){class n extends yh{constructor(s,o){super(s,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Qc=Io("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Zc=Io("text"),jw=Io("nl"),Zr=Io("url",{isLink:!0,toHref(t=Er.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Nr&&t[1].t===Ot}}),Be=t=>new Ae(t);function Rw({groups:t}){const e=t.domain.concat([Bs,Vs,Et,Hs,Ws,Us,qs,Ks,Fe,Xl,dr,Js,Gs,Ys,it,Qs,hr,Xs]),n=[Fs,Ot,Zl,ot,ea,dr,fr,ta,na,As,Is,cr,ur,Ts,Es,Ms,Os,js,Rs,Ds,Ps,Ls,$s,_s,zs],r=[Bs,Fs,Vs,Hs,Ws,Us,qs,Ks,Fe,cr,ur,dr,Js,Gs,Ys,fr,it,Qs,hr,Xs],s=Be(),o=I(s,hr);G(o,r,o),G(o,t.domain,o);const i=Be(),l=Be(),a=Be();G(s,t.domain,i),G(s,t.scheme,l),G(s,t.slashscheme,a),G(i,r,o),G(i,t.domain,i);const c=I(i,Et);I(o,Et,c),I(l,Et,c),I(a,Et,c);const u=I(o,ot);G(u,r,o),G(u,t.domain,o);const d=Be();G(c,t.domain,d),G(d,t.domain,d);const f=I(d,ot);G(f,t.domain,d);const h=Be(Qc);G(f,t.tld,h),G(f,t.utld,h),I(c,Nr,h);const m=I(d,Fe);I(m,Fe,m),G(m,t.domain,d),G(h,t.domain,d),I(h,ot,f),I(h,Fe,m);const g=I(h,Ot);G(g,t.numeric,Qc);const y=I(i,Fe),x=I(i,ot);I(y,Fe,y),G(y,t.domain,i),G(x,r,o),G(x,t.domain,i);const b=Be(Zr);G(x,t.tld,b),G(x,t.utld,b),G(b,t.domain,i),G(b,r,o),I(b,ot,x),I(b,Fe,y),I(b,Et,c);const k=I(b,Ot),S=Be(Zr);G(k,t.numeric,S);const v=Be(Zr),C=Be();G(v,e,v),G(v,n,C),G(C,e,v),G(C,n,C),I(b,it,v),I(S,it,v);const w=I(l,Ot),M=I(a,Ot),E=I(M,it),A=I(E,it);G(l,t.domain,i),I(l,ot,x),I(l,Fe,y),G(a,t.domain,i),I(a,ot,x),I(a,Fe,y),G(w,t.domain,v),I(w,it,v),I(w,fr,v),G(A,t.domain,v),G(A,e,v),I(A,it,v);const D=[[cr,ur],[Es,Ts],[Ms,Os],[As,Is],[js,Rs],[Ds,Ps],[Ls,$s],[_s,zs]];for(let _=0;_<D.length;_++){const[B,z]=D[_],R=I(v,B);I(C,B,R),I(R,z,v);const T=Be(Zr);G(R,e,T);const L=Be();G(R,n),G(T,e,T),G(T,n,L),G(L,e,T),G(L,n,L),I(T,z,v),I(L,z,v)}return I(s,Nr,b),I(s,Ql,jw),{start:s,tokens:mh}}function Dw(t,e,n){let r=n.length,s=0,o=[],i=[];for(;s<r;){let l=t,a=null,c=null,u=0,d=null,f=-1;for(;s<r&&!(a=l.go(n[s].t));)i.push(n[s++]);for(;s<r&&(c=a||l.go(n[s].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,s++,u++;if(f<0)s-=u,s<r&&(i.push(n[s]),s++);else{i.length>0&&(o.push(ki(Zc,e,i)),i=[]),s-=f,u-=f;const h=d.t,m=n.slice(s-u,s);o.push(ki(h,e,m))}}return i.length>0&&o.push(ki(Zc,e,i)),o}function ki(t,e,n){const r=n[0].s,s=n[n.length-1].e,o=e.slice(r,s);return new t(o,n)}const Pw=typeof console<"u"&&console&&console.warn||(()=>{}),Lw="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",re={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function $w(){return Ae.groups={},re.scanner=null,re.parser=null,re.tokenQueue=[],re.pluginQueue=[],re.customSchemes=[],re.initialized=!1,re}function eu(t,e=!1){if(re.initialized&&Pw(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Lw}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
151
- 1. Must only contain digits, lowercase ASCII letters or "-"
152
- 2. Cannot start or end with "-"
153
- 3. "-" cannot repeat`);re.customSchemes.push([t,e])}function _w(){re.scanner=Aw(re.customSchemes);for(let t=0;t<re.tokenQueue.length;t++)re.tokenQueue[t][1]({scanner:re.scanner});re.parser=Rw(re.scanner.tokens);for(let t=0;t<re.pluginQueue.length;t++)re.pluginQueue[t][1]({scanner:re.scanner,parser:re.parser});return re.initialized=!0,re}function sa(t){return re.initialized||_w(),Dw(re.parser.start,t,gh(re.scanner.start,t))}sa.scan=gh;function xh(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new ra(n),s=sa(t),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 oa="[\0-   ᠎ -\u2029  ]",zw=new RegExp(oa),Bw=new RegExp(`${oa}$`),Fw=new RegExp(oa,"g");function Vw(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Hw(t){return new ie({key:new de("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=Df(n.doc,[...e]);if(Ff(l).forEach(({newRange:c})=>{const u=Nk(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!Bw.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(zw).filter(Boolean);if(h.length<=0)return!1;const m=h[h.length-1],g=d.pos+f.lastIndexOf(m);if(!m)return!1;const y=sa(m).map(x=>x.toObject(t.defaultProtocol));if(!Vw(y))return!1;y.filter(x=>x.isLink).map(x=>({...x,from:g+x.start+1,to:g+x.end+1})).filter(x=>r.schema.marks.code?!r.doc.rangeHasMark(x.from,x.to,r.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{ql(x.from,x.to,r.doc).some(b=>b.mark.type===t.type)||i.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!i.steps.length)return i}})}function Ww(t){return new ie({key:new de("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=!1;if(t.enableClickSelection&&(i=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;l=f.find(h=>h.nodeName==="A")}if(!l)return i;const a=Bf(e.state,t.type.name),c=(s=l?.href)!=null?s:a.href,u=(o=l?.target)!=null?o:a.target;l&&c&&(window.open(c,u),i=!0)}return i}}})}function Uw(t){return new ie({key:new de("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:o}=e,{selection:i}=o,{empty:l}=i;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=xh(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Ut(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(Fw,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var qw=dn.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(t=>{if(typeof t=="string"){eu(t);return}eu(t.scheme,t.optionalSlashes)})},onDestroy(){$w()},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:(t,e)=>!!Ut(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.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:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ut(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ut(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",oe(this.options.HTMLAttributes,t),0]:["a",oe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ut(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ut(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[an({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=xh(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Ut(i,n),protocols:n,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:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Hw({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ut(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(Ww({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Uw({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Kw=Object.defineProperty,Jw=(t,e)=>{for(var n in e)Kw(t,n,{get:e[n],enumerable:!0})},Gw="listItem",tu="textStyle",nu=/^\s*([-+*])\s$/,bh=je.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:t}){return["ul",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
154
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Gw,this.editor.getAttributes(tu)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$n({find:nu,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$n({find:nu,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(tu),editor:this.editor})),[t]}}),kh=je.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const i=t.tokens.slice(1),l=e.parseChildren(i);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Yl(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Yw={};Jw(Yw,{findListItemPos:()=>$r,getNextListDepth:()=>ia,handleBackspace:()=>rl,handleDelete:()=>sl,hasListBefore:()=>vh,hasListItemAfter:()=>Xw,hasListItemBefore:()=>wh,listItemHasSubList:()=>Sh,nextListIsDeeper:()=>Ch,nextListIsHigher:()=>Nh});var $r=(t,e)=>{const{$from:n}=e.selection,r=pe(t,e.schema);let s=null,o=n.depth,i=n.pos,l=null;for(;o>0&&l===null;)s=n.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},ia=(t,e)=>{const n=$r(t,e);if(!n)return!1;const[,r]=Pk(e,t,n.$pos.pos+4);return r},vh=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),o=t.doc.resolve(s).node();return!(!o||!n.includes(o.type.name))},wh=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},Sh=(t,e,n)=>{if(!n)return!1;const r=pe(t,e.schema);let s=!1;return n.descendants(o=>{o.type===r&&(s=!0)}),s},rl=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!zt(t.state,e)&&vh(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!zt(t.state,e)||!zk(t.state))return!1;const r=$r(e,t.state);if(!r)return!1;const o=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=Sh(e,t.state,o);return wh(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Ch=(t,e)=>{const n=ia(t,e),r=$r(t,e);return!r||!n?!1:n>r.depth},Nh=(t,e)=>{const n=ia(t,e),r=$r(t,e);return!r||!n?!1:n<r.depth},sl=(t,e)=>{if(!zt(t.state,e)||!_k(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:Ch(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Nh(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Xw=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},Eh=fe.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&sl(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&sl(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&rl(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&rl(t,n,r)&&(e=!0)}),e}}}}),ru=/^(\s*)(\d+)\.\s+(.*)$/,Qw=/^\s/;function Zw(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],o=s.match(ru);if(!o)break;const[,i,l,a]=o,c=i.length;let u=a,d=n+1;const f=[s];for(;d<t.length;){const h=t[d];if(h.match(ru))break;if(h.trim()==="")f.push(h),u+=`
155
- `,d+=1;else if(h.match(Qw))f.push(h),u+=`
156
- ${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(l,10),content:u.trim(),raw:f.join(`
157
- `)}),r=d,n=d}return[e,r]}function Th(t,e,n){var r;const s=[];let o=0;for(;o<t.length;){const i=t[o];if(i.indent===e){const l=i.content.split(`
158
- `),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.slice(1).join(`
159
- `).trim();if(u){const h=n.blockTokens(u);c.push(...h)}let d=o+1;const f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){const h=Math.min(...f.map(g=>g.indent)),m=Th(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:m,raw:f.map(g=>g.raw).join(`
160
- `)})}s.push({type:"list_item",raw:i.raw,tokens:c}),o=d}else o+=1}return s}function eS(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.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 tS="listItem",su="textStyle",ou=/^(\d+)\.\s$/,Mh=je.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",oe(this.options.HTMLAttributes,n),0]:["ol",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?eS(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
161
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
162
- `),[o,i]=Zw(s);if(o.length===0)return;const l=Th(o,0,n);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(`
163
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(tS,this.editor.getAttributes(su)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$n({find:ou,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$n({find:ou,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(su)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),nS=/^\s*(\[([( |x])?\])\s$/,rS=je.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",oe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Yl(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var f,h;l.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const m=n();if(typeof m!="number")return!1;const g=h.doc.nodeAt(m);return h.setNodeMarkup(m,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{s.setAttribute(d,f)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([d,f])=>{s.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,h=Pn(d,f),m=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(y=>{m.has(y)||(y in g?s.setAttribute(y,g[y]):s.removeAttribute(y))}),Object.entries(h).forEach(([y,x])=>{x==null?y in g?s.setAttribute(y,g[y]):s.removeAttribute(y):s.setAttribute(y,x)}),u=m,!0}}}},addInputRules(){return[$n({find:nS,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),sS=je.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",oe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
164
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=o=>{const i=Ki(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:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(o)},s=Ki(t,{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:n.inlineTokens(o.mainContent),nestedTokens:i}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});fe.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(bh.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(kh.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Eh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Mh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(rS.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(sS.configure(this.options.taskList)),t}});var oS=je.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",oe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),iS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,lS=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,aS=dn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",oe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ln({find:iS,type:this.type})]},addPasteRules(){return[an({find:lS,type:this.type})]}}),cS=je.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),uS=dn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",oe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const o=s[2].trim();return{type:"underline",raw:s[0],text:o,tokens:n.inlineTokens(o)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function dS(t={}){return new ie({view(e){return new fS(e,t)}})}class fS{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let m=h.getBoundingClientRect(),g=d?m.bottom:m.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/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 n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!o){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Cd(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 ce extends Y{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ce.valid(r)?new ce(r):Y.near(r)}content(){return $.empty}eq(e){return e instanceof ce&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ce(e.resolve(n.pos))}getBookmark(){return new la(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!hS(e)||!pS(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ce.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(n>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=n;let a=e.doc.resolve(s);if(ce.valid(a))return a}for(;;){let i=n>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!V.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*n),r=!1;continue e}break}o=i,s+=n;let l=e.doc.resolve(s);if(ce.valid(l))return l}return null}}}ce.prototype.visible=!1;ce.findFrom=ce.findGapCursorFrom;Y.jsonID("gapcursor",ce);class la{constructor(e){this.pos=e}map(e){return new la(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ce.valid(n)?new ce(n):Y.near(n)}}function Oh(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function hS(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Oh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function pS(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Oh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function mS(){return new ie({props:{decorations:bS,createSelectionBetween(t,e,n){return e.pos==n.pos&&ce.valid(n)?new ce(n):null},handleClick:yS,handleKeyDown:gS,handleDOMEvents:{beforeinput:xS}}})}const gS=Ef({ArrowLeft:es("horiz",-1),ArrowRight:es("horiz",1),ArrowUp:es("vert",-1),ArrowDown:es("vert",1)});function es(t,e){const n=t=="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 q){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ce.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ce(c))),!0):!1}}function yS(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ce.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&V.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ce(r))),!0)}function xS(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ce))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let i=r.length-1;i>=0;i--)s=O.from(r[i].createAndFill(null,s));let o=t.state.tr.replace(n.pos,n.pos,new $(s,0,0));return o.setSelection(q.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function bS(t){if(!(t.selection instanceof ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(t.doc,[Ce.widget(t.selection.head,e,{key:"gapcursor"})])}var Zs=200,xe=function(){};xe.prototype.append=function(e){return e.length?(e=xe.from(e),!this.length&&e||e.length<Zs&&this.leafAppend(e)||this.length<Zs&&e.leafPrepend(this)||this.appendInner(e)):this};xe.prototype.prepend=function(e){return e.length?xe.from(e).append(this):this};xe.prototype.appendInner=function(e){return new kS(this,e)};xe.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?xe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};xe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};xe.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};xe.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},n,r),s};xe.from=function(e){return e instanceof xe?e:e&&e.length?new Ah(e):xe.empty};var Ah=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(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<=Zs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Zs)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(xe);xe.empty=new Ah([]);var kS=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,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})(xe);const vS=500;class Ye{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;n&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){s||(s=this.remapping(r,f+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new St(d.map));let h=d.step.map(s.slice(o)),m;h&&i.maybeStep(h).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new St(m,void 0,void 0,c.length+u.length))),o--,m&&s.appendMap(m,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new Ye(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,n,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new St(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),n&&(i++,n=void 0),s||(a=f)}let c=i-r.depth;return c>SS&&(l=wS(l,c),i-=c),new Ye(l.append(o),i)}remapping(e,n){let r=new xr;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,n),r}addMaps(e){return this.eventCount==0?this:new Ye(this.items.append(e.map(n=>new St(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},s);let a=n;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;i=Math.min(i,h);let m=o.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,r.push(new St(m,g,y))}else r.push(new St(m))},s);let c=[];for(let f=n;f<i;f++)c.push(new St(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new Ye(u,l);return d.emptyItemCount()>vS&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,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(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=i.selection&&i.selection.map(n.slice(r));u&&o++;let d=new St(c.invert(),a,u),f,h=s.length-1;(f=s.length&&s[h].merge(d))?s[h]=f:s.push(d)}}else i.map&&r--},this.items.length,0),new Ye(xe.from(s.reverse()),o)}}Ye.empty=new Ye(xe.empty,0);function wS(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let St=class Ih{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Ih(n.getMap().invert(),n,this.selection)}}};class Tt{constructor(e,n,r,s,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const SS=20;function CS(t,e,n,r){let s=n.getMeta(tn),o;if(s)return s.historyState;n.getMeta(TS)&&(t=new Tt(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(tn))return i.getMeta(tn).redo?new Tt(t.done.addTransform(n,void 0,r,ls(e)),t.undone,iu(n.mapping.maps),t.prevTime,t.prevComposition):new Tt(t.done,t.undone.addTransform(n,void 0,r,ls(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!i&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!NS(n,t.prevRanges)),c=i?vi(t.prevRanges,n.mapping):iu(n.mapping.maps);return new Tt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,ls(e)),Ye.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new Tt(t.done.rebased(n,o),t.undone.rebased(n,o),vi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Tt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function NS(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(n=!0)}),n}function iu(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,o,i)=>e.push(o,i));return e}function vi(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),o=e.map(t[r+1],-1);s<=o&&n.push(s,o)}return n}function ES(t,e,n){let r=ls(e),s=tn.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new Tt(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(tn,{redo:n,historyState:a})}let wi=!1,lu=null;function ls(t){let e=t.plugins;if(lu!=e){wi=!1,lu=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){wi=!0;break}}return wi}const tn=new de("history"),TS=new de("closeHistory");function MS(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ie({key:tn,state:{init(){return new Tt(Ye.empty,Ye.empty,null,0,-1)},apply(e,n,r){return CS(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Rh:r=="historyRedo"?Dh:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function jh(t,e){return(n,r)=>{let s=tn.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let o=ES(s,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const Rh=jh(!1,!0),Dh=jh(!0,!0);fe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new ie({key:new de("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!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 t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.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,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var OS=fe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[dS(this.options)]}});fe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ie({key:new de("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!n||!r)return se.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return t.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}))}),se.create(t,o)}}})]}});var AS=fe.create({name:"gapCursor",addProseMirrorPlugins(){return[mS()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=te(F(t,"allowGapCursor",n)))!=null?e:null}}});fe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new ie({key:new de("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Mo(i);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const d=Ce.node(l,l+i.nodeSize,{class:u.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(d)}return this.options.includeChildren}),se.create(t,s)}}})]}});fe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ie({key:new de("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Vf(n.selection)||t.view.dragging?null:se.create(n.doc,[Ce.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function au({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var IS=fe.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new de(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new ie({key:e,appendTransaction:(s,o,i)=>{const{doc:l,tr:a,schema:c}=i,u=e.getState(i),d=l.content.size,f=c.nodes[n];if(u)return a.insert(d,f.create())},state:{init:(s,o)=>{const i=o.tr.doc.lastChild;return!au({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!au({node:i,types:r})}}})]}}),jS=fe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Rh(t,e),redo:()=>({state:t,dispatch:e})=>Dh(t,e)}},addProseMirrorPlugins(){return[MS(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()}}}),RS=fe.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(iw.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(tw.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(bh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(cw.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(fw.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(hw.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(OS.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(AS.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(pw.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(mw.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(jS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(gw.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(vw.configure(this.options.italic)),this.options.listItem!==!1&&s.push(kh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Eh.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(qw.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Mh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(oS.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(aS.configure(this.options.strike)),this.options.text!==!1&&s.push(cS.configure(this.options.text)),this.options.underline!==!1&&s.push(uS.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(IS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),DS=RS;function PS(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=t,a=r&&!s,c=Ev(n),u=new RegExp(`\\s${c}$`),d=i?"^":"",f=s?"":c,h=a?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),m=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!m)return null;const g=l.pos-m.length,y=Array.from(m.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const x=y.input.slice(Math.max(0,y.index-1),y.index),b=new RegExp(`^[${o?.join("")}\0]?$`).test(x);if(o!==null&&!b)return null;const k=g+y.index;let S=k+y[0].length;return a&&u.test(m.slice(S-1,S+1))&&(y[0]+=" ",S+=1),k<l.pos&&S>=l.pos?{range:{from:k,to:S},query:y[0].slice(n.length),text:y[0]}:null}var LS=new de("suggestion");function $S({pluginKey:t=LS,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:m=()=>!0,findSuggestionMatch:g=PS,shouldShow:y}){let x;const b=h?.(),k=()=>{const w=e.state.selection.$anchor.pos,M=e.view.coordsAtPos(w),{top:E,right:A,bottom:D,left:_}=M;try{return new DOMRect(_,E,A-_,D-E)}catch{return null}},S=(w,M)=>M?()=>{const E=t.getState(e.state),A=E?.decorationId,D=w.dom.querySelector(`[data-decoration-id="${A}"]`);return D?.getBoundingClientRect()||null}:k;function v(w,M){var E;try{const D=t.getState(w.state),_=D?.decorationId?w.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,B={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:z=>d({editor:e,range:D?.range||{from:0,to:0},props:z}),decorationNode:_,clientRect:S(w,_)};(E=b?.onExit)==null||E.call(b,B)}catch{}const A=w.state.tr.setMeta(M,{exit:!0});w.dispatch(A)}const C=new ie({key:t,view(){return{update:async(w,M)=>{var E,A,D,_,B,z,R;const T=(E=this.key)==null?void 0:E.getState(M),L=(A=this.key)==null?void 0:A.getState(w.state),P=T.active&&L.active&&T.range.from!==L.range.from,U=!T.active&&L.active,X=T.active&&!L.active,H=!U&&!X&&T.query!==L.query,W=U||P&&H,Q=H||P,J=X||P&&H;if(!W&&!Q&&!J)return;const K=J&&!W?T:L,le=w.dom.querySelector(`[data-decoration-id="${K.decorationId}"]`);x={editor:e,range:K.range,query:K.query,text:K.text,items:[],command:ze=>d({editor:e,range:K.range,props:ze}),decorationNode:le,clientRect:S(w,le)},W&&((D=b?.onBeforeStart)==null||D.call(b,x)),Q&&((_=b?.onBeforeUpdate)==null||_.call(b,x)),(Q||W)&&(x.items=await f({editor:e,query:K.query})),J&&((B=b?.onExit)==null||B.call(b,x)),Q&&((z=b?.onUpdate)==null||z.call(b,x)),W&&((R=b?.onStart)==null||R.call(b,x))},destroy:()=>{var w;x&&((w=b?.onExit)==null||w.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(w,M,E,A){const{isEditable:D}=e,{composing:_}=e.view,{selection:B}=w,{empty:z,from:R}=B,T={...M},L=w.getMeta(t);if(L&&L.exit)return T.active=!1,T.decorationId=null,T.range={from:0,to:0},T.query=null,T.text=null,T;if(T.composing=_,D&&(z||e.view.composing)){(R<M.range.from||R>M.range.to)&&!_&&!M.composing&&(T.active=!1);const P=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:B.$from}),U=`id_${Math.floor(Math.random()*4294967295)}`;P&&m({editor:e,state:A,range:P.range,isActive:M.active})&&(!y||y({editor:e,range:P.range,query:P.query,text:P.text,transaction:w}))?(T.active=!0,T.decorationId=M.decorationId?M.decorationId:U,T.range=P.range,T.query=P.query,T.text=P.text):T.active=!1}else T.active=!1;return T.active||(T.decorationId=null,T.range={from:0,to:0},T.query=null,T.text=null),T}},props:{handleKeyDown(w,M){var E,A,D,_;const{active:B,range:z}=C.getState(w.state);if(!B)return!1;if(M.key==="Escape"||M.key==="Esc"){const T=C.getState(w.state),L=(E=x?.decorationNode)!=null?E:null,P=L??(T?.decorationId?w.dom.querySelector(`[data-decoration-id="${T.decorationId}"]`):null);if(((A=b?.onKeyDown)==null?void 0:A.call(b,{view:w,event:M,range:T.range}))||!1)return!0;const X={editor:e,range:T.range,query:T.query,text:T.text,items:[],command:H=>d({editor:e,range:T.range,props:H}),decorationNode:P,clientRect:P?()=>P.getBoundingClientRect()||null:null};return(D=b?.onExit)==null||D.call(b,X),v(w,t),!0}return((_=b?.onKeyDown)==null?void 0:_.call(b,{view:w,event:M,range:z}))||!1},decorations(w){const{active:M,range:E,decorationId:A,query:D}=C.getState(w);if(!M)return null;const _=!D?.length,B=[a];return _&&B.push(u),se.create(w.doc,[Ce.inline(E.from,E.to,{nodeName:l,class:B.join(" "),"data-decoration-id":A,"data-decoration-content":c})])}}});return C}function _S({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const s=new de;return{editor:t,char:r,pluginKey:s,command:({editor:o,range:i,props:l})=>{var a,c,u;const d=o.view.state.selection.$to.nodeAfter;(a=d?.text)!=null&&a.startsWith(" ")&&(i.to+=1),o.chain().focus().insertContentAt(i,[{type:n,attrs:{...l,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(u=(c=o.view.dom.ownerDocument.defaultView)==null?void 0:c.getSelection())==null||u.collapseToEnd()},allow:({state:o,range:i})=>{const l=o.doc.resolve(i.from),a=o.schema.nodes[n];return!!l.parent.type.contentMatch.matchType(a)},...e}}function Ph(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>_S({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function cu(t,e){const n=Ph(t),r=n.find(s=>s.char===e);return r||(n.length?n[0]:null)}var zS=je.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e?.char)!=null?n:"@"}${(r=t.attrs.label)!=null?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,s;return["span",oe(this.HTMLAttributes,t.HTMLAttributes),`${(r=n?.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:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=cu(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",oe({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=oe({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof s=="string"?["span",oe({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...oh({nodeName:"mention",name:"@",selfClosing:!0,allowedAttributes:["id","label",{name:"mentionSuggestionChar",skipIfDefault:"@"}],parseAttributes:t=>{const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,o,i]=r,l=o??i;e[s==="char"?"mentionSuggestionChar":s]=l,r=n.exec(t)}return e},serializeAttributes:t=>Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e==="mentionSuggestionChar"?"char":e}="${n}"`).join(" ")}),renderText({node:t}){const e={options:this.options,node:t,suggestion:cu(this,t.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:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:s,anchor:o}=r;if(!s)return!1;let i=new We,l=0;return e.doc.nodesBetween(o-1,o,(a,c)=>{if(a.type.name===this.name)return n=!0,i=a,l=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,l,l+i.nodeSize),n})}},addProseMirrorPlugins(){return Ph(this).map($S)}}),BS=zS,Si,jo="HoverCard",[Lh]=ll(jo,[mu]),Ro=mu(),[FS,Do]=Lh(jo),$h=t=>{const{__scopeHoverCard:e,children:n,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=t,a=Ro(e),c=N.useRef(0),u=N.useRef(0),d=N.useRef(!1),f=N.useRef(!1),[h,m]=so({prop:r,defaultProp:s??!1,onChange:o,caller:jo}),g=N.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>m(!0),i)},[i,m]),y=N.useCallback(()=>{clearTimeout(c.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>m(!1),l))},[l,m]),x=N.useCallback(()=>m(!1),[m]);return N.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),p.jsx(FS,{scope:e,open:h,onOpenChange:m,onOpen:g,onClose:y,onDismiss:x,hasSelectionRef:d,isPointerDownOnContentRef:f,children:p.jsx(kp,{...a,children:n})})};$h.displayName=jo;var _h="HoverCardTrigger",zh=N.forwardRef((t,e)=>{const{__scopeHoverCard:n,...r}=t,s=Do(_h,n),o=Ro(n);return p.jsx(xp,{asChild:!0,...o,children:p.jsx(zn.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:Ge(t.onPointerEnter,to(s.onOpen)),onPointerLeave:Ge(t.onPointerLeave,to(s.onClose)),onFocus:Ge(t.onFocus,s.onOpen),onBlur:Ge(t.onBlur,s.onClose),onTouchStart:Ge(t.onTouchStart,i=>i.preventDefault())})})});zh.displayName=_h;var aa="HoverCardPortal",[VS,HS]=Lh(aa,{forceMount:void 0}),Bh=t=>{const{__scopeHoverCard:e,forceMount:n,children:r,container:s}=t,o=Do(aa,e);return p.jsx(VS,{scope:e,forceMount:n,children:p.jsx(al,{present:n||o.open,children:p.jsx(bp,{asChild:!0,container:s,children:r})})})};Bh.displayName=aa;var eo="HoverCardContent",Fh=N.forwardRef((t,e)=>{const n=HS(eo,t.__scopeHoverCard),{forceMount:r=n.forceMount,...s}=t,o=Do(eo,t.__scopeHoverCard);return p.jsx(al,{present:r||o.open,children:p.jsx(WS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:Ge(t.onPointerEnter,to(o.onOpen)),onPointerLeave:Ge(t.onPointerLeave,to(o.onClose)),ref:e})})});Fh.displayName=eo;var WS=N.forwardRef((t,e)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=t,a=Do(eo,n),c=Ro(n),u=N.useRef(null),d=cl(e,u),[f,h]=N.useState(!1);return N.useEffect(()=>{if(f){const m=document.body;return Si=m.style.userSelect||m.style.webkitUserSelect,m.style.userSelect="none",m.style.webkitUserSelect="none",()=>{m.style.userSelect=Si,m.style.webkitUserSelect=Si}}},[f]),N.useEffect(()=>{if(u.current){const m=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",m),()=>{document.removeEventListener("pointerup",m),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),N.useEffect(()=>{u.current&&KS(u.current).forEach(g=>g.setAttribute("tabindex","-1"))}),p.jsx(vp,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:Ge(o,m=>{m.preventDefault()}),onDismiss:a.onDismiss,children:p.jsx(wp,{...c,...l,onPointerDown:Ge(l.onPointerDown,m=>{m.currentTarget.contains(m.target)&&h(!0),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!0}),ref:d,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)"}})})}),US="HoverCardArrow",qS=N.forwardRef((t,e)=>{const{__scopeHoverCard:n,...r}=t,s=Ro(n);return p.jsx(Sp,{...s,...r,ref:e})});qS.displayName=US;function to(t){return e=>e.pointerType==="touch"?void 0:t()}function KS(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;n.nextNode();)e.push(n.currentNode);return e}var JS=$h,GS=zh,YS=Bh,XS=Fh;function QS(t){const e=j.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(JS,{"data-slot":"hover-card",...n}),e[2]=n,e[3]=r):r=e[3],r}function ZS(t){const e=j.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(GS,{"data-slot":"hover-card-trigger",...n}),e[2]=n,e[3]=r):r=e[3],r}function e2(t){const e=j.c(12);let n,r,s,o;e[0]!==t?({className:n,align:s,sideOffset:o,...r}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=o):(n=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]!==n?(a=Z("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",n),e[5]=n,e[6]=a):a=e[6];let c;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==a?(c=p.jsx(YS,{"data-slot":"hover-card-portal",children:p.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 Vh=N.createContext(void 0);function t2(t,e){const n=e.split("."),r=n[0];if(!r)return;let s=t[r];for(let o=1;o<n.length&&s!==void 0;o++){const i=n[o];if(i)if(typeof s=="object"&&s!==null)s=s[i];else return}return s}function n2(t){const e=j.c(20),{node:n}=t,r=N.useContext(Vh),s=n.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const g=o?t2(r,s):void 0;i=g!==void 0?typeof g=="object"?JSON.stringify(g,null,2):String(g):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=p.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 g;return e[6]!==c?(g=p.jsx(Uc,{as:"span",children:c}),e[6]=c,e[7]=g):g=e[7],g}let u;e[8]!==c?(u=p.jsx(ZS,{asChild:!0,children:c}),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==s?(d=p.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:["@",s]}),e[10]=s,e[11]=d):d=e[11];let f;e[12]!==l?(f=p.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]!==d||e[15]!==f?(h=p.jsx(e2,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:p.jsxs("div",{className:"space-y-1.5",children:[d,f]})}),e[14]=d,e[15]=f,e[16]=h):h=e[16];let m;return e[17]!==u||e[18]!==h?(m=p.jsx(Uc,{as:"span",children:p.jsxs(QS,{openDelay:200,children:[u,h]})}),e[17]=u,e[18]=h,e[19]=m):m=e[19],m}function Hh(t){const e=[];function n(r){for(const s of r)s.children?.length||e.push(s),s.children&&n(s.children)}return n(t),e}let lt=Wh();function Wh(){return vl(()=>({items:[],selectedIndex:0,command:null}))}function uu(t,e){lt.setState({items:t,command:e,selectedIndex:0})}function r2(){const{items:t,selectedIndex:e}=lt.getState();t.length&&lt.setState({selectedIndex:(e-1+t.length)%t.length})}function s2(){const{items:t,selectedIndex:e}=lt.getState();t.length&&lt.setState({selectedIndex:(e+1)%t.length})}function Uh(){const{items:t,selectedIndex:e,command:n}=lt.getState(),r=t[e];return r?(n?.(r),!0):!1}function du(){lt=Wh()}function o2(){const t=j.c(7),e=Ei(lt,l2),n=Ei(lt,i2);if(!e.length)return null;let r;if(t[0]!==e||t[1]!==n){let o;t[3]!==n?(o=(i,l)=>p.jsx("button",{type:"button",onClick:()=>{lt.setState({selectedIndex:l}),Uh()},className:Z("flex items-center w-full text-left px-3 py-1.5 text-sm rounded-md transition-colors",l===n?"bg-accent text-accent-foreground":"hover:bg-muted"),children:i.label},i.id),t[3]=n,t[4]=o):o=t[4],r=e.map(o),t[0]=e,t[1]=n,t[2]=r}else r=t[2];let s;return t[5]!==r?(s=p.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:p.jsx("div",{className:"p-1",children:r})}),t[5]=r,t[6]=s):s=t[6],s}function i2(t){return t.selectedIndex}function l2(t){return t.items}function a2(){let t=null,e=null;return{onStart:n=>{uu(n.items,n.command),t=new ch(o2,{editor:n.editor}),e=document.createElement("div"),e.style.cssText="position:absolute;z-index:9999";const r=n.clientRect?.();r&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`),e.appendChild(t.element),document.body.appendChild(e)},onUpdate:n=>{uu(n.items,n.command);const r=n.clientRect?.();r&&e&&(e.style.top=`${r.bottom+window.scrollY+4}px`,e.style.left=`${r.left+window.scrollX}px`)},onKeyDown:({event:n})=>n.key==="Escape"?(e?.remove(),t?.destroy(),du(),!0):n.key==="ArrowUp"?(r2(),!0):n.key==="ArrowDown"?(s2(),!0):n.key==="Enter"?Uh():!1,onExit:()=>{e?.remove(),t?.destroy(),du()}}}const Ci=/@([\w.]+)/g;function c2(t,e){if(!t)return null;const n=Hh(e),r=new Map(n.map(a=>[a.id,a]));if(!Ci.test(t))return t;Ci.lastIndex=0;const o=[];let i=0,l;for(;(l=Ci.exec(t))!==null;){const a=l[1]??"",c=l.index;c>i&&o.push({type:"text",text:t.slice(i,c)});const u=r.get(a);u?o.push({type:"mention",attrs:{id:u.id,label:u.label}}):o.push({type:"text",text:l[0]}),i=c+l[0].length}return i<t.length&&o.push({type:"text",text:t.slice(i)}),{type:"doc",content:[{type:"paragraph",content:o.length>0?o:void 0}]}}function ca(t){const e=j.c(31),{mentions:n,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=t,a=T0();let c;e[0]!==n||e[1]!==r?(c=c2(r,n),e[0]=n,e[1]=r,e[2]=c):c=e[2];const u=c,d=a!==void 0,f=!l;let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=DS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let m;if(e[4]!==n||e[5]!==d){let E;e[7]!==n?(E=A=>{const{query:D}=A;return Hh(n).filter(B=>B.label.toLowerCase().includes(D.toLowerCase())||B.id.toLowerCase().includes(D.toLowerCase()))},e[7]=n,e[8]=E):E=e[8],m=BS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:h2,renderHTML:f2,suggestion:{items:E,render:a2,command:d2}}).extend(d?{addNodeView(){return Zv(n2)}}:{}),e[4]=n,e[5]=d,e[6]=m}else m=e[6];let g;e[9]!==m?(g=[h,m],e[9]=m,e[10]=g):g=e[10];const y=o??"";let x;e[11]!==y?(x={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full min-h-[20px]","data-placeholder":y},handleKeyDown:u2},e[11]=y,e[12]=x):x=e[12];let b;e[13]!==s?(b=E=>{const{editor:A}=E;return s?.(A.getText().trim())},e[13]=s,e[14]=b):b=e[14];let k;e[15]!==u||e[16]!==f||e[17]!==g||e[18]!==x||e[19]!==b?(k={content:u,editable:f,extensions:g,editorProps:x,onUpdate:b},e[15]=u,e[16]=f,e[17]=g,e[18]=x,e[19]=b,e[20]=k):k=e[20];const S=qv(k);let v;e[21]!==i?(v=Z("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]=v):v=e[22];let C;e[23]!==S?(C=p.jsx(zv,{editor:S}),e[23]=S,e[24]=C):C=e[24];let w;e[25]!==v||e[26]!==C?(w=p.jsx("div",{className:v,children:C}),e[25]=v,e[26]=C,e[27]=w):w=e[27];const M=w;if(a!==void 0){let E;return e[28]!==M||e[29]!==a?(E=p.jsx(Vh.Provider,{value:a,children:M}),e[28]=M,e[29]=a,e[30]=E):E=e[30],E}return M}function u2(t,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function d2(t){const{editor:e,range:n,props:r}=t;e.chain().focus().insertContentAt(n,[{type:"mention",attrs:r}]).run()}function f2(t){const{options:e,node:n}=t;return["span",e.HTMLAttributes,`@${n.attrs.id}`]}function h2(t){const{node:e}=t;return`@${e.attrs.id}`}function p2(t){const e=j.c(8),{value:n,onChange:r,placeholder:s,readonly:o}=t,i=Xu(),l=n??"";let a;e[0]!==r?(a=d=>r(d),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let u;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(u=p.jsx(ca,{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]=u):u=e[7],u}function m2(t){const e=j.c(8),{value:n,onChange:r,placeholder:s,readonly:o}=t,i=Xu(),l=n??"";let a;e[0]!==r?(a=d=>r(d),e[0]=r,e[1]=a):a=e[1];const c=s||"Enter value...";let u;return e[2]!==i||e[3]!==o||e[4]!==l||e[5]!==a||e[6]!==c?(u=p.jsx(ca,{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]=u):u=e[7],u}function g2(t){const e=j.c(8),{value:n,onChange:r,readonly:s,id:o}=t,i=n??"";let l;e[0]!==r?(l=u=>r(u.target.value===""?void 0:Number(u.target.value)),e[0]=r,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=Z("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=p.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 y2(t){const e=j.c(13),{value:n,onChange:r,readonly:s,id:o,label:i}=t,l=n??!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=p.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 u;e[7]!==i?(u=p.jsx("span",{className:"text-sm",children:i}),e[7]=i,e[8]=u):u=e[8];let d;return e[9]!==o||e[10]!==c||e[11]!==u?(d=p.jsxs("label",{htmlFor:o,className:"flex items-center gap-2 cursor-pointer",children:[c,u]}),e[9]=o,e[10]=c,e[11]=u,e[12]=d):d=e[12],d}function x2(t){const e=j.c(14),{value:n,onChange:r,readonly:s,id:o,options:i}=t;let l;e[0]!==i.enumOptions?(l=i.enumOptions??[],e[0]=i.enumOptions,e[1]=l):l=e[1];const a=l,c=n??"";let u;e[2]!==r?(u=g=>r(g.target.value),e[2]=r,e[3]=u):u=e[3];let d,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=Z("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=p.jsx("option",{value:"",children:"Select..."}),e[4]=d,e[5]=f):(d=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(b2),e[6]=a,e[7]=h):h=e[7];let m;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==u||e[12]!==h?(m=p.jsxs("select",{id:o,value:c,onChange:u,disabled:s,className:d,children:[f,h]}),e[8]=o,e[9]=s,e[10]=c,e[11]=u,e[12]=h,e[13]=m):m=e[13],m}function b2(t){return p.jsx("option",{value:String(t.value),children:String(t.label)},String(t.value))}const k2={TextWidget:p2,TextareaWidget:m2,NumberWidget:g2,CheckboxWidget:y2,SelectWidget:x2};function v2(t){switch(Array.isArray(t)?t[0]:t??"unknown"){case"string":return{Icon:Tu,color:"text-blue-500"};case"number":case"integer":return{Icon:Nu,color:"text-blue-500"};case"array":return{Icon:vu,color:"text-purple-500"};case"object":return{Icon:ku,color:"text-orange-500"};case"boolean":return{Icon:Eu,color:"text-pink-500"};case"null":return{Icon:ul,color:"text-gray-500"};default:return{Icon:Cu,color:"text-muted-foreground"}}}function w2(t){const e=j.c(36),{id:n,label:r,required:s,description:o,children:i,schema:l,hidden:a}=t;if(a){let v;return e[0]!==i?(v=p.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=v):v=e[1],v}if(n==="root"){let v;return e[2]!==i?(v=p.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=v):v=e[3],v}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let u,d,f,h,m,g,y;if(e[4]!==n||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:v,color:C}=v2(c);y="space-y-2",h="flex items-center gap-2",e[15]!==n||e[16]!==r?(m=p.jsx("label",{htmlFor:n,className:"text-sm font-medium leading-none",children:r}),e[15]=n,e[16]=r,e[17]=m):m=e[17],e[18]!==s?(g=s&&p.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=g):g=e[19],u=v,d=14,f=Z(C,"ml-auto"),e[4]=n,e[5]=r,e[6]=s,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=h,e[12]=m,e[13]=g,e[14]=y}else u=e[8],d=e[9],f=e[10],h=e[11],m=e[12],g=e[13],y=e[14];let x;e[20]!==u||e[21]!==d||e[22]!==f?(x=p.jsx(u,{size:d,className:f}),e[20]=u,e[21]=d,e[22]=f,e[23]=x):x=e[23];let b;e[24]!==h||e[25]!==m||e[26]!==g||e[27]!==x?(b=p.jsxs("div",{className:h,children:[m,g,x]}),e[24]=h,e[25]=m,e[26]=g,e[27]=x,e[28]=b):b=e[28];let k;e[29]!==o?(k=o&&p.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=k):k=e[30];let S;return e[31]!==i||e[32]!==y||e[33]!==b||e[34]!==k?(S=p.jsxs("div",{className:y,children:[b,k,i]}),e[31]=i,e[32]=y,e[33]=b,e[34]=k,e[35]=S):S=e[35],S}function S2(t){const e=j.c(8),{properties:n,title:r}=t;if(!r||r==="Root"){let l;e[0]!==n?(l=n.map(N2),e[0]=n,e[1]=l):l=e[1];let a;return e[2]!==l?(a=p.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==n?(o=n.map(C2),e[4]=n,e[5]=o):o=e[5];let i;return e[6]!==o?(i=p.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 C2(t){return p.jsx("div",{children:t.content},t.name)}function N2(t){return p.jsx("div",{children:t.content},t.name)}function E2(t){const e=j.c(11),{items:n,canAdd:r,onAddClick:s,title:o}=t;let i;e[0]!==n?(i=n.map(T2),e[0]=n,e[1]=i):i=e[1];let l;e[2]!==i?(l=p.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&&p.jsxs(ue,{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=p.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function T2(t){return p.jsx("div",{className:"flex gap-2 items-start",children:p.jsx("div",{className:"flex-1",children:t})},t.key||t.index)}function M2(){return null}function O2(){return null}const A2={FieldTemplate:w2,ObjectFieldTemplate:S2,ArrayFieldTemplate:E2,UnsupportedFieldTemplate:M2,ErrorListTemplate:O2};function I2(t){const e=j.c(6),{inputSchema:n,inputParams:r,mentions:s}=t;if(!n?.properties||!r)return null;let o;e[0]!==s?(o=(a,c,u)=>{const d=typeof c=="object"&&c!==null?JSON.stringify(c,null,2):String(c??""),f=Array.isArray(u.type)?u.type.join(" | "):u.type??"string";return p.jsxs("div",{className:"space-y-1.5",children:[p.jsxs("div",{className:"flex items-baseline gap-2",children:[p.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),p.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),u.description&&p.jsx("div",{className:"text-xs text-muted-foreground",children:u.description}),p.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:p.jsx(ca,{mentions:s,value:d,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]!==n.properties||e[4]!==i?(l=p.jsx("div",{className:"space-y-4",children:Object.entries(n.properties).map(a=>{const[c,u]=a,d=r[c];return i(c,d,u)})}),e[2]=r,e[3]=n.properties,e[4]=i,e[5]=l):l=e[5],l}function qh({inputSchema:t,inputParams:e,setInputParams:n,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!t)return p.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return p.jsx(I2,{inputSchema:t,inputParams:e,mentions:i});const l=t,a=N.useRef(e??{}),c=u=>{const d=u.formData??{},f=a.current;if(n?.(d),r){for(const[h,m]of Object.entries(d))f[h]!==m&&r(h,m);for(const h of Object.keys(f))h in d||r(h,void 0)}a.current=d};return p.jsx(Yu.Provider,{value:i,children:p.jsx(rm,{schema:l,formData:e,onChange:c,validator:sm,widgets:k2,templates:A2,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:p.jsx(p.Fragment,{})})})}function j2(t){const e=j.c(33),{open:n,onOpenChange:r,inputSchema:s,onSubmit:o,isPending:i}=t;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[a,c]=N.useState(l);let u;e[1]!==a||e[2]!==r||e[3]!==o?(u=async()=>{await o(a),r(!1),c({})},e[1]=a,e[2]=r,e[3]=o,e[4]=u):u=e[4];const d=u;let f;e[5]!==r?(f=M=>{M||c({}),r(M)},e[5]=r,e[6]=f):f=e[6];const h=f;let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsxs(um,{children:[p.jsx(dm,{children:"Workflow Input"}),p.jsx(fm,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=m):m=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=[],e[8]=g):g=e[8];let y;e[9]!==a||e[10]!==s?(y=p.jsx("div",{className:"py-4",children:p.jsx(qh,{inputSchema:s,inputParams:a,setInputParams:c,mentions:g})}),e[9]=a,e[10]=s,e[11]=y):y=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=p.jsx(ue,{variant:"outline",onClick:x,disabled:i,children:"Cancel"}),e[14]=i,e[15]=x,e[16]=b):b=e[16];let k;e[17]!==i?(k=i?p.jsx(Fn,{size:"xs"}):p.jsx(ml,{size:14}),e[17]=i,e[18]=k):k=e[18];let S;e[19]!==d||e[20]!==i||e[21]!==k?(S=p.jsxs(ue,{onClick:d,disabled:i,className:"gap-2",children:[k,"Run Workflow"]}),e[19]=d,e[20]=i,e[21]=k,e[22]=S):S=e[22];let v;e[23]!==S||e[24]!==b?(v=p.jsxs(hm,{children:[b,S]}),e[23]=S,e[24]=b,e[25]=v):v=e[25];let C;e[26]!==v||e[27]!==y?(C=p.jsxs(pm,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[m,y,v]}),e[26]=v,e[27]=y,e[28]=C):C=e[28];let w;return e[29]!==h||e[30]!==n||e[31]!==C?(w=p.jsx(mm,{open:n,onOpenChange:h,children:C}),e[29]=h,e[30]=n,e[31]=C,e[32]=w):w=e[32],w}function R2(t){const e=j.c(26),{title:n,description:r,onSave:s}=t,i=ro().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:u}=wl(),{resetToOriginalWorkflow:d,setSelectedGatewayId:f}=Oe(),h=Fu(),m=Wn(),g=we();let y;e[0]!==n?(y=p.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:n}),e[0]=n,e[1]=y):y=e[1];let x;e[2]!==r?(x=r?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),p.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]!==y||e[5]!==x?(b=p.jsx(pl,{children:p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y,x]})}),e[4]=y,e[5]=x,e[6]=b):b=e[6];let k;e[7]!==h||e[8]!==s||e[9]!==d||e[10]!==m||e[11]!==f||e[12]!==a||e[13]!==c||e[14]!==n||e[15]!==u||e[16]!==g||e[17]!==i||e[18]!==l?(k=!g&&p.jsxs(p.Fragment,{children:[p.jsx(lo,{title:n,url:i,icon:"workflow"}),p.jsx(N.Suspense,{fallback:p.jsx(Fn,{size:"xs"}),children:p.jsx(yu,{selectedGatewayId:m??void 0,onGatewayChange:f,variant:"bordered",placeholder:"Select gateway"})}),p.jsx(am,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:p.jsx(cm,{})},{value:"code",icon:p.jsx(Au,{})}]}),p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:d,disabled:!h,"aria-label":"Reset changes",children:p.jsx(uo,{size:14})})})}),p.jsx(et,{side:"bottom",children:"Reset changes"})]})}),p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:p.jsx(fo,{size:14})})})}),p.jsx(et,{side:"bottom",children:"Save workflow"})]})}),p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:p.jsx(ue,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:u,"aria-label":c?"Hide runs":"Show runs",children:p.jsx(Ou,{size:14})})})}),p.jsx(et,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=d,e[10]=m,e[11]=f,e[12]=a,e[13]=c,e[14]=n,e[15]=u,e[16]=g,e[17]=i,e[18]=l,e[19]=k):k=e[19];let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=p.jsx(L2,{}),e[20]=S):S=e[20];let v;e[21]!==k?(v=p.jsxs(co,{children:[k,S]}),e[21]=k,e[22]=v):v=e[22];let C;return e[23]!==b||e[24]!==v?(C=p.jsxs(p.Fragment,{children:[b,v]}),e[23]=b,e[24]=v,e[25]=C):C=e[25],C}function D2(){const t=we(),{item:e}=Rr(t);return e?.completed_at_epoch_ms!=null}function P2(){const t=we(),{item:e}=Rr(t);return e?.status==="cancelled"}function L2(){const t=j.c(57),e=Fu(),n=D2(),r=P2(),s=we(),o=Wn(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=C0(),u=Ir(),[d,f]=N.useState(!1),{handleCancelWorkflow:h,isCancelling:m}=N0(),{handleResumeWorkflow:g,isResuming:y}=E0(),x=s&&!n;let b;t[0]!==u?(b=u.some($2),t[0]=u,t[1]=b):b=t[1];const k=b,S=!o,v=e||k||S||l||m,C=x||l;let w;t[2]!==k||t[3]!==S||t[4]!==e||t[5]!==r||t[6]!==C?(w=()=>r?"Workflow is currently cancelled":C?"Workflow is currently running":e?"Save your changes before running":S?"Select a gateway first":k?"Add at least one step to the workflow":null,t[2]=k,t[3]=S,t[4]=e,t[5]=r,t[6]=C,t[7]=w):w=t[7];const E=w();let A;t[8]!==h||t[9]!==g||t[10]!==i||t[11]!==c||t[12]!==r||t[13]!==C||t[14]!==a||t[15]!==s?(A=async()=>{if(a&&c){f(!0);return}if(r&&s){await g(s);return}if(C&&s){await h(s);return}await i({})},t[8]=h,t[9]=g,t[10]=i,t[11]=c,t[12]=r,t[13]=C,t[14]=a,t[15]=s,t[16]=A):A=t[16];const D=A;let _;t[17]!==i?(_=async le=>{await i(le)},t[17]=i,t[18]=_):_=t[18];const B=_,z=r?"Resume":s?n?"Replay":"Running...":a?"Run with input...":"Run workflow",R=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let T;t[19]!==R?(T=Z("gap-2 h-7 px-3",R),t[19]=R,t[20]=T):T=t[20];let L;t[21]!==m||t[22]!==r||t[23]!==l||t[24]!==y||t[25]!==x?(L=(!x&&!l&&!m&&!y||r)&&p.jsx(ml,{size:14}),t[21]=m,t[22]=r,t[23]=l,t[24]=y,t[25]=x,t[26]=L):L=t[26];let P;t[27]!==m||t[28]!==r||t[29]!==l||t[30]!==y||t[31]!==x?(P=x&&!l&&!m&&!y&&!r&&p.jsx(_p,{size:14}),t[27]=m,t[28]=r,t[29]=l,t[30]=y,t[31]=x,t[32]=P):P=t[32];let U;t[33]!==m||t[34]!==l||t[35]!==y?(U=(l||m||y)&&p.jsx(Fn,{size:"xs"}),t[33]=m,t[34]=l,t[35]=y,t[36]=U):U=t[36];let X;t[37]!==z||t[38]!==D||t[39]!==v||t[40]!==T||t[41]!==L||t[42]!==P||t[43]!==U?(X=p.jsxs(ue,{variant:"default",size:"sm",className:T,disabled:v,onClick:D,children:[L,P,U,z]}),t[37]=z,t[38]=D,t[39]=v,t[40]=T,t[41]=L,t[42]=P,t[43]=U,t[44]=X):X=t[44];const H=X;let W;t[45]!==H||t[46]!==E?(W=E?p.jsx(Xe,{children:p.jsxs(Qe,{delayDuration:0,children:[p.jsx(Ze,{asChild:!0,children:p.jsx("span",{className:"inline-block",children:H})}),p.jsx(et,{side:"bottom",children:E})]})}):H,t[45]=H,t[46]=E,t[47]=W):W=t[47];const Q=W;let J;t[48]!==B||t[49]!==c||t[50]!==l||t[51]!==a||t[52]!==d?(J=a&&c&&p.jsx(j2,{open:d,onOpenChange:f,inputSchema:c,onSubmit:B,isPending:l}),t[48]=B,t[49]=c,t[50]=l,t[51]=a,t[52]=d,t[53]=J):J=t[53];let K;return t[54]!==Q||t[55]!==J?(K=p.jsxs(p.Fragment,{children:[Q,J]}),t[54]=Q,t[55]=J,t[56]=K):K=t[56],K}function $2(t){return"toolName"in t.action&&(!t.action.toolName||t.action.toolName==="")}function _2(){const t=j.c(17),e=we(),n=Ir(),{item:r}=Rr(e);if(!e||!r)return;let s;if(t[0]!==r.completed_steps?.error||t[1]!==r.completed_steps?.success||t[2]!==r.status||t[3]!==n){s={};let o;t[5]!==r.completed_steps?.success?(o=r.completed_steps?.success??[],t[5]=r.completed_steps?.success,t[6]=o):o=t[6];let i;t[7]!==o?(i=new Set(o),t[7]=o,t[8]=i):i=t[8];const l=i;let a;t[9]!==r.completed_steps?.error?(a=r.completed_steps?.error??[],t[9]=r.completed_steps?.error,t[10]=a):a=t[10];let c;t[11]!==a?(c=new Set(a),t[11]=a,t[12]=c):c=t[12];const u=c;let d;t[13]!==u||t[14]!==n||t[15]!==l?(d=-1,n.forEach((f,h)=>{(l.has(f.name)||u.has(f.name))&&(d=h)}),t[13]=u,t[14]=n,t[15]=l,t[16]=d):d=t[16],n.forEach((f,h)=>{let m="pending";u.has(f.name)?m="error":l.has(f.name)?m="success":r.status==="running"&&h===d+1&&(m="running"),s[f.name]={status:m,output:void 0,error:void 0,stepIndex:h}}),t[0]=r.completed_steps?.error,t[1]=r.completed_steps?.success,t[2]=r.status,t[3]=n,t[4]=s}else s=t[4];return s}function z2(t){const e=j.c(119),{step:n,index:r,isSelected:s,executionStatus:o,isSkipped:i,isLastStep:l,onSelect:a,onDelete:c,onDuplicate:u}=t,d=we(),{item:f}=Rr(d),h=f?.completed_at_epoch_ms;let m;e[0]!==f?.completed_steps?.success||e[1]!==n.name?(m=f?.completed_steps?.success?.includes(n.name)??!1,e[0]=f?.completed_steps?.success,e[1]=n.name,e[2]=m):m=e[2];const g=m;let y;e[3]!==f?.completed_steps?.error||e[4]!==n.name?(y=f?.completed_steps?.error?.includes(n.name)??!1,e[3]=f?.completed_steps?.error,e[4]=n.name,e[5]=y):y=e[5];const x=y,b="toolName"in n.action,k=b&&"connectionId"in n.action?n.action.connectionId:null,v=!!(b&&"toolName"in n.action?n.action.toolName:null);let C,w,M,E,A,D,_,B,z,R,T;if(e[6]!==k||e[7]!==o||e[8]!==v||e[9]!==r||e[10]!==g||e[11]!==x||e[12]!==l||e[13]!==s||e[14]!==i||e[15]!==b||e[16]!==c||e[17]!==u||e[18]!==a||e[19]!==n||e[20]!==d){const H=Y2(n);C=g?"success":x?"error":o?.status;const W=o!==void 0,Q=C==="success"||C==="error";let J=H.length>0?60:12;(C==="success"||C==="error")&&(J=J+32);let K,le,ze;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==C){const Jn=V2(C);let _r;e[44]!==C?(_r=H2(C),e[44]=C,e[45]=_r):_r=e[45],K=_r;const _o=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",zo=C==="running"&&"bg-accent/50",Bo=i&&"opacity-50";e[46]!==_o||e[47]!==zo||e[48]!==Bo?(B=Z("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",_o,zo,Bo),e[46]=_o,e[47]=zo,e[48]=Bo,e[49]=B):B=e[49],z=a,R="button",T=0,e[50]!==a?(w=Fo=>{(Fo.key==="Enter"||Fo.key===" ")&&(Fo.preventDefault(),a())},e[50]=a,e[51]=w):w=e[51],ze="w-5 flex flex-col items-center justify-center shrink-0 pt-3",le=Z("text-xs font-mono opacity-75 h-8 flex items-center",Jn),e[32]=s,e[33]=i,e[34]=a,e[35]=C,e[36]=K,e[37]=w,e[38]=le,e[39]=ze,e[40]=B,e[41]=z,e[42]=R,e[43]=T}else K=e[36],w=e[37],le=e[38],ze=e[39],B=e[40],z=e[41],R=e[42],T=e[43];const Wt=r+1;let Re;e[52]!==le||e[53]!==Wt?(Re=p.jsxs("span",{className:le,children:[Wt,"."]}),e[52]=le,e[53]=Wt,e[54]=Re):Re=e[54],e[55]!==ze||e[56]!==Re?(M=p.jsx("div",{className:ze,children:Re}),e[55]=ze,e[56]=Re,e[57]=M):M=e[57];let De;e[58]!==K||e[59]!==r?(De=r>0?p.jsx(Ni,{height:12,color:K}):p.jsx("div",{className:"h-3"}),e[58]=K,e[59]=r,e[60]=De):De=e[60];let Pe;e[61]!==k||e[62]!==v||e[63]!==b||e[64]!==n.name?(Pe=p.jsx(J2,{connectionId:k,isToolStep:b,hasToolSelected:v,stepName:n.name}),e[61]=k,e[62]=v,e[63]=b,e[64]=n.name,e[65]=Pe):Pe=e[65];let Ke;e[66]!==K||e[67]!==Q||e[68]!==C?(Ke=Q&&p.jsxs(p.Fragment,{children:[p.jsx(Ni,{height:8,color:K}),p.jsx(W2,{status:C})]}),e[66]=K,e[67]=Q,e[68]=C,e[69]=Ke):Ke=e[69];let Je;e[70]!==K||e[71]!==J||e[72]!==l||e[73]!==d?(Je=l&&d?null:p.jsx(Ni,{height:J,color:K}),e[70]=K,e[71]=J,e[72]=l,e[73]=d,e[74]=Je):Je=e[74],e[75]!==De||e[76]!==Pe||e[77]!==Ke||e[78]!==Je?(E=p.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[De,Pe,Ke,Je]}),e[75]=De,e[76]=Pe,e[77]=Ke,e[78]=Je,e[79]=E):E=e[79],A="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const Kn=v?"font-medium text-foreground":"text-foreground";let fn;e[80]!==Kn?(fn=Z("text-sm truncate flex-1",Kn),e[80]=Kn,e[81]=fn):fn=e[81];let hn;e[82]!==n?(hn=G2(n),e[82]=n,e[83]=hn):hn=e[83];let pn;e[84]!==fn||e[85]!==hn?(pn=p.jsx("span",{className:fn,children:hn}),e[84]=fn,e[85]=hn,e[86]=pn):pn=e[86];let mn;e[87]!==W||e[88]!==C?(mn=W&&p.jsx(U2,{status:C}),e[87]=W,e[88]=C,e[89]=mn):mn=e[89];let gn;e[90]!==W||e[91]!==c||e[92]!==u?(gn=!W&&p.jsxs(gm,{children:[p.jsx(ym,{asChild:!0,children:p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:F2,children:p.jsx(Zp,{size:14})})}),p.jsxs(xm,{align:"end",children:[p.jsxs(ba,{onClick:Jn=>{Jn.stopPropagation(),u()},children:[p.jsx(vm,{size:14}),"Duplicate"]}),p.jsxs(ba,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:Jn=>{Jn.stopPropagation(),c()},children:[p.jsx(Cp,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=W,e[91]=c,e[92]=u,e[93]=gn):gn=e[93],e[94]!==pn||e[95]!==mn||e[96]!==gn?(D=p.jsxs("div",{className:"flex items-center h-8",children:[pn,mn,gn]}),e[94]=pn,e[95]=mn,e[96]=gn,e[97]=D):D=e[97],_=H.length>0&&p.jsx("div",{className:"flex flex-wrap gap-1.5",children:H.map(B2)}),e[6]=k,e[7]=o,e[8]=v,e[9]=r,e[10]=g,e[11]=x,e[12]=l,e[13]=s,e[14]=i,e[15]=b,e[16]=c,e[17]=u,e[18]=a,e[19]=n,e[20]=d,e[21]=C,e[22]=w,e[23]=M,e[24]=E,e[25]=A,e[26]=D,e[27]=_,e[28]=B,e[29]=z,e[30]=R,e[31]=T}else C=e[21],w=e[22],M=e[23],E=e[24],A=e[25],D=e[26],_=e[27],B=e[28],z=e[29],R=e[30],T=e[31];let L;e[98]!==h||e[99]!==C?(L=C==="success"&&p.jsx(q2,{completedAtEpochMs:h}),e[98]=h,e[99]=C,e[100]=L):L=e[100];let P;e[101]!==o?.error||e[102]!==C?(P=C==="error"&&p.jsx(K2,{error:o?.error}),e[101]=o?.error,e[102]=C,e[103]=P):P=e[103];let U;e[104]!==L||e[105]!==P||e[106]!==A||e[107]!==D||e[108]!==_?(U=p.jsxs("div",{className:A,children:[D,_,L,P]}),e[104]=L,e[105]=P,e[106]=A,e[107]=D,e[108]=_,e[109]=U):U=e[109];let X;return e[110]!==w||e[111]!==M||e[112]!==E||e[113]!==U||e[114]!==B||e[115]!==z||e[116]!==R||e[117]!==T?(X=p.jsxs("div",{className:B,onClick:z,role:R,tabIndex:T,onKeyDown:w,children:[M,E,U]}),e[110]=w,e[111]=M,e[112]=E,e[113]=U,e[114]=B,e[115]=z,e[116]=R,e[117]=T,e[118]=X):X=e[118],X}function B2(t){return p.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:t},t)}function F2(t){return t.stopPropagation()}function V2(t){switch(t){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function H2(t){switch(t){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function W2(t){const e=j.c(2),{status:n}=t;if(n==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:p.jsx(hl,{size:8,className:"text-success-foreground"})}),e[0]=r):r=e[0],r}if(n==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:p.jsx(gl,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function U2(t){const e=j.c(3),{status:n}=t;if(n==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-7 flex items-center justify-center",children:p.jsx(hl,{size:11,className:"text-success"})}),e[0]=r):r=e[0],r}if(n==="error"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-7 flex items-center justify-center",children:p.jsx(gl,{size:11,className:"text-destructive"})}),e[1]=r):r=e[1],r}if(n==="running"){let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"size-7 flex items-center justify-center",children:p.jsx(nn,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function q2(t){const e=j.c(8),{completedAtEpochMs:n}=t;let r,s;if(e[0]!==n){const a=n!=null?new Date(n):null;r=a?a.toISOString().split("T")[0]:null,s=a?a.toTimeString().split(" ")[0]:null,e[0]=n,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&&p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx(Xp,{size:16,className:"text-success"}),p.jsx("span",{className:"text-xs text-success",children:r}),p.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=p.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 K2(t){const e=j.c(3),{error:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx(kl,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=n||"Execution failed";let o;return e[1]!==s?(o=p.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,p.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function J2(t){const e=j.c(5),{connectionId:n,isToolStep:r,hasToolSelected:s,stepName:o}=t,i=fl(n??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=p.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:p.jsx(io,{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=p.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?p.jsx(Pu,{size:16,className:"text-muted-foreground"}):p.jsx(km,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function Ni(t){const e=j.c(7),{height:n,color:r}=t,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=Z("w-px",s),e[0]=s,e[1]=o):o=e[1];let i;e[2]!==n?(i={height:n},e[2]=n,e[3]=i):i=e[3];let l;return e[4]!==o||e[5]!==i?(l=p.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function G2(t){return t.name?t.name:"toolName"in t.action&&t.action.toolName?t.action.toolName:"code"in t.action?t.name||"Code Step":"Select tool..."}function Y2(t){const e=t.outputSchema;if(!e||typeof e!="object")return[];const n=e.properties;return!n||typeof n!="object"?[]:Object.keys(n).slice(0,5)}function X2(t){const e=j.c(32),{className:n}=t,r=Ir(),s=Bu(),o=_2(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Oe(),c=we();let u;e[0]!==o||e[1]!==r?(u=o?r.findIndex(k=>o[k.name]?.status==="error"):-1,e[0]=o,e[1]=r,e[2]=u):u=e[2];const d=u;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=p.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==n?(h=Z("h-full flex flex-col p-8 overflow-auto",n),e[4]=n,e[5]=h):h=e[5];let m;if(e[6]!==s||e[7]!==l||e[8]!==a||e[9]!==d||e[10]!==i||e[11]!==o||e[12]!==r){let k;e[14]!==s||e[15]!==l||e[16]!==a||e[17]!==d||e[18]!==i||e[19]!==o||e[20]!==r.length?(k=(S,v)=>{const C=o?.[S.name],w=d!==-1&&v>d&&C?.status==="pending",M=v===r.length-1;return p.jsx(z2,{step:S,index:v,isSelected:S.name===s,executionStatus:C,isSkipped:w,isLastStep:M,onSelect:()=>i(S.name),onDelete:()=>l(S.name),onDuplicate:()=>a(S.name)},S.name)},e[14]=s,e[15]=l,e[16]=a,e[17]=d,e[18]=i,e[19]=o,e[20]=r.length,e[21]=k):k=e[21],m=r.map(k),e[6]=s,e[7]=l,e[8]=a,e[9]=d,e[10]=i,e[11]=o,e[12]=r,e[13]=m}else m=e[13];let g;e[22]!==m?(g=p.jsx("div",{className:"pt-3 -space-y-1",children:m}),e[22]=m,e[23]=g):g=e[23];let y;e[24]!==c?(y=c?null:p.jsx(Q2,{}),e[24]=c,e[25]=y):y=e[25];let x;e[26]!==g||e[27]!==y?(x=p.jsxs("div",{className:"w-full -space-y-1",children:[g,y]}),e[26]=g,e[27]=y,e[28]=x):x=e[28];let b;return e[29]!==h||e[30]!==x?(b=p.jsx(N.Suspense,{fallback:f,children:p.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function Q2(){const t=j.c(8),{addToolStep:e}=Oe();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=p.jsx("div",{className:"w-5 shrink-0"}),t[0]=n):n=t[0];let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"w-px h-3 bg-border"}),t[1]=r):r=t[1];let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx(ao,{size:14}),t[2]=s):s=t[2];let o;t[3]!==e?(o=p.jsx(ue,{variant:"outline",size:"icon",className:"size-8 rounded-lg",onClick:e,children:s}),t[3]=e,t[4]=o):o=t[4];let i;t[5]===Symbol.for("react.memo_cache_sentinel")?(i=p.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%"}}),t[5]=i):i=t[5];let l;return t[6]!==o?(l=p.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[n,p.jsxs("div",{className:"flex flex-col border-1 border-transparent items-center shrink-0",children:[r,o,i]})]}),t[6]=o,t[7]=l):l=t[7],l}function Z2(){const t=j.c(5),e=Wn();let n;t[0]!==e?(n=e?new URL(`/mcp/gateway/${e}`,window.location.origin).href:"",t[0]=e,t[1]=n):n=t[1];const r=n,s=!!e;let o;return t[2]!==r||t[3]!==s?(o={url:r,enabled:s},t[2]=r,t[3]=s,t[4]=o):o=t[4],yl(o)}function eC(t){const e=j.c(7),{className:n}=t;if(!Wn()){let o;e[0]!==n?(o=Z("flex flex-col h-full bg-sidebar",n),e[0]=n,e[1]=o):o=e[1];let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=p.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=p.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==n?(s=p.jsx(tC,{className:n}),e[5]=n,e[6]=s):s=e[6],s}function tC(t){const e=j.c(38),{className:n}=t,{tools:r,isLoading:s,error:o}=Z2(),i=Ar(),{updateStep:l}=Oe(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let u;if(e[0]!==c||e[1]!==r){let v;e[3]!==c?(v=C=>C.name===c,e[3]=c,e[4]=v):v=e[4],u=r.find(v),e[0]=c,e[1]=r,e[2]=u}else u=e[2];const f=M0(r,u??null,rC,nC);let h;e[5]!==i||e[6]!==l?(h=v=>{i&&l(i.name,{action:{...i.action,toolName:v.name},outputSchema:v.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const m=h;if(s){let v;e[8]!==n?(v=Z("flex flex-col h-full bg-sidebar",n),e[8]=n,e[9]=v):v=e[9];let C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=p.jsx("div",{className:"flex-1 flex items-center justify-center",children:p.jsx(Fn,{size:"sm"})}),e[10]=C):C=e[10];let w;return e[11]!==v?(w=p.jsx("div",{className:v,children:C}),e[11]=v,e[12]=w):w=e[12],w}if(o){let v;e[13]!==n?(v=Z("flex flex-col h-full bg-sidebar",n),e[13]=n,e[14]=v):v=e[14];let C;e[15]!==o.message?(C=p.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]=C):C=e[16];let w;return e[17]!==v||e[18]!==C?(w=p.jsx("div",{className:v,children:C}),e[17]=v,e[18]=C,e[19]=w):w=e[19],w}let g;e[20]!==n?(g=Z("flex flex-col h-full bg-sidebar",n),e[20]=n,e[21]=g):g=e[21];let y;e[22]===Symbol.for("react.memo_cache_sentinel")?(y=p.jsx("span",{className:"text-base font-medium text-foreground",children:"Select tool"}),e[22]=y):y=e[22];let x;e[23]!==r.length?(x=p.jsx("div",{className:"flex items-start border-b border-border",children:p.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[y,p.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]!==m||e[26]!==f||e[27]!==c){let v;e[29]!==m||e[30]!==c?(v=C=>p.jsx(sC,{icon:null,title:C.name,description:C.description,isSelected:C.name===c,onClick:()=>m(C)},C.name),e[29]=m,e[30]=c,e[31]=v):v=e[31],b=f.map(v),e[25]=m,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let k;e[32]!==b?(k=p.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=k):k=e[33];let S;return e[34]!==g||e[35]!==x||e[36]!==k?(S=p.jsxs("div",{className:g,children:[x,k]}),e[34]=g,e[35]=x,e[36]=k,e[37]=S):S=e[37],S}function nC(t,e){return t.name.localeCompare(e.name)}function rC(t){return t.name}function sC(t){const e=j.c(20),{icon:n,title:r,description:s,isSelected:o,onClick:i}=t,l=o&&"bg-muted/50";let a;e[0]!==l?(a=Z("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=g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),i())},e[2]=i,e[3]=c):c=e[3];let u;e[4]!==n||e[5]!==r?(u=p.jsx(io,{icon:n,name:r,size:"xs",className:"shadow-sm mt-0.5"}),e[4]=n,e[5]=r,e[6]=u):u=e[6];let d;e[7]!==r?(d=p.jsx("span",{className:"text-sm font-medium text-foreground truncate block",children:r}),e[7]=r,e[8]=d):d=e[8];let f;e[9]!==s?(f=s&&p.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]!==d||e[12]!==f?(h=p.jsxs("div",{className:"flex-1 min-w-0",children:[d,f]}),e[11]=d,e[12]=f,e[13]=h):h=e[13];let m;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==u||e[18]!==h?(m=p.jsxs("div",{className:a,onClick:i,role:"button",tabIndex:0,onKeyDown:c,children:[u,h]}),e[14]=i,e[15]=a,e[16]=c,e[17]=u,e[18]=h,e[19]=m):m=e[19],m}var Po="Collapsible",[oC,Kh]=ll(Po),[iC,ua]=oC(Po),Jh=N.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=t,[a,c]=so({prop:r,defaultProp:s??!1,onChange:i,caller:Po});return p.jsx(iC,{scope:n,disabled:o,contentId:gu(),open:a,onOpenToggle:N.useCallback(()=>c(u=>!u),[c]),children:p.jsx(zn.div,{"data-state":fa(a),"data-disabled":o?"":void 0,...l,ref:e})})});Jh.displayName=Po;var Gh="CollapsibleTrigger",Yh=N.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,s=ua(Gh,n);return p.jsx(zn.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":fa(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:Ge(t.onClick,s.onOpenToggle)})});Yh.displayName=Gh;var da="CollapsibleContent",Xh=N.forwardRef((t,e)=>{const{forceMount:n,...r}=t,s=ua(da,t.__scopeCollapsible);return p.jsx(al,{present:n||s.open,children:({present:o})=>p.jsx(lC,{...r,ref:e,present:o})})});Xh.displayName=da;var lC=N.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=t,i=ua(da,n),[l,a]=N.useState(r),c=N.useRef(null),u=cl(e,c),d=N.useRef(0),f=d.current,h=N.useRef(0),m=h.current,g=i.open||l,y=N.useRef(g),x=N.useRef(void 0);return N.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),Np(()=>{const b=c.current;if(b){x.current=x.current||{transitionDuration:b.style.transitionDuration,animationName:b.style.animationName},b.style.transitionDuration="0s",b.style.animationName="none";const k=b.getBoundingClientRect();d.current=k.height,h.current=k.width,y.current||(b.style.transitionDuration=x.current.transitionDuration,b.style.animationName=x.current.animationName),a(r)}},[i.open,r]),p.jsx(zn.div,{"data-state":fa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:g&&s})});function fa(t){return t?"open":"closed"}var aC=Jh,cC=Yh,uC=Xh,rt="Accordion",dC=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[ha,fC,hC]=Ep(rt),[Lo]=ll(rt,[hC,Kh]),pa=Kh(),Qh=ee.forwardRef((t,e)=>{const{type:n,...r}=t,s=r,o=r;return p.jsx(ha.Provider,{scope:t.__scopeAccordion,children:n==="multiple"?p.jsx(yC,{...o,ref:e}):p.jsx(gC,{...s,ref:e})})});Qh.displayName=rt;var[Zh,pC]=Lo(rt),[ep,mC]=Lo(rt,{collapsible:!1}),gC=ee.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=t,[l,a]=so({prop:n,defaultProp:r??"",onChange:s,caller:rt});return p.jsx(Zh,{scope:t.__scopeAccordion,value:ee.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:ee.useCallback(()=>o&&a(""),[o,a]),children:p.jsx(ep,{scope:t.__scopeAccordion,collapsible:o,children:p.jsx(tp,{...i,ref:e})})})}),yC=ee.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},...o}=t,[i,l]=so({prop:n,defaultProp:r??[],onChange:s,caller:rt}),a=ee.useCallback(u=>l((d=[])=>[...d,u]),[l]),c=ee.useCallback(u=>l((d=[])=>d.filter(f=>f!==u)),[l]);return p.jsx(Zh,{scope:t.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:p.jsx(ep,{scope:t.__scopeAccordion,collapsible:!0,children:p.jsx(tp,{...o,ref:e})})})}),[xC,$o]=Lo(rt),tp=ee.forwardRef((t,e)=>{const{__scopeAccordion:n,disabled:r,dir:s,orientation:o="vertical",...i}=t,l=ee.useRef(null),a=cl(l,e),c=fC(n),d=Tp(s)==="ltr",f=Ge(t.onKeyDown,h=>{if(!dC.includes(h.key))return;const m=h.target,g=c().filter(M=>!M.ref.current?.disabled),y=g.findIndex(M=>M.ref.current===m),x=g.length;if(y===-1)return;h.preventDefault();let b=y;const k=0,S=x-1,v=()=>{b=y+1,b>S&&(b=k)},C=()=>{b=y-1,b<k&&(b=S)};switch(h.key){case"Home":b=k;break;case"End":b=S;break;case"ArrowRight":o==="horizontal"&&(d?v():C());break;case"ArrowDown":o==="vertical"&&v();break;case"ArrowLeft":o==="horizontal"&&(d?C():v());break;case"ArrowUp":o==="vertical"&&C();break}const w=b%x;g[w].ref.current?.focus()});return p.jsx(xC,{scope:n,disabled:r,direction:s,orientation:o,children:p.jsx(ha.Slot,{scope:n,children:p.jsx(zn.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),no="AccordionItem",[bC,ma]=Lo(no),np=ee.forwardRef((t,e)=>{const{__scopeAccordion:n,value:r,...s}=t,o=$o(no,n),i=pC(no,n),l=pa(n),a=gu(),c=r&&i.value.includes(r)||!1,u=o.disabled||t.disabled;return p.jsx(bC,{scope:n,open:c,disabled:u,triggerId:a,children:p.jsx(aC,{"data-orientation":o.orientation,"data-state":ap(c),...l,...s,ref:e,disabled:u,open:c,onOpenChange:d=>{d?i.onItemOpen(r):i.onItemClose(r)}})})});np.displayName=no;var rp="AccordionHeader",sp=ee.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=$o(rt,n),o=ma(rp,n);return p.jsx(zn.h3,{"data-orientation":s.orientation,"data-state":ap(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});sp.displayName=rp;var ol="AccordionTrigger",op=ee.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=$o(rt,n),o=ma(ol,n),i=mC(ol,n),l=pa(n);return p.jsx(ha.ItemSlot,{scope:n,children:p.jsx(cC,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});op.displayName=ol;var ip="AccordionContent",lp=ee.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=$o(rt,n),o=ma(ip,n),i=pa(n);return p.jsx(uC,{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)",...t.style}})});lp.displayName=ip;function ap(t){return t?"open":"closed"}var kC=Qh,vC=np,wC=sp,SC=op,CC=lp;function NC(t){const e=j.c(4);let n;e[0]!==t?({...n}=t,e[0]=t,e[1]=n):n=e[1];let r;return e[2]!==n?(r=p.jsx(kC,{"data-slot":"accordion",...n}),e[2]=n,e[3]=r):r=e[3],r}function EC(t){const e=j.c(8);let n,r;e[0]!==t?({className:n,...r}=t,e[0]=t,e[1]=n,e[2]=r):(n=e[1],r=e[2]);let s;e[3]!==n?(s=Z("border-b last:border-b-0",n),e[3]=n,e[4]=s):s=e[4];let o;return e[5]!==r||e[6]!==s?(o=p.jsx(vC,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function TC(t){const e=j.c(11);let n,r,s;e[0]!==t?({className:r,children:n,...s}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=Z("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=p.jsx(bm,{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]!==n||e[8]!==s||e[9]!==o?(l=p.jsx(wC,{className:"flex",children:p.jsxs(SC,{"data-slot":"accordion-trigger",className:o,...s,children:[n,i]})}),e[7]=n,e[8]=s,e[9]=o,e[10]=l):l=e[10],l}function MC(t){const e=j.c(12);let n,r,s;e[0]!==t?({className:r,children:n,...s}=t,e[0]=t,e[1]=n,e[2]=r,e[3]=s):(n=e[1],r=e[2],s=e[3]);let o;e[4]!==r?(o=Z("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==n||e[7]!==o?(i=p.jsx("div",{className:o,children:n}),e[6]=n,e[7]=o,e[8]=i):i=e[8];let l;return e[9]!==s||e[10]!==i?(l=p.jsx(CC,{"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 OC=(t,e,n,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function u(h){(Array.isArray(t)?t:[t]).forEach(m=>{let g=m==="class",y=g&&o?s.map(x=>o[x]||x):s;g?(a.classList.remove(...y),a.classList.add(o&&o[h]?o[h]:h)):a.setAttribute(m,h)}),d(h)}function d(h){l&&c.includes(h)&&(a.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)u(r);else try{let h=localStorage.getItem(e)||n,m=i&&h==="system"?f():h;u(m)}catch{}};N.createContext(void 0);N.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:s,defaultTheme:o,value:i,themes:l,nonce:a,scriptProps:c})=>{let u=JSON.stringify([n,e,o,t,l,i,r,s]).slice(1,-1);return N.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${OC.toString()})(${u})`}})});function AC(t){const{updateStep:e}=Oe(),r=t&&"toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,{tool:s}=ga(r??"");t&&r&&s?.outputSchema&&(!t.outputSchema||Object.keys(t.outputSchema).length===0)&&queueMicrotask(()=>{e(t.name,{outputSchema:s.outputSchema})})}function IC(t){const e=j.c(25),{className:n}=t,r=Ar(),{appendStep:s}=Oe();if(AC(r),!r){let f;e[0]!==n?(f=Z("flex flex-col h-full bg-sidebar",n),e[0]=n,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 m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(ao,{size:14}),e[4]=m):m=e[4];let g;e[5]!==h?(g=p.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",p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:m})]}),e[5]=h,e[6]=g):g=e[6];let y;return e[7]!==f||e[8]!==g?(y=p.jsx("div",{className:f,children:g}),e[7]=f,e[8]=g,e[9]=y):y=e[9],y}let o;e[10]!==n?(o=Z("flex flex-col h-full bg-sidebar overflow-hidden",n),e[10]=n,e[11]=o):o=e[11];let i,l,a,c,u;e[12]!==r?(i=p.jsx(jC,{step:r}),l=p.jsx(DC,{step:r}),a=p.jsx(PC,{step:r}),c=p.jsx(zC,{step:r}),u=p.jsx(BC,{step:r}),e[12]=r,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=u):(i=e[13],l=e[14],a=e[15],c=e[16],u=e[17]);let d;return e[18]!==o||e[19]!==i||e[20]!==l||e[21]!==a||e[22]!==c||e[23]!==u?(d=p.jsxs("div",{className:o,children:[i,l,a,c,u]}),e[18]=o,e[19]=i,e[20]=l,e[21]=a,e[22]=c,e[23]=u,e[24]=d):d=e[24],d}function jC(t){const e=j.c(15),{step:n}=t,s="toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,o=we(),i=s??"";let l;e[0]!==i?(l=p.jsx(io,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=p.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:p.jsx(RC,{}),e[4]=o,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==a||e[8]!==c?(u=p.jsxs("div",{className:"flex items-center gap-2",children:[l,a,c]}),e[6]=l,e[7]=a,e[8]=c,e[9]=u):u=e[9];let d;e[10]!==n.description?(d=n.description&&p.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[10]=n.description,e[11]=d):d=e[11];let f;return e[12]!==u||e[13]!==d?(f=p.jsxs("div",{className:"border-b border-border p-5 shrink-0 flex flex-col gap-2",children:[u,d]}),e[12]=u,e[13]=d,e[14]=f):f=e[14],f}function RC(){const t=j.c(9),e=Ar(),{updateStep:n,startReplacingTool:r}=Oe(),s=we(),i=e&&"toolName"in e.action?e.action.toolName:null;let l;t[0]!==e||t[1]!==r||t[2]!==i||t[3]!==s||t[4]!==n?(l=()=>{if(e){if(s){hu.error("You cannot replace a tool while a workflow is executing.");return}i&&r(i),n(e.name,{action:{...e.action,toolName:""}})}},t[0]=e,t[1]=r,t[2]=i,t[3]=s,t[4]=n,t[5]=l):l=t[5];const a=l;let c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=p.jsx(Du,{size:14}),t[6]=c):c=t[6];let u;return t[7]!==a?(u=p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7",onClick:a,title:"Replace tool",children:c}),t[7]=a,t[8]=u):u=t[8],u}function ga(t){const e=j.c(13),n=Wn();let r;e[0]!==n?(r=n?new URL(`/mcp/gateway/${n}`,window.location.origin).href:"",e[0]=n,e[1]=r):r=e[1];const s=r,o=!!n;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=yl(i);let a;e[5]!==l.tools||e[6]!==t?(a=l.tools?.find(h=>h.name===t),e[5]=l.tools,e[6]=t,e[7]=a):a=e[7];const c=a,u=l.state==="connecting",d=l.state==="ready";let f;return e[8]!==l.error||e[9]!==u||e[10]!==d||e[11]!==c?(f={tool:c,isLoading:u,isReady:d,error:l.error},e[8]=l.error,e[9]=u,e[10]=d,e[11]=c,e[12]=f):f=e[12],f}function DC(t){const e=j.c(13),{step:n}=t,{updateStep:r}=Oe(),o="toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,i=we(),{tool:l}=ga(o??"");if(!l||!l.inputSchema)return null;let a;e[0]!==n.name||e[1]!==r?(a=x=>{r(n.name,{input:x})},e[0]=n.name,e[1]=r,e[2]=a):a=e[2];const c=a,u=i?"output":"input";let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=p.jsx(TC,{className:"px-5 py-5",children:p.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Input"})}),e[3]=d):d=e[3];const f=l.inputSchema,h=n.input;let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[4]=m):m=e[4];let g;e[5]!==c||e[6]!==n.name||e[7]!==f||e[8]!==h?(g=p.jsxs(EC,{value:"input",className:"border-b-0",children:[d,p.jsx(MC,{className:"px-5 pt-2",children:p.jsx(qh,{inputSchema:f,inputParams:h,setInputParams:c,mentions:m},n.name)})]}),e[5]=c,e[6]=n.name,e[7]=f,e[8]=h,e[9]=g):g=e[9];let y;return e[10]!==u||e[11]!==g?(y=p.jsx(NC,{type:"single",collapsible:!0,defaultValue:u,className:"border-b border-border shrink-0",children:g}),e[10]=u,e[11]=g,e[12]=y):y=e[12],y}function PC(t){const e=j.c(24),{step:n}=t,r=n.outputSchema,[s,o]=N.useState(!1),i=we(),{output:l,error:a}=x0(i,n.name);let c;e[0]!==a||e[1]!==l?(c=l||(a?{error:a}:null),e[0]=a,e[1]=l,e[2]=c):c=e[2];const u=c,d=r&&typeof r=="object"?r.properties:void 0;let f;e[3]!==d?(f=d?Object.entries(d):[],e[3]=d,e[4]=f):f=e[4];const h=f,m=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let g;e[5]!==m?(g=Z("flex flex-col border-b border-border",m),e[5]=m,e[6]=g):g=e[6];let y;e[7]!==s?(y=()=>o(!s),e[7]=s,e[8]=y):y=e[8];let x;e[9]===Symbol.for("react.memo_cache_sentinel")?(x=p.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=x):x=e[9];let b;e[10]!==s?(b=p.jsxs("div",{className:"flex items-center justify-between",children:[x,s?p.jsx(Su,{size:14,className:"text-muted-foreground"}):p.jsx(wu,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=b):b=e[11];let k;e[12]!==y||e[13]!==b?(k=p.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:y,children:b}),e[12]=y,e[13]=b,e[14]=k):k=e[14];let S;e[15]!==u||e[16]!==s||e[17]!==h||e[18]!==i?(S=s&&p.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i?p.jsx(go,{code:JSON.stringify(u,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&h.map(LC)]}),e[15]=u,e[16]=s,e[17]=h,e[18]=i,e[19]=S):S=e[19];let v;return e[20]!==g||e[21]!==k||e[22]!==S?(v=p.jsxs("div",{className:g,children:[k,S]}),e[20]=g,e[21]=k,e[22]=S,e[23]=v):v=e[23],v}function LC(t){const[e,n]=t;return p.jsx(_C,{name:e,schema:n},e)}function $C(t){switch(t){case"string":return{Icon:Tu,color:"text-blue-500"};case"number":case"integer":return{Icon:Nu,color:"text-blue-500"};case"array":return{Icon:vu,color:"text-purple-500"};case"object":return{Icon:ku,color:"text-orange-500"};case"boolean":return{Icon:Eu,color:"text-pink-500"};case"null":return{Icon:ul,color:"text-gray-500"};default:return{Icon:Cu,color:"text-muted-foreground"}}}function _C(t){const e=j.c(28),{name:n,schema:r}=t,s=Ar(),o=r.type??"unknown";let i,l,a,c,u;if(e[0]!==o){const{Icon:S,color:v}=$C(o);u="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=S,l=14,a=Z(v),e[0]=o,e[1]=i,e[2]=l,e[3]=a,e[4]=c,e[5]=u}else i=e[1],l=e[2],a=e[3],c=e[4],u=e[5];let d;e[6]!==i||e[7]!==l||e[8]!==a?(d=p.jsx(i,{size:l,className:a}),e[6]=i,e[7]=l,e[8]=a,e[9]=d):d=e[9];let f;e[10]!==n?(f=p.jsx("span",{className:"text-sm font-medium text-foreground",children:n}),e[10]=n,e[11]=f):f=e[11];let h;e[12]!==c||e[13]!==d||e[14]!==f?(h=p.jsxs("div",{className:c,children:[d,f]}),e[12]=c,e[13]=d,e[14]=f,e[15]=h):h=e[15];let m;e[16]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(Iu,{size:14,className:"opacity-50"}),e[16]=m):m=e[16];const g=s?.name;let y;e[17]!==g?(y=p.jsxs("span",{className:"text-muted-foreground",children:[g,"."]}),e[17]=g,e[18]=y):y=e[18];let x;e[19]!==n?(x=p.jsx("div",{className:"bg-blue-500/10 text-blue-500 px-1 py-0.5 rounded",children:n}),e[19]=n,e[20]=x):x=e[20];let b;e[21]!==y||e[22]!==x?(b=p.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[m,y,x]}),e[21]=y,e[22]=x,e[23]=b):b=e[23];let k;return e[24]!==b||e[25]!==u||e[26]!==h?(k=p.jsxs("div",{className:u,children:[h,b]}),e[24]=b,e[25]=u,e[26]=h,e[27]=k):k=e[27],k}function zC(t){const e=j.c(29),{step:n}=t,{updateStep:r}=Oe(),s=we(),o="toolName"in n.action,i=o&&"toolName"in n.action?n.action.toolName:null,{tool:l}=ga(i??""),a=o&&"transformCode"in n.action?n.action.transformCode??null:null,c=!!a;let u;e[0]!==l?(u=()=>{if(!l?.outputSchema)return`interface Input {
165
- // Tool output schema not available
166
- }`;const M=l.outputSchema,E=M.properties;return E?`interface Input {
167
- ${Object.entries(E).map(D=>{const[_,B]=D,z=as(B),R=!M.required?.includes(_);return` ${_}${R?"?":""}: ${z};`}).join(`
168
- `)}
169
- }`:`interface Input {
170
- [key: string]: unknown;
171
- }`},e[0]=l,e[1]=u):u=e[1];const d=u;let f;e[2]!==d||e[3]!==n.action||e[4]!==n.name||e[5]!==r?(f=()=>{const E=`${d()}
172
-
173
- interface Output {
174
- // Define your output type here
175
- result: unknown;
176
- }
177
-
178
- export default async function(input: Input): Promise<Output> {
179
- // Transform the tool output
180
- return {
181
- result: input,
182
- };
183
- }`;r(n.name,{action:{...n.action,transformCode:E}})},e[2]=d,e[3]=n.action,e[4]=n.name,e[5]=r,e[6]=f):f=e[6];const h=f;let m;e[7]!==n.action||e[8]!==n.name||e[9]!==r?(m=()=>{r(n.name,{action:{...n.action,transformCode:void 0}})},e[7]=n.action,e[8]=n.name,e[9]=r,e[10]=m):m=e[10];const g=m;let y;e[11]!==n.action||e[12]!==n.name||e[13]!==r?(y=(M,E)=>{r(n.name,{action:{...n.action,transformCode:M},...E?{outputSchema:E}:{}})},e[11]=n.action,e[12]=n.name,e[13]=r,e[14]=y):y=e[14];const x=y;if("code"in n.action&&n.action.code)return null;if(!c){let M;e[15]===Symbol.for("react.memo_cache_sentinel")?(M=p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),p.jsx(ao,{size:14,className:"text-muted-foreground"})]}),e[15]=M):M=e[15];let E;return e[16]!==h?(E=p.jsx("div",{className:"border-b border-border p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:h,children:M}),e[16]=h,e[17]=E):E=e[17],E}let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),p.jsx(Mp,{size:14,className:"text-muted-foreground"})]}),e[18]=b):b=e[18];let k;e[19]!==g?(k=p.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:g,children:b}),e[19]=g,e[20]=k):k=e[20];const S=`transform-code-${n.name}-${s}`,v=s!==void 0;let C;e[21]!==x||e[22]!==S||e[23]!==v||e[24]!==a?(C=p.jsx("div",{className:"flex-1 min-h-0",children:p.jsx(go,{code:a,language:"typescript",readOnly:v,onSave:x,height:"100%"},S)}),e[21]=x,e[22]=S,e[23]=v,e[24]=a,e[25]=C):C=e[25];let w;return e[26]!==k||e[27]!==C?(w=p.jsxs("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden border-b border-border",children:[k,C]}),e[26]=k,e[27]=C,e[28]=w):w=e[28],w}function BC(t){const e=j.c(24),{step:n}=t,[r,s]=N.useState(!1),{updateStep:o}=Oe(),i="code"in n.action&&n.action.code?n.action.code:null,l=we();let a;e[0]!==n.action||e[1]!==n.name||e[2]!==o?(a=(b,k)=>{o(n.name,{action:{...n.action,code:b},...k?{outputSchema:k}:{}})},e[0]=n.action,e[1]=n.name,e[2]=o,e[3]=a):a=e[3];const c=a;if(!i)return null;const u=r?"flex-1 min-h-0 overflow-hidden":"shrink-0";let d;e[4]!==u?(d=Z("flex flex-col border-b border-border",u),e[4]=u,e[5]=d):d=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=p.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Step Code"}),e[8]=h):h=e[8];let m;e[9]!==r?(m=p.jsxs("div",{className:"flex items-center justify-between",children:[h,r?p.jsx(Su,{size:14,className:"text-muted-foreground"}):p.jsx(wu,{size:14,className:"text-muted-foreground"})]}),e[9]=r,e[10]=m):m=e[10];let g;e[11]!==f||e[12]!==m?(g=p.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:f,children:m}),e[11]=f,e[12]=m,e[13]=g):g=e[13];let y;e[14]!==i||e[15]!==c||e[16]!==r||e[17]!==n.name||e[18]!==l?(y=r&&p.jsx("div",{className:"flex-1 min-h-0",children:p.jsx(go,{onSave:(b,k)=>c(b,k),code:i,language:"typescript",height:"100%",readOnly:l!==void 0},`step-code-${n.name}-${l}`)}),e[14]=i,e[15]=c,e[16]=r,e[17]=n.name,e[18]=l,e[19]=y):y=e[19];let x;return e[20]!==d||e[21]!==g||e[22]!==y?(x=p.jsxs("div",{className:d,children:[g,y]}),e[20]=d,e[21]=g,e[22]=y,e[23]=x):x=e[23],x}function as(t){if(Array.isArray(t.type))return t.type.map(n=>as({...t,type:n})).join(" | ");switch(t.type){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return t.items?`${as(t.items)}[]`:"unknown[]";case"object":return t.properties?`{ ${Object.entries(t.properties).map(([r,s])=>{const o=as(s),i=!t.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function FC(t){switch(t){case"success":return p.jsxs(yn,{variant:"success",className:"gap-1",children:[p.jsx(hl,{size:11}),"Success"]});case"error":case"failed":return p.jsxs(yn,{variant:"destructive",className:"gap-1",children:[p.jsx(kl,{size:11}),"Error"]});case"running":return p.jsxs(yn,{variant:"secondary",className:"gap-1",children:[p.jsx(ts,{size:11}),"Running"]});case"enqueued":return p.jsxs(yn,{variant:"secondary",className:"gap-1",children:[p.jsx(ts,{size:11}),"On hold"]});case"cancelled":return p.jsxs(yn,{variant:"secondary",className:"gap-1",children:[p.jsx(bu,{size:11}),"Cancelled"]});default:return p.jsxs(yn,{variant:"secondary",className:"gap-1",children:[p.jsx(ts,{size:11}),t]})}}function VC(t){return`Run #${t.slice(-4).toUpperCase()}`}function HC(t){const e=j.c(21),{className:n}=t,{executions:r,isLoading:s}=b0(),{setShowExecutionsList:o}=wl(),{setTrackingExecutionId:i}=Oe(),l=we();let a;e[0]!==i?(a=k=>{i(k)},e[0]=i,e[1]=a):a=e[1];const c=a;let u;e[2]!==o?(u=()=>{o(!1)},e[2]=o,e[3]=u):u=e[3];const d=u;let f;e[4]!==n?(f=Z("flex flex-col h-full bg-sidebar border-l border-border",n),e[4]=n,e[5]=f):f=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=p.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[6]=h):h=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=p.jsx(bu,{size:11}),e[7]=m):m=e[7];let g;e[8]!==d?(g=p.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[h,p.jsx(ue,{variant:"ghost",size:"icon",className:"size-7",onClick:d,children:m})]}),e[8]=d,e[9]=g):g=e[9];let y;e[10]!==r||e[11]!==c||e[12]!==s||e[13]!==l?(y=s?p.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):r.map((k,S)=>p.jsx(WC,{execution:k,isSelected:k.id===l,isFirst:S===0,onSelect:()=>c(k.id)},k.id)),e[10]=r,e[11]=c,e[12]=s,e[13]=l,e[14]=y):y=e[14];let x;e[15]!==y?(x=p.jsx("div",{className:"flex-1 overflow-auto",children:y}),e[15]=y,e[16]=x):x=e[16];let b;return e[17]!==f||e[18]!==g||e[19]!==x?(b=p.jsxs("div",{className:f,children:[g,x]}),e[17]=f,e[18]=g,e[19]=x,e[20]=b):b=e[20],b}function WC(t){const e=j.c(17),{execution:n,isSelected:r,isFirst:s,onSelect:o}=t,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=Z("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 u;e[4]!==n.status?(u=FC(n.status),e[4]=n.status,e[5]=u):u=e[5];let d;e[6]!==n.id?(d=VC(n.id),e[6]=n.id,e[7]=d):d=e[7];let f;e[8]!==d?(f=p.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:d}),e[8]=d,e[9]=f):f=e[9];let h;e[10]!==u||e[11]!==f?(h=p.jsxs("div",{className:"flex items-center gap-2 w-full",children:[u,f]}),e[10]=u,e[11]=f,e[12]=h):h=e[12];let m;return e[13]!==o||e[14]!==c||e[15]!==h?(m=p.jsx("div",{className:c,onClick:o,children:h}),e[13]=o,e[14]=c,e[15]=h,e[16]=m):m=e[16],m}function UC(t){const e=j.c(10),{itemId:n,mode:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},e[0]=s):s=e[0];const{connectionId:o}=_n(s),i=o??kt;let l;e[1]!==i?(l=nt(i),e[1]=i,e[2]=l):l=e[2];const a=l,c=r==="workflow"?"WORKFLOW":"WORKFLOW_EXECUTION",u=dl(i,c,n,a),d=oo(i,c,a);let f;e[3]!==d||e[4]!==n?(f=async y=>{await d.update.mutateAsync({id:n,data:y})},e[3]=d,e[4]=n,e[5]=f):f=e[5];const h=f,m=r==="execution"?n:void 0;let g;return e[6]!==u||e[7]!==m||e[8]!==h?(g={item:u,update:h,trackingExecutionId:m},e[6]=u,e[7]=m,e[8]=h,e[9]=g):g=e[9],g}function cp(t){const e=j.c(22),{itemId:n,onBack:r,mode:s}=t;let o;e[0]!==n||e[1]!==s?(o={itemId:n,mode:s},e[0]=n,e[1]=s,e[2]=o):o=e[2];const{item:i,update:l,trackingExecutionId:a}=UC(o);let c;e[3]!==i?(c=JSON.stringify(i),e[3]=i,e[4]=c):c=e[4];const u=c;if(!i){let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx("div",{className:"flex h-full w-full bg-background",children:p.jsx(Tr,{title:"Workflow not found",description:"This workflow may have been deleted or you may not have access to it."})}),e[5]=b):b=e[5];let k;return e[6]!==r?(k=p.jsx(On,{onBack:r,children:b}),e[6]=r,e[7]=k):k=e[7],k}const d=i.description??void 0;let f;e[8]!==i||e[9]!==d?(f={...i,description:d},e[8]=i,e[9]=d,e[10]=f):f=e[10];const h=f,m=s==="execution"?"action":"executions";let g;e[11]!==m||e[12]!==a||e[13]!==h?(g={workflow:h,trackingExecutionId:a,currentStepTab:m},e[11]=m,e[12]=a,e[13]=h,e[14]=g):g=e[14];let y;e[15]!==r||e[16]!==l?(y=p.jsx(GC,{onBack:r,onUpdate:l}),e[15]=r,e[16]=l,e[17]=y):y=e[17];let x;return e[18]!==u||e[19]!==g||e[20]!==y?(x=p.jsx(Jg,{initialState:g,children:y},u),e[18]=u,e[19]=g,e[20]=y,e[21]=x):x=e[21],x}function qC(t){const e=j.c(2);let n;return e[0]!==t?(n=p.jsx(cp,{...t,mode:"workflow"}),e[0]=t,e[1]=n):n=e[1],n}function KC(t){const e=j.c(18),{workflow:n,onUpdate:r}=t,{setWorkflow:s}=Oe();let o,i,l,a;if(e[0]!==n.description||e[1]!==n.id||e[2]!==n.steps||e[3]!==n.title){const d={title:n.title,description:n.description,steps:n.steps};o=go,i=`workflow-${n.id}`,l="100%",a=JSON.stringify(d,null,2),e[0]=n.description,e[1]=n.id,e[2]=n.steps,e[3]=n.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]!==n?(c=d=>{const f=JSON.parse(d);s({...n,...f}),r(f)},e[8]=r,e[9]=s,e[10]=n,e[11]=c):c=e[11];let u;return e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==a||e[16]!==c?(u=p.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]=u):u=e[17],u}function JC(){const t=j.c(12),{setTrackingExecutionId:e}=Oe(),n=we();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=p.jsx("div",{className:"flex items-center justify-center h-full w-12",children:p.jsx(Op,{className:"w-4 h-4 text-muted-foreground"})}),t[0]=r):r=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=p.jsx("strong",{className:"text-base text-foreground",children:"Run"}),t[1]=s):s=t[1];let o;t[2]!==n?(o=p.jsxs("div",{className:"flex items-center h-full",children:[r,p.jsxs("p",{className:"flex gap-3 items-center h-full",children:[s,p.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",n]})]})]}),t[2]=n,t[3]=o):o=t[3];let i;t[4]!==e?(i=()=>e(void 0),t[4]=e,t[5]=i):i=t[5];let l;t[6]===Symbol.for("react.memo_cache_sentinel")?(l=p.jsx(ul,{className:"w-4 h-4 text-muted-foreground"}),t[6]=l):l=t[6];let a;t[7]!==i?(a=p.jsx(ue,{variant:"ghost",size:"xs",onClick:i,children:l}),t[7]=i,t[8]=a):a=t[8];let c;return t[9]!==o||t[10]!==a?(c=p.jsxs("div",{className:"h-10 bg-accent flex items-center justify-between border-b border-border",children:[o,a]}),t[9]=o,t[10]=a,t[11]=c):c=t[11],c}function GC(t){const e=j.c(24),{onBack:n,onUpdate:r}=t,s=Hn(),o=we(),{setOriginalWorkflow:i}=Oe(),{viewMode:l,showExecutionsList:a}=wl(),c=Ar();let u;e[0]!==r||e[1]!==i||e[2]!==s?(u=async()=>{await r(s),i(s)},e[0]=r,e[1]=i,e[2]=s,e[3]=u):u=e[3];const d=u,f=c&&"toolName"in c.action,h=f?c.action.toolName:null,m=f&&!h&&!o,g=!m&&(c||o||!a);let y;e[4]!==d||e[5]!==s.description||e[6]!==s.title?(y=p.jsx(R2,{title:s.title,description:s.description,onSave:d}),e[4]=d,e[5]=s.description,e[6]=s.title,e[7]=y):y=e[7];let x;e[8]!==o?(x=o&&p.jsx(JC,{}),e[8]=o,e[9]=x):x=e[9];let b;e[10]!==r||e[11]!==a||e[12]!==g||e[13]!==m||e[14]!==l||e[15]!==s?(b=p.jsx("div",{className:"flex-1 overflow-hidden",children:l==="code"?p.jsx(KC,{workflow:s,onUpdate:r}):p.jsxs(zp,{direction:"horizontal",className:"flex w-full h-full",children:[p.jsx(xa,{defaultSize:50,minSize:30,children:p.jsx(X2,{})}),p.jsx(Bp,{}),p.jsxs(xa,{defaultSize:50,minSize:25,children:[m&&p.jsx(eC,{className:"border-l border-border"}),a&&p.jsx(HC,{}),g&&p.jsx(IC,{className:"border-l border-border"})]})]})}),e[10]=r,e[11]=a,e[12]=g,e[13]=m,e[14]=l,e[15]=s,e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x||e[19]!==b?(k=p.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[y,x,b]}),e[17]=y,e[18]=x,e[19]=b,e[20]=k):k=e[20];let S;return e[21]!==n||e[22]!==k?(S=p.jsx(On,{onBack:n,children:k}),e[21]=n,e[22]=k,e[23]=S):S=e[23],S}function YC(t){const e=j.c(2);let n;return e[0]!==t?(n=p.jsx(cp,{...t,mode:"execution"}),e[0]=t,e[1]=n):n=e[1],n}const XC={workflow:qC,workflow_execution:YC,assistant:kg,prompt:Tg};function QC(){const t=j.c(6),e=il();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},t[0]=n):n=t[0];const r=_n(n),s=decodeURIComponent(r.itemId);let o;t[1]!==e.history?(o=()=>{e.history.back()},t[1]=e.history,t[2]=o):o=t[2];const i=o,l=ZC;let a;return t[3]!==i||t[4]!==s?(a=p.jsx(Pg,{itemId:s,onBack:i,onUpdate:l}),t[3]=i,t[4]=s,t[5]=a):a=t[5],a}async function ZC(t){return Promise.resolve()}function eN(){const t=j.c(18),e=il();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},t[0]=n):n=t[0];const r=_n(n),s=r.connectionId,o=decodeURIComponent(r.collectionName),i=decodeURIComponent(r.itemId);let l;t[1]!==e.history?(l=()=>{e.history.back()},t[1]=e.history,t[2]=l):l=t[2];const a=l,c=s??kt;let u;t[3]!==c?(u=nt(c),t[3]=c,t[4]=u):u=t[4];const f=oo(c,o,u);let h;t[5]!==f||t[6]!==i?(h=async S=>{i&&await f.update.mutateAsync({id:i,data:S})},t[5]=f,t[6]=i,t[7]=h):h=t[7];const m=h;let g;t[8]!==o?(g=o?.toLowerCase(),t[8]=o,t[9]=g):g=t[9];const y=g,x=y&&XC[y];if(x){let S;return t[10]!==x||t[11]!==a||t[12]!==m||t[13]!==i?(S=p.jsx(x,{itemId:i,onBack:a,onUpdate:m}),t[10]=x,t[11]=a,t[12]=m,t[13]=i,t[14]=S):S=t[14],S}let b;t[15]===Symbol.for("react.memo_cache_sentinel")?(b=p.jsx(Ip,{size:36,className:"text-muted-foreground"}),t[15]=b):b=t[15];let k;return t[16]!==a?(k=p.jsx(im,{icon:b,title:"No component defined",description:"No component for this collection was defined",buttonProps:{onClick:a,children:"Go back"}}),t[16]=a,t[17]=k):k=t[17],k}function tN(){const t=j.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={from:"/shell/$org/mcps/$connectionId/$collectionName/$itemId"},t[0]=e):e=t[0];const n=_n(e);if(decodeURIComponent(n.collectionName)==="tools"){let i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=p.jsx(QC,{}),t[1]=i):i=t[1],i}let o;return t[2]===Symbol.for("react.memo_cache_sentinel")?(o=p.jsx(eN,{}),t[2]=o):o=t[2],o}function uE(){const t=j.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=p.jsx(pr,{children:p.jsx(N.Suspense,{fallback:p.jsx("div",{className:"flex h-full items-center justify-center",children:p.jsx(nn,{size:32,className:"animate-spin text-muted-foreground"})}),children:p.jsx(tN,{})})}),t[0]=e):e=t[0],e}export{uE as default};