@decocms/mesh 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/client/assets/{AlertCircle-CoA9j9_b.js → AlertCircle-BrGqb-qb.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-Bu1JR7vY.js → ArrowLeft-B6h573ak.js} +1 -1
  3. package/dist/client/assets/{ChevronDown-BmUd-Gap.js → ChevronDown-BuogCeI0.js} +1 -1
  4. package/dist/client/assets/{Clock-BGOqsAv_.js → Clock-LzAlJ-1R.js} +1 -1
  5. package/dist/client/assets/{Code01-C4I9q0rm.js → Code01-Wll8WS4F.js} +1 -1
  6. package/dist/client/assets/{Copy01-D_YhbDiF.js → Copy01-_s71W2Ph.js} +1 -1
  7. package/dist/client/assets/{CpuChip02-BkDt7iNK.js → CpuChip02-BwTl0fBj.js} +1 -1
  8. package/dist/client/assets/{DotsVertical-CxdZClGh.js → DotsVertical-BQk5hPxb.js} +1 -1
  9. package/dist/client/assets/{File06-BdMasDPT.js → File06-CpSSTggW.js} +1 -1
  10. package/dist/client/assets/{FlipBackward-B34yEzR2.js → FlipBackward-C0O2fx27.js} +1 -1
  11. package/dist/client/assets/{GitBranch01-D2Rua42v.js → GitBranch01-DjmPf135.js} +1 -1
  12. package/dist/client/assets/{Grid01-Bom2qqwm.js → Grid01-CmB5R6oU.js} +1 -1
  13. package/dist/client/assets/{Inbox01-Arx8J2Oq.js → Inbox01-Ct-8Lwpv.js} +1 -1
  14. package/dist/client/assets/{InfoCircle-BYXT4R1l.js → InfoCircle-D6JXYJn_.js} +1 -1
  15. package/dist/client/assets/{Key01-D0WGLaST.js → Key01-ZVAVplBN.js} +1 -1
  16. package/dist/client/assets/{LinkExternal01-LVkx-wZF.js → LinkExternal01-DfHTXuZ9.js} +1 -1
  17. package/dist/client/assets/{Loading01-Dw6V1r3u.js → Loading01-0wYmSKV6.js} +1 -1
  18. package/dist/client/assets/{Lock01-Dw2P1WZh.js → Lock01-D5nrmOSx.js} +1 -1
  19. package/dist/client/assets/{Play-BRRssd_q.js → Play-BedrzKsi.js} +1 -1
  20. package/dist/client/assets/{Plus-CQSfshmp.js → Plus-DofiSAMU.js} +1 -1
  21. package/dist/client/assets/{SearchMd-CGUWNVUr.js → SearchMd-D70t5LVP.js} +1 -1
  22. package/dist/client/assets/{Terminal-CIo_ltVk.js → Terminal-CStBCUAd.js} +1 -1
  23. package/dist/client/assets/{Trash01-BgGiU9JZ.js → Trash01-DnTS63e5.js} +1 -1
  24. package/dist/client/assets/{X-CsW5kmRT.js → X-DeVUfdHG.js} +1 -1
  25. package/dist/client/assets/{XClose-D2IdV8gs.js → XClose-5A0s2w1d.js} +1 -1
  26. package/dist/client/assets/{alert-dialog-rSIOP2OM.js → alert-dialog-BU8uTWb8.js} +1 -1
  27. package/dist/client/assets/{auth-D6vm_lfk.js → auth-DpA5_jth.js} +1 -1
  28. package/dist/client/assets/{auth-catchall-lDj0BXu4.js → auth-catchall-2WBu6I6H.js} +1 -1
  29. package/dist/client/assets/{avatar-C45Lgbwv.js → avatar-KDpJ2jsd.js} +1 -1
  30. package/dist/client/assets/{badge-Z-ujar-h.js → badge-CStgouQf.js} +1 -1
  31. package/dist/client/assets/{button-DMnSM5FV.js → button-IijH0wdI.js} +1 -1
  32. package/dist/client/assets/{card-DL_e-uTF.js → card-BnWpolEI.js} +1 -1
  33. package/dist/client/assets/{checkbox-SCLb_n1h.js → checkbox-BYeNlYdH.js} +1 -1
  34. package/dist/client/assets/collection-detail-DnxFiEu9.js +165 -0
  35. package/dist/client/assets/{collection-display-button-BbSV76WH.js → collection-display-button-2ZQ5sQTW.js} +1 -1
  36. package/dist/client/assets/{collection-header-CqO1LmKH.js → collection-header-DBUE7n6H.js} +1 -1
  37. package/dist/client/assets/{collection-page-DDVR6yeu.js → collection-page-BHk1uJKe.js} +1 -1
  38. package/dist/client/assets/{collection-search-BOBOP2ro.js → collection-search-CM9rltH6.js} +1 -1
  39. package/dist/client/assets/{collection-tab-CNlP707v.js → collection-tab-ClOnLgHC.js} +1 -1
  40. package/dist/client/assets/{collection-table-wrapper-ByX0J-nn.js → collection-table-wrapper-BRI7T6RJ.js} +1 -1
  41. package/dist/client/assets/{connection-card-CZFyOgeO.js → connection-card-DMv3uM_n.js} +1 -1
  42. package/dist/client/assets/{connection-detail-oL5IGO2h.js → connection-detail-Cs5NpuH7.js} +1 -1
  43. package/dist/client/assets/{connections-BKlzJU2y.js → connections-DSbytdP0.js} +1 -1
  44. package/dist/client/assets/constants-TKUQnnwA.js +1 -0
  45. package/dist/client/assets/{create-organization-dialog-lmQ3mepV.js → create-organization-dialog-DbNHSUuq.js} +1 -1
  46. package/dist/client/assets/{dialog-B1fXXmBI.js → dialog-CJsBFVDy.js} +1 -1
  47. package/dist/client/assets/{dropdown-menu-gRHakuHp.js → dropdown-menu-BvLCKekW.js} +1 -1
  48. package/dist/client/assets/{empty-state-BiqF__Lu.js → empty-state-Bg-FRZa4.js} +1 -1
  49. package/dist/client/assets/{env-vars-editor-Br0Q2jee.js → env-vars-editor-Z7SwcUr8.js} +1 -1
  50. package/dist/client/assets/{error-boundary-CUq8HVcH.js → error-boundary-CsEoagci.js} +1 -1
  51. package/dist/client/assets/{extract-connection-data-DsJuSGHU.js → extract-connection-data-BgA1QcA6.js} +1 -1
  52. package/dist/client/assets/{form-BbwJs-Od.js → form-BjarY-Jq.js} +1 -1
  53. package/dist/client/assets/{formatDistanceToNow-jHI_IOun.js → formatDistanceToNow-fhdySMxO.js} +1 -1
  54. package/dist/client/assets/gateway-detail-DeFxNps5.js +1 -0
  55. package/dist/client/assets/{gateways-BfCNNBIO.js → gateways-CXlSFkKr.js} +1 -1
  56. package/dist/client/assets/{home-oGaB9rtf.js → home-BXCs6vTQ.js} +1 -1
  57. package/dist/client/assets/index-9pHY4m3c.css +1 -0
  58. package/dist/client/assets/{index-B1eBXzBF.js → index-BGEzzv-W.js} +1 -1
  59. package/dist/client/assets/{index-BVHhSH8M.js → index-BLgTJ8o3.js} +2 -2
  60. package/dist/client/assets/{index-BbK2Byrj.js → index-B_OB0BCO.js} +1 -1
  61. package/dist/client/assets/{index-BMIizA12.js → index-CRGUNI2v.js} +1 -1
  62. package/dist/client/assets/{input-C6vwKKeq.js → input-BxywPo2X.js} +1 -1
  63. package/dist/client/assets/{layout-m8iq6RWE.js → layout-Dfp1nH3g.js} +1 -1
  64. package/dist/client/assets/lazy-highlighter-DYlTa9LA.js +9 -0
  65. package/dist/client/assets/{localstorage-keys-BB9xpX5T.js → localstorage-keys-Bj9V9Nbd.js} +1 -1
  66. package/dist/client/assets/{login-CevUioqo.js → login-BfaeBzql.js} +1 -1
  67. package/dist/client/assets/{mcp-oauth-CE6Gg3ul.js → mcp-oauth-Vd_yzV5S.js} +1 -1
  68. package/dist/client/assets/{members-CAJLI1Ui.js → members-fIe1QSNh.js} +1 -1
  69. package/dist/client/assets/monaco-editor-mQfzbJMr.js +19 -0
  70. package/dist/client/assets/monitoring-I1RqzeAN.js +4 -0
  71. package/dist/client/assets/{oauth-callback-DnSysdpG.js → oauth-callback-Cwog6Jzh.js} +1 -1
  72. package/dist/client/assets/{page-jzi_ERcf.js → page-BVptnX4j.js} +2 -2
  73. package/dist/client/assets/{pin-to-sidebar-button-DonhySMf.js → pin-to-sidebar-button-C8t5xznu.js} +1 -1
  74. package/dist/client/assets/{popover-BO5GT9tA.js → popover-CwHNob2q.js} +1 -1
  75. package/dist/client/assets/{resizable-DpISfhV6.js → resizable-DybyPt6-.js} +1 -1
  76. package/dist/client/assets/{resource-tabs-JMDBPJhv.js → resource-tabs-s0IiCCzU.js} +1 -1
  77. package/dist/client/assets/{responsive-select-BZGantuu.js → responsive-select-INSf3elv.js} +1 -1
  78. package/dist/client/assets/{select-mD7lFwRj.js → select-C0rvNlZx.js} +1 -1
  79. package/dist/client/assets/{settings-iXHGs-4V.js → settings-3Or8ShnF.js} +1 -1
  80. package/dist/client/assets/{shell-layout-C1VOF_px.js → shell-layout-4x0MHQQc.js} +1 -1
  81. package/dist/client/assets/{spinner-D7to-RHc.js → spinner-D7ZAVJCR.js} +1 -1
  82. package/dist/client/assets/{store-C7bepdKu.js → store-Bl_0XUq8.js} +1 -1
  83. package/dist/client/assets/{store-app-detail-dqrfmC2K.js → store-app-detail--3qLKygc.js} +1 -1
  84. package/dist/client/assets/{switch-CpJO-7Kf.js → switch-D37mVt_9.js} +1 -1
  85. package/dist/client/assets/{textarea-Dma5FaAA.js → textarea-DNeEC-Sl.js} +1 -1
  86. package/dist/client/assets/{thread-history-popover-DTmh-wTW.js → thread-history-popover-CykPOF9f.js} +14 -14
  87. package/dist/client/assets/{tools-list-DJTZFgWM.js → tools-list-CFmwpEf4.js} +1 -1
  88. package/dist/client/assets/{tooltip-DiQ9SlNX.js → tooltip-CSuczTFq.js} +1 -1
  89. package/dist/client/assets/{types-Bq0bBlbx.js → types-CJK7iTsI.js} +2 -2
  90. package/dist/client/assets/{use-binding-DQTEUjPl.js → use-binding-C5e_Y70M.js} +1 -1
  91. package/dist/client/assets/{use-connection-DUMeVexv.js → use-connection-CsPrFY0x.js} +1 -1
  92. package/dist/client/assets/{use-connection-resources-GqC2zg91.js → use-connection-resources-CjjFKWSM.js} +1 -1
  93. package/dist/client/assets/{use-gateway-pQG4iSzq.js → use-gateway-Bz_y7oh7.js} +1 -1
  94. package/dist/client/assets/{use-list-state-DKjekACN.js → use-list-state-B13SO1z3.js} +1 -1
  95. package/dist/client/assets/{use-mcp-CaAgRxkf.js → use-mcp-CPBDJGOj.js} +1 -1
  96. package/dist/client/assets/{use-members-Cxbw-nUt.js → use-members-b3tDRslY.js} +1 -1
  97. package/dist/client/assets/{use-mobile-C2teUdDI.js → use-mobile-VYFif8jU.js} +1 -1
  98. package/dist/client/assets/{use-organization-settings-B-bw0Nsb.js → use-organization-settings-i4aS_Egu.js} +1 -1
  99. package/dist/client/assets/{use-tool-call-BwHyofVZ.js → use-tool-call-BdbJ3oy8.js} +1 -1
  100. package/dist/client/assets/useQuery-DXchCtgN.js +1 -0
  101. package/dist/client/assets/{useSuspenseInfiniteQuery-WWHYgeeq.js → useSuspenseInfiniteQuery-BLpBJxLd.js} +1 -1
  102. package/dist/client/assets/{view-mode-toggle-DCDdw_zu.js → view-mode-toggle-BXo-WMnB.js} +1 -1
  103. package/dist/client/assets/{workflow-nViVDMOR.js → workflow-wGJTSVc-.js} +1 -1
  104. package/dist/client/index.html +2 -2
  105. package/package.json +1 -3
  106. package/dist/client/assets/collection-detail-DZRR92ph.js +0 -183
  107. package/dist/client/assets/constants-C4MXZrmv.js +0 -1
  108. package/dist/client/assets/core-D9xILP6l.js +0 -6
  109. package/dist/client/assets/gateway-detail-CvVf3uBW.js +0 -1
  110. package/dist/client/assets/index-B3GsxHkT.css +0 -1
  111. package/dist/client/assets/json-BESjz4hO.js +0 -1
  112. package/dist/client/assets/json-GXJs871j.js +0 -1
  113. package/dist/client/assets/json-syntax-highlighter-C3W2DACo.js +0 -2
  114. package/dist/client/assets/lazy-highlighter-C7qLCeM-.js +0 -4
  115. package/dist/client/assets/monitoring-_9gwma-O.js +0 -4
  116. package/dist/client/assets/prism-light-WCI-7yyK.js +0 -1
  117. package/dist/client/assets/useQuery-C3iXPPho.js +0 -1
