@decocms/mesh 2.80.0 → 2.81.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 (155) hide show
  1. package/dist/client/assets/{AlertCircle-CiKGr4cn.js → AlertCircle-xWltNfEq.js} +1 -1
  2. package/dist/client/assets/{ArrowUp-Da-3ALYS.js → ArrowUp-CUQneK4P.js} +1 -1
  3. package/dist/client/assets/{Calendar-Dopda02K.js → Calendar-Y3ThXr2h.js} +1 -1
  4. package/dist/client/assets/{Check-BueQ8sXT.js → Check-CJAfxThT.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-DDfyCFQ8.js → CheckCircle-WASxycr6.js} +1 -1
  6. package/dist/client/assets/{CheckDone01-DP8W-0Ck.js → CheckDone01-PM896wVf.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-B54vhftI.js → ChevronDown-Dld_B1wq.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-Qk3bMFOm.js → ChevronRight-Cq8A1HG0.js} +1 -1
  9. package/dist/client/assets/{Code01-Czv3Cc_J.js → Code01-ChhMACJn.js} +1 -1
  10. package/dist/client/assets/{Copy01-Hi_cl0Dv.js → Copy01-Bi307Fis.js} +1 -1
  11. package/dist/client/assets/{DotsHorizontal-DZDYO-QK.js → DotsHorizontal-DcG4iWPg.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-CYxClX8Y.js → DotsVertical-BPAPN4Vy.js} +1 -1
  13. package/dist/client/assets/{Download01-BswjDGYT.js → Download01-DRqJBc9y.js} +1 -1
  14. package/dist/client/assets/{Edit01-DjIIVPOc.js → Edit01-BcGMiw_q.js} +1 -1
  15. package/dist/client/assets/{File02-bSumnbI3.js → File02-DeXzXnSO.js} +1 -1
  16. package/dist/client/assets/{File06-BI7Uu4zl.js → File06-rEVum9HB.js} +1 -1
  17. package/dist/client/assets/{FilterLines-Q41KztHS.js → FilterLines-DrS5EiaX.js} +1 -1
  18. package/dist/client/assets/{Globe02-JvoP5i4W.js → Globe02-Cl0jyOd0.js} +1 -1
  19. package/dist/client/assets/{Grid01-m8yQbjB6.js → Grid01-CVEw4oPD.js} +1 -1
  20. package/dist/client/assets/{Home02-DTvC6Flk.js → Home02-Bd4juFGZ.js} +1 -1
  21. package/dist/client/assets/{Image01-BNmU4xH6.js → Image01-rVwlpIKS.js} +1 -1
  22. package/dist/client/assets/{Inbox01-DiTgWQsT.js → Inbox01-Bkz_LV5C.js} +1 -1
  23. package/dist/client/assets/{InfoCircle-DH8sre6K.js → InfoCircle-SJsH0_B2.js} +1 -1
  24. package/dist/client/assets/{LinkExternal01-9a7f-IN4.js → LinkExternal01-BSi9tdvX.js} +1 -1
  25. package/dist/client/assets/{List-Pg8bvCbL.js → List-B74x-rf5.js} +1 -1
  26. package/dist/client/assets/{Loading01-BRTSMxhn.js → Loading01-RCsoo1ix.js} +1 -1
  27. package/dist/client/assets/{Lock01-B7WU7P_V.js → Lock01-CfncREYU.js} +1 -1
  28. package/dist/client/assets/{Pin01-bFHadhAa.js → Pin01-Czz1A6-0.js} +1 -1
  29. package/dist/client/assets/{Play-DyaA5Zmc.js → Play-C8CLPL7D.js} +1 -1
  30. package/dist/client/assets/{Plus-Cz_ADK0z.js → Plus-CpyX6WFq.js} +1 -1
  31. package/dist/client/assets/{RefreshCcw01-DcK5GlBz.js → RefreshCcw01-BuLmgwFb.js} +1 -1
  32. package/dist/client/assets/{SearchMd-D-bexsV7.js → SearchMd-BOA0hXkq.js} +1 -1
  33. package/dist/client/assets/{Settings01-DPHSJhgi.js → Settings01-BcXVtEQp.js} +1 -1
  34. package/dist/client/assets/{Settings02-Df6PciiP.js → Settings02-Dk5wthsz.js} +1 -1
  35. package/dist/client/assets/{Share07-DajhKQ3b.js → Share07-CJfVmj5Z.js} +1 -1
  36. package/dist/client/assets/{Terminal-7qQ8JJuS.js → Terminal-XQYzEwI_.js} +1 -1
  37. package/dist/client/assets/{Tool01-BkAWyAME.js → Tool01-CNnhnfli.js} +1 -1
  38. package/dist/client/assets/{Trash01-CI-Is3Yn.js → Trash01-Cz4Sm-xC.js} +1 -1
  39. package/dist/client/assets/{Upload01-CUb9gyAO.js → Upload01-0EICpVas.js} +1 -1
  40. package/dist/client/assets/{Users03-SF-dSLqE.js → Users03-DQvz8FEb.js} +1 -1
  41. package/dist/client/assets/{X-BsaSCiuH.js → X-CCXl2rQT.js} +1 -1
  42. package/dist/client/assets/{XClose-Ci0CUeMY.js → XClose-5S7WPLdS.js} +1 -1
  43. package/dist/client/assets/{agent-connections-preview-n89fCXN3.js → agent-connections-preview-BQ8Arzvl.js} +1 -1
  44. package/dist/client/assets/{agent-detail-CsLoUo8d.js → agent-detail-BZGpCuwy.js} +1 -1
  45. package/dist/client/assets/{agents-DyzOMaYm.js → agents-DO0n38y9.js} +1 -1
  46. package/dist/client/assets/{alert-dialog-SfcJdPkB.js → alert-dialog-C85Zzn2R.js} +1 -1
  47. package/dist/client/assets/auth-catchall-DBcX3yyJ.js +1 -0
  48. package/dist/client/assets/{avatar-CIusYiTC.js → avatar-9AUKxcSp.js} +1 -1
  49. package/dist/client/assets/{badge-YrgMcbz0.js → badge-w3pFrziF.js} +1 -1
  50. package/dist/client/assets/{binder-baFVvwYI.js → binder-CJ8-0VEz.js} +1 -1
  51. package/dist/client/assets/{breadcrumb-BYw8VEGe.js → breadcrumb-DIY9dflk.js} +1 -1
  52. package/dist/client/assets/{button-hNTfDx5k.js → button-Cp5BMKMH.js} +1 -1
  53. package/dist/client/assets/{card-BOjAHeKA.js → card-Cmxh92DM.js} +1 -1
  54. package/dist/client/assets/{checkbox-Ws2l0GP_.js → checkbox-bkECPKDF.js} +1 -1
  55. package/dist/client/assets/{circle-alert-C3Z-LVBs.js → circle-alert-BPyWz2k5.js} +1 -1
  56. package/dist/client/assets/{collection-detail-Bs4i738A.js → collection-detail-B5lZPagv.js} +1 -1
  57. package/dist/client/assets/{collection-search-qzDs12in.js → collection-search-DQ21VTxr.js} +1 -1
  58. package/dist/client/assets/{collection-tab-dpSaoxo5.js → collection-tab-BRK0dkZT.js} +1 -1
  59. package/dist/client/assets/{collection-table-wrapper-C89Pd09_.js → collection-table-wrapper-D8a3iWFK.js} +1 -1
  60. package/dist/client/assets/{collection-tabs-BFCAL3Ef.js → collection-tabs-DKjfE4EA.js} +1 -1
  61. package/dist/client/assets/{command-9x7CgOM6.js → command-EttVHAem.js} +1 -1
  62. package/dist/client/assets/{connect-BPT9KDn0.js → connect-Br-CchSG.js} +1 -1
  63. package/dist/client/assets/{connection-card-A1rg1S9o.js → connection-card-Vy4xyhPj.js} +1 -1
  64. package/dist/client/assets/{connection-detail-CS2iB9c4.js → connection-detail-D4nhotsv.js} +1 -1
  65. package/dist/client/assets/{connections-jjiCMIHc.js → connections-C4fecNGZ.js} +1 -1
  66. package/dist/client/assets/{constants-CxDTVa7k.js → constants-DmlZIPyZ.js} +1 -1
  67. package/dist/client/assets/constants-RSNbjd4V.js +1 -0
  68. package/dist/client/assets/{create-organization-dialog-CaIYpf7d.js → create-organization-dialog-Bsc2-YVd.js} +1 -1
  69. package/dist/client/assets/{create-project-dialog-DdFgWD6v.js → create-project-dialog-BElDYbC2.js} +1 -1
  70. package/dist/client/assets/{dialog-D-l2Ftfa.js → dialog-CqONuPoH.js} +1 -1
  71. package/dist/client/assets/{dropdown-menu-6OmusebQ.js → dropdown-menu-DbWYDLhc.js} +1 -1
  72. package/dist/client/assets/{dynamic-plugin-layout-DnHdGWu_.js → dynamic-plugin-layout-DDIYWN0Z.js} +1 -1
  73. package/dist/client/assets/{empty-state-H17Qkdps.js → empty-state-C6xECif3.js} +1 -1
  74. package/dist/client/assets/{empty-state-BAEb2Yq8.js → empty-state-TNWwGe1b.js} +1 -1
  75. package/dist/client/assets/{env-vars-editor-CsrIwY_h.js → env-vars-editor-SQPq2SMw.js} +1 -1
  76. package/dist/client/assets/{error-boundary-DcK43VnV.js → error-boundary-CQ81ah0p.js} +1 -1
  77. package/dist/client/assets/{extract-connection-data-D9TFszzK.js → extract-connection-data-DCfPkqOO.js} +1 -1
  78. package/dist/client/assets/{file-browser-BZ-3xrWn.js → file-browser-Be2N1sr-.js} +2 -2
  79. package/dist/client/assets/{form-cNiyyInc.js → form-D1jv9Gm5.js} +1 -1
  80. package/dist/client/assets/{grid-view-DOwq6txV.js → grid-view-BJp4miY2.js} +1 -1
  81. package/dist/client/assets/{home-DZYN8Vx1.js → home-Dbb8lMh9.js} +1 -1
  82. package/dist/client/assets/{index-BCTjxuxx.js → index-B5kEoFQg.js} +1 -1
  83. package/dist/client/assets/{index-Cqchys4E.js → index-Cfpj4va-.js} +1 -1
  84. package/dist/client/assets/{index-D6LGMWO4.js → index-DBg-x3r6.js} +1 -1
  85. package/dist/client/assets/{index-DWXVnQUC.js → index-DtyUlmPl.js} +1 -1
  86. package/dist/client/assets/{index-ZnlwECtw.js → index-Dzrb5IU0.js} +12 -12
  87. package/dist/client/assets/{index-DJ9A3Py3.js → index-IBsTMWBT.js} +2 -2
  88. package/dist/client/assets/{index-CeWx2NNb.js → index-SkCx09UW.js} +1 -1
  89. package/dist/client/assets/{index-DxJ-j0Ev.js → index-sMKRwjf9.js} +1 -1
  90. package/dist/client/assets/{index-BDLGEALJ.js → index-wi-I7Eui.js} +1 -1
  91. package/dist/client/assets/{infiniteQueryObserver-DYYmB22D.js → infiniteQueryObserver-5Bkiqb7u.js} +1 -1
  92. package/dist/client/assets/{input-DStTH4lS.js → input-Bu9KNsQu.js} +1 -1
  93. package/dist/client/assets/{integration-icon-DQbsI6P5.js → integration-icon-BuUoAcdc.js} +1 -1
  94. package/dist/client/assets/{label-Bgp7Xcmy.js → label-D0ZJ_6Ha.js} +1 -1
  95. package/dist/client/assets/{layout-DrhfzeHS.js → layout-DFPNMqpJ.js} +1 -1
  96. package/dist/client/assets/{localstorage-keys-9l2NItB8.js → localstorage-keys-nksI6kwp.js} +1 -1
  97. package/dist/client/assets/{login-CTsR0qiP.js → login-B-_b1BOn.js} +1 -1
  98. package/dist/client/assets/{mcp-oauth-CYdn-f-E.js → mcp-oauth-DaMoaVBx.js} +1 -1
  99. package/dist/client/assets/{mcp-server-card-BLMZgpdO.js → mcp-server-card-Cpl_kpP3.js} +1 -1
  100. package/dist/client/assets/{mcp-server-detail-DdMXOxLE.js → mcp-server-detail-_FD04jDS.js} +2 -2
  101. package/dist/client/assets/{members-bpdTRVhf.js → members-DO_WmXz3.js} +1 -1
  102. package/dist/client/assets/{monaco-editor-ruzQbqHe.js → monaco-editor-DF-DdcnU.js} +1 -1
  103. package/dist/client/assets/{monitoring-Cv86j2gL.js → monitoring-tDpFQNoM.js} +1 -1
  104. package/dist/client/assets/{oauth-callback-aA8r46gQ.js → oauth-callback-Chbx8CiU.js} +1 -1
  105. package/dist/client/assets/{page-DKkIAZdy.js → page-Cr6F7BId.js} +1 -1
  106. package/dist/client/assets/{page-DalS2GfE.js → page-DFmFdhtk.js} +1 -1
  107. package/dist/client/assets/{plugin-empty-state-DaTpX_Lf.js → plugin-empty-state-mrTHqDqE.js} +1 -1
  108. package/dist/client/assets/{plugin-header-gCXmpGT-.js → plugin-header-D3ZBGzZe.js} +1 -1
  109. package/dist/client/assets/{popover-BPM6fp-c.js → popover-BgoGCOG_.js} +1 -1
  110. package/dist/client/assets/{project-layout-ChFZfQFC.js → project-layout-CA0ey3ks.js} +1 -1
  111. package/dist/client/assets/{project-settings-WdJ5GWA5.js → project-settings-C-0cxG5w.js} +1 -1
  112. package/dist/client/assets/{projects-list-VofSP8Fk.js → projects-list-CUoGozz1.js} +1 -1
  113. package/dist/client/assets/{registry-utils-BDfEBNTB.js → registry-utils-NAWclyJP.js} +1 -1
  114. package/dist/client/assets/{resizable-DZ4SvELz.js → resizable-prxDWhaY.js} +1 -1
  115. package/dist/client/assets/{select-Bd5JCngl.js → select-DY04D7me.js} +1 -1
  116. package/dist/client/assets/{shell-layout-CnOvvRuZ.js → shell-layout-C8gb_VmT.js} +3 -3
  117. package/dist/client/assets/{spinner-BfmE2Bn1.js → spinner-Ba8lcdGm.js} +1 -1
  118. package/dist/client/assets/{store-invite-DovKZI3N.js → store-invite-EQ2BmRrN.js} +1 -1
  119. package/dist/client/assets/{switch-C2pp1N8M.js → switch-1RIMvplB.js} +1 -1
  120. package/dist/client/assets/{table-zxezToQ6.js → table-CIf5nOqR.js} +1 -1
  121. package/dist/client/assets/{tasks-BLhPu2z7.js → tasks-DddwuAN-.js} +1 -1
  122. package/dist/client/assets/{textarea-CcTX1RHB.js → textarea-m6hdro6B.js} +1 -1
  123. package/dist/client/assets/{tools-list-BHfzZ45W.js → tools-list-TG2ebMlL.js} +1 -1
  124. package/dist/client/assets/{topbar-portal-BTISO2Z7.js → topbar-portal-BnFckW6e.js} +1 -1
  125. package/dist/client/assets/{typewriter-title-BwnIVCPq.js → typewriter-title-HfylJpxK.js} +1 -1
  126. package/dist/client/assets/{use-binding-C_jMhdrP.js → use-binding-CvlOQ3_o.js} +1 -1
  127. package/dist/client/assets/{use-connection-3zaR_n7G.js → use-connection-galsKjsg.js} +1 -1
  128. package/dist/client/assets/{use-create-virtual-mcp-C1daV5Xz.js → use-create-virtual-mcp-CLMmnEIF.js} +1 -1
  129. package/dist/client/assets/{use-deco-chat-open-DPIjJF-8.js → use-deco-chat-open-56JOsu98.js} +1 -1
  130. package/dist/client/assets/{use-install-from-registry-CS4EyJzQ.js → use-install-from-registry--6M51Zsc.js} +1 -1
  131. package/dist/client/assets/{use-list-state-jOSfvauC.js → use-list-state-C66VwH6t.js} +1 -1
  132. package/dist/client/assets/{use-llm-BiW6rOAv.js → use-llm-Di7QCbsC.js} +1 -1
  133. package/dist/client/assets/use-mcp-prompts-D7NVjhSC.js +1 -0
  134. package/dist/client/assets/{use-mcp-tools-yKBjvRyY.js → use-mcp-tools-u-Z7-vQF.js} +1 -1
  135. package/dist/client/assets/{use-mobile-DJOxadqa.js → use-mobile-BODNLqyc.js} +1 -1
  136. package/dist/client/assets/{use-organization-settings-IGzyXmrX.js → use-organization-settings-ha2vXAOb.js} +1 -1
  137. package/dist/client/assets/{use-project-DCUkEsLH.js → use-project-k6C7YOp8.js} +1 -1
  138. package/dist/client/assets/{use-virtual-mcp-cvpfQlRr.js → use-virtual-mcp-CXLv90mq.js} +1 -1
  139. package/dist/client/assets/useInfiniteQuery-DB7F-uIw.js +1 -0
  140. package/dist/client/assets/{useMutation-DvtcIR1J.js → useMutation-BtMBiEQ3.js} +1 -1
  141. package/dist/client/assets/useQuery-C3_CC7sI.js +1 -0
  142. package/dist/client/assets/utils-BSGC96Lh.js +1 -0
  143. package/dist/client/assets/{view-mode-toggle-ClTYoP2u.js → view-mode-toggle-CL2zNed4.js} +1 -1
  144. package/dist/client/assets/{workflow-C0rrw_JZ.js → workflow-1Lg2Gqwk.js} +1 -1
  145. package/dist/client/index.html +1 -1
  146. package/dist/server/cli.js +211 -211
  147. package/dist/server/migrate.js +309 -314
  148. package/dist/server/server.js +209 -209
  149. package/package.json +2 -2
  150. package/dist/client/assets/auth-catchall-CY-zCZfz.js +0 -1
  151. package/dist/client/assets/constants-DSPJyAep.js +0 -1
  152. package/dist/client/assets/use-mcp-prompts-DcQnLaNY.js +0 -1
  153. package/dist/client/assets/useInfiniteQuery-DpFCGFTj.js +0 -1
  154. package/dist/client/assets/useQuery-CWQsCMUA.js +0 -1
  155. package/dist/client/assets/utils-DVZmolTw.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as U,c as ae,o as Nx,h as Cw,k as _w,j as T,s as Nb,a2 as Ix,b_ as wx,bX as Nw,bs as At,b$ as Iw,u as ci,t as _n,c0 as ww,aW as Rx,c1 as Rw,c2 as dn,c3 as il,c4 as Ow,c5 as al,c6 as Lw,c7 as Dw,c8 as Mw,c9 as Pw,y as Fw,K as qm,ca as Bw,cb as Uw,cc as Hw,cd as $w,z as Ox,m as Lx,O as as,b3 as jm,bW as Es,g as zw}from"./index-ZnlwECtw.js";import{c as pe}from"./utils-DVZmolTw.js";import{i as qw}from"./X-BsaSCiuH.js";import{u as ka,S as Ib,a as jw,i as Gw,m as Dx,M as Vw,c as Ww,g as Yw,C as Kw,t as Mx,b as Xw,h as Zw}from"./use-deco-chat-open-DPIjJF-8.js";import{b as di,P as pi,a as fi}from"./popover-BPM6fp-c.js";import{S as So}from"./spinner-BfmE2Bn1.js";import{b as wn,T as Rn,a as On,c as Ao,I as Gm}from"./integration-icon-DQbsI6P5.js";import{d as Px,u as Vm,i as Qr,f as Qw}from"./constants-CxDTVa7k.js";import{u as Jw,g as Fx,l as wb,a as Rb,r as eR}from"./use-mcp-prompts-DcQnLaNY.js";import{E as tR,i as nR}from"./error-boundary-DcK43VnV.js";import{B as et}from"./button-hNTfDx5k.js";import{c as rR,b as iR,e as aR,a as sR,D as oR}from"./dialog-D-l2Ftfa.js";import{a as lR,F as uR,b as cR,c as dR,d as pR,f as fR}from"./form-cNiyyInc.js";import{I as Bx}from"./input-DStTH4lS.js";import{i as Ux}from"./AlertCircle-CiKGr4cn.js";import{i as hR}from"./ArrowUp-Da-3ALYS.js";import{t as Hh}from"./ChevronDown-B54vhftI.js";import{i as mR}from"./Edit01-DjIIVPOc.js";import{t as ia}from"./Users03-SF-dSLqE.js";import{i as Hx}from"./ChevronRight-Qk3bMFOm.js";import{i as xa}from"./Check-BueQ8sXT.js";import{a as Wm}from"./Copy01-Hi_cl0Dv.js";import{c as gR}from"./usage-B8eRkRZY.js";import{i as bR}from"./Terminal-7qQ8JJuS.js";import{M as $x,s as Ob}from"./monaco-editor-ruzQbqHe.js";import{u as ER,L as yR}from"./localstorage-keys-9l2NItB8.js";import{E as TR}from"./empty-state-BAEb2Yq8.js";import{g as SR,h as AR}from"./use-connection-3zaR_n7G.js";import{g as kR}from"./generate-id-Dyweu44Y.js";import{i as zx}from"./SearchMd-D-bexsV7.js";import{s as xR}from"./Trash01-CI-Is3Yn.js";import{B as vR}from"./badge-YrgMcbz0.js";import{i as CR}from"./Code01-Czv3Cc_J.js";import{b as _R}from"./use-virtual-mcp-cvpfQlRr.js";import{u as NR}from"./use-create-virtual-mcp-C1daV5Xz.js";const qx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));qx.displayName="Atom02";const jx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"m21.152 10.9-9.015 9.015a5.25 5.25 0 0 1-7.425-7.425l9.016-9.015a3.5 3.5 0 1 1 4.95 4.95l-8.662 8.662a1.75 1.75 0 1 1-2.475-2.475l7.601-7.602"}));jx.displayName="Attachment01";const Gx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));Gx.displayName="Coins01";const Vx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));Vx.displayName="Lightbulb01";const Wx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));Wx.displayName="Stop";const Yx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));Yx.displayName="Target04";const Kx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));Kx.displayName="XCircle";function IR(t){const e={};for(const n of t.arguments??[])e[n.name]=n.required?Nb().min(1,"Required"):Nb();return Nx(e)}function wR(t){const e={};for(const n of t.arguments??[])e[n.name]="";return e}function Xx(t){const e=ae.c(64),{prompt:n,setPrompt:r,onSubmit:i}=t,a=U.useId();let s;if(e[0]!==n){const H=n?IR(n):Nx({});s=Cw(H),e[0]=n,e[1]=s}else s=e[1];const l=s;let u;e[2]!==n?(u=n?wR(n):{},e[2]=n,e[3]=u):u=e[3];let c;e[4]!==l||e[5]!==u?(c={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=c):c=e[6];const d=_w(c);let f;e[7]!==n?.arguments?(f=n?.arguments??[],e[7]=n?.arguments,e[8]=f):f=e[8];const p=f;let h;e[9]!==d||e[10]!==i||e[11]!==r?(h=async H=>{await i(H),r(null),d.reset()},e[9]=d,e[10]=i,e[11]=r,e[12]=h):h=e[12];const g=h;let b;e[13]!==d||e[14]!==r?(b=H=>{H||(d.reset(),r(null))},e[13]=d,e[14]=r,e[15]=b):b=e[15];const E=b;if(!n)return null;let y;e[16]!==n.name||e[17]!==n.title?(y=n.title||n.name.replace(/_/g," "),e[16]=n.name,e[17]=n.title,e[18]=y):y=e[18];let S;e[19]!==y?(S=T.jsx(rR,{children:y}),e[19]=y,e[20]=S):S=e[20];let k;e[21]!==n.description?(k=n.description&&T.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[21]=n.description,e[22]=k):k=e[22];let x;e[23]!==k||e[24]!==S?(x=T.jsxs(iR,{children:[S,k]}),e[23]=k,e[24]=S,e[25]=x):x=e[25];let A;e[26]!==d||e[27]!==g?(A=H=>{H.stopPropagation(),d.handleSubmit(g)(H)},e[26]=d,e[27]=g,e[28]=A):A=e[28];let v;if(e[29]!==p||e[30]!==d.control||e[31]!==d.formState.isSubmitting){let H;e[33]!==d.control||e[34]!==d.formState.isSubmitting?(H=J=>T.jsx(uR,{control:d.control,name:J.name,render:I=>{const{field:X}=I;return T.jsxs(cR,{children:[T.jsxs(dR,{className:"text-xs",children:[J.name,J.required?null:T.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),T.jsx(pR,{children:T.jsx(Bx,{...X,value:X.value??"",required:J.required,placeholder:J.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),T.jsx(fR,{})]})}},J.name),e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=H):H=e[35],v=p.map(H),e[29]=p,e[30]=d.control,e[31]=d.formState.isSubmitting,e[32]=v}else v=e[32];let w;e[36]!==E?(w=()=>E(!1),e[36]=E,e[37]=w):w=e[37];let N;e[38]!==d.formState.isSubmitting||e[39]!==w?(N=T.jsx(et,{type:"button",variant:"ghost",onClick:w,disabled:d.formState.isSubmitting,children:"Cancel"}),e[38]=d.formState.isSubmitting,e[39]=w,e[40]=N):N=e[40];const _=!d.formState.isValid||d.formState.isSubmitting;let D;e[41]!==d.formState.isSubmitting?(D=d.formState.isSubmitting?T.jsxs("span",{className:"flex items-center gap-2",children:[T.jsx(So,{size:"xs"}),"Loading..."]}):"Use prompt",e[41]=d.formState.isSubmitting,e[42]=D):D=e[42];let M;e[43]!==a||e[44]!==_||e[45]!==D?(M=T.jsx(et,{type:"submit",form:a,disabled:_,children:D}),e[43]=a,e[44]=_,e[45]=D,e[46]=M):M=e[46];let q;e[47]!==N||e[48]!==M?(q=T.jsxs(aR,{children:[N,M]}),e[47]=N,e[48]=M,e[49]=q):q=e[49];let P;e[50]!==a||e[51]!==A||e[52]!==v||e[53]!==q?(P=T.jsxs("form",{id:a,className:"space-y-4 py-4",autoComplete:"off",onSubmit:A,children:[v,q]}),e[50]=a,e[51]=A,e[52]=v,e[53]=q,e[54]=P):P=e[54];let F;e[55]!==d||e[56]!==P?(F=T.jsx(lR,{...d,children:P}),e[55]=d,e[56]=P,e[57]=F):F=e[57];let $;e[58]!==x||e[59]!==F?($=T.jsxs(sR,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[x,F]}),e[58]=x,e[59]=F,e[60]=$):$=e[60];let G;return e[61]!==E||e[62]!==$?(G=T.jsx(oR,{open:!0,onOpenChange:E,children:$}),e[61]=E,e[62]=$,e[63]=G):G=e[63],G}function it(t){this.content=t}it.prototype={constructor:it,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new it(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new it(n)},addToStart:function(t,e){return new it([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new it(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new it(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=it.from(t),t.size?new it(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=it.from(t),t.size?new it(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=it.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}};it.from=function(t){if(t instanceof it)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new it(e)};function Zx(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=Zx(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Qx(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,c=Math.min(s.text.length,o.text.length);for(;u<c&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=Qx(s.content,o.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class W{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,o=0;o<n;s++){let l=this.content[s],u=o+l.nodeSize;if(u>e&&r(l,i+o,a||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let u=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new W(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new W(r,i)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new W(i,a)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Zx(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Qx(this,e,n,r)}findIndex(e){if(e==0)return Fa(0,e);if(e==this.size)return Fa(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Fa(n+1,a):Fa(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const sl={index:0,offset:0};function Fa(t,e){return sl.index=t,sl.offset=e,sl}function ys(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(!ys(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ys(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let _e=class $h{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ys(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return $h.none;if(e instanceof $h)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};_e.none=[];class Ts extends Error{}class ee{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ev(this.content,e+this.openStart,n);return r&&new ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ee(Jx(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ee(W.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new ee(e,r,i)}}ee.empty=new ee(W.empty,0,0);function Jx(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(Jx(a.content,e-i-1,n-i-1)))}function ev(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=ev(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function RR(t,e,n){if(n.openStart>t.depth)throw new Ts("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ts("Inconsistent open depths");return tv(t,e,n,0)}function tv(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=tv(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return br(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=OR(n,t);return br(a,rv(t,s,o,e,r))}else return br(a,Ss(t,e,r))}function nv(t,e){if(!e.type.compatibleContent(t.type))throw new Ts("Cannot join "+e.type.name+" onto "+t.type.name)}function zh(t,e,n){let r=t.node(n);return nv(r,e.node(n)),r}function gr(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 Ui(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(gr(t.nodeAfter,r),a++));for(let o=a;o<s;o++)gr(i.child(o),r);e&&e.depth==n&&e.textOffset&&gr(e.nodeBefore,r)}function br(t,e){return t.type.checkContent(e),t.copy(e)}function rv(t,e,n,r,i){let a=t.depth>i&&zh(t,e,i+1),s=r.depth>i&&zh(n,r,i+1),o=[];return Ui(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(nv(a,s),gr(br(a,rv(t,e,n,r,i+1)),o)):(a&&gr(br(a,Ss(t,e,i+1)),o),Ui(e,n,i,o),s&&gr(br(s,Ss(n,r,i+1)),o)),Ui(r,null,i,o),new W(o)}function Ss(t,e,n){let r=[];if(Ui(null,t,n,r),t.depth>n){let i=zh(t,e,n+1);gr(br(i,Ss(t,e,n+1)),r)}return Ui(e,null,n,r),new W(r)}function OR(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(W.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class aa{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return _e.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new As(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(a),u=a-l;if(r.push(s,o,i+l),!u||(s=s.child(o),s.isText))break;a=u-1,i+=l+1}return new aa(n,r,a)}static resolveCached(e,n){let r=Lb.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else Lb.set(e,r=new LR);let i=r.elts[r.i]=aa.resolve(e,n);return r.i=(r.i+1)%DR,i}}class LR{constructor(){this.elts=[],this.i=0}}const DR=12,Lb=new WeakMap;class As{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 MR=Object.create(null);let Xn=class qh{constructor(e,n,r,i=_e.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||W.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ys(this.attrs,n||e.defaultAttrs||MR)&&_e.sameSet(this.marks,r||_e.none)}copy(e=null){return e==this.content?this:new qh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qh(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ee.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new ee(u,i.depth-s,a.depth-s)}replace(e,n,r){return RR(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return aa.resolveCached(this,e)}resolveNoCache(e){return aa.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),iv(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=W.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<a;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=_e.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(!_e.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=W.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Xn.prototype.text=void 0;class ks extends Xn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):iv(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 ks(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ks(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 iv(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class kr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new PR(e,n);if(r.next==null)return kr.empty;let i=av(r);r.next&&r.err("Unexpected trailing text");let a=qR(zR(i));return jR(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return W.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:d}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=a(d,o.concat(c));if(f)return f}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
1
+ import{r as U,c as ae,o as Nx,h as Cw,k as _w,j as T,s as Nb,a2 as Ix,c0 as wx,bZ as Nw,bu as At,c1 as Iw,u as ci,t as _n,c2 as ww,aY as Rx,c3 as Rw,c4 as dn,c5 as il,c6 as Ow,c7 as al,c8 as Lw,c9 as Dw,ca as Mw,cb as Pw,y as Fw,K as qm,cc as Bw,cd as Uw,ce as Hw,cf as $w,z as Ox,m as Lx,O as as,b5 as jm,bY as Es,g as zw}from"./index-Dzrb5IU0.js";import{c as pe}from"./utils-BSGC96Lh.js";import{i as qw}from"./X-CCXl2rQT.js";import{u as ka,S as Ib,a as jw,i as Gw,m as Dx,M as Vw,c as Ww,g as Yw,C as Kw,t as Mx,b as Xw,h as Zw}from"./use-deco-chat-open-56JOsu98.js";import{b as di,P as pi,a as fi}from"./popover-BgoGCOG_.js";import{S as So}from"./spinner-Ba8lcdGm.js";import{b as wn,T as Rn,a as On,c as Ao,I as Gm}from"./integration-icon-BuUoAcdc.js";import{d as Px,u as Vm,i as Qr,f as Qw}from"./constants-DmlZIPyZ.js";import{u as Jw,g as Fx,l as wb,a as Rb,r as eR}from"./use-mcp-prompts-D7NVjhSC.js";import{E as tR,i as nR}from"./error-boundary-CQ81ah0p.js";import{B as et}from"./button-Cp5BMKMH.js";import{c as rR,b as iR,e as aR,a as sR,D as oR}from"./dialog-CqONuPoH.js";import{a as lR,F as uR,b as cR,c as dR,d as pR,f as fR}from"./form-D1jv9Gm5.js";import{I as Bx}from"./input-Bu9KNsQu.js";import{i as Ux}from"./AlertCircle-xWltNfEq.js";import{i as hR}from"./ArrowUp-CUQneK4P.js";import{t as Hh}from"./ChevronDown-Dld_B1wq.js";import{i as mR}from"./Edit01-BcGMiw_q.js";import{t as ia}from"./Users03-DQvz8FEb.js";import{i as Hx}from"./ChevronRight-Cq8A1HG0.js";import{i as xa}from"./Check-CJAfxThT.js";import{a as Wm}from"./Copy01-Bi307Fis.js";import{c as gR}from"./usage-B8eRkRZY.js";import{i as bR}from"./Terminal-XQYzEwI_.js";import{M as $x,s as Ob}from"./monaco-editor-DF-DdcnU.js";import{u as ER,L as yR}from"./localstorage-keys-nksI6kwp.js";import{E as TR}from"./empty-state-TNWwGe1b.js";import{g as SR,h as AR}from"./use-connection-galsKjsg.js";import{g as kR}from"./generate-id-Dyweu44Y.js";import{i as zx}from"./SearchMd-BOA0hXkq.js";import{s as xR}from"./Trash01-Cz4Sm-xC.js";import{B as vR}from"./badge-w3pFrziF.js";import{i as CR}from"./Code01-ChhMACJn.js";import{b as _R}from"./use-virtual-mcp-CXLv90mq.js";import{u as NR}from"./use-create-virtual-mcp-CLMmnEIF.js";const qx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M17.115 15.358c-.27.306-.554.608-.851.905-4.296 4.296-9.678 5.88-12.021 3.536-1.607-1.606-1.368-4.641.325-7.775M6.89 8.725c.281-.32.578-.636.888-.947C12.074 3.482 17.456 1.9 19.8 4.243c1.608 1.607 1.367 4.645-.33 7.781m-3.206-4.246c4.296 4.296 5.88 9.678 3.536 12.021-2.343 2.343-7.725.76-12.02-3.535C3.483 11.968 1.9 6.586 4.244 4.243c2.343-2.343 7.725-.76 12.02 3.535ZM13 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}));qx.displayName="Atom02";const jx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"m21.152 10.9-9.015 9.015a5.25 5.25 0 0 1-7.425-7.425l9.016-9.015a3.5 3.5 0 1 1 4.95 4.95l-8.662 8.662a1.75 1.75 0 1 1-2.475-2.475l7.601-7.602"}));jx.displayName="Attachment01";const Gx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));Gx.displayName="Coins01";const Vx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M15 16.5V19c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C13.398 22 12.932 22 12 22c-.932 0-1.398 0-1.765-.152a2 2 0 0 1-1.083-1.083C9 20.398 9 19.932 9 19v-2.5m6 0c2.649-1.157 4.5-3.925 4.5-7a7.5 7.5 0 0 0-15 0c0 3.075 1.851 5.843 4.5 7m6 0H9"}));Vx.displayName="Lightbulb01";const Wx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"}));Wx.displayName="Stop";const Yx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"M16 8V5l3-3 1 2 2 1-3 3h-3Zm0 0-4 4m10 0c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m5 10a5 5 0 1 1-5-5"}));Yx.displayName="Target04";const Kx=({size:t=24,color:e="currentColor",...n})=>U.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},U.createElement("path",{d:"m15 9-6 6m0-6 6 6m7-3c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z"}));Kx.displayName="XCircle";function IR(t){const e={};for(const n of t.arguments??[])e[n.name]=n.required?Nb().min(1,"Required"):Nb();return Nx(e)}function wR(t){const e={};for(const n of t.arguments??[])e[n.name]="";return e}function Xx(t){const e=ae.c(64),{prompt:n,setPrompt:r,onSubmit:i}=t,a=U.useId();let s;if(e[0]!==n){const H=n?IR(n):Nx({});s=Cw(H),e[0]=n,e[1]=s}else s=e[1];const l=s;let u;e[2]!==n?(u=n?wR(n):{},e[2]=n,e[3]=u):u=e[3];let c;e[4]!==l||e[5]!==u?(c={resolver:l,defaultValues:u,mode:"onChange"},e[4]=l,e[5]=u,e[6]=c):c=e[6];const d=_w(c);let f;e[7]!==n?.arguments?(f=n?.arguments??[],e[7]=n?.arguments,e[8]=f):f=e[8];const p=f;let h;e[9]!==d||e[10]!==i||e[11]!==r?(h=async H=>{await i(H),r(null),d.reset()},e[9]=d,e[10]=i,e[11]=r,e[12]=h):h=e[12];const g=h;let b;e[13]!==d||e[14]!==r?(b=H=>{H||(d.reset(),r(null))},e[13]=d,e[14]=r,e[15]=b):b=e[15];const E=b;if(!n)return null;let y;e[16]!==n.name||e[17]!==n.title?(y=n.title||n.name.replace(/_/g," "),e[16]=n.name,e[17]=n.title,e[18]=y):y=e[18];let S;e[19]!==y?(S=T.jsx(rR,{children:y}),e[19]=y,e[20]=S):S=e[20];let k;e[21]!==n.description?(k=n.description&&T.jsx("p",{className:"text-sm text-muted-foreground",children:n.description}),e[21]=n.description,e[22]=k):k=e[22];let x;e[23]!==k||e[24]!==S?(x=T.jsxs(iR,{children:[S,k]}),e[23]=k,e[24]=S,e[25]=x):x=e[25];let A;e[26]!==d||e[27]!==g?(A=H=>{H.stopPropagation(),d.handleSubmit(g)(H)},e[26]=d,e[27]=g,e[28]=A):A=e[28];let v;if(e[29]!==p||e[30]!==d.control||e[31]!==d.formState.isSubmitting){let H;e[33]!==d.control||e[34]!==d.formState.isSubmitting?(H=J=>T.jsx(uR,{control:d.control,name:J.name,render:I=>{const{field:X}=I;return T.jsxs(cR,{children:[T.jsxs(dR,{className:"text-xs",children:[J.name,J.required?null:T.jsxs("span",{className:"text-muted-foreground font-normal",children:[" ","(optional)"]})]}),T.jsx(pR,{children:T.jsx(Bx,{...X,value:X.value??"",required:J.required,placeholder:J.description??"",className:"h-9",disabled:d.formState.isSubmitting})}),T.jsx(fR,{})]})}},J.name),e[33]=d.control,e[34]=d.formState.isSubmitting,e[35]=H):H=e[35],v=p.map(H),e[29]=p,e[30]=d.control,e[31]=d.formState.isSubmitting,e[32]=v}else v=e[32];let w;e[36]!==E?(w=()=>E(!1),e[36]=E,e[37]=w):w=e[37];let N;e[38]!==d.formState.isSubmitting||e[39]!==w?(N=T.jsx(et,{type:"button",variant:"ghost",onClick:w,disabled:d.formState.isSubmitting,children:"Cancel"}),e[38]=d.formState.isSubmitting,e[39]=w,e[40]=N):N=e[40];const _=!d.formState.isValid||d.formState.isSubmitting;let D;e[41]!==d.formState.isSubmitting?(D=d.formState.isSubmitting?T.jsxs("span",{className:"flex items-center gap-2",children:[T.jsx(So,{size:"xs"}),"Loading..."]}):"Use prompt",e[41]=d.formState.isSubmitting,e[42]=D):D=e[42];let M;e[43]!==a||e[44]!==_||e[45]!==D?(M=T.jsx(et,{type:"submit",form:a,disabled:_,children:D}),e[43]=a,e[44]=_,e[45]=D,e[46]=M):M=e[46];let q;e[47]!==N||e[48]!==M?(q=T.jsxs(aR,{children:[N,M]}),e[47]=N,e[48]=M,e[49]=q):q=e[49];let P;e[50]!==a||e[51]!==A||e[52]!==v||e[53]!==q?(P=T.jsxs("form",{id:a,className:"space-y-4 py-4",autoComplete:"off",onSubmit:A,children:[v,q]}),e[50]=a,e[51]=A,e[52]=v,e[53]=q,e[54]=P):P=e[54];let F;e[55]!==d||e[56]!==P?(F=T.jsx(lR,{...d,children:P}),e[55]=d,e[56]=P,e[57]=F):F=e[57];let $;e[58]!==x||e[59]!==F?($=T.jsxs(sR,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[x,F]}),e[58]=x,e[59]=F,e[60]=$):$=e[60];let G;return e[61]!==E||e[62]!==$?(G=T.jsx(oR,{open:!0,onOpenChange:E,children:$}),e[61]=E,e[62]=$,e[63]=G):G=e[63],G}function it(t){this.content=t}it.prototype={constructor:it,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new it(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new it(n)},addToStart:function(t,e){return new it([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new it(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new it(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=it.from(t),t.size?new it(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=it.from(t),t.size?new it(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=it.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}};it.from=function(t){if(t instanceof it)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new it(e)};function Zx(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let s=0;i.text[s]==a.text[s];s++)n++;return n}if(i.content.size||a.content.size){let s=Zx(i.content,a.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function Qx(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let s=t.child(--i),o=e.child(--a),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let u=0,c=Math.min(s.text.length,o.text.length);for(;u<c&&s.text[s.text.length-u-1]==o.text[o.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let u=Qx(s.content,o.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class W{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,a){for(let s=0,o=0;o<n;s++){let l=this.content[s],u=o+l.nodeSize;if(u>e&&r(l,i+o,a||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let a="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let u=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?i?typeof i=="function"?i(o):i:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&r&&(s?s=!1:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new W(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let a=0,s=0;s<n;a++){let o=this.content[a],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),i+=o.nodeSize),s=l}return new W(r,i)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new W(i,a)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Zx(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Qx(this,e,n,r)}findIndex(e){if(e==0)return Fa(0,e);if(e==this.size)return Fa(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Fa(n+1,a):Fa(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let n,r=0;for(let i=0;i<e.length;i++){let a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const sl={index:0,offset:0};function Fa(t,e){return sl.index=t,sl.offset=e,sl}function ys(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(!ys(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ys(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let _e=class $h{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ys(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return $h.none;if(e instanceof $h)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};_e.none=[];class Ts extends Error{}class ee{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=ev(this.content,e+this.openStart,n);return r&&new ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ee(Jx(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ee(W.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new ee(e,r,i)}}ee.empty=new ee(W.empty,0,0);function Jx(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(i==e||a.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,a.copy(Jx(a.content,e-i-1,n-i-1)))}function ev(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),s=t.maybeChild(i);if(a==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=ev(s.content,e-a-1,n,s);return o&&t.replaceChild(i,s.copy(o))}function RR(t,e,n){if(n.openStart>t.depth)throw new Ts("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ts("Inconsistent open depths");return tv(t,e,n,0)}function tv(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let s=tv(t,e,n,r+1);return a.copy(a.content.replaceChild(i,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return br(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=OR(n,t);return br(a,rv(t,s,o,e,r))}else return br(a,Ss(t,e,r))}function nv(t,e){if(!e.type.compatibleContent(t.type))throw new Ts("Cannot join "+e.type.name+" onto "+t.type.name)}function zh(t,e,n){let r=t.node(n);return nv(r,e.node(n)),r}function gr(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 Ui(t,e,n,r){let i=(e||t).node(n),a=0,s=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(gr(t.nodeAfter,r),a++));for(let o=a;o<s;o++)gr(i.child(o),r);e&&e.depth==n&&e.textOffset&&gr(e.nodeBefore,r)}function br(t,e){return t.type.checkContent(e),t.copy(e)}function rv(t,e,n,r,i){let a=t.depth>i&&zh(t,e,i+1),s=r.depth>i&&zh(n,r,i+1),o=[];return Ui(null,t,i,o),a&&s&&e.index(i)==n.index(i)?(nv(a,s),gr(br(a,rv(t,e,n,r,i+1)),o)):(a&&gr(br(a,Ss(t,e,i+1)),o),Ui(e,n,i,o),s&&gr(br(s,Ss(n,r,i+1)),o)),Ui(r,null,i,o),new W(o)}function Ss(t,e,n){let r=[];if(Ui(null,t,n,r),t.depth>n){let i=zh(t,e,n+1);gr(br(i,Ss(t,e,n+1)),r)}return Ui(e,null,n,r),new W(r)}function OR(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(W.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class aa{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return _e.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let o=r;r=i,i=o}let a=r.marks;for(var s=0;s<a.length;s++)a[s].type.spec.inclusive===!1&&(!i||!a[s].isInSet(i.marks))&&(a=a[s--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new As(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(a),u=a-l;if(r.push(s,o,i+l),!u||(s=s.child(o),s.isText))break;a=u-1,i+=l+1}return new aa(n,r,a)}static resolveCached(e,n){let r=Lb.get(e);if(r)for(let a=0;a<r.elts.length;a++){let s=r.elts[a];if(s.pos==n)return s}else Lb.set(e,r=new LR);let i=r.elts[r.i]=aa.resolve(e,n);return r.i=(r.i+1)%DR,i}}class LR{constructor(){this.elts=[],this.i=0}}const DR=12,Lb=new WeakMap;class As{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 MR=Object.create(null);let Xn=class qh{constructor(e,n,r,i=_e.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||W.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ys(this.attrs,n||e.defaultAttrs||MR)&&_e.sameSet(this.marks,r||_e.none)}copy(e=null){return e==this.content?this:new qh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new qh(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ee.empty;let i=this.resolve(e),a=this.resolve(n),s=r?0:i.sharedDepth(n),o=i.start(s),u=i.node(s).content.cut(i.pos-o,a.pos-o);return new ee(u,i.depth-s,a.depth-s)}replace(e,n,r){return RR(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return aa.resolveCached(this,e)}resolveNoCache(e){return aa.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),iv(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=W.empty,i=0,a=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,a),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=i;l<a;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),s=a&&a.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=_e.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(!_e.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=W.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};Xn.prototype.text=void 0;class ks extends Xn{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):iv(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 ks(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ks(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 iv(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class kr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new PR(e,n);if(r.next==null)return kr.empty;let i=av(r);r.next&&r.err("Unexpected trailing text");let a=qR(zR(i));return jR(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return W.from(o.map(u=>u.createAndFill()));for(let u=0;u<s.next.length;u++){let{type:c,next:d}=s.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(d)==-1){i.push(d);let f=a(d,o.concat(c));if(f)return f}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let s=[];for(let o=i;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<a.next.length;s++){let{type:o,next:l}=a.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!i.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:i}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let a=i+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)a+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return a}).join(`
2
2
  `)}}kr.empty=new kr(!0);class PR{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 av(t){let e=[];do e.push(FR(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function FR(t){let e=[];do e.push(BR(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function BR(t){let e=$R(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=UR(t,e);else break;return e}function Db(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function UR(t,e){let n=Db(t),r=n;return t.eat(",")&&(t.next!="}"?r=Db(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function HR(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let s=n[a];s.isInGroup(e)&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function $R(t){if(t.eat("(")){let e=av(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=HR(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 zR(t){let e=[[]];return i(a(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let u={term:l,to:o};return e[s].push(u),u}function i(s,o){s.forEach(l=>l.to=o)}function a(s,o){if(s.type=="choice")return s.exprs.reduce((l,u)=>l.concat(a(u,o)),[]);if(s.type=="seq")for(let l=0;;l++){let u=a(s.exprs[l],o);if(l==s.exprs.length-1)return u;i(u,o=n())}else if(s.type=="star"){let l=n();return r(o,l),i(a(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return i(a(s.expr,o),l),i(a(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(a(s.expr,o));if(s.type=="range"){let l=o;for(let u=0;u<s.min;u++){let c=n();i(a(s.expr,l),c),l=c}if(s.max==-1)i(a(s.expr,l),l);else for(let u=s.min;u<s.max;u++){let c=n();r(l,c),i(a(s.expr,l),c),l=c}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function sv(t,e){return e-t}function Mb(t,e){let n=[];return r(e),n.sort(sv);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let s=0;s<a.length;s++){let{term:o,to:l}=a[s];!o&&n.indexOf(l)==-1&&r(l)}}}function qR(t){let e=Object.create(null);return n(Mb(t,0));function n(r){let i=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let u;for(let c=0;c<i.length;c++)i[c][0]==o&&(u=i[c][1]);Mb(t,l).forEach(c=>{u||i.push([o,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let a=e[r.join(",")]=new kr(r.indexOf(t.length-1)>-1);for(let s=0;s<i.length;s++){let o=i[s][1].sort(sv);a.next.push({type:i[s][0],next:e[o.join(",")]||n(o)})}return a}}function jR(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,s=[];for(let o=0;o<i.next.length;o++){let{type:l,next:u}=i.next[o];s.push(l.name),a&&!(l.isText||l.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ov(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 lv(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function uv(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function cv(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new VR(t,r,e[r]);return n}let Pb=class dv{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=cv(e,r.attrs),this.defaultAttrs=ov(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==kr.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:lv(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xn(this,this.computeAttrs(e),W.from(n),_e.setFrom(r))}createChecked(e=null,n,r){return n=W.from(n),this.checkContent(n),new Xn(this,this.computeAttrs(e),n,_e.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=W.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(W.empty,!0);return a?new Xn(this,e,n.append(a),_e.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){uv(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:_e.none:e}static compile(e,n){let r=Object.create(null);e.forEach((a,s)=>r[a]=new dv(a,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function GR(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class VR{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?GR(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ko{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=cv(e,i.attrs),this.excluded=null;let a=ov(this.attrs);this.instance=a?new _e(this,a):null}create(e=null){return!e&&this.instance?this.instance:new _e(this,lv(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,s)=>r[a]=new ko(a,i++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){uv(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let pv=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=it.from(e.nodes),n.marks=it.from(e.marks||{}),this.nodes=Pb.compile(this.spec.nodes,this),this.marks=ko.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],s=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=r[s]||(r[s]=kr.parse(s,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?Fb(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],s=a.spec.excludes;a.excluded=s==null?[a]:s==""?[]:Fb(this,s.split(" "))}this.nodeFromJSON=i=>Xn.fromJSON(this,i),this.markFromJSON=i=>_e.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Pb){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new ks(r,r.defaultAttrs,e,_e.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 Fb(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],s=a;if(a)n.push(a);else for(let o in t.marks){let l=t.marks[o];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function WR(t){return t.tag!=null}function YR(t){return t.style!=null}class Zn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(WR(i))this.tags.push(i);else if(YR(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new Ub(this,n,!1);return r.addAll(e,_e.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Ub(this,n,!0);return r.addAll(e,_e.none,n.from,n.to),ee.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(ZR(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let s=a.getAttrs(e);if(s===!1)continue;a.attrs=s||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let s=this.styles[a],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let a=i.priority==null?50:i.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<a)break}n.splice(s,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(s=>{r(s=Hb(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(s=>{r(s=Hb(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Zn(e,Zn.schemaRules(e)))}}const fv={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},KR={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hv={ol:!0,ul:!0},sa=1,jh=2,Hi=4;function Bb(t,e,n){return e!=null?(e?sa:0)|(e==="full"?jh:0):t&&t.whitespace=="pre"?sa|jh:n&~Hi}class Ba{constructor(e,n,r,i,a,s){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=_e.none,this.match=a||(s&Hi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(W.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&sa)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=W.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!fv.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ub{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,s=Bb(null,n.preserveWhitespace,0)|(r?Hi:0);i?a=new Ba(i.type,i.attrs,_e.none,!0,n.topMatch||i.type.contentMatch,s):r?a=new Ba(null,null,_e.none,!0,null,s):a=new Ba(e.schema.topNodeType,null,_e.none,!0,null,s),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&jh?"full":this.localPreserveWS||(i.options&sa)>0,{schema:s}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
3
3
  `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let o=r.split(/\r?\n|\r/);for(let l=0;l<o.length;l++)l&&this.insertNode(s.linebreakReplacement.create(),n,!0),o[l]&&this.insertNode(s.text(o[l]),n,!/\S/.test(o[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let o=i.content[i.content.length-1],l=e.previousSibling;(!o||l&&l.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;hv.hasOwnProperty(s)&&this.parser.normalizeLists&&XR(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:KR.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let u,c=this.needsBlock;if(fv.hasOwnProperty(s))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=l&&l.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),u&&this.sync(a),this.needsBlock=c}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,l,u,l.consuming===!1?o:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],s=r.getPropertyValue(a);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(a,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(u=>!l.clearMark(u)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,i){let a,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(a=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=i==null?null:e.childNodes[i];s!=o;s=s.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(s,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],u=l.findWrapping(e);if(u&&(!i||i.length>u.length+o)&&(i=u,a=l,!u.length))break;if(l.solid){if(r)break;o+=2}}if(!i)return null;this.sync(a);for(let s=0;s<i.length;s++)n=this.enterInner(i[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let s=_e.none;for(let o of i.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):$b(o.type,e.type))&&(s=o.addToSet(s));return a.content.push(e.mark(s)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=Bb(e,a,s.options);s.options&Hi&&s.content.length==0&&(o|=Hi);let l=_e.none;return r=r.filter(u=>(s.type?s.type.allowsMarkType(u.type):$b(u.type,e))?(l=u.addToSet(l),!1):!0),this.nodes.push(new Ba(e,n,l,i,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=sa)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),s=(o,l)=>{for(;o>=0;o--){let u=n[o];if(u==""){if(o==n.length-1||o==0)continue;for(;l>=a;l--)if(s(o-1,l))return!0;return!1}else{let c=l>0||l==0&&i?this.nodes[l].type:r&&l>=a?r.node(l-a).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function XR(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&hv.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function ZR(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Hb(t){let e={};for(let n in t)e[n]=t[n];return e}function $b(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],s=o=>{a.push(o);for(let l=0;l<o.edgeCount;l++){let{type:u,next:c}=o.edge(l);if(u==e||a.indexOf(c)<0&&s(c))return!0}};if(s(i.contentMatch))return!0}}class wr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=ol(n).createDocumentFragment());let i=r,a=[];return e.forEach(s=>{if(a.length||s.marks.length){let o=0,l=0;for(;o<a.length&&l<s.marks.length;){let u=s.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(a[o][0])||u.type.spec.spanning===!1)break;o++,l++}for(;o<a.length;)i=a.pop()[1];for(;l<s.marks.length;){let u=s.marks[l++],c=this.serializeMark(u,s.isInline,n);c&&(a.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=ss(ol(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&ss(ol(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return ss(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new wr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=zb(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return zb(e.marks)}}function zb(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function ol(t){return t.document||window.document}const qb=new WeakMap;function QR(t){let e=qb.get(t);return e===void 0&&qb.set(t,e=JR(t)),e}function JR(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function ss(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=QR(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let o,l=n?t.createElementNS(n,i):t.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let d in u)if(u[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),u[d]):d=="style"&&l.style?l.style.cssText=u[d]:l.setAttribute(d,u[d])}}for(let d=c;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:p,contentDOM:h}=ss(t,f,n,r);if(l.appendChild(p),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}const mv=65535,gv=Math.pow(2,16);function eO(t,e){return t+e*gv}function jb(t){return t&mv}function tO(t){return(t-(t&mv))/gv}const bv=1,Ev=2,ls=4,yv=8;class Gh{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&yv)>0}get deletedBefore(){return(this.delInfo&(bv|ls))>0}get deletedAfter(){return(this.delInfo&(Ev|ls))>0}get deletedAcross(){return(this.delInfo&ls)>0}}class Ut{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ut.empty)return Ut.empty}recover(e){let n=0,r=jb(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+tO(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?i:0);if(l>e)break;let u=this.ranges[o+a],c=this.ranges[o+s],d=l+u;if(e<=d){let f=u?e==l?-1:e==d?1:n:n,p=l+i+(f<0?0:c);if(r)return p;let h=e==(n<0?l:d)?null:eO(o/3,e-l),g=e==l?Ev:e==d?bv:ls;return(n<0?e!=l:e!=d)&&(g|=yv),new Gh(p,g,h)}i+=c-u}return r?e+i:new Gh(e+i,0,null)}touches(e,n){let r=0,i=jb(n),a=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let u=this.ranges[o+a],c=l+u;if(e<=c&&o==i*3)return!0;r+=this.ranges[o+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let s=this.ranges[i],o=s-(this.inverted?a:0),l=s+(this.inverted?0:a),u=this.ranges[i+n],c=this.ranges[i+r];e(o,o+u,l,l+c),a+=c-u}}invert(){return new Ut(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ut.empty:new Ut(e<0?[0,-e,0]:[0,0,e])}}Ut.empty=new Ut([]);class oa{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new oa(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new oa;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let s=this._maps[a],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(a);if(l!=null&&l>a&&l<this.to){a=l,e=this._maps[l].recover(o.recover);continue}}i|=o.delInfo,e=o.pos}return r?e:new Gh(e,i,null)}}const ll=Object.create(null);class ht{getMap(){return Ut.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ll[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 ll)throw new RangeError("Duplicate use of step JSON ID "+e);return ll[e]=n,n.prototype.jsonID=e,n}}class Ge{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ge(e,null)}static fail(e){return new Ge(null,e)}static fromReplace(e,n,r,i){try{return Ge.ok(e.replace(n,r,i))}catch(a){if(a instanceof Ts)return Ge.fail(a.message);throw a}}}function Ym(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(Ym(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return W.fromArray(r)}class Gn extends ht{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new ee(Ym(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Ge.fromReplace(e,this.from,this.to,a)}invert(){return new tn(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 Gn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Gn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Gn(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 Gn(n.from,n.to,e.markFromJSON(n.mark))}}ht.jsonID("addMark",Gn);class tn extends ht{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ee(Ym(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ge.fromReplace(e,this.from,this.to,r)}invert(){return new Gn(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 tn(n.pos,r.pos,this.mark)}merge(e){return e instanceof tn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new tn(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 tn(n.from,n.to,e.markFromJSON(n.mark))}}ht.jsonID("removeMark",tn);class Vn extends ht{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new ee(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Vn(this.pos,n.marks[i]);return new Vn(this.pos,this.mark)}}return new xr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Vn(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 Vn(n.pos,e.markFromJSON(n.mark))}}ht.jsonID("addNodeMark",Vn);class xr extends ht{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new ee(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Vn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new xr(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 xr(n.pos,e.markFromJSON(n.mark))}}ht.jsonID("removeNodeMark",xr);class Qe extends ht{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Vh(e,this.from,this.to)?Ge.fail("Structure replace would overwrite content"):Ge.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ut([this.from,this.to-this.from,this.slice.size])}invert(e){return new Qe(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 Qe(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Qe)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ee.empty:new ee(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Qe(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ee.empty:new ee(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Qe(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 Qe(n.from,n.to,ee.fromJSON(e,n.slice),!!n.structure)}}ht.jsonID("replace",Qe);class tt extends ht{constructor(e,n,r,i,a,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=s,this.structure=o}apply(e){if(this.structure&&(Vh(e,this.from,this.gapFrom)||Vh(e,this.gapTo,this.to)))return Ge.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ge.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ge.fromReplace(e,this.from,this.to,r):Ge.fail("Content does not fit in gap")}getMap(){return new Ut([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 tt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new tt(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new tt(n.from,n.to,n.gapFrom,n.gapTo,ee.fromJSON(e,n.slice),n.insert,!!n.structure)}}ht.jsonID("replaceAround",tt);function Vh(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let s=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function nO(t,e,n,r){let i=[],a=[],s,o;t.doc.nodesBetween(e,n,(l,u,c)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let f=Math.max(u,e),p=Math.min(u+l.nodeSize,n),h=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(h)||(s&&s.to==f&&s.mark.eq(d[g])?s.to=p:i.push(s=new tn(f,p,d[g])));o&&o.to==f?o.to=p:a.push(o=new Gn(f,p,r))}}),i.forEach(l=>t.step(l)),a.forEach(l=>t.step(l))}function rO(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;a++;let l=null;if(r instanceof ko){let u=s.marks,c;for(;c=r.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let u=Math.min(o+s.nodeSize,n);for(let c=0;c<l.length;c++){let d=l[c],f;for(let p=0;p<i.length;p++){let h=i[p];h.step==a-1&&d.eq(i[p].style)&&(f=h)}f?(f.to=u,f.step=a):i.push({style:d,from:Math.max(o,e),to:u,step:a})}}}),i.forEach(s=>t.step(new tn(s.from,s.to,s.style)))}function Km(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<a.childCount;l++){let u=a.child(l),c=o+u.nodeSize,d=r.matchType(u.type);if(!d)s.push(new Qe(o,c,ee.empty));else{r=d;for(let f=0;f<u.marks.length;f++)n.allowsMarkType(u.marks[f].type)||t.step(new tn(o,c,u.marks[f]));if(i&&u.isText&&n.whitespace!="pre"){let f,p=/\r?\n|\r/g,h;for(;f=p.exec(u.text);)h||(h=new ee(W.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),s.push(new Qe(o+f.index,o+f.index+f[0].length,h))}}o=c}if(!r.validEnd){let l=r.fillBefore(W.empty,!0);t.replace(o,o,new ee(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function iO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function hi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let s=t.$from.node(r),o=t.$from.index(r)+i,l=t.$to.indexAfter(r)-a;if(r<t.depth&&s.canReplace(o,l,n))return r;if(r==0||s.type.spec.isolating||!iO(s,o,l))break;o&&(i=1),l<s.childCount&&(a=1)}return null}function aO(t,e,n){let{$from:r,$to:i,depth:a}=e,s=r.before(a+1),o=i.after(a+1),l=s,u=o,c=W.empty,d=0;for(let h=a,g=!1;h>n;h--)g||r.index(h)>0?(g=!0,c=W.from(r.node(h).copy(c)),d++):l--;let f=W.empty,p=0;for(let h=a,g=!1;h>n;h--)g||i.after(h+1)<i.end(h)?(g=!0,f=W.from(i.node(h).copy(f)),p++):u++;t.step(new tt(l,u,s,o,new ee(c.append(f),d,p),c.size-d,!0))}function Xm(t,e,n=null,r=t){let i=sO(t,e),a=i&&oO(r,e);return a?i.map(Gb).concat({type:e,attrs:n}).concat(a.map(Gb)):null}function Gb(t){return{type:t,attrs:null}}function sO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let s=a.length?a[0]:e;return n.canReplaceWith(r,i,s)?a:null}function oO(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),s=e.contentMatch.findWrapping(a.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let u=r;l&&u<i;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:s}function lO(t,e,n){let r=W.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=W.from(n[s].type.create(n[s].attrs,r))}let i=e.start,a=e.end;t.step(new tt(i,a,i,a,new ee(r,0,0),n.length,!0))}function uO(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,l)&&cO(t.doc,t.mapping.slice(a).map(o),r)){let u=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?u=!1:!p&&h&&(u=!0)}u===!1&&Sv(t,s,o,a),Km(t,t.mapping.slice(a).map(o,1),r,void 0,u===null);let c=t.mapping.slice(a),d=c.map(o,1),f=c.map(o+s.nodeSize,1);return t.step(new tt(d,f,d+1,f-1,new ee(W.from(r.create(l,null,s.marks)),0,0),1,!0)),u===!0&&Tv(t,s,o,a),!1}})}function Tv(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(i.text);){let l=t.mapping.slice(r).map(n+1+a+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Sv(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+a);t.replaceWith(s,s+1,e.type.schema.text(`
@@ -137,7 +137,7 @@ ${p.slice(u+2)}`,d+=1;else break}e.push({indent:u,number:parseInt(o,10),content:
137
137
  `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
138
138
  `),[a,s]=DF(i);if(a.length===0)return;const o=$_(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:o,raw:i.slice(0,s).join(`
139
139
  `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(PF,this.editor.getAttributes(u0)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=si({find:c0,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=si({find:c0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(u0)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),FF=/^\s*(\[([( |x])?\])\s$/,BF=_t.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",We(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Sg(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),s=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),u=d=>{var f,p;o.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,o.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};u(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",d=>d.preventDefault()),o.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const h=n();if(typeof h!="number")return!1;const g=p.doc.nodeAt(h);return p.setNodeMarkup(h,void 0,{...g?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,s),i.append(a,l),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)});let c=new Set(Object.keys(e));return{dom:i,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;i.dataset.checked=d.attrs.checked,o.checked=d.attrs.checked,u(d);const f=r.extensionManager.attributes,p=ii(d,f),h=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return c.forEach(b=>{h.has(b)||(b in g?i.setAttribute(b,g[b]):i.removeAttribute(b))}),Object.entries(p).forEach(([b,E])=>{E==null?b in g?i.setAttribute(b,g[b]):i.removeAttribute(b):i.setAttribute(b,E)}),c=h,!0}}}},addInputRules(){return[si({find:FF,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),UF=_t.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",We(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
140
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=om(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=om(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ze.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(L_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(D_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(H_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(z_.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(BF.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(UF.configure(this.options.taskList)),t}});var d0="&nbsp;",HF=" ",$F=_t.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",We(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===d0||r[0].text===HF)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?d0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),zF=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qF=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jF=Rr.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",We(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[ai({find:zF,type:this.type})]},addPasteRules(){return[_r({find:qF,type:this.type})]}}),GF=_t.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),VF=Rr.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",We(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),WF=ze.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push($P.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(PP.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(L_.configure(this.options.bulletList)),this.options.code!==!1&&i.push(jP.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(WP.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(YP.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(NP.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(IP.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(KP.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(XP.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(LP.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(ZP.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(nF.configure(this.options.italic)),this.options.listItem!==!1&&i.push(D_.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(H_.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(_F.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(z_.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push($F.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(jF.configure(this.options.strike)),this.options.text!==!1&&i.push(GF.configure(this.options.text)),this.options.underline!==!1&&i.push(VF.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(OP.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),q_=WF;var YF=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],ym=YF.join(","),j_=typeof Element>"u",ga=j_?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,uo=!j_&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},co=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),a=i===""||i==="true",s=a||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):co(e.parentNode));return s},KF=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},XF=function(e,n,r){if(co(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(ym));return n&&ga.call(e,ym)&&i.unshift(e),i=i.filter(r),i},Tm=function(e,n,r){for(var i=[],a=Array.from(e);a.length;){var s=a.shift();if(!co(s,!1))if(s.tagName==="SLOT"){var o=s.assignedElements(),l=o.length?o:s.children,u=Tm(l,!0,r);r.flatten?i.push.apply(i,u):i.push({scopeParent:s,candidates:u})}else{var c=ga.call(s,ym);c&&r.filter(s)&&(n||!e.includes(s))&&i.push(s);var d=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),f=!co(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(d&&f){var p=Tm(d===!0?s.children:d.children,!0,r);r.flatten?i.push.apply(i,p):i.push({scopeParent:s,candidates:p})}else a.unshift.apply(a,s.children)}}return i},G_=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},V_=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||KF(e))&&!G_(e)?0:e.tabIndex},ZF=function(e,n){var r=V_(e);return r<0&&n&&!G_(e)?0:r},QF=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},W_=function(e){return e.tagName==="INPUT"},JF=function(e){return W_(e)&&e.type==="hidden"},eB=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},tB=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},nB=function(e){if(!e.name)return!0;var n=e.form||uo(e),r=function(o){return n.querySelectorAll('input[type="radio"][name="'+o+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var a=tB(i,e.form);return!a||a===e},rB=function(e){return W_(e)&&e.type==="radio"},iB=function(e){return rB(e)&&!nB(e)},aB=function(e){var n,r=e&&uo(e),i=(n=r)===null||n===void 0?void 0:n.host,a=!1;if(r&&r!==e){var s,o,l;for(a=!!((s=i)!==null&&s!==void 0&&(o=s.ownerDocument)!==null&&o!==void 0&&o.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!a&&i;){var u,c,d;r=uo(i),i=(u=r)===null||u===void 0?void 0:u.host,a=!!((c=i)!==null&&c!==void 0&&(d=c.ownerDocument)!==null&&d!==void 0&&d.contains(i))}}return a},p0=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},sB=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var a=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(e).visibility==="hidden")return!0;var s=ga.call(e,"details>summary:first-of-type"),o=s?e.parentElement:e;if(ga.call(o,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=e;e;){var u=e.parentElement,c=uo(e);if(u&&!u.shadowRoot&&i(u)===!0)return p0(e);e.assignedSlot?e=e.assignedSlot:!u&&c!==e.ownerDocument?e=c.host:e=u}e=l}if(aB(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return p0(e);return!1},oB=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return ga.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},lB=function(e,n){return!(n.disabled||JF(n)||sB(n,e)||eB(n)||oB(n))},f0=function(e,n){return!(iB(n)||V_(n)<0||!lB(e,n))},uB=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Y_=function(e){var n=[],r=[];return e.forEach(function(i,a){var s=!!i.scopeParent,o=s?i.scopeParent:i,l=ZF(o,s),u=s?Y_(i.candidates):o;l===0?s?n.push.apply(n,u):n.push(o):r.push({documentOrder:a,tabIndex:l,item:i,isScope:s,content:u})}),r.sort(QF).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},K_=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Tm([e],n.includeContainer,{filter:f0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:uB}):r=XF(e,n.includeContainer,f0.bind(null,n)),Y_(r)};function cB(){return/apple/i.test(navigator.vendor)}const h0="data-floating-ui-focusable";function dB(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function Sm(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&ww(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function xi(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Ll(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function pB(t){return t.matches("html,body")}function ba(t){return t?.ownerDocument||document}function fB(t){return t?t.hasAttribute(h0)?t:t.querySelector("["+h0+"]")||t:null}function ps(t,e,n){return n===void 0&&(n=!0),t.filter(i=>{var a;return i.parentId===e&&(!n||((a=i.context)==null?void 0:a.open))}).flatMap(i=>[i,...ps(t,i.id,n)])}function hB(t){return"nativeEvent"in t}var mB=typeof document<"u",gB=function(){},Sr=mB?U.useLayoutEffect:gB;const bB={...Rx},EB=bB.useInsertionEffect,yB=EB||(t=>t());function jr(t){const e=U.useRef(()=>{});return yB(()=>{e.current=t}),U.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}const X_=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Z_(t,e){const n=K_(t,X_()),r=n.length;if(r===0)return;const i=dB(ba(t)),a=n.indexOf(i),s=a===-1?e===1?0:r-1:a+e;return n[s]}function TB(t){return Z_(ba(t).body,1)||t}function SB(t){return Z_(ba(t).body,-1)||t}function Dl(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!Sm(n,r)}function AB(t){K_(t,X_()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function m0(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const kB="data-floating-ui-focusable",g0="active",b0="selected",xB={...Rx};let E0=!1,vB=0;const y0=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+vB++;function CB(){const[t,e]=U.useState(()=>E0?y0():void 0);return Sr(()=>{t==null&&e(y0())},[]),U.useEffect(()=>{E0=!0},[]),t}const _B=xB.useId,Pg=_B||CB;function NB(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const IB=U.createContext(null),wB=U.createContext(null),Q_=()=>{var t;return((t=U.useContext(IB))==null?void 0:t.id)||null},J_=()=>U.useContext(wB);function Fg(t){return"data-floating-ui-"+t}const RB={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},T0=U.forwardRef(function(e,n){const[r,i]=U.useState();Sr(()=>{cB()&&i("button")},[]);const a={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Fg("focus-guard")]:"",style:RB};return T.jsx("span",{...e,...a})}),OB={clipPath:"inset(50%)",position:"fixed",top:0,left:0},eN=U.createContext(null),S0=Fg("portal");function LB(t){t===void 0&&(t={});const{id:e,root:n}=t,r=Pg(),i=MB(),[a,s]=U.useState(null),o=U.useRef(null);return Sr(()=>()=>{a?.remove(),queueMicrotask(()=>{o.current=null})},[a]),Sr(()=>{if(!r||o.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=r,u.setAttribute(S0,""),l.appendChild(u),o.current=u,s(u)},[e,r]),Sr(()=>{if(n===null||!r||o.current)return;let l=n||i?.portalNode;l&&!Pw(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const c=document.createElement("div");c.id=r,c.setAttribute(S0,""),l=u||l,l.appendChild(c),o.current=c,s(c)},[e,n,r,i]),a}function DB(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,a=LB({id:n,root:r}),[s,o]=U.useState(null),l=U.useRef(null),u=U.useRef(null),c=U.useRef(null),d=U.useRef(null),f=s?.modal,p=s?.open,h=!!s&&!s.modal&&s.open&&i&&!!(r||a);return U.useEffect(()=>{if(!a||!i||f)return;function g(b){a&&Dl(b)&&(b.type==="focusin"?m0:AB)(a)}return a.addEventListener("focusin",g,!0),a.addEventListener("focusout",g,!0),()=>{a.removeEventListener("focusin",g,!0),a.removeEventListener("focusout",g,!0)}},[a,i,f]),U.useEffect(()=>{a&&(p||m0(a))},[p,a]),T.jsxs(eN.Provider,{value:U.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:c,afterInsideRef:d,portalNode:a,setFocusManagerState:o}),[i,a]),children:[h&&a&&T.jsx(T0,{"data-type":"outside",ref:l,onFocus:g=>{if(Dl(g,a)){var b;(b=c.current)==null||b.focus()}else{const E=s?s.domReference:null,y=SB(E);y?.focus()}}}),h&&a&&T.jsx("span",{"aria-owns":a.id,style:OB}),a&&Ix.createPortal(e,a),h&&a&&T.jsx(T0,{"data-type":"outside",ref:u,onFocus:g=>{if(Dl(g,a)){var b;(b=d.current)==null||b.focus()}else{const E=s?s.domReference:null,y=TB(E);y?.focus(),s?.closeOnFocusOut&&s?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const MB=()=>U.useContext(eN),PB={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},FB={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},A0=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function BB(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:a}=t,{enabled:s=!0,escapeKey:o=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:c=!1,referencePressEvent:d="pointerdown",ancestorScroll:f=!1,bubbles:p,capture:h}=e,g=J_(),b=jr(typeof l=="function"?l:()=>!1),E=typeof l=="function"?b:l,y=U.useRef(!1),{escapeKey:S,outsidePress:k}=A0(p),{escapeKey:x,outsidePress:A}=A0(h),v=U.useRef(!1),w=jr(P=>{var F;if(!n||!s||!o||P.key!=="Escape"||v.current)return;const $=(F=a.current.floatingContext)==null?void 0:F.nodeId,G=g?ps(g.nodesRef.current,$):[];if(!S&&(P.stopPropagation(),G.length>0)){let H=!0;if(G.forEach(J=>{var I;if((I=J.context)!=null&&I.open&&!J.context.dataRef.current.__escapeKeyBubbles){H=!1;return}}),!H)return}r(!1,hB(P)?P.nativeEvent:P,"escape-key")}),N=jr(P=>{var F;const $=()=>{var G;w(P),(G=xi(P))==null||G.removeEventListener("keydown",$)};(F=xi(P))==null||F.addEventListener("keydown",$)}),_=jr(P=>{var F;const $=a.current.insideReactTree;a.current.insideReactTree=!1;const G=y.current;if(y.current=!1,u==="click"&&G||$||typeof E=="function"&&!E(P))return;const H=xi(P),J="["+Fg("inert")+"]",I=ba(i.floating).querySelectorAll(J);let X=dn(H)?H:null;for(;X&&!al(X);){const te=Lw(X);if(al(te)||!dn(te))break;X=te}if(I.length&&dn(H)&&!pB(H)&&!Sm(H,i.floating)&&Array.from(I).every(te=>!Sm(X,te)))return;if(Dw(H)&&q){const te=al(H),se=Mw(H),he=/auto|scroll/,Ae=te||he.test(se.overflowX),ve=te||he.test(se.overflowY),Ce=Ae&&H.clientWidth>0&&H.scrollWidth>H.clientWidth,De=ve&&H.clientHeight>0&&H.scrollHeight>H.clientHeight,Ke=se.direction==="rtl",we=De&&(Ke?P.offsetX<=H.offsetWidth-H.clientWidth:P.offsetX>H.clientWidth),lt=Ce&&P.offsetY>H.clientHeight;if(we||lt)return}const re=(F=a.current.floatingContext)==null?void 0:F.nodeId,R=g&&ps(g.nodesRef.current,re).some(te=>{var se;return Ll(P,(se=te.context)==null?void 0:se.elements.floating)});if(Ll(P,i.floating)||Ll(P,i.domReference)||R)return;const ie=g?ps(g.nodesRef.current,re):[];if(ie.length>0){let te=!0;if(ie.forEach(se=>{var he;if((he=se.context)!=null&&he.open&&!se.context.dataRef.current.__outsidePressBubbles){te=!1;return}}),!te)return}r(!1,P,"outside-press")}),D=jr(P=>{var F;const $=()=>{var G;_(P),(G=xi(P))==null||G.removeEventListener(u,$)};(F=xi(P))==null||F.addEventListener(u,$)});U.useEffect(()=>{if(!n||!s)return;a.current.__escapeKeyBubbles=S,a.current.__outsidePressBubbles=k;let P=-1;function F(I){r(!1,I,"ancestor-scroll")}function $(){window.clearTimeout(P),v.current=!0}function G(){P=window.setTimeout(()=>{v.current=!1},Ow()?5:0)}const H=ba(i.floating);o&&(H.addEventListener("keydown",x?N:w,x),H.addEventListener("compositionstart",$),H.addEventListener("compositionend",G)),E&&H.addEventListener(u,A?D:_,A);let J=[];return f&&(dn(i.domReference)&&(J=il(i.domReference)),dn(i.floating)&&(J=J.concat(il(i.floating))),!dn(i.reference)&&i.reference&&i.reference.contextElement&&(J=J.concat(il(i.reference.contextElement)))),J=J.filter(I=>{var X;return I!==((X=H.defaultView)==null?void 0:X.visualViewport)}),J.forEach(I=>{I.addEventListener("scroll",F,{passive:!0})}),()=>{o&&(H.removeEventListener("keydown",x?N:w,x),H.removeEventListener("compositionstart",$),H.removeEventListener("compositionend",G)),E&&H.removeEventListener(u,A?D:_,A),J.forEach(I=>{I.removeEventListener("scroll",F)}),window.clearTimeout(P)}},[a,i,o,E,u,n,r,f,s,S,k,w,x,N,_,A,D]),U.useEffect(()=>{a.current.insideReactTree=!1},[a,E,u]);const M=U.useMemo(()=>({onKeyDown:w,...c&&{[PB[d]]:P=>{r(!1,P.nativeEvent,"reference-press")},...d!=="click"&&{onClick(P){r(!1,P.nativeEvent,"reference-press")}}}}),[w,r,c,d]),q=U.useMemo(()=>({onKeyDown:w,onMouseDown(){y.current=!0},onMouseUp(){y.current=!0},[FB[u]]:()=>{a.current.insideReactTree=!0}}),[w,u,a]);return U.useMemo(()=>s?{reference:M,floating:q}:{},[s,M,q])}function UB(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=Pg(),a=U.useRef({}),[s]=U.useState(()=>NB()),o=Q_()!=null,[l,u]=U.useState(r.reference),c=jr((p,h,g)=>{a.current.openEvent=p?h:void 0,s.emit("openchange",{open:p,event:h,reason:g,nested:o}),n?.(p,h,g)}),d=U.useMemo(()=>({setPositionReference:u}),[]),f=U.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return U.useMemo(()=>({dataRef:a,open:e,onOpenChange:c,elements:f,events:s,floatingId:i,refs:d}),[e,c,f,s,i,d])}function HB(t){t===void 0&&(t={});const{nodeId:e}=t,n=UB({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[a,s]=U.useState(null),[o,l]=U.useState(null),c=i?.domReference||a,d=U.useRef(null),f=J_();Sr(()=>{c&&(d.current=c)},[c]);const p=Rw({...t,elements:{...i,...o&&{reference:o}}}),h=U.useCallback(S=>{const k=dn(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;l(k),p.refs.setReference(k)},[p.refs]),g=U.useCallback(S=>{(dn(S)||S===null)&&(d.current=S,s(S)),(dn(p.refs.reference.current)||p.refs.reference.current===null||S!==null&&!dn(S))&&p.refs.setReference(S)},[p.refs]),b=U.useMemo(()=>({...p.refs,setReference:g,setPositionReference:h,domReference:d}),[p.refs,g,h]),E=U.useMemo(()=>({...p.elements,domReference:c}),[p.elements,c]),y=U.useMemo(()=>({...p,...r,refs:b,elements:E,nodeId:e}),[p,b,E,e,r]);return Sr(()=>{r.dataRef.current.floatingContext=y;const S=f?.nodesRef.current.find(k=>k.id===e);S&&(S.context=y)}),U.useMemo(()=>({...p,context:y,refs:b,elements:E}),[p,b,E,y])}function Ml(t,e,n){const r=new Map,i=n==="item";let a=t;if(i&&t){const{[g0]:s,[b0]:o,...l}=t;a=l}return{...n==="floating"&&{tabIndex:-1,[kB]:""},...a,...e.map(s=>{const o=s?s[n]:null;return typeof o=="function"?t?o(t):null:o}).concat(t).reduce((s,o)=>(o&&Object.entries(o).forEach(l=>{let[u,c]=l;if(!(i&&[g0,b0].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof c=="function"){var d;(d=r.get(u))==null||d.push(c),s[u]=function(){for(var f,p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return(f=r.get(u))==null?void 0:f.map(b=>b(...h)).find(b=>b!==void 0)}}}else s[u]=c}),s),{})}}function $B(t){t===void 0&&(t=[]);const e=t.map(o=>o?.reference),n=t.map(o=>o?.floating),r=t.map(o=>o?.item),i=U.useCallback(o=>Ml(o,t,"reference"),e),a=U.useCallback(o=>Ml(o,t,"floating"),n),s=U.useCallback(o=>Ml(o,t,"item"),r);return U.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:s}),[i,a,s])}const zB=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function qB(t,e){var n,r;e===void 0&&(e={});const{open:i,elements:a,floatingId:s}=t,{enabled:o=!0,role:l="dialog"}=e,u=Pg(),c=((n=a.domReference)==null?void 0:n.id)||u,d=U.useMemo(()=>{var y;return((y=fB(a.floating))==null?void 0:y.id)||s},[a.floating,s]),f=(r=zB.get(l))!=null?r:l,h=Q_()!=null,g=U.useMemo(()=>f==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:i?d:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":i?d:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:c},...f==="menu"&&h&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[f,d,h,i,c,l]),b=U.useMemo(()=>{const y={id:d,...f&&{role:f}};return f==="tooltip"||l==="label"?y:{...y,...f==="menu"&&{"aria-labelledby":c}}},[f,d,c,l]),E=U.useCallback(y=>{let{active:S,selected:k}=y;const x={role:"option",...S&&{id:d+"-fui-option"}};switch(l){case"select":case"combobox":return{...x,"aria-selected":k}}return{}},[d,l]);return U.useMemo(()=>o?{reference:g,floating:b,item:E}:{},[o,g,b,E])}function jB(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:o}=t,l=r&&!i,u=IM(n),c=new RegExp(`\\s${u}$`),d=s?"^":"",f=i?"":u,p=l?new RegExp(`${d}${u}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${u}[^\\s${f}]*`,"gm"),h=((e=o.nodeBefore)==null?void 0:e.isText)&&o.nodeBefore.text;if(!h)return null;const g=o.pos-h.length,b=Array.from(h.matchAll(p)).pop();if(!b||b.input===void 0||b.index===void 0)return null;const E=b.input.slice(Math.max(0,b.index-1),b.index),y=new RegExp(`^[${a?.join("")}\0]?$`).test(E);if(a!==null&&!y)return null;const S=g+b.index;let k=S+b[0].length;return l&&c.test(h.slice(k-1,k+1))&&(b[0]+=" ",k+=1),S<o.pos&&k>=o.pos?{range:{from:S,to:k},query:b[0].slice(n.length),text:b[0]}:null}var GB=new Fe("suggestion");function VB({pluginKey:t=GB,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:c="is-empty",command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:h=()=>!0,findSuggestionMatch:g=jB,shouldShow:b}){let E;const y=p?.(),S=()=>{const v=e.state.selection.$anchor.pos,w=e.view.coordsAtPos(v),{top:N,right:_,bottom:D,left:M}=w;try{return new DOMRect(M,N,_-M,D-N)}catch{return null}},k=(v,w)=>w?()=>{const N=t.getState(e.state),_=N?.decorationId,D=v.dom.querySelector(`[data-decoration-id="${_}"]`);return D?.getBoundingClientRect()||null}:S;function x(v,w){var N;try{const D=t.getState(v.state),M=D?.decorationId?v.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,q={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:P=>d({editor:e,range:D?.range||{from:0,to:0},props:P}),decorationNode:M,clientRect:k(v,M)};(N=y?.onExit)==null||N.call(y,q)}catch{}const _=v.state.tr.setMeta(w,{exit:!0});v.dispatch(_)}const A=new Le({key:t,view(){return{update:async(v,w)=>{var N,_,D,M,q,P,F;const $=(N=this.key)==null?void 0:N.getState(w),G=(_=this.key)==null?void 0:_.getState(v.state),H=$.active&&G.active&&$.range.from!==G.range.from,J=!$.active&&G.active,I=$.active&&!G.active,X=!J&&!I&&$.query!==G.query,re=J||H&&X,R=X||H,ie=I||H&&X;if(!re&&!R&&!ie)return;const te=ie&&!re?$:G,se=v.dom.querySelector(`[data-decoration-id="${te.decorationId}"]`);E={editor:e,range:te.range,query:te.query,text:te.text,items:[],command:he=>d({editor:e,range:te.range,props:he}),decorationNode:se,clientRect:k(v,se)},re&&((D=y?.onBeforeStart)==null||D.call(y,E)),R&&((M=y?.onBeforeUpdate)==null||M.call(y,E)),(R||re)&&(E.items=await f({editor:e,query:te.query})),ie&&((q=y?.onExit)==null||q.call(y,E)),R&&((P=y?.onUpdate)==null||P.call(y,E)),re&&((F=y?.onStart)==null||F.call(y,E))},destroy:()=>{var v;E&&((v=y?.onExit)==null||v.call(y,E))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,w,N,_){const{isEditable:D}=e,{composing:M}=e.view,{selection:q}=v,{empty:P,from:F}=q,$={...w},G=v.getMeta(t);if(G&&G.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=M,D&&(P||e.view.composing)){(F<w.range.from||F>w.range.to)&&!M&&!w.composing&&($.active=!1);const H=g({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:q.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;H&&h({editor:e,state:_,range:H.range,isActive:w.active})&&(!b||b({editor:e,range:H.range,query:H.query,text:H.text,transaction:v}))?($.active=!0,$.decorationId=w.decorationId?w.decorationId:J,$.range=H.range,$.query=H.query,$.text=H.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(v,w){var N,_,D,M;const{active:q,range:P}=A.getState(v.state);if(!q)return!1;if(w.key==="Escape"||w.key==="Esc"){const $=A.getState(v.state),G=(N=E?.decorationNode)!=null?N:null,H=G??($?.decorationId?v.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((_=y?.onKeyDown)==null?void 0:_.call(y,{view:v,event:w,range:$.range}))||!1)return!0;const I={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:X=>d({editor:e,range:$.range,props:X}),decorationNode:H,clientRect:H?()=>H.getBoundingClientRect()||null:null};return(D=y?.onExit)==null||D.call(y,I),x(v,t),!0}return((M=y?.onKeyDown)==null?void 0:M.call(y,{view:v,event:w,range:P}))||!1},decorations(v){const{active:w,range:N,decorationId:_,query:D}=A.getState(v);if(!w)return null;const M=!D?.length,q=[l];return M&&q.push(c),Pe.create(v.doc,[dt.inline(N.from,N.to,{nodeName:o,class:q.join(" "),"data-decoration-id":_,"data-decoration-content":u})])}}});return A}function WB(t){const e=ae.c(26),{editor:n,query:r,items:i,onSelect:a,onClose:s}=t,[o,l]=U.useState(0),u=U.useRef(i),c=U.useRef(o),d=U.useRef(a),f=U.useRef(s),p=U.useDeferredValue(r);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l(0)},e[0]=h):h=e[0];let g;e[1]!==p?(g=[p],e[1]=p,e[2]=g):g=e[2],U.useEffect(h,g);let b,E;e[3]!==i.length||e[4]!==o?(b=()=>{o>=i.length&&i.length>0&&l(0)},E=[i.length,o],e[3]=i.length,e[4]=o,e[5]=b,e[6]=E):(b=e[5],E=e[6]),U.useEffect(b,E);let y,S;e[7]!==i?(y=()=>{u.current=i},S=[i],e[7]=i,e[8]=y,e[9]=S):(y=e[8],S=e[9]),U.useEffect(y,S);let k,x;e[10]!==o?(k=()=>{c.current=o},x=[o],e[10]=o,e[11]=k,e[12]=x):(k=e[11],x=e[12]),U.useEffect(k,x);let A,v;e[13]!==a?(v=()=>{d.current=a},A=[a],e[13]=a,e[14]=A,e[15]=v):(A=e[14],v=e[15]),U.useEffect(v,A);let w,N;e[16]!==s?(w=()=>{f.current=s},N=[s],e[16]=s,e[17]=w,e[18]=N):(w=e[17],N=e[18]),U.useEffect(w,N);let _;e[19]!==n.isDestroyed||e[20]!==n.view.dom?(_=()=>{const P=n.view.dom;if(n?.isDestroyed||!P)return;const F=G=>{const H=u.current;if(!H.length)return!1;const J=()=>l(X=>(X+1)%H.length),I=()=>l(X=>(X-1+H.length)%H.length);switch(G.key){case"ArrowUp":return G.preventDefault(),I(),!0;case"ArrowDown":return G.preventDefault(),J(),!0;case"Tab":return G.preventDefault(),G.shiftKey?I():J(),!0;case"Home":return G.preventDefault(),l(0),!0;case"End":return G.preventDefault(),l(H.length-1),!0;case"Enter":{if(G.isComposing)return!1;G.preventDefault();const X=c.current;return X!==-1&&H[X]&&d.current?.(H[X],X),!0}case"Escape":return G.preventDefault(),f.current?.(),!0;default:return!1}},$=G=>{F(G)};return P.addEventListener("keydown",$,!0),()=>{P?.removeEventListener("keydown",$,!0)}},e[19]=n.isDestroyed,e[20]=n.view.dom,e[21]=_):_=e[21];let D;e[22]!==n?(D=[n],e[22]=n,e[23]=D):D=e[23],U.useEffect(_,D);const M=i.length?o:void 0;let q;return e[24]!==M?(q={selectedIndex:M,setSelectedIndex:l},e[24]=M,e[25]=q):q=e[25],q}function YB(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const tN=U.createContext(void 0);function nN(){const t=U.useContext(tN);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function KB(t){const e=ae.c(8),{editor:n,char:r,pluginKey:i}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:!1,element:null,query:"",range:null,selectedItem:null},e[0]=a):a=e[0];const[s,o]=U.useReducer(YB,a);let l,u;e[1]!==r||e[2]!==n||e[3]!==i?(l=()=>{if(n?.isDestroyed)return;const d=i instanceof Fe?i:new Fe(i);n.state.plugins.find(h=>h.spec.key===d)&&n.unregisterPlugin(d);const p=VB({pluginKey:d,editor:n,char:r,allow(h){const g=n.state.doc.resolve(h.range.from);for(let b=g.depth;b>0;b--)if(g.node(b).type.name==="image")return!1;return!0},command(){},render:()=>({onStart:h=>{o({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onUpdate:h=>{o({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(o({type:"ON_EXIT"}),!0):!1,onExit:()=>{o({type:"ON_EXIT"})}}),items:XB});return n.registerPlugin(p),()=>{n?.isDestroyed||n.unregisterPlugin(d)}},u=[n,i,r,o],e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=u):(l=e[4],u=e[5]),U.useEffect(l,u);let c;return e[6]!==s?(c={state:s,dispatch:o},e[6]=s,e[7]=c):c=e[7],c}function XB(){return[]}function ZB({editor:t,queryKey:e,queryFn:n,onSelect:r}){const{state:i,dispatch:a}=nN(),s=U.useDeferredValue(i.query),{data:o}=Fw({queryKey:qm.suggestionItems(e,i.open,s),queryFn:()=>i.open?n({query:s}):[]}),l=()=>{a({type:"ON_EXIT"})},u=async(d,f)=>{if(!(i.selectedItem!==null||!i.range)){a({type:"SET_SELECTED_ITEM",payload:d});try{const{view:p}=t,g=p.state.selection.$to.nodeAfter?.text?.startsWith(" "),b=i.range?{...i.range}:{from:0,to:0};g&&i.range&&(b.to+=1),await r({range:b,item:d})}finally{l()}}},{selectedIndex:c}=WB({editor:t,query:s,items:o,onSelect:u,onClose:l});return{selectedItem:i.selectedItem,items:o,selectedIndex:c,close:l,onSelect:u}}function QB({children:t}){const{state:e,dispatch:n}=nN(),{open:r,element:i}=e,a=()=>{n({type:"ON_EXIT"})},{refs:s,floatingStyles:o,context:l}=HB({placement:"bottom-start",open:r,onOpenChange:f=>{f||a()},elements:{reference:i},middleware:[Bw(10),Uw(),Hw()],whileElementsMounted:$w}),u=BB(l,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),c=qB(l,{role:"listbox"}),{getFloatingProps:d}=$B([u,c]);return r?T.jsx(DB,{children:T.jsx("div",{ref:s.setFloating,style:o,...d(),className:"z-50 w-auto min-w-[280px] max-w-[400px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const JB=t=>{const e=ae.c(23),{item:n,isSelected:r,onSelect:i,isLoading:a,ref:s}=t,o=r&&"bg-accent text-accent-foreground",l=a&&"pointer-events-none opacity-50";let u;e[0]!==o||e[1]!==l?(u=pe("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",o,l),e[0]=o,e[1]=l,e[2]=u):u=e[2];let c;e[3]!==n.name||e[4]!==n.title?(c=n.title||n.name.replace(/_/g," "),e[3]=n.name,e[4]=n.title,e[5]=c):c=e[5];let d;e[6]!==c?(d=T.jsx("span",{className:"font-medium flex items-center truncate",children:c}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==a?(f=a&&T.jsx(So,{size:"xs"}),e[8]=a,e[9]=f):f=e[9];let p;e[10]!==d||e[11]!==f?(p=T.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d,f]}),e[10]=d,e[11]=f,e[12]=p):p=e[12];let h;e[13]!==n.description?(h=n.description&&T.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:n.description}),e[13]=n.description,e[14]=h):h=e[14];let g;e[15]!==p||e[16]!==h?(g=T.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[p,h]}),e[15]=p,e[16]=h,e[17]=g):g=e[17];let b;return e[18]!==i||e[19]!==s||e[20]!==u||e[21]!==g?(b=T.jsx("div",{ref:s,onClick:i,className:u,children:g}),e[18]=i,e[19]=s,e[20]=u,e[21]=g,e[22]=b):b=e[22],b},e4=t=>{const e=ae.c(18),{editor:n,queryKey:r,queryFn:i,onSelect:a}=t;let s;e[0]!==n||e[1]!==a||e[2]!==i||e[3]!==r?(s={editor:n,queryKey:r,queryFn:i,onSelect:a},e[0]=n,e[1]=a,e[2]=i,e[3]=r,e[4]=s):s=e[4];const{items:o,selectedIndex:l,onSelect:u,selectedItem:c}=ZB(s);if(!o.length){let h;return e[5]===Symbol.for("react.memo_cache_sentinel")?(h=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=h):h=e[5],h}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={maxHeight:"min(217px, var(--radix-popover-content-available-height, 217px))"},e[6]=d):d=e[6];let f;if(e[7]!==u||e[8]!==o||e[9]!==l||e[10]!==c?.name){let h;e[12]!==u||e[13]!==l||e[14]!==c?.name?(h=(g,b)=>T.jsx(JB,{item:g,isSelected:b===l,ref:b===l?r4:void 0,onSelect:()=>u(g,b),isLoading:c?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=c?.name,e[15]=h):h=e[15],f=o.map(h),e[7]=u,e[8]=o,e[9]=l,e[10]=c?.name,e[11]=f}else f=e[11];let p;return e[16]!==f?(p=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:d,children:T.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=p):p=e[17],p};function t4(){const t=ae.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsx("div",{className:"p-1",children:[...Array(3)].map(n4)}),t[0]=e):e=t[0],e}function n4(t,e){return T.jsxs("div",{className:"px-2 py-1.5 h-[44px] animate-pulse",children:[T.jsx("div",{className:"h-4 w-24 bg-muted rounded mb-1"}),T.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function rN(t){const e=ae.c(16),{editor:n,char:r,pluginKey:i,queryKey:a,queryFn:s,onSelect:o}=t;let l;e[0]!==r||e[1]!==n||e[2]!==i?(l={editor:n,char:r,pluginKey:i},e[0]=r,e[1]=n,e[2]=i,e[3]=l):l=e[3];const{state:u,dispatch:c}=KB(l);let d;e[4]!==c||e[5]!==u?(d={state:u,dispatch:c},e[4]=c,e[5]=u,e[6]=d):d=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=T.jsx(t4,{}),e[7]=f):f=e[7];let p;e[8]!==n||e[9]!==o||e[10]!==s||e[11]!==a?(p=T.jsx(QB,{children:T.jsx(U.Suspense,{fallback:f,children:T.jsx(e4,{editor:n,queryKey:a,queryFn:s,onSelect:o})})}),e[8]=n,e[9]=o,e[10]=s,e[11]=a,e[12]=p):p=e[12];let h;return e[13]!==d||e[14]!==p?(h=T.jsx(tN.Provider,{value:d,children:p}),e[13]=d,e[14]=p,e[15]=h):h=e[15],h}function r4(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}async function k0(t,e,n,r,i){try{const a=await Fx(n,r,i);f_(t,e,{id:r,name:r,metadata:a.messages,char:"/"})}catch(a){console.error("[prompt] Failed to fetch prompt:",a),_n.error("Failed to load prompt. Please try again.")}}const i4=t=>{const e=ae.c(29),{editor:n,virtualMcpId:r}=t,i=Ox(),{org:a}=ci();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=Vm(s);let l;e[3]!==a.id||e[4]!==r?(l=qm.virtualMcpPrompts(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l,[c,d]=U.useState(null);let f;e[6]!==o||e[7]!==n?(f=async v=>{const{item:w,range:N}=v;if(w.arguments&&w.arguments.length>0){d({range:N,item:w});return}o&&await k0(n,N,o,w.name)},e[6]=o,e[7]=n,e[8]=f):f=e[8];const p=f;let h;e[9]!==c||e[10]!==o||e[11]!==n?(h=async v=>{if(!c||!o)return;const{range:w,item:N}=c;await k0(n,w,o,N.name,v),d(null)},e[9]=c,e[10]=o,e[11]=n,e[12]=h):h=e[12];const g=h;let b;e[13]!==o||e[14]!==i||e[15]!==u?(b=async v=>{const{query:w}=v;if(!o)return[];let N=i.getQueryData(u);if(N?i.fetchQuery({queryKey:u,queryFn:()=>wb(o),staleTime:6e4}).catch(a4):N=(await i.fetchQuery({queryKey:u,queryFn:()=>wb(o),staleTime:6e4})).prompts,!N)return[];let _=N;if(w.trim()){const D=w.toLowerCase();_=N.filter(M=>M.name.toLowerCase().includes(D)||M.title?.toLowerCase().includes(D)||M.description?.toLowerCase().includes(D))}return _},e[13]=o,e[14]=i,e[15]=u,e[16]=b):b=e[16];const E=b;let y;e[17]!==n||e[18]!==E||e[19]!==p||e[20]!==u?(y=T.jsx(rN,{editor:n,char:"/",pluginKey:"promptsDropdownMenu",queryKey:u,queryFn:E,onSelect:p}),e[17]=n,e[18]=E,e[19]=p,e[20]=u,e[21]=y):y=e[21];const S=c?.item??null;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=()=>d(null),e[22]=k):k=e[22];let x;e[23]!==g||e[24]!==S?(x=T.jsx(Xx,{prompt:S,setPrompt:k,onSubmit:g}),e[23]=g,e[24]=S,e[25]=x):x=e[25];let A;return e[26]!==y||e[27]!==x?(A=T.jsxs(T.Fragment,{children:[y,x]}),e[26]=y,e[27]=x,e[28]=A):A=e[28],A};function a4(){}async function s4(t,e,n,r){try{const i=await eR(n,r);f_(t,e,{id:r,name:r,metadata:i.contents,char:"@"})}catch(i){console.error("[resource] Failed to fetch resource:",i),_n.error("Failed to load resource. Please try again.")}}const o4=t=>{const e=ae.c(18),{editor:n,virtualMcpId:r}=t,i=Ox(),{org:a}=ci();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=Vm(s);let l;e[3]!==a.id||e[4]!==r?(l=qm.virtualMcpResources(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l;let c;e[6]!==o||e[7]!==n?(c=async g=>{const{item:b,range:E}=g;o&&await s4(n,E,o,b.uri)},e[6]=o,e[7]=n,e[8]=c):c=e[8];const d=c;let f;e[9]!==o||e[10]!==i||e[11]!==u?(f=async g=>{const{query:b}=g;if(!o)return[];let E=i.getQueryData(u);if(E?i.fetchQuery({queryKey:u,queryFn:()=>Rb(o),staleTime:6e4}).catch(l4):E=(await i.fetchQuery({queryKey:u,queryFn:()=>Rb(o),staleTime:6e4})).resources,!E)return[];let y=E;if(b.trim()){const S=b.toLowerCase();y=E.filter(k=>k.uri.toLowerCase().includes(S)||k.name?.toLowerCase().includes(S)||k.description?.toLowerCase().includes(S))}return y.map(u4)},e[9]=o,e[10]=i,e[11]=u,e[12]=f):f=e[12];const p=f;let h;return e[13]!==n||e[14]!==p||e[15]!==d||e[16]!==u?(h=T.jsx(rN,{editor:n,char:"@",pluginKey:"resourcesDropdownMenu",queryKey:u,queryFn:p,onSelect:d}),e[13]=n,e[14]=p,e[15]=d,e[16]=u,e[17]=h):h=e[17],h};function l4(){}function u4(t){return{name:t.name??t.uri,title:t.name,description:t.description,uri:t.uri}}const c4=[q_.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),DP.configure({placeholder:"Ask anything, use / for prompts, @ for resources, or drop files here...",showOnlyWhenEditable:!1}),m_,b_];function d4(t){const e=ae.c(22),{tiptapDoc:n,setTiptapDoc:r,selectedModel:i,isStreaming:a,onSubmit:s,children:o}=t,l=a||!i,u=U.useRef(s),c=U.useRef(r),d=n||"",f=!l;let p,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(_,D)=>D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),u.current?.(),!0):!1},h=_=>{const{editor:D}=_;c.current(D?.getJSON())},e[0]=p,e[1]=h):(p=e[0],h=e[1]);let g;e[2]!==d||e[3]!==f?(g={extensions:c4,content:d,editable:f,editorProps:p,onUpdate:h},e[2]=d,e[3]=f,e[4]=g):g=e[4];let b;e[5]!==l?(b=[l],e[5]=l,e[6]=b):b=e[6];const E=s_(g,b);let y,S;e[7]!==s?(y=()=>{u.current=s},S=[s],e[7]=s,e[8]=y,e[9]=S):(y=e[8],S=e[9]),U.useEffect(y,S);let k,x;e[10]!==r?(x=()=>{c.current=r},k=[r],e[10]=r,e[11]=k,e[12]=x):(k=e[11],x=e[12]),U.useEffect(x,k);let A,v;e[13]!==E||e[14]!==n?(A=()=>{if(E?.isDestroyed)return;const _=JSON.stringify(E?.getJSON()),D=JSON.stringify(n||{type:"doc",content:[]});_!==D&&E.commands.setContent(n||{type:"doc",content:[]})},v=[E,n],e[13]=E,e[14]=n,e[15]=A,e[16]=v):(A=e[15],v=e[16]),U.useEffect(A,v);let w;e[17]!==E?(w={editor:E},e[17]=E,e[18]=w):w=e[18];let N;return e[19]!==o||e[20]!==w?(N=T.jsx(Fo.Provider,{value:w,children:o}),e[19]=o,e[20]=w,e[21]=N):N=e[21],N}function p4(t){const e=ae.c(24),{selectedModel:n,isStreaming:r,selectedVirtualMcp:i,ref:a}=t,{editor:s}=o_(),o=i?.id??null,l=r||!n;let u;e[0]!==s?.commands?(u=()=>({focus:()=>{s?.commands.focus()},clear:()=>{s?.commands.clearContent(!0)}}),e[0]=s?.commands,e[1]=u):u=e[1];let c;if(e[2]!==s?(c=[s],e[2]=s,e[3]=c):c=e[3],U.useImperativeHandle(a??null,u,c),!s)return null;const d=l&&"cursor-not-allowed opacity-70",f=l&&"[&_.ProseMirror]:cursor-not-allowed";let p;e[4]!==d||e[5]!==f?(p=pe("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col","[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",d,f),e[4]=d,e[5]=f,e[6]=p):p=e[6];let h;e[7]!==s||e[8]!==p?(h=T.jsx(Ag,{editor:s,className:p}),e[7]=s,e[8]=p,e[9]=h):h=e[9];let g;e[10]!==s||e[11]!==o?(g=T.jsx(U.Suspense,{fallback:null,children:T.jsx(i4,{editor:s,virtualMcpId:o})}),e[10]=s,e[11]=o,e[12]=g):g=e[12];let b;e[13]!==s||e[14]!==o?(b=T.jsx(U.Suspense,{fallback:null,children:T.jsx(o4,{editor:s,virtualMcpId:o})}),e[13]=s,e[14]=o,e[15]=b):b=e[15];let E;e[16]!==s||e[17]!==n?(E=T.jsx(oP,{editor:s,selectedModel:n}),e[16]=s,e[17]=n,e[18]=E):E=e[18];let y;return e[19]!==h||e[20]!==g||e[21]!==b||e[22]!==E?(y=T.jsxs(T.Fragment,{children:[h,g,b,E]}),e[19]=h,e[20]=g,e[21]=b,e[22]=E,e[23]=y):y=e[23],y}function iN(t){const e=ae.c(38),{messages:n}=t;let r,i,a,s,o,l,u,c,d,f,p,h;if(e[0]!==n){h=Symbol.for("react.early_return_sentinel");e:{const k=gR(n);if(!k){h=null;break e}const{totalTokens:x,inputTokens:A,outputTokens:v,cost:w}=k;if(a=w,!x&&!A&&!v){h=null;break e}i=wn;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=T.jsx(Gx,{size:12}),e[13]=N):N=e[13];const _=T.jsxs(et,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap shrink-0",children:[N,T.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:x.toLocaleString()})]});e[14]!==_?(p=T.jsx(Rn,{asChild:!0,children:_}),e[14]=_,e[15]=p):p=e[15],r=On,d="top",f="font-mono text-[11px]",o="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx("span",{className:"text-muted",children:"in"}),e[16]=l):l=e[16],u=T.jsx("span",{children:A.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("span",{className:"text-muted",children:"out"}),e[17]=c):c=e[17],s=v.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=s,e[5]=o,e[6]=l,e[7]=u,e[8]=c,e[9]=d,e[10]=f,e[11]=p,e[12]=h}else r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;e[18]!==s?(g=T.jsx("span",{children:s}),e[18]=s,e[19]=g):g=e[19];let b;e[20]!==a?(b=a>0&&T.jsxs(T.Fragment,{children:[T.jsx("span",{className:"text-muted",children:"cost"}),T.jsxs("span",{children:["$",a.toFixed(4)]})]}),e[20]=a,e[21]=b):b=e[21];let E;e[22]!==g||e[23]!==b||e[24]!==o||e[25]!==l||e[26]!==u||e[27]!==c?(E=T.jsxs("div",{className:o,children:[l,u,c,g,b]}),e[22]=g,e[23]=b,e[24]=o,e[25]=l,e[26]=u,e[27]=c,e[28]=E):E=e[28];let y;e[29]!==r||e[30]!==E||e[31]!==d||e[32]!==f?(y=T.jsx(r,{side:d,className:f,children:E}),e[29]=r,e[30]=E,e[31]=d,e[32]=f,e[33]=y):y=e[33];let S;return e[34]!==i||e[35]!==y||e[36]!==p?(S=T.jsxs(i,{children:[p,y]}),e[34]=i,e[35]=y,e[36]=p,e[37]=S):S=e[37],S}function f4(t){const e=ae.c(25),{onVirtualMcpChange:n,virtualMcps:r,disabled:i}=t,a=i===void 0?!1:i,[s,o]=U.useState(!1),l=U.useRef(null),{org:u}=ci();let c;e[0]!==u.id?(c=Px(u.id),e[0]=u.id,e[1]=c):c=e[1];const d=c;let f;e[2]!==r?(f=r.filter(h4),e[2]=r,e[3]=f):f=e[3];const p=f;let h,g;e[4]!==s?(h=()=>{s&&setTimeout(()=>{l.current?.focus()},0)},g=[s],e[4]=s,e[5]=h,e[6]=g):(h=e[5],g=e[6]),U.useEffect(h,g);let b;e[7]!==n?(b=w=>{n(w),o(!1)},e[7]=n,e[8]=b):b=e[8];const E=b;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=T.jsx(ia,{size:16}),e[9]=y):y=e[9];let S;e[10]!==a?(S=T.jsx(Rn,{asChild:!0,children:T.jsx(pi,{asChild:!0,children:T.jsx(et,{type:"button",variant:"ghost",size:"icon",className:"size-8 rounded-full",disabled:a,children:y})})}),e[10]=a,e[11]=S):S=e[11];let k;e[12]!==s?(k=!s&&T.jsx(On,{side:"top",children:"Decopilot"}),e[12]=s,e[13]=k):k=e[13];let x;e[14]!==S||e[15]!==k?(x=T.jsxs(wn,{children:[S,k]}),e[14]=S,e[15]=k,e[16]=x):x=e[16];let A;e[17]!==d.id||e[18]!==p||e[19]!==E?(A=T.jsx(fi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(xg,{virtualMcps:p,selectedVirtualMcpId:d.id,onVirtualMcpChange:E,searchInputRef:l})}),e[17]=d.id,e[18]=p,e[19]=E,e[20]=A):A=e[20];let v;return e[21]!==s||e[22]!==x||e[23]!==A?(v=T.jsxs(di,{open:s,onOpenChange:o,children:[x,A]}),e[21]=s,e[22]=x,e[23]=A,e[24]=v):v=e[24],v}function h4(t){return!t.id||!Qr(t.id)}function m4({virtualMcpId:t,virtualMcps:e,onVirtualMcpChange:n,disabled:r=!1}){const[i,a]=U.useState(!1),s=U.useRef(null),o=Lx(),{org:l}=ci(),u=e.find(h=>h.id===t);if(!u||Qr(t))return null;U.useEffect(()=>{i&&setTimeout(()=>{s.current?.focus()},0)},[i]);const c=g_(t),d=h=>{h.stopPropagation(),n(null)},f=h=>{h.stopPropagation(),o({to:"/$org/$project/agents/$agentId",params:{org:l.slug,project:as,agentId:t}})},p=h=>{n(h),a(!1)};return T.jsxs("div",{className:pe("flex items-center justify-between px-3 py-1.5 rounded-t-xl",c?.bg),children:[T.jsxs(di,{open:i,onOpenChange:a,children:[T.jsx(pi,{asChild:!0,children:T.jsxs("button",{type:"button",disabled:r,className:pe("flex items-center gap-1.5 hover:opacity-80 transition-opacity",r?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[T.jsx(Gm,{icon:u.icon,name:u.title,size:"2xs",className:"bg-background rounded-sm",fallbackIcon:u.fallbackIcon??T.jsx(ia,{size:10})}),T.jsx("span",{className:"text-xs text-white font-normal",children:u.title}),T.jsx(Hh,{size:14,className:"text-white/50"})]})}),T.jsx(fi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(xg,{virtualMcps:e,selectedVirtualMcpId:t,onVirtualMcpChange:p,searchInputRef:s})})]}),T.jsxs("div",{className:"flex items-center gap-1",children:[T.jsx("button",{type:"button",onClick:f,disabled:r,className:pe("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Edit agent",children:T.jsx(mR,{size:14,className:"text-white"})}),T.jsx("button",{type:"button",onClick:d,disabled:r,className:pe("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Reset to default",children:T.jsx(Kx,{size:14,className:"text-white"})})]})]})}function g4(){const t=ae.c(111),{activeThreadId:e,tiptapDoc:n,setTiptapDoc:r,virtualMcps:i,selectedVirtualMcp:a,setVirtualMcpId:s,modelsConnections:o,selectedModel:l,setSelectedModel:u,selectedMode:c,setSelectedMode:d,messages:f,isStreaming:p,sendMessage:h,stopStreaming:g,chatError:b,clearChatError:E,finishReason:y,clearFinishReason:S}=ka(),k=U.useRef(null);let x;t[0]!==p||t[1]!==l||t[2]!==n?(x=!p&&!!l&&!z3(n),t[0]=p,t[1]=l,t[2]=n,t[3]=x):x=t[3];const A=x;let v;t[4]!==A||t[5]!==p||t[6]!==h||t[7]!==g||t[8]!==n?(v=Nt=>{Nt?.preventDefault(),p?g():A&&n&&h(n)},t[4]=A,t[5]=p,t[6]=h,t[7]=g,t[8]=n,t[9]=v):v=t[9];const w=v;let N;t[10]!==b||t[11]!==h?(N=()=>{if(b){const Jt={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${b.message}. Can you help me fix it?`}]}]};h(Jt)}},t[10]=b,t[11]=h,t[12]=N):N=t[12];const _=N;let D;t[13]!==h?(D=()=>{h({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[13]=h,t[14]=D):D=t[14];const M=D;let q,P,F,$;if(t[15]!==b||t[16]!==E||t[17]!==S||t[18]!==y||t[19]!==M||t[20]!==_||t[21]!==a){const Nt=a?g_(a.id):null;P="flex flex-col gap-2 w-full min-h-42 justify-end",t[26]!==b||t[27]!==E||t[28]!==_?(F=b&&T.jsxs(_x,{variant:"danger",title:"Error occurred",description:b.message,icon:T.jsx(Ux,{size:16}),onDismiss:E,children:[T.jsx(et,{size:"sm",variant:"outline",onClick:_,className:"h-7 text-xs",children:"Fix in chat"}),T.jsx(et,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}),t[26]=b,t[27]=E,t[28]=_,t[29]=F):F=t[29],t[30]!==S||t[31]!==y||t[32]!==M?($=y&&y!=="stop"&&T.jsx(_x,{variant:"warning",title:"Response incomplete",description:y==="length"?"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.":y==="content-filter"?"Response was filtered due to content policy.":y==="tool-calls"?"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working.":`Response stopped unexpectedly: ${y}`,icon:T.jsx(nR,{size:16}),onDismiss:S,children:T.jsx(et,{size:"sm",variant:"outline",onClick:M,className:"h-7 text-xs",children:"Continue"})}),t[30]=S,t[31]=y,t[32]=M,t[33]=$):$=t[33],q=pe("relative rounded-xl w-full flex flex-col",a&&"shadow-sm",Nt?.bg),t[15]=b,t[16]=E,t[17]=S,t[18]=y,t[19]=M,t[20]=_,t[21]=a,t[22]=q,t[23]=P,t[24]=F,t[25]=$}else q=t[22],P=t[23],F=t[24],$=t[25];let G;t[34]!==p||t[35]!==a||t[36]!==s||t[37]!==i?(G=a?.id&&!Qr(a.id)&&T.jsx(m4,{onVirtualMcpChange:s,virtualMcpId:a.id,virtualMcps:i,disabled:p}),t[34]=p,t[35]=a,t[36]=s,t[37]=i,t[38]=G):G=t[38];const H=!a&&"shadow-sm";let J;t[39]!==H?(J=pe("w-full relative rounded-xl min-h-[130px] flex flex-col border border-border bg-background",H),t[39]=H,t[40]=J):J=t[40];let I;t[41]!==p||t[42]!==l||t[43]!==a?(I=T.jsx("div",{className:"relative flex flex-col gap-2 flex-1",children:T.jsx(p4,{ref:k,selectedModel:l,isStreaming:p,selectedVirtualMcp:a})}),t[41]=p,t[42]=l,t[43]=a,t[44]=I):I=t[44];let X;t[45]!==p||t[46]!==a||t[47]!==s||t[48]!==i?(X=a&&Qr(a.id)?T.jsx(f4,{onVirtualMcpChange:s,virtualMcps:i,disabled:p}):T.jsx(nP,{selectedVirtualMcpId:a?.id??null,onVirtualMcpChange:s,virtualMcps:i,placeholder:"Agent",disabled:p}),t[45]=p,t[46]=a,t[47]=s,t[48]=i,t[49]=X):X=t[49];let re;t[50]!==f?(re=T.jsx(iN,{messages:f}),t[50]=f,t[51]=re):re=t[51];let R;t[52]!==X||t[53]!==re?(R=T.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[X,re]}),t[52]=X,t[53]=re,t[54]=R):R=t[54];const ie=l??void 0;let te;t[55]!==o||t[56]!==u||t[57]!==ie?(te=T.jsx(Vw,{selectedModel:ie,onModelChange:u,modelsConnections:o,placeholder:"Model",variant:"borderless"}),t[55]=o,t[56]=u,t[57]=ie,t[58]=te):te=t[58];let se;t[59]!==p||t[60]!==c||t[61]!==d?(se=T.jsx(J3,{selectedMode:c,onModeChange:d,placeholder:"Mode",variant:"borderless",disabled:p}),t[59]=p,t[60]=c,t[61]=d,t[62]=se):se=t[62];let he;t[63]!==p||t[64]!==l?(he=T.jsx(uP,{selectedModel:l,isStreaming:p}),t[63]=p,t[64]=l,t[65]=he):he=t[65];const Ae=p?"button":"submit";let ve;t[66]!==p||t[67]!==g?(ve=Nt=>{p&&(Nt.preventDefault(),Nt.stopPropagation(),g())},t[66]=p,t[67]=g,t[68]=ve):ve=t[68];const Ce=A||p?"default":"ghost",De=!A&&!p,Ke=!A&&!p&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let we;t[69]!==Ke?(we=pe("size-8 rounded-full transition-all",Ke),t[69]=Ke,t[70]=we):we=t[70];const lt=p?"Stop generating":"Send message (Enter)";let qe;t[71]!==p?(qe=p?T.jsx(Wx,{size:20}):T.jsx(hR,{size:20}),t[71]=p,t[72]=qe):qe=t[72];let Re;t[73]!==Ae||t[74]!==ve||t[75]!==Ce||t[76]!==De||t[77]!==we||t[78]!==lt||t[79]!==qe?(Re=T.jsx(et,{type:Ae,onClick:ve,variant:Ce,size:"icon",disabled:De,className:we,title:lt,children:qe}),t[73]=Ae,t[74]=ve,t[75]=Ce,t[76]=De,t[77]=we,t[78]=lt,t[79]=qe,t[80]=Re):Re=t[80];let Ye;t[81]!==te||t[82]!==se||t[83]!==he||t[84]!==Re?(Ye=T.jsxs("div",{className:"flex items-center gap-1",children:[te,se,he,Re]}),t[81]=te,t[82]=se,t[83]=he,t[84]=Re,t[85]=Ye):Ye=t[85];let He;t[86]!==R||t[87]!==Ye?(He=T.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[R,Ye]}),t[86]=R,t[87]=Ye,t[88]=He):He=t[88];let zt;t[89]!==w||t[90]!==J||t[91]!==I||t[92]!==He?(zt=T.jsxs("form",{onSubmit:w,className:J,children:[I,He]}),t[89]=w,t[90]=J,t[91]=I,t[92]=He,t[93]=zt):zt=t[93];let rt;t[94]!==e||t[95]!==w||t[96]!==p||t[97]!==l||t[98]!==r||t[99]!==zt||t[100]!==n?(rt=T.jsx("div",{className:"p-0.5",children:T.jsx(d4,{tiptapDoc:n,setTiptapDoc:r,selectedModel:l,isStreaming:p,onSubmit:w,children:zt},e)}),t[94]=e,t[95]=w,t[96]=p,t[97]=l,t[98]=r,t[99]=zt,t[100]=n,t[101]=rt):rt=t[101];let qt;t[102]!==rt||t[103]!==q||t[104]!==G?(qt=T.jsxs("div",{className:q,children:[G,rt]}),t[102]=rt,t[103]=q,t[104]=G,t[105]=qt):qt=t[105];let Pt;return t[106]!==qt||t[107]!==P||t[108]!==F||t[109]!==$?(Pt=T.jsxs("div",{className:P,children:[F,$,qt]}),t[106]=qt,t[107]=P,t[108]=F,t[109]=$,t[110]=Pt):Pt=t[110],Pt}function Bg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Lr=Bg();function aN(t){Lr=t}var Ki={exec:()=>null};function Se(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(xt.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var xt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},b4=/^(?:[ \t]*(?:\n|$))+/,E4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,y4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ia=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,T4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ug=/(?:[*+-]|\d{1,9}[.)])/,sN=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oN=Se(sN).replace(/bull/g,Ug).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),S4=Se(sN).replace(/bull/g,Ug).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Hg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,A4=/^[^\n]+/,$g=/(?!\s*\])(?:\\.|[^\[\]\\])+/,k4=Se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$g).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),x4=Se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ug).getRegex(),Uo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",zg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,v4=Se("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",zg).replace("tag",Uo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),lN=Se(Hg).replace("hr",Ia).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uo).getRegex(),C4=Se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",lN).getRegex(),qg={blockquote:C4,code:E4,def:k4,fences:y4,heading:T4,hr:Ia,html:v4,lheading:oN,list:x4,newline:b4,paragraph:lN,table:Ki,text:A4},x0=Se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ia).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uo).getRegex(),_4={...qg,lheading:S4,table:x0,paragraph:Se(Hg).replace("hr",Ia).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",x0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uo).getRegex()},N4={...qg,html:Se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",zg).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ki,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Se(Hg).replace("hr",Ia).replace("heading",` *#{1,6} *[^
140
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const s=om(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:r},n);return s?[{type:"taskList",raw:s.raw,items:s.items}]:n.blockTokens(a)},i=om(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,s)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:s}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ze.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(L_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(D_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(H_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(z_.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(BF.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(UF.configure(this.options.taskList)),t}});var d0="&nbsp;",HF=" ",$F=_t.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",We(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===d0||r[0].text===HF)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?d0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),zF=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qF=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,jF=Rr.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",We(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[ai({find:zF,type:this.type})]},addPasteRules(){return[_r({find:qF,type:this.type})]}}),GF=_t.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),VF=Rr.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",We(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),WF=ze.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push($P.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(PP.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(L_.configure(this.options.bulletList)),this.options.code!==!1&&i.push(jP.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(WP.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(YP.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(NP.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(IP.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(KP.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(XP.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(LP.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(ZP.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(nF.configure(this.options.italic)),this.options.listItem!==!1&&i.push(D_.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(H_.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(_F.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(z_.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push($F.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(jF.configure(this.options.strike)),this.options.text!==!1&&i.push(GF.configure(this.options.text)),this.options.underline!==!1&&i.push(VF.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(OP.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),q_=WF;var YF=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],ym=YF.join(","),j_=typeof Element>"u",ga=j_?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,uo=!j_&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t?.ownerDocument},co=function(e,n){var r;n===void 0&&(n=!0);var i=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),a=i===""||i==="true",s=a||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):co(e.parentNode));return s},KF=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},XF=function(e,n,r){if(co(e))return[];var i=Array.prototype.slice.apply(e.querySelectorAll(ym));return n&&ga.call(e,ym)&&i.unshift(e),i=i.filter(r),i},Tm=function(e,n,r){for(var i=[],a=Array.from(e);a.length;){var s=a.shift();if(!co(s,!1))if(s.tagName==="SLOT"){var o=s.assignedElements(),l=o.length?o:s.children,u=Tm(l,!0,r);r.flatten?i.push.apply(i,u):i.push({scopeParent:s,candidates:u})}else{var c=ga.call(s,ym);c&&r.filter(s)&&(n||!e.includes(s))&&i.push(s);var d=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),f=!co(d,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(d&&f){var p=Tm(d===!0?s.children:d.children,!0,r);r.flatten?i.push.apply(i,p):i.push({scopeParent:s,candidates:p})}else a.unshift.apply(a,s.children)}}return i},G_=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},V_=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||KF(e))&&!G_(e)?0:e.tabIndex},ZF=function(e,n){var r=V_(e);return r<0&&n&&!G_(e)?0:r},QF=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},W_=function(e){return e.tagName==="INPUT"},JF=function(e){return W_(e)&&e.type==="hidden"},eB=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},tB=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},nB=function(e){if(!e.name)return!0;var n=e.form||uo(e),r=function(o){return n.querySelectorAll('input[type="radio"][name="'+o+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=r(window.CSS.escape(e.name));else try{i=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var a=tB(i,e.form);return!a||a===e},rB=function(e){return W_(e)&&e.type==="radio"},iB=function(e){return rB(e)&&!nB(e)},aB=function(e){var n,r=e&&uo(e),i=(n=r)===null||n===void 0?void 0:n.host,a=!1;if(r&&r!==e){var s,o,l;for(a=!!((s=i)!==null&&s!==void 0&&(o=s.ownerDocument)!==null&&o!==void 0&&o.contains(i)||e!=null&&(l=e.ownerDocument)!==null&&l!==void 0&&l.contains(e));!a&&i;){var u,c,d;r=uo(i),i=(u=r)===null||u===void 0?void 0:u.host,a=!!((c=i)!==null&&c!==void 0&&(d=c.ownerDocument)!==null&&d!==void 0&&d.contains(i))}}return a},p0=function(e){var n=e.getBoundingClientRect(),r=n.width,i=n.height;return r===0&&i===0},sB=function(e,n){var r=n.displayCheck,i=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var a=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!a}if(getComputedStyle(e).visibility==="hidden")return!0;var s=ga.call(e,"details>summary:first-of-type"),o=s?e.parentElement:e;if(ga.call(o,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof i=="function"){for(var l=e;e;){var u=e.parentElement,c=uo(e);if(u&&!u.shadowRoot&&i(u)===!0)return p0(e);e.assignedSlot?e=e.assignedSlot:!u&&c!==e.ownerDocument?e=c.host:e=u}e=l}if(aB(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return p0(e);return!1},oB=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var i=n.children.item(r);if(i.tagName==="LEGEND")return ga.call(n,"fieldset[disabled] *")?!0:!i.contains(e)}return!0}n=n.parentElement}return!1},lB=function(e,n){return!(n.disabled||JF(n)||sB(n,e)||eB(n)||oB(n))},f0=function(e,n){return!(iB(n)||V_(n)<0||!lB(e,n))},uB=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},Y_=function(e){var n=[],r=[];return e.forEach(function(i,a){var s=!!i.scopeParent,o=s?i.scopeParent:i,l=ZF(o,s),u=s?Y_(i.candidates):o;l===0?s?n.push.apply(n,u):n.push(o):r.push({documentOrder:a,tabIndex:l,item:i,isScope:s,content:u})}),r.sort(QF).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(n)},K_=function(e,n){n=n||{};var r;return n.getShadowRoot?r=Tm([e],n.includeContainer,{filter:f0.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:uB}):r=XF(e,n.includeContainer,f0.bind(null,n)),Y_(r)};function cB(){return/apple/i.test(navigator.vendor)}const h0="data-floating-ui-focusable";function dB(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function Sm(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&ww(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function xi(t){return"composedPath"in t?t.composedPath()[0]:t.target}function Ll(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function pB(t){return t.matches("html,body")}function ba(t){return t?.ownerDocument||document}function fB(t){return t?t.hasAttribute(h0)?t:t.querySelector("["+h0+"]")||t:null}function ps(t,e,n){return n===void 0&&(n=!0),t.filter(i=>{var a;return i.parentId===e&&(!n||((a=i.context)==null?void 0:a.open))}).flatMap(i=>[i,...ps(t,i.id,n)])}function hB(t){return"nativeEvent"in t}var mB=typeof document<"u",gB=function(){},Sr=mB?U.useLayoutEffect:gB;const bB={...Rx},EB=bB.useInsertionEffect,yB=EB||(t=>t());function jr(t){const e=U.useRef(()=>{});return yB(()=>{e.current=t}),U.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}const X_=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function Z_(t,e){const n=K_(t,X_()),r=n.length;if(r===0)return;const i=dB(ba(t)),a=n.indexOf(i),s=a===-1?e===1?0:r-1:a+e;return n[s]}function TB(t){return Z_(ba(t).body,1)||t}function SB(t){return Z_(ba(t).body,-1)||t}function Dl(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!Sm(n,r)}function AB(t){K_(t,X_()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function m0(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}const kB="data-floating-ui-focusable",g0="active",b0="selected",xB={...Rx};let E0=!1,vB=0;const y0=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+vB++;function CB(){const[t,e]=U.useState(()=>E0?y0():void 0);return Sr(()=>{t==null&&e(y0())},[]),U.useEffect(()=>{E0=!0},[]),t}const _B=xB.useId,Pg=_B||CB;function NB(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(i=>i(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const IB=U.createContext(null),wB=U.createContext(null),Q_=()=>{var t;return((t=U.useContext(IB))==null?void 0:t.id)||null},J_=()=>U.useContext(wB);function Fg(t){return"data-floating-ui-"+t}const RB={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},T0=U.forwardRef(function(e,n){const[r,i]=U.useState();Sr(()=>{cB()&&i("button")},[]);const a={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Fg("focus-guard")]:"",style:RB};return T.jsx("span",{...e,...a})}),OB={clipPath:"inset(50%)",position:"fixed",top:0,left:0},eN=U.createContext(null),S0=Fg("portal");function LB(t){t===void 0&&(t={});const{id:e,root:n}=t,r=Pg(),i=MB(),[a,s]=U.useState(null),o=U.useRef(null);return Sr(()=>()=>{a?.remove(),queueMicrotask(()=>{o.current=null})},[a]),Sr(()=>{if(!r||o.current)return;const l=e?document.getElementById(e):null;if(!l)return;const u=document.createElement("div");u.id=r,u.setAttribute(S0,""),l.appendChild(u),o.current=u,s(u)},[e,r]),Sr(()=>{if(n===null||!r||o.current)return;let l=n||i?.portalNode;l&&!Pw(l)&&(l=l.current),l=l||document.body;let u=null;e&&(u=document.createElement("div"),u.id=e,l.appendChild(u));const c=document.createElement("div");c.id=r,c.setAttribute(S0,""),l=u||l,l.appendChild(c),o.current=c,s(c)},[e,n,r,i]),a}function DB(t){const{children:e,id:n,root:r,preserveTabOrder:i=!0}=t,a=LB({id:n,root:r}),[s,o]=U.useState(null),l=U.useRef(null),u=U.useRef(null),c=U.useRef(null),d=U.useRef(null),f=s?.modal,p=s?.open,h=!!s&&!s.modal&&s.open&&i&&!!(r||a);return U.useEffect(()=>{if(!a||!i||f)return;function g(b){a&&Dl(b)&&(b.type==="focusin"?m0:AB)(a)}return a.addEventListener("focusin",g,!0),a.addEventListener("focusout",g,!0),()=>{a.removeEventListener("focusin",g,!0),a.removeEventListener("focusout",g,!0)}},[a,i,f]),U.useEffect(()=>{a&&(p||m0(a))},[p,a]),T.jsxs(eN.Provider,{value:U.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:l,afterOutsideRef:u,beforeInsideRef:c,afterInsideRef:d,portalNode:a,setFocusManagerState:o}),[i,a]),children:[h&&a&&T.jsx(T0,{"data-type":"outside",ref:l,onFocus:g=>{if(Dl(g,a)){var b;(b=c.current)==null||b.focus()}else{const E=s?s.domReference:null,y=SB(E);y?.focus()}}}),h&&a&&T.jsx("span",{"aria-owns":a.id,style:OB}),a&&Ix.createPortal(e,a),h&&a&&T.jsx(T0,{"data-type":"outside",ref:u,onFocus:g=>{if(Dl(g,a)){var b;(b=d.current)==null||b.focus()}else{const E=s?s.domReference:null,y=TB(E);y?.focus(),s?.closeOnFocusOut&&s?.onOpenChange(!1,g.nativeEvent,"focus-out")}}})]})}const MB=()=>U.useContext(eN),PB={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},FB={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},A0=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t?.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t?.outsidePress)!=null?n:!0}};function BB(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:i,dataRef:a}=t,{enabled:s=!0,escapeKey:o=!0,outsidePress:l=!0,outsidePressEvent:u="pointerdown",referencePress:c=!1,referencePressEvent:d="pointerdown",ancestorScroll:f=!1,bubbles:p,capture:h}=e,g=J_(),b=jr(typeof l=="function"?l:()=>!1),E=typeof l=="function"?b:l,y=U.useRef(!1),{escapeKey:S,outsidePress:k}=A0(p),{escapeKey:x,outsidePress:A}=A0(h),v=U.useRef(!1),w=jr(P=>{var F;if(!n||!s||!o||P.key!=="Escape"||v.current)return;const $=(F=a.current.floatingContext)==null?void 0:F.nodeId,G=g?ps(g.nodesRef.current,$):[];if(!S&&(P.stopPropagation(),G.length>0)){let H=!0;if(G.forEach(J=>{var I;if((I=J.context)!=null&&I.open&&!J.context.dataRef.current.__escapeKeyBubbles){H=!1;return}}),!H)return}r(!1,hB(P)?P.nativeEvent:P,"escape-key")}),N=jr(P=>{var F;const $=()=>{var G;w(P),(G=xi(P))==null||G.removeEventListener("keydown",$)};(F=xi(P))==null||F.addEventListener("keydown",$)}),_=jr(P=>{var F;const $=a.current.insideReactTree;a.current.insideReactTree=!1;const G=y.current;if(y.current=!1,u==="click"&&G||$||typeof E=="function"&&!E(P))return;const H=xi(P),J="["+Fg("inert")+"]",I=ba(i.floating).querySelectorAll(J);let X=dn(H)?H:null;for(;X&&!al(X);){const te=Lw(X);if(al(te)||!dn(te))break;X=te}if(I.length&&dn(H)&&!pB(H)&&!Sm(H,i.floating)&&Array.from(I).every(te=>!Sm(X,te)))return;if(Dw(H)&&q){const te=al(H),se=Mw(H),he=/auto|scroll/,Ae=te||he.test(se.overflowX),ve=te||he.test(se.overflowY),Ce=Ae&&H.clientWidth>0&&H.scrollWidth>H.clientWidth,De=ve&&H.clientHeight>0&&H.scrollHeight>H.clientHeight,Ke=se.direction==="rtl",we=De&&(Ke?P.offsetX<=H.offsetWidth-H.clientWidth:P.offsetX>H.clientWidth),lt=Ce&&P.offsetY>H.clientHeight;if(we||lt)return}const re=(F=a.current.floatingContext)==null?void 0:F.nodeId,R=g&&ps(g.nodesRef.current,re).some(te=>{var se;return Ll(P,(se=te.context)==null?void 0:se.elements.floating)});if(Ll(P,i.floating)||Ll(P,i.domReference)||R)return;const ie=g?ps(g.nodesRef.current,re):[];if(ie.length>0){let te=!0;if(ie.forEach(se=>{var he;if((he=se.context)!=null&&he.open&&!se.context.dataRef.current.__outsidePressBubbles){te=!1;return}}),!te)return}r(!1,P,"outside-press")}),D=jr(P=>{var F;const $=()=>{var G;_(P),(G=xi(P))==null||G.removeEventListener(u,$)};(F=xi(P))==null||F.addEventListener(u,$)});U.useEffect(()=>{if(!n||!s)return;a.current.__escapeKeyBubbles=S,a.current.__outsidePressBubbles=k;let P=-1;function F(I){r(!1,I,"ancestor-scroll")}function $(){window.clearTimeout(P),v.current=!0}function G(){P=window.setTimeout(()=>{v.current=!1},Ow()?5:0)}const H=ba(i.floating);o&&(H.addEventListener("keydown",x?N:w,x),H.addEventListener("compositionstart",$),H.addEventListener("compositionend",G)),E&&H.addEventListener(u,A?D:_,A);let J=[];return f&&(dn(i.domReference)&&(J=il(i.domReference)),dn(i.floating)&&(J=J.concat(il(i.floating))),!dn(i.reference)&&i.reference&&i.reference.contextElement&&(J=J.concat(il(i.reference.contextElement)))),J=J.filter(I=>{var X;return I!==((X=H.defaultView)==null?void 0:X.visualViewport)}),J.forEach(I=>{I.addEventListener("scroll",F,{passive:!0})}),()=>{o&&(H.removeEventListener("keydown",x?N:w,x),H.removeEventListener("compositionstart",$),H.removeEventListener("compositionend",G)),E&&H.removeEventListener(u,A?D:_,A),J.forEach(I=>{I.removeEventListener("scroll",F)}),window.clearTimeout(P)}},[a,i,o,E,u,n,r,f,s,S,k,w,x,N,_,A,D]),U.useEffect(()=>{a.current.insideReactTree=!1},[a,E,u]);const M=U.useMemo(()=>({onKeyDown:w,...c&&{[PB[d]]:P=>{r(!1,P.nativeEvent,"reference-press")},...d!=="click"&&{onClick(P){r(!1,P.nativeEvent,"reference-press")}}}}),[w,r,c,d]),q=U.useMemo(()=>({onKeyDown:w,onMouseDown(){y.current=!0},onMouseUp(){y.current=!0},[FB[u]]:()=>{a.current.insideReactTree=!0}}),[w,u,a]);return U.useMemo(()=>s?{reference:M,floating:q}:{},[s,M,q])}function UB(t){const{open:e=!1,onOpenChange:n,elements:r}=t,i=Pg(),a=U.useRef({}),[s]=U.useState(()=>NB()),o=Q_()!=null,[l,u]=U.useState(r.reference),c=jr((p,h,g)=>{a.current.openEvent=p?h:void 0,s.emit("openchange",{open:p,event:h,reason:g,nested:o}),n?.(p,h,g)}),d=U.useMemo(()=>({setPositionReference:u}),[]),f=U.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return U.useMemo(()=>({dataRef:a,open:e,onOpenChange:c,elements:f,events:s,floatingId:i,refs:d}),[e,c,f,s,i,d])}function HB(t){t===void 0&&(t={});const{nodeId:e}=t,n=UB({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,i=r.elements,[a,s]=U.useState(null),[o,l]=U.useState(null),c=i?.domReference||a,d=U.useRef(null),f=J_();Sr(()=>{c&&(d.current=c)},[c]);const p=Rw({...t,elements:{...i,...o&&{reference:o}}}),h=U.useCallback(S=>{const k=dn(S)?{getBoundingClientRect:()=>S.getBoundingClientRect(),getClientRects:()=>S.getClientRects(),contextElement:S}:S;l(k),p.refs.setReference(k)},[p.refs]),g=U.useCallback(S=>{(dn(S)||S===null)&&(d.current=S,s(S)),(dn(p.refs.reference.current)||p.refs.reference.current===null||S!==null&&!dn(S))&&p.refs.setReference(S)},[p.refs]),b=U.useMemo(()=>({...p.refs,setReference:g,setPositionReference:h,domReference:d}),[p.refs,g,h]),E=U.useMemo(()=>({...p.elements,domReference:c}),[p.elements,c]),y=U.useMemo(()=>({...p,...r,refs:b,elements:E,nodeId:e}),[p,b,E,e,r]);return Sr(()=>{r.dataRef.current.floatingContext=y;const S=f?.nodesRef.current.find(k=>k.id===e);S&&(S.context=y)}),U.useMemo(()=>({...p,context:y,refs:b,elements:E}),[p,b,E,y])}function Ml(t,e,n){const r=new Map,i=n==="item";let a=t;if(i&&t){const{[g0]:s,[b0]:o,...l}=t;a=l}return{...n==="floating"&&{tabIndex:-1,[kB]:""},...a,...e.map(s=>{const o=s?s[n]:null;return typeof o=="function"?t?o(t):null:o}).concat(t).reduce((s,o)=>(o&&Object.entries(o).forEach(l=>{let[u,c]=l;if(!(i&&[g0,b0].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof c=="function"){var d;(d=r.get(u))==null||d.push(c),s[u]=function(){for(var f,p=arguments.length,h=new Array(p),g=0;g<p;g++)h[g]=arguments[g];return(f=r.get(u))==null?void 0:f.map(b=>b(...h)).find(b=>b!==void 0)}}}else s[u]=c}),s),{})}}function $B(t){t===void 0&&(t=[]);const e=t.map(o=>o?.reference),n=t.map(o=>o?.floating),r=t.map(o=>o?.item),i=U.useCallback(o=>Ml(o,t,"reference"),e),a=U.useCallback(o=>Ml(o,t,"floating"),n),s=U.useCallback(o=>Ml(o,t,"item"),r);return U.useMemo(()=>({getReferenceProps:i,getFloatingProps:a,getItemProps:s}),[i,a,s])}const zB=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function qB(t,e){var n,r;e===void 0&&(e={});const{open:i,elements:a,floatingId:s}=t,{enabled:o=!0,role:l="dialog"}=e,u=Pg(),c=((n=a.domReference)==null?void 0:n.id)||u,d=U.useMemo(()=>{var y;return((y=fB(a.floating))==null?void 0:y.id)||s},[a.floating,s]),f=(r=zB.get(l))!=null?r:l,h=Q_()!=null,g=U.useMemo(()=>f==="tooltip"||l==="label"?{["aria-"+(l==="label"?"labelledby":"describedby")]:i?d:void 0}:{"aria-expanded":i?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":i?d:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:c},...f==="menu"&&h&&{role:"menuitem"},...l==="select"&&{"aria-autocomplete":"none"},...l==="combobox"&&{"aria-autocomplete":"list"}},[f,d,h,i,c,l]),b=U.useMemo(()=>{const y={id:d,...f&&{role:f}};return f==="tooltip"||l==="label"?y:{...y,...f==="menu"&&{"aria-labelledby":c}}},[f,d,c,l]),E=U.useCallback(y=>{let{active:S,selected:k}=y;const x={role:"option",...S&&{id:d+"-fui-option"}};switch(l){case"select":case"combobox":return{...x,"aria-selected":k}}return{}},[d,l]);return U.useMemo(()=>o?{reference:g,floating:b,item:E}:{},[o,g,b,E])}function jB(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:o}=t,l=r&&!i,u=IM(n),c=new RegExp(`\\s${u}$`),d=s?"^":"",f=i?"":u,p=l?new RegExp(`${d}${u}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${u}[^\\s${f}]*`,"gm"),h=((e=o.nodeBefore)==null?void 0:e.isText)&&o.nodeBefore.text;if(!h)return null;const g=o.pos-h.length,b=Array.from(h.matchAll(p)).pop();if(!b||b.input===void 0||b.index===void 0)return null;const E=b.input.slice(Math.max(0,b.index-1),b.index),y=new RegExp(`^[${a?.join("")}\0]?$`).test(E);if(a!==null&&!y)return null;const S=g+b.index;let k=S+b[0].length;return l&&c.test(h.slice(k-1,k+1))&&(b[0]+=" ",k+=1),S<o.pos&&k>=o.pos?{range:{from:S,to:k},query:b[0].slice(n.length),text:b[0]}:null}var GB=new Fe("suggestion");function VB({pluginKey:t=GB,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:c="is-empty",command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:h=()=>!0,findSuggestionMatch:g=jB,shouldShow:b}){let E;const y=p?.(),S=()=>{const v=e.state.selection.$anchor.pos,w=e.view.coordsAtPos(v),{top:N,right:_,bottom:D,left:M}=w;try{return new DOMRect(M,N,_-M,D-N)}catch{return null}},k=(v,w)=>w?()=>{const N=t.getState(e.state),_=N?.decorationId,D=v.dom.querySelector(`[data-decoration-id="${_}"]`);return D?.getBoundingClientRect()||null}:S;function x(v,w){var N;try{const D=t.getState(v.state),M=D?.decorationId?v.dom.querySelector(`[data-decoration-id="${D.decorationId}"]`):null,q={editor:e,range:D?.range||{from:0,to:0},query:D?.query||null,text:D?.text||null,items:[],command:P=>d({editor:e,range:D?.range||{from:0,to:0},props:P}),decorationNode:M,clientRect:k(v,M)};(N=y?.onExit)==null||N.call(y,q)}catch{}const _=v.state.tr.setMeta(w,{exit:!0});v.dispatch(_)}const A=new Le({key:t,view(){return{update:async(v,w)=>{var N,_,D,M,q,P,F;const $=(N=this.key)==null?void 0:N.getState(w),G=(_=this.key)==null?void 0:_.getState(v.state),H=$.active&&G.active&&$.range.from!==G.range.from,J=!$.active&&G.active,I=$.active&&!G.active,X=!J&&!I&&$.query!==G.query,re=J||H&&X,R=X||H,ie=I||H&&X;if(!re&&!R&&!ie)return;const te=ie&&!re?$:G,se=v.dom.querySelector(`[data-decoration-id="${te.decorationId}"]`);E={editor:e,range:te.range,query:te.query,text:te.text,items:[],command:he=>d({editor:e,range:te.range,props:he}),decorationNode:se,clientRect:k(v,se)},re&&((D=y?.onBeforeStart)==null||D.call(y,E)),R&&((M=y?.onBeforeUpdate)==null||M.call(y,E)),(R||re)&&(E.items=await f({editor:e,query:te.query})),ie&&((q=y?.onExit)==null||q.call(y,E)),R&&((P=y?.onUpdate)==null||P.call(y,E)),re&&((F=y?.onStart)==null||F.call(y,E))},destroy:()=>{var v;E&&((v=y?.onExit)==null||v.call(y,E))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,w,N,_){const{isEditable:D}=e,{composing:M}=e.view,{selection:q}=v,{empty:P,from:F}=q,$={...w},G=v.getMeta(t);if(G&&G.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=M,D&&(P||e.view.composing)){(F<w.range.from||F>w.range.to)&&!M&&!w.composing&&($.active=!1);const H=g({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:s,$position:q.$from}),J=`id_${Math.floor(Math.random()*4294967295)}`;H&&h({editor:e,state:_,range:H.range,isActive:w.active})&&(!b||b({editor:e,range:H.range,query:H.query,text:H.text,transaction:v}))?($.active=!0,$.decorationId=w.decorationId?w.decorationId:J,$.range=H.range,$.query=H.query,$.text=H.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(v,w){var N,_,D,M;const{active:q,range:P}=A.getState(v.state);if(!q)return!1;if(w.key==="Escape"||w.key==="Esc"){const $=A.getState(v.state),G=(N=E?.decorationNode)!=null?N:null,H=G??($?.decorationId?v.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((_=y?.onKeyDown)==null?void 0:_.call(y,{view:v,event:w,range:$.range}))||!1)return!0;const I={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:X=>d({editor:e,range:$.range,props:X}),decorationNode:H,clientRect:H?()=>H.getBoundingClientRect()||null:null};return(D=y?.onExit)==null||D.call(y,I),x(v,t),!0}return((M=y?.onKeyDown)==null?void 0:M.call(y,{view:v,event:w,range:P}))||!1},decorations(v){const{active:w,range:N,decorationId:_,query:D}=A.getState(v);if(!w)return null;const M=!D?.length,q=[l];return M&&q.push(c),Pe.create(v.doc,[dt.inline(N.from,N.to,{nodeName:o,class:q.join(" "),"data-decoration-id":_,"data-decoration-content":u})])}}});return A}function WB(t){const e=ae.c(26),{editor:n,query:r,items:i,onSelect:a,onClose:s}=t,[o,l]=U.useState(0),u=U.useRef(i),c=U.useRef(o),d=U.useRef(a),f=U.useRef(s),p=U.useDeferredValue(r);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{l(0)},e[0]=h):h=e[0];let g;e[1]!==p?(g=[p],e[1]=p,e[2]=g):g=e[2],U.useEffect(h,g);let b,E;e[3]!==i.length||e[4]!==o?(b=()=>{o>=i.length&&i.length>0&&l(0)},E=[i.length,o],e[3]=i.length,e[4]=o,e[5]=b,e[6]=E):(b=e[5],E=e[6]),U.useEffect(b,E);let y,S;e[7]!==i?(y=()=>{u.current=i},S=[i],e[7]=i,e[8]=y,e[9]=S):(y=e[8],S=e[9]),U.useEffect(y,S);let k,x;e[10]!==o?(k=()=>{c.current=o},x=[o],e[10]=o,e[11]=k,e[12]=x):(k=e[11],x=e[12]),U.useEffect(k,x);let A,v;e[13]!==a?(v=()=>{d.current=a},A=[a],e[13]=a,e[14]=A,e[15]=v):(A=e[14],v=e[15]),U.useEffect(v,A);let w,N;e[16]!==s?(w=()=>{f.current=s},N=[s],e[16]=s,e[17]=w,e[18]=N):(w=e[17],N=e[18]),U.useEffect(w,N);let _;e[19]!==n.isDestroyed||e[20]!==n.view.dom?(_=()=>{const P=n.view.dom;if(n?.isDestroyed||!P)return;const F=G=>{const H=u.current;if(!H.length)return!1;const J=()=>l(X=>(X+1)%H.length),I=()=>l(X=>(X-1+H.length)%H.length);switch(G.key){case"ArrowUp":return G.preventDefault(),I(),!0;case"ArrowDown":return G.preventDefault(),J(),!0;case"Tab":return G.preventDefault(),G.shiftKey?I():J(),!0;case"Home":return G.preventDefault(),l(0),!0;case"End":return G.preventDefault(),l(H.length-1),!0;case"Enter":{if(G.isComposing)return!1;G.preventDefault();const X=c.current;return X!==-1&&H[X]&&d.current?.(H[X],X),!0}case"Escape":return G.preventDefault(),f.current?.(),!0;default:return!1}},$=G=>{F(G)};return P.addEventListener("keydown",$,!0),()=>{P?.removeEventListener("keydown",$,!0)}},e[19]=n.isDestroyed,e[20]=n.view.dom,e[21]=_):_=e[21];let D;e[22]!==n?(D=[n],e[22]=n,e[23]=D):D=e[23],U.useEffect(_,D);const M=i.length?o:void 0;let q;return e[24]!==M?(q={selectedIndex:M,setSelectedIndex:l},e[24]=M,e[25]=q):q=e[25],q}function YB(t,e){switch(e.type){case"SET_SELECTED_ITEM":return{...t,selectedItem:e.payload};case"ON_START":return{...t,open:!0,selectedItem:null,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_UPDATE":return{...t,element:e.payload.element,query:e.payload.query,range:e.payload.range};case"ON_EXIT":return{open:!1,element:null,query:"",range:null,selectedItem:null};default:return t}}const tN=U.createContext(void 0);function nN(){const t=U.useContext(tN);if(!t)throw new Error("useSuggestionContext must be used within a SuggestionContext.Provider");return t}function KB(t){const e=ae.c(8),{editor:n,char:r,pluginKey:i}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={open:!1,element:null,query:"",range:null,selectedItem:null},e[0]=a):a=e[0];const[s,o]=U.useReducer(YB,a);let l,u;e[1]!==r||e[2]!==n||e[3]!==i?(l=()=>{if(n?.isDestroyed)return;const d=i instanceof Fe?i:new Fe(i);n.state.plugins.find(h=>h.spec.key===d)&&n.unregisterPlugin(d);const p=VB({pluginKey:d,editor:n,char:r,allow(h){const g=n.state.doc.resolve(h.range.from);for(let b=g.depth;b>0;b--)if(g.node(b).type.name==="image")return!1;return!0},command(){},render:()=>({onStart:h=>{o({type:"ON_START",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onUpdate:h=>{o({type:"ON_UPDATE",payload:{element:h.decorationNode??null,query:h.query,range:h.range}})},onKeyDown:h=>h.event.key==="Escape"?(o({type:"ON_EXIT"}),!0):!1,onExit:()=>{o({type:"ON_EXIT"})}}),items:XB});return n.registerPlugin(p),()=>{n?.isDestroyed||n.unregisterPlugin(d)}},u=[n,i,r,o],e[1]=r,e[2]=n,e[3]=i,e[4]=l,e[5]=u):(l=e[4],u=e[5]),U.useEffect(l,u);let c;return e[6]!==s?(c={state:s,dispatch:o},e[6]=s,e[7]=c):c=e[7],c}function XB(){return[]}function ZB({editor:t,queryKey:e,queryFn:n,onSelect:r}){const{state:i,dispatch:a}=nN(),s=U.useDeferredValue(i.query),{data:o}=Fw({queryKey:qm.suggestionItems(e,i.open,s),queryFn:()=>i.open?n({query:s}):[]}),l=()=>{a({type:"ON_EXIT"})},u=async(d,f)=>{if(!(i.selectedItem!==null||!i.range)){a({type:"SET_SELECTED_ITEM",payload:d});try{const{view:p}=t,g=p.state.selection.$to.nodeAfter?.text?.startsWith(" "),b=i.range?{...i.range}:{from:0,to:0};g&&i.range&&(b.to+=1),await r({range:b,item:d})}finally{l()}}},{selectedIndex:c}=WB({editor:t,query:s,items:o,onSelect:u,onClose:l});return{selectedItem:i.selectedItem,items:o,selectedIndex:c,close:l,onSelect:u}}function QB({children:t}){const{state:e,dispatch:n}=nN(),{open:r,element:i}=e,a=()=>{n({type:"ON_EXIT"})},{refs:s,floatingStyles:o,context:l}=HB({placement:"bottom-start",open:r,onOpenChange:f=>{f||a()},elements:{reference:i},middleware:[Bw(10),Uw(),Hw()],whileElementsMounted:$w}),u=BB(l,{outsidePress:f=>!(f.target instanceof Element&&f.target.closest(".ProseMirror"))}),c=qB(l,{role:"listbox"}),{getFloatingProps:d}=$B([u,c]);return r?T.jsx(DB,{children:T.jsx("div",{ref:s.setFloating,style:o,...d(),className:"z-50 w-auto min-w-[280px] max-w-[400px] rounded-lg border bg-popover p-0 text-popover-foreground shadow-md outline-hidden overflow-hidden",children:t})}):null}const JB=t=>{const e=ae.c(23),{item:n,isSelected:r,onSelect:i,isLoading:a,ref:s}=t,o=r&&"bg-accent text-accent-foreground",l=a&&"pointer-events-none opacity-50";let u;e[0]!==o||e[1]!==l?(u=pe("relative flex w-full cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors","hover:bg-accent hover:text-accent-foreground","focus:bg-accent focus:text-accent-foreground",o,l),e[0]=o,e[1]=l,e[2]=u):u=e[2];let c;e[3]!==n.name||e[4]!==n.title?(c=n.title||n.name.replace(/_/g," "),e[3]=n.name,e[4]=n.title,e[5]=c):c=e[5];let d;e[6]!==c?(d=T.jsx("span",{className:"font-medium flex items-center truncate",children:c}),e[6]=c,e[7]=d):d=e[7];let f;e[8]!==a?(f=a&&T.jsx(So,{size:"xs"}),e[8]=a,e[9]=f):f=e[9];let p;e[10]!==d||e[11]!==f?(p=T.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d,f]}),e[10]=d,e[11]=f,e[12]=p):p=e[12];let h;e[13]!==n.description?(h=n.description&&T.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:n.description}),e[13]=n.description,e[14]=h):h=e[14];let g;e[15]!==p||e[16]!==h?(g=T.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[p,h]}),e[15]=p,e[16]=h,e[17]=g):g=e[17];let b;return e[18]!==i||e[19]!==s||e[20]!==u||e[21]!==g?(b=T.jsx("div",{ref:s,onClick:i,className:u,children:g}),e[18]=i,e[19]=s,e[20]=u,e[21]=g,e[22]=b):b=e[22],b},e4=t=>{const e=ae.c(18),{editor:n,queryKey:r,queryFn:i,onSelect:a}=t;let s;e[0]!==n||e[1]!==a||e[2]!==i||e[3]!==r?(s={editor:n,queryKey:r,queryFn:i,onSelect:a},e[0]=n,e[1]=a,e[2]=i,e[3]=r,e[4]=s):s=e[4];const{items:o,selectedIndex:l,onSelect:u,selectedItem:c}=ZB(s);if(!o.length){let h;return e[5]===Symbol.for("react.memo_cache_sentinel")?(h=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md border shadow-md p-3 text-sm",children:"No items found"}),e[5]=h):h=e[5],h}let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={maxHeight:"min(217px, var(--radix-popover-content-available-height, 217px))"},e[6]=d):d=e[6];let f;if(e[7]!==u||e[8]!==o||e[9]!==l||e[10]!==c?.name){let h;e[12]!==u||e[13]!==l||e[14]!==c?.name?(h=(g,b)=>T.jsx(JB,{item:g,isSelected:b===l,ref:b===l?r4:void 0,onSelect:()=>u(g,b),isLoading:c?.name===g.name},g.name),e[12]=u,e[13]=l,e[14]=c?.name,e[15]=h):h=e[15],f=o.map(h),e[7]=u,e[8]=o,e[9]=l,e[10]=c?.name,e[11]=f}else f=e[11];let p;return e[16]!==f?(p=T.jsx("div",{className:"min-w-[280px] max-w-[400px] bg-popover text-popover-foreground rounded-md overflow-y-auto",style:d,children:T.jsx("div",{className:"p-1",children:f})}),e[16]=f,e[17]=p):p=e[17],p};function t4(){const t=ae.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=T.jsx("div",{className:"p-1",children:[...Array(3)].map(n4)}),t[0]=e):e=t[0],e}function n4(t,e){return T.jsxs("div",{className:"px-2 py-1.5 h-[44px] animate-pulse",children:[T.jsx("div",{className:"h-4 w-24 bg-muted rounded mb-1"}),T.jsx("div",{className:"h-3 w-32 bg-muted rounded"})]},e)}function rN(t){const e=ae.c(16),{editor:n,char:r,pluginKey:i,queryKey:a,queryFn:s,onSelect:o}=t;let l;e[0]!==r||e[1]!==n||e[2]!==i?(l={editor:n,char:r,pluginKey:i},e[0]=r,e[1]=n,e[2]=i,e[3]=l):l=e[3];const{state:u,dispatch:c}=KB(l);let d;e[4]!==c||e[5]!==u?(d={state:u,dispatch:c},e[4]=c,e[5]=u,e[6]=d):d=e[6];let f;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=T.jsx(t4,{}),e[7]=f):f=e[7];let p;e[8]!==n||e[9]!==o||e[10]!==s||e[11]!==a?(p=T.jsx(QB,{children:T.jsx(U.Suspense,{fallback:f,children:T.jsx(e4,{editor:n,queryKey:a,queryFn:s,onSelect:o})})}),e[8]=n,e[9]=o,e[10]=s,e[11]=a,e[12]=p):p=e[12];let h;return e[13]!==d||e[14]!==p?(h=T.jsx(tN.Provider,{value:d,children:p}),e[13]=d,e[14]=p,e[15]=h):h=e[15],h}function r4(t){t&&t.scrollIntoView({block:"center",behavior:"smooth"})}async function k0(t,e,n,r,i){try{const a=await Fx(n,r,i);f_(t,e,{id:r,name:r,metadata:a.messages,char:"/"})}catch(a){console.error("[prompt] Failed to fetch prompt:",a),_n.error("Failed to load prompt. Please try again.")}}const i4=t=>{const e=ae.c(29),{editor:n,virtualMcpId:r}=t,i=Ox(),{org:a}=ci();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=Vm(s);let l;e[3]!==a.id||e[4]!==r?(l=qm.virtualMcpPrompts(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l,[c,d]=U.useState(null);let f;e[6]!==o||e[7]!==n?(f=async v=>{const{item:w,range:N}=v;if(w.arguments&&w.arguments.length>0){d({range:N,item:w});return}o&&await k0(n,N,o,w.name)},e[6]=o,e[7]=n,e[8]=f):f=e[8];const p=f;let h;e[9]!==c||e[10]!==o||e[11]!==n?(h=async v=>{if(!c||!o)return;const{range:w,item:N}=c;await k0(n,w,o,N.name,v),d(null)},e[9]=c,e[10]=o,e[11]=n,e[12]=h):h=e[12];const g=h;let b;e[13]!==o||e[14]!==i||e[15]!==u?(b=async v=>{const{query:w}=v;if(!o)return[];let N=i.getQueryData(u);if(N?i.fetchQuery({queryKey:u,queryFn:()=>wb(o),staleTime:6e4}).catch(a4):N=await i.fetchQuery({queryKey:u,queryFn:()=>wb(o),staleTime:6e4}),!N.prompts)return[];let _=N.prompts;if(w.trim()){const D=w.toLowerCase();_=N.prompts.filter(M=>M.name.toLowerCase().includes(D)||M.title?.toLowerCase().includes(D)||M.description?.toLowerCase().includes(D))}return _},e[13]=o,e[14]=i,e[15]=u,e[16]=b):b=e[16];const E=b;let y;e[17]!==n||e[18]!==E||e[19]!==p||e[20]!==u?(y=T.jsx(rN,{editor:n,char:"/",pluginKey:"promptsDropdownMenu",queryKey:u,queryFn:E,onSelect:p}),e[17]=n,e[18]=E,e[19]=p,e[20]=u,e[21]=y):y=e[21];const S=c?.item??null;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=()=>d(null),e[22]=k):k=e[22];let x;e[23]!==g||e[24]!==S?(x=T.jsx(Xx,{prompt:S,setPrompt:k,onSubmit:g}),e[23]=g,e[24]=S,e[25]=x):x=e[25];let A;return e[26]!==y||e[27]!==x?(A=T.jsxs(T.Fragment,{children:[y,x]}),e[26]=y,e[27]=x,e[28]=A):A=e[28],A};function a4(){}async function s4(t,e,n,r){try{const i=await eR(n,r);f_(t,e,{id:r,name:r,metadata:i.contents,char:"@"})}catch(i){console.error("[resource] Failed to fetch resource:",i),_n.error("Failed to load resource. Please try again.")}}const o4=t=>{const e=ae.c(18),{editor:n,virtualMcpId:r}=t,i=Ox(),{org:a}=ci();let s;e[0]!==a.id||e[1]!==r?(s={connectionId:r,orgId:a.id},e[0]=a.id,e[1]=r,e[2]=s):s=e[2];const o=Vm(s);let l;e[3]!==a.id||e[4]!==r?(l=qm.virtualMcpResources(r,a.id),e[3]=a.id,e[4]=r,e[5]=l):l=e[5];const u=l;let c;e[6]!==o||e[7]!==n?(c=async g=>{const{item:b,range:E}=g;o&&await s4(n,E,o,b.uri)},e[6]=o,e[7]=n,e[8]=c):c=e[8];const d=c;let f;e[9]!==o||e[10]!==i||e[11]!==u?(f=async g=>{const{query:b}=g;if(!o)return[];let E=i.getQueryData(u);if(E?i.fetchQuery({queryKey:u,queryFn:()=>Rb(o),staleTime:6e4}).catch(l4):E=await i.fetchQuery({queryKey:u,queryFn:()=>Rb(o),staleTime:6e4}),!E.resources)return[];let y=E.resources;if(b.trim()){const S=b.toLowerCase();y=E.resources.filter(k=>k.uri.toLowerCase().includes(S)||k.name?.toLowerCase().includes(S)||k.description?.toLowerCase().includes(S))}return y.map(u4)},e[9]=o,e[10]=i,e[11]=u,e[12]=f):f=e[12];const p=f;let h;return e[13]!==n||e[14]!==p||e[15]!==d||e[16]!==u?(h=T.jsx(rN,{editor:n,char:"@",pluginKey:"resourcesDropdownMenu",queryKey:u,queryFn:p,onSelect:d}),e[13]=n,e[14]=p,e[15]=d,e[16]=u,e[17]=h):h=e[17],h};function l4(){}function u4(t){return{name:t.name??t.uri,title:t.name,description:t.description,uri:t.uri}}const c4=[q_.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1}),DP.configure({placeholder:"Ask anything, use / for prompts, @ for resources, or drop files here...",showOnlyWhenEditable:!1}),m_,b_];function d4(t){const e=ae.c(22),{tiptapDoc:n,setTiptapDoc:r,selectedModel:i,isStreaming:a,onSubmit:s,children:o}=t,l=a||!i,u=U.useRef(s),c=U.useRef(r),d=n||"",f=!l;let p,h;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={attributes:{class:"prose prose-sm max-w-none focus:outline-none w-full h-full text-[15px] p-[18px]"},handleKeyDown:(_,D)=>D.key==="Enter"&&!D.shiftKey?(D.preventDefault(),u.current?.(),!0):!1},h=_=>{const{editor:D}=_;c.current(D?.getJSON())},e[0]=p,e[1]=h):(p=e[0],h=e[1]);let g;e[2]!==d||e[3]!==f?(g={extensions:c4,content:d,editable:f,editorProps:p,onUpdate:h},e[2]=d,e[3]=f,e[4]=g):g=e[4];let b;e[5]!==l?(b=[l],e[5]=l,e[6]=b):b=e[6];const E=s_(g,b);let y,S;e[7]!==s?(y=()=>{u.current=s},S=[s],e[7]=s,e[8]=y,e[9]=S):(y=e[8],S=e[9]),U.useEffect(y,S);let k,x;e[10]!==r?(x=()=>{c.current=r},k=[r],e[10]=r,e[11]=k,e[12]=x):(k=e[11],x=e[12]),U.useEffect(x,k);let A,v;e[13]!==E||e[14]!==n?(A=()=>{if(E?.isDestroyed)return;const _=JSON.stringify(E?.getJSON()),D=JSON.stringify(n||{type:"doc",content:[]});_!==D&&E.commands.setContent(n||{type:"doc",content:[]})},v=[E,n],e[13]=E,e[14]=n,e[15]=A,e[16]=v):(A=e[15],v=e[16]),U.useEffect(A,v);let w;e[17]!==E?(w={editor:E},e[17]=E,e[18]=w):w=e[18];let N;return e[19]!==o||e[20]!==w?(N=T.jsx(Fo.Provider,{value:w,children:o}),e[19]=o,e[20]=w,e[21]=N):N=e[21],N}function p4(t){const e=ae.c(24),{selectedModel:n,isStreaming:r,selectedVirtualMcp:i,ref:a}=t,{editor:s}=o_(),o=i?.id??null,l=r||!n;let u;e[0]!==s?.commands?(u=()=>({focus:()=>{s?.commands.focus()},clear:()=>{s?.commands.clearContent(!0)}}),e[0]=s?.commands,e[1]=u):u=e[1];let c;if(e[2]!==s?(c=[s],e[2]=s,e[3]=c):c=e[3],U.useImperativeHandle(a??null,u,c),!s)return null;const d=l&&"cursor-not-allowed opacity-70",f=l&&"[&_.ProseMirror]:cursor-not-allowed";let p;e[4]!==d||e[5]!==f?(p=pe("overflow-y-auto relative flex-1 max-h-[164px] min-h-[20px] w-full flex flex-col","[&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[20px] [&_.ProseMirror]:flex-1","[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]","[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground","[&_.ProseMirror_p.is-editor-empty:first-child::before]:opacity-50","[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left","[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none","[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0",d,f),e[4]=d,e[5]=f,e[6]=p):p=e[6];let h;e[7]!==s||e[8]!==p?(h=T.jsx(Ag,{editor:s,className:p}),e[7]=s,e[8]=p,e[9]=h):h=e[9];let g;e[10]!==s||e[11]!==o?(g=T.jsx(U.Suspense,{fallback:null,children:T.jsx(i4,{editor:s,virtualMcpId:o})}),e[10]=s,e[11]=o,e[12]=g):g=e[12];let b;e[13]!==s||e[14]!==o?(b=T.jsx(U.Suspense,{fallback:null,children:T.jsx(o4,{editor:s,virtualMcpId:o})}),e[13]=s,e[14]=o,e[15]=b):b=e[15];let E;e[16]!==s||e[17]!==n?(E=T.jsx(oP,{editor:s,selectedModel:n}),e[16]=s,e[17]=n,e[18]=E):E=e[18];let y;return e[19]!==h||e[20]!==g||e[21]!==b||e[22]!==E?(y=T.jsxs(T.Fragment,{children:[h,g,b,E]}),e[19]=h,e[20]=g,e[21]=b,e[22]=E,e[23]=y):y=e[23],y}function iN(t){const e=ae.c(38),{messages:n}=t;let r,i,a,s,o,l,u,c,d,f,p,h;if(e[0]!==n){h=Symbol.for("react.early_return_sentinel");e:{const k=gR(n);if(!k){h=null;break e}const{totalTokens:x,inputTokens:A,outputTokens:v,cost:w}=k;if(a=w,!x&&!A&&!v){h=null;break e}i=wn;let N;e[13]===Symbol.for("react.memo_cache_sentinel")?(N=T.jsx(Gx,{size:12}),e[13]=N):N=e[13];const _=T.jsxs(et,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground pl-1! h-6 gap-1 whitespace-nowrap shrink-0",children:[N,T.jsx("span",{className:"text-[10px] font-mono tabular-nums",children:x.toLocaleString()})]});e[14]!==_?(p=T.jsx(Rn,{asChild:!0,children:_}),e[14]=_,e[15]=p):p=e[15],r=On,d="top",f="font-mono text-[11px]",o="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5",e[16]===Symbol.for("react.memo_cache_sentinel")?(l=T.jsx("span",{className:"text-muted",children:"in"}),e[16]=l):l=e[16],u=T.jsx("span",{children:A.toLocaleString()}),e[17]===Symbol.for("react.memo_cache_sentinel")?(c=T.jsx("span",{className:"text-muted",children:"out"}),e[17]=c):c=e[17],s=v.toLocaleString()}e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=s,e[5]=o,e[6]=l,e[7]=u,e[8]=c,e[9]=d,e[10]=f,e[11]=p,e[12]=h}else r=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],h=e[12];if(h!==Symbol.for("react.early_return_sentinel"))return h;let g;e[18]!==s?(g=T.jsx("span",{children:s}),e[18]=s,e[19]=g):g=e[19];let b;e[20]!==a?(b=a>0&&T.jsxs(T.Fragment,{children:[T.jsx("span",{className:"text-muted",children:"cost"}),T.jsxs("span",{children:["$",a.toFixed(4)]})]}),e[20]=a,e[21]=b):b=e[21];let E;e[22]!==g||e[23]!==b||e[24]!==o||e[25]!==l||e[26]!==u||e[27]!==c?(E=T.jsxs("div",{className:o,children:[l,u,c,g,b]}),e[22]=g,e[23]=b,e[24]=o,e[25]=l,e[26]=u,e[27]=c,e[28]=E):E=e[28];let y;e[29]!==r||e[30]!==E||e[31]!==d||e[32]!==f?(y=T.jsx(r,{side:d,className:f,children:E}),e[29]=r,e[30]=E,e[31]=d,e[32]=f,e[33]=y):y=e[33];let S;return e[34]!==i||e[35]!==y||e[36]!==p?(S=T.jsxs(i,{children:[p,y]}),e[34]=i,e[35]=y,e[36]=p,e[37]=S):S=e[37],S}function f4(t){const e=ae.c(25),{onVirtualMcpChange:n,virtualMcps:r,disabled:i}=t,a=i===void 0?!1:i,[s,o]=U.useState(!1),l=U.useRef(null),{org:u}=ci();let c;e[0]!==u.id?(c=Px(u.id),e[0]=u.id,e[1]=c):c=e[1];const d=c;let f;e[2]!==r?(f=r.filter(h4),e[2]=r,e[3]=f):f=e[3];const p=f;let h,g;e[4]!==s?(h=()=>{s&&setTimeout(()=>{l.current?.focus()},0)},g=[s],e[4]=s,e[5]=h,e[6]=g):(h=e[5],g=e[6]),U.useEffect(h,g);let b;e[7]!==n?(b=w=>{n(w),o(!1)},e[7]=n,e[8]=b):b=e[8];const E=b;let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=T.jsx(ia,{size:16}),e[9]=y):y=e[9];let S;e[10]!==a?(S=T.jsx(Rn,{asChild:!0,children:T.jsx(pi,{asChild:!0,children:T.jsx(et,{type:"button",variant:"ghost",size:"icon",className:"size-8 rounded-full",disabled:a,children:y})})}),e[10]=a,e[11]=S):S=e[11];let k;e[12]!==s?(k=!s&&T.jsx(On,{side:"top",children:"Decopilot"}),e[12]=s,e[13]=k):k=e[13];let x;e[14]!==S||e[15]!==k?(x=T.jsxs(wn,{children:[S,k]}),e[14]=S,e[15]=k,e[16]=x):x=e[16];let A;e[17]!==d.id||e[18]!==p||e[19]!==E?(A=T.jsx(fi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(xg,{virtualMcps:p,selectedVirtualMcpId:d.id,onVirtualMcpChange:E,searchInputRef:l})}),e[17]=d.id,e[18]=p,e[19]=E,e[20]=A):A=e[20];let v;return e[21]!==s||e[22]!==x||e[23]!==A?(v=T.jsxs(di,{open:s,onOpenChange:o,children:[x,A]}),e[21]=s,e[22]=x,e[23]=A,e[24]=v):v=e[24],v}function h4(t){return!t.id||!Qr(t.id)}function m4({virtualMcpId:t,virtualMcps:e,onVirtualMcpChange:n,disabled:r=!1}){const[i,a]=U.useState(!1),s=U.useRef(null),o=Lx(),{org:l}=ci(),u=e.find(h=>h.id===t);if(!u||Qr(t))return null;U.useEffect(()=>{i&&setTimeout(()=>{s.current?.focus()},0)},[i]);const c=g_(t),d=h=>{h.stopPropagation(),n(null)},f=h=>{h.stopPropagation(),o({to:"/$org/$project/agents/$agentId",params:{org:l.slug,project:as,agentId:t}})},p=h=>{n(h),a(!1)};return T.jsxs("div",{className:pe("flex items-center justify-between px-3 py-1.5 rounded-t-xl",c?.bg),children:[T.jsxs(di,{open:i,onOpenChange:a,children:[T.jsx(pi,{asChild:!0,children:T.jsxs("button",{type:"button",disabled:r,className:pe("flex items-center gap-1.5 hover:opacity-80 transition-opacity",r?"cursor-not-allowed opacity-50":"cursor-pointer"),children:[T.jsx(Gm,{icon:u.icon,name:u.title,size:"2xs",className:"bg-background rounded-sm",fallbackIcon:u.fallbackIcon??T.jsx(ia,{size:10})}),T.jsx("span",{className:"text-xs text-white font-normal",children:u.title}),T.jsx(Hh,{size:14,className:"text-white/50"})]})}),T.jsx(fi,{className:"w-[550px] p-0 overflow-hidden",align:"start",side:"top",sideOffset:8,children:T.jsx(xg,{virtualMcps:e,selectedVirtualMcpId:t,onVirtualMcpChange:p,searchInputRef:s})})]}),T.jsxs("div",{className:"flex items-center gap-1",children:[T.jsx("button",{type:"button",onClick:f,disabled:r,className:pe("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Edit agent",children:T.jsx(mR,{size:14,className:"text-white"})}),T.jsx("button",{type:"button",onClick:d,disabled:r,className:pe("flex items-center justify-center p-1 rounded-full transition-colors",r?"cursor-not-allowed opacity-50":"cursor-pointer hover:bg-white/10"),"aria-label":"Reset to default",children:T.jsx(Kx,{size:14,className:"text-white"})})]})]})}function g4(){const t=ae.c(111),{activeThreadId:e,tiptapDoc:n,setTiptapDoc:r,virtualMcps:i,selectedVirtualMcp:a,setVirtualMcpId:s,modelsConnections:o,selectedModel:l,setSelectedModel:u,selectedMode:c,setSelectedMode:d,messages:f,isStreaming:p,sendMessage:h,stopStreaming:g,chatError:b,clearChatError:E,finishReason:y,clearFinishReason:S}=ka(),k=U.useRef(null);let x;t[0]!==p||t[1]!==l||t[2]!==n?(x=!p&&!!l&&!z3(n),t[0]=p,t[1]=l,t[2]=n,t[3]=x):x=t[3];const A=x;let v;t[4]!==A||t[5]!==p||t[6]!==h||t[7]!==g||t[8]!==n?(v=Nt=>{Nt?.preventDefault(),p?g():A&&n&&h(n)},t[4]=A,t[5]=p,t[6]=h,t[7]=g,t[8]=n,t[9]=v):v=t[9];const w=v;let N;t[10]!==b||t[11]!==h?(N=()=>{if(b){const Jt={type:"doc",content:[{type:"paragraph",content:[{type:"text",text:`I encountered this error: ${b.message}. Can you help me fix it?`}]}]};h(Jt)}},t[10]=b,t[11]=h,t[12]=N):N=t[12];const _=N;let D;t[13]!==h?(D=()=>{h({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Please continue."}]}]})},t[13]=h,t[14]=D):D=t[14];const M=D;let q,P,F,$;if(t[15]!==b||t[16]!==E||t[17]!==S||t[18]!==y||t[19]!==M||t[20]!==_||t[21]!==a){const Nt=a?g_(a.id):null;P="flex flex-col gap-2 w-full min-h-42 justify-end",t[26]!==b||t[27]!==E||t[28]!==_?(F=b&&T.jsxs(_x,{variant:"danger",title:"Error occurred",description:b.message,icon:T.jsx(Ux,{size:16}),onDismiss:E,children:[T.jsx(et,{size:"sm",variant:"outline",onClick:_,className:"h-7 text-xs",children:"Fix in chat"}),T.jsx(et,{size:"sm",variant:"outline",disabled:!0,className:"h-7 text-xs",children:"Report"})]}),t[26]=b,t[27]=E,t[28]=_,t[29]=F):F=t[29],t[30]!==S||t[31]!==y||t[32]!==M?($=y&&y!=="stop"&&T.jsx(_x,{variant:"warning",title:"Response incomplete",description:y==="length"?"Response reached the model's output limit. Different models have different limits. Try switching models or asking it to continue.":y==="content-filter"?"Response was filtered due to content policy.":y==="tool-calls"?"Response paused after tool execution to prevent infinite loops and save costs. Click continue to keep working.":`Response stopped unexpectedly: ${y}`,icon:T.jsx(nR,{size:16}),onDismiss:S,children:T.jsx(et,{size:"sm",variant:"outline",onClick:M,className:"h-7 text-xs",children:"Continue"})}),t[30]=S,t[31]=y,t[32]=M,t[33]=$):$=t[33],q=pe("relative rounded-xl w-full flex flex-col",a&&"shadow-sm",Nt?.bg),t[15]=b,t[16]=E,t[17]=S,t[18]=y,t[19]=M,t[20]=_,t[21]=a,t[22]=q,t[23]=P,t[24]=F,t[25]=$}else q=t[22],P=t[23],F=t[24],$=t[25];let G;t[34]!==p||t[35]!==a||t[36]!==s||t[37]!==i?(G=a?.id&&!Qr(a.id)&&T.jsx(m4,{onVirtualMcpChange:s,virtualMcpId:a.id,virtualMcps:i,disabled:p}),t[34]=p,t[35]=a,t[36]=s,t[37]=i,t[38]=G):G=t[38];const H=!a&&"shadow-sm";let J;t[39]!==H?(J=pe("w-full relative rounded-xl min-h-[130px] flex flex-col border border-border bg-background",H),t[39]=H,t[40]=J):J=t[40];let I;t[41]!==p||t[42]!==l||t[43]!==a?(I=T.jsx("div",{className:"relative flex flex-col gap-2 flex-1",children:T.jsx(p4,{ref:k,selectedModel:l,isStreaming:p,selectedVirtualMcp:a})}),t[41]=p,t[42]=l,t[43]=a,t[44]=I):I=t[44];let X;t[45]!==p||t[46]!==a||t[47]!==s||t[48]!==i?(X=a&&Qr(a.id)?T.jsx(f4,{onVirtualMcpChange:s,virtualMcps:i,disabled:p}):T.jsx(nP,{selectedVirtualMcpId:a?.id??null,onVirtualMcpChange:s,virtualMcps:i,placeholder:"Agent",disabled:p}),t[45]=p,t[46]=a,t[47]=s,t[48]=i,t[49]=X):X=t[49];let re;t[50]!==f?(re=T.jsx(iN,{messages:f}),t[50]=f,t[51]=re):re=t[51];let R;t[52]!==X||t[53]!==re?(R=T.jsxs("div",{className:"flex items-center gap-2 min-w-0 overflow-hidden",children:[X,re]}),t[52]=X,t[53]=re,t[54]=R):R=t[54];const ie=l??void 0;let te;t[55]!==o||t[56]!==u||t[57]!==ie?(te=T.jsx(Vw,{selectedModel:ie,onModelChange:u,modelsConnections:o,placeholder:"Model",variant:"borderless"}),t[55]=o,t[56]=u,t[57]=ie,t[58]=te):te=t[58];let se;t[59]!==p||t[60]!==c||t[61]!==d?(se=T.jsx(J3,{selectedMode:c,onModeChange:d,placeholder:"Mode",variant:"borderless",disabled:p}),t[59]=p,t[60]=c,t[61]=d,t[62]=se):se=t[62];let he;t[63]!==p||t[64]!==l?(he=T.jsx(uP,{selectedModel:l,isStreaming:p}),t[63]=p,t[64]=l,t[65]=he):he=t[65];const Ae=p?"button":"submit";let ve;t[66]!==p||t[67]!==g?(ve=Nt=>{p&&(Nt.preventDefault(),Nt.stopPropagation(),g())},t[66]=p,t[67]=g,t[68]=ve):ve=t[68];const Ce=A||p?"default":"ghost",De=!A&&!p,Ke=!A&&!p&&"bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground cursor-not-allowed";let we;t[69]!==Ke?(we=pe("size-8 rounded-full transition-all",Ke),t[69]=Ke,t[70]=we):we=t[70];const lt=p?"Stop generating":"Send message (Enter)";let qe;t[71]!==p?(qe=p?T.jsx(Wx,{size:20}):T.jsx(hR,{size:20}),t[71]=p,t[72]=qe):qe=t[72];let Re;t[73]!==Ae||t[74]!==ve||t[75]!==Ce||t[76]!==De||t[77]!==we||t[78]!==lt||t[79]!==qe?(Re=T.jsx(et,{type:Ae,onClick:ve,variant:Ce,size:"icon",disabled:De,className:we,title:lt,children:qe}),t[73]=Ae,t[74]=ve,t[75]=Ce,t[76]=De,t[77]=we,t[78]=lt,t[79]=qe,t[80]=Re):Re=t[80];let Ye;t[81]!==te||t[82]!==se||t[83]!==he||t[84]!==Re?(Ye=T.jsxs("div",{className:"flex items-center gap-1",children:[te,se,he,Re]}),t[81]=te,t[82]=se,t[83]=he,t[84]=Re,t[85]=Ye):Ye=t[85];let He;t[86]!==R||t[87]!==Ye?(He=T.jsxs("div",{className:"flex items-center justify-between p-2.5",children:[R,Ye]}),t[86]=R,t[87]=Ye,t[88]=He):He=t[88];let zt;t[89]!==w||t[90]!==J||t[91]!==I||t[92]!==He?(zt=T.jsxs("form",{onSubmit:w,className:J,children:[I,He]}),t[89]=w,t[90]=J,t[91]=I,t[92]=He,t[93]=zt):zt=t[93];let rt;t[94]!==e||t[95]!==w||t[96]!==p||t[97]!==l||t[98]!==r||t[99]!==zt||t[100]!==n?(rt=T.jsx("div",{className:"p-0.5",children:T.jsx(d4,{tiptapDoc:n,setTiptapDoc:r,selectedModel:l,isStreaming:p,onSubmit:w,children:zt},e)}),t[94]=e,t[95]=w,t[96]=p,t[97]=l,t[98]=r,t[99]=zt,t[100]=n,t[101]=rt):rt=t[101];let qt;t[102]!==rt||t[103]!==q||t[104]!==G?(qt=T.jsxs("div",{className:q,children:[G,rt]}),t[102]=rt,t[103]=q,t[104]=G,t[105]=qt):qt=t[105];let Pt;return t[106]!==qt||t[107]!==P||t[108]!==F||t[109]!==$?(Pt=T.jsxs("div",{className:P,children:[F,$,qt]}),t[106]=qt,t[107]=P,t[108]=F,t[109]=$,t[110]=Pt):Pt=t[110],Pt}function Bg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Lr=Bg();function aN(t){Lr=t}var Ki={exec:()=>null};function Se(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,a)=>{let s=typeof a=="string"?a:a.source;return s=s.replace(xt.caret,"$1"),n=n.replace(i,s),r},getRegex:()=>new RegExp(n,e)};return r}var xt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},b4=/^(?:[ \t]*(?:\n|$))+/,E4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,y4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ia=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,T4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ug=/(?:[*+-]|\d{1,9}[.)])/,sN=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oN=Se(sN).replace(/bull/g,Ug).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),S4=Se(sN).replace(/bull/g,Ug).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Hg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,A4=/^[^\n]+/,$g=/(?!\s*\])(?:\\.|[^\[\]\\])+/,k4=Se(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$g).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),x4=Se(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ug).getRegex(),Uo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",zg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,v4=Se("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",zg).replace("tag",Uo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),lN=Se(Hg).replace("hr",Ia).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uo).getRegex(),C4=Se(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",lN).getRegex(),qg={blockquote:C4,code:E4,def:k4,fences:y4,heading:T4,hr:Ia,html:v4,lheading:oN,list:x4,newline:b4,paragraph:lN,table:Ki,text:A4},x0=Se("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ia).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uo).getRegex(),_4={...qg,lheading:S4,table:x0,paragraph:Se(Hg).replace("hr",Ia).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",x0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Uo).getRegex()},N4={...qg,html:Se(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",zg).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ki,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Se(Hg).replace("hr",Ia).replace("heading",` *#{1,6} *[^
141
141
  ]`).replace("lheading",oN).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},I4=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,w4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,uN=/^( {2,}|\\)\n(?!\s*$)/,R4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ho=/[\p{P}\p{S}]/u,jg=/[\s\p{P}\p{S}]/u,cN=/[^\s\p{P}\p{S}]/u,O4=Se(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,jg).getRegex(),dN=/(?!~)[\p{P}\p{S}]/u,L4=/(?!~)[\s\p{P}\p{S}]/u,D4=/(?:[^\s\p{P}\p{S}]|~)/u,M4=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,pN=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,P4=Se(pN,"u").replace(/punct/g,Ho).getRegex(),F4=Se(pN,"u").replace(/punct/g,dN).getRegex(),fN="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",B4=Se(fN,"gu").replace(/notPunctSpace/g,cN).replace(/punctSpace/g,jg).replace(/punct/g,Ho).getRegex(),U4=Se(fN,"gu").replace(/notPunctSpace/g,D4).replace(/punctSpace/g,L4).replace(/punct/g,dN).getRegex(),H4=Se("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,cN).replace(/punctSpace/g,jg).replace(/punct/g,Ho).getRegex(),$4=Se(/\\(punct)/,"gu").replace(/punct/g,Ho).getRegex(),z4=Se(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),q4=Se(zg).replace("(?:-->|$)","-->").getRegex(),j4=Se("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",q4).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),po=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,G4=Se(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",po).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),hN=Se(/^!?\[(label)\]\[(ref)\]/).replace("label",po).replace("ref",$g).getRegex(),mN=Se(/^!?\[(ref)\](?:\[\])?/).replace("ref",$g).getRegex(),V4=Se("reflink|nolink(?!\\()","g").replace("reflink",hN).replace("nolink",mN).getRegex(),Gg={_backpedal:Ki,anyPunctuation:$4,autolink:z4,blockSkip:M4,br:uN,code:w4,del:Ki,emStrongLDelim:P4,emStrongRDelimAst:B4,emStrongRDelimUnd:H4,escape:I4,link:G4,nolink:mN,punctuation:O4,reflink:hN,reflinkSearch:V4,tag:j4,text:R4,url:Ki},W4={...Gg,link:Se(/^!?\[(label)\]\((.*?)\)/).replace("label",po).getRegex(),reflink:Se(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",po).getRegex()},Am={...Gg,emStrongRDelimAst:U4,emStrongLDelim:F4,url:Se(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},Y4={...Am,br:Se(uN).replace("{2,}","*").getRegex(),text:Se(Am.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Xa={normal:qg,gfm:_4,pedantic:N4},vi={normal:Gg,gfm:Am,breaks:Y4,pedantic:W4},K4={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},v0=t=>K4[t];function sn(t,e){if(e){if(xt.escapeTest.test(t))return t.replace(xt.escapeReplace,v0)}else if(xt.escapeTestNoEncode.test(t))return t.replace(xt.escapeReplaceNoEncode,v0);return t}function C0(t){try{t=encodeURI(t).replace(xt.percentDecode,"%")}catch{return null}return t}function _0(t,e){const n=t.replace(xt.findPipe,(a,s,o)=>{let l=!1,u=s;for(;--u>=0&&o[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(xt.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(xt.slashPipe,"|");return r}function Ci(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function X4(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function N0(t,e,n,r,i){const a=e.href,s=e.title||null,o=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}function Z4(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
142
142
  `).map(a=>{const s=a.match(n.other.beginningSpace);if(s===null)return a;const[o]=s;return o.length>=i.length?a.slice(i.length):a}).join(`
143
143
  `)}var fo=class{options;rules;lexer;constructor(t){this.options=t||Lr}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Ci(n,`