@lobu/runtime-server 21.2.0 → 21.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/owletto/dist/assets/_-CLhipgJI.js +1 -0
  3. package/dist/owletto/dist/assets/{_-C1iPVDAS.js → _-D0ZVGAIA.js} +2 -2
  4. package/dist/owletto/dist/assets/{_agentId-DvhFYLLv.js → _agentId-BLXUf3ot.js} +1 -1
  5. package/dist/owletto/dist/assets/_agentId-DnI66MF3.js +1 -0
  6. package/dist/owletto/dist/assets/{_automationId-NuFSEFlw.js → _automationId-ziwseLb7.js} +1 -1
  7. package/dist/owletto/dist/assets/{_connectorKey._connectionId-D_FhMGN1.js → _connectorKey._connectionId-B6V3ySFK.js} +1 -1
  8. package/dist/owletto/dist/assets/{_connectorKey.index-B8AZikVg.js → _connectorKey.index-CR5u_dtt.js} +1 -1
  9. package/dist/owletto/dist/assets/{_conversationId-D1Cx42I0.js → _conversationId-FBMYmOl8.js} +1 -1
  10. package/dist/owletto/dist/assets/{_deploymentId-BjtZC8Oo.js → _deploymentId-DNTXbT_m.js} +1 -1
  11. package/dist/owletto/dist/assets/_name-B37LKIxH.js +1 -0
  12. package/dist/owletto/dist/assets/{_owner-c8L8M4FP.js → _owner-BxYumqC2.js} +1 -1
  13. package/dist/owletto/dist/assets/_shape-Bxz-04jR.js +1 -0
  14. package/dist/owletto/dist/assets/_skillKey-D5MFbiw2.js +1 -0
  15. package/dist/owletto/dist/assets/{_slug-Nlm2ziLr.js → _slug-Dlhit09k.js} +1 -1
  16. package/dist/owletto/dist/assets/_viewKey-C6535i-t.js +1 -0
  17. package/dist/owletto/dist/assets/_viewKey-CQCtY3Y8.js +1 -0
  18. package/dist/owletto/dist/assets/_viewKey-CxKfKbRa.js +1 -0
  19. package/dist/owletto/dist/assets/{accept-invitation-BfqbITxp.js → accept-invitation-BQQwec3R.js} +1 -1
  20. package/dist/owletto/dist/assets/{activity-route-view-CTQEg3Us.js → activity-route-view-BwThvdGs.js} +1 -1
  21. package/dist/owletto/dist/assets/{agent-card-controls-49SIdmyU.js → agent-card-controls-B3RhzsPz.js} +1 -1
  22. package/dist/owletto/dist/assets/{agent-client-setup-list-ChwHMq4Q.js → agent-client-setup-list-BFtgRwe8.js} +1 -1
  23. package/dist/owletto/dist/assets/{agent-connect-pages-CJntJskO.js → agent-connect-pages-BO4wQn4L.js} +1 -1
  24. package/dist/owletto/dist/assets/{agent-editor-form-CEEFNek5.js → agent-editor-form-BYC4uSNz.js} +1 -1
  25. package/dist/owletto/dist/assets/{agent-guardrails-route-BF_RvzHv.js → agent-guardrails-route-Dp02G1AQ.js} +1 -1
  26. package/dist/owletto/dist/assets/{agent-loading-shells-Cve_XIMW.js → agent-loading-shells-OagauQzV.js} +1 -1
  27. package/dist/owletto/dist/assets/{agent-permissions-matrix-DEYa123T.js → agent-permissions-matrix-B9Ho3P1t.js} +1 -1
  28. package/dist/owletto/dist/assets/{agent-skill-context-DuS7Ojm_.js → agent-skill-context-BAr2Dw3F.js} +1 -1
  29. package/dist/owletto/dist/assets/{agent-skills-route-BItudd8s.js → agent-skills-route-B4VUnVi0.js} +1 -1
  30. package/dist/owletto/dist/assets/{agent-subpage-shell-BkGzpmv5.js → agent-subpage-shell-Dz8I-GUt.js} +1 -1
  31. package/dist/owletto/dist/assets/{agent-thread-DhCFggHZ.js → agent-thread-B9-cdkaV.js} +1 -1
  32. package/dist/owletto/dist/assets/agents-D0CIg4b9.js +1 -0
  33. package/dist/owletto/dist/assets/{agents-workbench-BZaoiFNY.js → agents-workbench-C2sr5h82.js} +1 -1
  34. package/dist/owletto/dist/assets/{app._appId-0fp8NC9-.js → app._appId-DLsJ_QWS.js} +1 -1
  35. package/dist/owletto/dist/assets/{automation-detail-content-C08Ef137.js → automation-detail-content-9Rjb_I9j.js} +1 -1
  36. package/dist/owletto/dist/assets/automations-D0CIg4b9.js +1 -0
  37. package/dist/owletto/dist/assets/{calendar-CvEqJnKS.js → calendar-DAiyi1ZL.js} +1 -1
  38. package/dist/owletto/dist/assets/{callback-BfjlxUcL.js → callback-CaRe2TOT.js} +1 -1
  39. package/dist/owletto/dist/assets/{card-MXMmjz9G.js → card-CMmh2mzo.js} +1 -1
  40. package/dist/owletto/dist/assets/{claim-B5igXpyF.js → claim-CYHnUF7G.js} +1 -1
  41. package/dist/owletto/dist/assets/{clients-DqMOcwpO.js → clients-Cp1BJ28u.js} +1 -1
  42. package/dist/owletto/dist/assets/{code-editor-bpbaa7f6.js → code-editor-CYsR2VBP.js} +1 -1
  43. package/dist/owletto/dist/assets/connect-CZip2g_B.js +1 -0
  44. package/dist/owletto/dist/assets/connect._clientId-CEKY8Dnv.js +1 -0
  45. package/dist/owletto/dist/assets/{connected._clientId-BWVr-PMm.js → connected._clientId-C5xRjxNO.js} +1 -1
  46. package/dist/owletto/dist/assets/{connection-D-dXA43c.js → connection-C06HZ241.js} +1 -1
  47. package/dist/owletto/dist/assets/{connection-feed-detail-XYK-ubKG.js → connection-feed-detail-D1whY5hL.js} +1 -1
  48. package/dist/owletto/dist/assets/{connector-provenance-RL_DcF2q.js → connector-provenance-BjKiUhYE.js} +1 -1
  49. package/dist/owletto/dist/assets/{connectors-B2_PLuXP.js → connectors-Baejya0T.js} +1 -1
  50. package/dist/owletto/dist/assets/{consent-CMrkyIfi.js → consent-CfYDldcF.js} +1 -1
  51. package/dist/owletto/dist/assets/{core.esm-BrIR85HL.js → core.esm-QA7BQgiK.js} +1 -1
  52. package/dist/owletto/dist/assets/create-C3P-3_8O.js +1 -0
  53. package/dist/owletto/dist/assets/create-CwnrPUEw.js +1 -0
  54. package/dist/owletto/dist/assets/{create-UTXCruIl.js → create-DOScS9Gl.js} +1 -1
  55. package/dist/owletto/dist/assets/{create-automation-form-BHir-pIp.js → create-automation-form-CuxiIRCF.js} +1 -1
  56. package/dist/owletto/dist/assets/{create._connectorKey-qjd3B6p5.js → create._connectorKey-Bjv3lCf8.js} +1 -1
  57. package/dist/owletto/dist/assets/{cronstrue-BwvvZn_Y.js → cronstrue-2GHCtD7h.js} +1 -1
  58. package/dist/owletto/dist/assets/{deployments-DHAx8TBs.js → deployments-ByBv1DW-.js} +1 -1
  59. package/dist/owletto/dist/assets/deployments-C-_ECORv.js +1 -0
  60. package/dist/owletto/dist/assets/{deployments-body-B54mJoZC.js → deployments-body-Bm2upStd.js} +1 -1
  61. package/dist/owletto/dist/assets/{device-Bi_9KNKQ.js → device-B0i7Xp8y.js} +1 -1
  62. package/dist/owletto/dist/assets/{device-pin-tombstone-Dkmmka9d.js → device-pin-tombstone-Bd6vS2zu.js} +1 -1
  63. package/dist/owletto/dist/assets/{device-rows-CkTAaZ3m.js → device-rows-Bwf8qDte.js} +1 -1
  64. package/dist/owletto/dist/assets/{device._deviceId-B_WqDhY5.js → device._deviceId-DJLAesm3.js} +1 -1
  65. package/dist/owletto/dist/assets/{entity-options-Bm1sbpmt.js → entity-options-CrbS6K-i.js} +1 -1
  66. package/dist/owletto/dist/assets/{entity-page-DZUGex-P.js → entity-page-ijZe_1-6.js} +1 -1
  67. package/dist/owletto/dist/assets/{entity-type-page-DSBcVv9e.js → entity-type-page-onp2Tk_E.js} +1 -1
  68. package/dist/owletto/dist/assets/{event-page-B837JclA.js → event-page-C0B2UDY-.js} +1 -1
  69. package/dist/owletto/dist/assets/{events-feed-BgvLTppV.js → events-feed-DK35T4g7.js} +1 -1
  70. package/dist/owletto/dist/assets/{full-page-spinner-ByBsHimW.js → full-page-spinner-Dd8eEaxq.js} +1 -1
  71. package/dist/owletto/dist/assets/guardrails-DKO8_J-G.js +1 -0
  72. package/dist/owletto/dist/assets/identity-CKM54vrM.js +1 -0
  73. package/dist/owletto/dist/assets/{index-DjYcFuq9.js → index--VmN5WxW.js} +1 -1
  74. package/dist/owletto/dist/assets/{index-GZkujXG1.js → index-B2AmRqYh.js} +1589 -1589
  75. package/dist/owletto/dist/assets/{index-Be5BLMwZ.js → index-B_rcEgFX.js} +1 -1
  76. package/dist/owletto/dist/assets/{index-Dpf0I2N4.js → index-BmhGe6-Z.js} +1 -1
  77. package/dist/owletto/dist/assets/index-C1dJSGrL.js +1 -0
  78. package/dist/owletto/dist/assets/index-CAFw4qCb.js +1 -0
  79. package/dist/owletto/dist/assets/{index-DBs2lhwE.js → index-CCcc_xBw.js} +1 -1
  80. package/dist/owletto/dist/assets/{index-DqrjJ9LB.js → index-CLU3gXVm.js} +1 -1
  81. package/dist/owletto/dist/assets/{index-Cane2GT3.js → index-Cf0GJoiG.js} +1 -1
  82. package/dist/owletto/dist/assets/index-CqQVnAY-.js +1 -0
  83. package/dist/owletto/dist/assets/{index-BrT0gBIi.js → index-CxT0uyIe.js} +1 -1
  84. package/dist/owletto/dist/assets/index-DR08e6Ec.js +1 -0
  85. package/dist/owletto/dist/assets/index-DYb9L5FC.js +1 -0
  86. package/dist/owletto/dist/assets/{index-C1MV7ajb.js → index-DlepU3cY.js} +1 -1
  87. package/dist/owletto/dist/assets/index-SUUcQGT-.js +1 -0
  88. package/dist/owletto/dist/assets/index-SdiFOfR1.js +1 -0
  89. package/dist/owletto/dist/assets/index-zcfi5r1l.js +1 -0
  90. package/dist/owletto/dist/assets/{json-diff-D6sv990W.js → json-diff-ClBBYBQD.js} +1 -1
  91. package/dist/owletto/dist/assets/{list-skeleton-B39wKVT1.js → list-skeleton-BtWn2eo2.js} +1 -1
  92. package/dist/owletto/dist/assets/{login-DxnhCvKx.js → login-d3PdO-qV.js} +1 -1
  93. package/dist/owletto/dist/assets/{logout-Lvib6Kk7.js → logout-DgckxwLn.js} +1 -1
  94. package/dist/owletto/dist/assets/{member-scope-gate-CM-GNviT.js → member-scope-gate-DXOCfx-v.js} +1 -1
  95. package/dist/owletto/dist/assets/{memory-browse-page-DKmyI1FJ.js → memory-browse-page-CeAnKoTR.js} +1 -1
  96. package/dist/owletto/dist/assets/{missing-view-CAFqvZpi.js → missing-view-DrZ8m8yo.js} +1 -1
  97. package/dist/owletto/dist/assets/{model-selector-BoudNhPZ.js → model-selector-CapL1ARf.js} +1 -1
  98. package/dist/owletto/dist/assets/models-CB8mhq7j.js +1 -0
  99. package/dist/owletto/dist/assets/{new-Jp_DtYBt.js → new-BBUb-VR4.js} +1 -1
  100. package/dist/owletto/dist/assets/{new-e3C5Yokb.js → new-CBLJ25_w.js} +1 -1
  101. package/dist/owletto/dist/assets/{new-CKSjnGM9.js → new-tTXB4qBW.js} +1 -1
  102. package/dist/owletto/dist/assets/{oauth-workspace-access-DuPiMSr2.js → oauth-workspace-access-DearynqZ.js} +1 -1
  103. package/dist/owletto/dist/assets/{organization-DUPBruFP.js → organization-BgdBg-PJ.js} +1 -1
  104. package/dist/owletto/dist/assets/{permissions-DqkX4mTH.js → permissions-h_qSft1A.js} +1 -1
  105. package/dist/owletto/dist/assets/{proposal-review-shell-C04RG1qM.js → proposal-review-shell-D4YNrrye.js} +1 -1
  106. package/dist/owletto/dist/assets/{recent-BmxCZQ8j.js → recent-JiBNvZzD.js} +1 -1
  107. package/dist/owletto/dist/assets/{renderer-eFSU65zm.js → renderer-DgPLyEbx.js} +1 -1
  108. package/dist/owletto/dist/assets/{reset-password-BinCwene.js → reset-password-B8tWPtIj.js} +1 -1
  109. package/dist/owletto/dist/assets/{runs-DwThk2CI.js → runs-oHveuEUB.js} +1 -1
  110. package/dist/owletto/dist/assets/{runs-panel-DfxWCV7K.js → runs-panel-C56GDaJm.js} +1 -1
  111. package/dist/owletto/dist/assets/{runs-table-Dh7FL3Va.js → runs-table-BUKDjiBc.js} +1 -1
  112. package/dist/owletto/dist/assets/{schema-value-normalization-CPLeOm7K.js → schema-value-normalization-3JuM_r1H.js} +1 -1
  113. package/dist/owletto/dist/assets/settings-DaKg6U5O.js +1 -0
  114. package/dist/owletto/dist/assets/{settings-DLg89oqz.js → settings-DhnRi2nq.js} +1 -1
  115. package/dist/owletto/dist/assets/skills-BpQncuMC.js +1 -0
  116. package/dist/owletto/dist/assets/{switch-Dcx3_8kM.js → switch-BQ40_DMb.js} +1 -1
  117. package/dist/owletto/dist/assets/{use-applied-views-BpvIIgWG.js → use-applied-views-B-Z-Weji.js} +1 -1
  118. package/dist/owletto/dist/assets/{use-mention-search-Vndny_Gd.js → use-mention-search-B4DfZFm5.js} +1 -1
  119. package/dist/owletto/dist/assets/{view-frame-DxiuLSGA.js → view-frame-C7ciEoLo.js} +1 -1
  120. package/dist/owletto/dist/index.html +1 -1
  121. package/dist/server-main.bundle.mjs +2266 -2125
  122. package/npm-shrinkwrap.json +5 -5
  123. package/package.json +1 -1
  124. package/vendor/connector-sdk/package.json +1 -1
  125. package/vendor/core/package.json +1 -1
  126. package/vendor/views/dist/api.d.ts +42 -5
  127. package/vendor/views/dist/api.js +63 -6
  128. package/vendor/views/package.json +1 -1
  129. package/dist/owletto/dist/assets/_-TlzPuBqI.js +0 -1
  130. package/dist/owletto/dist/assets/_agentId-DutmYPK7.js +0 -1
  131. package/dist/owletto/dist/assets/_name-DTlirHDv.js +0 -1
  132. package/dist/owletto/dist/assets/_shape-DQaUs_O7.js +0 -1
  133. package/dist/owletto/dist/assets/_skillKey-CJSEeyG0.js +0 -1
  134. package/dist/owletto/dist/assets/_viewKey-BK9NZs21.js +0 -1
  135. package/dist/owletto/dist/assets/_viewKey-D-Og614G.js +0 -1
  136. package/dist/owletto/dist/assets/_viewKey-DIFCFECi.js +0 -1
  137. package/dist/owletto/dist/assets/agents-BIA5SCAT.js +0 -1
  138. package/dist/owletto/dist/assets/automations-BIA5SCAT.js +0 -1
  139. package/dist/owletto/dist/assets/connect-DpQrbviv.js +0 -1
  140. package/dist/owletto/dist/assets/connect._clientId-A_F-UzTr.js +0 -1
  141. package/dist/owletto/dist/assets/create-DhxcVjNh.js +0 -1
  142. package/dist/owletto/dist/assets/create-jVkf6V76.js +0 -1
  143. package/dist/owletto/dist/assets/deployments-CSJHFlJz.js +0 -1
  144. package/dist/owletto/dist/assets/guardrails-cMGe6IIe.js +0 -1
  145. package/dist/owletto/dist/assets/identity-BORtpi5L.js +0 -1
  146. package/dist/owletto/dist/assets/index-B5lGxbbZ.js +0 -1
  147. package/dist/owletto/dist/assets/index-BGz-9DDG.js +0 -1
  148. package/dist/owletto/dist/assets/index-BrzsfXR-.js +0 -1
  149. package/dist/owletto/dist/assets/index-C31QOVZH.js +0 -1
  150. package/dist/owletto/dist/assets/index-C6USRbY8.js +0 -1
  151. package/dist/owletto/dist/assets/index-Dh8ubWqr.js +0 -1
  152. package/dist/owletto/dist/assets/index-DpgsgDFc.js +0 -1
  153. package/dist/owletto/dist/assets/index-pFFCzVi5.js +0 -1
  154. package/dist/owletto/dist/assets/models-B8BuBmLu.js +0 -1
  155. package/dist/owletto/dist/assets/settings-CSrpSUqR.js +0 -1
  156. package/dist/owletto/dist/assets/skills-PQP0fNxc.js +0 -1