@@ -1,183 +0,0 @@
1
- import{aj as Qe,r as E,v as np,w as Eo,c as R,j as m,g as qi,y as rp,i as sp,d as xr,b as op,t as ru,F as X,Q as ip,ak as No,al as su,a5 as lp,a4 as ap,am as cp,H as Ui,an as ou,ao as up,B as Rn,E as He,$ as Ki,ap as dp,z as qs,aq as fp,Z as Ji,ar as hp,as as pp,at as mp,au as Gi,av as gp,aw as iu,a1 as yp,ax as xp,L as bp,ay as kp,az as wp,af as lu}from"./index-BVHhSH8M.js";import{U as Sn,f as au,d as Xi,c as Ze,b as Yi,I as Us,u as vp,n as Sp}from"./use-connection-DUMeVexv.js";import{E as Qi}from"./SearchMd-CGUWNVUr.js";import{E as cu}from"./error-boundary-CUq8HVcH.js";import{P as Zi}from"./pin-to-sidebar-button-DonhySMf.js";import{B as me,c as Y}from"./button-DMnSM5FV.js";import{F as To,a as Cp,b as el,d as tl}from"./form-BbwJs-Od.js";import{I as nl}from"./input-C6vwKKeq.js";import{T as ui}from"./textarea-Dma5FaAA.js";import{b as $t,T as _t,a as zt,c as Bt,i as rl,d as Ep}from"./tooltip-DiQ9SlNX.js";import{i as uu}from"./FlipBackward-B34yEzR2.js";import{a as du,V as sl,b as Ks}from"./layout-m8iq6RWE.js";import{i as Np}from"./AlertCircle-CoA9j9_b.js";import{s as Tp}from"./Clock-BGOqsAv_.js";import{i as Mp,n as Op}from"./Code01-C4I9q0rm.js";import{a as Ap}from"./Copy01-D_YhbDiF.js";import{i as or}from"./Loading01-Dw6V1r3u.js";import{i as ol}from"./Play-BRRssd_q.js";import{s as il,i as Ip}from"./XClose-D2IdV8gs.js";import{u as Rp,O as jp,M as Dp,F as Pp,v as Lp}from"./index-BMIizA12.js";import{u as ll}from"./use-mcp-CaAgRxkf.js";import{J as $p}from"./json-syntax-highlighter-C3W2DACo.js";import{E as _p}from"./empty-state-BiqF__Lu.js";import{D as zp,u as Bp}from"./use-binding-DQTEUjPl.js";import{u as Fp}from"./use-gateway-pQG4iSzq.js";import{S as jn}from"./spinner-D7to-RHc.js";import{G as Vp,b as Hp,R as ca,a as Wp}from"./resizable-DpISfhV6.js";import{V as qp}from"./view-mode-toggle-DCDdw_zu.js";import{i as Up}from"./GitBranch01-D2Rua42v.js";import{i as Kp}from"./responsive-select-BZGantuu.js";import{a as al,b as cl}from"./use-tool-call-BwHyofVZ.js";import{D as Jp,a as Gp,b as Xp,f as Yp,c as Qp,d as Zp}from"./dialog-B1fXXmBI.js";import"./index-B1eBXzBF.js";import{s as ul}from"./Plus-CQSfshmp.js";import{b as em,D as tm,a as nm,c as ua}from"./dropdown-menu-gRHakuHp.js";import{B as dn}from"./badge-Z-ujar-h.js";import{i as fu}from"./X-CsW5kmRT.js";import"./use-organization-settings-B-bw0Nsb.js";import"./ArrowLeft-Bu1JR7vY.js";import"./mcp-oauth-CE6Gg3ul.js";import"./auth-D6vm_lfk.js";import"./env-vars-editor-Br0Q2jee.js";import"./Trash01-BgGiU9JZ.js";import"./File06-BdMasDPT.js";import"./Key01-D0WGLaST.js";import"./select-mD7lFwRj.js";import"./ChevronDown-BmUd-Gap.js";import"./Terminal-CIo_ltVk.js";import"./CpuChip02-BkDt7iNK.js";import"./formatDistanceToNow-jHI_IOun.js";import"./constants-C4MXZrmv.js";import"./registry-utils-ulDDT0d8.js";import"./extract-connection-data-DsJuSGHU.js";import"./generate-id-Dyweu44Y.js";import"./index-BbK2Byrj.js";import"./useQuery-C3iXPPho.js";import"./use-mobile-C2teUdDI.js";const hu=Qe("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 pu=Qe("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 mu=Qe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const gu=Qe("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);const rm=Qe("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);const sm=Qe("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 yu=Qe("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 xu=Qe("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 bu=Qe("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 ku=Qe("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"}]]),dl=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));dl.displayName="AlertOctagon";const wu=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));wu.displayName="Box";const vu=({size:t=24,color:e="currentColor",...n})=>E.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},E.createElement("path",{d:"m22.7 11.5-2 2-2-2m2.245 1.5A9 9 0 1 0 19 17.657M12 7v5l3 2"}));vu.displayName="ClockFastForward";const Su=({size:t=24,color:e="currentColor",...n})=>E.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},E.createElement("path",{d:"m17 17 5-5-5-5M7 7l-5 5 5 5m7-14-4 18"}));Su.displayName="Code02";const Wr=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));Wr.displayName="Columns01";const Cu=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));Cu.displayName="CornerDownRight";const Eu=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));Eu.displayName="Database01";const Nu=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));Nu.displayName="Repeat03";const fl=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));fl.displayName="Save02";const Tu=({size:t=24,color:e="currentColor",...n})=>E.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},E.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"}));Tu.displayName="Tool01";const{getOwnPropertyNames:om,getOwnPropertySymbols:im}=Object,{hasOwnProperty:lm}=Object.prototype;function Mo(t,e){return function(r,s,o){return t(r,s,o)&&e(r,s,o)}}function Mr(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 am(t){return t?.[Symbol.toStringTag]}function da(t){return om(t).concat(im(t))}const cm=Object.hasOwn||((t,e)=>lm.call(t,e));function Yt(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const um="__v",dm="__o",fm="_owner",{getOwnPropertyDescriptor:fa,keys:ha}=Object;function hm(t,e){return t.byteLength===e.byteLength&&Yr(new Uint8Array(t),new Uint8Array(e))}function pm(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 mm(t,e){return t.byteLength===e.byteLength&&Yr(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function gm(t,e){return Yt(t.getTime(),e.getTime())}function ym(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function xm(t,e){return t===e}function pa(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 bm=Yt;function km(t,e,n){const r=ha(t);let s=r.length;if(ha(e).length!==s)return!1;for(;s-- >0;)if(!Mu(t,e,n,r[s]))return!1;return!0}function Bn(t,e,n){const r=da(t);let s=r.length;if(da(e).length!==s)return!1;let o,i,l;for(;s-- >0;)if(o=r[s],!Mu(t,e,n,o)||(i=fa(t,o),l=fa(e,o),(i||l)&&(!i||!l||i.configurable!==l.configurable||i.enumerable!==l.enumerable||i.writable!==l.writable)))return!1;return!0}function wm(t,e){return Yt(t.valueOf(),e.valueOf())}function vm(t,e){return t.source===e.source&&t.flags===e.flags}function ma(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 Yr(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 Sm(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 Mu(t,e,n,r){return(r===fm||r===dm||r===um)&&(t.$$typeof||e.$$typeof)?!0:cm(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const Cm="[object ArrayBuffer]",Em="[object Arguments]",Nm="[object Boolean]",Tm="[object DataView]",Mm="[object Date]",Om="[object Error]",Am="[object Map]",Im="[object Number]",Rm="[object Object]",jm="[object RegExp]",Dm="[object Set]",Pm="[object String]",Lm={"[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},$m="[object URL]",_m=Object.prototype.toString;function zm({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:p}){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 C=y.constructor;if(C!==x.constructor)return!1;if(C===Object)return a(y,x,b);if(Array.isArray(y))return e(y,x,b);if(C===Date)return r(y,x,b);if(C===RegExp)return u(y,x,b);if(C===Map)return i(y,x,b);if(C===Set)return d(y,x,b);const w=_m.call(y);if(w===Mm)return r(y,x,b);if(w===jm)return u(y,x,b);if(w===Am)return i(y,x,b);if(w===Dm)return d(y,x,b);if(w===Rm)return typeof y.then!="function"&&typeof x.then!="function"&&a(y,x,b);if(w===$m)return h(y,x,b);if(w===Om)return s(y,x,b);if(w===Em)return a(y,x,b);if(Lm[w])return f(y,x,b);if(w===Cm)return t(y,x,b);if(w===Tm)return n(y,x,b);if(w===Nm||w===Im||w===Pm)return c(y,x,b);if(p){let S=p[w];if(!S){const v=am(y);v&&(S=p[v])}if(S)return S(y,x,b)}return!1}}function Bm({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:hm,areArraysEqual:n?Bn:pm,areDataViewsEqual:mm,areDatesEqual:gm,areErrorsEqual:ym,areFunctionsEqual:xm,areMapsEqual:n?Mo(pa,Bn):pa,areNumbersEqual:bm,areObjectsEqual:n?Bn:km,arePrimitiveWrappersEqual:wm,areRegExpsEqual:vm,areSetsEqual:n?Mo(ma,Bn):ma,areTypedArraysEqual:n?Mo(Yr,Bn):Yr,areUrlsEqual:Sm,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Mr(r.areArraysEqual),o=Mr(r.areMapsEqual),i=Mr(r.areObjectsEqual),l=Mr(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:o,areObjectsEqual:i,areSetsEqual:l})}return r}function Fm(t){return function(e,n,r,s,o,i,l){return t(e,n,l)}}function Vm({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 Hm=Mt();Mt({strict:!0});Mt({circular:!0});Mt({circular:!0,strict:!0});Mt({createInternalComparator:()=>Yt});Mt({strict:!0,createInternalComparator:()=>Yt});Mt({circular:!0,createInternalComparator:()=>Yt});Mt({circular:!0,createInternalComparator:()=>Yt,strict:!0});function Mt(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,o=Bm(t),i=zm(o),l=n?n(i):Fm(i);return Vm({circular:e,comparator:i,createState:r,equals:l,strict:s})}np({title:Eo().min(1),description:Eo().nullable(),body:Eo()});function Oo(t){for(const e of t.messages??[])if(e.role==="user"&&e.content?.type==="text")return e.content.text??"";return""}function Wm(){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 qm(t){const e=R.c(13),{form:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Details"}),e[0]=r):r=e[0];let s;e[1]!==n.control?(s=m.jsxs("div",{className:"flex flex-col gap-4",children:[r,m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.jsx(To,{control:n.control,name:"title",render:Jm}),m.jsx(To,{control:n.control,name:"description",render:Km})]})]}),e[1]=n.control,e[2]=s):s=e[2];let o,i;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx("div",{className:"text-sm font-medium text-foreground",children:"Message"}),i=m.jsx("div",{className:"text-xs text-muted-foreground",children:"This becomes the user message in the prompt."}),e[3]=o,e[4]=i):(o=e[3],i=e[4]);let l;e[5]!==n.control?(l=m.jsxs("div",{className:"flex flex-col gap-2",children:[o,i,m.jsx(To,{control:n.control,name:"body",render:Um})]}),e[5]=n.control,e[6]=l):l=e[6];let a;e[7]!==s||e[8]!==l?(a=m.jsxs("div",{className:"h-full py-6 flex flex-col max-w-3xl mx-auto w-full min-w-0 gap-8 overflow-y-auto px-4",children:[s,l]}),e[7]=s,e[8]=l,e[9]=a):a=e[9];let c;return e[10]!==n||e[11]!==a?(c=m.jsx(Cp,{...n,children:a}),e[10]=n,e[11]=a,e[12]=c):c=e[12],c}function Um(t){const{field:e}=t;return m.jsx(el,{children:m.jsx(tl,{children:m.jsx(ui,{...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 Km(t){const{field:e}=t;return m.jsxs(el,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Description"}),m.jsx(tl,{children:m.jsx(nl,{...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 Jm(t){const{field:e}=t;return m.jsxs(el,{children:[m.jsx("div",{className:"text-xs text-muted-foreground",children:"Title"}),m.jsx(tl,{children:m.jsx(nl,{...e,placeholder:"Untitled prompt",className:"h-9 rounded-lg border border-border bg-muted/20 shadow-none focus-visible:ring-0"})})]})}function Gm(t){const e=R.c(51),{providerId:n,promptId:r,onBack:s}=t,i=qi().location.href,l=n||Sn;let a;e[0]!==l?(a=Ze(l),e[0]=l,e[1]=a):a=e[1];const c=a,u=au(n,"PROMPT",r,c),d=Xi(n,"PROMPT",c),f=d.update.isPending;let h;e[2]!==u?(h=u?{title:u.title,description:u.description??null,body:Oo(u)}:void 0,e[2]=u,e[3]=h):h=e[3];let p;e[4]!==h?(p={values:h},e[4]=h,e[5]=p):p=e[5];const g=rp(p);let y;e[6]!==g||e[7]!==u?(y=()=>{u&&g.reset({title:u.title,description:u.description??null,body:Oo(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 K=>{const ie=await d.update.mutateAsync({id:r,data:{title:K.title,description:K.description,arguments:[],icons:[],messages:[{role:"user",content:{type:"text",text:K.body}}]}});g.reset({title:ie.title,description:ie.description??null,body:Oo(ie)})}),e[9]=d.update,e[10]=g,e[11]=r,e[12]=b):b=e[12];const k=b;if(!u){let K;return e[13]===Symbol.for("react.memo_cache_sentinel")?(K=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(Qi,{title:"Prompt not found",description:"This prompt may have been deleted or you may not have access to it."})}),e[13]=K):K=e[13],K}let C;e[14]!==u.title?(C=m.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:u.title}),e[14]=u.title,e[15]=C):C=e[15];let w;e[16]!==u.description?(w=u.description?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:u.description})]}):null,e[16]=u.description,e[17]=w):w=e[17];let S;e[18]!==C||e[19]!==w?(S=m.jsx(du,{children:m.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[C,w]})}),e[18]=C,e[19]=w,e[20]=S):S=e[20];let v;e[21]!==u.title||e[22]!==i?(v=m.jsx(Zi,{title:u.title,url:i,icon:"description"}),e[21]=u.title,e[22]=i,e[23]=v):v=e[23];const M=!g.formState.isDirty||f;let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=m.jsx(uu,{size:14}),e[24]=T):T=e[24];let I;e[25]!==x||e[26]!==M?(I=m.jsx($t,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:M,onClick:x,"aria-label":"Cancel",children:T})})}),e[25]=x,e[26]=M,e[27]=I):I=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=m.jsx(_t,{side:"bottom",children:"Cancel"}),e[28]=D):D=e[28];let $;e[29]!==I?($=m.jsx(zt,{children:m.jsxs(Bt,{delayDuration:0,children:[I,D]})}),e[29]=I,e[30]=$):$=e[30];const V=!g.formState.isDirty||f;let F;e[31]!==k?(F=()=>{k()},e[31]=k,e[32]=F):F=e[32];let P;e[33]===Symbol.for("react.memo_cache_sentinel")?(P=m.jsx(fl,{size:14}),e[33]=P):P=e[33];let N;e[34]!==V||e[35]!==F?(N=m.jsx($t,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",disabled:V,onClick:F,"aria-label":"Save",children:P})})}),e[34]=V,e[35]=F,e[36]=N):N=e[36];let _;e[37]===Symbol.for("react.memo_cache_sentinel")?(_=m.jsx(_t,{side:"bottom",children:"Save"}),e[37]=_):_=e[37];let L;e[38]!==N?(L=m.jsx(zt,{children:m.jsxs(Bt,{delayDuration:0,children:[N,_]})}),e[38]=N,e[39]=L):L=e[39];let J;e[40]!==v||e[41]!==$||e[42]!==L?(J=m.jsxs(sl,{children:[v,$,L]}),e[40]=v,e[41]=$,e[42]=L,e[43]=J):J=e[43];let Z;e[44]!==g?(Z=m.jsx("div",{className:"h-full",children:m.jsx(qm,{form:g})}),e[44]=g,e[45]=Z):Z=e[45];let U;return e[46]!==s||e[47]!==J||e[48]!==Z||e[49]!==S?(U=m.jsxs(Ks,{onBack:s,children:[S,J,Z]}),e[46]=s,e[47]=J,e[48]=Z,e[49]=S,e[50]=U):U=e[50],U}function Xm(t){const e=R.c(5),{itemId:n,onBack:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Wm()??Sn,e[0]=s):s=e[0];const o=s;if(!o||o===Sn){let l;return e[1]===Symbol.for("react.memo_cache_sentinel")?(l=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(Qi,{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=m.jsx(cu,{children:m.jsx(E.Suspense,{fallback:null,children:m.jsx(Gm,{providerId:o,promptId:n,onBack:r})})}),e[2]=n,e[3]=r,e[4]=i):i=e[4],i}const Ym=sp("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 Qm(t){const e=R.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=Y(Ym({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=m.jsx("div",{"data-slot":"alert",role:"alert",className:o,...r}),e[7]=r,e[8]=o,e[9]=i):i=e[9],i}function Zm(t){const e=R.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=Y("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=m.jsx("div",{"data-slot":"alert-title",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function eg(t){const e=R.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=Y("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=m.jsx("div",{"data-slot":"alert-description",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}const tg=t=>t.replace(/_/g," ").replace(/\b\w/g,e=>e.toLocaleLowerCase());function ng(t){const e=R.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=Rp(a);if(!c.isAuthenticated){let f;return e[4]!==c.supportsOAuth||e[5]!==s?(f=m.jsx("div",{className:"flex h-full items-center justify-center",children:c.supportsOAuth?m.jsx(jp,{onAuthenticate:()=>s(),buttonText:"Go back to authenticate"}):m.jsx(Dp,{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=m.jsx(rg,{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 rg({toolName:t,connectionId:e,mcpProxyUrl:n,onBack:r}){const o=qi().location.href,{replayId:i}=op({strict:!1}),l=(()=>{if(!i)return null;const N=`replay-${i}`,_=sessionStorage.getItem(N);if(!_)return null;sessionStorage.removeItem(N);try{return JSON.parse(_)}catch{return null}})(),a=(()=>{if(!l)return null;const N={};for(const[_,L]of Object.entries(l))L!==null&&typeof L=="object"?N[_]=JSON.stringify(L,null,2):N[_]=L;return N})(),[c,u]=E.useState(a??{}),[d,f]=E.useState(l?JSON.stringify(l,null,2):"{}"),[h,p]=E.useState(null),[g,y]=E.useState(null),[x,b]=E.useState(!1),[k,C]=E.useState(null),w=Yi(e),S=ll({url:n.href});E.useEffect(()=>{S.error&&console.error("MCP Error:",S.error)},[S.error]);const v=S.tools?.find(N=>N.name===t),M=v?.inputSchema?.properties,T=M?Object.keys(M):[],I=T.length>0,D={};if(I&&v?.inputSchema?.properties)for(const N of T)D[N]=v.inputSchema.required?.includes(N)?"":void 0;const $=N=>Object.prototype.hasOwnProperty.call(c,N),V=async()=>{b(!0),y(null),p(null),C(null);const N=performance.now(),_=Ze(e);try{const L=I?{...D,...c}:(()=>{const ee=d.trim();if(!ee)return{};const G=JSON.parse(ee);if(G&&typeof G=="object")return G;throw new Error("Raw JSON input must be an object.")})();I&&v?.inputSchema?.properties&&Object.entries(v.inputSchema.properties).forEach(([ee,G])=>{if((G.type==="object"||G.type==="array")&&typeof L[ee]=="string")try{L[ee]=JSON.parse(L[ee])}catch{}});const J=await _(t,L),Z=performance.now(),U=Math.round(Z-N);p(J);const K=JSON.stringify(J),ie=new TextEncoder().encode(K).length;C({duration:`${U}ms`,bytes:`${ie} bytes`,tokens:`~${Math.ceil(ie/4)} tokens`,cost:"$0.0000"})}catch(L){const J=L instanceof Error?L.message:String(L);y(J||"Unknown error occurred");const Z=performance.now();C({duration:`${Math.round(Z-N)}ms`})}finally{b(!1)}},F=(N,_)=>{u(L=>({...L,[N]:_}))},P=()=>{p(null),y(null),C(null)};return m.jsxs(Ks,{onBack:r,children:[m.jsx(sl,{children:m.jsx(Zi,{title:v?.name??tg(t),url:o,icon:"build"})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 h-full",children:[m.jsx("div",{className:"flex flex-col border-r border-border overflow-hidden",children:m.jsxs("div",{className:"flex-1 overflow-auto",children:[m.jsx("div",{className:"flex flex-col gap-4 p-6 border-b border-border min-h-28",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(Us,{icon:w?.icon||null,name:w?.title||t,size:"sm",className:"shadow-sm shrink-0"}),m.jsx("h1",{className:"text-lg font-medium text-foreground leading-none",children:t}),m.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1 bg-muted/50 rounded-md h-fit",children:[S.state==="ready"?m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse shrink-0"}):S.state==="connecting"?m.jsx(or,{size:10,className:"animate-spin text-yellow-500 shrink-0"}):m.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 shrink-0"}),m.jsx("span",{className:"font-mono text-xs capitalize text-muted-foreground leading-none",children:S.state.replace("_"," ")})]})]}),m.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:v?.description||"No description available"})]})}),m.jsxs("div",{className:"flex flex-col p-6 gap-4",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h2",{className:"text-sm font-semibold text-foreground uppercase tracking-wide",children:"Parameters"}),v?.inputSchema?.required&&v.inputSchema.required.length>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:[m.jsx("span",{className:"text-red-500",children:"*"})," Required"]})]}),m.jsx("div",{className:"space-y-4",children:I&&v?.inputSchema?.properties?Object.entries(v.inputSchema.properties).map(([N,_])=>m.jsxs("div",{className:"space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("label",{className:"text-sm font-medium leading-none flex items-center gap-1.5",children:[N,v.inputSchema?.required?.includes(N)&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:_.type})]}),_.description&&m.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:_.description}),_.type==="object"||_.type==="array"?m.jsx(ui,{className:"font-mono text-xs",value:$(N)?c[N]??"":D[N]??"",onChange:L=>F(N,L.target.value),placeholder:`Enter ${N} as JSON...`,rows:3}):m.jsx(nl,{value:$(N)?c[N]??"":D[N]??"",onChange:L=>F(N,L.target.value),placeholder:`Enter ${N}...`})]},N)):v?.inputSchema&&!I?m.jsxs("div",{className:"space-y-2",children:[m.jsx("label",{className:"text-sm font-medium",children:"Raw JSON Input"}),m.jsx(ui,{className:"font-mono text-xs min-h-[120px]",value:d,onChange:N=>f(N.target.value),placeholder:'e.g. { "foo": "bar" }'})]}):m.jsx("div",{className:"flex items-center justify-center p-8 bg-muted/30 rounded-lg border border-dashed border-border",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No parameters required"})})})]})]})}),m.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-14 border-t lg:border-t-0 border-b border-border bg-background",children:[m.jsx("h2",{className:"text-sm font-medium text-foreground uppercase tracking-wide",children:"Result"}),k&&m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Tp,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:k.duration})]}),k.tokens&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(wu,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:k.tokens})]}),k.bytes&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Eu,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"font-mono text-foreground",children:k.bytes})]}),k.cost&&m.jsx("div",{className:"flex items-center gap-1.5",children:m.jsx("span",{className:"font-mono text-foreground",children:k.cost})})]})]}),m.jsx("div",{className:"flex items-center justify-end lg:justify-between px-4 h-14 border-b border-border bg-background",children:m.jsxs("div",{className:"flex items-center gap-2 w-full lg:w-auto",children:[m.jsx(me,{size:"sm",variant:"default",className:"h-8 gap-2 flex-1 lg:flex-none",onClick:V,disabled:x,children:x?m.jsxs(m.Fragment,{children:[m.jsx(or,{size:14,className:"animate-spin"}),"Executing..."]}):m.jsxs(m.Fragment,{children:[m.jsx(ol,{className:"h-3.5 w-3.5 fill-current"}),"Execute Tool"]})}),m.jsx(zt,{children:m.jsxs(Bt,{children:[m.jsx($t,{asChild:!0,children:m.jsx(me,{size:"icon",variant:"outline",className:"h-8 w-8 shrink-0",onClick:P,disabled:!h&&!g,children:m.jsx(il,{size:14})})}),m.jsx(_t,{children:m.jsx("p",{children:"Clear results"})})]})})]})}),g&&m.jsx("div",{className:"px-6 py-4 bg-background",children:m.jsx(Qm,{variant:"destructive",children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Np,{className:"h-4 w-4"}),m.jsx(Zm,{className:"mb-0",children:"Execution Failed"})]}),m.jsx(eg,{className:"text-xs text-destructive",children:g})]})})}),m.jsx("div",{className:"relative flex-1 overflow-auto bg-muted/50",children:h?m.jsxs(m.Fragment,{children:[m.jsx($p,{jsonString:JSON.stringify(h,null,2),padding:"1.5rem"}),m.jsx(me,{size:"icon",variant:"ghost",className:"absolute top-4 right-4 h-8 w-8 bg-background/80 hover:bg-background border border-border shadow-sm",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(h,null,2)),ru.success("Copied to clipboard")},children:m.jsx(Ap,{className:"h-3.5 w-3.5"})})]}):m.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-muted-foreground",children:[m.jsx(Mp,{className:"h-12 w-12 mb-3 opacity-40"}),m.jsx("p",{className:"text-sm",children:"Run the tool to see results"})]})})]})]})]})}function sg(t){const e=R.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=xr(s).connectionId??Sn;if(!Yi(i)){let u;return e[1]===Symbol.for("react.memo_cache_sentinel")?(u=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsxs("div",{className:"flex flex-col items-center gap-2 text-center",children:[m.jsx("h3",{className:"text-lg font-semibold",children:"Connection not found"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection may have been deleted or you may not have access."})]})}),e[1]=u):u=e[1],u}let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(or,{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=m.jsx(E.Suspense,{fallback:a,children:m.jsx(ng,{toolName:n,connectionId:i,onBack:r})}),e[3]=i,e[4]=r,e[5]=n,e[6]=c):c=e[6],c}const ga=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},hl=(t=>t?ga(t):ga),og=t=>t;function di(t,e=og){const n=X.useSyncExternalStore(t.subscribe,X.useCallback(()=>e(t.getState()),[t,e]),X.useCallback(()=>e(t.getInitialState()),[t,e]));return X.useDebugValue(n),n}const ig=t=>{const e=hl(t),n=r=>di(e,r);return Object.assign(n,e),n},lg=(t=>ig);function Ou(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 fi=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then(r){return fi(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return fi(r)(n)}}}},ag=(t,e)=>(n,r,s)=>{let o={storage:Ou(()=>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 p=()=>{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 fi(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(C=>[!0,C]):[!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[C,w]=b;if(h=o.merge(w,(k=r())!=null?k:f),n(h,!0),C)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:()=>p(),hasHydrated:()=>i,onHydrate:g=>(l.add(g),()=>{l.delete(g)}),onFinishHydration:g=>(a.add(g),()=>{a.delete(g)})},o.skipHydration||p(),h||f},Au=ag,{useSyncExternalStoreWithSelector:cg}=ip,ug=t=>t;function dg(t,e=ug,n){const r=cg(t.subscribe,t.getState,t.getInitialState,e,n);return X.useDebugValue(r),r}const ya=t=>Symbol.iterator in t,xa=t=>"entries"in t,ba=(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},fg=(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 hg(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:ya(t)&&ya(e)?xa(t)&&xa(e)?ba(t,e):fg(t,e):ba({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function pg(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 Ao(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 mg(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 Io(t,e){switch(t){case"tool":return{input:{},action:{toolName:""},outputSchema:{},name:`Step_${e+1}`};case"code":return{...zp,name:`Step_${e+1}`};default:throw new Error(`Invalid step type: ${t}`)}}const Iu=E.createContext(null),gg=t=>hl()(Au(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??Io(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:Ao(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=Io("code",Number((Math.random()*1e6).toFixed(0)));if(c={...c,input:i},a){const d=pg(a,"Input"),f=c.action,h=mg(f.code,d);c={...c,action:{...f,code:h}}}const u=Ao(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=Io("tool",Number((Math.random()*1e6).toFixed(0)));const s=Ao(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:Ou(()=>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 yg(t){const e=R.c(8),{children:n,initialState:r}=t,s=Fp();let o;e[0]!==s?.[0]?.id||e[1]!==r.currentStepTab||e[2]!==r.trackingExecutionId||e[3]!==r.workflow?(o=()=>gg({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]=E.useState(o);let l;return e[5]!==n||e[6]!==i?(l=m.jsx(Iu.Provider,{value:i,children:n}),e[5]=n,e[6]=i,e[7]=l):l=e[7],l}function Dn(t,e){const n=E.useContext(Iu);if(!n)throw new Error("Missing WorkflowStoreProvider - refresh the page. If the error persists, please contact support.");return dg(n,t,hg)}function Pn(){return Dn(xg)}function xg(t){return t.workflow}function Me(){return Dn(bg)}function bg(t){return t.actions}function Ru(){const t=kr();return Dn(kg)??t[0]?.name}function kg(t){return t.currentStepName}function br(){const t=R.c(5),e=Ru(),n=kr();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 kr(){return Pn().steps}function ju(){const t=R.c(4),e=Pn(),n=Dn(wg);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 wg(t){return t.originalWorkflow}function we(){return Dn(vg)}function vg(t){return t.trackingExecutionId}function Ln(){return Dn(Sg)}function Sg(t){return t.selectedGatewayId}function ka(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 Cg(t){if(Array.isArray(t))return t}function Eg(t,e,n){return(e=Rg(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ng(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 Tg(){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 wa(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 va(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wa(Object(n),!0).forEach(function(r){Eg(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wa(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Mg(t,e){if(t==null)return{};var n,r,s=Og(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 Og(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 Ag(t,e){return Cg(t)||Ng(t,e)||jg(t,e)||Tg()}function Ig(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 Rg(t){var e=Ig(t,"string");return typeof e=="symbol"?e:e+""}function jg(t,e){if(t){if(typeof t=="string")return ka(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)?ka(t,e):void 0}}function Dg(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Sa(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 Ca(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Sa(Object(n),!0).forEach(function(r){Dg(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Pg(){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 Hn(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 Qr(t){return{}.toString.call(t).includes("Object")}function Lg(t){return!Object.keys(t).length}function ir(t){return typeof t=="function"}function $g(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function _g(t,e){return Qr(e)||wt("changeType"),Object.keys(e).some(function(n){return!$g(t,n)})&&wt("changeField"),e}function zg(t){ir(t)||wt("selectorType")}function Bg(t){ir(t)||Qr(t)||wt("handlerType"),Qr(t)&&Object.values(t).some(function(e){return!ir(e)})&&wt("handlersType")}function Fg(t){t||wt("initialIsRequired"),Qr(t)||wt("initialType"),Lg(t)&&wt("initialContent")}function Vg(t,e){throw new Error(t[e]||t.default)}var Hg={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"},wt=Hn(Vg)(Hg),Or={changes:_g,selector:zg,handler:Bg,initial:Fg};function Wg(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Or.initial(t),Or.handler(e);var n={current:t},r=Hn(Kg)(n,e),s=Hn(Ug)(n),o=Hn(Or.changes)(t),i=Hn(qg)(n);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Or.selector(c),c(n.current)}function a(c){Pg(r,s,o,i)(c)}return[l,a]}function qg(t,e){return ir(e)?e(t.current):e}function Ug(t,e){return t.current=Ca(Ca({},t.current),e),e}function Kg(t,e,n){return ir(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 Jg={create:Wg},Gg={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Xg(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 Yg(t){return{}.toString.call(t).includes("Object")}function Qg(t){return t||Ea("configIsRequired"),Yg(t)||Ea("configType"),t.urls?(Zg(),{paths:{vs:t.urls.monacoBase}}):t}function Zg(){console.warn(Du.deprecation)}function e1(t,e){throw new Error(t[e]||t.default)}var Du={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
- `},Ea=Xg(e1)(Du),t1={config:Qg},n1=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 Pu(t,e){return Object.keys(e).forEach(function(n){e[n]instanceof Object&&t[n]&&Object.assign(e[n],Pu(t[n],e[n]))}),va(va({},t),e)}var r1={type:"cancelation",msg:"operation is manually canceled"};function Ro(t){var e=!1,n=new Promise(function(r,s){t.then(function(o){return e?s(r1):r(o)}),t.catch(s)});return n.cancel=function(){return e=!0},n}var s1=["monaco"],o1=Jg.create({config:Gg,isInitialized:!1,resolve:null,reject:null,monaco:null}),Lu=Ag(o1,2),wr=Lu[0],Js=Lu[1];function i1(t){var e=t1.config(t),n=e.monaco,r=Mg(e,s1);Js(function(s){return{config:Pu(s.config,r),monaco:n}})}function l1(){var t=wr(function(e){var n=e.monaco,r=e.isInitialized,s=e.resolve;return{monaco:n,isInitialized:r,resolve:s}});if(!t.isInitialized){if(Js({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Ro(jo);if(window.monaco&&window.monaco.editor)return $u(window.monaco),t.resolve(window.monaco),Ro(jo);n1(a1,u1)(d1)}return Ro(jo)}function a1(t){return document.body.appendChild(t)}function c1(t){var e=document.createElement("script");return t&&(e.src=t),e}function u1(t){var e=wr(function(r){var s=r.config,o=r.reject;return{config:s,reject:o}}),n=c1("".concat(e.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=e.reject,n}function d1(){var t=wr(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;$u(r),t.resolve(r)},function(n){t.reject(n)})}function $u(t){wr().monaco||Js({monaco:t})}function f1(){return wr(function(t){var e=t.monaco;return e})}var jo=new Promise(function(t,e){return Js({resolve:t,reject:e})}),Gs={config:i1,init:l1,__getMonacoInstance:f1},h1={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Do=h1,p1={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},m1=p1;function g1({children:t}){return X.createElement("div",{style:m1.container},t)}var y1=g1,x1=y1;function b1({width:t,height:e,isEditorReady:n,loading:r,_ref:s,className:o,wrapperProps:i}){return X.createElement("section",{style:{...Do.wrapper,width:t,height:e},...i},!n&&X.createElement(x1,null,r),X.createElement("div",{ref:s,style:{...Do.fullWidth,...!n&&Do.hide},className:o}))}var k1=b1,_u=E.memo(k1);function w1(t){E.useEffect(t,[])}var zu=w1;function v1(t,e,n=!0){let r=E.useRef(!0);E.useEffect(r.current||!n?()=>{r.current=!1}:t,e)}var Re=v1;function Jn(){}function xn(t,e,n,r){return S1(t,r)||C1(t,e,n,r)}function S1(t,e){return t.editor.getModel(Bu(t,e))}function C1(t,e,n,r){return t.editor.createModel(e,n,r?Bu(t,r):void 0)}function Bu(t,e){return t.Uri.parse(e)}function E1({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:p,wrapperProps:g={},beforeMount:y=Jn,onMount:x=Jn}){let[b,k]=E.useState(!1),[C,w]=E.useState(!0),S=E.useRef(null),v=E.useRef(null),M=E.useRef(null),T=E.useRef(x),I=E.useRef(y),D=E.useRef(!1);zu(()=>{let P=Gs.init();return P.then(N=>(v.current=N)&&w(!1)).catch(N=>N?.type!=="cancelation"&&console.error("Monaco initialization: error:",N)),()=>S.current?F():P.cancel()}),Re(()=>{if(S.current&&v.current){let P=S.current.getOriginalEditor(),N=xn(v.current,t||"",r||n||"text",o||"");N!==P.getModel()&&P.setModel(N)}},[o],b),Re(()=>{if(S.current&&v.current){let P=S.current.getModifiedEditor(),N=xn(v.current,e||"",s||n||"text",i||"");N!==P.getModel()&&P.setModel(N)}},[i],b),Re(()=>{let P=S.current.getModifiedEditor();P.getOption(v.current.editor.EditorOption.readOnly)?P.setValue(e||""):e!==P.getValue()&&(P.executeEdits("",[{range:P.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),P.pushUndoStop())},[e],b),Re(()=>{S.current?.getModel()?.original.setValue(t||"")},[t],b),Re(()=>{let{original:P,modified:N}=S.current.getModel();v.current.editor.setModelLanguage(P,r||n||"text"),v.current.editor.setModelLanguage(N,s||n||"text")},[n,r,s],b),Re(()=>{v.current?.editor.setTheme(c)},[c],b),Re(()=>{S.current?.updateOptions(d)},[d],b);let $=E.useCallback(()=>{if(!v.current)return;I.current(v.current);let P=xn(v.current,t||"",r||n||"text",o||""),N=xn(v.current,e||"",s||n||"text",i||"");S.current?.setModel({original:P,modified:N})},[n,e,s,t,r,o,i]),V=E.useCallback(()=>{!D.current&&M.current&&(S.current=v.current.editor.createDiffEditor(M.current,{automaticLayout:!0,...d}),$(),v.current?.editor.setTheme(c),k(!0),D.current=!0)},[d,c,$]);E.useEffect(()=>{b&&T.current(S.current,v.current)},[b]),E.useEffect(()=>{!C&&!b&&V()},[C,b,V]);function F(){let P=S.current?.getModel();l||P?.original?.dispose(),a||P?.modified?.dispose(),S.current?.dispose()}return X.createElement(_u,{width:h,height:f,isEditorReady:b,loading:u,_ref:M,className:p,wrapperProps:g})}var N1=E1;E.memo(N1);function T1(t){let e=E.useRef();return E.useEffect(()=>{e.current=t},[t]),e.current}var M1=T1,Ar=new Map;function O1({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:p="100%",className:g,wrapperProps:y={},beforeMount:x=Jn,onMount:b=Jn,onChange:k,onValidate:C=Jn}){let[w,S]=E.useState(!1),[v,M]=E.useState(!0),T=E.useRef(null),I=E.useRef(null),D=E.useRef(null),$=E.useRef(b),V=E.useRef(x),F=E.useRef(),P=E.useRef(r),N=M1(o),_=E.useRef(!1),L=E.useRef(!1);zu(()=>{let U=Gs.init();return U.then(K=>(T.current=K)&&M(!1)).catch(K=>K?.type!=="cancelation"&&console.error("Monaco initialization: error:",K)),()=>I.current?Z():U.cancel()}),Re(()=>{let U=xn(T.current,t||r||"",e||s||"",o||n||"");U!==I.current?.getModel()&&(d&&Ar.set(N,I.current?.saveViewState()),I.current?.setModel(U),d&&I.current?.restoreViewState(Ar.get(o)))},[o],w),Re(()=>{I.current?.updateOptions(c)},[c],w),Re(()=>{!I.current||r===void 0||(I.current.getOption(T.current.editor.EditorOption.readOnly)?I.current.setValue(r):r!==I.current.getValue()&&(L.current=!0,I.current.executeEdits("",[{range:I.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),I.current.pushUndoStop(),L.current=!1))},[r],w),Re(()=>{let U=I.current?.getModel();U&&s&&T.current?.editor.setModelLanguage(U,s)},[s],w),Re(()=>{l!==void 0&&I.current?.revealLine(l)},[l],w),Re(()=>{T.current?.editor.setTheme(i)},[i],w);let J=E.useCallback(()=>{if(!(!D.current||!T.current)&&!_.current){V.current(T.current);let U=o||n,K=xn(T.current,r||t||"",e||s||"",U||"");I.current=T.current?.editor.create(D.current,{model:K,automaticLayout:!0,...c},u),d&&I.current.restoreViewState(Ar.get(U)),T.current.editor.setTheme(i),l!==void 0&&I.current.revealLine(l),S(!0),_.current=!0}},[t,e,n,r,s,o,c,u,d,i,l]);E.useEffect(()=>{w&&$.current(I.current,T.current)},[w]),E.useEffect(()=>{!v&&!w&&J()},[v,w,J]),P.current=r,E.useEffect(()=>{w&&k&&(F.current?.dispose(),F.current=I.current?.onDidChangeModelContent(U=>{L.current||k(I.current.getValue(),U)}))},[w,k]),E.useEffect(()=>{if(w){let U=T.current.editor.onDidChangeMarkers(K=>{let ie=I.current.getModel()?.uri;if(ie&&K.find(ee=>ee.path===ie.path)){let ee=T.current.editor.getModelMarkers({resource:ie});C?.(ee)}});return()=>{U?.dispose()}}return()=>{}},[w,C]);function Z(){F.current?.dispose(),f?d&&Ar.set(o,I.current.saveViewState()):I.current.getModel()?.dispose(),I.current.dispose()}return X.createElement(_u,{width:h,height:p,isEditorReady:w,loading:a,_ref:D,className:g,wrapperProps:y})}var A1=O1,I1=E.memo(A1),R1=I1;async function j1(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 Gs.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 p=f.displayParts.map(y=>y.text).join("").replace(/^const __outputValue:\s*/,"");return bn(p)}else return null}catch(a){return e.setValue(n),console.error("Error getting return type:",a),null}}function bn(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:bn(r)}}const e=t.match(/^Array<(.+)>$/);if(e&&e[1])return{type:"array",items:bn(e[1])};const n=t.match(/^Record<(.+),\s*(.+)>$/);if(n&&n[2])return{type:"object",additionalProperties:bn(n[2].trim())};if(t.includes("|")){const r=D1(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=>bn(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("}")?P1(t):{description:`TypeScript type: ${t}`}}function D1(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 P1(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()&&Na(o.trim(),n,r),o="";continue}o+=a}o.trim()&&Na(o.trim(),n,r);const i={type:"object",properties:n};return r.length>0&&(i.required=r),i}function Na(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]=bn(i.trim()),o||n.push(s))}}class L1 extends E.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?m.jsx("div",{className:"flex items-center justify-center h-full w-full bg-[#1e1e1e] text-gray-400",children:m.jsx(jn,{size:"sm"})}):E.cloneElement(this.props.children,{mountKey:this.state.mountKey})}}let Ir=null;const $1=async()=>{if(Ir)return Ir;const[t,e,n]=await Promise.all([No(()=>import("./standalone-Cva4pL7v.js"),[]),No(()=>import("./typescript-Ca_eWjgL.js"),[]),No(()=>import("./estree-CwOGYdhi.js"),[])]);return Ir={format:t.format,plugins:[e.default,n.default]},Ir};Gs.config({paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.52.0/min/vs"}});const _1={parser:"typescript",semi:!0,singleQuote:!1,tabWidth:2,trailingComma:"es5",printWidth:80},Ta={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"},z1=m.jsx("div",{className:"flex items-center justify-center h-full w-full text-gray-400",children:m.jsx(jn,{size:"sm"})}),B1=E.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=E.useRef(null),u=E.useRef(null),d=E.useRef(r);d.current=r;const f=E.useRef(i);f.current=i;const h=E.useId(),p=`${h}-${a}`,g=i==="typescript"?`file:///workflow-${h.replace(/:/g,"-")}-${a}.tsx`:void 0,y=s?{...Ta,readOnly:!0}:Ta,x=async k=>{const C=k.getModel();if(!C){console.warn("No model found");return}const w=C.getValue();if(f.current==="json"){try{const v=JSON.parse(w),M=JSON.stringify(v,null,2);if(M!==w){const T=C.getFullModelRange();k.executeEdits("json-format",[{range:T,text:M}])}}catch(v){console.error("JSON formatting failed:",v)}return}try{const{format:v,plugins:M}=await $1(),T=await v(w,{..._1,plugins:M});if(T!==w){const I=C.getFullModelRange();k.executeEdits("prettier",[{range:I,text:T}])}}catch(v){console.error("Prettier formatting failed:",v)}},b=async(k,C)=>{c.current=k,l&&u.current&&(u.current.style.visibility="hidden",await k.getAction("editor.foldLevel2")?.run(),u.current.style.visibility="visible"),i==="typescript"&&(C.languages.typescript.typescriptDefaults.setCompilerOptions({target:C.languages.typescript.ScriptTarget.ESNext,module:C.languages.typescript.ModuleKind.ESNext,moduleResolution:C.languages.typescript.ModuleResolutionKind.NodeJs,allowNonTsExtensions:!0,allowJs:!0,strict:!1,noEmit:!0,esModuleInterop:!0,jsx:C.languages.typescript.JsxEmit.React,allowSyntheticDefaultImports:!0}),C.languages.typescript.typescriptDefaults.setDiagnosticsOptions({noSemanticValidation:!1,noSyntaxValidation:!1})),k.addCommand(C.KeyMod.CtrlCmd|C.KeyCode.KeyS,async()=>{await x(k);const w=await j1(k),S=k.getValue();console.log({value:S,returnType:w}),d.current?.(S,w)})};return m.jsx("div",{ref:u,className:"h-full",children:m.jsx(R1,{height:o,language:i,value:e,path:g,onChange:n,onMount:b,loading:z1,options:y},p)})}),Xs=E.memo(function(e){const n=R.c(2);let r;return n[0]!==e?(r=m.jsx(L1,{children:m.jsx(B1,{...e})}),n[0]=e,n[1]=r):r=n[1],r});function $n(){const t=R.c(2),e=vp();let n;t[0]!==e?(n={connections:e,binding:"WORKFLOW"},t[0]=e,t[1]=n):n=t[1];const r=Bp(n);if(!r||r.length===0||!r[0])throw new Error("No workflow connection found");return r[0]}const Ma=[1,1e3,2e3,3e3,5e3,1e4];function vr(t){const e=R.c(15),n=$n();let r;e[0]!==n.id?(r=Ze(n.id),e[0]=n.id,e[1]=r):r=e[1];const s=r,o=E.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?p=>{const g=p.state?.data?.item?.status;if(g==="running"||g==="enqueued"){const y=Ma[o.current]??1;return o.current=(o.current+1)%Ma.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}=al(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 F1(t,e){const n=R.c(14),r=$n();let s;n[0]!==r.id?(s=Ze(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}=al(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 V1(){const t=R.c(19),e=$n(),n=Pn();let r;t[0]!==e.id?(r=Ze(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:p}=al(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]!==p||t[17]!==y?(x={executions:y,isLoading:h,refetch:p},t[15]=h,t[16]=p,t[17]=y,t[18]=x):x=t[18],x}function Fu(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 H1(t){const e=[];for(const n of t){const r=Fu(n.input);e.push(...r)}return[...new Set(e)].filter(n=>n!=="__entire_input__")}function W1(t){for(const e of t)if(Fu(e.input).includes("__entire_input__"))return!0;return!1}function q1(t){const e=H1(t);if(e.length===0)return W1(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 U1(){const t=R.c(2),e=Pn();let n;return t[0]!==e.steps?(n=q1(e.steps),t[0]=e.steps,t[1]=n):n=t[1],n}function K1(){const t=R.c(14),{id:e}=$n(),{setTrackingExecutionId:n}=Me();let r;t[0]!==e?(r=Ze(e),t[0]=e,t[1]=r):r=t[1];const s=r,o=Pn(),i=Ln(),l=U1();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}=cl(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 Hub 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 p;return t[9]!==f||t[10]!==l||t[11]!==u||t[12]!==h?(p={handleRunWorkflow:f,isPending:u,requiresInput:h,inputSchema:l},t[9]=f,t[10]=l,t[11]=u,t[12]=h,t[13]=p):p=t[13],p}function J1(){const t=R.c(9),{id:e}=$n();let n;t[0]!==e?(n=Ze(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}=cl(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 G1(){const t=R.c(9),{id:e}=$n();let n;t[0]!==e?(n=Ze(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}=cl(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 X1(){const t=R.c(3),e=we(),{item:n}=vr(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 Y1(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 pl=lg()(Au(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"})),Vu=E.createContext([]);function Hu(){return E.useContext(Vu)}function xe(t){this.content=t}xe.prototype={constructor:xe,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 xe(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 xe(n)},addToStart:function(t,e){return new xe([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new xe(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 xe(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=xe.from(t),t.size?new xe(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=xe.from(t),t.size?new xe(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=xe.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}};xe.from=function(t){if(t instanceof xe)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new xe(e)};function Wu(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=Wu(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function qu(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=qu(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 Wu(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return qu(this,e,n,r)}findIndex(e){if(e==0)return Rr(0,e);if(e==this.size)return Rr(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?Rr(n+1,o):Rr(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 Po={index:0,offset:0};function Rr(t,e){return Po.index=t,Po.offset=e,Po}function Zr(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(!Zr(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Zr(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let te=class hi{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&&Zr(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 hi.none;if(e instanceof hi)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};te.none=[];class es extends Error{}class j{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=Ku(this.content,e+this.openStart,n);return r&&new j(r,this.openStart,this.openEnd)}removeBetween(e,n){return new j(Uu(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 j.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 j(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 j(e,r,s)}}j.empty=new j(O.empty,0,0);function Uu(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(Uu(o.content,e-s-1,n-s-1)))}function Ku(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=Ku(i.content,e-o-1,n,i);return l&&t.replaceChild(s,i.copy(l))}function Q1(t,e,n){if(n.openStart>t.depth)throw new es("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new es("Inconsistent open depths");return Ju(t,e,n,0)}function Ju(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=Ju(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 Vt(i,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Z1(n,t);return Vt(o,Xu(t,i,l,e,r))}else return Vt(o,ts(t,e,r))}function Gu(t,e){if(!e.type.compatibleContent(t.type))throw new es("Cannot join "+e.type.name+" onto "+t.type.name)}function pi(t,e,n){let r=t.node(n);return Gu(r,e.node(n)),r}function Ft(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 Gn(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&&(Ft(t.nodeAfter,r),o++));for(let l=o;l<i;l++)Ft(s.child(l),r);e&&e.depth==n&&e.textOffset&&Ft(e.nodeBefore,r)}function Vt(t,e){return t.type.checkContent(e),t.copy(e)}function Xu(t,e,n,r,s){let o=t.depth>s&&pi(t,e,s+1),i=r.depth>s&&pi(n,r,s+1),l=[];return Gn(null,t,s,l),o&&i&&e.index(s)==n.index(s)?(Gu(o,i),Ft(Vt(o,Xu(t,e,n,r,s+1)),l)):(o&&Ft(Vt(o,ts(t,e,s+1)),l),Gn(e,n,s,l),i&&Ft(Vt(i,ts(n,r,s+1)),l)),Gn(r,null,s,l),new O(l)}function ts(t,e,n){let r=[];if(Gn(null,t,n,r),t.depth>n){let s=pi(t,e,n+1);Ft(Vt(s,ts(t,e,n+1)),r)}return Gn(e,null,n,r),new O(r)}function Z1(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 lr{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 te.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 ns(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 lr(n,r,o)}static resolveCached(e,n){let r=Oa.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 Oa.set(e,r=new e0);let s=r.elts[r.i]=lr.resolve(e,n);return r.i=(r.i+1)%t0,s}}class e0{constructor(){this.elts=[],this.i=0}}const t0=12,Oa=new WeakMap;class ns{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 n0=Object.create(null);class ze{constructor(e,n,r,s=te.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&&Zr(this.attrs,n||e.defaultAttrs||n0)&&te.sameSet(this.marks,r||te.none)}copy(e=null){return e==this.content?this:new ze(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ze(this.type,this.attrs,this.content,e)}cut(e,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 j.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 j(c,s.depth-i,o.depth-i)}replace(e,n,r){return Q1(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 lr.resolveCached(this,e)}resolveNoCache(e){return lr.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()+")"),Yu(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=te.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(!te.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}}ze.prototype.text=void 0;class rs extends ze{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):Yu(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 rs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new rs(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 Yu(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ut{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new r0(e,n);if(r.next==null)return Ut.empty;let s=Qu(r);r.next&&r.err("Unexpected trailing text");let o=u0(c0(s));return d0(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
- `)}}Ut.empty=new Ut(!0);class r0{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 Qu(t){let e=[];do e.push(s0(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function s0(t){let e=[];do e.push(o0(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function o0(t){let e=a0(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=i0(t,e);else break;return e}function Aa(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function i0(t,e){let n=Aa(t),r=n;return t.eat(",")&&(t.next!="}"?r=Aa(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function l0(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 a0(t){if(t.eat("(")){let e=Qu(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=l0(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 c0(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 Zu(t,e){return e-t}function Ia(t,e){let n=[];return r(e),n.sort(Zu);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 u0(t){let e=Object.create(null);return n(Ia(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]);Ia(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Ut(r.indexOf(t.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(Zu);o.next.push({type:s[i][0],next:e[l.join(",")]||n(l)})}return o}}function d0(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 ed(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 td(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 nd(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 rd(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new h0(t,r,e[r]);return n}let Ra=class sd{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=rd(e,r.attrs),this.defaultAttrs=ed(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ut.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:td(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ze(this,this.computeAttrs(e),O.from(n),te.setFrom(r))}createChecked(e=null,n,r){return n=O.from(n),this.checkContent(n),new ze(this,this.computeAttrs(e),n,te.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 ze(this,e,n.append(o),te.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){nd(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:te.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,i)=>r[o]=new sd(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 f0(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 h0{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?f0(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Ys{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=rd(e,s.attrs),this.excluded=null;let o=ed(this.attrs);this.instance=o?new te(this,o):null}create(e=null){return!e&&this.instance?this.instance:new te(this,td(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new Ys(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){nd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class od{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=xe.from(e.nodes),n.marks=xe.from(e.marks||{}),this.nodes=Ra.compile(this.spec.nodes,this),this.marks=Ys.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Ut.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?ja(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==""?[]:ja(this,i.split(" "))}this.nodeFromJSON=s=>ze.fromJSON(this,s),this.markFromJSON=s=>te.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 Ra){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 rs(r,r.defaultAttrs,e,te.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 ja(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 p0(t){return t.tag!=null}function m0(t){return t.style!=null}class vt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(p0(s))this.tags.push(s);else if(m0(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 Pa(this,n,!1);return r.addAll(e,te.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Pa(this,n,!0);return r.addAll(e,te.none,n.from,n.to),j.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(x0(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=La(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=La(i)),i.node||i.ignore||i.mark||(i.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new vt(e,vt.schemaRules(e)))}}const id={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},g0={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ld={ol:!0,ul:!0},ar=1,mi=2,Xn=4;function Da(t,e,n){return e!=null?(e?ar:0)|(e==="full"?mi:0):t&&t.whitespace=="pre"?ar|mi:n&~Xn}class jr{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=te.none,this.match=o||(i&Xn?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&ar)){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&&!id.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Pa{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=Da(null,n.preserveWhitespace,0)|(r?Xn:0);s?o=new jr(s.type,s.attrs,te.none,!0,n.topMatch||s.type.contentMatch,i):r?o=new jr(null,null,te.none,!0,null,i):o=new jr(e.schema.topNodeType,null,te.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&mi?"full":this.localPreserveWS||(s.options&ar)>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;ld.hasOwnProperty(i)&&this.parser.normalizeLists&&y0(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:g0.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(id.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=te.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):$a(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=Da(e,o,i.options);i.options&Xn&&i.content.length==0&&(l|=Xn);let a=te.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):$a(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new jr(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|=ar)}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 y0(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ld.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function x0(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function La(t){let e={};for(let n in t)e[n]=t[n];return e}function $a(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 Qt{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Lo(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}=qr(Lo(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&&qr(Lo(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return qr(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=_a(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return _a(e.marks)}}function _a(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Lo(t){return t.document||window.document}const za=new WeakMap;function b0(t){let e=za.get(t);return e===void 0&&za.set(t,e=k0(t)),e}function k0(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 qr(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=b0(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:p}=qr(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const ad=65535,cd=Math.pow(2,16);function w0(t,e){return t+e*cd}function Ba(t){return t&ad}function v0(t){return(t-(t&ad))/cd}const ud=1,dd=2,Ur=4,fd=8;class gi{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&fd)>0}get deletedBefore(){return(this.delInfo&(ud|Ur))>0}get deletedAfter(){return(this.delInfo&(dd|Ur))>0}get deletedAcross(){return(this.delInfo&Ur)>0}}class je{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&je.empty)return je.empty}recover(e){let n=0,r=Ba(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+v0(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 p=e==(n<0?a:d)?null:w0(l/3,e-a),g=e==a?dd:e==d?ud:Ur;return(n<0?e!=a:e!=d)&&(g|=fd),new gi(h,g,p)}s+=u-c}return r?e+s:new gi(e+s,0,null)}touches(e,n){let r=0,s=Ba(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 je(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?je.empty:new je(e<0?[0,-e,0]:[0,0,e])}}je.empty=new je([]);class cr{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 cr(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 cr;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 gi(e,s,null)}}const $o=Object.create(null);class Ee{getMap(){return je.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=$o[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 $o)throw new RangeError("Duplicate use of step JSON ID "+e);return $o[e]=n,n.prototype.jsonID=e,n}}class de{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new de(e,null)}static fail(e){return new de(null,e)}static fromReplace(e,n,r,s){try{return de.ok(e.replace(n,r,s))}catch(o){if(o instanceof es)return de.fail(o.message);throw o}}}function ml(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(ml(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return O.fromArray(r)}class xt 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 j(ml(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 de.fromReplace(e,this.from,this.to,o)}invert(){return new qe(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 xt(n.pos,r.pos,this.mark)}merge(e){return e instanceof xt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xt(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 xt(n.from,n.to,e.markFromJSON(n.mark))}}Ee.jsonID("addMark",xt);class qe 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 j(ml(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new xt(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 qe(n.pos,r.pos,this.mark)}merge(e){return e instanceof qe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new qe(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 qe(n.from,n.to,e.markFromJSON(n.mark))}}Ee.jsonID("removeMark",qe);class bt extends Ee{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return de.fromReplace(e,this.pos,this.pos+1,new j(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 bt(this.pos,n.marks[s]);return new bt(this.pos,this.mark)}}return new Kt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new bt(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 bt(n.pos,e.markFromJSON(n.mark))}}Ee.jsonID("addNodeMark",bt);class Kt extends Ee{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return de.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return de.fromReplace(e,this.pos,this.pos+1,new j(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 bt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Kt(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 Kt(n.pos,e.markFromJSON(n.mark))}}Ee.jsonID("removeNodeMark",Kt);class he 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&&yi(e,this.from,this.to)?de.fail("Structure replace would overwrite content"):de.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new je([this.from,this.to-this.from,this.slice.size])}invert(e){return new he(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new he(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof he)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?j.empty:new j(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new he(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?j.empty:new j(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new he(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 he(n.from,n.to,j.fromJSON(e,n.slice),!!n.structure)}}Ee.jsonID("replace",he);class ge 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&&(yi(e,this.from,this.gapFrom)||yi(e,this.gapTo,this.to)))return de.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return de.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?de.fromReplace(e,this.from,this.to,r):de.fail("Content does not fit in gap")}getMap(){return new je([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 ge(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 ge(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 ge(n.from,n.to,n.gapFrom,n.gapTo,j.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ee.jsonID("replaceAround",ge);function yi(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 S0(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),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(i&&i.to==f&&i.mark.eq(d[g])?i.to=h:s.push(i=new qe(f,h,d[g])));l&&l.to==f?l.to=h:o.push(l=new xt(f,h,r))}}),s.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function C0(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 Ys){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 p=s[h];p.step==o-1&&d.eq(s[h].style)&&(f=p)}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 qe(i.from,i.to,i.style)))}function gl(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 he(l,u,j.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new qe(l,u,c.marks[f]));if(s&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new j(O.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new he(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);t.replace(l,l,new j(a,0,0))}for(let a=i.length-1;a>=0;a--)t.step(i[a])}function E0(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function _n(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||!E0(i,l,a))break;l&&(s=1),a<i.childCount&&(o=1)}return null}function N0(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 p=o,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,u=O.from(r.node(p).copy(u)),d++):a--;let f=O.empty,h=0;for(let p=o,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,f=O.from(s.node(p).copy(f)),h++):c++;t.step(new ge(a,c,i,l,new j(u.append(f),d,h),u.size-d,!0))}function yl(t,e,n=null,r=t){let s=T0(t,e),o=s&&M0(r,e);return o?s.map(Fa).concat({type:e,attrs:n}).concat(o.map(Fa)):null}function Fa(t){return{type:t,attrs:null}}function T0(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 M0(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 O0(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 ge(s,o,s,o,new j(r,0,0),n.length,!0))}function A0(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)&&I0(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&pd(t,i,l,o),gl(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 ge(d,f,d+1,f-1,new j(O.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&hd(t,i,l,o),!1}})}function hd(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 pd(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 I0(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function R0(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 ge(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new j(O.from(i),0,0),1,!0))}function it(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),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.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 j0(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 he(e,e,new j(o.append(i),n,n),!0))}function Ot(t,e){let n=t.resolve(e),r=n.index();return md(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function D0(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 md(t,e){return!!(t&&e&&!t.isLeaf&&D0(t,e))}function Qs(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&&md(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 P0(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);pd(t,u.node(),u.before(),l)}i.inlineContent&&gl(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 he(c,a.map(e+n,-1),j.empty,!0)),r===!0){let u=t.doc.resolve(c);hd(t,u.node(),u.before(),t.steps.length)}return t}function L0(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 gd(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 Zs(t,e,n=e,r=j.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),o=t.resolve(n);return yd(s,o,r)?new he(e,n,r):new $0(s,o,r).fit()}function yd(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class $0{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 j(o,i,l);return e>-1?new ge(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new he(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=_o(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=_o(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new j(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=_o(e,n);if(s.childCount<=1&&n>0){let o=e.size-n<=n+s.size;this.unplaced=new j(Wn(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new j(Wn(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(xd(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=qn(this.placed,n,O.from(u)),this.frontier[n].match=d,p&&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=p?e==0?j.empty:new j(Wn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new j(Wn(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||!zo(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=zo(e,n,s,r,o);if(i){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=zo(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=qn(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=qn(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=qn(this.placed,this.frontier.length,n))}}function Wn(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Wn(t.firstChild.content,e-1,n)))}function qn(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(qn(t.lastChild.content,e-1,n)))}function _o(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function xd(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,xd(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 zo(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&&!_0(n,o.content,i)?l:null}function _0(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function z0(t){return t.spec.defining||t.spec.definingForContent}function B0(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),o=t.doc.resolve(n);if(yd(s,o,r))return t.step(new he(e,n,r));let i=kd(s,o);i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let f=s.depth,h=s.pos-1;f>0;f--,h--){let p=s.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:s.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=z0(h.type);if(p&&!h.sameMarkup(s.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)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,p.type,p.marks))return t.replace(s.before(y),x?o.after(y):n,new j(bd(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 bd(t,e,n,r,s){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(bd(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 F0(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=L0(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new j(O.from(r),0,0))}function V0(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),o=kd(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 kd(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 wn 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 de.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 de.fromReplace(e,this.pos,this.pos+1,new j(O.from(s),0,n.isLeaf?0:1))}getMap(){return je.empty}invert(e){return new wn(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 wn(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 wn(n.pos,n.attr,n.value)}}Ee.jsonID("attr",wn);class ur 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 de.ok(r)}getMap(){return je.empty}invert(e){return new ur(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 ur(n.attr,n.value)}}Ee.jsonID("docAttr",ur);let Cn=class extends Error{};Cn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Cn.prototype=Object.create(Error.prototype);Cn.prototype.constructor=Cn;Cn.prototype.name="TransformError";class wd{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new cr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Cn(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=j.empty){let s=Zs(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new j(O.from(r),0,0))}delete(e,n){return this.replace(e,n,j.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return B0(this,e,n,r),this}replaceRangeWith(e,n,r){return F0(this,e,n,r),this}deleteRange(e,n){return V0(this,e,n),this}lift(e,n){return N0(this,e,n),this}join(e,n=1){return P0(this,e,n),this}wrap(e,n){return O0(this,e,n),this}setBlockType(e,n=e,r,s=null){return A0(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return R0(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new wn(e,n,r)),this}setDocAttribute(e,n){return this.step(new ur(e,n)),this}addNodeMark(e,n){return this.step(new bt(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 te)n.isInSet(r.marks)&&this.step(new Kt(e,n));else{let s=r.marks,o,i=[];for(;o=n.isInSet(s);)i.push(new Kt(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,n=1,r){return j0(this,e,n,r),this}addMark(e,n,r){return S0(this,e,n,r),this}removeMark(e,n,r){return C0(this,e,n,r),this}clearIncompatible(e,n,r){return gl(this,e,n,r),this}}const Bo=Object.create(null);class q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new H0(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=j.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?j.empty:n),l==0&&Wa(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),Wa(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new H(e):pn(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?pn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):pn(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 De(e.node(0))}static atStart(e){return pn(e,e,0,0,1)||new De(e)}static atEnd(e){return pn(e,e,e.content.size,e.childCount,-1)||new De(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Bo[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 Bo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Bo[e]=n,n.prototype.jsonID=e,n}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class H0{constructor(e,n){this.$from=e,this.$to=n}}let Va=!1;function Ha(t){!Va&&!t.parent.inlineContent&&(Va=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class H extends q{constructor(e,n=e){Ha(e),Ha(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 q.near(r);let s=e.resolve(n.map(this.anchor));return new H(s.parent.inlineContent?s:r,r)}replace(e,n=j.empty){if(super.replace(e,n),n==j.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof H&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new eo(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 H(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=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(o)n=o.$head;else return q.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new H(e,n)}}q.jsonID("text",H);class eo{constructor(e,n){this.anchor=e,this.head=n}map(e){return new eo(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}}class B extends q{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?q.near(o):new B(o)}content(){return new j(O.from(this.node),0,0)}eq(e){return e instanceof B&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new xl(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new B(e.resolve(n.anchor))}static create(e,n){return new B(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}B.prototype.visible=!1;q.jsonID("node",B);class xl{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new eo(r,r):new xl(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&B.isSelectable(r)?new B(n):q.near(n)}}class De extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=j.empty){if(n==j.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new De(e)}map(e){return new De(e)}eq(e){return e instanceof De}getBookmark(){return W0}}q.jsonID("all",De);const W0={map(){return this},resolve(t){return new De(t)}};function pn(t,e,n,r,s,o=!1){if(e.inlineContent)return H.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&&B.isSelectable(l))return B.create(t,n-(s<0?l.nodeSize:0))}else{let a=pn(t,l,n+s,s<0?l.childCount:0,s,o);if(a)return a}n+=l.nodeSize*s}return null}function Wa(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof he||s instanceof ge))return;let o=t.mapping.maps[r],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),t.setSelection(q.near(t.doc.resolve(i),n))}const qa=1,Dr=2,Ua=4;class q0 extends wd{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|qa)&~Dr,this.storedMarks=null,this}get selectionSet(){return(this.updated&qa)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Dr,this}ensureMarks(e){return te.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&Dr)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Dr,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)||te.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(q.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|=Ua,this}get scrolledIntoView(){return(this.updated&Ua)>0}}function Ka(t,e){return!e||!t?t:t.bind(e)}class Un{constructor(e,n,r){this.name=e,this.init=Ka(n.init,r),this.apply=Ka(n.apply,r)}}const U0=[new Un("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Un("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new Un("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Un("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Fo{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=U0.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 Un(r.key,r.spec.state,r))})}}class kn{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 kn(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 q0(this)}static create(e){let n=new Fo(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new kn(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 Fo(this.schema,e.plugins),r=n.fields,s=new kn(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 Fo(e.schema,e.plugins),o=new kn(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=ze.fromJSON(e.schema,n.doc);else if(i.name=="selection")o.selection=q.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 vd(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=vd(s,e,{})),n[r]=s}return n}class oe{constructor(e){this.spec=e,this.props={},e.props&&vd(e.props,this,this.props),this.key=e.key?e.key.key:Sd("plugin")}getState(e){return e[this.key]}}const Vo=Object.create(null);function Sd(t){return t in Vo?t+"$"+ ++Vo[t]:(Vo[t]=0,t+"$")}class ce{constructor(e="key"){this.key=Sd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const bl=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Cd(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ed=(t,e,n)=>{let r=Cd(t,n);if(!r)return!1;let s=kl(r);if(!s){let i=r.blockRange(),l=i&&_n(i);return l==null?!1:(e&&e(t.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Dd(t,s,e,-1))return!0;if(r.parent.content.size==0&&(En(o,"end")||B.isSelectable(o)))for(let i=r.depth;;i--){let l=Zs(t.doc,r.before(i),r.after(i),j.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(En(o,"end")?q.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):B.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},K0=(t,e,n)=>{let r=Cd(t,n);if(!r)return!1;let s=kl(r);return s?Nd(t,s,e):!1},J0=(t,e,n)=>{let r=Md(t,n);if(!r)return!1;let s=wl(r);return s?Nd(t,s,e):!1};function Nd(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=Zs(t.doc,o,a,j.empty);if(!c||c.from!=o||c instanceof he&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(H.create(u.doc,o)),n(u.scrollIntoView())}return!0}function En(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 Td=(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=kl(r)}let i=o&&o.nodeBefore;return!i||!B.isSelectable(i)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function kl(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 Md(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Od=(t,e,n)=>{let r=Md(t,n);if(!r)return!1;let s=wl(r);if(!s)return!1;let o=s.nodeAfter;if(Dd(t,s,e,1))return!0;if(r.parent.content.size==0&&(En(o,"start")||B.isSelectable(o))){let i=Zs(t.doc,r.before(),r.after(),j.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=t.tr.step(i);l.setSelection(En(o,"start")?q.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):B.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},Ad=(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=wl(r)}let i=o&&o.nodeAfter;return!i||!B.isSelectable(i)?!1:(e&&e(t.tr.setSelection(B.create(t.doc,o.pos)).scrollIntoView()),!0)};function wl(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 G0=(t,e)=>{let n=t.selection,r=n instanceof B,s;if(r){if(n.node.isTextblock||!Ot(t.doc,n.from))return!1;s=n.from}else if(s=Qs(t.doc,n.from,-1),s==null)return!1;if(e){let o=t.tr.join(s);r&&o.setSelection(B.create(o.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},X0=(t,e)=>{let n=t.selection,r;if(n instanceof B){if(n.node.isTextblock||!Ot(t.doc,n.to))return!1;r=n.to}else if(r=Qs(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Y0=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),o=s&&_n(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)},Id=(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 vl(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 Q0=(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=vl(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(q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Rd=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof De||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=vl(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(H.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},jd=(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(it(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),s=r&&_n(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Z0(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof B&&e.selection.node.isBlock)return!r.parentOffset||!it(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=vl(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 H||e.selection instanceof De)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=it(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=it(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)),p=u.doc.resolve(h);l&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return n&&n(u.scrollIntoView()),!0}}const ey=Z0(),ty=(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(B.create(t.doc,s))),!0)};function ny(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||Ot(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Dd(t,e,n,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&ny(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,p=O.empty;for(let x=i.length-1;x>=0;x--)p=O.from(i[x].create(null,p));p=O.from(s.copy(p));let g=t.tr.step(new ge(e.pos-1,h,e.pos,h,new j(p,1,0),i.length,!0)),y=g.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Ot(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:q.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&_n(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&En(o,"start",!0)&&En(s,"end")){let h=s,p=[];for(;p.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=p.length-1;k>=0;k--)x=O.from(p[k].copy(x));let b=t.tr.step(new ge(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new j(x,p.length,0),0,!0));n(b.scrollIntoView())}return!0}}return!1}function Pd(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(H.create(e.doc,t<0?s.start(o):s.end(o)))),!0):!1}}const ry=Pd(-1),sy=Pd(1);function oy(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),l=i&&yl(i,t,e);return l?(r&&r(n.tr.wrap(i,l).scrollIntoView()),!0):!1}}function Ja(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 Sl(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Sl(bl,Ed,Td);Sl(bl,Od,Ad);Sl(Id,Rd,jd,ey);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function iy(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 ly(l,i,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ly(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 ns(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ns(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=yl(o,n,r,e);return l?(t&&ay(t,e,l,s,n),!0):!1}function ay(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 ge(e.start-(r?2:0),e.end,e.start,e.end,new j(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&&it(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function cy(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?uy(e,n,t,o):dy(e,n,o):!0:!1}}function uy(t,e,n,r){let s=t.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new ge(o-1,i,o,i,new j(O.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ns(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=_n(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return Ot(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function dy(t,e,n){let r=t.tr,s=n.parent;for(let h=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)h-=s.child(p).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 ge(d-(l?1:0),f+(a?1:0),d+1,f-1,new j((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 fy(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 j(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 ge(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const be=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Nn=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let xi=null;const st=function(t,e,n){let r=xi||(xi=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},hy=function(){xi=null},Jt=function(t,e,n,r){return n&&(Ga(t,e,n,r,-1)||Ga(t,e,n,r,1))},py=/^(img|br|input|textarea|hr)$/i;function Ga(t,e,n,r,s){for(var o;;){if(t==n&&e==r)return!0;if(e==(s<0?0:_e(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Sr(t)||py.test(t.nodeName)||t.contentEditable=="false")return!1;e=be(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?_e(t):0}else return!1}}function _e(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function my(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=_e(t)}else if(t.parentNode&&!Sr(t))e=be(t),t=t.parentNode;else return null}}function gy(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&&!Sr(t))e=be(t)+1,t=t.parentNode;else return null}}function yy(t,e,n){for(let r=e==0,s=e==_e(t);r||s;){if(t==n)return!0;let o=be(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,s=s&&o==_e(t)}}function Sr(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 to=function(t){return t.focusNode&&Jt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Rt(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function xy(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function by(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(_e(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(_e(r.startContainer),r.startOffset)}}}const Xe=typeof navigator<"u"?navigator:null,Xa=typeof document<"u"?document:null,At=Xe&&Xe.userAgent||"",bi=/Edge\/(\d+)/.exec(At),Ld=/MSIE \d/.exec(At),ki=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(At),Ae=!!(Ld||ki||bi),St=Ld?document.documentMode:ki?+ki[1]:bi?+bi[1]:0,Be=!Ae&&/gecko\/(\d+)/i.test(At);Be&&+(/Firefox\/(\d+)/.exec(At)||[0,0])[1];const wi=!Ae&&/Chrome\/(\d+)/.exec(At),pe=!!wi,$d=wi?+wi[1]:0,Ce=!Ae&&!!Xe&&/Apple Computer/.test(Xe.vendor),Tn=Ce&&(/Mobile\/\w+/.test(At)||!!Xe&&Xe.maxTouchPoints>2),$e=Tn||(Xe?/Mac/.test(Xe.platform):!1),_d=Xe?/Win/.test(Xe.platform):!1,ot=/Android \d/.test(At),Cr=!!Xa&&"webkitFontSmoothing"in Xa.documentElement.style,ky=Cr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wy(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 et(t,e){return typeof t=="number"?t:t[e]}function vy(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 Ya(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=Nn(i);continue}let l=i,a=l==o.body,c=a?wy(o):vy(l),u=0,d=0;if(e.top<c.top+et(r,"top")?d=-(c.top-e.top+et(s,"top")):e.bottom>c.bottom-et(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+et(s,"top")-c.top:e.bottom-c.bottom+et(s,"bottom")),e.left<c.left+et(r,"left")?u=-(c.left-e.left+et(s,"left")):e.right>c.right-et(r,"right")&&(u=e.right-c.right+et(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-h,y=l.scrollTop-p;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:Nn(i)}}function Sy(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:zd(t.dom)}}function zd(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Nn(r));return e}function Cy({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Bd(n,r==0?0:r-e)}function Bd(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 fn=null;function Ey(t){if(t.setActive)return t.setActive();if(fn)return t.focus(fn);let e=zd(t);t.focus(fn==null?{get preventScroll(){return fn={preventScroll:!0},!0}}:void 0),fn||(fn=!1,Bd(e,0))}function Fd(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=st(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=u,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(o=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?Ny(n,s):!n||r&&n.nodeType==1?{node:t,offset:o}:Fd(n,s)}function Ny(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=ft(r,1);if(i.top!=i.bottom&&Cl(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 Cl(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ty(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function My(t,e,n){let{node:r,offset:s}=Fd(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 Oy(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 Vd(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(Cl(e,c))return Vd(i,e,c)}}if((o=(o+1)%r)==s)break}return t}function Ay(t,e){let n=t.dom.ownerDocument,r,s=0,o=by(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(!Cl(e,c)||(i=Vd(t.dom,e,c),!i))return null}if(Ce)for(let c=i;r&&c;c=Nn(c))c.draggable&&(r=void 0);if(i=Ty(i,e),r){if(Be&&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;Cr&&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=Oy(t,r,s,e))}l==null&&(l=My(t,i,e));let a=t.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Qa(t){return t.top<t.bottom||t.left<t.right}function ft(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Qa(r))return r}return Array.prototype.find.call(n,Qa)||t.getBoundingClientRect()}const Iy=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Hd(t,e,n){let{node:r,offset:s,atom:o}=t.docView.domFromPos(e,n<0?-1:1),i=Cr||Be;if(r.nodeType==3)if(i&&(Iy.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=ft(st(r,s,s),n);if(Be&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=ft(st(r,s-1,s-1),-1);if(c.top==a.top){let u=ft(st(r,s,s+1),-1);if(u.top!=a.top)return Fn(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++,Fn(ft(st(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==_e(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Ho(a.getBoundingClientRect(),!1)}if(o==null&&s<_e(r)){let a=r.childNodes[s];if(a.nodeType==1)return Ho(a.getBoundingClientRect(),!0)}return Ho(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==_e(r))){let a=r.childNodes[s-1],c=a.nodeType==3?st(a,_e(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Fn(ft(c,1),!1)}if(o==null&&s<_e(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?st(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Fn(ft(c,-1),!0)}return Fn(ft(r.nodeType==3?st(r):r,-n),n>=0)}function Fn(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 Ho(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 Wd(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 Ry(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Wd(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=Hd(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=st(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 jy=/[\u0590-\u08ac]/;function Dy(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?!jy.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:i:Wd(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:p,focusOffset:g}=t.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&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 Za=null,ec=null,tc=!1;function Py(t,e,n){return Za==e&&ec==n?tc:(Za=e,ec=n,tc=n=="up"||n=="down"?Ry(t,e,n):Dy(t,e,n))}const Fe=0,nc=1,jt=2,Ye=3;class Er{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Fe,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>be(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(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 Ud){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 qd&&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?be(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?be(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=be(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=be(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,p=0;h<this.children.length;h++){let g=this.children[h],y=p+g.size;if(o>p&&i<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=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((Be||Ce)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
31
- `),d&&p==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:be(y)+1});break}let x=g.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let g=h.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Be&&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&&Ce)&&Jt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Jt(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&Be)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,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?jt:nc,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ye:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?jt:Ye}r=i}this.dirty=jt}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?jt:nc;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class qd extends Er{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==Fe&&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 Ly extends Er{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 Gt extends Er{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=Qt.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Gt(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Ye||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ye&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Fe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Fe}}slice(e,n,r){let s=Gt.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=Si(o,n,i,r)),e>0&&(o=Si(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 Ct extends Er{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}=Qt.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=Gd(u,r,n),c?a=new $y(e,n,r,s,u,d||null,f,c,o,i+1):n.isText?new no(e,n,r,s,u,f,o):new Ct(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==Fe&&e.eq(this.node)&&ss(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 zy(this,i&&i.node,e);Vy(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?te.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==jt)&&(i&&this.protectLocalComposition(e,i),Kd(this.contentDOM,this.children,e),Tn&&Hy(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof H)||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=Wy(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 Ly(this,o,n,s);e.input.compositionNodes.push(i),this.children=Si(this.children,r,r+s.length,e,i)}update(e,n,r,s){return this.dirty==Ye||!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=Fe}updateOuterDeco(e){if(ss(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Jd(this.dom,this.nodeDOM,vi(this.outerDeco,this.node,n),vi(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 rc(t,e,n,r,s){Gd(r,e,t);let o=new Ct(void 0,t,e,n,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class no extends Ct{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==Ye||this.dirty!=Fe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Fe||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=Fe,!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 no(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=Ye)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ud extends Er{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Fe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class $y extends Ct{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==Ye)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 Kd(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=sc(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(i instanceof Gt){let a=r?r.previousSibling:t.lastChild;Kd(i.contentDOM,i.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=sc(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Yn=function(t){t&&(this.nodeName=t)};Yn.prototype=Object.create(null);const Dt=[new Yn];function vi(t,e,n){if(t.length==0)return Dt;let r=n?Dt[0]:new Yn,s=[r];for(let o=0;o<t.length;o++){let i=t[o].type.attrs;if(i){i.nodeName&&s.push(r=new Yn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(n&&s.length==1&&s.push(r=new Yn(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 Jd(t,e,n,r){if(n==Dt&&r==Dt)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=Dt[0]),s=a}_y(s,l||Dt[0],i)}return s}function _y(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 Gd(t,e,n){return Jd(t,t,Dt,vi(e,n,t.nodeType!=1))}function ss(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 sc(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class zy{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=By(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=Fe,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Gt.create(this.top,e[o],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==Ye&&i.dom==i.contentDOM&&(i.dirty=jt),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 Ct){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!=Ye&&ss(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=jt,d.updateChildren(s,i+1),d.dirty=Fe),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)||!ss(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Ct.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=Ct.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 qd(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 Gt;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof no)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ce||pe)&&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 Ud(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 By(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 Gt)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 Fy(t,e){return t.type.side-e.type.side}function Vy(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(Fy);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 p=o+f.nodeSize;if(f.isText){let y=p;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<p&&(a=f.cut(y-o),f=f.cut(0,y-o),p=y,h=-1)}else for(;i<s.length&&s[i].to<p;)i++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();r(f,g,e.forChild(o,f),h),o=p}}function Hy(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 Wy(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 Si(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 El(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(to(n)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&B.isSelectable(d)&&s.parent&&!(d.isInline&&yy(n.focusNode,n.focusOffset,s.dom))){let f=s.posBefore;c=new B(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 p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.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=Nl(t,u,l,d)}return c}function Xd(t){return t.editable?t.hasFocus():Qd(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function lt(t,e=!1){let n=t.state.selection;if(Yd(t,n),!!Xd(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&pe){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Jt(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Uy(t);else{let{anchor:r,head:s}=n,o,i;oc&&!(n instanceof H)&&(n.$from.parent.inlineContent||(o=ic(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=ic(t,n.to))),t.docView.setSelection(r,s,t,e),oc&&(o&&lc(o),i&&lc(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&qy(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const oc=Ce||pe&&$d<63;function ic(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(Ce&&s&&s.contentEditable=="false")return Wo(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Wo(s);if(o)return Wo(o)}}function Wo(t){return t.contentEditable="true",Ce&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function lc(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function qy(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(()=>{(!Xd(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Uy(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,be(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ae&&St<=11&&(n.disabled=!0,n.disabled=!1)}function Yd(t,e){if(e instanceof B){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ac(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ac(t)}function ac(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Nl(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||H.between(e,n,r)}function cc(t){return t.editable&&!t.hasFocus()?!1:Qd(t)}function Qd(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 Ky(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Jt(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Ci(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&&q.findFrom(o,e)}function ht(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function uc(t,e,n){let r=t.state.selection;if(r instanceof H)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 ht(t,new H(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Ci(t.state,e);return s&&s instanceof B?ht(t,s):!1}else if(!($e&&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?B.isSelectable(o)?ht(t,new B(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):Cr?ht(t,new H(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return ht(t,new H(e>0?r.$to:r.$from));{let s=Ci(t.state,e);return s?ht(t,s):!1}}}function is(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Qn(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function hn(t,e){return e<0?Jy(t):Gy(t)}function Jy(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,o,i=!1;for(Be&&n.nodeType==1&&r<is(n)&&Qn(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Qn(l,-1))s=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Zd(n))break;{let l=n.previousSibling;for(;l&&Qn(l,-1);)s=n.parentNode,o=be(l),l=l.previousSibling;if(l)n=l,r=is(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Ei(t,n,r):s&&Ei(t,s,o)}function Gy(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=is(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Qn(l,1))o=n,i=++r;else break}else{if(Zd(n))break;{let l=n.nextSibling;for(;l&&Qn(l,1);)o=l.parentNode,i=be(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=is(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&Ei(t,o,i)}function Zd(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Xy(t,e){for(;t&&e==t.childNodes.length&&!Sr(t);)e=be(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 Yy(t,e){for(;t&&!e&&!Sr(t);)e=be(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 Ei(t,e,n){if(e.nodeType!=3){let o,i;(i=Xy(e,n))?(e=i,n=0):(o=Yy(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(to(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&&lt(t)},50)}function dc(t,e){let n=t.state.doc.resolve(e);if(!(pe||_d)&&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 fc(t,e,n){let r=t.state.selection;if(r instanceof H&&!r.empty||n.indexOf("s")>-1||$e&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=Ci(t.state,e);if(i&&i instanceof B)return ht(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof De?q.near(i,e):q.findFrom(i,e);return l?ht(t,l):!1}return!1}function hc(t,e){if(!(t.state.selection instanceof H))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 pc(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Qy(t){if(!Ce||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;pc(t,r,"true"),setTimeout(()=>pc(t,r,"false"),20)}return!1}function Zy(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function ex(t,e){let n=e.keyCode,r=Zy(e);if(n==8||$e&&n==72&&r=="c")return hc(t,-1)||hn(t,-1);if(n==46&&!e.shiftKey||$e&&n==68&&r=="c")return hc(t,1)||hn(t,1);if(n==13||n==27)return!0;if(n==37||$e&&n==66&&r=="c"){let s=n==37?dc(t,t.state.selection.from)=="ltr"?-1:1:-1;return uc(t,s,r)||hn(t,s)}else if(n==39||$e&&n==70&&r=="c"){let s=n==39?dc(t,t.state.selection.from)=="ltr"?1:-1:1;return uc(t,s,r)||hn(t,s)}else{if(n==38||$e&&n==80&&r=="c")return fc(t,-1,r)||hn(t,-1);if(n==40||$e&&n==78&&r=="c")return Qy(t)||fc(t,1,r)||hn(t,1);if(r==($e?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Tl(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")||Qt.fromSchema(t.state.schema),l=of(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=sf[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),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 ef(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 j(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,p=Qt.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=sx(n),Cr&&ox(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")||vt.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!tx.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=ix(mc(l,+u[1],+u[2]),u[4]);else if(l=j.maxOpen(nx(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=mc(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const tx=/^(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 nx(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&&nf(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=rf(i[i.length-1],o.length));let u=tf(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return O.from(i)}return t}function tf(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function nf(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let o=nf(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(tf(n,t,s+1))))}}function rf(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,rf(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(O.empty,!0);return t.copy(n.append(r))}function Ni(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=Ni(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 mc(t,e,n){return e<t.openStart&&(t=new j(Ni(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new j(Ni(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const sf={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 gc=null;function of(){return gc||(gc=document.implementation.createHTMLDocument("title"))}let qo=null;function rx(t){let e=window.trustedTypes;return e?(qo||(qo=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),qo.createHTML(t)):t}function sx(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=of().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&sf[r[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=rx(t),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;return n}function ox(t){let e=t.querySelectorAll(pe?"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 ix(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 j(s,o,i)}const Ne={},Te={},lx={touchstart:!0,touchmove:!0};class ax{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 cx(t){for(let e in Ne){let n=Ne[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{dx(t,r)&&!Ml(t,r)&&(t.editable||!(r.type in Te))&&n(t,r)},lx[e]?{passive:!0}:void 0)}Ce&&t.dom.addEventListener("input",()=>null),Ti(t)}function kt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function ux(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 Ti(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ml(t,r))})}function Ml(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function dx(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 fx(t,e){!Ml(t,e)&&Ne[e.type]&&(t.editable||!(e.type in Te))&&Ne[e.type](t,e)}Te.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!af(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ot&&pe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Tn&&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,Rt(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||ex(t,n)?n.preventDefault():kt(t,"key")};Te.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Te.keypress=(t,e)=>{let n=e;if(af(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||$e&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof H)||!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 ro(t){return{left:t.clientX,top:t.clientY}}function hx(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ol(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 vn(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 px(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(vn(t,new B(n)),!0):!1}function mx(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof B&&(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(B.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?(vn(t,B.create(t.state.doc,s)),!0):!1}function gx(t,e,n,r,s){return Ol(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(s?mx(t,n):px(t,n))}function yx(t,e,n,r){return Ol(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function xx(t,e,n,r){return Ol(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||bx(t,n,r)}function bx(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(vn(t,H.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)vn(t,H.create(r,l+1,l+1+i.content.size));else if(B.isSelectable(i))vn(t,B.create(r,l));else continue;return!0}}function Al(t){return ls(t)}const lf=$e?"metaKey":"ctrlKey";Ne.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Al(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&hx(n,t.input.lastClick)&&!n[lf]&&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(ro(n));i&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new kx(t,i,n,!!r)):(o=="doubleClick"?yx:xx)(t,i.pos,i.inside,n)?n.preventDefault():kt(t,"pointer"))};class kx{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[lf],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 B&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Be&&!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)),kt(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(()=>lt(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(ro(e))),this.updateAllowDefault(e),this.allowDefault||!n?kt(this.view,"pointer"):gx(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ce&&this.mightDrag&&!this.mightDrag.node.isAtom||pe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(vn(this.view,q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),kt(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)}}Ne.touchstart=t=>{t.input.lastTouch=Date.now(),Al(t),kt(t,"pointer")};Ne.touchmove=t=>{t.input.lastTouch=Date.now(),kt(t,"pointer")};Ne.contextmenu=t=>Al(t);function af(t,e){return t.composing?!0:Ce&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const wx=ot?5e3:-1;Te.compositionstart=Te.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||pe&&_d&&vx(t)))t.markCursor=t.state.storedMarks||n.marks(),ls(t,!0),t.markCursor=null;else if(ls(t,!e.selection.empty),Be&&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}cf(t,wx)};function vx(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"}Te.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++,cf(t,20))};function cf(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ls(t),e))}function uf(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Cx());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Sx(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=my(e.focusNode,e.focusOffset),r=gy(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 Cx(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ls(t,e=!1){if(!(ot&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),uf(t),e||t.docView&&t.docView.dirty){let n=El(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 Ex(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 dr=Ae&&St<15||Tn&&ky<604;Ne.copy=Te.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let o=dr?null:n.clipboardData,i=r.content(),{dom:l,text:a}=Tl(t,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Ex(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Nx(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Tx(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?fr(t,r.value,null,s,e):fr(t,r.textContent,r.innerHTML,s,e)},50)}function fr(t,e,n,r,s){let o=ef(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,o||j.empty)))return!0;if(!o)return!1;let i=Nx(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 df(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," "):""}Te.paste=(t,e)=>{let n=e;if(t.composing&&!ot)return;let r=dr?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&fr(t,df(r),r.getData("text/html"),s,n)?n.preventDefault():Tx(t,n)};class ff{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Mx=$e?"altKey":"ctrlKey";function hf(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Mx]}Ne.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(ro(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof B?s.to-1:s.to))){if(r&&r.mightDrag)i=B.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=B.create(t.state.doc,d.posBefore))}}let l=(i||t.state.selection).content(),{dom:a,text:c,slice:u}=Tl(t,l);(!n.dataTransfer.files.length||!pe||$d>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(dr?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",dr||n.dataTransfer.setData("text/plain",c),t.dragging=new ff(u,hf(t,n),i)};Ne.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Te.dragover=Te.dragenter=(t,e)=>e.preventDefault();Te.drop=(t,e)=>{try{Ox(t,e,t.dragging)}finally{t.dragging=null}};function Ox(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(ro(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=ef(t,df(e.dataTransfer),dr?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(n&&hf(t,e));if(t.someProp("handleDrop",h=>h(t,e,o||j.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?gd(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&&B.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new B(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,g,y,x)=>h=x),a.setSelection(Nl(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Ne.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())&&lt(t)},20))};Ne.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)};Ne.beforeinput=(t,e)=>{if(pe&&ot&&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,Rt(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 Te)Ne[t]=Te[t];function hr(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 as{constructor(e,n){this.toDOM=e,this.spec=n||Ht,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 Se(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof as&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Et{constructor(e,n){this.attrs=e,this.spec=n||Ht}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 Se(o,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Et&&hr(this.attrs,e.attrs)&&hr(this.spec,e.spec)}static is(e){return e.type instanceof Et}destroy(){}}class Il{constructor(e,n){this.attrs=e,this.spec=n||Ht}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 Se(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 Il&&hr(this.attrs,e.attrs)&&hr(this.spec,e.spec)}destroy(){}}class Se{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Se(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 Se(e,e,new as(n,r))}static inline(e,n,r,s){return new Se(e,n,new Et(r,s))}static node(e,n,r,s){return new Se(e,n,new Il(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Et}get widget(){return this.type instanceof as}}const mn=[],Ht={};class re{constructor(e,n){this.local=e.length?e:mn,this.children=n.length?n:mn}static create(e,n){return n.length?cs(n,e,0,Ht):ve}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==ve||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ht)}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?Ax(this.children,i||[],e,n,r,s,o):i?new re(i.sort(Wt),mn):ve}add(e,n){return n.length?this==ve?re.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=mf(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,cs(u,l,c+1,Ht)),o+=3}});let i=pf(o?gf(n):n,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new re(i.length?this.local.concat(i).sort(Wt):this.local,s||this.children)}remove(e){return e.length==0||this==ve?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!=ve?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,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 re(s,r):ve}forChild(e,n){if(this==ve)return this;if(n.isLeaf)return re.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 Et){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 re(s.sort(Wt),mn);return r?new gt([l,r]):l}return r||ve}eq(e){if(this==e)return!0;if(!(e instanceof re)||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 Rl(this.localsInner(e))}localsInner(e){if(this==ve)return mn;if(e.inlineContent||!this.local.some(Et.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Et||n.push(this.local[r]);return n}forEachSet(e){e(this)}}re.empty=new re([],[]);re.removeOverlap=Rl;const ve=re.empty;class gt{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Ht));return gt.from(r)}forChild(e,n){if(n.isLeaf)return re.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,n);o!=ve&&(o instanceof gt?r=r.concat(o.members):r.push(o))}return gt.from(r)}eq(e){if(!(e instanceof gt)||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?Rl(r?n:n.sort(Wt)):mn}static from(e){switch(e.length){case 0:return ve;case 1:return e[0];default:return new gt(e.every(n=>n instanceof re)?e:e.reduce((n,r)=>n.concat(r instanceof re?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Ax(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,p,g)=>{let y=g-p-(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:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==h){let x=l[c+2].mapInner(n,y,u+1,t[c]+o+1,i);x!=ve?(l[c]=d,l[c+1]=h,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ix(l,t,e,n,s,o,i),u=cs(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 re(e.sort(Wt),l)}function pf(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 Se(s.from+e,s.to+e,s.type))}return n}function Ix(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 mf(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 gf(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function cs(t,e,n,r){let s=[],o=!1;e.forEach((l,a)=>{let c=mf(t,l,a+n);if(c){o=!0;let u=cs(c,l,n+a+1,r);u!=ve&&s.push(a,a+l.nodeSize,u)}});let i=pf(o?gf(t):t,-n).sort(Wt);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 re(i,s):ve}function Wt(t,e){return t.from-e.from||t.to-e.to}function Rl(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),yc(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),yc(e,s,r.copy(o.from,r.to)));break}}}return e}function yc(t,e,n){for(;e<t.length&&Wt(n,t[e])>0;)e++;t.splice(e,0,n)}function Uo(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ve&&e.push(r)}),t.cursorWrapper&&e.push(re.create(t.state.doc,[t.cursorWrapper.deco])),gt.from(e)}const Rx={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},jx=Ae&&St<=11;class Dx{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 Px{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Dx,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]);Ae&&St<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),jx&&(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,Rx)),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(cc(this.view)){if(this.suppressingSelectionUpdates)return lt(this.view);if(Ae&&St<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Jt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Nn(o))n.add(o);for(let o=e.anchorNode;o;o=Nn(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)&&cc(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(Be&&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||_x(e,d)!=h)&&f.remove()}}}else if((pe||Ce)&&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&&to(r)&&(c=El(e))&&c.eq(q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,lt(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),Lx(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||lt(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(Ae&&St<=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?be(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?be(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let xc=new WeakMap,bc=!1;function Lx(t){if(!xc.has(t)&&(xc.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Be,bc)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."),bc=!0}}function kc(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return Jt(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function $x(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return kc(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?kc(t,n):null}function _x(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 zx(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}],to(a)||c.push({node:a.focusNode,offset:a.focusOffset})),pe&&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")||vt.fromSchema(t.state.schema),h=d.resolve(i),p=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:Bx,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=y),p={anchor:y+i,head:x+i}}return{doc:g,sel:p,from:i,to:l}}function Bx(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ce&&/^(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||Ce&&/^(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 Fx=/^(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 Vx(t,e,n,r,s){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let v=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=El(t,v);if(M&&!t.state.selection.eq(M)){if(pe&&ot&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",I=>I(t,Rt(13,"Enter"))))return;let T=t.state.tr.setSelection(M);v=="pointer"?T.setMeta("pointer",!0):v=="key"&&T.scrollIntoView(),o&&T.setMeta("composition",o),t.dispatch(T)}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=zx(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 p=qx(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(Tn&&t.input.lastIOSEnter>Date.now()-225||ot)&&s.some(v=>v.nodeType==1&&!Fx.test(v.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",v=>v(t,Rt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof H&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=wc(t,t.state.doc,c.sel);if(v&&!v.eq(t.state.selection)){let M=t.state.tr.setSelection(v);o&&M.setMeta("composition",o),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof H&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Ae&&St<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),x=u.resolve(p.start),b=g.sameParent(y)&&g.parent.inlineContent&&x.end()>=p.endA;if((Tn&&t.input.lastIOSEnter>Date.now()-225&&(!b||s.some(v=>v.nodeName=="DIV"||v.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",v=>v(t,Rt(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Wx(u,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",v=>v(t,Rt(8,"Backspace")))){ot&&pe&&t.domObserver.suppressSelectionUpdates();return}pe&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),ot&&!b&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(v){return v(t,Rt(13,"Enter"))})},20));let k=p.start,C=p.endA,w=v=>{let M=v||t.state.tr.replace(k,C,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let T=wc(t,M.doc,c.sel);T&&!(pe&&t.composing&&T.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==k||T.head==M.mapping.map(C)-1)||Ae&&T.empty&&T.head==k)&&M.setSelection(T)}return o&&M.setMeta("composition",o),M.scrollIntoView()},S;if(b)if(g.pos==y.pos){Ae&&St<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>lt(t),20));let v=w(t.state.tr.delete(k,C)),M=u.resolve(p.start).marksAcross(u.resolve(p.endA));M&&v.ensureMarks(M),t.dispatch(v)}else if(p.endA==p.endB&&(S=Hx(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start())))){let v=w(t.state.tr);S.type=="add"?v.addMark(k,C,S.mark):v.removeMark(k,C,S.mark),t.dispatch(v)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let v=g.parent.textBetween(g.parentOffset,y.parentOffset),M=()=>w(t.state.tr.insertText(v,k,C));t.someProp("handleTextInput",T=>T(t,k,C,v,M))||t.dispatch(M())}else t.dispatch(w());else t.dispatch(w())}function wc(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Nl(t,e.resolve(n.anchor),e.resolve(n.head))}function Hx(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 Wx(t,e,n,r,s){if(n-e<=s.pos-r.pos||Ko(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(Ko(o,!0,!0));return!i.parent.isTextblock||i.pos>n||Ko(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Ko(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 qx(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&&vc(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&&vc(t.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function vc(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 yf{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 ax,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Tc),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=Ec(this),Cc(this),this.nodeViews=Nc(this),this.docView=rc(this.state.doc,Sc(this),Uo(this),this.dom,this),this.domObserver=new Px(this,(r,s,o,i)=>Vx(this,r,s,o,i)),this.domObserver.start(),cx(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&&Ti(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Tc),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&&(uf(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=Nc(this);Kx(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ti(this),this.editable=Ec(this),Cc(this);let a=Uo(this),c=Sc(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&&Sy(this);if(i){this.domObserver.stop();let h=d&&(Ae||pe)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Ux(s.selection,e.selection);if(d){let p=pe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Sx(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=rc(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ky(this))?lt(this,h):(Yd(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&&Cy(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 B){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ya(this,n.getBoundingClientRect(),e)}else Ya(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 ff(e.slice,e.move,s<0?void 0:B.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(Ae){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&&Ey(this.dom),lt(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 Ay(this,e)}coordsAtPos(e,n=1){return Hd(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 Py(this,n||this.state,e)}pasteHTML(e,n){return fr(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return fr(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Tl(this,e)}destroy(){this.docView&&(ux(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Uo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,hy())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return fx(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ce&&this.root.nodeType===11&&xy(this.dom.ownerDocument)==this.dom&&$x(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}yf.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Sc(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"),[Se.node(0,t.state.doc.content.size,e)]}function Cc(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:Se.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Ec(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Ux(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 Nc(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 Kx(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 Tc(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 Nt={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:"'"},us={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jx=typeof navigator<"u"&&/Mac/.test(navigator.platform),Gx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ke=0;ke<10;ke++)Nt[48+ke]=Nt[96+ke]=String(ke);for(var ke=1;ke<=24;ke++)Nt[ke+111]="F"+ke;for(var ke=65;ke<=90;ke++)Nt[ke]=String.fromCharCode(ke+32),us[ke]=String.fromCharCode(ke);for(var Jo in Nt)us.hasOwnProperty(Jo)||(us[Jo]=Nt[Jo]);function Xx(t){var e=Jx&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Gx&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?us:Nt)[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 Yx=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Qx=typeof navigator<"u"&&/Win/.test(navigator.platform);function Zx(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))Yx?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 eb(t){let e=Object.create(null);for(let n in t)e[Zx(n)]=t[n];return e}function Go(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 tb(t){return new oe({props:{handleKeyDown:xf(t)}})}function xf(t){let e=eb(t);return function(n,r){let s=Xx(r),o,i=e[Go(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Go(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Qx&&r.ctrlKey&&r.altKey)&&(o=Nt[r.keyCode])&&o!=s){let l=e[Go(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var nb=Object.defineProperty,jl=(t,e)=>{for(var n in e)nb(t,n,{get:e[n],enumerable:!0})};function so(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 oo=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,(...p)=>{const g=this.buildProps(a,e),y=f(...p)(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:so({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}},bf={};jl(bf,{blur:()=>rb,clearContent:()=>sb,clearNodes:()=>ob,command:()=>ib,createParagraphNear:()=>lb,cut:()=>ab,deleteCurrentNode:()=>cb,deleteNode:()=>ub,deleteRange:()=>db,deleteSelection:()=>fb,enter:()=>hb,exitCode:()=>pb,extendMarkRange:()=>mb,first:()=>gb,focus:()=>xb,forEach:()=>bb,insertContent:()=>kb,insertContentAt:()=>Sb,joinBackward:()=>Nb,joinDown:()=>Eb,joinForward:()=>Tb,joinItemBackward:()=>Mb,joinItemForward:()=>Ob,joinTextblockBackward:()=>Ab,joinTextblockForward:()=>Ib,joinUp:()=>Cb,keyboardShortcut:()=>jb,lift:()=>Db,liftEmptyBlock:()=>Pb,liftListItem:()=>Lb,newlineInCode:()=>$b,resetAttributes:()=>_b,scrollIntoView:()=>zb,selectAll:()=>Bb,selectNodeBackward:()=>Fb,selectNodeForward:()=>Vb,selectParentNode:()=>Hb,selectTextblockEnd:()=>Wb,selectTextblockStart:()=>qb,setContent:()=>Ub,setMark:()=>fk,setMeta:()=>hk,setNode:()=>pk,setNodeSelection:()=>mk,setTextDirection:()=>gk,setTextSelection:()=>yk,sinkListItem:()=>xk,splitBlock:()=>bk,splitListItem:()=>kk,toggleList:()=>wk,toggleMark:()=>vk,toggleNode:()=>Sk,toggleWrap:()=>Ck,undoInputRule:()=>Ek,unsetAllMarks:()=>Nk,unsetMark:()=>Tk,unsetTextDirection:()=>Mk,updateAttributes:()=>Ok,wrapIn:()=>Ak,wrapInList:()=>Ik});var rb=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),sb=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),ob=()=>({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 p=_n(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},ib=t=>e=>t(e),lb=()=>({state:t,dispatch:e})=>Rd(t,e),ab=(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 H(r.doc.resolve(Math.max(i-1,0)))),!0},cb=()=>({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 fe(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 ub=t=>({tr:e,state:n,dispatch:r})=>{const s=fe(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},db=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},fb=()=>({state:t,dispatch:e})=>bl(t,e),hb=()=>({commands:t})=>t.keyboardShortcut("Enter"),pb=()=>({state:t,dispatch:e})=>Q0(t,e);function Dl(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ds(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Dl(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function kf(t,e,n={}){return t.find(r=>r.type===e&&ds(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Mc(t,e,n={}){return!!kf(t,e,n)}function Pl(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),!kf([...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&&Mc([...t.parent.child(i-1).marks],e,n);)i-=1,l-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&Mc([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function at(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 mb=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const o=at(t,r.schema),{doc:i,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=Pl(a,o,e);if(d&&d.from<=c&&d.to>=u){const f=H.create(i,d.from,d.to);n.setSelection(f)}}return!0},gb=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 wf(t){return t instanceof H}function Pt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function vf(t,e=null){if(!e)return null;const n=q.atStart(t),r=q.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,o=r.to;return e==="all"?H.create(t,Pt(0,s,o),Pt(t.content.size,s,o)):H.create(t,Pt(e,s,o),Pt(e,s,o))}function Mi(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function pr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function yb(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var xb=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(pr()||Mi())&&r.dom.focus(),yb()&&!pr()&&!Mi()&&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&&!wf(n.state.selection))return i(),!0;const l=vf(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},bb=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),kb=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Sf=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&&Sf(r)}return t};function Pr(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 Sf(n)}function mr(t,e,n){if(t instanceof ze||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),mr("",e,n)}if(s){if(n.errorOnInvalidContent){let i=!1,l="";const a=new od({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?vt.fromSchema(a).parseSlice(Pr(t),n.parseOptions):vt.fromSchema(a).parse(Pr(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=vt.fromSchema(e);return n.slice?o.parseSlice(Pr(t),n.parseOptions).content:o.parse(Pr(t),n.parseOptions)}return mr("",e,n)}function wb(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof he||s instanceof ge))return;const o=t.mapping.maps[r];let i=0;o.forEach((l,a,c,u)=>{i===0&&(i=u)}),t.setSelection(q.near(t.doc.resolve(i),n))}var vb=t=>!("type"in t),Sb=(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{mr(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=mr(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((vb(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,C=x.content.size>0;b&&k&&C&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&wb(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},Cb=()=>({state:t,dispatch:e})=>G0(t,e),Eb=()=>({state:t,dispatch:e})=>X0(t,e),Nb=()=>({state:t,dispatch:e})=>Ed(t,e),Tb=()=>({state:t,dispatch:e})=>Od(t,e),Mb=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Qs(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Ob=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Qs(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Ab=()=>({state:t,dispatch:e})=>K0(t,e),Ib=()=>({state:t,dispatch:e})=>J0(t,e);function Cf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Rb(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))pr()||Cf()?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 jb=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const o=Rb(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 Tt(t,e,n={}){const{from:r,to:s,empty:o}=t.selection,i=e?fe(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(s,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=s-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>ds(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}var Db=(t,e={})=>({state:n,dispatch:r})=>{const s=fe(t,n.schema);return Tt(n,s,e)?Y0(n,r):!1},Pb=()=>({state:t,dispatch:e})=>jd(t,e),Lb=t=>({state:e,dispatch:n})=>{const r=fe(t,e.schema);return cy(r)(e,n)},$b=()=>({state:t,dispatch:e})=>Id(t,e);function io(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Oc(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 _b=(t,e)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=io(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=fe(t,r.schema)),l==="mark"&&(i=at(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,Oc(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(Oc(f.attrs,e))))})})}),a},zb=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Bb=()=>({tr:t,dispatch:e})=>{if(e){const n=new De(t.doc);t.setSelection(n)}return!0},Fb=()=>({state:t,dispatch:e})=>Td(t,e),Vb=()=>({state:t,dispatch:e})=>Ad(t,e),Hb=()=>({state:t,dispatch:e})=>ty(t,e),Wb=()=>({state:t,dispatch:e})=>sy(t,e),qb=()=>({state:t,dispatch:e})=>ry(t,e);function Oi(t,e,n={},r={}){return mr(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Ub=(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=Oi(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 Ef(t,e){const n=at(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 Nf(t,e){const n=new wd(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function Kb(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 Jb(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function Gb(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 lo(t){return e=>Gb(e.$from,t)}function z(t,e,n){return t.config[e]===void 0&&t.parent?z(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?z(t.parent,e,n):null}):t.config[e]}function Ll(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=z(e,"addExtensions",n);return r?[e,...Ll(r())]:e}).flat(10)}function $l(t,e){const n=Qt.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Tf(t){return typeof t=="function"}function Q(t,e=void 0,...n){return Tf(t)?e?t.bind(e)(...n):t(...n):t}function Xb(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Mn(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 Mf(t){const e=[],{nodeExtensions:n,markExtensions:r}=Mn(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=z(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=z(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 se(...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 On(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)=>se(n,r),{})}function Yb(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Ac(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):Yb(n.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function Ic(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Xb(n)?!1:n!=null))}function Rc(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 Qb(t,e){var n;const r=Mf(t),{nodeExtensions:s,markExtensions:o}=Mn(t),i=(n=s.find(c=>z(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=z(b,"extendNodeSchema",d);return{...x,...k?k(c):{}}},{}),h=Ic({...f,content:Q(z(c,"content",d)),marks:Q(z(c,"marks",d)),group:Q(z(c,"group",d)),inline:Q(z(c,"inline",d)),atom:Q(z(c,"atom",d)),selectable:Q(z(c,"selectable",d)),draggable:Q(z(c,"draggable",d)),code:Q(z(c,"code",d)),whitespace:Q(z(c,"whitespace",d)),linebreakReplacement:Q(z(c,"linebreakReplacement",d)),defining:Q(z(c,"defining",d)),isolating:Q(z(c,"isolating",d)),attrs:Object.fromEntries(u.map(Rc))}),p=Q(z(c,"parseHTML",d));p&&(h.parseDOM=p.map(x=>Ac(x,u)));const g=z(c,"renderHTML",d);g&&(h.toDOM=x=>g({node:x,HTMLAttributes:On(x,u)}));const y=z(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=z(x,"extendMarkSchema",d);return{...y,...b?b(c):{}}},{}),h=Ic({...f,inclusive:Q(z(c,"inclusive",d)),excludes:Q(z(c,"excludes",d)),group:Q(z(c,"group",d)),spanning:Q(z(c,"spanning",d)),code:Q(z(c,"code",d)),attrs:Object.fromEntries(u.map(Rc))}),p=Q(z(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>Ac(y,u)));const g=z(c,"renderHTML",d);return g&&(h.toDOM=y=>g({mark:y,HTMLAttributes:On(y,u)})),[c.name,h]}));return new od({topNode:i,nodes:l,marks:a})}function Zb(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function fs(t){return t.sort((n,r)=>{const s=z(n,"priority")||100,o=z(r,"priority")||100;return s>o?-1:s<o?1:0})}function Of(t){const e=fs(Ll(t)),n=Zb(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 Af(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 ek(t,e){const n={from:0,to:t.content.size};return Af(t,n,e)}function If(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function tk(t,e){const n=fe(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 Rf(t,e){const n=io(typeof e=="string"?e:e.name,t.schema);return n==="node"?tk(t,e):n==="mark"?Ef(t,e):{}}function nk(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 rk(t){const e=nk(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 jf(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}})})}),rk(r)}function _l(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const o=n.resolve(t),i=Pl(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 sk=(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 Lr(t,e){return e.nodes[t]||e.marks[t]||null}function Kr(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 ok=(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 Ai(t,e,n={}){const{empty:r,ranges:s}=t.selection,o=e?at(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>ds(d.attrs,n,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const x=Math.max(h,y),b=Math.min(p,y+g.nodeSize),k=b-x;i+=k,l.push(...g.marks.map(C=>({mark:C,from:x,to:b})))})}),i===0)return!1;const a=l.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>ds(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 ik(t,e,n={}){if(!e)return Tt(t,null,n)||Ai(t,null,n);const r=io(e,t.schema);return r==="node"?Tt(t,e,n):r==="mark"?Ai(t,e,n):!1}var lk=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const o=lo(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)},ak=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function jc(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Dc(t,e){const{nodeExtensions:n}=Mn(e),r=n.find(i=>i.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=Q(z(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function ao(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&&(ao(o,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Df(t){return t instanceof B}var Pf=class Lf{constructor(e){this.position=e}static fromJSON(e){return new Lf(e.position)}toJSON(){return{position:this.position}}};function ck(t,e){const n=e.mapping.mapResult(t.position);return{position:new Pf(n.pos),mapResult:n}}function uk(t){return new Pf(t)}function dk(t,e,n){var r;const{selection:s}=e;let o=null;if(wf(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),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&p}return!c}),c})}var fk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:l}=o,a=at(t,r.schema);if(s)if(i){const c=Ef(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 p=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(p,g,a.create({...x.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return dk(r,n,a)},hk=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),pk=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const o=fe(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})=>Ja(o,{...i,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Ja(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},mk=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Pt(t,0,r.content.size),o=B.create(r,s);e.setSelection(o)}return!0},gk=(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},yk=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:o}=typeof t=="number"?{from:t,to:t}:t,i=H.atStart(r).from,l=H.atEnd(r).to,a=Pt(s,i,l),c=Pt(o,i,l),u=H.create(r,a,c);e.setSelection(u)}return!0},xk=t=>({state:e,dispatch:n})=>{const r=fe(t,e.schema);return fy(r)(e,n)};function Pc(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 bk=({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=Kr(c,l.node().type.name,l.node().attrs);if(o instanceof B&&o.node.isBlock)return!l.parentOffset||!it(i,l.pos)?!1:(r&&(t&&Pc(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:Kb(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=it(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&it(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(o instanceof H&&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&&Pc(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},kk=(t,e={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const l=fe(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,C={...Kr(f,a.node().type.name,a.node().attrs),...e},w=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(C))||void 0;x=x.append(O.from(l.createAndFill(null,w)||void 0));const S=a.before(a.depth-(b-1));n.replace(S,a.after(-k),new j(x,4-b,0));let v=-1;n.doc.nodesBetween(S,n.doc.content.size,(M,T)=>{if(v>-1)return!1;M.isTextblock&&M.content.size===0&&(v=T+1)}),v>-1&&n.setSelection(H.near(n.doc.resolve(v))),n.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Kr(f,d.type.name,d.attrs),...e},g={...Kr(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:g}]:[{type:l,attrs:p}];if(!it(n.doc,a.pos,2))return!1;if(s){const{selection:x,storedMarks:b}=r,{splittableMarks:k}=o.extensionManager,C=b||x.$to.parentOffset&&x.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!C||!s)return!0;const w=C.filter(S=>k.includes(S.type.name));n.ensureMarks(w)}return!0},Xo=(t,e)=>{const n=lo(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&&Ot(t.doc,n.pos)&&t.join(n.pos),!0},Yo=(t,e)=>{const n=lo(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&&Ot(t.doc,r)&&t.join(r),!0},wk=(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=fe(t,i.schema),p=fe(e,i.schema),{selection:g,storedMarks:y}=i,{$from:x,$to:b}=g,k=x.blockRange(b),C=y||g.$to.parentOffset&&g.$from.marks();if(!k)return!1;const w=lo(S=>Dc(S.type.name,d))(g);if(k.depth>=1&&w&&k.depth-w.depth<=1){if(w.node.type===h)return c.liftListItem(p);if(Dc(w.node.type.name,d)&&h.validContent(w.node.content)&&l)return a().command(()=>(o.setNodeMarkup(w.pos,h),!0)).command(()=>Xo(o,h)).command(()=>Yo(o,h)).run()}return!n||!C||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Xo(o,h)).command(()=>Yo(o,h)).run():a().command(()=>{const S=u().wrapInList(h,r),v=C.filter(M=>f.includes(M.type.name));return o.ensureMarks(v),S?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Xo(o,h)).command(()=>Yo(o,h)).run()},vk=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=at(t,r.schema);return Ai(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},Sk=(t,e,n={})=>({state:r,commands:s})=>{const o=fe(t,r.schema),i=fe(e,r.schema),l=Tt(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})},Ck=(t,e={})=>({state:n,commands:r})=>{const s=fe(t,n.schema);return Tt(n,s,e)?r.lift(s):r.wrapIn(s,e)},Ek=()=>({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},Nk=()=>({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},Tk=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=n,a=at(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&i){let{from:f,to:h}=l;const p=(o=c.marks().find(y=>y.type===a))==null?void 0:o.attrs,g=Pl(c,a,p);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},Mk=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},Ok=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=io(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(o=fe(t,r.schema)),l==="mark"&&(i=at(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,p,g;n.selection.empty?r.doc.nodesBetween(u,d,(y,x)=>{o&&o===y.type&&(a=!0,p=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,p=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),C=Math.min(x+y.nodeSize,d);n.addMark(k,C,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(p,g,i.create({...y.attrs,...e}))}))}),a},Ak=(t,e={})=>({state:n,dispatch:r})=>{const s=fe(t,n.schema);return oy(s,e)(n,r)},Ik=(t,e={})=>({state:n,dispatch:r})=>{const s=fe(t,n.schema);return iy(s,e)(n,r)},Rk=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={}}},co=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},jk=(t,e)=>{if(Dl(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 $r(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=ok(c)+o;return i.forEach(f=>{if(u)return;const h=jk(d,f.find);if(!h)return;const p=a.state.tr,g=so({state:a.state,transaction:p}),y={from:r-(h[0].length-o.length),to:s},{commands:x,chain:b,can:k}=new oo({editor:n,state:g});f.handler({state:g,range:y,match:h,commands:x,chain:b,can:k})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:o}),a.dispatch(p),u=!0)}),u}function Dk(t){const{editor:e,rules:n}=t,r=new oe({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=$l(O.from(u),i.schema);const{from:d}=a,f=d+u.length;$r({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 $r({editor:e,from:o,to:i,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&$r({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?$r({editor:e,from:i.pos,to:i.pos,text:`
37
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Pk(t){return Object.prototype.toString.call(t).slice(8,-1)}function _r(t){return Pk(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function $f(t,e){const n={...t};return _r(t)&&_r(e)&&Object.keys(e).forEach(r=>{_r(e[r])&&_r(t[r])?n[r]=$f(t[r],e[r]):n[r]=e[r]}),n}var zl=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{...Q(z(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Q(z(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>$f(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}},Zt=class _f extends zl{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new _f(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 Lk(t){return typeof t=="number"}var $k=class{constructor(t){this.find=t.find,this.handler=t.handler}},_k=(t,e,n)=>{if(Dl(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 zk(t){const{editor:e,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=t,{commands:a,chain:c,can:u}=new oo({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(h,p)=>{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 C=(k=(b=(x=h.content)==null?void 0:x.size)!=null?b:h.nodeSize)!=null?k:0,w=Math.max(r,p),S=Math.min(s,p+C);if(w>=S)return;const v=h.isText?h.text||"":h.textBetween(w-p,S-p,void 0,"");_k(v,o.find,i).forEach(T=>{if(T.index===void 0)return;const I=w+T.index+1,D=I+T[0].length,$={from:n.tr.mapping.map(I),to:n.tr.mapping.map(D)},V=o.handler({state:n,range:$,match:T,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(V)})}),d.every(h=>h!==null)}var zr=null,Bk=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function Fk(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:p})=>{const g=u.tr,y=so({state:u,transaction:g});if(!(!zk({editor:e,state:y,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,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 oe({view(d){const f=p=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(p.target)?d.dom.parentElement:null,r&&(zr=e)},h=()=>{zr&&(zr=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=zr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!o,x=p.getMeta("applyPasteRules"),b=!!x;if(!g&&!y&&!b)return;if(b){let{text:w}=x;typeof w=="string"?w=w:w=$l(O.from(w),h.schema);const{from:S}=x,v=S+w.length,M=Bk(w);return a({rule:u,state:h,from:S,to:{b:v},pasteEvt:M})}const k=f.doc.content.findDiffStart(h.doc.content),C=f.doc.content.findDiffEnd(h.doc.content);if(!(!Lk(k)||!C||k===C.b))return a({rule:u,state:h,from:k,to:C,pasteEvt:i})}}))}var uo=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Of(t),this.schema=Qb(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:Lr(e.name,this.schema)},r=z(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return fs([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Lr(r.name,this.schema)},o=[],i=z(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&z(r,"exitable",s)&&(l.ArrowRight=()=>Zt.handleExit({editor:t,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}const a=tb(l);o.push(a);const c=z(r,"addInputRules",s);if(jc(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=Dk({editor:t,rules:f}),p=Array.isArray(h)?h:[h];o.push(...p)}}const u=z(r,"addPasteRules",s);if(jc(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=Fk({editor:t,rules:f});o.push(...h)}}const d=z(r,"addProseMirrorPlugins",s);if(d){const f=d();o.push(...f)}return o})}get attributes(){return Mf(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Mn(this.extensions);return Object.fromEntries(e.filter(n=>!!z(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:fe(n.name,this.schema)},o=z(n,"addNodeView",s);if(!o)return[];const i=o();if(!i)return[];const l=(a,c,u,d,f)=>{const h=On(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 fs([...this.extensions].reverse()).reduceRight((r,s)=>{const o={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Lr(s.name,this.schema)},i=z(s,"dispatchTransaction",o);return i?l=>{i.call(o,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Mn(this.extensions);return Object.fromEntries(e.filter(n=>!!z(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:at(n.name,this.schema)},o=z(n,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const u=On(l,r);return o()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{tw(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:Lr(e.name,this.schema)};e.type==="mark"&&((n=Q(z(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=z(e,"onBeforeCreate",r),o=z(e,"onCreate",r),i=z(e,"onUpdate",r),l=z(e,"onSelectionUpdate",r),a=z(e,"onTransaction",r),c=z(e,"onFocus",r),u=z(e,"onBlur",r),d=z(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)})}};uo.resolve=Of;uo.sort=fs;uo.flatten=Ll;var Vk={};jl(Vk,{ClipboardTextSerializer:()=>Bf,Commands:()=>Ff,Delete:()=>Vf,Drop:()=>Hf,Editable:()=>Wf,FocusEvents:()=>Uf,Keymap:()=>Kf,Paste:()=>Jf,Tabindex:()=>Gf,TextDirection:()=>Xf,focusEventsPluginKey:()=>qf});var ue=class zf extends zl{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new zf(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Bf=ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new oe({key:new ce("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=If(n);return Af(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ff=ue.create({name:"commands",addCommands(){return{...bf}}}),Vf=ue.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=Nf(t.before,[t,...e]);jf(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,(p,g)=>{const y=g+p.nodeSize-2,x=h.oldRange.from<=g&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,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,p)=>{var g,y;if(h instanceof qe){const x=f.slice(p).map(h.from,-1),b=f.slice(p).map(h.to),k=f.invert().map(x,-1),C=f.invert().map(b),w=(g=u.doc.nodeAt(x-1))==null?void 0:g.marks.some(v=>v.eq(h.mark)),S=(y=u.doc.nodeAt(b))==null?void 0:y.marks.some(v=>v.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:C},newRange:{from:x,to:b},partial:!!(S||w),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()}}),Hf=ue.create({name:"drop",addProseMirrorPlugins(){return[new oe({key:new ce("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Wf=ue.create({name:"editable",addProseMirrorPlugins(){return[new oe({key:new ce("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qf=new ce("focusEvents"),Uf=ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new oe({key:qf,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}}}})]}}),Kf=ue.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,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,x=g&&p.parent.childCount===1?y===d.pos:q.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 pr()||Cf()?o:s},addProseMirrorPlugins(){return[new oe({key:new ce("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=q.atStart(e.doc).from,c=q.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!ao(n.doc))return;const f=n.tr,h=so({state:n,transaction:f}),{commands:p}=new oo({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Jf=ue.create({name:"paste",addProseMirrorPlugins(){return[new oe({key:new ce("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Gf=ue.create({name:"tabindex",addProseMirrorPlugins(){return[new oe({key:new ce("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Xf=ue.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Mn(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 oe({key:new ce("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Hk=class gn{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 gn(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 gn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new gn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((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 gn(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new gn(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)}},Wk=`.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 qk(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 Uk=class extends Rk{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:ck,createMappablePosition:uk},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=vf(e,this.options.autofocus);this.editorState=kn.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=qk(Wk,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=Tf(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?[Wf,Bf.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ff,Uf,Kf,Gf,Hf,Jf,Vf,Xf.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 uo(r,this)}createCommandManager(){this.commandManager=new oo({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Oi(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=Oi(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 yf(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 Rf(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return ik(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return $l(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
108
-
109
- `,textSerializers:n={}}=t||{};return ek(this.state.doc,{blockSeparator:e,textSerializers:{...If(this.schema),...n}})}get isEmpty(){return ao(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 Hk(e,this)}get $doc(){return this.$pos(0)}};function An(t){return new co({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Q(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(_l(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 Kk(t){return new co({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Q(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 Ii(t){return new co({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),o=Q(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 In(t){return new co({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const o=Q(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),a=i.doc.resolve(n.from).blockRange(),c=a&&yl(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,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.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&&Ot(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&i.join(n.from-1)},undoable:t.undoable})}function Jk(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof B){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 Gk(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Xk={};jl(Xk,{createAtomBlockMarkdownSpec:()=>Yk,createBlockMarkdownSpec:()=>Qk,createInlineMarkdownSpec:()=>Yf,parseAttributes:()=>Bl,parseIndentedBlocks:()=>Ri,renderNestedMarkdownContent:()=>Vl,serializeAttributes:()=>Fl});function Bl(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 Fl(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 Yk(t){const{nodeName:e,name:n,parseAttributes:r=Bl,serializeAttributes:s=Fl,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|$)`),p=u.match(h);if(!p)return;const g=p[1]||"",y=r(g);if(!i.find(b=>!(b in y)))return{type:e,raw:p[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=s(d),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function Qk(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Bl,serializeAttributes:o=Fl,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 p={...i,...d.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=d.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,h){var p;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=d.match(g);if(!y)return;const[x,b=""]=y,k=s(b);let C=1;const w=x.length;let S="";const v=/^:::([\w-]*)(\s.*)?/gm,M=d.slice(w);for(v.lastIndex=0;;){const T=v.exec(M);if(T===null)break;const I=T.index,D=T[1];if(!((p=T[2])!=null&&p.endsWith(":::"))){if(D)C+=1;else if(C-=1,C===0){const $=M.slice(0,I);S=$.trim();const V=d.slice(0,w+I+T[0].length);let F=[];if(S)if(l==="block")for(F=h.blockTokens($),F.forEach(P=>{P.text&&(!P.tokens||P.tokens.length===0)&&(P.tokens=h.inlineTokens(P.text))});F.length>0;){const P=F[F.length-1];if(P.type==="paragraph"&&(!P.text||P.text.trim()===""))F.pop();else break}else F=h.inlineTokens(S);return{type:e,raw:V,attributes:k,content:S,tokens:F}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),p=o(h),g=p?` {${p}}`:"",y=f.renderChildren(d.content||[],`
110
-
111
- `);return`:::${c}${g}
112
-
113
- ${y}
114
-
115
- :::`}}}function Zk(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 ew(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function Yf(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Zk,serializeAttributes:o=ew,defaultAttributes:i={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=f=>{if(!a)return f;const h={};return a.forEach(p=>{const g=typeof p=="string"?p:p.name,y=typeof p=="string"?void 0:p.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 p={...i,...f.attributes};if(l)return h.createNode(e,p);const g=r?r(f):f.content||"";return g?h.createNode(e,p,[h.createTextNode(g)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=f.match(h),g=p?.index;return g!==void 0?g:-1},tokenize(f,h,p){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[,C]=y;b=C}else{const[,C,w]=y;b=C,x=w||""}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 p=u(f.attrs||{}),g=o(p),y=g?` ${g}`:"";return l?`[${c}${y}]`:`[${c}${y}]${h}[/${c}]`}}}function Ri(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 p=e.extractItemData(h),{indentLevel:g,mainContent:y}=p;c=`${c}${f}
118
- `;const x=[y];for(u+=1;u<l.length;){const w=l[u];if(w.trim()===""){const v=l.slice(u+1).findIndex(I=>I.trim()!=="");if(v===-1)break;if((((s=(r=l[u+1+v].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){x.push(w),c=`${c}${w}
119
- `,u+=1;continue}else break}if((((i=(o=w.match(/^(\s*)/))==null?void 0:o[1])==null?void 0:i.length)||0)>g)x.push(w),c=`${c}${w}
120
- `,u+=1;else break}let b;const k=x.slice(1);if(k.length>0){const w=k.map(S=>S.slice(g+d)).join(`
121
- `);w.trim()&&(e.customNestedParser?b=e.customNestedParser(w):b=n.blockTokens(w))}const C=e.createToken(p,b);a.push(C)}if(a.length!==0)return{items:a,raw:c}}function Vl(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 tw(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 Ie=class Qf extends zl{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Qf(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},nw=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(),C=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,w=(i=t.offsetY)!=null?i:(o=t.nativeEvent)==null?void 0:o.offsetY;d=k.x-b.x+C,f=k.y-b.y+w}const h=this.dom.cloneNode(!0);try{const b=this.dom.getBoundingClientRect();h.style.width=`${Math.round(b.width)}px`,h.style.height=`${Math.round(b.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(h,d,f)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=B.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=B.isSelectable(this.node),d=t.type==="copy",f=t.type==="paste",h=t.type==="cut",p=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&&p){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||p&&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"&&(pr()||Mi())&&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 Xt(t){return new $k({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const o=Q(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(_l(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.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 rw=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},sw=({contentComponent:t})=>{const e=su.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function ow(){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]:cp.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 iw=class extends X.Component{constructor(t){var e;super(t),this.editorContentRef=X.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=ow(),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 m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:rw(e,this.editorContentRef),...n}),t?.contentComponent&&m.jsx(sw,{contentComponent:t.contentComponent})]})}},lw=E.forwardRef((t,e)=>{const n=X.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return X.createElement(iw,{key:n,innerRef:e,...t})}),aw=X.memo(lw),cw=typeof window<"u"?E.useLayoutEffect:E.useEffect,uw=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 dw(t){var e;const[n]=E.useState(()=>new uw(t.editor)),r=ap.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:Hm);return cw(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var fw=!1,ji=typeof window>"u",hw=ji||!!(typeof window<"u"&&window.next),pw=class Zf{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||hw?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 Uk(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?Zf.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 mw(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new pw(n)),s=su.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),dw({editor:s,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),s}var gw=E.createContext({editor:null});gw.Consumer;var eh=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),yw=()=>E.useContext(eh),Lc=X.forwardRef((t,e)=>{const{onDragStart:n}=yw(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function $c(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function _c(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function xw(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function bw(t){if($c(t)||_c(t))return!0;if(xw(t)){const e=t.type;if(e)return $c(e)||_c(e)}return!1}function kw(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var th=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?lp.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=kw(),o=bw(e),i={...n};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=m.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])})}};X.createContext({markViewContentRef:()=>{}});var ww=class extends nw{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:E.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=E.memo(a=>m.jsx(eh.Provider,{value:r,children:E.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 th(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=On(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function vw(t,e){return n=>n.editor.contentComponent?new ww(t,n,e):{}}var hs=(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]},Sw=/^\s*>\s$/,Cw=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return hs("blockquote",{...se(this.options.HTMLAttributes,t),children:hs("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[In({find:Sw,type:this.type})]}}),Ew=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Nw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Tw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Mw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ow=Zt.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 hs("strong",{...se(this.options.HTMLAttributes,t),children:hs("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[An({find:Ew,type:this.type}),An({find:Tw,type:this.type})]},addPasteRules(){return[Xt({find:Nw,type:this.type}),Xt({find:Mw,type:this.type})]}}),Aw=/(^|[^`])`([^`]+)`(?!`)$/,Iw=/(^|[^`])`([^`]+)`(?!`)/g,Rw=Zt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",se(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[An({find:Aw,type:this.type})]},addPasteRules(){return[Xt({find:Iw,type:this.type})]}}),Qo=4,jw=/^```([a-z]+)?[\s\n]$/,Dw=/^~~~([a-z]+)?[\s\n]$/,Pw=Ie.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Qo,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",se(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:Qo,{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(p=>l+p).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:Qo,{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 p=0,g=0;const y=c-u;for(let S=0;S<h.length;S+=1){if(g+h[S].length>=y){p=S;break}g+=h[S].length+1}const b=((a=h[p].match(/^ */))==null?void 0:a[0])||"",k=Math.min(b.length,n);if(k===0)return!0;let C=u;for(let S=0;S<p;S+=1)C+=h[S].length+1;return l.delete(C,C+k),c-C<=k&&l.setSelection(H.create(l.doc,C)),!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 p;const g=((p=h.match(/^ */))==null?void 0:p[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(q.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Ii({find:jw,type:this.type,getAttributes:t=>({language:t[1]})}),Ii({find:Dw,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new oe({key:new ce("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(H.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),Lw=Ie.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
146
-
147
- `):""}),$w=Ie.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",se(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()}}}),_w=Ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(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]}`,se(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=>Ii({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),zw=Ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",se(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Jk(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Df(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(H.create(i.doc,a.pos+1)):a.nodeAfter.isBlock?i.setSelection(B.create(i.doc,a.pos)):i.setSelection(H.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(H.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Kk({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Bw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Fw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Vw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Hw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ww=Zt.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",se(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[An({find:Bw,type:this.type}),An({find:Vw,type:this.type})]},addPasteRules(){return[Xt({find:Fw,type:this.type}),Xt({find:Hw,type:this.type})]}});const qw="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Uw="ελ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",Di="numeric",Pi="ascii",Li="alpha",Zn="asciinumeric",Kn="alphanumeric",$i="domain",nh="emoji",Kw="scheme",Jw="slashscheme",Zo="whitespace";function Gw(t,e){return t in e||(e[t]=[]),e[t]}function Lt(t,e,n){e[Di]&&(e[Zn]=!0,e[Kn]=!0),e[Pi]&&(e[Zn]=!0,e[Li]=!0),e[Zn]&&(e[Kn]=!0),e[Li]&&(e[Kn]=!0),e[Kn]&&(e[$i]=!0),e[nh]&&(e[$i]=!0);for(const r in e){const s=Gw(r,n);s.indexOf(t)<0&&s.push(t)}}function Xw(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Oe(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Oe.groups={};Oe.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||Oe.groups;let s;return e&&e.j?s=e:(s=new Oe(e),n&&r&&Lt(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||Oe.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 Oe,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new Oe,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(Xw(i.t,r),n);Lt(o,a,r)}else n&&Lt(o,n,r);i.t=o}return s.j[t]=i,i}};const W=(t,e,n,r,s)=>t.ta(e,n,r,s),le=(t,e,n,r,s)=>t.tr(e,n,r,s),zc=(t,e,n,r,s)=>t.ts(e,n,r,s),A=(t,e,n,r,s)=>t.tt(e,n,r,s),rt="WORD",_i="UWORD",rh="ASCIINUMERICAL",sh="ALPHANUMERICAL",gr="LOCALHOST",zi="TLD",Bi="UTLD",Jr="SCHEME",yn="SLASH_SCHEME",Hl="NUM",Fi="WS",Wl="NL",er="OPENBRACE",tr="CLOSEBRACE",ps="OPENBRACKET",ms="CLOSEBRACKET",gs="OPENPAREN",ys="CLOSEPAREN",xs="OPENANGLEBRACKET",bs="CLOSEANGLEBRACKET",ks="FULLWIDTHLEFTPAREN",ws="FULLWIDTHRIGHTPAREN",vs="LEFTCORNERBRACKET",Ss="RIGHTCORNERBRACKET",Cs="LEFTWHITECORNERBRACKET",Es="RIGHTWHITECORNERBRACKET",Ns="FULLWIDTHLESSTHAN",Ts="FULLWIDTHGREATERTHAN",Ms="AMPERSAND",Os="APOSTROPHE",As="ASTERISK",pt="AT",Is="BACKSLASH",Rs="BACKTICK",js="CARET",yt="COLON",ql="COMMA",Ds="DOLLAR",Ke="DOT",Ps="EQUALS",Ul="EXCLAMATION",Le="HYPHEN",nr="PERCENT",Ls="PIPE",$s="PLUS",_s="POUND",rr="QUERY",Kl="QUOTE",oh="FULLWIDTHMIDDLEDOT",Jl="SEMI",Je="SLASH",sr="TILDE",zs="UNDERSCORE",ih="EMOJI",Bs="SYM";var lh=Object.freeze({__proto__:null,ALPHANUMERICAL:sh,AMPERSAND:Ms,APOSTROPHE:Os,ASCIINUMERICAL:rh,ASTERISK:As,AT:pt,BACKSLASH:Is,BACKTICK:Rs,CARET:js,CLOSEANGLEBRACKET:bs,CLOSEBRACE:tr,CLOSEBRACKET:ms,CLOSEPAREN:ys,COLON:yt,COMMA:ql,DOLLAR:Ds,DOT:Ke,EMOJI:ih,EQUALS:Ps,EXCLAMATION:Ul,FULLWIDTHGREATERTHAN:Ts,FULLWIDTHLEFTPAREN:ks,FULLWIDTHLESSTHAN:Ns,FULLWIDTHMIDDLEDOT:oh,FULLWIDTHRIGHTPAREN:ws,HYPHEN:Le,LEFTCORNERBRACKET:vs,LEFTWHITECORNERBRACKET:Cs,LOCALHOST:gr,NL:Wl,NUM:Hl,OPENANGLEBRACKET:xs,OPENBRACE:er,OPENBRACKET:ps,OPENPAREN:gs,PERCENT:nr,PIPE:Ls,PLUS:$s,POUND:_s,QUERY:rr,QUOTE:Kl,RIGHTCORNERBRACKET:Ss,RIGHTWHITECORNERBRACKET:Es,SCHEME:Jr,SEMI:Jl,SLASH:Je,SLASH_SCHEME:yn,SYM:Bs,TILDE:sr,TLD:zi,UNDERSCORE:zs,UTLD:Bi,UWORD:_i,WORD:rt,WS:Fi});const tt=/[a-z]/,Vn=new RegExp("\\p{L}","u"),ei=new RegExp("\\p{Emoji}","u"),nt=/\d/,ti=/\s/,Bc="\r",ni=`
150
- `,Yw="️",Qw="‍",ri="";let Br=null,Fr=null;function Zw(t=[]){const e={};Oe.groups=e;const n=new Oe;Br==null&&(Br=Fc(qw)),Fr==null&&(Fr=Fc(Uw)),A(n,"'",Os),A(n,"{",er),A(n,"}",tr),A(n,"[",ps),A(n,"]",ms),A(n,"(",gs),A(n,")",ys),A(n,"<",xs),A(n,">",bs),A(n,"(",ks),A(n,")",ws),A(n,"「",vs),A(n,"」",Ss),A(n,"『",Cs),A(n,"』",Es),A(n,"<",Ns),A(n,">",Ts),A(n,"&",Ms),A(n,"*",As),A(n,"@",pt),A(n,"`",Rs),A(n,"^",js),A(n,":",yt),A(n,",",ql),A(n,"$",Ds),A(n,".",Ke),A(n,"=",Ps),A(n,"!",Ul),A(n,"-",Le),A(n,"%",nr),A(n,"|",Ls),A(n,"+",$s),A(n,"#",_s),A(n,"?",rr),A(n,'"',Kl),A(n,"/",Je),A(n,";",Jl),A(n,"~",sr),A(n,"_",zs),A(n,"\\",Is),A(n,"・",oh);const r=le(n,nt,Hl,{[Di]:!0});le(r,nt,r);const s=le(r,tt,rh,{[Zn]:!0}),o=le(r,Vn,sh,{[Kn]:!0}),i=le(n,tt,rt,{[Pi]:!0});le(i,nt,s),le(i,tt,i),le(s,nt,s),le(s,tt,s);const l=le(n,Vn,_i,{[Li]:!0});le(l,tt),le(l,nt,o),le(l,Vn,l),le(o,nt,o),le(o,tt),le(o,Vn,o);const a=A(n,ni,Wl,{[Zo]:!0}),c=A(n,Bc,Fi,{[Zo]:!0}),u=le(n,ti,Fi,{[Zo]:!0});A(n,ri,u),A(c,ni,a),A(c,ri,u),le(c,ti,u),A(u,Bc),A(u,ni),le(u,ti,u),A(u,ri,u);const d=le(n,ei,ih,{[nh]:!0});A(d,"#"),le(d,ei,d),A(d,Yw,d);const f=A(d,Qw);A(f,"#"),le(f,ei,d);const h=[[tt,i],[nt,s]],p=[[tt,null],[Vn,l],[nt,o]];for(let g=0;g<Br.length;g++)ut(n,Br[g],zi,rt,h);for(let g=0;g<Fr.length;g++)ut(n,Fr[g],Bi,_i,p);Lt(zi,{tld:!0,ascii:!0},e),Lt(Bi,{utld:!0,alpha:!0},e),ut(n,"file",Jr,rt,h),ut(n,"mailto",Jr,rt,h),ut(n,"http",yn,rt,h),ut(n,"https",yn,rt,h),ut(n,"ftp",yn,rt,h),ut(n,"ftps",yn,rt,h),Lt(Jr,{scheme:!0,ascii:!0},e),Lt(yn,{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]?{[Kw]:!0}:{[Jw]:!0};y.indexOf("-")>=0?b[$i]=!0:tt.test(y)?nt.test(y)?b[Zn]=!0:b[Pi]=!0:b[Di]=!0,zc(n,y,y,b)}return zc(n,"localhost",gr,{ascii:!0}),n.jd=new Oe(Bs),{start:n,tokens:Object.assign({groups:e},lh)}}function ah(t,e){const n=ev(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 ev(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 ut(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 Oe(r),o.jr=s.slice(),t.j[a]=o),t=o}return o=new Oe(n),o.jr=s.slice(),t.j[e[i-1]]=o,o}function Fc(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 yr={defaultProtocol:"http",events:null,format:Vc,formatHref:Vc,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Gl(t,e=null){let n=Object.assign({},yr);t&&(n=Object.assign(n,t instanceof Gl?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}Gl.prototype={o:yr,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]:yr[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 Vc(t){return t}function ch(t,e){this.t="token",this.v=t,this.tk=e}ch.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=yr.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 fo(t,e){class n extends ch{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 Hc=fo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Wc=fo("text"),tv=fo("nl"),Vr=fo("url",{isLink:!0,toHref(t=yr.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==gr&&t[1].t===yt}}),Pe=t=>new Oe(t);function nv({groups:t}){const e=t.domain.concat([Ms,As,pt,Is,Rs,js,Ds,Ps,Le,Hl,nr,Ls,$s,_s,Je,Bs,sr,zs]),n=[Os,yt,ql,Ke,Ul,nr,rr,Kl,Jl,xs,bs,er,tr,ms,ps,gs,ys,ks,ws,vs,Ss,Cs,Es,Ns,Ts],r=[Ms,Os,As,Is,Rs,js,Ds,Ps,Le,er,tr,nr,Ls,$s,_s,rr,Je,Bs,sr,zs],s=Pe(),o=A(s,sr);W(o,r,o),W(o,t.domain,o);const i=Pe(),l=Pe(),a=Pe();W(s,t.domain,i),W(s,t.scheme,l),W(s,t.slashscheme,a),W(i,r,o),W(i,t.domain,i);const c=A(i,pt);A(o,pt,c),A(l,pt,c),A(a,pt,c);const u=A(o,Ke);W(u,r,o),W(u,t.domain,o);const d=Pe();W(c,t.domain,d),W(d,t.domain,d);const f=A(d,Ke);W(f,t.domain,d);const h=Pe(Hc);W(f,t.tld,h),W(f,t.utld,h),A(c,gr,h);const p=A(d,Le);A(p,Le,p),W(p,t.domain,d),W(h,t.domain,d),A(h,Ke,f),A(h,Le,p);const g=A(h,yt);W(g,t.numeric,Hc);const y=A(i,Le),x=A(i,Ke);A(y,Le,y),W(y,t.domain,i),W(x,r,o),W(x,t.domain,i);const b=Pe(Vr);W(x,t.tld,b),W(x,t.utld,b),W(b,t.domain,i),W(b,r,o),A(b,Ke,x),A(b,Le,y),A(b,pt,c);const k=A(b,yt),C=Pe(Vr);W(k,t.numeric,C);const w=Pe(Vr),S=Pe();W(w,e,w),W(w,n,S),W(S,e,w),W(S,n,S),A(b,Je,w),A(C,Je,w);const v=A(l,yt),M=A(a,yt),T=A(M,Je),I=A(T,Je);W(l,t.domain,i),A(l,Ke,x),A(l,Le,y),W(a,t.domain,i),A(a,Ke,x),A(a,Le,y),W(v,t.domain,w),A(v,Je,w),A(v,rr,w),W(I,t.domain,w),W(I,e,w),A(I,Je,w);const D=[[er,tr],[ps,ms],[gs,ys],[xs,bs],[ks,ws],[vs,Ss],[Cs,Es],[Ns,Ts]];for(let $=0;$<D.length;$++){const[V,F]=D[$],P=A(w,V);A(S,V,P),A(P,F,w);const N=Pe(Vr);W(P,e,N);const _=Pe();W(P,n),W(N,e,N),W(N,n,_),W(_,e,N),W(_,n,_),A(N,F,w),A(_,F,w)}return A(s,gr,b),A(s,Wl,tv),{start:s,tokens:lh}}function rv(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(si(Wc,e,i)),i=[]),s-=f,u-=f;const h=d.t,p=n.slice(s-u,s);o.push(si(h,e,p))}}return i.length>0&&o.push(si(Wc,e,i)),o}function si(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 sv=typeof console<"u"&&console&&console.warn||(()=>{}),ov="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ne={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function iv(){return Oe.groups={},ne.scanner=null,ne.parser=null,ne.tokenQueue=[],ne.pluginQueue=[],ne.customSchemes=[],ne.initialized=!1,ne}function qc(t,e=!1){if(ne.initialized&&sv(`linkifyjs: already initialized - will not register custom scheme "${t}" ${ov}`),!/^[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`);ne.customSchemes.push([t,e])}function lv(){ne.scanner=Zw(ne.customSchemes);for(let t=0;t<ne.tokenQueue.length;t++)ne.tokenQueue[t][1]({scanner:ne.scanner});ne.parser=nv(ne.scanner.tokens);for(let t=0;t<ne.pluginQueue.length;t++)ne.pluginQueue[t][1]({scanner:ne.scanner,parser:ne.parser});return ne.initialized=!0,ne}function Xl(t){return ne.initialized||lv(),rv(ne.parser.start,t,ah(ne.scanner.start,t))}Xl.scan=ah;function uh(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 Gl(n),s=Xl(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 Yl="[\0-   ᠎ -\u2029  ]",av=new RegExp(Yl),cv=new RegExp(`${Yl}$`),uv=new RegExp(Yl,"g");function dv(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function fv(t){return new oe({key:new ce("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=Nf(n.doc,[...e]);if(jf(l).forEach(({newRange:c})=>{const u=Jb(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(!cv.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(av).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;const y=Xl(p).map(x=>x.toObject(t.defaultProtocol));if(!dv(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=>{_l(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 hv(t){return new oe({key:new ce("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=Rf(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 pv(t){return new oe({key:new ce("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=uh(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 It(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(uv,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var mv=Zt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){qc(t);return}qc(t.scheme,t.optionalSlashes)})},onDestroy(){iv()},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)=>!!It(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=>!!It(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=>!!It(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",se(this.options.HTMLAttributes,t),0]:["a",se(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=>!!It(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=>!!It(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[Xt({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=uh(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!It(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(fv({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!It(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(hv({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(pv({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),gv=Object.defineProperty,yv=(t,e)=>{for(var n in e)gv(t,n,{get:e[n],enumerable:!0})},xv="listItem",Uc="textStyle",Kc=/^\s*([-+*])\s$/,dh=Ie.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",se(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(xv,this.editor.getAttributes(Uc)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=In({find:Kc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=In({find:Kc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Uc),editor:this.editor})),[t]}}),fh=Ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",se(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)=>Vl(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)}}}),bv={};yv(bv,{findListItemPos:()=>Nr,getNextListDepth:()=>Ql,handleBackspace:()=>Vi,handleDelete:()=>Hi,hasListBefore:()=>hh,hasListItemAfter:()=>kv,hasListItemBefore:()=>ph,listItemHasSubList:()=>mh,nextListIsDeeper:()=>gh,nextListIsHigher:()=>yh});var Nr=(t,e)=>{const{$from:n}=e.selection,r=fe(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}},Ql=(t,e)=>{const n=Nr(t,e);if(!n)return!1;const[,r]=sk(e,t,n.$pos.pos+4);return r},hh=(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))},ph=(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)},mh=(t,e,n)=>{if(!n)return!1;const r=fe(t,e.schema);let s=!1;return n.descendants(o=>{o.type===r&&(s=!0)}),s},Vi=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Tt(t.state,e)&&hh(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(!Tt(t.state,e)||!ak(t.state))return!1;const r=Nr(e,t.state);if(!r)return!1;const o=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=mh(e,t.state,o);return ph(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},gh=(t,e)=>{const n=Ql(t,e),r=Nr(t,e);return!r||!n?!1:n>r.depth},yh=(t,e)=>{const n=Ql(t,e),r=Nr(t,e);return!r||!n?!1:n<r.depth},Hi=(t,e)=>{if(!Tt(t.state,e)||!lk(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:gh(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():yh(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},kv=(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)},xh=ue.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&&Hi(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&&Hi(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&&Vi(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&&Vi(t,n,r)&&(e=!0)}),e}}}}),Jc=/^(\s*)(\d+)\.\s+(.*)$/,wv=/^\s/;function vv(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],o=s.match(Jc);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(Jc))break;if(h.trim()==="")f.push(h),u+=`
155
- `,d+=1;else if(h.match(wv))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 bh(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)),p=bh(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:p,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 Sv(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 Cv="listItem",Gc="textStyle",Xc=/^(\d+)\.\s$/,kh=Ie.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML: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",se(this.options.HTMLAttributes,n),0]:["ol",se(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?Sv(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]=vv(s);if(o.length===0)return;const l=bh(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(Cv,this.editor.getAttributes(Gc)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=In({find:Xc,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=In({find:Xc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Gc)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),Ev=/^\s*(\[([( |x])?\])\s$/,Nv=Ie.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML: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",se(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 Vl(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 p=n();if(typeof p!="number")return!1;const g=h.doc.nodeAt(p);return h.setNodeMarkup(p,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=On(d,f),p=new Set(Object.keys(h)),g=this.options.HTMLAttributes;return u.forEach(y=>{p.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=p,!0}}}},addInputRules(){return[In({find:Ev,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Tv=Ie.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",se(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=Ri(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=Ri(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()}}});ue.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(dh.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(fh.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(xh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(kh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Nv.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Tv.configure(this.options.taskList)),t}});var Mv=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",se(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()}}}),Ov=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Av=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Iv=Zt.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",se(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[An({find:Ov,type:this.type})]},addPasteRules(){return[Xt({find:Av,type:this.type})]}}),Rv=Ie.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),jv=Zt.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",se(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 Dv(t={}){return new oe({view(e){return new Pv(e,t)}})}class Pv{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 p=h.getBoundingClientRect(),g=d?p.bottom:p.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.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=gd(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 ae extends q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ae.valid(r)?new ae(r):q.near(r)}content(){return j.empty}eq(e){return e instanceof ae&&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 ae(e.resolve(n.pos))}getBookmark(){return new Zl(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Lv(e)||!$v(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&&ae.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(ae.valid(a))return a}for(;;){let i=n>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!B.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(ae.valid(l))return l}return null}}}ae.prototype.visible=!1;ae.findFrom=ae.findGapCursorFrom;q.jsonID("gapcursor",ae);class Zl{constructor(e){this.pos=e}map(e){return new Zl(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ae.valid(n)?new ae(n):q.near(n)}}function wh(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function Lv(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||wh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function $v(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||wh(s.type))return!0;if(s.inlineContent)return!1}}return!0}function _v(){return new oe({props:{decorations:Vv,createSelectionBetween(t,e,n){return e.pos==n.pos&&ae.valid(n)?new ae(n):null},handleClick:Bv,handleKeyDown:zv,handleDOMEvents:{beforeinput:Fv}}})}const zv=xf({ArrowLeft:Hr("horiz",-1),ArrowRight:Hr("horiz",1),ArrowUp:Hr("vert",-1),ArrowDown:Hr("vert",1)});function Hr(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 H){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ae.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new ae(c))),!0):!1}}function Bv(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ae.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&B.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ae(r))),!0)}function Fv(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ae))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 j(s,0,0));return o.setSelection(H.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function Vv(t){if(!(t.selection instanceof ae))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",re.create(t.doc,[Se.widget(t.selection.head,e,{key:"gapcursor"})])}var Fs=200,ye=function(){};ye.prototype.append=function(e){return e.length?(e=ye.from(e),!this.length&&e||e.length<Fs&&this.leafAppend(e)||this.length<Fs&&e.leafPrepend(this)||this.appendInner(e)):this};ye.prototype.prepend=function(e){return e.length?ye.from(e).append(this):this};ye.prototype.appendInner=function(e){return new Hv(this,e)};ye.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?ye.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};ye.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ye.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)};ye.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};ye.from=function(e){return e instanceof ye?e:e&&e.length?new vh(e):ye.empty};var vh=(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<=Fs)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Fs)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})(ye);ye.empty=new vh([]);var Hv=(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})(ye);const Wv=500;class We{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 dt(d.map));let h=d.step.map(s.slice(o)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new dt(p,void 0,void 0,c.length+u.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new We(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 dt(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>Uv&&(l=qv(l,c),i-=c),new We(l.append(o),i)}remapping(e,n){let r=new cr;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 We(this.items.append(e.map(n=>new dt(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 p=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 dt(p,g,y))}else r.push(new dt(p))},s);let c=[];for(let f=n;f<i;f++)c.push(new dt(o.maps[f]));let u=this.items.slice(0,s).append(c).append(r),d=new We(u,l);return d.emptyItemCount()>Wv&&(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 dt(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 We(ye.from(s.reverse()),o)}}We.empty=new We(ye.empty,0);function qv(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let dt=class Sh{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 Sh(n.getMap().invert(),n,this.selection)}}};class mt{constructor(e,n,r,s,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const Uv=20;function Kv(t,e,n,r){let s=n.getMeta(qt),o;if(s)return s.historyState;n.getMeta(Xv)&&(t=new mt(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(qt))return i.getMeta(qt).redo?new mt(t.done.addTransform(n,void 0,r,Gr(e)),t.undone,Yc(n.mapping.maps),t.prevTime,t.prevComposition):new mt(t.done,t.undone.addTransform(n,void 0,r,Gr(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||!Jv(n,t.prevRanges)),c=i?oi(t.prevRanges,n.mapping):Yc(n.mapping.maps);return new mt(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Gr(e)),We.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new mt(t.done.rebased(n,o),t.undone.rebased(n,o),oi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new mt(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),oi(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function Jv(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 Yc(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 oi(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 Gv(t,e,n){let r=Gr(e),s=qt.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 mt(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta(qt,{redo:n,historyState:a})}let ii=!1,Qc=null;function Gr(t){let e=t.plugins;if(Qc!=e){ii=!1,Qc=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ii=!0;break}}return ii}const qt=new ce("history"),Xv=new ce("closeHistory");function Yv(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new oe({key:qt,state:{init(){return new mt(We.empty,We.empty,null,0,-1)},apply(e,n,r){return Kv(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Eh:r=="historyRedo"?Nh:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Ch(t,e){return(n,r)=>{let s=qt.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let o=Gv(s,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const Eh=Ch(!1,!0),Nh=Ch(!0,!0);ue.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new oe({key:new ce("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 Qv=ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Dv(this.options)]}});ue.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new oe({key:new ce("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!n||!r)return re.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(Se.node(c,c+a.nodeSize,{class:this.options.className}))}),re.create(t,o)}}})]}});var Zv=ue.create({name:"gapCursor",addProseMirrorPlugins(){return[_v()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Q(z(t,"allowGapCursor",n)))!=null?e:null}}});ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new oe({key:new ce("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&&ao(i);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const d=Se.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}),re.create(t,s)}}})]}});ue.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new oe({key:new ce("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Df(n.selection)||t.view.dragging?null:re.create(n.doc,[Se.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Zc({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var eS=ue.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ce(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 oe({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!Zc({node:i,types:r})},apply:(s,o)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return o;const i=s.doc.lastChild;return!Zc({node:i,types:r})}}})]}}),tS=ue.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Eh(t,e),redo:()=>({state:t,dispatch:e})=>Nh(t,e)}},addProseMirrorPlugins(){return[Yv(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()}}}),nS=ue.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(Ow.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Cw.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(dh.configure(this.options.bulletList)),this.options.code!==!1&&s.push(Rw.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Pw.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(Lw.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(Qv.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Zv.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push($w.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(_w.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(tS.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(zw.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(Ww.configure(this.options.italic)),this.options.listItem!==!1&&s.push(fh.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(xh.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(mv.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(kh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Mv.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Iv.configure(this.options.strike)),this.options.text!==!1&&s.push(Rv.configure(this.options.text)),this.options.underline!==!1&&s.push(jv.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(eS.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),rS=nS;function sS(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=t,a=r&&!s,c=Gk(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"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.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 C=k+y[0].length;return a&&u.test(p.slice(C-1,C+1))&&(y[0]+=" ",C+=1),k<l.pos&&C>=l.pos?{range:{from:k,to:C},query:y[0].slice(n.length),text:y[0]}:null}var oS=new ce("suggestion");function iS({pluginKey:t=oS,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:p=()=>!0,findSuggestionMatch:g=sS,shouldShow:y}){let x;const b=h?.(),k=()=>{const v=e.state.selection.$anchor.pos,M=e.view.coordsAtPos(v),{top:T,right:I,bottom:D,left:$}=M;try{return new DOMRect($,T,I-$,D-T)}catch{return null}},C=(v,M)=>M?()=>{const T=t.getState(e.state),I=T?.decorationId,D=v.dom.querySelector(`[data-decoration-id="${I}"]`);return D?.getBoundingClientRect()||null}:k;function w(v,M){var T;try{const D=t.getState(v.state),$=D?.decorationId?v.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,V={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:F=>d({editor:e,range:D?.range||{from:0,to:0},props:F}),decorationNode:$,clientRect:C(v,$)};(T=b?.onExit)==null||T.call(b,V)}catch{}const I=v.state.tr.setMeta(M,{exit:!0});v.dispatch(I)}const S=new oe({key:t,view(){return{update:async(v,M)=>{var T,I,D,$,V,F,P;const N=(T=this.key)==null?void 0:T.getState(M),_=(I=this.key)==null?void 0:I.getState(v.state),L=N.active&&_.active&&N.range.from!==_.range.from,J=!N.active&&_.active,Z=N.active&&!_.active,U=!J&&!Z&&N.query!==_.query,K=J||L&&U,ie=U||L,ee=Z||L&&U;if(!K&&!ie&&!ee)return;const G=ee&&!K?N:_,Ve=v.dom.querySelector(`[data-decoration-id="${G.decorationId}"]`);x={editor:e,range:G.range,query:G.query,text:G.text,items:[],command:ct=>d({editor:e,range:G.range,props:ct}),decorationNode:Ve,clientRect:C(v,Ve)},K&&((D=b?.onBeforeStart)==null||D.call(b,x)),ie&&(($=b?.onBeforeUpdate)==null||$.call(b,x)),(ie||K)&&(x.items=await f({editor:e,query:G.query})),ee&&((V=b?.onExit)==null||V.call(b,x)),ie&&((F=b?.onUpdate)==null||F.call(b,x)),K&&((P=b?.onStart)==null||P.call(b,x))},destroy:()=>{var v;x&&((v=b?.onExit)==null||v.call(b,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,M,T,I){const{isEditable:D}=e,{composing:$}=e.view,{selection:V}=v,{empty:F,from:P}=V,N={...M},_=v.getMeta(t);if(_&&_.exit)return N.active=!1,N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null,N;if(N.composing=$,D&&(F||e.view.composing)){(P<M.range.from||P>M.range.to)&&!$&&!M.composing&&(N.active=!1);const L=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:V.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;L&&p({editor:e,state:I,range:L.range,isActive:M.active})&&(!y||y({editor:e,range:L.range,query:L.query,text:L.text,transaction:v}))?(N.active=!0,N.decorationId=M.decorationId?M.decorationId:J,N.range=L.range,N.query=L.query,N.text=L.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(v,M){var T,I,D,$;const{active:V,range:F}=S.getState(v.state);if(!V)return!1;if(M.key==="Escape"||M.key==="Esc"){const N=S.getState(v.state),_=(T=x?.decorationNode)!=null?T:null,L=_??(N?.decorationId?v.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null);if(((I=b?.onKeyDown)==null?void 0:I.call(b,{view:v,event:M,range:N.range}))||!1)return!0;const Z={editor:e,range:N.range,query:N.query,text:N.text,items:[],command:U=>d({editor:e,range:N.range,props:U}),decorationNode:L,clientRect:L?()=>L.getBoundingClientRect()||null:null};return(D=b?.onExit)==null||D.call(b,Z),w(v,t),!0}return(($=b?.onKeyDown)==null?void 0:$.call(b,{view:v,event:M,range:F}))||!1},decorations(v){const{active:M,range:T,decorationId:I,query:D}=S.getState(v);if(!M)return null;const $=!D?.length,V=[a];return $&&V.push(u),re.create(v.doc,[Se.inline(T.from,T.to,{nodeName:l,class:V.join(" "),"data-decoration-id":I,"data-decoration-content":c})])}}});return S}function lS({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const s=new ce;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 Th(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>lS({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function eu(t,e){const n=Th(t),r=n.find(s=>s.char===e);return r||(n.length?n[0]:null)}var aS=Ie.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",se(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=eu(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",se({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=se({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof s=="string"?["span",se({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},...Yf({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:eu(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 ze,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 Th(this).map(iS)}}),cS=aS,li,ho="HoverCard",[Mh]=Ui(ho,[ou]),po=ou(),[uS,mo]=Mh(ho),Oh=t=>{const{__scopeHoverCard:e,children:n,open:r,defaultOpen:s,onOpenChange:o,openDelay:i=700,closeDelay:l=300}=t,a=po(e),c=E.useRef(0),u=E.useRef(0),d=E.useRef(!1),f=E.useRef(!1),[h,p]=qs({prop:r,defaultProp:s??!1,onChange:o,caller:ho}),g=E.useCallback(()=>{clearTimeout(u.current),c.current=window.setTimeout(()=>p(!0),i)},[i,p]),y=E.useCallback(()=>{clearTimeout(c.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>p(!1),l))},[l,p]),x=E.useCallback(()=>p(!1),[p]);return E.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(u.current)},[]),m.jsx(uS,{scope:e,open:h,onOpenChange:p,onOpen:g,onClose:y,onDismiss:x,hasSelectionRef:d,isPointerDownOnContentRef:f,children:m.jsx(fp,{...a,children:n})})};Oh.displayName=ho;var Ah="HoverCardTrigger",Ih=E.forwardRef((t,e)=>{const{__scopeHoverCard:n,...r}=t,s=mo(Ah,n),o=po(n);return m.jsx(up,{asChild:!0,...o,children:m.jsx(Rn.a,{"data-state":s.open?"open":"closed",...r,ref:e,onPointerEnter:He(t.onPointerEnter,Hs(s.onOpen)),onPointerLeave:He(t.onPointerLeave,Hs(s.onClose)),onFocus:He(t.onFocus,s.onOpen),onBlur:He(t.onBlur,s.onClose),onTouchStart:He(t.onTouchStart,i=>i.preventDefault())})})});Ih.displayName=Ah;var ea="HoverCardPortal",[dS,fS]=Mh(ea,{forceMount:void 0}),Rh=t=>{const{__scopeHoverCard:e,forceMount:n,children:r,container:s}=t,o=mo(ea,e);return m.jsx(dS,{scope:e,forceMount:n,children:m.jsx(Ki,{present:n||o.open,children:m.jsx(dp,{asChild:!0,container:s,children:r})})})};Rh.displayName=ea;var Vs="HoverCardContent",jh=E.forwardRef((t,e)=>{const n=fS(Vs,t.__scopeHoverCard),{forceMount:r=n.forceMount,...s}=t,o=mo(Vs,t.__scopeHoverCard);return m.jsx(Ki,{present:r||o.open,children:m.jsx(hS,{"data-state":o.open?"open":"closed",...s,onPointerEnter:He(t.onPointerEnter,Hs(o.onOpen)),onPointerLeave:He(t.onPointerLeave,Hs(o.onClose)),ref:e})})});jh.displayName=Vs;var hS=E.forwardRef((t,e)=>{const{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,...l}=t,a=mo(Vs,n),c=po(n),u=E.useRef(null),d=Ji(e,u),[f,h]=E.useState(!1);return E.useEffect(()=>{if(f){const p=document.body;return li=p.style.userSelect||p.style.webkitUserSelect,p.style.userSelect="none",p.style.webkitUserSelect="none",()=>{p.style.userSelect=li,p.style.webkitUserSelect=li}}},[f]),E.useEffect(()=>{if(u.current){const p=()=>{h(!1),a.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(a.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",p),()=>{document.removeEventListener("pointerup",p),a.hasSelectionRef.current=!1,a.isPointerDownOnContentRef.current=!1}}},[a.isPointerDownOnContentRef,a.hasSelectionRef]),E.useEffect(()=>{u.current&&gS(u.current).forEach(g=>g.setAttribute("tabindex","-1"))}),m.jsx(hp,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:i,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:He(o,p=>{p.preventDefault()}),onDismiss:a.onDismiss,children:m.jsx(pp,{...c,...l,onPointerDown:He(l.onPointerDown,p=>{p.currentTarget.contains(p.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)"}})})}),pS="HoverCardArrow",mS=E.forwardRef((t,e)=>{const{__scopeHoverCard:n,...r}=t,s=po(n);return m.jsx(mp,{...s,...r,ref:e})});mS.displayName=pS;function Hs(t){return e=>e.pointerType==="touch"?void 0:t()}function gS(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 yS=Oh,xS=Ih,bS=Rh,kS=jh;function wS(t){const e=R.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=m.jsx(yS,{"data-slot":"hover-card",...n}),e[2]=n,e[3]=r):r=e[3],r}function vS(t){const e=R.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=m.jsx(xS,{"data-slot":"hover-card-trigger",...n}),e[2]=n,e[3]=r):r=e[3],r}function SS(t){const e=R.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=Y("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=m.jsx(bS,{"data-slot":"hover-card-portal",children:m.jsx(kS,{"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 Dh=E.createContext(void 0);function CS(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 ES(t){const e=R.c(20),{node:n}=t,r=E.useContext(Dh),s=n.attrs.id??"",o=r!==void 0;let i;if(e[0]!==o||e[1]!==s||e[2]!==r){const g=o?CS(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=m.jsxs("span",{className:"bg-primary/20 text-primary px-1 rounded font-medium cursor-pointer",children:["@",s]}),e[4]=s,e[5]=a):a=e[5];const c=a;if(!o||l===void 0){let g;return e[6]!==c?(g=m.jsx(Lc,{as:"span",children:c}),e[6]=c,e[7]=g):g=e[7],g}let u;e[8]!==c?(u=m.jsx(vS,{asChild:!0,children:c}),e[8]=c,e[9]=u):u=e[9];let d;e[10]!==s?(d=m.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=m.jsx("pre",{className:"text-xs font-mono bg-muted/50 p-2 rounded overflow-auto max-h-[200px] whitespace-pre-wrap break-all",children:l}),e[12]=l,e[13]=f):f=e[13];let h;e[14]!==d||e[15]!==f?(h=m.jsx(SS,{className:"w-auto max-w-[400px] p-3",side:"top",align:"start",children:m.jsxs("div",{className:"space-y-1.5",children:[d,f]})}),e[14]=d,e[15]=f,e[16]=h):h=e[16];let p;return e[17]!==u||e[18]!==h?(p=m.jsx(Lc,{as:"span",children:m.jsxs(wS,{openDelay:200,children:[u,h]})}),e[17]=u,e[18]=h,e[19]=p):p=e[19],p}function Ph(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 Ge=Lh();function Lh(){return hl(()=>({items:[],selectedIndex:0,command:null}))}function tu(t,e){Ge.setState({items:t,command:e,selectedIndex:0})}function NS(){const{items:t,selectedIndex:e}=Ge.getState();t.length&&Ge.setState({selectedIndex:(e-1+t.length)%t.length})}function TS(){const{items:t,selectedIndex:e}=Ge.getState();t.length&&Ge.setState({selectedIndex:(e+1)%t.length})}function $h(){const{items:t,selectedIndex:e,command:n}=Ge.getState(),r=t[e];return r?(n?.(r),!0):!1}function nu(){Ge=Lh()}function MS(){const t=R.c(7),e=di(Ge,AS),n=di(Ge,OS);if(!e.length)return null;let r;if(t[0]!==e||t[1]!==n){let o;t[3]!==n?(o=(i,l)=>m.jsx("button",{type:"button",onClick:()=>{Ge.setState({selectedIndex:l}),$h()},className:Y("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=m.jsx("div",{className:"bg-popover border border-border rounded-lg shadow-lg overflow-hidden min-w-[180px]",children:m.jsx("div",{className:"p-1",children:r})}),t[5]=r,t[6]=s):s=t[6],s}function OS(t){return t.selectedIndex}function AS(t){return t.items}function IS(){let t=null,e=null;return{onStart:n=>{tu(n.items,n.command),t=new th(MS,{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=>{tu(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(),nu(),!0):n.key==="ArrowUp"?(NS(),!0):n.key==="ArrowDown"?(TS(),!0):n.key==="Enter"?$h():!1,onExit:()=>{e?.remove(),t?.destroy(),nu()}}}const ai=/@([\w.]+)/g;function RS(t,e){if(!t)return null;const n=Ph(e),r=new Map(n.map(a=>[a.id,a]));if(!ai.test(t))return t;ai.lastIndex=0;const o=[];let i=0,l;for(;(l=ai.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 ta(t){const e=R.c(31),{mentions:n,value:r,onChange:s,placeholder:o,className:i,readOnly:l}=t,a=X1();let c;e[0]!==n||e[1]!==r?(c=RS(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=rS.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,hardBreak:!1}),e[3]=h):h=e[3];let p;if(e[4]!==n||e[5]!==d){let T;e[7]!==n?(T=I=>{const{query:D}=I;return Ph(n).filter(V=>V.label.toLowerCase().includes(D.toLowerCase())||V.id.toLowerCase().includes(D.toLowerCase()))},e[7]=n,e[8]=T):T=e[8],p=cS.configure({HTMLAttributes:{class:"bg-primary/20 text-primary px-1 rounded font-medium"},renderText:LS,renderHTML:PS,suggestion:{items:T,render:IS,command:DS}}).extend(d?{addNodeView(){return vw(ES)}}:{}),e[4]=n,e[5]=d,e[6]=p}else p=e[6];let g;e[9]!==p?(g=[h,p],e[9]=p,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:jS},e[11]=y,e[12]=x):x=e[12];let b;e[13]!==s?(b=T=>{const{editor:I}=T;return s?.(I.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 C=mw(k);let w;e[21]!==i?(w=Y("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]=w):w=e[22];let S;e[23]!==C?(S=m.jsx(aw,{editor:C}),e[23]=C,e[24]=S):S=e[24];let v;e[25]!==w||e[26]!==S?(v=m.jsx("div",{className:w,children:S}),e[25]=w,e[26]=S,e[27]=v):v=e[27];const M=v;if(a!==void 0){let T;return e[28]!==M||e[29]!==a?(T=m.jsx(Dh.Provider,{value:a,children:M}),e[28]=M,e[29]=a,e[30]=T):T=e[30],T}return M}function jS(t,e){return e.key==="Enter"?(e.preventDefault(),!0):!1}function DS(t){const{editor:e,range:n,props:r}=t;e.chain().focus().insertContentAt(n,[{type:"mention",attrs:r}]).run()}function PS(t){const{options:e,node:n}=t;return["span",e.HTMLAttributes,`@${n.attrs.id}`]}function LS(t){const{node:e}=t;return`@${e.attrs.id}`}function $S(t){const e=R.c(8),{value:n,onChange:r,placeholder:s,readonly:o}=t,i=Hu(),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=m.jsx(ta,{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 _S(t){const e=R.c(8),{value:n,onChange:r,placeholder:s,readonly:o}=t,i=Hu(),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=m.jsx(ta,{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 zS(t){const e=R.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=Y("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),e[2]=a):a=e[2];let c;return e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==l?(c=m.jsx("input",{id:o,type:"number",value:i,onChange:l,disabled:s,className:a}),e[3]=o,e[4]=s,e[5]=i,e[6]=l,e[7]=c):c=e[7],c}function BS(t){const e=R.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=m.jsx("input",{id:o,type:"checkbox",checked:l,onChange:a,disabled:s,className:"h-4 w-4 rounded border-input"}),e[2]=o,e[3]=s,e[4]=l,e[5]=a,e[6]=c):c=e[6];let u;e[7]!==i?(u=m.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=m.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 FS(t){const e=R.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=Y("w-full rounded-md border border-input bg-background px-3 py-2 text-sm","ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50"),f=m.jsx("option",{value:"",children:"Select..."}),e[4]=d,e[5]=f):(d=e[4],f=e[5]);let h;e[6]!==a?(h=a.map(VS),e[6]=a,e[7]=h):h=e[7];let p;return e[8]!==o||e[9]!==s||e[10]!==c||e[11]!==u||e[12]!==h?(p=m.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]=p):p=e[13],p}function VS(t){return m.jsx("option",{value:String(t.value),children:String(t.label)},String(t.value))}const HS={TextWidget:$S,TextareaWidget:_S,NumberWidget:zS,CheckboxWidget:BS,SelectWidget:FS};function WS(t){switch(Array.isArray(t)?t[0]:t??"unknown"){case"string":return{Icon:ku,color:"text-blue-500"};case"number":case"integer":return{Icon:xu,color:"text-blue-500"};case"array":return{Icon:pu,color:"text-purple-500"};case"object":return{Icon:hu,color:"text-orange-500"};case"boolean":return{Icon:bu,color:"text-pink-500"};case"null":return{Icon:Gi,color:"text-gray-500"};default:return{Icon:yu,color:"text-muted-foreground"}}}function qS(t){const e=R.c(36),{id:n,label:r,required:s,description:o,children:i,schema:l,hidden:a}=t;if(a){let w;return e[0]!==i?(w=m.jsx("div",{className:"hidden",children:i}),e[0]=i,e[1]=w):w=e[1],w}if(n==="root"){let w;return e[2]!==i?(w=m.jsx("div",{className:"space-y-4",children:i}),e[2]=i,e[3]=w):w=e[3],w}const c=Array.isArray(l.type)?l.type[0]:l.type??"string";let u,d,f,h,p,g,y;if(e[4]!==n||e[5]!==r||e[6]!==s||e[7]!==c){const{Icon:w,color:S}=WS(c);y="space-y-2",h="flex items-center gap-2",e[15]!==n||e[16]!==r?(p=m.jsx("label",{htmlFor:n,className:"text-sm font-medium leading-none",children:r}),e[15]=n,e[16]=r,e[17]=p):p=e[17],e[18]!==s?(g=s&&m.jsx("span",{className:"text-red-500 text-xs",children:"*"}),e[18]=s,e[19]=g):g=e[19],u=w,d=14,f=Y(S,"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]=p,e[13]=g,e[14]=y}else u=e[8],d=e[9],f=e[10],h=e[11],p=e[12],g=e[13],y=e[14];let x;e[20]!==u||e[21]!==d||e[22]!==f?(x=m.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]!==p||e[26]!==g||e[27]!==x?(b=m.jsxs("div",{className:h,children:[p,g,x]}),e[24]=h,e[25]=p,e[26]=g,e[27]=x,e[28]=b):b=e[28];let k;e[29]!==o?(k=o&&m.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:o}),e[29]=o,e[30]=k):k=e[30];let C;return e[31]!==i||e[32]!==y||e[33]!==b||e[34]!==k?(C=m.jsxs("div",{className:y,children:[b,k,i]}),e[31]=i,e[32]=y,e[33]=b,e[34]=k,e[35]=C):C=e[35],C}function US(t){const e=R.c(8),{properties:n,title:r}=t;if(!r||r==="Root"){let l;e[0]!==n?(l=n.map(JS),e[0]=n,e[1]=l):l=e[1];let a;return e[2]!==l?(a=m.jsx("div",{className:"space-y-4",children:l}),e[2]=l,e[3]=a):a=e[3],a}let o;e[4]!==n?(o=n.map(KS),e[4]=n,e[5]=o):o=e[5];let i;return e[6]!==o?(i=m.jsx("div",{className:"pl-4 border-l-2 border-border/50 space-y-4",children:o}),e[6]=o,e[7]=i):i=e[7],i}function KS(t){return m.jsx("div",{children:t.content},t.name)}function JS(t){return m.jsx("div",{children:t.content},t.name)}function GS(t){const e=R.c(11),{items:n,canAdd:r,onAddClick:s,title:o}=t;let i;e[0]!==n?(i=n.map(XS),e[0]=n,e[1]=i):i=e[1];let l;e[2]!==i?(l=m.jsx("div",{className:"space-y-2",children:i}),e[2]=i,e[3]=l):l=e[3];let a;e[4]!==r||e[5]!==s||e[6]!==o?(a=r&&m.jsxs(me,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:s,children:["+ Add ",o||"item"]}),e[4]=r,e[5]=s,e[6]=o,e[7]=a):a=e[7];let c;return e[8]!==l||e[9]!==a?(c=m.jsxs("div",{className:"space-y-2",children:[l,a]}),e[8]=l,e[9]=a,e[10]=c):c=e[10],c}function XS(t){return m.jsx("div",{className:"flex gap-2 items-start",children:m.jsx("div",{className:"flex-1",children:t})},t.key||t.index)}function YS(){return null}function QS(){return null}const ZS={FieldTemplate:qS,ObjectFieldTemplate:US,ArrayFieldTemplate:GS,UnsupportedFieldTemplate:YS,ErrorListTemplate:QS};function e2(t){const e=R.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 m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-baseline gap-2",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:a}),m.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:f})]}),u.description&&m.jsx("div",{className:"text-xs text-muted-foreground",children:u.description}),m.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm",children:m.jsx(ta,{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=m.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 _h({inputSchema:t,inputParams:e,setInputParams:n,handleInputChange:r,mentions:s,readOnly:o}){const i=s??[];if(!t)return m.jsx("div",{className:"text-sm text-muted-foreground italic",children:"No arguments defined in schema."});if(o)return m.jsx(e2,{inputSchema:t,inputParams:e,mentions:i});const l=t,a=E.useRef(e??{}),c=u=>{const d=u.formData??{},f=a.current;if(n?.(d),r){for(const[h,p]of Object.entries(d))f[h]!==p&&r(h,p);for(const h of Object.keys(f))h in d||r(h,void 0)}a.current=d};return m.jsx(Vu.Provider,{value:i,children:m.jsx(Pp,{schema:l,formData:e,onChange:c,validator:Lp,widgets:HS,templates:ZS,readonly:o,uiSchema:{"ui:submitButtonOptions":{norender:!0}},liveValidate:!1,className:"rjsf-form",omitExtraData:!0,liveOmit:!0,children:m.jsx(m.Fragment,{})})})}function t2(t){const e=R.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]=E.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 p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsxs(Jp,{children:[m.jsx(Gp,{children:"Workflow Input"}),m.jsx(Xp,{children:"This workflow requires input values to run. Fill in the fields below to start the execution."})]}),e[7]=p):p=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=m.jsx("div",{className:"py-4",children:m.jsx(_h,{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=m.jsx(me,{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?m.jsx(jn,{size:"xs"}):m.jsx(ol,{size:14}),e[17]=i,e[18]=k):k=e[18];let C;e[19]!==d||e[20]!==i||e[21]!==k?(C=m.jsxs(me,{onClick:d,disabled:i,className:"gap-2",children:[k,"Run Workflow"]}),e[19]=d,e[20]=i,e[21]=k,e[22]=C):C=e[22];let w;e[23]!==C||e[24]!==b?(w=m.jsxs(Yp,{children:[b,C]}),e[23]=C,e[24]=b,e[25]=w):w=e[25];let S;e[26]!==w||e[27]!==y?(S=m.jsxs(Qp,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[p,y,w]}),e[26]=w,e[27]=y,e[28]=S):S=e[28];let v;return e[29]!==h||e[30]!==n||e[31]!==S?(v=m.jsx(Zp,{open:n,onOpenChange:h,children:S}),e[29]=h,e[30]=n,e[31]=S,e[32]=v):v=e[32],v}function n2(t){const e=R.c(26),{title:n,description:r,onSave:s}=t,i=qi().location.href,{viewMode:l,setViewMode:a,showExecutionsList:c,toggleExecutionsList:u}=pl(),{resetToOriginalWorkflow:d,setSelectedGatewayId:f}=Me(),h=ju(),p=Ln(),g=we();let y;e[0]!==n?(y=m.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?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"•"}),m.jsx("span",{className:"text-xs text-muted-foreground font-normal truncate min-w-0 max-w-[20ch]",children:r})]}):null,e[2]=r,e[3]=x):x=e[3];let b;e[4]!==y||e[5]!==x?(b=m.jsx(du,{children:m.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]!==p||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&&m.jsxs(m.Fragment,{children:[m.jsx(Zi,{title:n,url:i,icon:"workflow"}),m.jsx(E.Suspense,{fallback:m.jsx(jn,{size:"xs"}),children:m.jsx(Vp,{selectedGatewayId:p??void 0,onGatewayChange:f,variant:"bordered",placeholder:"Select Hub"})}),m.jsx(qp,{value:l,onValueChange:a,size:"sm",options:[{value:"visual",icon:m.jsx(Up,{})},{value:"code",icon:m.jsx(Su,{})}]}),m.jsx(zt,{children:m.jsxs(Bt,{delayDuration:0,children:[m.jsx($t,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:d,disabled:!h,"aria-label":"Reset changes",children:m.jsx(uu,{size:14})})})}),m.jsx(_t,{side:"bottom",children:"Reset changes"})]})}),m.jsx(zt,{children:m.jsxs(Bt,{delayDuration:0,children:[m.jsx($t,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:"outline",size:"icon",className:"size-7 border border-input",onClick:s,disabled:!h,"aria-label":"Save workflow",children:m.jsx(fl,{size:14})})})}),m.jsx(_t,{side:"bottom",children:"Save workflow"})]})}),m.jsx(zt,{children:m.jsxs(Bt,{delayDuration:0,children:[m.jsx($t,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:m.jsx(me,{variant:c?"secondary":"outline",size:"icon",className:"size-7 border border-input",onClick:u,"aria-label":c?"Hide runs":"Show runs",children:m.jsx(vu,{size:14})})})}),m.jsx(_t,{side:"bottom",children:c?"Hide runs":"Show runs"})]})})]}),e[7]=h,e[8]=s,e[9]=d,e[10]=p,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 C;e[20]===Symbol.for("react.memo_cache_sentinel")?(C=m.jsx(o2,{}),e[20]=C):C=e[20];let w;e[21]!==k?(w=m.jsxs(sl,{children:[k,C]}),e[21]=k,e[22]=w):w=e[22];let S;return e[23]!==b||e[24]!==w?(S=m.jsxs(m.Fragment,{children:[b,w]}),e[23]=b,e[24]=w,e[25]=S):S=e[25],S}function r2(){const t=we(),{item:e}=vr(t);return e?.completed_at_epoch_ms!=null}function s2(){const t=we(),{item:e}=vr(t);return e?.status==="cancelled"}function o2(){const t=R.c(57),e=ju(),n=r2(),r=s2(),s=we(),o=Ln(),{handleRunWorkflow:i,isPending:l,requiresInput:a,inputSchema:c}=K1(),u=kr(),[d,f]=E.useState(!1),{handleCancelWorkflow:h,isCancelling:p}=J1(),{handleResumeWorkflow:g,isResuming:y}=G1(),x=s&&!n;let b;t[0]!==u?(b=u.some(i2),t[0]=u,t[1]=b):b=t[1];const k=b,C=!o,w=e||k||C||l||p,S=x||l;let v;t[2]!==k||t[3]!==C||t[4]!==e||t[5]!==r||t[6]!==S?(v=()=>r?"Workflow is currently cancelled":S?"Workflow is currently running":e?"Save your changes before running":C?"Select a Hub first":k?"Add at least one step to the workflow":null,t[2]=k,t[3]=C,t[4]=e,t[5]=r,t[6]=S,t[7]=v):v=t[7];const T=v();let I;t[8]!==h||t[9]!==g||t[10]!==i||t[11]!==c||t[12]!==r||t[13]!==S||t[14]!==a||t[15]!==s?(I=async()=>{if(a&&c){f(!0);return}if(r&&s){await g(s);return}if(S&&s){await h(s);return}await i({})},t[8]=h,t[9]=g,t[10]=i,t[11]=c,t[12]=r,t[13]=S,t[14]=a,t[15]=s,t[16]=I):I=t[16];const D=I;let $;t[17]!==i?($=async Ve=>{await i(Ve)},t[17]=i,t[18]=$):$=t[18];const V=$,F=r?"Resume":s?n?"Replay":"Running...":a?"Run with input...":"Run workflow",P=!x&&"bg-primary text-primary-foreground hover:bg-primary/90";let N;t[19]!==P?(N=Y("gap-2 h-7 px-3",P),t[19]=P,t[20]=N):N=t[20];let _;t[21]!==p||t[22]!==r||t[23]!==l||t[24]!==y||t[25]!==x?(_=(!x&&!l&&!p&&!y||r)&&m.jsx(ol,{size:14}),t[21]=p,t[22]=r,t[23]=l,t[24]=y,t[25]=x,t[26]=_):_=t[26];let L;t[27]!==p||t[28]!==r||t[29]!==l||t[30]!==y||t[31]!==x?(L=x&&!l&&!p&&!y&&!r&&m.jsx(Kp,{size:14}),t[27]=p,t[28]=r,t[29]=l,t[30]=y,t[31]=x,t[32]=L):L=t[32];let J;t[33]!==p||t[34]!==l||t[35]!==y?(J=(l||p||y)&&m.jsx(jn,{size:"xs"}),t[33]=p,t[34]=l,t[35]=y,t[36]=J):J=t[36];let Z;t[37]!==F||t[38]!==D||t[39]!==w||t[40]!==N||t[41]!==_||t[42]!==L||t[43]!==J?(Z=m.jsxs(me,{variant:"default",size:"sm",className:N,disabled:w,onClick:D,children:[_,L,J,F]}),t[37]=F,t[38]=D,t[39]=w,t[40]=N,t[41]=_,t[42]=L,t[43]=J,t[44]=Z):Z=t[44];const U=Z;let K;t[45]!==U||t[46]!==T?(K=T?m.jsx(zt,{children:m.jsxs(Bt,{delayDuration:0,children:[m.jsx($t,{asChild:!0,children:m.jsx("span",{className:"inline-block",children:U})}),m.jsx(_t,{side:"bottom",children:T})]})}):U,t[45]=U,t[46]=T,t[47]=K):K=t[47];const ie=K;let ee;t[48]!==V||t[49]!==c||t[50]!==l||t[51]!==a||t[52]!==d?(ee=a&&c&&m.jsx(t2,{open:d,onOpenChange:f,inputSchema:c,onSubmit:V,isPending:l}),t[48]=V,t[49]=c,t[50]=l,t[51]=a,t[52]=d,t[53]=ee):ee=t[53];let G;return t[54]!==ie||t[55]!==ee?(G=m.jsxs(m.Fragment,{children:[ie,ee]}),t[54]=ie,t[55]=ee,t[56]=G):G=t[56],G}function i2(t){return"toolName"in t.action&&(!t.action.toolName||t.action.toolName==="")}function l2(){const t=R.c(17),e=we(),n=kr(),{item:r}=vr(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 p="pending";u.has(f.name)?p="error":l.has(f.name)?p="success":r.status==="running"&&h===d+1&&(p="running"),s[f.name]={status:p,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 a2(t){const e=R.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}=vr(d),h=f?.completed_at_epoch_ms;let p;e[0]!==f?.completed_steps?.success||e[1]!==n.name?(p=f?.completed_steps?.success?.includes(n.name)??!1,e[0]=f?.completed_steps?.success,e[1]=n.name,e[2]=p):p=e[2];const g=p;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,w=!!(b&&"toolName"in n.action?n.action.toolName:null);let S,v,M,T,I,D,$,V,F,P,N;if(e[6]!==k||e[7]!==o||e[8]!==w||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 U=b2(n);S=g?"success":x?"error":o?.status;const K=o!==void 0,ie=S==="success"||S==="error";let ee=U.length>0?60:12;(S==="success"||S==="error")&&(ee=ee+32);let G,Ve,ct;if(e[32]!==s||e[33]!==i||e[34]!==a||e[35]!==S){const zn=d2(S);let Tr;e[44]!==S?(Tr=f2(S),e[44]=S,e[45]=Tr):Tr=e[45],G=Tr;const wo=s&&"bg-background border-1 border-border outline outline-offset-3 outline-border/25",vo=S==="running"&&"bg-accent/50",So=i&&"opacity-50";e[46]!==wo||e[47]!==vo||e[48]!==So?(V=Y("flex gap-2 items-start border-1 border-transparent px-4 w-full rounded-lg cursor-pointer group hover:bg-accent/30",wo,vo,So),e[46]=wo,e[47]=vo,e[48]=So,e[49]=V):V=e[49],F=a,P="button",N=0,e[50]!==a?(v=Co=>{(Co.key==="Enter"||Co.key===" ")&&(Co.preventDefault(),a())},e[50]=a,e[51]=v):v=e[51],ct="w-5 flex flex-col items-center justify-center shrink-0 pt-3",Ve=Y("text-xs font-mono opacity-75 h-8 flex items-center",zn),e[32]=s,e[33]=i,e[34]=a,e[35]=S,e[36]=G,e[37]=v,e[38]=Ve,e[39]=ct,e[40]=V,e[41]=F,e[42]=P,e[43]=N}else G=e[36],v=e[37],Ve=e[38],ct=e[39],V=e[40],F=e[41],P=e[42],N=e[43];const bo=r+1;let en;e[52]!==Ve||e[53]!==bo?(en=m.jsxs("span",{className:Ve,children:[bo,"."]}),e[52]=Ve,e[53]=bo,e[54]=en):en=e[54],e[55]!==ct||e[56]!==en?(M=m.jsx("div",{className:ct,children:en}),e[55]=ct,e[56]=en,e[57]=M):M=e[57];let tn;e[58]!==G||e[59]!==r?(tn=r>0?m.jsx(ci,{height:12,color:G}):m.jsx("div",{className:"h-3"}),e[58]=G,e[59]=r,e[60]=tn):tn=e[60];let nn;e[61]!==k||e[62]!==w||e[63]!==b||e[64]!==n.name?(nn=m.jsx(y2,{connectionId:k,isToolStep:b,hasToolSelected:w,stepName:n.name}),e[61]=k,e[62]=w,e[63]=b,e[64]=n.name,e[65]=nn):nn=e[65];let rn;e[66]!==G||e[67]!==ie||e[68]!==S?(rn=ie&&m.jsxs(m.Fragment,{children:[m.jsx(ci,{height:8,color:G}),m.jsx(h2,{status:S})]}),e[66]=G,e[67]=ie,e[68]=S,e[69]=rn):rn=e[69];let sn;e[70]!==G||e[71]!==ee||e[72]!==l||e[73]!==d?(sn=l&&d?null:m.jsx(ci,{height:ee,color:G}),e[70]=G,e[71]=ee,e[72]=l,e[73]=d,e[74]=sn):sn=e[74],e[75]!==tn||e[76]!==nn||e[77]!==rn||e[78]!==sn?(T=m.jsxs("div",{className:"flex flex-col items-center shrink-0",children:[tn,nn,rn,sn]}),e[75]=tn,e[76]=nn,e[77]=rn,e[78]=sn,e[79]=T):T=e[79],I="flex-1 flex flex-col gap-3 min-w-0 pt-3 pb-3";const ko=w?"font-medium text-foreground":"text-foreground";let on;e[80]!==ko?(on=Y("text-sm truncate flex-1",ko),e[80]=ko,e[81]=on):on=e[81];let ln;e[82]!==n?(ln=x2(n),e[82]=n,e[83]=ln):ln=e[83];let an;e[84]!==on||e[85]!==ln?(an=m.jsx("span",{className:on,children:ln}),e[84]=on,e[85]=ln,e[86]=an):an=e[86];let cn;e[87]!==K||e[88]!==S?(cn=K&&m.jsx(p2,{status:S}),e[87]=K,e[88]=S,e[89]=cn):cn=e[89];let un;e[90]!==K||e[91]!==c||e[92]!==u?(un=!K&&m.jsxs(em,{children:[m.jsx(tm,{asChild:!0,children:m.jsx(me,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity",onClick:u2,children:m.jsx(Ip,{size:14})})}),m.jsxs(nm,{align:"end",children:[m.jsxs(ua,{onClick:zn=>{zn.stopPropagation(),u()},children:[m.jsx(sm,{size:14}),"Duplicate"]}),m.jsxs(ua,{className:"text-destructive hover:bg-destructive/10! focus:text-destructive",onClick:zn=>{zn.stopPropagation(),c()},children:[m.jsx(gp,{size:14,className:"text-destructive"}),"Delete"]})]})]}),e[90]=K,e[91]=c,e[92]=u,e[93]=un):un=e[93],e[94]!==an||e[95]!==cn||e[96]!==un?(D=m.jsxs("div",{className:"flex items-center h-8",children:[an,cn,un]}),e[94]=an,e[95]=cn,e[96]=un,e[97]=D):D=e[97],$=U.length>0&&m.jsx("div",{className:"flex flex-wrap gap-1.5",children:U.map(c2)}),e[6]=k,e[7]=o,e[8]=w,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]=S,e[22]=v,e[23]=M,e[24]=T,e[25]=I,e[26]=D,e[27]=$,e[28]=V,e[29]=F,e[30]=P,e[31]=N}else S=e[21],v=e[22],M=e[23],T=e[24],I=e[25],D=e[26],$=e[27],V=e[28],F=e[29],P=e[30],N=e[31];let _;e[98]!==h||e[99]!==S?(_=S==="success"&&m.jsx(m2,{completedAtEpochMs:h}),e[98]=h,e[99]=S,e[100]=_):_=e[100];let L;e[101]!==o?.error||e[102]!==S?(L=S==="error"&&m.jsx(g2,{error:o?.error}),e[101]=o?.error,e[102]=S,e[103]=L):L=e[103];let J;e[104]!==_||e[105]!==L||e[106]!==I||e[107]!==D||e[108]!==$?(J=m.jsxs("div",{className:I,children:[D,$,_,L]}),e[104]=_,e[105]=L,e[106]=I,e[107]=D,e[108]=$,e[109]=J):J=e[109];let Z;return e[110]!==v||e[111]!==M||e[112]!==T||e[113]!==J||e[114]!==V||e[115]!==F||e[116]!==P||e[117]!==N?(Z=m.jsxs("div",{className:V,onClick:F,role:P,tabIndex:N,onKeyDown:v,children:[M,T,J]}),e[110]=v,e[111]=M,e[112]=T,e[113]=J,e[114]=V,e[115]=F,e[116]=P,e[117]=N,e[118]=Z):Z=e[118],Z}function c2(t){return m.jsx("span",{className:"px-1.5 py-1 text-xs text-muted-foreground bg-background border border-border rounded-lg",children:t},t)}function u2(t){return t.stopPropagation()}function d2(t){switch(t){case"success":return"text-success";case"error":return"text-destructive";default:return"text-muted-foreground"}}function f2(t){switch(t){case"success":return"bg-success";case"error":return"bg-destructive";default:return"bg-border"}}function h2(t){const e=R.c(2),{status:n}=t;if(n==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-4 rounded bg-success flex items-center justify-center",children:m.jsx(rl,{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=m.jsx("div",{className:"size-4 rounded bg-destructive flex items-center justify-center",children:m.jsx(il,{size:8,className:"text-destructive-foreground"})}),e[1]=r):r=e[1],r}return null}function p2(t){const e=R.c(3),{status:n}=t;if(n==="success"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(rl,{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=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(il,{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=m.jsx("div",{className:"size-7 flex items-center justify-center",children:m.jsx(or,{size:11,className:"text-muted-foreground animate-spin"})}),e[2]=r):r=e[2],r}return null}function m2(t){const e=R.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&&m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx(Op,{size:16,className:"text-success"}),m.jsx("span",{className:"text-xs text-success",children:r}),m.jsx("span",{className:"text-xs text-success",children:o})]}),e[3]=r,e[4]=o,e[5]=i):i=e[5];let l;return e[6]!==i?(l=m.jsx("div",{className:"inline-flex items-center gap-3 px-1.5 py-1 bg-success-foreground rounded-lg w-fit",children:i}),e[6]=i,e[7]=l):l=e[7],l}function g2(t){const e=R.c(3),{error:n}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx(dl,{size:16,className:"text-destructive"}),e[0]=r):r=e[0];const s=n||"Execution failed";let o;return e[1]!==s?(o=m.jsxs("div",{className:"inline-flex items-center gap-1.5 px-1.5 py-1 bg-destructive-foreground rounded-lg w-fit",children:[r,m.jsx("span",{className:"text-xs text-destructive",children:s})]}),e[1]=s,e[2]=o):o=e[2],o}function y2(t){const e=R.c(5),{connectionId:n,isToolStep:r,hasToolSelected:s,stepName:o}=t,i=Yi(n??"");if(r&&s&&i?.icon){let a;return e[0]!==i.icon||e[1]!==o?(a=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center overflow-hidden",children:m.jsx(Us,{icon:i.icon,name:o,size:"xs",className:"border-0 rounded-none"})}),e[0]=i.icon,e[1]=o,e[2]=a):a=e[2],a}let l;return e[3]!==r?(l=m.jsx("div",{className:"size-8 rounded-lg border border-border/10 bg-background shadow-sm flex items-center justify-center",children:r?m.jsx(Tu,{size:16,className:"text-muted-foreground"}):m.jsx(rm,{size:16,className:"text-muted-foreground"})}),e[3]=r,e[4]=l):l=e[4],l}function ci(t){const e=R.c(7),{height:n,color:r}=t,s=r===void 0?"bg-border":r;let o;e[0]!==s?(o=Y("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=m.jsx("div",{className:o,style:i}),e[4]=o,e[5]=i,e[6]=l):l=e[6],l}function x2(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 b2(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 k2(t){const e=R.c(32),{className:n}=t,r=kr(),s=Ru(),o=l2(),{setCurrentStepName:i,deleteStep:l,duplicateStep:a}=Me(),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=m.jsx("div",{children:"Loading..."}),e[3]=f):f=e[3];let h;e[4]!==n?(h=Y("h-full flex flex-col p-8 overflow-auto",n),e[4]=n,e[5]=h):h=e[5];let p;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=(C,w)=>{const S=o?.[C.name],v=d!==-1&&w>d&&S?.status==="pending",M=w===r.length-1;return m.jsx(a2,{step:C,index:w,isSelected:C.name===s,executionStatus:S,isSkipped:v,isLastStep:M,onSelect:()=>i(C.name),onDelete:()=>l(C.name),onDuplicate:()=>a(C.name)},C.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],p=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]=p}else p=e[13];let g;e[22]!==p?(g=m.jsx("div",{className:"pt-3 -space-y-1",children:p}),e[22]=p,e[23]=g):g=e[23];let y;e[24]!==c?(y=c?null:m.jsx(w2,{}),e[24]=c,e[25]=y):y=e[25];let x;e[26]!==g||e[27]!==y?(x=m.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=m.jsx(E.Suspense,{fallback:f,children:m.jsx("div",{className:h,children:x})}),e[29]=h,e[30]=x,e[31]=b):b=e[31],b}function w2(){const t=R.c(8),{addToolStep:e}=Me();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsx("div",{className:"w-5 shrink-0"}),t[0]=n):n=t[0];let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=m.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=m.jsx(ul,{size:14}),t[2]=s):s=t[2];let o;t[3]!==e?(o=m.jsx(me,{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=m.jsx("div",{className:"w-px h-8",style:{backgroundImage:"repeating-linear-gradient(180deg, var(--border), var(--border) 4px, transparent 4px, transparent 8px)",backgroundPosition:"left top",backgroundRepeat:"repeat-y",backgroundSize:"2px 100%"}}),t[5]=i):i=t[5];let l;return t[6]!==o?(l=m.jsxs("div",{className:"flex gap-2 items-start px-4 pb-3",children:[n,m.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 v2(){const t=R.c(5),e=Ln();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],ll(o)}function S2(t){const e=R.c(7),{className:n}=t;if(!Ln()){let o;e[0]!==n?(o=Y("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=m.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground p-4 text-center",children:"Select a gateway to see available tools"}),e[2]=i):i=e[2];let l;return e[3]!==o?(l=m.jsx("div",{className:o,children:i}),e[3]=o,e[4]=l):l=e[4],l}let s;return e[5]!==n?(s=m.jsx(C2,{className:n}),e[5]=n,e[6]=s):s=e[6],s}function C2(t){const e=R.c(38),{className:n}=t,{tools:r,isLoading:s,error:o}=v2(),i=br(),{updateStep:l}=Me(),c=i&&"toolName"in i.action&&"toolName"in i.action?i.action.toolName:null;let u;if(e[0]!==c||e[1]!==r){let w;e[3]!==c?(w=S=>S.name===c,e[3]=c,e[4]=w):w=e[4],u=r.find(w),e[0]=c,e[1]=r,e[2]=u}else u=e[2];const f=Y1(r,u??null,N2,E2);let h;e[5]!==i||e[6]!==l?(h=w=>{i&&l(i.name,{action:{...i.action,toolName:w.name},outputSchema:w.outputSchema??{}})},e[5]=i,e[6]=l,e[7]=h):h=e[7];const p=h;if(s){let w;e[8]!==n?(w=Y("flex flex-col h-full bg-sidebar",n),e[8]=n,e[9]=w):w=e[9];let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=m.jsx("div",{className:"flex-1 flex items-center justify-center",children:m.jsx(jn,{size:"sm"})}),e[10]=S):S=e[10];let v;return e[11]!==w?(v=m.jsx("div",{className:w,children:S}),e[11]=w,e[12]=v):v=e[12],v}if(o){let w;e[13]!==n?(w=Y("flex flex-col h-full bg-sidebar",n),e[13]=n,e[14]=w):w=e[14];let S;e[15]!==o.message?(S=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-destructive p-4 text-center",children:["Failed to load tools: ",o.message]}),e[15]=o.message,e[16]=S):S=e[16];let v;return e[17]!==w||e[18]!==S?(v=m.jsx("div",{className:w,children:S}),e[17]=w,e[18]=S,e[19]=v):v=e[19],v}let g;e[20]!==n?(g=Y("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=m.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=m.jsx("div",{className:"flex items-start border-b border-border",children:m.jsxs("div",{className:"flex-1 flex items-center h-12 px-5",children:[y,m.jsxs("span",{className:"ml-2 text-sm text-muted-foreground",children:["(",r.length,")"]})]})}),e[23]=r.length,e[24]=x):x=e[24];let b;if(e[25]!==p||e[26]!==f||e[27]!==c){let w;e[29]!==p||e[30]!==c?(w=S=>m.jsx(T2,{icon:null,title:S.name,description:S.description,isSelected:S.name===c,onClick:()=>p(S)},S.name),e[29]=p,e[30]=c,e[31]=w):w=e[31],b=f.map(w),e[25]=p,e[26]=f,e[27]=c,e[28]=b}else b=e[28];let k;e[32]!==b?(k=m.jsx("div",{className:"flex-1 overflow-auto",children:b}),e[32]=b,e[33]=k):k=e[33];let C;return e[34]!==g||e[35]!==x||e[36]!==k?(C=m.jsxs("div",{className:g,children:[x,k]}),e[34]=g,e[35]=x,e[36]=k,e[37]=C):C=e[37],C}function E2(t,e){return t.name.localeCompare(e.name)}function N2(t){return t.name}function T2(t){const e=R.c(20),{icon:n,title:r,description:s,isSelected:o,onClick:i}=t,l=o&&"bg-muted/50";let a;e[0]!==l?(a=Y("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=m.jsx(Us,{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=m.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&&m.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2",children:s}),e[9]=s,e[10]=f):f=e[10];let h;e[11]!==d||e[12]!==f?(h=m.jsxs("div",{className:"flex-1 min-w-0",children:[d,f]}),e[11]=d,e[12]=f,e[13]=h):h=e[13];let p;return e[14]!==i||e[15]!==a||e[16]!==c||e[17]!==u||e[18]!==h?(p=m.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]=p):p=e[19],p}var go="Collapsible",[M2,zh]=Ui(go),[O2,na]=M2(go),Bh=E.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:s,disabled:o,onOpenChange:i,...l}=t,[a,c]=qs({prop:r,defaultProp:s??!1,onChange:i,caller:go});return m.jsx(O2,{scope:n,disabled:o,contentId:iu(),open:a,onOpenToggle:E.useCallback(()=>c(u=>!u),[c]),children:m.jsx(Rn.div,{"data-state":sa(a),"data-disabled":o?"":void 0,...l,ref:e})})});Bh.displayName=go;var Fh="CollapsibleTrigger",Vh=E.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,s=na(Fh,n);return m.jsx(Rn.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":sa(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...r,ref:e,onClick:He(t.onClick,s.onOpenToggle)})});Vh.displayName=Fh;var ra="CollapsibleContent",Hh=E.forwardRef((t,e)=>{const{forceMount:n,...r}=t,s=na(ra,t.__scopeCollapsible);return m.jsx(Ki,{present:n||s.open,children:({present:o})=>m.jsx(A2,{...r,ref:e,present:o})})});Hh.displayName=ra;var A2=E.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:s,...o}=t,i=na(ra,n),[l,a]=E.useState(r),c=E.useRef(null),u=Ji(e,c),d=E.useRef(0),f=d.current,h=E.useRef(0),p=h.current,g=i.open||l,y=E.useRef(g),x=E.useRef(void 0);return E.useEffect(()=>{const b=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(b)},[]),yp(()=>{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]),m.jsx(Rn.div,{"data-state":sa(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":p?`${p}px`:void 0,...t.style},children:g&&s})});function sa(t){return t?"open":"closed"}var I2=Bh,R2=Vh,j2=Hh,Ue="Accordion",D2=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[oa,P2,L2]=xp(Ue),[yo]=Ui(Ue,[L2,zh]),ia=zh(),Wh=X.forwardRef((t,e)=>{const{type:n,...r}=t,s=r,o=r;return m.jsx(oa.Provider,{scope:t.__scopeAccordion,children:n==="multiple"?m.jsx(B2,{...o,ref:e}):m.jsx(z2,{...s,ref:e})})});Wh.displayName=Ue;var[qh,$2]=yo(Ue),[Uh,_2]=yo(Ue,{collapsible:!1}),z2=X.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},collapsible:o=!1,...i}=t,[l,a]=qs({prop:n,defaultProp:r??"",onChange:s,caller:Ue});return m.jsx(qh,{scope:t.__scopeAccordion,value:X.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:X.useCallback(()=>o&&a(""),[o,a]),children:m.jsx(Uh,{scope:t.__scopeAccordion,collapsible:o,children:m.jsx(Kh,{...i,ref:e})})})}),B2=X.forwardRef((t,e)=>{const{value:n,defaultValue:r,onValueChange:s=()=>{},...o}=t,[i,l]=qs({prop:n,defaultProp:r??[],onChange:s,caller:Ue}),a=X.useCallback(u=>l((d=[])=>[...d,u]),[l]),c=X.useCallback(u=>l((d=[])=>d.filter(f=>f!==u)),[l]);return m.jsx(qh,{scope:t.__scopeAccordion,value:i,onItemOpen:a,onItemClose:c,children:m.jsx(Uh,{scope:t.__scopeAccordion,collapsible:!0,children:m.jsx(Kh,{...o,ref:e})})})}),[F2,xo]=yo(Ue),Kh=X.forwardRef((t,e)=>{const{__scopeAccordion:n,disabled:r,dir:s,orientation:o="vertical",...i}=t,l=X.useRef(null),a=Ji(l,e),c=P2(n),d=bp(s)==="ltr",f=He(t.onKeyDown,h=>{if(!D2.includes(h.key))return;const p=h.target,g=c().filter(M=>!M.ref.current?.disabled),y=g.findIndex(M=>M.ref.current===p),x=g.length;if(y===-1)return;h.preventDefault();let b=y;const k=0,C=x-1,w=()=>{b=y+1,b>C&&(b=k)},S=()=>{b=y-1,b<k&&(b=C)};switch(h.key){case"Home":b=k;break;case"End":b=C;break;case"ArrowRight":o==="horizontal"&&(d?w():S());break;case"ArrowDown":o==="vertical"&&w();break;case"ArrowLeft":o==="horizontal"&&(d?S():w());break;case"ArrowUp":o==="vertical"&&S();break}const v=b%x;g[v].ref.current?.focus()});return m.jsx(F2,{scope:n,disabled:r,direction:s,orientation:o,children:m.jsx(oa.Slot,{scope:n,children:m.jsx(Rn.div,{...i,"data-orientation":o,ref:a,onKeyDown:r?void 0:f})})})}),Ws="AccordionItem",[V2,la]=yo(Ws),Jh=X.forwardRef((t,e)=>{const{__scopeAccordion:n,value:r,...s}=t,o=xo(Ws,n),i=$2(Ws,n),l=ia(n),a=iu(),c=r&&i.value.includes(r)||!1,u=o.disabled||t.disabled;return m.jsx(V2,{scope:n,open:c,disabled:u,triggerId:a,children:m.jsx(I2,{"data-orientation":o.orientation,"data-state":ep(c),...l,...s,ref:e,disabled:u,open:c,onOpenChange:d=>{d?i.onItemOpen(r):i.onItemClose(r)}})})});Jh.displayName=Ws;var Gh="AccordionHeader",Xh=X.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=xo(Ue,n),o=la(Gh,n);return m.jsx(Rn.h3,{"data-orientation":s.orientation,"data-state":ep(o.open),"data-disabled":o.disabled?"":void 0,...r,ref:e})});Xh.displayName=Gh;var Wi="AccordionTrigger",Yh=X.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=xo(Ue,n),o=la(Wi,n),i=_2(Wi,n),l=ia(n);return m.jsx(oa.ItemSlot,{scope:n,children:m.jsx(R2,{"aria-disabled":o.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:o.triggerId,...l,...r,ref:e})})});Yh.displayName=Wi;var Qh="AccordionContent",Zh=X.forwardRef((t,e)=>{const{__scopeAccordion:n,...r}=t,s=xo(Ue,n),o=la(Qh,n),i=ia(n);return m.jsx(j2,{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}})});Zh.displayName=Qh;function ep(t){return t?"open":"closed"}var H2=Wh,W2=Jh,q2=Xh,U2=Yh,K2=Zh;function J2(t){const e=R.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=m.jsx(H2,{"data-slot":"accordion",...n}),e[2]=n,e[3]=r):r=e[3],r}function G2(t){const e=R.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=Y("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=m.jsx(W2,{"data-slot":"accordion-item",className:s,...r}),e[5]=r,e[6]=s,e[7]=o):o=e[7],o}function X2(t){const e=R.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=Y("focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 py-4 text-left text-sm font-medium transition-all outline-none hover:bg-accent/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-90",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(Ep,{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=m.jsx(q2,{className:"flex",children:m.jsxs(U2,{"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 Y2(t){const e=R.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=Y("pt-0 pb-4",r),e[4]=r,e[5]=o):o=e[5];let i;e[6]!==n||e[7]!==o?(i=m.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=m.jsx(K2,{"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 Q2=(t,e,n,r,s,o,i,l)=>{let a=document.documentElement,c=["light","dark"];function u(h){(Array.isArray(t)?t:[t]).forEach(p=>{let g=p==="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(p,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,p=i&&h==="system"?f():h;u(p)}catch{}};E.createContext(void 0);E.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 E.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?a:"",dangerouslySetInnerHTML:{__html:`(${Q2.toString()})(${u})`}})});function Z2(t){const{updateStep:e}=Me(),r=t&&"toolName"in t.action&&"toolName"in t.action?t.action.toolName:null,{tool:s}=aa(r??"");t&&r&&s?.outputSchema&&(!t.outputSchema||Object.keys(t.outputSchema).length===0)&&queueMicrotask(()=>{e(t.name,{outputSchema:s.outputSchema})})}function eC(t){const e=R.c(25),{className:n}=t,r=br(),{appendStep:s}=Me();if(Z2(r),!r){let f;e[0]!==n?(f=Y("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 p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(ul,{size:14}),e[4]=p):p=e[4];let g;e[5]!==h?(g=m.jsxs("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground gap-2 flex-col",children:["Select or create a step to configure",m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:h,children:p})]}),e[5]=h,e[6]=g):g=e[6];let y;return e[7]!==f||e[8]!==g?(y=m.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=Y("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=m.jsx(tC,{step:r}),l=m.jsx(rC,{step:r}),a=m.jsx(sC,{step:r}),c=m.jsx(aC,{step:r}),u=m.jsx(cC,{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=m.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 tC(t){const e=R.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=m.jsx(Us,{icon:null,name:i,size:"xs",className:"shadow-sm"}),e[0]=i,e[1]=l):l=e[1];let a;e[2]!==s?(a=m.jsx("span",{className:"text-base font-medium text-foreground truncate flex-1",children:s}),e[2]=s,e[3]=a):a=e[3];let c;e[4]!==o?(c=o?null:m.jsx(nC,{}),e[4]=o,e[5]=c):c=e[5];let u;e[6]!==l||e[7]!==a||e[8]!==c?(u=m.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&&m.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=m.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 nC(){const t=R.c(9),e=br(),{updateStep:n,startReplacingTool:r}=Me(),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){ru.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=m.jsx(Nu,{size:14}),t[6]=c):c=t[6];let u;return t[7]!==a?(u=m.jsx(me,{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 aa(t){const e=R.c(13),n=Ln();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=ll(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 rC(t){const e=R.c(13),{step:n}=t,{updateStep:r}=Me(),o="toolName"in n.action&&"toolName"in n.action?n.action.toolName:null,i=we(),{tool:l}=aa(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=m.jsx(X2,{className:"px-5 py-5",children:m.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 p;e[4]===Symbol.for("react.memo_cache_sentinel")?(p=[],e[4]=p):p=e[4];let g;e[5]!==c||e[6]!==n.name||e[7]!==f||e[8]!==h?(g=m.jsxs(G2,{value:"input",className:"border-b-0",children:[d,m.jsx(Y2,{className:"px-5 pt-2",children:m.jsx(_h,{inputSchema:f,inputParams:h,setInputParams:c,mentions:p},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=m.jsx(J2,{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 sC(t){const e=R.c(24),{step:n}=t,r=n.outputSchema,[s,o]=E.useState(!1),i=we(),{output:l,error:a}=F1(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,p=s?"flex-1 min-h-0 overflow-hidden":"shrink-0";let g;e[5]!==p?(g=Y("flex flex-col border-b border-border",p),e[5]=p,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=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Output"}),e[9]=x):x=e[9];let b;e[10]!==s?(b=m.jsxs("div",{className:"flex items-center justify-between",children:[x,s?m.jsx(gu,{size:14,className:"text-muted-foreground"}):m.jsx(mu,{size:14,className:"text-muted-foreground"})]}),e[10]=s,e[11]=b):b=e[11];let k;e[12]!==y||e[13]!==b?(k=m.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 C;e[15]!==u||e[16]!==s||e[17]!==h||e[18]!==i?(C=s&&m.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5",children:[i?m.jsx(Xs,{code:JSON.stringify(u,null,2),language:"json",height:"100%",readOnly:!0}):null,!i&&h.map(oC)]}),e[15]=u,e[16]=s,e[17]=h,e[18]=i,e[19]=C):C=e[19];let w;return e[20]!==g||e[21]!==k||e[22]!==C?(w=m.jsxs("div",{className:g,children:[k,C]}),e[20]=g,e[21]=k,e[22]=C,e[23]=w):w=e[23],w}function oC(t){const[e,n]=t;return m.jsx(lC,{name:e,schema:n},e)}function iC(t){switch(t){case"string":return{Icon:ku,color:"text-blue-500"};case"number":case"integer":return{Icon:xu,color:"text-blue-500"};case"array":return{Icon:pu,color:"text-purple-500"};case"object":return{Icon:hu,color:"text-orange-500"};case"boolean":return{Icon:bu,color:"text-pink-500"};case"null":return{Icon:Gi,color:"text-gray-500"};default:return{Icon:yu,color:"text-muted-foreground"}}}function lC(t){const e=R.c(28),{name:n,schema:r}=t,s=br(),o=r.type??"unknown";let i,l,a,c,u;if(e[0]!==o){const{Icon:C,color:w}=iC(o);u="flex items-center gap-2",c="flex-1 flex items-center gap-2",i=C,l=14,a=Y(w),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=m.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=m.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=m.jsxs("div",{className:c,children:[d,f]}),e[12]=c,e[13]=d,e[14]=f,e[15]=h):h=e[15];let p;e[16]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(Cu,{size:14,className:"opacity-50"}),e[16]=p):p=e[16];const g=s?.name;let y;e[17]!==g?(y=m.jsxs("span",{className:"text-muted-foreground",children:[g,"."]}),e[17]=g,e[18]=y):y=e[18];let x;e[19]!==n?(x=m.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=m.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[p,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=m.jsxs("div",{className:u,children:[h,b]}),e[24]=b,e[25]=u,e[26]=h,e[27]=k):k=e[27],k}function aC(t){const e=R.c(29),{step:n}=t,{updateStep:r}=Me(),s=we(),o="toolName"in n.action,i=o&&"toolName"in n.action?n.action.toolName:null,{tool:l}=aa(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,T=M.properties;return T?`interface Input {
167
- ${Object.entries(T).map(D=>{const[$,V]=D,F=Xr(V),P=!M.required?.includes($);return` ${$}${P?"?":""}: ${F};`}).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 T=`${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:T}})},e[2]=d,e[3]=n.action,e[4]=n.name,e[5]=r,e[6]=f):f=e[6];const h=f;let p;e[7]!==n.action||e[8]!==n.name||e[9]!==r?(p=()=>{r(n.name,{action:{...n.action,transformCode:void 0}})},e[7]=n.action,e[8]=n.name,e[9]=r,e[10]=p):p=e[10];const g=p;let y;e[11]!==n.action||e[12]!==n.name||e[13]!==r?(y=(M,T)=>{r(n.name,{action:{...n.action,transformCode:M},...T?{outputSchema:T}:{}})},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=m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),m.jsx(ul,{size:14,className:"text-muted-foreground"})]}),e[15]=M):M=e[15];let T;return e[16]!==h?(T=m.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]=T):T=e[17],T}let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Transform Code"}),m.jsx(kp,{size:14,className:"text-muted-foreground"})]}),e[18]=b):b=e[18];let k;e[19]!==g?(k=m.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 C=`transform-code-${n.name}-${s}`,w=s!==void 0;let S;e[21]!==x||e[22]!==C||e[23]!==w||e[24]!==a?(S=m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(Xs,{code:a,language:"typescript",readOnly:w,onSave:x,height:"100%"},C)}),e[21]=x,e[22]=C,e[23]=w,e[24]=a,e[25]=S):S=e[25];let v;return e[26]!==k||e[27]!==S?(v=m.jsxs("div",{className:"flex flex-col flex-1 min-h-0 overflow-hidden border-b border-border",children:[k,S]}),e[26]=k,e[27]=S,e[28]=v):v=e[28],v}function cC(t){const e=R.c(24),{step:n}=t,[r,s]=E.useState(!1),{updateStep:o}=Me(),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=Y("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=m.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:"Step Code"}),e[8]=h):h=e[8];let p;e[9]!==r?(p=m.jsxs("div",{className:"flex items-center justify-between",children:[h,r?m.jsx(gu,{size:14,className:"text-muted-foreground"}):m.jsx(mu,{size:14,className:"text-muted-foreground"})]}),e[9]=r,e[10]=p):p=e[10];let g;e[11]!==f||e[12]!==p?(g=m.jsx("div",{className:"p-5 shrink-0 cursor-pointer hover:bg-accent/50 transition-colors",onClick:f,children:p}),e[11]=f,e[12]=p,e[13]=g):g=e[13];let y;e[14]!==i||e[15]!==c||e[16]!==r||e[17]!==n.name||e[18]!==l?(y=r&&m.jsx("div",{className:"flex-1 min-h-0",children:m.jsx(Xs,{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=m.jsxs("div",{className:d,children:[g,y]}),e[20]=d,e[21]=g,e[22]=y,e[23]=x):x=e[23],x}function Xr(t){if(Array.isArray(t.type))return t.type.map(n=>Xr({...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?`${Xr(t.items)}[]`:"unknown[]";case"object":return t.properties?`{ ${Object.entries(t.properties).map(([r,s])=>{const o=Xr(s),i=!t.required?.includes(r);return`${r}${i?"?":""}: ${o}`}).join("; ")} }`:"Record<string, unknown>";case"null":return"null";default:return"unknown"}}function uC(t){switch(t){case"success":return m.jsxs(dn,{variant:"success",className:"gap-1",children:[m.jsx(rl,{size:11}),"Success"]});case"error":case"failed":return m.jsxs(dn,{variant:"destructive",className:"gap-1",children:[m.jsx(dl,{size:11}),"Error"]});case"running":return m.jsxs(dn,{variant:"secondary",className:"gap-1",children:[m.jsx(Wr,{size:11}),"Running"]});case"enqueued":return m.jsxs(dn,{variant:"secondary",className:"gap-1",children:[m.jsx(Wr,{size:11}),"On hold"]});case"cancelled":return m.jsxs(dn,{variant:"secondary",className:"gap-1",children:[m.jsx(fu,{size:11}),"Cancelled"]});default:return m.jsxs(dn,{variant:"secondary",className:"gap-1",children:[m.jsx(Wr,{size:11}),t]})}}function dC(t){return`Run #${t.slice(-4).toUpperCase()}`}function fC(t){const e=R.c(21),{className:n}=t,{executions:r,isLoading:s}=V1(),{setShowExecutionsList:o}=pl(),{setTrackingExecutionId:i}=Me(),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=Y("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=m.jsx("p",{className:"flex-1 text-base font-medium text-foreground",children:"Runs"}),e[6]=h):h=e[6];let p;e[7]===Symbol.for("react.memo_cache_sentinel")?(p=m.jsx(fu,{size:11}),e[7]=p):p=e[7];let g;e[8]!==d?(g=m.jsxs("div",{className:"flex items-center h-12 px-5 border-b border-border shrink-0",children:[h,m.jsx(me,{variant:"ghost",size:"icon",className:"size-7",onClick:d,children:p})]}),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?m.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Loading executions..."}):r.map((k,C)=>m.jsx(hC,{execution:k,isSelected:k.id===l,isFirst:C===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=m.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=m.jsxs("div",{className:f,children:[g,x]}),e[17]=f,e[18]=g,e[19]=x,e[20]=b):b=e[20],b}function hC(t){const e=R.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=Y("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=uC(n.status),e[4]=n.status,e[5]=u):u=e[5];let d;e[6]!==n.id?(d=dC(n.id),e[6]=n.id,e[7]=d):d=e[7];let f;e[8]!==d?(f=m.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=m.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 p;return e[13]!==o||e[14]!==c||e[15]!==h?(p=m.jsx("div",{className:c,onClick:o,children:h}),e[13]=o,e[14]=c,e[15]=h,e[16]=p):p=e[16],p}function pC(t){const e=R.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}=xr(s),i=o??Sn;let l;e[1]!==i?(l=Ze(i),e[1]=i,e[2]=l):l=e[2];const a=l,c=r==="workflow"?"WORKFLOW":"WORKFLOW_EXECUTION",u=au(i,c,n,a),d=Xi(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,p=r==="execution"?n:void 0;let g;return e[6]!==u||e[7]!==p||e[8]!==h?(g={item:u,update:h,trackingExecutionId:p},e[6]=u,e[7]=p,e[8]=h,e[9]=g):g=e[9],g}function tp(t){const e=R.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}=pC(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=m.jsx("div",{className:"flex h-full w-full bg-background",children:m.jsx(Qi,{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=m.jsx(Ks,{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,p=s==="execution"?"action":"executions";let g;e[11]!==p||e[12]!==a||e[13]!==h?(g={workflow:h,trackingExecutionId:a,currentStepTab:p},e[11]=p,e[12]=a,e[13]=h,e[14]=g):g=e[14];let y;e[15]!==r||e[16]!==l?(y=m.jsx(xC,{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=m.jsx(yg,{initialState:g,children:y},u),e[18]=u,e[19]=g,e[20]=y,e[21]=x):x=e[21],x}function mC(t){const e=R.c(2);let n;return e[0]!==t?(n=m.jsx(tp,{...t,mode:"workflow"}),e[0]=t,e[1]=n):n=e[1],n}function gC(t){const e=R.c(18),{workflow:n,onUpdate:r}=t,{setWorkflow:s}=Me();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=Xs,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=m.jsx(o,{height:l,code:a,language:"json",onSave:c},i),e[12]=o,e[13]=i,e[14]=l,e[15]=a,e[16]=c,e[17]=u):u=e[17],u}function yC(){const t=R.c(12),{setTrackingExecutionId:e}=Me(),n=we();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=m.jsx("div",{className:"flex items-center justify-center h-full w-12",children:m.jsx(wp,{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=m.jsx("strong",{className:"text-base text-foreground",children:"Run"}),t[1]=s):s=t[1];let o;t[2]!==n?(o=m.jsxs("div",{className:"flex items-center h-full",children:[r,m.jsxs("p",{className:"flex gap-3 items-center h-full",children:[s,m.jsxs("span",{className:"text-sm text-muted-foreground",children:["#",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=m.jsx(Gi,{className:"w-4 h-4 text-muted-foreground"}),t[6]=l):l=t[6];let a;t[7]!==i?(a=m.jsx(me,{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=m.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 xC(t){const e=R.c(24),{onBack:n,onUpdate:r}=t,s=Pn(),o=we(),{setOriginalWorkflow:i}=Me(),{viewMode:l,showExecutionsList:a}=pl(),c=br();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,p=f&&!h&&!o,g=!p&&(c||o||!a);let y;e[4]!==d||e[5]!==s.description||e[6]!==s.title?(y=m.jsx(n2,{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&&m.jsx(yC,{}),e[8]=o,e[9]=x):x=e[9];let b;e[10]!==r||e[11]!==a||e[12]!==g||e[13]!==p||e[14]!==l||e[15]!==s?(b=m.jsx("div",{className:"flex-1 overflow-hidden",children:l==="code"?m.jsx(gC,{workflow:s,onUpdate:r}):m.jsxs(Hp,{direction:"horizontal",className:"flex w-full h-full",children:[m.jsx(ca,{defaultSize:50,minSize:30,children:m.jsx(k2,{})}),m.jsx(Wp,{}),m.jsxs(ca,{defaultSize:50,minSize:25,children:[p&&m.jsx(S2,{className:"border-l border-border"}),a&&m.jsx(fC,{}),g&&m.jsx(eC,{className:"border-l border-border"})]})]})}),e[10]=r,e[11]=a,e[12]=g,e[13]=p,e[14]=l,e[15]=s,e[16]=b):b=e[16];let k;e[17]!==y||e[18]!==x||e[19]!==b?(k=m.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 C;return e[21]!==n||e[22]!==k?(C=m.jsx(Ks,{onBack:n,children:k}),e[21]=n,e[22]=k,e[23]=C):C=e[23],C}function bC(t){const e=R.c(2);let n;return e[0]!==t?(n=m.jsx(tp,{...t,mode:"execution"}),e[0]=t,e[1]=n):n=e[1],n}const kC={workflow:mC,workflow_execution:bC,prompt:Xm};function wC(){const t=R.c(6),e=lu();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=xr(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=vC;let a;return t[3]!==i||t[4]!==s?(a=m.jsx(sg,{itemId:s,onBack:i,onUpdate:l}),t[3]=i,t[4]=s,t[5]=a):a=t[5],a}async function vC(t){return Promise.resolve()}function SC(){const t=R.c(18),e=lu();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=xr(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??Sn;let u;t[3]!==c?(u=Ze(c),t[3]=c,t[4]=u):u=t[4];const f=Xi(c,o,u);let h;t[5]!==f||t[6]!==i?(h=async C=>{i&&await f.update.mutateAsync({id:i,data:C})},t[5]=f,t[6]=i,t[7]=h):h=t[7];const p=h;let g;t[8]!==o?(g=o?.toLowerCase(),t[8]=o,t[9]=g):g=t[9];const y=g,x=y&&kC[y];if(x){let C;return t[10]!==x||t[11]!==a||t[12]!==p||t[13]!==i?(C=m.jsx(x,{itemId:i,onBack:a,onUpdate:p}),t[10]=x,t[11]=a,t[12]=p,t[13]=i,t[14]=C):C=t[14],C}let b;t[15]===Symbol.for("react.memo_cache_sentinel")?(b=m.jsx(Sp,{size:36,className:"text-muted-foreground"}),t[15]=b):b=t[15];let k;return t[16]!==a?(k=m.jsx(_p,{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 CC(){const t=R.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=xr(e);if(decodeURIComponent(n.collectionName)==="tools"){let i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsx(wC,{}),t[1]=i):i=t[1],i}let o;return t[2]===Symbol.for("react.memo_cache_sentinel")?(o=m.jsx(SC,{}),t[2]=o):o=t[2],o}function ME(){const t=R.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=m.jsx(cu,{children:m.jsx(E.Suspense,{fallback:m.jsx("div",{className:"flex h-full items-center justify-center",children:m.jsx(or,{size:32,className:"animate-spin text-muted-foreground"})}),children:m.jsx(CC,{})})}),t[0]=e):e=t[0],e}export{ME as default};