@@ -1 +1 @@
1
- import{j as r,af as i}from"./index-GZkujXG1.js";function l({checked:n,onCheckedChange:s,disabled:o,className:e,...t}){return r.jsx("button",{type:"button",role:"switch","aria-checked":n,disabled:o,onClick:()=>s(!n),className:i("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",n?"bg-primary":"bg-input",e),...t,children:r.jsx("span",{className:i("pointer-events-none block h-4 w-4 rounded-full bg-background ring-0 transition-transform",n?"translate-x-4":"translate-x-0")})})}export{l as S};
1
+ import{j as r,af as i}from"./index-B2AmRqYh.js";function l({checked:n,onCheckedChange:s,disabled:o,className:e,...t}){return r.jsx("button",{type:"button",role:"switch","aria-checked":n,disabled:o,onClick:()=>s(!n),className:i("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",n?"bg-primary":"bg-input",e),...t,children:r.jsx("span",{className:i("pointer-events-none block h-4 w-4 rounded-full bg-background ring-0 transition-transform",n?"translate-x-4":"translate-x-0")})})}export{l as S};
@@ -1 +1 @@
1
- import{fi as a}from"./index-GZkujXG1.js";const n=a({orgContext:t=>({slug:t.slug??null}),queryKey:t=>["views",t.slug],tool:"manage_views",body:()=>({action:"list"}),transform:t=>(Array.isArray(t.views)?t.views:[]).flatMap(e=>!e||typeof e.key!="string"||typeof e.name!="string"?[]:[{key:e.key,name:e.name,attach:Array.isArray(e.attach)?e.attach:[],content_hash:typeof e.content_hash=="string"?e.content_hash:null}]),enabled:(t,e)=>!!t.slug&&!!e.organizationId,staleTime:1e4});export{n as u};
1
+ import{fi as a}from"./index-B2AmRqYh.js";const n=a({orgContext:t=>({slug:t.slug??null}),queryKey:t=>["views",t.slug],tool:"manage_views",body:()=>({action:"list"}),transform:t=>(Array.isArray(t.views)?t.views:[]).flatMap(e=>!e||typeof e.key!="string"||typeof e.name!="string"?[]:[{key:e.key,name:e.name,attach:Array.isArray(e.attach)?e.attach:[],content_hash:typeof e.content_hash=="string"?e.content_hash:null}]),enabled:(t,e)=>!!t.slug&&!!e.organizationId,staleTime:1e4});export{n as u};
@@ -1,4 +1,4 @@
1
- import{f5 as Qf,f6 as Xf,f7 as Zf,f8 as ed,f9 as td,r as R,aI as vt,aF as nd,j as J,fa as rd,fb as id,es as Pi,fc as sd,bG as od,fd as ld,fe as ad,bF as cd,eP as ud,bI as fd,ff as dd,fg as hd,af as Bi,dU as pd,a as md,d7 as gd,bw as yd,d9 as bd,cE as Sd,dE as xd,cz as kd,Z as Cd}from"./index-GZkujXG1.js";import{k as wd,b as Ed}from"./index-Vcq4gwWv.js";var co=Object.defineProperty,Md=(n,e)=>{let t={};for(var r in n)co(t,r,{get:n[r],enumerable:!0});return co(t,Symbol.toStringTag,{value:"Module"}),t};function ne(n){this.content=n}ne.prototype={constructor:ne,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new ne(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ne(t)},addToStart:function(n,e){return new ne([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ne(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new ne(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ne.from(n),n.size?new ne(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ne.from(n),n.size?new ne(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ne.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ne.from=function(n){if(n instanceof ne)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ne(e)};function sa(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&aa(o.charCodeAt(a-1))&&la(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=sa(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function oa(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,t--,r--;return f&&d&&f<c.length&&aa(c.charCodeAt(f-1))&&la(c.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=oa(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function la(n){return n>=56320&&n<57344}function aa(n){return n>=55296&&n<56320}let P=class ae{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new ae(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new ae(r,i)}cutByIndex(e,t){return e==t?ae.empty:e==0&&t==this.content.length?this:new ae(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ae(i,s)}addToStart(e){return new ae([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ae(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return sa(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return oa(this,e,t,r)}findIndex(e){if(e==0)return tr(0,e);if(e==this.size)return tr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?tr(t+1,s):tr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ae.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ae.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ae.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new ae(t||e,r)}static from(e){if(!e)return ae.empty;if(e instanceof ae)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ae([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};P.empty=new P([],0);const ui={index:0,offset:0};function tr(n,e){return ui.index=n,ui.offset=e,ui}function Fi(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fi(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fi(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Er=class Li{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fi(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Li.none;if(e instanceof Li)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Er.none=[];let Td=class extends Error{},I=class Wt{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ua(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Wt(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Wt(ca(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Wt.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Wt(P.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Wt(e,r,i)}};I.empty=new I(P.empty,0,0);function ca(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(ca(s.content,e-i-1,t-i-1)))}function ua(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=ua(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Nd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Od(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Dd(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function vd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Rd(n,r,e[r]);return t}function Ad(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}let Rd=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Ad(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Id=class fa{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=vd(e,i.attrs),this.excluded=null;let s=Nd(this.attrs);this.instance=s?new Er(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Er(this,Od(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new fa(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Dd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}};const da=65535,ha=Math.pow(2,16);function $d(n,e){return n+e*ha}function uo(n){return n&da}function zd(n){return(n-(n&da))/ha}const pa=1,ma=2,Sr=4,ga=8;class Vi{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ga)>0}get deletedBefore(){return(this.delInfo&(pa|Sr))>0}get deletedAfter(){return(this.delInfo&(ma|Sr))>0}get deletedAcross(){return(this.delInfo&Sr)>0}}class Se{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Se.empty)return Se.empty}recover(e){let t=0,r=uo(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+zd(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:$d(l/3,e-a),g=e==a?ma:e==f?pa:Sr;return(t<0?e!=a:e!=f)&&(g|=ga),new Vi(h,g,p)}i+=u-c}return r?e+i:new Vi(e+i,0,null)}touches(e,t){let r=0,i=uo(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Se(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Se.empty:new Se(e<0?[0,-e,0]:[0,0,e])}}Se.empty=new Se([]);class Rn{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Rn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Rn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Vi(e,i,null)}}const fi=Object.create(null);class le{getMap(){return Se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=fi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in fi)throw new RangeError("Duplicate use of step JSON ID "+e);return fi[e]=t,t.prototype.jsonID=e,t}}class U{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new U(e,null)}static fail(e){return new U(null,e)}static fromReplace(e,t,r,i){try{return U.ok(e.replace(t,r,i))}catch(s){if(s instanceof Td)return U.fail(s.message);throw s}}}function Ms(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Ms(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return P.fromArray(r)}class rt extends le{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new I(Ms(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,s)}invert(){return new De(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new rt(t.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new rt(t.from,t.to,e.markFromJSON(t.mark))}}le.jsonID("addMark",rt);class De extends le{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new I(Ms(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,r)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new De(t.pos,r.pos,this.mark)}merge(e){return e instanceof De&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new De(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new De(t.from,t.to,e.markFromJSON(t.mark))}}le.jsonID("removeMark",De);class it extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return U.fromReplace(e,this.pos,this.pos+1,new I(P.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new it(this.pos,t.marks[i]);return new it(this.pos,this.mark)}}return new At(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(t.pos,e.markFromJSON(t.mark))}}le.jsonID("addNodeMark",it);class At extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return U.fromReplace(e,this.pos,this.pos+1,new I(P.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new At(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new At(t.pos,e.markFromJSON(t.mark))}}le.jsonID("removeNodeMark",At);class K extends le{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&qi(e,this.from,this.to)?U.fail("Structure replace would overwrite content"):U.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Se([this.from,this.to-this.from,this.slice.size])}invert(e){return new K(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&K.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new K(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof K)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?I.empty:new I(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new K(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?I.empty:new I(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new K(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new K(t.from,t.to,I.fromJSON(e,t.slice),!!t.structure)}}K.MAP_BIAS=1;le.jsonID("replace",K);class Q extends le{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(qi(e,this.from,this.gapFrom)||qi(e,this.gapTo,this.to)))return U.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return U.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?U.fromReplace(e,this.from,this.to,r):U.fail("Content does not fit in gap")}getMap(){return new Se([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Q(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Q(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Q(t.from,t.to,t.gapFrom,t.gapTo,I.fromJSON(e,t.slice),t.insert,!!t.structure)}}le.jsonID("replaceAround",Q);function qi(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Pd(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(p)||(o&&o.to==d&&o.mark.eq(f[g])?o.to=h:i.push(o=new De(d,h,f[g])));l&&l.to==d?l.to=h:s.push(l=new rt(d,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Bd(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof Id){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=s):i.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new De(o.from,o.to,o.style)))}function Ts(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)o.push(new K(l,u,I.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new De(l,u,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new I(P.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new K(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(P.empty,!0);n.replace(l,l,new I(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Fd(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function cn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!Fd(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Ld(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=P.empty,f=0;for(let p=s,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,u=P.from(r.node(p).copy(u)),f++):a--;let d=P.empty,h=0;for(let p=s,g=!1;p>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,d=P.from(i.node(p).copy(d)),h++):c++;n.step(new Q(a,c,o,l,new I(u.append(d),f,h),u.size-f,!0))}function ya(n,e,t=null,r=n){let i=Vd(n,e),s=i&&qd(r,e);return s?i.map(fo).concat({type:e,attrs:t}).concat(s.map(fo)):null}function fo(n){return{type:n,attrs:null}}function Vd(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function qd(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function jd(n,e,t){let r=P.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=P.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Q(i,s,i,s,new I(r,0,0),t.length,!0))}function Wd(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&Jd(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Sa(n,o,l,s),Ts(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+o.nodeSize,1);return n.step(new Q(f,d,f+1,d-1,new I(P.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&ba(n,o,l,s),!1}})}function ba(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Sa(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
1
+ import{f5 as Qf,f6 as Xf,f7 as Zf,f8 as ed,f9 as td,r as R,aI as vt,aF as nd,j as J,fa as rd,fb as id,es as Pi,fc as sd,bG as od,fd as ld,fe as ad,bF as cd,eP as ud,bI as fd,ff as dd,fg as hd,af as Bi,dU as pd,a as md,d7 as gd,bw as yd,d9 as bd,cE as Sd,dE as xd,cz as kd,Z as Cd}from"./index-B2AmRqYh.js";import{k as wd,b as Ed}from"./index-Vcq4gwWv.js";var co=Object.defineProperty,Md=(n,e)=>{let t={};for(var r in n)co(t,r,{get:n[r],enumerable:!0});return co(t,Symbol.toStringTag,{value:"Module"}),t};function ne(n){this.content=n}ne.prototype={constructor:ne,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new ne(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ne(t)},addToStart:function(n,e){return new ne([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ne(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new ne(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ne.from(n),n.size?new ne(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ne.from(n),n.size?new ne(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ne.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ne.from=function(n){if(n instanceof ne)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ne(e)};function sa(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&aa(o.charCodeAt(a-1))&&la(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=sa(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function oa(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,t--,r--;return f&&d&&f<c.length&&aa(c.charCodeAt(f-1))&&la(c.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=oa(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function la(n){return n>=56320&&n<57344}function aa(n){return n>=55296&&n<56320}let P=class ae{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new ae(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new ae(r,i)}cutByIndex(e,t){return e==t?ae.empty:e==0&&t==this.content.length?this:new ae(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ae(i,s)}addToStart(e){return new ae([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ae(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return sa(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return oa(this,e,t,r)}findIndex(e){if(e==0)return tr(0,e);if(e==this.size)return tr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?tr(t+1,s):tr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ae.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ae.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ae.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new ae(t||e,r)}static from(e){if(!e)return ae.empty;if(e instanceof ae)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ae([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};P.empty=new P([],0);const ui={index:0,offset:0};function tr(n,e){return ui.index=n,ui.offset=e,ui}function Fi(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Fi(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Fi(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Er=class Li{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Fi(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Li.none;if(e instanceof Li)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Er.none=[];let Td=class extends Error{},I=class Wt{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ua(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Wt(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Wt(ca(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Wt.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Wt(P.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Wt(e,r,i)}};I.empty=new I(P.empty,0,0);function ca(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(ca(s.content,e-i-1,t-i-1)))}function ua(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=ua(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Nd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Od(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Dd(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function vd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Rd(n,r,e[r]);return t}function Ad(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}let Rd=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Ad(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Id=class fa{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=vd(e,i.attrs),this.excluded=null;let s=Nd(this.attrs);this.instance=s?new Er(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Er(this,Od(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new fa(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Dd(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}};const da=65535,ha=Math.pow(2,16);function $d(n,e){return n+e*ha}function uo(n){return n&da}function zd(n){return(n-(n&da))/ha}const pa=1,ma=2,Sr=4,ga=8;class Vi{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ga)>0}get deletedBefore(){return(this.delInfo&(pa|Sr))>0}get deletedAfter(){return(this.delInfo&(ma|Sr))>0}get deletedAcross(){return(this.delInfo&Sr)>0}}class Se{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Se.empty)return Se.empty}recover(e){let t=0,r=uo(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+zd(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+i+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:$d(l/3,e-a),g=e==a?ma:e==f?pa:Sr;return(t<0?e!=a:e!=f)&&(g|=ga),new Vi(h,g,p)}i+=u-c}return r?e+i:new Vi(e+i,0,null)}touches(e,t){let r=0,i=uo(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Se(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Se.empty:new Se(e<0?[0,-e,0]:[0,0,e])}}Se.empty=new Se([]);class Rn{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Rn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Rn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Vi(e,i,null)}}const fi=Object.create(null);class le{getMap(){return Se.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=fi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in fi)throw new RangeError("Duplicate use of step JSON ID "+e);return fi[e]=t,t.prototype.jsonID=e,t}}class U{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new U(e,null)}static fail(e){return new U(null,e)}static fromReplace(e,t,r,i){try{return U.ok(e.replace(t,r,i))}catch(s){if(s instanceof Td)return U.fail(s.message);throw s}}}function Ms(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Ms(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return P.fromArray(r)}class rt extends le{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new I(Ms(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,s)}invert(){return new De(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new rt(t.pos,r.pos,this.mark)}merge(e){return e instanceof rt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new rt(t.from,t.to,e.markFromJSON(t.mark))}}le.jsonID("addMark",rt);class De extends le{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new I(Ms(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return U.fromReplace(e,this.from,this.to,r)}invert(){return new rt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new De(t.pos,r.pos,this.mark)}merge(e){return e instanceof De&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new De(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new De(t.from,t.to,e.markFromJSON(t.mark))}}le.jsonID("removeMark",De);class it extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return U.fromReplace(e,this.pos,this.pos+1,new I(P.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new it(this.pos,t.marks[i]);return new it(this.pos,this.mark)}}return new At(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(t.pos,e.markFromJSON(t.mark))}}le.jsonID("addNodeMark",it);class At extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return U.fromReplace(e,this.pos,this.pos+1,new I(P.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new At(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new At(t.pos,e.markFromJSON(t.mark))}}le.jsonID("removeNodeMark",At);class K extends le{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&qi(e,this.from,this.to)?U.fail("Structure replace would overwrite content"):U.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Se([this.from,this.to-this.from,this.slice.size])}invert(e){return new K(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&K.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new K(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof K)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?I.empty:new I(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new K(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?I.empty:new I(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new K(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new K(t.from,t.to,I.fromJSON(e,t.slice),!!t.structure)}}K.MAP_BIAS=1;le.jsonID("replace",K);class Q extends le{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(qi(e,this.from,this.gapFrom)||qi(e,this.gapTo,this.to)))return U.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return U.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?U.fromReplace(e,this.from,this.to,r):U.fail("Content does not fit in gap")}getMap(){return new Se([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Q(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Q(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Q(t.from,t.to,t.gapFrom,t.gapTo,I.fromJSON(e,t.slice),t.insert,!!t.structure)}}le.jsonID("replaceAround",Q);function qi(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Pd(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(p)||(o&&o.to==d&&o.mark.eq(f[g])?o.to=h:i.push(o=new De(d,h,f[g])));l&&l.to==d?l.to=h:s.push(l=new rt(d,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Bd(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof Id){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=s):i.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>n.step(new De(o.from,o.to,o.style)))}function Ts(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)o.push(new K(l,u,I.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new De(l,u,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new I(P.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new K(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(P.empty,!0);n.replace(l,l,new I(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Fd(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function cn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+i,a=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!Fd(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Ld(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=P.empty,f=0;for(let p=s,g=!1;p>t;p--)g||r.index(p)>0?(g=!0,u=P.from(r.node(p).copy(u)),f++):a--;let d=P.empty,h=0;for(let p=s,g=!1;p>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,d=P.from(i.node(p).copy(d)),h++):c++;n.step(new Q(a,c,o,l,new I(u.append(d),f,h),u.size-f,!0))}function ya(n,e,t=null,r=n){let i=Vd(n,e),s=i&&qd(r,e);return s?i.map(fo).concat({type:e,attrs:t}).concat(s.map(fo)):null}function fo(n){return{type:n,attrs:null}}function Vd(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function qd(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function jd(n,e,t){let r=P.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=P.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Q(i,s,i,s,new I(r,0,0),t.length,!0))}function Wd(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,a)&&Jd(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Sa(n,o,l,s),Ts(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+o.nodeSize,1);return n.step(new Q(f,d,f+1,d-1,new I(P.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&ba(n,o,l,s),!1}})}function ba(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Sa(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
2
2
  `))}})}function Jd(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Kd(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Q(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new I(P.from(o),0,0),1,!0))}function Ue(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>s;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!g.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function Hd(n,e,t=1,r){let i=n.doc.resolve(e),s=P.empty,o=P.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=P.from(i.node(l).copy(s));let u=r&&r[c];o=P.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}n.step(new K(e,e,new I(s.append(o),t,t),!0))}function zt(n,e){let t=n.resolve(e),r=t.index();return xa(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Ud(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function xa(n,e){return!!(n&&e&&!n.isLeaf&&Ud(n,e))}function _r(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&xa(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function _d(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let u=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Sa(n,u.node(),u.before(),l)}o.inlineContent&&Ts(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new K(c,a.map(e+t,-1),I.empty,!0)),r===!0){let u=n.doc.resolve(c);ba(n,u.node(),u.before(),n.steps.length)}return n}function Gd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Ns(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(s==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Gr(n,e,t=e,r=I.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return ka(i,s,r)?new K(e,t,r):new Yd(i,s,r).fit()}function ka(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Yd{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=P.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=P.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new I(s,o,l);return e>-1?new Q(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new K(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=di(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(o?c.matchType(o.type)||(f=c.fillBefore(P.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=di(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new I(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=di(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new I(mn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new I(mn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));f=f.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),m=f.matchType(g.type);if(!m)break;c++,(c>1||a==0||g.content.size)&&(f=m,u.push(Ca(g.mark(d.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=gn(this.placed,t,P.from(u)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g<h;g++){let y=m.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),m=y.content}this.unplaced=p?e==0?I.empty:new I(mn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new I(mn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!hi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=hi(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=hi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=gn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=gn(this.placed,this.depth,P.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(P.empty,!0);t.childCount&&(this.placed=gn(this.placed,this.frontier.length,t))}}function mn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(mn(n.firstChild.content,e-1,t)))}function gn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(gn(n.lastChild.content,e-1,t)))}function di(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ca(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Ca(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(P.empty,!0)))),n.copy(r)}function hi(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Qd(t,s.content,o)?l:null}function Qd(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Xd(n){return n.spec.defining||n.spec.definingForContent}function Zd(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(ka(i,s,r))return n.step(new K(e,t,r));let o=Ea(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?l=d:i.before(d)==h&&o.splice(1,0,-d)}let a=o.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=Xd(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let m=o[(g+a)%o.length],y=!0;m<0&&(y=!1,m=-m);let S=i.node(m-1),x=i.index(m-1);if(S.canReplaceWith(x,x,p.type,p.marks))return n.replace(i.before(m),y?s.after(m):t,new I(wa(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=o.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=o[d];h<0||(e=i.before(h),t=s.after(h))}}function wa(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(wa(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(P.empty,!0))}return n}function eh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Gd(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new I(P.from(r),0,0))}function th(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(t),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let s=Ea(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Ea(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Zt extends le{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return U.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return U.fromReplace(e,this.pos,this.pos+1,new I(P.from(i),0,t.isLeaf?0:1))}getMap(){return Se.empty}invert(e){return new Zt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Zt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Zt(t.pos,t.attr,t.value)}}le.jsonID("attr",Zt);class In extends le{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return U.ok(r)}getMap(){return Se.empty}invert(e){return new In(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new In(t.attr,t.value)}}le.jsonID("docAttr",In);let tn=class extends Error{};tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};tn.prototype=Object.create(Error.prototype);tn.prototype.constructor=tn;tn.prototype.name="TransformError";class Ma{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Rn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=I.empty){let i=Gr(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new I(P.from(r),0,0))}delete(e,t){return this.replace(e,t,I.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Zd(this,e,t,r),this}replaceRangeWith(e,t,r){return eh(this,e,t,r),this}deleteRange(e,t){return th(this,e,t),this}lift(e,t){return Ld(this,e,t),this}join(e,t=1){return _d(this,e,t),this}wrap(e,t){return jd(this,e,t),this}setBlockType(e,t=e,r,i=null){return Wd(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Kd(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Zt(e,t,r)),this}setDocAttribute(e,t){return this.step(new In(e,t)),this}addNodeMark(e,t){return this.step(new it(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Er)t.isInSet(r.marks)&&this.step(new At(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new At(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,r){return Hd(this,e,t,r),this}addMark(e,t,r){return Pd(this,e,t,r),this}removeMark(e,t,r){return Bd(this,e,t,r),this}clearIncompatible(e,t,r){return Ts(this,e,t,r),this}}function Ta(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&Da(o.charCodeAt(a-1))&&Oa(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=Ta(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Na(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,t--,r--;return f&&d&&f<c.length&&Da(c.charCodeAt(f-1))&&Oa(c.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=Na(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Oa(n){return n>=56320&&n<57344}function Da(n){return n>=55296&&n<56320}let je=class ce{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new ce(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new ce(r,i)}cutByIndex(e,t){return e==t?ce.empty:e==0&&t==this.content.length?this:new ce(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ce(i,s)}addToStart(e){return new ce([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ce(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Ta(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Na(this,e,t,r)}findIndex(e){if(e==0)return nr(0,e);if(e==this.size)return nr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?nr(t+1,s):nr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ce.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ce.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ce.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new ce(t||e,r)}static from(e){if(!e)return ce.empty;if(e instanceof ce)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ce([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};je.empty=new je([],0);const pi={index:0,offset:0};function nr(n,e){return pi.index=n,pi.offset=e,pi}let Rt=class Jt{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Aa(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Jt(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Jt(va(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Jt.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Jt(je.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Jt(e,r,i)}};Rt.empty=new Rt(je.empty,0,0);function va(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(va(s.content,e-i-1,t-i-1)))}function Aa(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Aa(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Ra(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&za(o.charCodeAt(a-1))&&$a(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=Ra(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Ia(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,t--,r--;return f&&d&&f<c.length&&za(c.charCodeAt(f-1))&&$a(c.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=Ia(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function $a(n){return n>=56320&&n<57344}function za(n){return n>=55296&&n<56320}let ve=class ue{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new ue(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new ue(r,i)}cutByIndex(e,t){return e==t?ue.empty:e==0&&t==this.content.length?this:new ue(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new ue(i,s)}addToStart(e){return new ue([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ue(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Ra(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ia(this,e,t,r)}findIndex(e){if(e==0)return rr(0,e);if(e==this.size)return rr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?rr(t+1,s):rr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return ue.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return ue.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ue.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new ue(t||e,r)}static from(e){if(!e)return ue.empty;if(e instanceof ue)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ue([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};ve.empty=new ve([],0);const mi={index:0,offset:0};function rr(n,e){return mi.index=n,mi.offset=e,mi}function Mr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Mr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Mr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let We=class ji{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Mr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ji.none;if(e instanceof ji)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};We.none=[];let Tr=class extends Error{},Re=class Kt{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ba(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Kt(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Kt(Pa(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Kt.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Kt(ve.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Kt(e,r,i)}};Re.empty=new Re(ve.empty,0,0);function Pa(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Pa(s.content,e-i-1,t-i-1)))}function Ba(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Ba(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function nh(n,e,t){if(t.openStart>n.depth)throw new Tr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Tr("Inconsistent open depths");return Fa(n,e,t,0)}function Fa(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Fa(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return kt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=rh(t,n);return kt(s,Va(n,o,l,e,r))}else return kt(s,Nr(n,e,r))}function La(n,e){if(!e.type.compatibleContent(n.type))throw new Tr("Cannot join "+e.type.name+" onto "+n.type.name)}function Wi(n,e,t){let r=n.node(t);return La(r,e.node(t)),r}function xt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function xn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(xt(n.nodeAfter,r),s++));for(let l=s;l<o;l++)xt(i.child(l),r);e&&e.depth==t&&e.textOffset&&xt(e.nodeBefore,r)}function kt(n,e){if(!n.type.validContent(e))throw new Tr("Invalid content for node "+n.type.name);return n.copy(e)}function Va(n,e,t,r,i){let s=n.depth>i&&Wi(n,e,i+1),o=r.depth>i&&Wi(t,r,i+1),l=[];return xn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(La(s,o),xt(kt(s,Va(n,e,t,r,i+1)),l)):(s&&xt(kt(s,Nr(n,e,i+1)),l),xn(e,t,i,l),o&&xt(kt(o,Nr(t,r,i+1)),l)),xn(r,null,i,l),new ve(l)}function Nr(n,e,t){let r=[];if(xn(null,n,t,r),n.depth>t){let i=Wi(n,e,t+1);xt(kt(i,Nr(n,e,t+1)),r)}return xn(e,null,t,r),new ve(r)}function rh(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(ve.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}let ho=class Ji{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return We.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new oh(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Ji(t,r,s)}static resolveCached(e,t){let r=po.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else po.set(e,r=new ih);let i=r.elts[r.i]=Ji.resolve(e,t);return r.i=(r.i+1)%sh,i}},ih=class{constructor(){this.elts=[],this.i=0}};const sh=12,po=new WeakMap;let oh=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}};const lh=Object.create(null);let qa=class Ki{constructor(e,t,r,i=We.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||ve.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,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,t,r,i){return this.content.textBetween(e,t,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,t,r){return this.type==e&&Mr(this.attrs,t||e.defaultAttrs||lh)&&We.sameSet(this.marks,r||We.none)}copy(e=null){return e==this.content?this:new Ki(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ki(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return Re.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new Re(c,i.depth-o,s.depth-o)}replace(e,t,r){return nh(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return ho.resolveCached(this,e)}resolveNoCache(e){return ho.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),ah(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=ve.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.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=We.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!We.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=ve.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};qa.prototype.text=void 0;function ah(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}const gi=Object.create(null);class D{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ch(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Re.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?Re.empty:t),l==0&&yo(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),yo(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new M(e):Ht(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?Ht(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Ht(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ye(e.node(0))}static atStart(e){return Ht(e,e,0,0,1)||new ye(e)}static atEnd(e){return Ht(e,e,e.content.size,e.childCount,-1)||new ye(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=gi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in gi)throw new RangeError("Duplicate use of selection JSON ID "+e);return gi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return M.between(this.$anchor,this.$head).getBookmark()}}D.prototype.visible=!0;class ch{constructor(e,t){this.$from=e,this.$to=t}}let mo=!1;function go(n){!mo&&!n.parent.inlineContent&&(mo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class M extends D{constructor(e,t=e){go(e),go(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return D.near(r);let i=e.resolve(t.map(this.anchor));return new M(i.parent.inlineContent?i:r,r)}replace(e,t=Re.empty){if(super.replace(e,t),t==Re.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof M&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Yr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new M(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=D.findFrom(t,r,!0)||D.findFrom(t,-r,!0);if(s)t=s.$head;else return D.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(D.findFrom(e,-r,!0)||D.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new M(e,t)}}D.jsonID("text",M);class Yr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Yr(e.map(this.anchor),e.map(this.head))}resolve(e){return M.between(e.resolve(this.anchor),e.resolve(this.head))}}class k extends D{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?D.near(s):new k(s)}content(){return new Re(ve.from(this.node),0,0)}eq(e){return e instanceof k&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Os(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new k(e.resolve(t.anchor))}static create(e,t){return new k(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}k.prototype.visible=!1;D.jsonID("node",k);class Os{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Yr(r,r):new Os(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&k.isSelectable(r)?new k(t):D.near(t)}}class ye extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Re.empty){if(t==Re.empty){e.delete(0,e.doc.content.size);let r=D.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ye(e)}map(e){return new ye(e)}eq(e){return e instanceof ye}getBookmark(){return uh}}D.jsonID("all",ye);const uh={map(){return this},resolve(n){return new ye(n)}};function Ht(n,e,t,r,i,s=!1){if(e.inlineContent)return M.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&k.isSelectable(l))return k.create(n,t-(i<0?l.nodeSize:0))}else{let a=Ht(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function yo(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof K||i instanceof Q))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(D.near(n.doc.resolve(o),t))}const bo=1,ir=2,So=4;class fh extends Ma{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|bo)&~ir,this.storedMarks=null,this}get selectionSet(){return(this.updated&bo)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ir,this}ensureMarks(e){return We.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ir)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ir,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||We.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(D.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=So,this}get scrolledIntoView(){return(this.updated&So)>0}}function xo(n,e){return!e||!n?n:n.bind(e)}class yn{constructor(e,t,r){this.name=e,this.init=xo(t.init,r),this.apply=xo(t.apply,r)}}const dh=[new yn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new yn("selection",{init(n,e){return n.selection||D.atStart(e.doc)},apply(n){return n.selection}}),new yn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new yn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class yi{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new yn(r.key,r.spec.state,r))})}}class mt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new mt(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new fh(this)}static create(e){let t=new yi(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new mt(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new yi(this.schema,e.plugins),r=t.fields,i=new mt(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new yi(e.schema,e.plugins),s=new mt(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=qa.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=D.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ja(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ja(i,e,{})),t[r]=i}return t}class H{constructor(e){this.spec=e,this.props={},e.props&&ja(e.props,this,this.props),this.key=e.key?e.key.key:Wa("plugin")}getState(e){return e[this.key]}}const bi=Object.create(null);function Wa(n){return n in bi?n+"$"+ ++bi[n]:(bi[n]=0,n+"$")}class ee{constructor(e="key"){this.key=Wa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ja=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ka(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ha=(n,e,t)=>{let r=Ka(n,t);if(!r)return!1;let i=Ds(r);if(!i){let o=r.blockRange(),l=o&&cn(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(tc(n,i,e,-1))return!0;if(r.parent.content.size==0&&(nn(s,"end")||k.isSelectable(s)))for(let o=r.depth;;o--){let l=Gr(n.doc,r.before(o),r.after(o),Rt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(nn(s,"end")?D.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):k.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},hh=(n,e,t)=>{let r=Ka(n,t);if(!r)return!1;let i=Ds(r);return i?Ua(n,i,e):!1},ph=(n,e,t)=>{let r=Ga(n,t);if(!r)return!1;let i=vs(r);return i?Ua(n,i,e):!1};function Ua(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Gr(n.doc,s,a,Rt.empty);if(!c||c.from!=s||c instanceof K&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(M.create(u.doc,s)),t(u.scrollIntoView())}return!0}function nn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const _a=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Ds(r)}let o=s&&s.nodeBefore;return!o||!k.isSelectable(o)?!1:(e&&e(n.tr.setSelection(k.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Ds(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ga(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Ya=(n,e,t)=>{let r=Ga(n,t);if(!r)return!1;let i=vs(r);if(!i)return!1;let s=i.nodeAfter;if(tc(n,i,e,1))return!0;if(r.parent.content.size==0&&(nn(s,"start")||k.isSelectable(s))){let o=Gr(n.doc,r.before(),r.after(),Rt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(nn(s,"start")?D.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):k.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Qa=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=vs(r)}let o=s&&s.nodeAfter;return!o||!k.isSelectable(o)?!1:(e&&e(n.tr.setSelection(k.create(n.doc,s.pos)).scrollIntoView()),!0)};function vs(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const mh=(n,e)=>{let t=n.selection,r=t instanceof k,i;if(r){if(t.node.isTextblock||!zt(n.doc,t.from))return!1;i=t.from}else if(i=_r(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(k.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},gh=(n,e)=>{let t=n.selection,r;if(t instanceof k){if(t.node.isTextblock||!zt(n.doc,t.to))return!1;r=t.to}else if(r=_r(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},yh=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&cn(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Xa=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
3
3
  `).scrollIntoView()),!0)};function As(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const bh=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=As(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Za=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof ye||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=As(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=n.tr.insert(o,s.createAndFill());l.setSelection(M.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},ec=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ue(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&cn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function Sh(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof k&&e.selection.node.isBlock)return!r.parentOffset||!Ue(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=As(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof M||e.selection instanceof ye)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Ue(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Ue(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(o).type!=l){let h=u.mapping.map(r.before(o)),p=u.doc.resolve(h);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return t&&t(u.scrollIntoView()),!0}}const xh=Sh(),kh=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(k.create(n.doc,i))),!0)};function Ch(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function tc(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Ch(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=je.empty;for(let y=o.length-1;y>=0;y--)p=je.from(o[y].create(null,p));p=je.from(i.copy(p));let g=n.tr.step(new Q(e.pos-1,h,e.pos,h,new Rt(p,1,0),o.length,!0)),m=g.doc.resolve(h+2*o.length);m.nodeAfter&&m.nodeAfter.type==i.type&&zt(g.doc,m.pos)&&g.join(m.pos),t(g.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:D.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&cn(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&nn(s,"start",!0)&&nn(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let g=s,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(h.canReplace(h.childCount,h.childCount,g.content)){if(t){let y=je.empty;for(let x=p.length-1;x>=0;x--)y=je.from(p[x].copy(y));let S=n.tr.step(new Q(e.pos-p.length,e.pos+s.nodeSize,e.pos+m,e.pos+s.nodeSize-m,new Rt(y,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function nc(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(M.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const wh=nc(-1),Eh=nc(1);function Mh(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&ya(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function ko(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Rs(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}Rs(Ja,Ha,_a);Rs(Ja,Ya,Qa);Rs(Xa,Za,ec,xh);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function rc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,a=0;for(;o[a]==l[a];a++)t++;return a&&a<o.length&&a<l.length&&oc(o.charCodeAt(a-1))&&sc(o.charCodeAt(a))&&t--,t}if(i.content.size||s.content.size){let o=rc(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function ic(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=o.text,u=l.text,f=c.length,d=u.length;for(;f>0&&d>0&&c[f-1]==u[d-1];)f--,d--,t--,r--;return f&&d&&f<c.length&&oc(c.charCodeAt(f-1))&&sc(c.charCodeAt(f))&&(t++,r++),{a:t,b:r}}if(o.content.size||l.content.size){let c=ic(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function sc(n){return n>=56320&&n<57344}function oc(n){return n>=55296&&n<56320}let $=class fe{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new fe(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new fe(r,i)}cutByIndex(e,t){return e==t?fe.empty:e==0&&t==this.content.length?this:new fe(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new fe(i,s)}addToStart(e){return new fe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new fe(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return rc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return ic(this,e,t,r)}findIndex(e){if(e==0)return sr(0,e);if(e==this.size)return sr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?sr(t+1,s):sr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return fe.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return fe.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return fe.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new fe(t||e,r)}static from(e){if(!e)return fe.empty;if(e instanceof fe)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new fe([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};$.empty=new $([],0);const Si={index:0,offset:0};function sr(n,e){return Si.index=n,Si.offset=e,Si}function Or(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Or(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Or(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let V=class Hi{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Or(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Hi.none;if(e instanceof Hi)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};V.none=[];class Dr extends Error{}let xe=class Ut{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ac(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new Ut(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Ut(lc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Ut.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ut($.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Ut(e,r,i)}};xe.empty=new xe($.empty,0,0);function lc(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(lc(s.content,e-i-1,t-i-1)))}function ac(n,e,t,r,i,s){let{index:o,offset:l}=n.findIndex(e),a=n.maybeChild(o);if(l==e||a.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=ac(a.content,e-l-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,a);return c&&n.replaceChild(o,a.copy(c))}function Th(n,e,t){if(t.openStart>n.depth)throw new Dr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Dr("Inconsistent open depths");return cc(n,e,t,0)}function cc(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=cc(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return wt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Nh(t,n);return wt(s,fc(n,o,l,e,r))}else return wt(s,vr(n,e,r))}function uc(n,e){if(!e.type.compatibleContent(n.type))throw new Dr("Cannot join "+e.type.name+" onto "+n.type.name)}function Ui(n,e,t){let r=n.node(t);return uc(r,e.node(t)),r}function Ct(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function kn(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Ct(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Ct(i.child(l),r);e&&e.depth==t&&e.textOffset&&Ct(e.nodeBefore,r)}function wt(n,e){if(!n.type.validContent(e))throw new Dr("Invalid content for node "+n.type.name);return n.copy(e)}function fc(n,e,t,r,i){let s=n.depth>i&&Ui(n,e,i+1),o=r.depth>i&&Ui(t,r,i+1),l=[];return kn(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(uc(s,o),Ct(wt(s,fc(n,e,t,r,i+1)),l)):(s&&Ct(wt(s,vr(n,e,i+1)),l),kn(e,t,i,l),o&&Ct(wt(o,vr(t,r,i+1)),l)),kn(r,null,i,l),new $(l)}function vr(n,e,t){let r=[];if(kn(null,n,t,r),n.depth>t){let i=Ui(n,e,t+1);Ct(wt(i,vr(n,e,t+1)),r)}return kn(e,null,t,r),new $(r)}function Nh(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy($.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class $n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return V.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new vh(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new $n(t,r,s)}static resolveCached(e,t){let r=Co.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else Co.set(e,r=new Oh);let i=r.elts[r.i]=$n.resolve(e,t);return r.i=(r.i+1)%Dh,i}}class Oh{constructor(){this.elts=[],this.i=0}}const Dh=12,Co=new WeakMap;let vh=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}};const Ah=Object.create(null);let Et=class _i{constructor(e,t,r,i=V.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||$.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,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,t,r,i){return this.content.textBetween(e,t,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,t,r){return this.type==e&&Or(this.attrs,t||e.defaultAttrs||Ah)&&V.sameSet(this.marks,r||V.none)}copy(e=null){return e==this.content?this:new _i(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _i(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return xe.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new xe(c,i.depth-o,s.depth-o)}replace(e,t,r){return Th(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return $n.resolveCached(this,e)}resolveNoCache(e){return $n.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.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()+")"),dc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=$.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.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=V.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!V.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=$.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Et.prototype.text=void 0;class Ar extends Et{constructor(e,t,r,i){if(super(e,t,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):dc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Ar(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ar(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function dc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class It{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Rh(e,t);if(r.next==null)return It.empty;let i=hc(r);r.next&&r.err("Unexpected trailing text");let s=Lh(Fh(i));return Vh(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return $.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:f}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
4
4
  `)}}It.empty=new It(!0);class Rh{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function hc(n){let e=[];do e.push(Ih(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ih(n){let e=[];do e.push($h(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function $h(n){let e=Bh(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=zh(n,e);else break;return e}function wo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function zh(n,e){let t=wo(n),r=t;return n.eat(",")&&(n.next!="}"?r=wo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Ph(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function Bh(n){if(n.eat("(")){let e=hc(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Ph(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Fh(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),i(s(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function pc(n,e){return e-n}function Eo(n,e){let t=[];return r(e),t.sort(pc);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function Lh(n){let e=Object.create(null);return t(Eo(n,0));function t(r){let i=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Eo(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new It(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(pc);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function Vh(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function mc(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function gc(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function yc(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function bc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new jh(n,r,e[r]);return t}let Mo=class Sc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=bc(e,r.attrs),this.defaultAttrs=mc(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==It.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:gc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Et(this,this.computeAttrs(e),$.from(t),V.setFrom(r))}createChecked(e=null,t,r){return t=$.from(t),this.checkContent(t),new Et(this,this.computeAttrs(e),t,V.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=$.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore($.empty,!0);return s?new Et(this,e,t.append(s),V.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){yc(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:V.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Sc(s,t,o));let i=t.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 s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function qh(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class jh{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?qh(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Is{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=bc(e,i.attrs),this.excluded=null;let s=mc(this.attrs);this.instance=s?new V(this,s):null}create(e=null){return!e&&this.instance?this.instance:new V(this,gc(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Is(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){yc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class xc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=ne.from(e.nodes),t.marks=ne.from(e.marks||{}),this.nodes=Mo.compile(this.spec.nodes,this),this.marks=Is.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 s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=It.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?To(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:To(this,o.split(" "))}this.nodeFromJSON=i=>Et.fromJSON(this,i),this.markFromJSON=i=>V.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Mo){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Ar(r,r.defaultAttrs,e,V.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function To(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Wh(n){return n.tag!=null}function Jh(n){return n.style!=null}let Cn=class Gi{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(Wh(i))this.tags.push(i);else if(Jh(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Oo(this,t,!1);return r.addAll(e,V.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Oo(this,t,!0);return r.addAll(e,V.none,t.from,t.to),xe.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Uh(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Do(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Do(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Gi(e,Gi.schemaRules(e)))}};const kc={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},Kh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Cc={ol:!0,ul:!0},zn=1,Yi=2,wn=4;function No(n,e,t){return e!=null?(e?zn:0)|(e==="full"?Yi:0):n&&n.whitespace=="pre"?zn|Yi:t&~wn}let or=class{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=V.none,this.match=s||(o&wn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&zn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=$.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!kc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Oo=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=No(null,t.preserveWhitespace,0)|(r?wn:0);i?s=new or(i.type,i.attrs,V.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new or(null,null,V.none,!0,null,o):s=new or(e.schema.topNodeType,null,V.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&Yi?"full":this.localPreserveWS||(i.options&zn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
@@ -1 +1 @@
1
- import{r as s,cV as ce,cR as ue,j as d,aB as N,eZ as le,e_ as de,e$ as fe,cS as k,aE as pe,f0 as z,f1 as me,af as P,aj as L,ac as I,f2 as be}from"./index-GZkujXG1.js";import{D as ve,E as he}from"./app-bridge-BH3g2mKG.js";var S="Tabs",[ye]=pe(S,[z]),B=z(),[ge,V]=ye(S),J=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:o,orientation:i="horizontal",dir:u,activationMode:g="automatic",...h}=e,l=ce(u),[c,m]=ue({prop:r,onChange:a,defaultProp:o??"",caller:S});return d.jsx(ge,{scope:n,baseId:le(),value:c,onValueChange:m,orientation:i,dir:l,activationMode:g,children:d.jsx(N.div,{dir:l,"data-orientation":i,...h,ref:t})})});J.displayName=S;var W="TabsList",H=s.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,o=V(W,n),i=B(n);return d.jsx(de,{asChild:!0,...i,orientation:o.orientation,dir:o.dir,loop:r,children:d.jsx(N.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});H.displayName=W;var X="TabsTrigger",Z=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...o}=e,i=V(X,n),u=B(n),g=K(i.baseId,r),h=ee(i.baseId,r),l=r===i.value;return d.jsx(fe,{asChild:!0,...u,focusable:!a,active:l,children:d.jsx(N.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":h,"data-state":l?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:g,...o,ref:t,onMouseDown:k(e.onMouseDown,c=>{!a&&c.button===0&&c.ctrlKey===!1?i.onValueChange(r):c.preventDefault()}),onKeyDown:k(e.onKeyDown,c=>{[" ","Enter"].includes(c.key)&&i.onValueChange(r)}),onFocus:k(e.onFocus,()=>{const c=i.activationMode!=="manual";!l&&!a&&c&&i.onValueChange(r)})})})});Z.displayName=X;var Q="TabsContent",Y=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:o,...i}=e,u=V(Q,n),g=K(u.baseId,r),h=ee(u.baseId,r),l=r===u.value,c=s.useRef(l);return s.useEffect(()=>{const m=requestAnimationFrame(()=>c.current=!1);return()=>cancelAnimationFrame(m)},[]),d.jsx(me,{present:a||l,children:({present:m})=>d.jsx(N.div,{"data-state":l?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":g,hidden:!m,id:h,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:c.current?"0s":void 0},children:m&&o})})});Y.displayName=Q;function K(e,t){return`${e}-trigger-${t}`}function ee(e,t){return`${e}-content-${t}`}var xe=J,te=H,ne=Z,re=Y;const Ne=xe,we=s.forwardRef(({className:e,...t},n)=>d.jsx(te,{ref:n,className:P("inline-flex h-9 items-center justify-start gap-1 border-b border-border bg-transparent p-0",e),...t}));we.displayName=te.displayName;const Te=s.forwardRef(({className:e,...t},n)=>d.jsx(ne,{ref:n,className:P("inline-flex items-center justify-center whitespace-nowrap px-3 pb-2 pt-1 text-sm font-medium text-muted-foreground transition-all","border-b-2 border-transparent","hover:text-foreground","data-[state=active]:border-foreground data-[state=active]:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",e),...t}));Te.displayName=ne.displayName;const Re=s.forwardRef(({className:e,...t},n)=>d.jsx(re,{ref:n,className:P("mt-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",e),...t}));Re.displayName=re.displayName;const Ee=new Set(["query_sql","query_sdk"]),O=new Map;function Ce(e){const t=O.get(e);if(t)return t;const n=L(`${I}/api/${e}/tools`,{method:"GET",credentials:"include",timeoutMs:15e3}).then(async r=>{if(!r.ok)throw new Error(`tool list failed: ${r.status}`);const a=await r.json();return new Set((a.tools??[]).flatMap(o=>typeof o.name=="string"&&o.annotations?.readOnlyHint===!0?[o.name]:[]))});return O.set(e,n),n.catch(()=>O.delete(e)),n}async function $e(e,t,n,r){if(n!=="invoke_view_action")return!Ee.has(n)&&!(await Ce(e)).has(n)?{error:`Views can only call read tools and their declared actions; "${n}" is neither`}:{url:`${I}/api/${e}/${encodeURIComponent(n)}`,body:r??{}};const{view:a,action:o,value:i,interaction_id:u}=r??{};return a!==t?{error:`This frame hosts "${t}", not "${String(a)}"`}:typeof o!="string"||!o?{error:"action is required"}:{url:`${I}/api/${e}/views/${encodeURIComponent(t)}/actions/${encodeURIComponent(o)}`,body:{value:i??null,interaction_id:u}}}const Se=({orgSlug:e,viewKey:t,scope:n,params:r,onParamsChange:a,contentHash:o,title:i,minHeight:u=96,className:g})=>{const h=s.useRef(null),l=s.useRef(null),[c,m]=s.useState(null),[$,_]=s.useState(null),[oe,se]=s.useState(u),j=s.useRef(null),T=s.useRef(null),D=s.useRef(u);D.current=u;const x=s.useRef({scope:n,params:r,onParamsChange:a});x.current={scope:n,params:r,onParamsChange:a};const R=be(e,t);s.useEffect(()=>{let y=!1;return R!==T.current&&(m(null),T.current=null,j.current=null),_(null),o!=null&&o===j.current&&R===T.current?()=>{y=!0}:(L(`${I}/api/${e}/views/${encodeURIComponent(t)}/shell`,{credentials:"include"}).then(async f=>{if(!f.ok)throw new Error(`shell ${f.status}`);const M=await f.text();if(y)return;const b=f.headers.get("X-Lobu-View-Hash");b!==null&&b===j.current&&R===T.current||(j.current=b,T.current=R,_(null),m(M))}).catch(f=>{y||_(f instanceof Error?f.message:String(f))}),()=>{y=!0})},[R,e,t,o]);const ae=JSON.stringify(r),ie=JSON.stringify(n);return s.useEffect(()=>{l.current?.sendToolInput({arguments:{scope:x.current.scope,params:x.current.params}})},[ie,ae]),s.useEffect(()=>{if(!c||$)return;const y=h.current;if(!y?.contentWindow)return;const f=e,M=t;let b=!1;const F=()=>document.documentElement.classList.contains("dark")?"dark":"light",v=new ve(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{},updateModelContext:{structuredContent:{}}},{hostContext:{theme:F(),displayMode:"inline",platform:"web"}});v.addEventListener("sizechange",({height:p})=>{typeof p=="number"&&se(Math.max(D.current,Math.ceil(p)))}),v.oncalltool=async({name:p,arguments:w})=>{if(b)return{content:[{type:"text",text:"view unmounted"}],isError:!0};let E;try{E=await $e(f,M,p,w)}catch(U){return{content:[{type:"text",text:String(U)}],isError:!0}}if(b)return{content:[{type:"text",text:"view unmounted"}],isError:!0};if("error"in E)return{content:[{type:"text",text:E.error}],isError:!0};const A=await L(E.url,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(E.body),timeoutMs:3e4}),C=await A.json().catch(()=>null);return A.ok?{content:[{type:"text",text:JSON.stringify(C)}],structuredContent:C??{}}:{content:[{type:"text",text:C&&typeof C.error=="string"&&C.error||`API error: ${A.status}`}],isError:!0}},v.onupdatemodelcontext=async({structuredContent:p})=>{if(b)return{};const w=p?.params;return w&&typeof w=="object"&&!Array.isArray(w)&&x.current.onParamsChange(w),{}},v.onopenlink=async({url:p})=>b?{}:(window.open(p,"_blank","noopener,noreferrer"),{}),v.addEventListener("initialized",()=>{v.sendToolInput({arguments:{scope:x.current.scope,params:x.current.params}})});const q=new he(y.contentWindow,y.contentWindow);v.connect(q).catch(p=>{console.error("[view-frame] failed to initialize",p)}),l.current=v;const G=new MutationObserver(()=>{v.setHostContext({theme:F(),displayMode:"inline",platform:"web"})});return G.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{b=!0,G.disconnect(),l.current=null,q.close()}},[c,$,e,t]),$?d.jsxs("div",{"data-testid":"view-frame-error",className:"text-sm text-destructive",children:["View failed to load: ",$]}):d.jsx("div",{className:g,"data-testid":"view-frame","data-view":t,children:c?d.jsx("iframe",{ref:h,title:i??t,srcDoc:c,sandbox:"allow-scripts",style:{width:"100%",height:oe,border:"none",display:"block"}}):d.jsx("div",{className:"animate-pulse rounded-md bg-muted/40",style:{height:u}})})};export{Ne as T,Se as V,we as a,Te as b,Re as c};
1
+ import{r as s,cV as ce,cR as ue,j as d,aB as N,eZ as le,e_ as de,e$ as fe,cS as k,aE as pe,f0 as z,f1 as me,af as P,aj as L,ac as I,f2 as be}from"./index-B2AmRqYh.js";import{D as ve,E as he}from"./app-bridge-BH3g2mKG.js";var S="Tabs",[ye]=pe(S,[z]),B=z(),[ge,V]=ye(S),J=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:o,orientation:i="horizontal",dir:u,activationMode:g="automatic",...h}=e,l=ce(u),[c,m]=ue({prop:r,onChange:a,defaultProp:o??"",caller:S});return d.jsx(ge,{scope:n,baseId:le(),value:c,onValueChange:m,orientation:i,dir:l,activationMode:g,children:d.jsx(N.div,{dir:l,"data-orientation":i,...h,ref:t})})});J.displayName=S;var W="TabsList",H=s.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,o=V(W,n),i=B(n);return d.jsx(de,{asChild:!0,...i,orientation:o.orientation,dir:o.dir,loop:r,children:d.jsx(N.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});H.displayName=W;var X="TabsTrigger",Z=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...o}=e,i=V(X,n),u=B(n),g=K(i.baseId,r),h=ee(i.baseId,r),l=r===i.value;return d.jsx(fe,{asChild:!0,...u,focusable:!a,active:l,children:d.jsx(N.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":h,"data-state":l?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:g,...o,ref:t,onMouseDown:k(e.onMouseDown,c=>{!a&&c.button===0&&c.ctrlKey===!1?i.onValueChange(r):c.preventDefault()}),onKeyDown:k(e.onKeyDown,c=>{[" ","Enter"].includes(c.key)&&i.onValueChange(r)}),onFocus:k(e.onFocus,()=>{const c=i.activationMode!=="manual";!l&&!a&&c&&i.onValueChange(r)})})})});Z.displayName=X;var Q="TabsContent",Y=s.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:o,...i}=e,u=V(Q,n),g=K(u.baseId,r),h=ee(u.baseId,r),l=r===u.value,c=s.useRef(l);return s.useEffect(()=>{const m=requestAnimationFrame(()=>c.current=!1);return()=>cancelAnimationFrame(m)},[]),d.jsx(me,{present:a||l,children:({present:m})=>d.jsx(N.div,{"data-state":l?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":g,hidden:!m,id:h,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:c.current?"0s":void 0},children:m&&o})})});Y.displayName=Q;function K(e,t){return`${e}-trigger-${t}`}function ee(e,t){return`${e}-content-${t}`}var xe=J,te=H,ne=Z,re=Y;const Ne=xe,we=s.forwardRef(({className:e,...t},n)=>d.jsx(te,{ref:n,className:P("inline-flex h-9 items-center justify-start gap-1 border-b border-border bg-transparent p-0",e),...t}));we.displayName=te.displayName;const Te=s.forwardRef(({className:e,...t},n)=>d.jsx(ne,{ref:n,className:P("inline-flex items-center justify-center whitespace-nowrap px-3 pb-2 pt-1 text-sm font-medium text-muted-foreground transition-all","border-b-2 border-transparent","hover:text-foreground","data-[state=active]:border-foreground data-[state=active]:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",e),...t}));Te.displayName=ne.displayName;const Re=s.forwardRef(({className:e,...t},n)=>d.jsx(re,{ref:n,className:P("mt-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",e),...t}));Re.displayName=re.displayName;const Ee=new Set(["query_sql","query_sdk"]),O=new Map;function Ce(e){const t=O.get(e);if(t)return t;const n=L(`${I}/api/${e}/tools`,{method:"GET",credentials:"include",timeoutMs:15e3}).then(async r=>{if(!r.ok)throw new Error(`tool list failed: ${r.status}`);const a=await r.json();return new Set((a.tools??[]).flatMap(o=>typeof o.name=="string"&&o.annotations?.readOnlyHint===!0?[o.name]:[]))});return O.set(e,n),n.catch(()=>O.delete(e)),n}async function $e(e,t,n,r){if(n!=="invoke_view_action")return!Ee.has(n)&&!(await Ce(e)).has(n)?{error:`Views can only call read tools and their declared actions; "${n}" is neither`}:{url:`${I}/api/${e}/${encodeURIComponent(n)}`,body:r??{}};const{view:a,action:o,value:i,interaction_id:u}=r??{};return a!==t?{error:`This frame hosts "${t}", not "${String(a)}"`}:typeof o!="string"||!o?{error:"action is required"}:{url:`${I}/api/${e}/views/${encodeURIComponent(t)}/actions/${encodeURIComponent(o)}`,body:{value:i??null,interaction_id:u}}}const Se=({orgSlug:e,viewKey:t,scope:n,params:r,onParamsChange:a,contentHash:o,title:i,minHeight:u=96,className:g})=>{const h=s.useRef(null),l=s.useRef(null),[c,m]=s.useState(null),[$,_]=s.useState(null),[oe,se]=s.useState(u),j=s.useRef(null),T=s.useRef(null),D=s.useRef(u);D.current=u;const x=s.useRef({scope:n,params:r,onParamsChange:a});x.current={scope:n,params:r,onParamsChange:a};const R=be(e,t);s.useEffect(()=>{let y=!1;return R!==T.current&&(m(null),T.current=null,j.current=null),_(null),o!=null&&o===j.current&&R===T.current?()=>{y=!0}:(L(`${I}/api/${e}/views/${encodeURIComponent(t)}/shell`,{credentials:"include"}).then(async f=>{if(!f.ok)throw new Error(`shell ${f.status}`);const M=await f.text();if(y)return;const b=f.headers.get("X-Lobu-View-Hash");b!==null&&b===j.current&&R===T.current||(j.current=b,T.current=R,_(null),m(M))}).catch(f=>{y||_(f instanceof Error?f.message:String(f))}),()=>{y=!0})},[R,e,t,o]);const ae=JSON.stringify(r),ie=JSON.stringify(n);return s.useEffect(()=>{l.current?.sendToolInput({arguments:{scope:x.current.scope,params:x.current.params}})},[ie,ae]),s.useEffect(()=>{if(!c||$)return;const y=h.current;if(!y?.contentWindow)return;const f=e,M=t;let b=!1;const F=()=>document.documentElement.classList.contains("dark")?"dark":"light",v=new ve(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{},updateModelContext:{structuredContent:{}}},{hostContext:{theme:F(),displayMode:"inline",platform:"web"}});v.addEventListener("sizechange",({height:p})=>{typeof p=="number"&&se(Math.max(D.current,Math.ceil(p)))}),v.oncalltool=async({name:p,arguments:w})=>{if(b)return{content:[{type:"text",text:"view unmounted"}],isError:!0};let E;try{E=await $e(f,M,p,w)}catch(U){return{content:[{type:"text",text:String(U)}],isError:!0}}if(b)return{content:[{type:"text",text:"view unmounted"}],isError:!0};if("error"in E)return{content:[{type:"text",text:E.error}],isError:!0};const A=await L(E.url,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(E.body),timeoutMs:3e4}),C=await A.json().catch(()=>null);return A.ok?{content:[{type:"text",text:JSON.stringify(C)}],structuredContent:C??{}}:{content:[{type:"text",text:C&&typeof C.error=="string"&&C.error||`API error: ${A.status}`}],isError:!0}},v.onupdatemodelcontext=async({structuredContent:p})=>{if(b)return{};const w=p?.params;return w&&typeof w=="object"&&!Array.isArray(w)&&x.current.onParamsChange(w),{}},v.onopenlink=async({url:p})=>b?{}:(window.open(p,"_blank","noopener,noreferrer"),{}),v.addEventListener("initialized",()=>{v.sendToolInput({arguments:{scope:x.current.scope,params:x.current.params}})});const q=new he(y.contentWindow,y.contentWindow);v.connect(q).catch(p=>{console.error("[view-frame] failed to initialize",p)}),l.current=v;const G=new MutationObserver(()=>{v.setHostContext({theme:F(),displayMode:"inline",platform:"web"})});return G.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{b=!0,G.disconnect(),l.current=null,q.close()}},[c,$,e,t]),$?d.jsxs("div",{"data-testid":"view-frame-error",className:"text-sm text-destructive",children:["View failed to load: ",$]}):d.jsx("div",{className:g,"data-testid":"view-frame","data-view":t,children:c?d.jsx("iframe",{ref:h,title:i??t,srcDoc:c,sandbox:"allow-scripts",style:{width:"100%",height:oe,border:"none",display:"block"}}):d.jsx("div",{className:"animate-pulse rounded-md bg-muted/40",style:{height:u}})})};export{Ne as T,Se as V,we as a,Te as b,Re as c};
@@ -65,7 +65,7 @@
65
65
  pointer-events: none;
66
66
  }
67
67
  </style>
68
- <script type="module" crossorigin src="/assets/index-GZkujXG1.js"></script>
68
+ <script type="module" crossorigin src="/assets/index-B2AmRqYh.js"></script>
69
69
  <link rel="stylesheet" crossorigin href="/assets/index-BmAuAhub.css">
70
70
  </head>
71
71
  <body>