clitrigger 0.2.24 → 0.2.26

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 (78) hide show
  1. package/README.md +44 -31
  2. package/README_KR.md +44 -31
  3. package/dist/client/assets/AnalyticsPanel-CJF51ov7.js +48 -0
  4. package/dist/client/assets/FloatingComposerController-5A3GJtK4-BqOKhUaC.js +1 -0
  5. package/dist/client/assets/PlannerPageEditor-1-XUcFw6.css +1 -0
  6. package/dist/client/assets/PlannerPageEditor-BJ0DxLsM.js +211 -0
  7. package/dist/client/assets/TaskGraph-B4qlPjjq.js +2 -0
  8. package/dist/client/assets/VaultLayout-Cbz0Dzjt.js +153 -0
  9. package/dist/client/assets/clsx-B-dksMZM.js +1 -0
  10. package/dist/client/assets/index-B_5C2Aov.css +32 -0
  11. package/dist/client/assets/index-Df25dsa5.js +668 -0
  12. package/dist/client/assets/index-Vcq4gwWv.js +1 -0
  13. package/dist/client/assets/style-BZV40eAE.css +1 -0
  14. package/dist/client/assets/style-BeBN7DXF.js +7 -0
  15. package/dist/client/assets/value-BTdN53H7.js +1 -0
  16. package/dist/client/assets/with-selector-bfGVmvLm.js +17 -0
  17. package/dist/client/index.html +2 -2
  18. package/dist/server/db/queries.d.ts.map +1 -1
  19. package/dist/server/db/queries.js +14 -8
  20. package/dist/server/db/queries.js.map +1 -1
  21. package/dist/server/db/schema.d.ts.map +1 -1
  22. package/dist/server/db/schema.js +3 -1
  23. package/dist/server/db/schema.js.map +1 -1
  24. package/dist/server/index.d.ts.map +1 -1
  25. package/dist/server/index.js +47 -25
  26. package/dist/server/index.js.map +1 -1
  27. package/dist/server/lib/jira-client.d.ts.map +1 -1
  28. package/dist/server/lib/jira-client.js +4 -1
  29. package/dist/server/lib/jira-client.js.map +1 -1
  30. package/dist/server/middleware/auth.d.ts +9 -0
  31. package/dist/server/middleware/auth.d.ts.map +1 -1
  32. package/dist/server/middleware/auth.js +95 -17
  33. package/dist/server/middleware/auth.js.map +1 -1
  34. package/dist/server/plugins/jira/router.d.ts.map +1 -1
  35. package/dist/server/plugins/jira/router.js +3 -1
  36. package/dist/server/plugins/jira/router.js.map +1 -1
  37. package/dist/server/routes/files.d.ts.map +1 -1
  38. package/dist/server/routes/files.js +9 -20
  39. package/dist/server/routes/files.js.map +1 -1
  40. package/dist/server/routes/images.d.ts.map +1 -1
  41. package/dist/server/routes/images.js +9 -0
  42. package/dist/server/routes/images.js.map +1 -1
  43. package/dist/server/routes/memory.d.ts.map +1 -1
  44. package/dist/server/routes/memory.js +2 -16
  45. package/dist/server/routes/memory.js.map +1 -1
  46. package/dist/server/routes/projects.d.ts.map +1 -1
  47. package/dist/server/routes/projects.js +42 -12
  48. package/dist/server/routes/projects.js.map +1 -1
  49. package/dist/server/routes/vault.d.ts.map +1 -1
  50. package/dist/server/routes/vault.js +6 -1
  51. package/dist/server/routes/vault.js.map +1 -1
  52. package/dist/server/services/claude-manager.d.ts.map +1 -1
  53. package/dist/server/services/claude-manager.js +15 -0
  54. package/dist/server/services/claude-manager.js.map +1 -1
  55. package/dist/server/services/session-manager.d.ts +1 -0
  56. package/dist/server/services/session-manager.d.ts.map +1 -1
  57. package/dist/server/services/session-manager.js +32 -1
  58. package/dist/server/services/session-manager.js.map +1 -1
  59. package/dist/server/utils/net-safety.d.ts +2 -0
  60. package/dist/server/utils/net-safety.d.ts.map +1 -0
  61. package/dist/server/utils/net-safety.js +28 -0
  62. package/dist/server/utils/net-safety.js.map +1 -0
  63. package/dist/server/utils/open-path.d.ts +4 -0
  64. package/dist/server/utils/open-path.d.ts.map +1 -0
  65. package/dist/server/utils/open-path.js +19 -0
  66. package/dist/server/utils/open-path.js.map +1 -0
  67. package/dist/server/utils/path-safety.d.ts +2 -0
  68. package/dist/server/utils/path-safety.d.ts.map +1 -0
  69. package/dist/server/utils/path-safety.js +25 -0
  70. package/dist/server/utils/path-safety.js.map +1 -0
  71. package/dist/server/websocket/index.d.ts.map +1 -1
  72. package/dist/server/websocket/index.js +26 -1
  73. package/dist/server/websocket/index.js.map +1 -1
  74. package/electron/main.cjs +17 -3
  75. package/package.json +6 -6
  76. package/dist/client/assets/FloatingComposerController-5A3GJtK4-D5OJqjB6.js +0 -1
  77. package/dist/client/assets/index-7c5uNap1.js +0 -1080
  78. package/dist/client/assets/index-CyIseJUh.css +0 -32
@@ -0,0 +1,211 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FloatingComposerController-5A3GJtK4-BqOKhUaC.js","assets/index-Df25dsa5.js","assets/index-B_5C2Aov.css","assets/with-selector-bfGVmvLm.js","assets/index-Vcq4gwWv.js","assets/clsx-B-dksMZM.js"])))=>i.map(i=>d[i]);
2
+ var uM=Object.defineProperty;var fM=(t,e,n)=>e in t?uM(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var B=(t,e,n)=>fM(t,typeof e!="symbol"?e+"":e,n);import{d as hM,r as v,R as M1,c as Dr,j as b,a as T1,ak as $i,aj as tt,al as A1,am as pM,u as N1,an as jh,a3 as mM,D as gM,ao as bM,ap as yM,K as vM,ah as wM,aq as kM,ar as xM,as as CM,at as SM,au as EM}from"./index-Df25dsa5.js";import{w as R1,r as MM}from"./with-selector-bfGVmvLm.js";import{k as TM,b as AM}from"./index-Vcq4gwWv.js";import{c as $r}from"./clsx-B-dksMZM.js";/**
3
+ * @license lucide-react v1.8.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const NM=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],RM=hM("square-check-big",NM);function qc(){return typeof window<"u"}function mo(t){return Vh(t)?(t.nodeName||"").toLowerCase():"#document"}function qt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ur(t){var e;return(e=(Vh(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Vh(t){return qc()?t instanceof Node||t instanceof qt(t).Node:!1}function Be(t){return qc()?t instanceof Element||t instanceof qt(t).Element:!1}function yt(t){return qc()?t instanceof HTMLElement||t instanceof qt(t).HTMLElement:!1}function Us(t){return!qc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof qt(t).ShadowRoot}function Ml(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=Mn(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&o!=="inline"&&o!=="contents"}function IM(t){return/^(table|td|th)$/.test(mo(t))}function Gc(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const OM=/transform|translate|scale|rotate|perspective|filter/,DM=/paint|layout|strict|content/,Co=t=>!!t&&t!=="none";let au;function Hh(t){const e=Be(t)?Mn(t):t;return Co(e.transform)||Co(e.translate)||Co(e.scale)||Co(e.rotate)||Co(e.perspective)||!Zc()&&(Co(e.backdropFilter)||Co(e.filter))||OM.test(e.willChange||"")||DM.test(e.contain||"")}function _M(t){let e=_r(t);for(;yt(e)&&!Er(e);){if(Hh(e))return e;if(Gc(e))return null;e=_r(e)}return null}function Zc(){return au==null&&(au=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),au}function Er(t){return/^(html|body|#document)$/.test(mo(t))}function Mn(t){return qt(t).getComputedStyle(t)}function Kc(t){return Be(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function _r(t){if(mo(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Us(t)&&t.host||ur(t);return Us(e)?e.host:e}function I1(t){const e=_r(t);return Er(e)?t.ownerDocument?t.ownerDocument.body:t.body:yt(e)&&Ml(e)?e:I1(e)}function Mr(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=I1(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=qt(o);if(i){const l=xf(s);return e.concat(s,s.visualViewport||[],Ml(o)?o:[],l&&n?Mr(l):[])}else return e.concat(o,Mr(o,[],n))}function xf(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}const O1=["top","right","bottom","left"],kg=["start","end"],xg=O1.reduce((t,e)=>t.concat(e,e+"-"+kg[0],e+"-"+kg[1]),[]),Fn=Math.min,Et=Math.max,Ya=Math.round,ta=Math.floor,rr=t=>({x:t,y:t}),PM={left:"right",right:"left",bottom:"top",top:"bottom"};function Cf(t,e,n){return Et(t,Fn(e,n))}function zn(t,e){return typeof t=="function"?t(e):t}function an(t){return t.split("-")[0]}function Vn(t){return t.split("-")[1]}function Fh(t){return t==="x"?"y":"x"}function zh(t){return t==="y"?"height":"width"}function _n(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Uh(t){return Fh(_n(t))}function D1(t,e,n){n===void 0&&(n=!1);const r=Vn(t),o=Uh(t),i=zh(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Qa(s)),[s,Qa(s)]}function $M(t){const e=Qa(t);return[Xa(t),e,Xa(e)]}function Xa(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Cg=["left","right"],Sg=["right","left"],LM=["top","bottom"],BM=["bottom","top"];function jM(t,e,n){switch(t){case"top":case"bottom":return n?e?Sg:Cg:e?Cg:Sg;case"left":case"right":return e?LM:BM;default:return[]}}function VM(t,e,n,r){const o=Vn(t);let i=jM(an(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(Xa)))),i}function Qa(t){const e=an(t);return PM[e]+t.slice(e.length)}function HM(t){return{top:0,right:0,bottom:0,left:0,...t}}function Wh(t){return typeof t!="number"?HM(t):{top:t,right:t,bottom:t,left:t}}function Li(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}/*!
8
+ * tabbable 6.5.0
9
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
10
+ */var FM=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","area[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],ec=FM.join(","),_1=typeof Element>"u",Bi=_1?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,tc=!_1&&Element.prototype.getRootNode?function(t){var e;return t==null||(e=t.getRootNode)===null||e===void 0?void 0:e.call(t)}:function(t){return t==null?void 0:t.ownerDocument},nc=function(e,n){var r;n===void 0&&(n=!0);var o=e==null||(r=e.getAttribute)===null||r===void 0?void 0:r.call(e,"inert"),i=o===""||o==="true",s=i||n&&e&&(typeof e.closest=="function"?e.closest("[inert]"):nc(e.parentNode));return s},zM=function(e){var n,r=e==null||(n=e.getAttribute)===null||n===void 0?void 0:n.call(e,"contenteditable");return r===""||r==="true"},P1=function(e,n,r){if(nc(e))return[];var o=Array.prototype.slice.apply(e.querySelectorAll(ec));return n&&Bi.call(e,ec)&&o.unshift(e),o=o.filter(r),o},rc=function(e,n,r){for(var o=[],i=Array.from(e);i.length;){var s=i.shift();if(!nc(s,!1))if(s.tagName==="SLOT"){var l=s.assignedElements(),a=l.length?l:s.children,c=rc(a,!0,r);r.flatten?o.push.apply(o,c):o.push({scopeParent:s,candidates:c})}else{var d=Bi.call(s,ec);d&&r.filter(s)&&(n||!e.includes(s))&&o.push(s);var u=s.shadowRoot||typeof r.getShadowRoot=="function"&&r.getShadowRoot(s),f=!nc(u,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(s));if(u&&f){var h=rc(u===!0?s.children:u.children,!0,r);r.flatten?o.push.apply(o,h):o.push({scopeParent:s,candidates:h})}else i.unshift.apply(i,s.children)}}return o},$1=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},L1=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||zM(e))&&!$1(e)?0:e.tabIndex},UM=function(e,n){var r=L1(e);return r<0&&n&&!$1(e)?0:r},WM=function(e,n){return e.tabIndex===n.tabIndex?e.documentOrder-n.documentOrder:e.tabIndex-n.tabIndex},B1=function(e){return e.tagName==="INPUT"},qM=function(e){return B1(e)&&e.type==="hidden"},GM=function(e){var n=e.tagName==="DETAILS"&&Array.prototype.slice.apply(e.children).some(function(r){return r.tagName==="SUMMARY"});return n},ZM=function(e,n){for(var r=0;r<e.length;r++)if(e[r].checked&&e[r].form===n)return e[r]},KM=function(e){if(!e.name)return!0;var n=e.form||tc(e),r=function(l){return n.querySelectorAll('input[type="radio"][name="'+l+'"]')},o;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")o=r(window.CSS.escape(e.name));else try{o=r(e.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var i=ZM(o,e.form);return!i||i===e},JM=function(e){return B1(e)&&e.type==="radio"},YM=function(e){return JM(e)&&!KM(e)},XM=function(e){var n,r=e&&tc(e),o=(n=r)===null||n===void 0?void 0:n.host,i=!1;if(r&&r!==e){var s,l,a;for(i=!!((s=o)!==null&&s!==void 0&&(l=s.ownerDocument)!==null&&l!==void 0&&l.contains(o)||e!=null&&(a=e.ownerDocument)!==null&&a!==void 0&&a.contains(e));!i&&o;){var c,d,u;r=tc(o),o=(c=r)===null||c===void 0?void 0:c.host,i=!!((d=o)!==null&&d!==void 0&&(u=d.ownerDocument)!==null&&u!==void 0&&u.contains(o))}}return i},Eg=function(e){var n=e.getBoundingClientRect(),r=n.width,o=n.height;return r===0&&o===0},QM=function(e,n){var r=n.displayCheck,o=n.getShadowRoot;if(r==="full-native"&&"checkVisibility"in e){var i=e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}var s=getComputedStyle(e),l=s.visibility;if(l==="hidden"||l==="collapse")return!0;var a=Bi.call(e,"details>summary:first-of-type"),c=a?e.parentElement:e;if(Bi.call(c,"details:not([open]) *"))return!0;if(!r||r==="full"||r==="full-native"||r==="legacy-full"){if(typeof o=="function"){for(var d=e;e;){var u=e.parentElement,f=tc(e);if(u&&!u.shadowRoot&&o(u)===!0)return Eg(e);e.assignedSlot?e=e.assignedSlot:!u&&f!==e.ownerDocument?e=f.host:e=u}e=d}if(XM(e))return!e.getClientRects().length;if(r!=="legacy-full")return!0}else if(r==="non-zero-area")return Eg(e);return!1},eT=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var n=e.parentElement;n;){if(n.tagName==="FIELDSET"&&n.disabled){for(var r=0;r<n.children.length;r++){var o=n.children.item(r);if(o.tagName==="LEGEND")return Bi.call(n,"fieldset[disabled] *")?!0:!o.contains(e)}return!0}n=n.parentElement}return!1},Sf=function(e,n){return!(n.disabled||qM(n)||QM(n,e)||GM(n)||eT(n))},Ef=function(e,n){return!(YM(n)||L1(n)<0||!Sf(e,n))},tT=function(e){var n=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(n)||n>=0)},j1=function(e){var n=[],r=[];return e.forEach(function(o,i){var s=!!o.scopeParent,l=s?o.scopeParent:o,a=UM(l,s),c=s?j1(o.candidates):l;a===0?s?n.push.apply(n,c):n.push(l):r.push({documentOrder:i,tabIndex:a,item:o,isScope:s,content:c})}),r.sort(WM).reduce(function(o,i){return i.isScope?o.push.apply(o,i.content):o.push(i.content),o},[]).concat(n)},Jc=function(e,n){n=n||{};var r;return n.getShadowRoot?r=rc([e],n.includeContainer,{filter:Ef.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:tT}):r=P1(e,n.includeContainer,Ef.bind(null,n)),j1(r)},nT=function(e,n){n=n||{};var r;return n.getShadowRoot?r=rc([e],n.includeContainer,{filter:Sf.bind(null,n),flatten:!0,getShadowRoot:n.getShadowRoot}):r=P1(e,n.includeContainer,Sf.bind(null,n)),r},V1=function(e,n){if(n=n||{},!e)throw new Error("No node provided");return Bi.call(e,ec)===!1?!1:Ef(n,e)};function H1(){const t=navigator.userAgentData;return t!=null&&t.platform?t.platform:navigator.platform}function F1(){const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(e=>{let{brand:n,version:r}=e;return n+"/"+r}).join(" "):navigator.userAgent}function z1(){return/apple/i.test(navigator.vendor)}function Mf(){const t=/android/i;return t.test(H1())||t.test(F1())}function rT(){return H1().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function U1(){return F1().includes("jsdom/")}const Mg="data-floating-ui-focusable",oT="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";function qr(t){let e=t.activeElement;for(;((n=e)==null||(n=n.shadowRoot)==null?void 0:n.activeElement)!=null;){var n;e=e.shadowRoot.activeElement}return e}function Ct(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Us(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function kr(t){return"composedPath"in t?t.composedPath()[0]:t.target}function cu(t,e){if(e==null)return!1;if("composedPath"in t)return t.composedPath().includes(e);const n=t;return n.target!=null&&e.contains(n.target)}function iT(t){return t.matches("html,body")}function Mt(t){return(t==null?void 0:t.ownerDocument)||document}function W1(t){return yt(t)&&t.matches(oT)}function Tg(t){return t?t.getAttribute("role")==="combobox"&&W1(t):!1}function sT(t){if(!t||U1())return!0;try{return t.matches(":focus-visible")}catch{return!0}}function Tf(t){return t?t.hasAttribute(Mg)?t:t.querySelector("["+Mg+"]")||t:null}function Ci(t,e,n){return n===void 0&&(n=!0),t.filter(o=>{var i;return o.parentId===e&&(!n||((i=o.context)==null?void 0:i.open))}).flatMap(o=>[o,...Ci(t,o.id,n)])}function Ag(t,e){var n;let r=[],o=(n=t.find(i=>i.id===e))==null?void 0:n.parentId;for(;o;){const i=t.find(s=>s.id===o);o=i==null?void 0:i.parentId,i&&(r=r.concat(i))}return r}function du(t){t.preventDefault(),t.stopPropagation()}function lT(t){return"nativeEvent"in t}function aT(t){return t.mozInputSource===0&&t.isTrusted?!0:Mf()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function cT(t){return U1()?!1:!Mf()&&t.width===0&&t.height===0||Mf()&&t.width===1&&t.height===1&&t.pressure===0&&t.detail===0&&t.pointerType==="mouse"||t.width<1&&t.height<1&&t.pressure===0&&t.detail===0&&t.pointerType==="touch"}function Af(t,e){const n=["mouse","pen"];return n.push("",void 0),n.includes(t)}var dT=typeof document<"u",uT=function(){},Qe=dT?v.useLayoutEffect:uT;const fT={...M1};function Pn(t){const e=v.useRef(t);return Qe(()=>{e.current=t}),e}const hT=fT.useInsertionEffect,pT=hT||(t=>t());function zt(t){const e=v.useRef(()=>{});return pT(()=>{e.current=t}),v.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}const Tl=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function q1(t,e){const n=Jc(t,Tl()),r=n.length;if(r===0)return;const o=qr(Mt(t)),i=n.indexOf(o),s=i===-1?e===1?0:r-1:i+e;return n[s]}function G1(t){return q1(Mt(t).body,1)||t}function Z1(t){return q1(Mt(t).body,-1)||t}function Ds(t,e){const n=e||t.currentTarget,r=t.relatedTarget;return!r||!Ct(n,r)}function mT(t){Jc(t,Tl()).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}function Ng(t){t.querySelectorAll("[data-tabindex]").forEach(n=>{const r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}function Rg(t,e,n){let{reference:r,floating:o}=t;const i=_n(e),s=Uh(e),l=zh(s),a=an(e),c=i==="y",d=r.x+r.width/2-o.width/2,u=r.y+r.height/2-o.height/2,f=r[l]/2-o[l]/2;let h;switch(a){case"top":h={x:d,y:r.y-o.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:u};break;case"left":h={x:r.x-o.width,y:u};break;default:h={x:r.x,y:r.y}}switch(Vn(e)){case"start":h[s]-=f*(n&&c?-1:1);break;case"end":h[s]+=f*(n&&c?-1:1);break}return h}async function gT(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:h=0}=zn(e,t),p=Wh(h),g=l[f?u==="floating"?"reference":"floating":u],y=Li(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(g)))==null||n?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),w=u==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),x=await(i.isElement==null?void 0:i.isElement(k))?await(i.getScale==null?void 0:i.getScale(k))||{x:1,y:1}:{x:1,y:1},C=Li(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:k,strategy:a}):w);return{top:(y.top-C.top+p.top)/x.y,bottom:(C.bottom-y.bottom+p.bottom)/x.y,left:(y.left-C.left+p.left)/x.x,right:(C.right-y.right+p.right)/x.x}}const bT=50,yT=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=s.detectOverflow?s:{...s,detectOverflow:gT},a=await(s.isRTL==null?void 0:s.isRTL(e));let c=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:d,y:u}=Rg(c,r,a),f=r,h=0;const p={};for(let m=0;m<i.length;m++){const g=i[m];if(!g)continue;const{name:y,fn:w}=g,{x:k,y:x,data:C,reset:E}=await w({x:d,y:u,initialPlacement:r,placement:f,strategy:o,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});d=k??d,u=x??u,p[y]={...p[y],...C},E&&h<bT&&(h++,typeof E=="object"&&(E.placement&&(f=E.placement),E.rects&&(c=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:d,y:u}=Rg(c,f,a)),m=-1)}return{x:d,y:u,placement:f,strategy:o,middlewareData:p}},vT=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:a}=e,{element:c,padding:d=0}=zn(t,e)||{};if(c==null)return{};const u=Wh(d),f={x:n,y:r},h=Uh(o),p=zh(h),m=await s.getDimensions(c),g=h==="y",y=g?"top":"left",w=g?"bottom":"right",k=g?"clientHeight":"clientWidth",x=i.reference[p]+i.reference[h]-f[h]-i.floating[p],C=f[h]-i.reference[h],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let S=E?E[k]:0;(!S||!await(s.isElement==null?void 0:s.isElement(E)))&&(S=l.floating[k]||i.floating[p]);const M=x/2-C/2,N=S/2-m[p]/2-1,A=Fn(u[y],N),R=Fn(u[w],N),P=A,D=S-m[p]-R,T=S/2-m[p]/2+M,_=Cf(P,T,D),F=!a.arrow&&Vn(o)!=null&&T!==_&&i.reference[p]/2-(T<P?A:R)-m[p]/2<0,L=F?T<P?T-P:T-D:0;return{[h]:f[h]+L,data:{[h]:_,centerOffset:T-_-L,...F&&{alignmentOffset:L}},reset:F}}});function wT(t,e,n){return(t?[...n.filter(o=>Vn(o)===t),...n.filter(o=>Vn(o)!==t)]:n.filter(o=>an(o)===o)).filter(o=>t?Vn(o)===t||(e?Xa(o)!==o:!1):!0)}const kT=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,o;const{rects:i,middlewareData:s,placement:l,platform:a,elements:c}=e,{crossAxis:d=!1,alignment:u,allowedPlacements:f=xg,autoAlignment:h=!0,...p}=zn(t,e),m=u!==void 0||f===xg?wT(u||null,h,f):f,g=await a.detectOverflow(e,p),y=((n=s.autoPlacement)==null?void 0:n.index)||0,w=m[y];if(w==null)return{};const k=D1(w,i,await(a.isRTL==null?void 0:a.isRTL(c.floating)));if(l!==w)return{reset:{placement:m[0]}};const x=[g[an(w)],g[k[0]],g[k[1]]],C=[...((r=s.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:x}],E=m[y+1];if(E)return{data:{index:y+1,overflows:C},reset:{placement:E}};const S=C.map(A=>{const R=Vn(A.placement);return[A.placement,R&&d?A.overflows.slice(0,2).reduce((P,D)=>P+D,0):A.overflows[0],A.overflows]}).sort((A,R)=>A[1]-R[1]),N=((o=S.filter(A=>A[2].slice(0,Vn(A[0])?2:3).every(R=>R<=0))[0])==null?void 0:o[0])||S[0][0];return N!==l?{data:{index:y+1,overflows:C},reset:{placement:N}}:{}}}},xT=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=zn(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=an(o),w=_n(l),k=an(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(c.floating)),C=f||(k||!m?[Qa(l)]:$M(l)),E=p!=="none";!f&&E&&C.push(...VM(l,m,p,x));const S=[l,...C],M=await a.detectOverflow(e,g),N=[];let A=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&N.push(M[y]),u){const T=D1(o,s,x);N.push(M[T[0]],M[T[1]])}if(A=[...A,{placement:o,overflows:N}],!N.every(T=>T<=0)){var R,P;const T=(((R=i.flip)==null?void 0:R.index)||0)+1,_=S[T];if(_&&(!(u==="alignment"?w!==_n(_):!1)||A.every(O=>_n(O.placement)===w?O.overflows[0]>0:!0)))return{data:{index:T,overflows:A},reset:{placement:_}};let F=(P=A.filter(L=>L.overflows[0]<=0).sort((L,O)=>L.overflows[1]-O.overflows[1])[0])==null?void 0:P.placement;if(!F)switch(h){case"bestFit":{var D;const L=(D=A.filter(O=>{if(E){const V=_n(O.placement);return V===w||V==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(V=>V>0).reduce((V,U)=>V+U,0)]).sort((O,V)=>O[1]-V[1])[0])==null?void 0:D[0];L&&(F=L);break}case"initialPlacement":F=l;break}if(o!==F)return{reset:{placement:F}}}return{}}}};function Ig(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Og(t){return O1.some(e=>t[e]>=0)}const CT=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:o="referenceHidden",...i}=zn(t,e);switch(o){case"referenceHidden":{const s=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=Ig(s,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Og(l)}}}case"escaped":{const s=await r.detectOverflow(e,{...i,altBoundary:!0}),l=Ig(s,n.floating);return{data:{escapedOffsets:l,escaped:Og(l)}}}default:return{}}}}};function K1(t){const e=Fn(...t.map(i=>i.left)),n=Fn(...t.map(i=>i.top)),r=Et(...t.map(i=>i.right)),o=Et(...t.map(i=>i.bottom));return{x:e,y:n,width:r-e,height:o-n}}function ST(t){const e=t.slice().sort((o,i)=>o.y-i.y),n=[];let r=null;for(let o=0;o<e.length;o++){const i=e[o];!r||i.y-r.y>r.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(o=>Li(K1(o)))}const ET=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:o,platform:i,strategy:s}=e,{padding:l=2,x:a,y:c}=zn(t,e),d=Array.from(await(i.getClientRects==null?void 0:i.getClientRects(r.reference))||[]),u=ST(d),f=Li(K1(d)),h=Wh(l);function p(){if(u.length===2&&u[0].left>u[1].right&&a!=null&&c!=null)return u.find(g=>a>g.left-h.left&&a<g.right+h.right&&c>g.top-h.top&&c<g.bottom+h.bottom)||f;if(u.length>=2){if(_n(n)==="y"){const A=u[0],R=u[u.length-1],P=an(n)==="top",D=A.top,T=R.bottom,_=P?A.left:R.left,F=P?A.right:R.right,L=F-_,O=T-D;return{top:D,bottom:T,left:_,right:F,width:L,height:O,x:_,y:D}}const g=an(n)==="left",y=Et(...u.map(A=>A.right)),w=Fn(...u.map(A=>A.left)),k=u.filter(A=>g?A.left===w:A.right===y),x=k[0].top,C=k[k.length-1].bottom,E=w,S=y,M=S-E,N=C-x;return{top:x,bottom:C,left:E,right:S,width:M,height:N,x:E,y:x}}return f}const m=await i.getElementRects({reference:{getBoundingClientRect:p},floating:r.floating,strategy:s});return o.reference.x!==m.reference.x||o.reference.y!==m.reference.y||o.reference.width!==m.reference.width||o.reference.height!==m.reference.height?{reset:{rects:m}}:{}}}},J1=new Set(["left","top"]);async function MT(t,e){const{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=an(n),l=Vn(n),a=_n(n)==="y",c=J1.has(s)?-1:1,d=i&&a?-1:1,u=zn(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*d,y:f*c}:{x:f*c,y:h*d}}const TT=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=e,a=await MT(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:{...a,placement:s}}}}},AT=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:i}=e,{mainAxis:s=!0,crossAxis:l=!1,limiter:a={fn:y=>{let{x:w,y:k}=y;return{x:w,y:k}}},...c}=zn(t,e),d={x:n,y:r},u=await i.detectOverflow(e,c),f=_n(an(o)),h=Fh(f);let p=d[h],m=d[f];if(s){const y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",k=p+u[y],x=p-u[w];p=Cf(k,p,x)}if(l){const y=f==="y"?"top":"left",w=f==="y"?"bottom":"right",k=m+u[y],x=m-u[w];m=Cf(k,m,x)}const g=a.fn({...e,[h]:p,[f]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:s,[f]:l}}}}}},NT=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=zn(t,e),d={x:n,y:r},u=_n(o),f=Fh(u);let h=d[f],p=d[u];const m=zn(l,e),g=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(a){const k=f==="y"?"height":"width",x=i.reference[f]-i.floating[k]+g.mainAxis,C=i.reference[f]+i.reference[k]-g.mainAxis;h<x?h=x:h>C&&(h=C)}if(c){var y,w;const k=f==="y"?"width":"height",x=J1.has(an(o)),C=i.reference[u]-i.floating[k]+(x&&((y=s.offset)==null?void 0:y[u])||0)+(x?0:g.crossAxis),E=i.reference[u]+i.reference[k]+(x?0:((w=s.offset)==null?void 0:w[u])||0)-(x?g.crossAxis:0);p<C?p=C:p>E&&(p=E)}return{[f]:h,[u]:p}}}},RT=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:i,platform:s,elements:l}=e,{apply:a=()=>{},...c}=zn(t,e),d=await s.detectOverflow(e,c),u=an(o),f=Vn(o),h=_n(o)==="y",{width:p,height:m}=i.floating;let g,y;u==="top"||u==="bottom"?(g=u,y=f===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(y=u,g=f==="end"?"top":"bottom");const w=m-d.top-d.bottom,k=p-d.left-d.right,x=Fn(m-d[g],w),C=Fn(p-d[y],k),E=!e.middlewareData.shift;let S=x,M=C;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(M=k),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(S=w),E&&!f){const A=Et(d.left,0),R=Et(d.right,0),P=Et(d.top,0),D=Et(d.bottom,0);h?M=p-2*(A!==0||R!==0?A+R:Et(d.left,d.right)):S=m-2*(P!==0||D!==0?P+D:Et(d.top,d.bottom))}await a({...e,availableWidth:M,availableHeight:S});const N=await s.getDimensions(l.floating);return p!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function Y1(t){const e=Mn(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=yt(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=Ya(n)!==i||Ya(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function qh(t){return Be(t)?t:t.contextElement}function Si(t){const e=qh(t);if(!yt(e))return rr(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:i}=Y1(e);let s=(i?Ya(n.width):n.width)/r,l=(i?Ya(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const IT=rr(0);function X1(t){const e=qt(t);return!Zc()||!e.visualViewport?IT:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function OT(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==qt(t)?!1:e}function Bo(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=qh(t);let s=rr(1);e&&(r?Be(r)&&(s=Si(r)):s=Si(t));const l=OT(i,n,r)?X1(i):rr(0);let a=(o.left+l.x)/s.x,c=(o.top+l.y)/s.y,d=o.width/s.x,u=o.height/s.y;if(i){const f=qt(i),h=r&&Be(r)?qt(r):r;let p=f,m=xf(p);for(;m&&r&&h!==p;){const g=Si(m),y=m.getBoundingClientRect(),w=Mn(m),k=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,x=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;a*=g.x,c*=g.y,d*=g.x,u*=g.y,a+=k,c+=x,p=qt(m),m=xf(p)}}return Li({width:d,height:u,x:a,y:c})}function Yc(t,e){const n=Kc(t).scrollLeft;return e?e.left+n:Bo(ur(t)).left+n}function Q1(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Yc(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function DT(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const i=o==="fixed",s=ur(r),l=e?Gc(e.floating):!1;if(r===s||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=rr(1);const d=rr(0),u=yt(r);if((u||!u&&!i)&&((mo(r)!=="body"||Ml(s))&&(a=Kc(r)),u)){const h=Bo(r);c=Si(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const f=s&&!u&&!i?Q1(s,a):rr(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+f.x,y:n.y*c.y-a.scrollTop*c.y+d.y+f.y}}function _T(t){return Array.from(t.getClientRects())}function PT(t){const e=ur(t),n=Kc(t),r=t.ownerDocument.body,o=Et(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Et(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Yc(t);const l=-n.scrollTop;return Mn(r).direction==="rtl"&&(s+=Et(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}const Dg=25;function $T(t,e){const n=qt(t),r=ur(t),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,a=0;if(o){i=o.width,s=o.height;const d=Zc();(!d||d&&e==="fixed")&&(l=o.offsetLeft,a=o.offsetTop)}const c=Yc(r);if(c<=0){const d=r.ownerDocument,u=d.body,f=getComputedStyle(u),h=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-h);p<=Dg&&(i-=p)}else c<=Dg&&(i+=c);return{width:i,height:s,x:l,y:a}}function LT(t,e){const n=Bo(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=yt(t)?Si(t):rr(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,a=o*i.x,c=r*i.y;return{width:s,height:l,x:a,y:c}}function _g(t,e,n){let r;if(e==="viewport")r=$T(t,n);else if(e==="document")r=PT(ur(t));else if(Be(e))r=LT(e,n);else{const o=X1(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Li(r)}function ev(t,e){const n=_r(t);return n===e||!Be(n)||Er(n)?!1:Mn(n).position==="fixed"||ev(n,e)}function BT(t,e){const n=e.get(t);if(n)return n;let r=Mr(t,[],!1).filter(l=>Be(l)&&mo(l)!=="body"),o=null;const i=Mn(t).position==="fixed";let s=i?_r(t):t;for(;Be(s)&&!Er(s);){const l=Mn(s),a=Hh(s);!a&&l.position==="fixed"&&(o=null),(i?!a&&!o:!a&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Ml(s)&&!a&&ev(t,s))?r=r.filter(d=>d!==s):o=l,s=_r(s)}return e.set(t,r),r}function jT(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const s=[...n==="clippingAncestors"?Gc(e)?[]:BT(e,this._c):[].concat(n),r],l=_g(e,s[0],o);let a=l.top,c=l.right,d=l.bottom,u=l.left;for(let f=1;f<s.length;f++){const h=_g(e,s[f],o);a=Et(h.top,a),c=Fn(h.right,c),d=Fn(h.bottom,d),u=Et(h.left,u)}return{width:c-u,height:d-a,x:u,y:a}}function VT(t){const{width:e,height:n}=Y1(t);return{width:e,height:n}}function HT(t,e,n){const r=yt(e),o=ur(e),i=n==="fixed",s=Bo(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=rr(0);function c(){a.x=Yc(o)}if(r||!r&&!i)if((mo(e)!=="body"||Ml(o))&&(l=Kc(e)),r){const h=Bo(e,!0,i,e);a.x=h.x+e.clientLeft,a.y=h.y+e.clientTop}else o&&c();i&&!r&&o&&c();const d=o&&!r&&!i?Q1(o,l):rr(0),u=s.left+l.scrollLeft-a.x-d.x,f=s.top+l.scrollTop-a.y-d.y;return{x:u,y:f,width:s.width,height:s.height}}function uu(t){return Mn(t).position==="static"}function Pg(t,e){if(!yt(t)||Mn(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ur(t)===n&&(n=n.ownerDocument.body),n}function tv(t,e){const n=qt(t);if(Gc(t))return n;if(!yt(t)){let o=_r(t);for(;o&&!Er(o);){if(Be(o)&&!uu(o))return o;o=_r(o)}return n}let r=Pg(t,e);for(;r&&IM(r)&&uu(r);)r=Pg(r,e);return r&&Er(r)&&uu(r)&&!Hh(r)?n:r||_M(t)||n}const FT=async function(t){const e=this.getOffsetParent||tv,n=this.getDimensions,r=await n(t.floating);return{reference:HT(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function zT(t){return Mn(t).direction==="rtl"}const UT={convertOffsetParentRelativeRectToViewportRelativeRect:DT,getDocumentElement:ur,getClippingRect:jT,getOffsetParent:tv,getElementRects:FT,getClientRects:_T,getDimensions:VT,getScale:Si,isElement:Be,isRTL:zT};function nv(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function WT(t,e){let n=null,r;const o=ur(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:d,top:u,width:f,height:h}=c;if(l||e(),!f||!h)return;const p=ta(u),m=ta(o.clientWidth-(d+f)),g=ta(o.clientHeight-(u+h)),y=ta(d),k={rootMargin:-p+"px "+-m+"px "+-g+"px "+-y+"px",threshold:Et(0,Fn(1,a))||1};let x=!0;function C(E){const S=E[0].intersectionRatio;if(S!==a){if(!x)return s();S?s(!1,S):r=setTimeout(()=>{s(!1,1e-7)},1e3)}S===1&&!nv(c,t.getBoundingClientRect())&&s(),x=!1}try{n=new IntersectionObserver(C,{...k,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,k)}n.observe(t)}return s(!0),i}function ji(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=qh(t),d=o||i?[...c?Mr(c):[],...e?Mr(e):[]]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const u=c&&l?WT(c,n):null;let f=-1,h=null;s&&(h=new ResizeObserver(y=>{let[w]=y;w&&w.target===c&&h&&e&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=h)==null||k.observe(e)})),n()}),c&&!a&&h.observe(c),e&&h.observe(e));let p,m=a?Bo(t):null;a&&g();function g(){const y=Bo(t);m&&!nv(m,y)&&n(),m=y,p=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(w=>{o&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),u==null||u(),(y=h)==null||y.disconnect(),h=null,a&&cancelAnimationFrame(p)}}const qT=TT,GT=kT,ZT=AT,KT=xT,JT=RT,YT=CT,$g=vT,XT=ET,QT=NT,eA=(t,e,n)=>{const r=new Map,o={platform:UT,...n},i={...o.platform,_c:r};return yT(t,e,{...o,platform:i})};var tA=typeof document<"u",nA=function(){},Oa=tA?v.useLayoutEffect:nA;function oc(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!oc(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&t.$$typeof)&&!oc(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function rv(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Lg(t,e){const n=rv(t);return Math.round(e*n)/n}function fu(t){const e=v.useRef(t);return Oa(()=>{e.current=t}),e}function rA(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[d,u]=v.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=v.useState(r);oc(f,r)||h(r);const[p,m]=v.useState(null),[g,y]=v.useState(null),w=v.useCallback(O=>{O!==E.current&&(E.current=O,m(O))},[]),k=v.useCallback(O=>{O!==S.current&&(S.current=O,y(O))},[]),x=i||p,C=s||g,E=v.useRef(null),S=v.useRef(null),M=v.useRef(d),N=a!=null,A=fu(a),R=fu(o),P=fu(c),D=v.useCallback(()=>{if(!E.current||!S.current)return;const O={placement:e,strategy:n,middleware:f};R.current&&(O.platform=R.current),eA(E.current,S.current,O).then(V=>{const U={...V,isPositioned:P.current!==!1};T.current&&!oc(M.current,U)&&(M.current=U,Dr.flushSync(()=>{u(U)}))})},[f,e,n,R,P]);Oa(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,u(O=>({...O,isPositioned:!1})))},[c]);const T=v.useRef(!1);Oa(()=>(T.current=!0,()=>{T.current=!1}),[]),Oa(()=>{if(x&&(E.current=x),C&&(S.current=C),x&&C){if(A.current)return A.current(x,C,D);D()}},[x,C,D,A,N]);const _=v.useMemo(()=>({reference:E,floating:S,setReference:w,setFloating:k}),[w,k]),F=v.useMemo(()=>({reference:x,floating:C}),[x,C]),L=v.useMemo(()=>{const O={position:n,left:0,top:0};if(!F.floating)return O;const V=Lg(F.floating,d.x),U=Lg(F.floating,d.y);return l?{...O,transform:"translate("+V+"px, "+U+"px)",...rv(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:U}},[n,l,F.floating,d.x,d.y]);return v.useMemo(()=>({...d,update:D,refs:_,elements:F,floatingStyles:L}),[d,D,_,F,L])}const oA=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?$g({element:r.current,padding:o}).fn(n):{}:r?$g({element:r,padding:o}).fn(n):{}}}},Hn=(t,e)=>{const n=qT(t);return{name:n.name,fn:n.fn,options:[t,e]}},ri=(t,e)=>{const n=ZT(t);return{name:n.name,fn:n.fn,options:[t,e]}},iA=(t,e)=>({fn:QT(t).fn,options:[t,e]}),jo=(t,e)=>{const n=KT(t);return{name:n.name,fn:n.fn,options:[t,e]}},Ws=(t,e)=>{const n=JT(t);return{name:n.name,fn:n.fn,options:[t,e]}},ov=(t,e)=>{const n=GT(t);return{name:n.name,fn:n.fn,options:[t,e]}},sA=(t,e)=>{const n=YT(t);return{name:n.name,fn:n.fn,options:[t,e]}},_s=(t,e)=>{const n=XT(t);return{name:n.name,fn:n.fn,options:[t,e]}},iv=(t,e)=>{const n=oA(t);return{name:n.name,fn:n.fn,options:[t,e]}};function lA(t){const e=v.useRef(void 0),n=v.useCallback(r=>{const o=t.map(i=>{if(i!=null){if(typeof i=="function"){const s=i,l=s(r);return typeof l=="function"?l:()=>{s(null)}}return i.current=r,()=>{i.current=null}}});return()=>{o.forEach(i=>i==null?void 0:i())}},t);return v.useMemo(()=>t.every(r=>r==null)?null:r=>{e.current&&(e.current(),e.current=void 0),r!=null&&(e.current=n(r))},t)}const aA="data-floating-ui-focusable",Bg="active",jg="selected",cA={...M1};let Vg=!1,dA=0;const Hg=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+dA++;function uA(){const[t,e]=v.useState(()=>Vg?Hg():void 0);return Qe(()=>{t==null&&e(Hg())},[]),v.useEffect(()=>{Vg=!0},[]),t}const fA=cA.useId,Gh=fA||uA;function hA(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(o=>o(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const pA=v.createContext(null),mA=v.createContext(null),Zh=()=>{var t;return((t=v.useContext(pA))==null?void 0:t.id)||null},Xc=()=>v.useContext(mA);function Vo(t){return"data-floating-ui-"+t}function $t(t){t.current!==-1&&(clearTimeout(t.current),t.current=-1)}const Fg=Vo("safe-polygon");function Da(t,e,n){if(n&&!Af(n))return 0;if(typeof t=="number")return t;if(typeof t=="function"){const r=t();return typeof r=="number"?r:r==null?void 0:r[e]}return t==null?void 0:t[e]}function hu(t){return typeof t=="function"?t():t}function Kh(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,dataRef:o,events:i,elements:s}=t,{enabled:l=!0,delay:a=0,handleClose:c=null,mouseOnly:d=!1,restMs:u=0,move:f=!0}=e,h=Xc(),p=Zh(),m=Pn(c),g=Pn(a),y=Pn(n),w=Pn(u),k=v.useRef(),x=v.useRef(-1),C=v.useRef(),E=v.useRef(-1),S=v.useRef(!0),M=v.useRef(!1),N=v.useRef(()=>{}),A=v.useRef(!1),R=zt(()=>{var L;const O=(L=o.current.openEvent)==null?void 0:L.type;return(O==null?void 0:O.includes("mouse"))&&O!=="mousedown"});v.useEffect(()=>{if(!l)return;function L(O){let{open:V}=O;V||($t(x),$t(E),S.current=!0,A.current=!1)}return i.on("openchange",L),()=>{i.off("openchange",L)}},[l,i]),v.useEffect(()=>{if(!l||!m.current||!n)return;function L(V){R()&&r(!1,V,"hover")}const O=Mt(s.floating).documentElement;return O.addEventListener("mouseleave",L),()=>{O.removeEventListener("mouseleave",L)}},[s.floating,n,r,l,m,R]);const P=v.useCallback(function(L,O,V){O===void 0&&(O=!0),V===void 0&&(V="hover");const U=Da(g.current,"close",k.current);U&&!C.current?($t(x),x.current=window.setTimeout(()=>r(!1,L,V),U)):O&&($t(x),r(!1,L,V))},[g,r]),D=zt(()=>{N.current(),C.current=void 0}),T=zt(()=>{if(M.current){const L=Mt(s.floating).body;L.style.pointerEvents="",L.removeAttribute(Fg),M.current=!1}}),_=zt(()=>o.current.openEvent?["click","mousedown"].includes(o.current.openEvent.type):!1);v.useEffect(()=>{if(!l)return;function L(Z){if($t(x),S.current=!1,d&&!Af(k.current)||hu(w.current)>0&&!Da(g.current,"open"))return;const z=Da(g.current,"open",k.current);z?x.current=window.setTimeout(()=>{y.current||r(!0,Z,"hover")},z):n||r(!0,Z,"hover")}function O(Z){if(_()){T();return}N.current();const z=Mt(s.floating);if($t(E),A.current=!1,m.current&&o.current.floatingContext){n||$t(x),C.current=m.current({...o.current.floatingContext,tree:h,x:Z.clientX,y:Z.clientY,onClose(){T(),D(),_()||P(Z,!0,"safe-polygon")}});const se=C.current;z.addEventListener("mousemove",se),N.current=()=>{z.removeEventListener("mousemove",se)};return}(k.current==="touch"?!Ct(s.floating,Z.relatedTarget):!0)&&P(Z)}function V(Z){_()||o.current.floatingContext&&(m.current==null||m.current({...o.current.floatingContext,tree:h,x:Z.clientX,y:Z.clientY,onClose(){T(),D(),_()||P(Z)}})(Z))}function U(){$t(x)}function re(Z){_()||P(Z,!1)}if(Be(s.domReference)){const Z=s.domReference,z=s.floating;return n&&Z.addEventListener("mouseleave",V),f&&Z.addEventListener("mousemove",L,{once:!0}),Z.addEventListener("mouseenter",L),Z.addEventListener("mouseleave",O),z&&(z.addEventListener("mouseleave",V),z.addEventListener("mouseenter",U),z.addEventListener("mouseleave",re)),()=>{n&&Z.removeEventListener("mouseleave",V),f&&Z.removeEventListener("mousemove",L),Z.removeEventListener("mouseenter",L),Z.removeEventListener("mouseleave",O),z&&(z.removeEventListener("mouseleave",V),z.removeEventListener("mouseenter",U),z.removeEventListener("mouseleave",re))}}},[s,l,t,d,f,P,D,T,r,n,y,h,g,m,o,_,w]),Qe(()=>{var L;if(l&&n&&(L=m.current)!=null&&(L=L.__options)!=null&&L.blockPointerEvents&&R()){M.current=!0;const V=s.floating;if(Be(s.domReference)&&V){var O;const U=Mt(s.floating).body;U.setAttribute(Fg,"");const re=s.domReference,Z=h==null||(O=h.nodesRef.current.find(z=>z.id===p))==null||(O=O.context)==null?void 0:O.elements.floating;return Z&&(Z.style.pointerEvents=""),U.style.pointerEvents="none",re.style.pointerEvents="auto",V.style.pointerEvents="auto",()=>{U.style.pointerEvents="",re.style.pointerEvents="",V.style.pointerEvents=""}}}},[l,n,p,s,h,m,R]),Qe(()=>{n||(k.current=void 0,A.current=!1,D(),T())},[n,D,T]),v.useEffect(()=>()=>{D(),$t(x),$t(E),T()},[l,s.domReference,D,T]);const F=v.useMemo(()=>{function L(O){k.current=O.pointerType}return{onPointerDown:L,onPointerEnter:L,onMouseMove(O){const{nativeEvent:V}=O;function U(){!S.current&&!y.current&&r(!0,V,"hover")}d&&!Af(k.current)||n||hu(w.current)===0||A.current&&O.movementX**2+O.movementY**2<2||($t(E),k.current==="touch"?U():(A.current=!0,E.current=window.setTimeout(U,hu(w.current))))}}},[d,r,n,y,w]);return v.useMemo(()=>l?{reference:F}:{},[l,F])}const Nf=()=>{},sv=v.createContext({delay:0,initialDelay:0,timeoutMs:0,currentId:null,setCurrentId:Nf,setState:Nf,isInstantPhase:!1}),gA=()=>v.useContext(sv);function bA(t){const{children:e,delay:n,timeoutMs:r=0}=t,[o,i]=v.useReducer((a,c)=>({...a,...c}),{delay:n,timeoutMs:r,initialDelay:n,currentId:null,isInstantPhase:!1}),s=v.useRef(null),l=v.useCallback(a=>{i({currentId:a})},[]);return Qe(()=>{o.currentId?s.current===null?s.current=o.currentId:o.isInstantPhase||i({isInstantPhase:!0}):(o.isInstantPhase&&i({isInstantPhase:!1}),s.current=null)},[o.currentId,o.isInstantPhase]),b.jsx(sv.Provider,{value:v.useMemo(()=>({...o,setState:i,setCurrentId:l}),[o,l]),children:e})}function yA(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,floatingId:o}=t,{id:i,enabled:s=!0}=e,l=i??o,a=gA(),{currentId:c,setCurrentId:d,initialDelay:u,setState:f,timeoutMs:h}=a;return Qe(()=>{s&&c&&(f({delay:{open:1,close:Da(u,"close")}}),c!==l&&r(!1))},[s,l,r,f,c,u]),Qe(()=>{function p(){r(!1),f({delay:u,currentId:null})}if(s&&c&&!n&&c===l){if(h){const m=window.setTimeout(p,h);return()=>{clearTimeout(m)}}p()}},[s,n,f,c,l,r,u,h]),Qe(()=>{s&&(d===Nf||!n||d(l))},[s,n,d,l]),a}let zg=0;function fi(t,e){e===void 0&&(e={});const{preventScroll:n=!1,cancelPrevious:r=!0,sync:o=!1}=e;r&&cancelAnimationFrame(zg);const i=()=>t==null?void 0:t.focus({preventScroll:n});o?i():zg=requestAnimationFrame(i)}function pu(t,e){if(!t||!e)return!1;const n=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(n&&Us(n)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function vA(t){return"composedPath"in t?t.composedPath()[0]:t.target}function wA(t){return(t==null?void 0:t.ownerDocument)||document}const Ei={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function Ug(t){return t==="inert"?Ei.inert:t==="aria-hidden"?Ei["aria-hidden"]:Ei.none}let na=new WeakSet,ra={},mu=0;const kA=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype;function lv(t){return t?Us(t)?t.host:lv(t.parentNode):null}const xA=(t,e)=>e.map(n=>{if(t.contains(n))return n;const r=lv(n);return t.contains(r)?r:null}).filter(n=>n!=null);function CA(t,e,n,r){const o="data-floating-ui-inert",i=r?"inert":n?"aria-hidden":null,s=xA(e,t),l=new Set,a=new Set(s),c=[];ra[o]||(ra[o]=new WeakMap);const d=ra[o];s.forEach(u),f(e),l.clear();function u(h){!h||l.has(h)||(l.add(h),h.parentNode&&u(h.parentNode))}function f(h){!h||a.has(h)||[].forEach.call(h.children,p=>{if(mo(p)!=="script")if(l.has(p))f(p);else{const m=i?p.getAttribute(i):null,g=m!==null&&m!=="false",y=Ug(i),w=(y.get(p)||0)+1,k=(d.get(p)||0)+1;y.set(p,w),d.set(p,k),c.push(p),w===1&&g&&na.add(p),k===1&&p.setAttribute(o,""),!g&&i&&p.setAttribute(i,i==="inert"?"":"true")}})}return mu++,()=>{c.forEach(h=>{const p=Ug(i),g=(p.get(h)||0)-1,y=(d.get(h)||0)-1;p.set(h,g),d.set(h,y),g||(!na.has(h)&&i&&h.removeAttribute(i),na.delete(h)),y||h.removeAttribute(o)}),mu--,mu||(Ei.inert=new WeakMap,Ei["aria-hidden"]=new WeakMap,Ei.none=new WeakMap,na=new WeakSet,ra={})}}function Wg(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=wA(t[0]).body;return CA(t.concat(Array.from(r.querySelectorAll('[aria-live],[role="status"],output'))),r,e,n)}const Jh={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},ic=v.forwardRef(function(e,n){const[r,o]=v.useState();Qe(()=>{z1()&&o("button")},[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":r?void 0:!0,[Vo("focus-guard")]:"",style:Jh};return b.jsx("span",{...e,...i})}),SA={clipPath:"inset(50%)",position:"fixed",top:0,left:0},av=v.createContext(null),qg=Vo("portal");function EA(t){t===void 0&&(t={});const{id:e,root:n}=t,r=Gh(),o=cv(),[i,s]=v.useState(null),l=v.useRef(null);return Qe(()=>()=>{i==null||i.remove(),queueMicrotask(()=>{l.current=null})},[i]),Qe(()=>{if(!r||l.current)return;const a=e?document.getElementById(e):null;if(!a)return;const c=document.createElement("div");c.id=r,c.setAttribute(qg,""),a.appendChild(c),l.current=c,s(c)},[e,r]),Qe(()=>{if(n===null||!r||l.current)return;let a=n||(o==null?void 0:o.portalNode);a&&!Vh(a)&&(a=a.current),a=a||document.body;let c=null;e&&(c=document.createElement("div"),c.id=e,a.appendChild(c));const d=document.createElement("div");d.id=r,d.setAttribute(qg,""),a=c||a,a.appendChild(d),l.current=d,s(d)},[e,n,r,o]),i}function gu(t){const{children:e,id:n,root:r,preserveTabOrder:o=!0}=t,i=EA({id:n,root:r}),[s,l]=v.useState(null),a=v.useRef(null),c=v.useRef(null),d=v.useRef(null),u=v.useRef(null),f=s==null?void 0:s.modal,h=s==null?void 0:s.open,p=!!s&&!s.modal&&s.open&&o&&!!(r||i);return v.useEffect(()=>{if(!i||!o||f)return;function m(g){i&&Ds(g)&&(g.type==="focusin"?Ng:mT)(i)}return i.addEventListener("focusin",m,!0),i.addEventListener("focusout",m,!0),()=>{i.removeEventListener("focusin",m,!0),i.removeEventListener("focusout",m,!0)}},[i,o,f]),v.useEffect(()=>{i&&(h||Ng(i))},[h,i]),b.jsxs(av.Provider,{value:v.useMemo(()=>({preserveTabOrder:o,beforeOutsideRef:a,afterOutsideRef:c,beforeInsideRef:d,afterInsideRef:u,portalNode:i,setFocusManagerState:l}),[o,i]),children:[p&&i&&b.jsx(ic,{"data-type":"outside",ref:a,onFocus:m=>{if(Ds(m,i)){var g;(g=d.current)==null||g.focus()}else{const y=s?s.domReference:null,w=Z1(y);w==null||w.focus()}}}),p&&i&&b.jsx("span",{"aria-owns":i.id,style:SA}),i&&Dr.createPortal(e,i),p&&i&&b.jsx(ic,{"data-type":"outside",ref:c,onFocus:m=>{if(Ds(m,i)){var g;(g=u.current)==null||g.focus()}else{const y=s?s.domReference:null,w=G1(y);w==null||w.focus(),s!=null&&s.closeOnFocusOut&&(s==null||s.onOpenChange(!1,m.nativeEvent,"focus-out"))}}})]})}const cv=()=>v.useContext(av);function Gg(t){return v.useMemo(()=>e=>{t.forEach(n=>{n&&(n.current=e)})},t)}const Zg=20;let Jr=[];function Yh(){Jr=Jr.filter(t=>{var e;return(e=t.deref())==null?void 0:e.isConnected})}function MA(t){Yh(),t&&mo(t)!=="body"&&(Jr.push(new WeakRef(t)),Jr.length>Zg&&(Jr=Jr.slice(-Zg)))}function Kg(){Yh();const t=Jr[Jr.length-1];return t==null?void 0:t.deref()}function TA(t){const e=Tl();return V1(t,e)?t:Jc(t,e)[0]||t}function Jg(t,e){var n;if(!e.current.includes("floating")&&!((n=t.getAttribute("role"))!=null&&n.includes("dialog")))return;const r=Tl(),i=nT(t,r).filter(l=>{const a=l.getAttribute("data-tabindex")||"";return V1(l,r)||l.hasAttribute("data-tabindex")&&!a.startsWith("-")}),s=t.getAttribute("tabindex");e.current.includes("floating")||i.length===0?s!=="0"&&t.setAttribute("tabindex","0"):(s!=="-1"||t.hasAttribute("data-tabindex")&&t.getAttribute("data-tabindex")!=="-1")&&(t.setAttribute("tabindex","-1"),t.setAttribute("data-tabindex","-1"))}const AA=v.forwardRef(function(e,n){return b.jsx("button",{...e,type:"button",ref:n,tabIndex:-1,style:Jh})});function NA(t){const{context:e,children:n,disabled:r=!1,order:o=["content"],guards:i=!0,initialFocus:s=0,returnFocus:l=!0,restoreFocus:a=!1,modal:c=!0,visuallyHiddenDismiss:d=!1,closeOnFocusOut:u=!0,outsideElementsInert:f=!1,getInsideElements:h=()=>[]}=t,{open:p,onOpenChange:m,events:g,dataRef:y,elements:{domReference:w,floating:k}}=e,x=zt(()=>{var H;return(H=y.current.floatingContext)==null?void 0:H.nodeId}),C=zt(h),E=typeof s=="number"&&s<0,S=Tg(w)&&E,M=kA(),N=M?i:!0,A=!N||M&&f,R=Pn(o),P=Pn(s),D=Pn(l),T=Xc(),_=cv(),F=v.useRef(null),L=v.useRef(null),O=v.useRef(!1),V=v.useRef(!1),U=v.useRef(-1),re=v.useRef(-1),Z=_!=null,z=Tf(k),ie=zt(function(H){return H===void 0&&(H=z),H?Jc(H,Tl()):[]}),se=zt(H=>{const Q=ie(H);return R.current.map(J=>w&&J==="reference"?w:z&&J==="floating"?z:Q).filter(Boolean).flat()});v.useEffect(()=>{if(r||!c)return;function H(J){if(J.key==="Tab"){Ct(z,qr(Mt(z)))&&ie().length===0&&!S&&du(J);const ke=se(),Ee=kr(J);R.current[0]==="reference"&&Ee===w&&(du(J),J.shiftKey?fi(ke[ke.length-1]):fi(ke[1])),R.current[1]==="floating"&&Ee===z&&J.shiftKey&&(du(J),fi(ke[0]))}}const Q=Mt(z);return Q.addEventListener("keydown",H),()=>{Q.removeEventListener("keydown",H)}},[r,w,z,c,R,S,ie,se]),v.useEffect(()=>{if(r||!k)return;function H(Q){const J=kr(Q),Ee=ie().indexOf(J);Ee!==-1&&(U.current=Ee)}return k.addEventListener("focusin",H),()=>{k.removeEventListener("focusin",H)}},[r,k,ie]),v.useEffect(()=>{if(r||!u)return;function H(){V.current=!0,setTimeout(()=>{V.current=!1})}function Q(Ee){const le=Ee.relatedTarget,ot=Ee.currentTarget,it=kr(Ee);queueMicrotask(()=>{const ze=x(),Xt=!(Ct(w,le)||Ct(k,le)||Ct(le,k)||Ct(_==null?void 0:_.portalNode,le)||le!=null&&le.hasAttribute(Vo("focus-guard"))||T&&(Ci(T.nodesRef.current,ze).find(hn=>{var Ft,Te;return Ct((Ft=hn.context)==null?void 0:Ft.elements.floating,le)||Ct((Te=hn.context)==null?void 0:Te.elements.domReference,le)})||Ag(T.nodesRef.current,ze).find(hn=>{var Ft,Te,ea;return[(Ft=hn.context)==null?void 0:Ft.elements.floating,Tf((Te=hn.context)==null?void 0:Te.elements.floating)].includes(le)||((ea=hn.context)==null?void 0:ea.elements.domReference)===le})));if(ot===w&&z&&Jg(z,R),a&&ot!==w&&!(it!=null&&it.isConnected)&&qr(Mt(z))===Mt(z).body){yt(z)&&z.focus();const hn=U.current,Ft=ie(),Te=Ft[hn]||Ft[Ft.length-1]||z;yt(Te)&&Te.focus()}if(y.current.insideReactTree){y.current.insideReactTree=!1;return}(S||!c)&&le&&Xt&&!V.current&&le!==Kg()&&(O.current=!0,m(!1,Ee,"focus-out"))})}const J=!!(!T&&_);function ke(){$t(re),y.current.insideReactTree=!0,re.current=window.setTimeout(()=>{y.current.insideReactTree=!1})}if(k&&yt(w))return w.addEventListener("focusout",Q),w.addEventListener("pointerdown",H),k.addEventListener("focusout",Q),J&&k.addEventListener("focusout",ke,!0),()=>{w.removeEventListener("focusout",Q),w.removeEventListener("pointerdown",H),k.removeEventListener("focusout",Q),J&&k.removeEventListener("focusout",ke,!0)}},[r,w,k,z,c,T,_,m,u,a,ie,S,x,R,y]);const we=v.useRef(null),ye=v.useRef(null),me=Gg([we,_==null?void 0:_.beforeInsideRef]),fe=Gg([ye,_==null?void 0:_.afterInsideRef]);v.useEffect(()=>{var H,Q;if(r||!k)return;const J=Array.from((_==null||(H=_.portalNode)==null?void 0:H.querySelectorAll("["+Vo("portal")+"]"))||[]),Ee=(Q=(T?Ag(T.nodesRef.current,x()):[]).find(it=>{var ze;return Tg(((ze=it.context)==null?void 0:ze.elements.domReference)||null)}))==null||(Q=Q.context)==null?void 0:Q.elements.domReference,le=[k,Ee,...J,...C(),F.current,L.current,we.current,ye.current,_==null?void 0:_.beforeOutsideRef.current,_==null?void 0:_.afterOutsideRef.current,R.current.includes("reference")||S?w:null].filter(it=>it!=null),ot=c||S?Wg(le,!A,A):Wg(le);return()=>{ot()}},[r,w,k,c,R,_,S,N,A,T,x,C]),Qe(()=>{if(r||!yt(z))return;const H=Mt(z),Q=qr(H);queueMicrotask(()=>{const J=se(z),ke=P.current,Ee=(typeof ke=="number"?J[ke]:ke.current)||z,le=Ct(z,Q);!E&&!le&&p&&fi(Ee,{preventScroll:Ee===z})})},[r,p,z,E,se,P]),Qe(()=>{if(r||!z)return;const H=Mt(z),Q=qr(H);MA(Q);function J(le){let{reason:ot,event:it,nested:ze}=le;if(["hover","safe-polygon"].includes(ot)&&it.type==="mouseleave"&&(O.current=!0),ot==="outside-press")if(ze)O.current=!1;else if(aT(it)||cT(it))O.current=!1;else{let Xt=!1;document.createElement("div").focus({get preventScroll(){return Xt=!0,!1}}),Xt?O.current=!1:O.current=!0}}g.on("openchange",J);const ke=H.createElement("span");ke.setAttribute("tabindex","-1"),ke.setAttribute("aria-hidden","true"),Object.assign(ke.style,Jh),Z&&w&&w.insertAdjacentElement("afterend",ke);function Ee(){if(typeof D.current=="boolean"){const le=w||Kg();return le&&le.isConnected?le:ke}return D.current.current||ke}return()=>{g.off("openchange",J);const le=qr(H),ot=Ct(k,le)||T&&Ci(T.nodesRef.current,x(),!1).some(ze=>{var Xt;return Ct((Xt=ze.context)==null?void 0:Xt.elements.floating,le)}),it=Ee();queueMicrotask(()=>{const ze=TA(it);D.current&&!O.current&&yt(ze)&&(!(ze!==le&&le!==H.body)||ot)&&ze.focus({preventScroll:!0}),ke.remove()})}},[r,k,z,D,y,g,T,Z,w,x]),v.useEffect(()=>(queueMicrotask(()=>{O.current=!1}),()=>{queueMicrotask(Yh)}),[r]),Qe(()=>{if(!r&&_)return _.setFocusManagerState({modal:c,closeOnFocusOut:u,open:p,onOpenChange:m,domReference:w}),()=>{_.setFocusManagerState(null)}},[r,_,c,p,m,u,w]),Qe(()=>{r||z&&Jg(z,R)},[r,z,R]);function Pe(H){return r||!d||!c?null:b.jsx(AA,{ref:H==="start"?F:L,onClick:Q=>m(!1,Q.nativeEvent),children:typeof d=="string"?d:"Dismiss"})}const $e=!r&&N&&(c?!S:!0)&&(Z||c);return b.jsxs(b.Fragment,{children:[$e&&b.jsx(ic,{"data-type":"inside",ref:me,onFocus:H=>{if(c){const J=se();fi(o[0]==="reference"?J[0]:J[J.length-1])}else if(_!=null&&_.preserveTabOrder&&_.portalNode)if(O.current=!1,Ds(H,_.portalNode)){const J=G1(w);J==null||J.focus()}else{var Q;(Q=_.beforeOutsideRef.current)==null||Q.focus()}}}),!S&&Pe("start"),n,Pe("end"),$e&&b.jsx(ic,{"data-type":"inside",ref:fe,onFocus:H=>{if(c)fi(se()[0]);else if(_!=null&&_.preserveTabOrder&&_.portalNode)if(u&&(O.current=!0),Ds(H,_.portalNode)){const J=Z1(w);J==null||J.focus()}else{var Q;(Q=_.afterOutsideRef.current)==null||Q.focus()}}})]})}const RA={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},IA={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},Yg=t=>{var e,n;return{escapeKey:typeof t=="boolean"?t:(e=t==null?void 0:t.escapeKey)!=null?e:!1,outsidePress:typeof t=="boolean"?t:(n=t==null?void 0:t.outsidePress)!=null?n:!0}};function dv(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,elements:o,dataRef:i}=t,{enabled:s=!0,escapeKey:l=!0,outsidePress:a=!0,outsidePressEvent:c="pointerdown",referencePress:d=!1,referencePressEvent:u="pointerdown",ancestorScroll:f=!1,bubbles:h,capture:p}=e,m=Xc(),g=zt(typeof a=="function"?a:()=>!1),y=typeof a=="function"?g:a,w=v.useRef(!1),{escapeKey:k,outsidePress:x}=Yg(h),{escapeKey:C,outsidePress:E}=Yg(p),S=v.useRef(!1),M=zt(T=>{var _;if(!n||!s||!l||T.key!=="Escape"||S.current)return;const F=(_=i.current.floatingContext)==null?void 0:_.nodeId,L=m?Ci(m.nodesRef.current,F):[];if(!k&&(T.stopPropagation(),L.length>0)){let O=!0;if(L.forEach(V=>{var U;if((U=V.context)!=null&&U.open&&!V.context.dataRef.current.__escapeKeyBubbles){O=!1;return}}),!O)return}r(!1,lT(T)?T.nativeEvent:T,"escape-key")}),N=zt(T=>{var _;const F=()=>{var L;M(T),(L=kr(T))==null||L.removeEventListener("keydown",F)};(_=kr(T))==null||_.addEventListener("keydown",F)}),A=zt(T=>{var _;const F=i.current.insideReactTree;i.current.insideReactTree=!1;const L=w.current;if(w.current=!1,c==="click"&&L||F||typeof y=="function"&&!y(T))return;const O=kr(T),V="["+Vo("inert")+"]",U=Mt(o.floating).querySelectorAll(V);let re=Be(O)?O:null;for(;re&&!Er(re);){const se=_r(re);if(Er(se)||!Be(se))break;re=se}if(U.length&&Be(O)&&!iT(O)&&!Ct(O,o.floating)&&Array.from(U).every(se=>!Ct(re,se)))return;if(yt(O)&&D){const se=Er(O),we=Mn(O),ye=/auto|scroll/,me=se||ye.test(we.overflowX),fe=se||ye.test(we.overflowY),Pe=me&&O.clientWidth>0&&O.scrollWidth>O.clientWidth,$e=fe&&O.clientHeight>0&&O.scrollHeight>O.clientHeight,H=we.direction==="rtl",Q=$e&&(H?T.offsetX<=O.offsetWidth-O.clientWidth:T.offsetX>O.clientWidth),J=Pe&&T.offsetY>O.clientHeight;if(Q||J)return}const Z=(_=i.current.floatingContext)==null?void 0:_.nodeId,z=m&&Ci(m.nodesRef.current,Z).some(se=>{var we;return cu(T,(we=se.context)==null?void 0:we.elements.floating)});if(cu(T,o.floating)||cu(T,o.domReference)||z)return;const ie=m?Ci(m.nodesRef.current,Z):[];if(ie.length>0){let se=!0;if(ie.forEach(we=>{var ye;if((ye=we.context)!=null&&ye.open&&!we.context.dataRef.current.__outsidePressBubbles){se=!1;return}}),!se)return}r(!1,T,"outside-press")}),R=zt(T=>{var _;const F=()=>{var L;A(T),(L=kr(T))==null||L.removeEventListener(c,F)};(_=kr(T))==null||_.addEventListener(c,F)});v.useEffect(()=>{if(!n||!s)return;i.current.__escapeKeyBubbles=k,i.current.__outsidePressBubbles=x;let T=-1;function _(U){r(!1,U,"ancestor-scroll")}function F(){window.clearTimeout(T),S.current=!0}function L(){T=window.setTimeout(()=>{S.current=!1},Zc()?5:0)}const O=Mt(o.floating);l&&(O.addEventListener("keydown",C?N:M,C),O.addEventListener("compositionstart",F),O.addEventListener("compositionend",L)),y&&O.addEventListener(c,E?R:A,E);let V=[];return f&&(Be(o.domReference)&&(V=Mr(o.domReference)),Be(o.floating)&&(V=V.concat(Mr(o.floating))),!Be(o.reference)&&o.reference&&o.reference.contextElement&&(V=V.concat(Mr(o.reference.contextElement)))),V=V.filter(U=>{var re;return U!==((re=O.defaultView)==null?void 0:re.visualViewport)}),V.forEach(U=>{U.addEventListener("scroll",_,{passive:!0})}),()=>{l&&(O.removeEventListener("keydown",C?N:M,C),O.removeEventListener("compositionstart",F),O.removeEventListener("compositionend",L)),y&&O.removeEventListener(c,E?R:A,E),V.forEach(U=>{U.removeEventListener("scroll",_)}),window.clearTimeout(T)}},[i,o,l,y,c,n,r,f,s,k,x,M,C,N,A,E,R]),v.useEffect(()=>{i.current.insideReactTree=!1},[i,y,c]);const P=v.useMemo(()=>({onKeyDown:M,...d&&{[RA[u]]:T=>{r(!1,T.nativeEvent,"reference-press")},...u!=="click"&&{onClick(T){r(!1,T.nativeEvent,"reference-press")}}}}),[M,r,d,u]),D=v.useMemo(()=>{function T(_){_.button===0&&(w.current=!0)}return{onKeyDown:M,onMouseDown:T,onMouseUp:T,[IA[c]]:()=>{i.current.insideReactTree=!0}}},[M,c,i]);return v.useMemo(()=>s?{reference:P,floating:D}:{},[s,P,D])}function OA(t){const{open:e=!1,onOpenChange:n,elements:r}=t,o=Gh(),i=v.useRef({}),[s]=v.useState(()=>hA()),l=Zh()!=null,[a,c]=v.useState(r.reference),d=zt((h,p,m)=>{i.current.openEvent=h?p:void 0,s.emit("openchange",{open:h,event:p,reason:m,nested:l}),n==null||n(h,p,m)}),u=v.useMemo(()=>({setPositionReference:c}),[]),f=v.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return v.useMemo(()=>({dataRef:i,open:e,onOpenChange:d,elements:f,events:s,floatingId:o,refs:u}),[e,d,f,s,o,u])}function Al(t){t===void 0&&(t={});const{nodeId:e}=t,n=OA({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,o=r.elements,[i,s]=v.useState(null),[l,a]=v.useState(null),d=(o==null?void 0:o.domReference)||i,u=v.useRef(null),f=Xc();Qe(()=>{d&&(u.current=d)},[d]);const h=rA({...t,elements:{...o,...l&&{reference:l}}}),p=v.useCallback(k=>{const x=Be(k)?{getBoundingClientRect:()=>k.getBoundingClientRect(),getClientRects:()=>k.getClientRects(),contextElement:k}:k;a(x),h.refs.setReference(x)},[h.refs]),m=v.useCallback(k=>{(Be(k)||k===null)&&(u.current=k,s(k)),(Be(h.refs.reference.current)||h.refs.reference.current===null||k!==null&&!Be(k))&&h.refs.setReference(k)},[h.refs]),g=v.useMemo(()=>({...h.refs,setReference:m,setPositionReference:p,domReference:u}),[h.refs,m,p]),y=v.useMemo(()=>({...h.elements,domReference:d}),[h.elements,d]),w=v.useMemo(()=>({...h,...r,refs:g,elements:y,nodeId:e}),[h,g,y,e,r]);return Qe(()=>{r.dataRef.current.floatingContext=w;const k=f==null?void 0:f.nodesRef.current.find(x=>x.id===e);k&&(k.context=w)}),v.useMemo(()=>({...h,context:w,refs:g,elements:y}),[h,g,y,w])}function bu(){return rT()&&z1()}function DA(t,e){e===void 0&&(e={});const{open:n,onOpenChange:r,events:o,dataRef:i,elements:s}=t,{enabled:l=!0,visibleOnly:a=!0}=e,c=v.useRef(!1),d=v.useRef(-1),u=v.useRef(!0);v.useEffect(()=>{if(!l)return;const h=qt(s.domReference);function p(){!n&&yt(s.domReference)&&s.domReference===qr(Mt(s.domReference))&&(c.current=!0)}function m(){u.current=!0}function g(){u.current=!1}return h.addEventListener("blur",p),bu()&&(h.addEventListener("keydown",m,!0),h.addEventListener("pointerdown",g,!0)),()=>{h.removeEventListener("blur",p),bu()&&(h.removeEventListener("keydown",m,!0),h.removeEventListener("pointerdown",g,!0))}},[s.domReference,n,l]),v.useEffect(()=>{if(!l)return;function h(p){let{reason:m}=p;(m==="reference-press"||m==="escape-key")&&(c.current=!0)}return o.on("openchange",h),()=>{o.off("openchange",h)}},[o,l]),v.useEffect(()=>()=>{$t(d)},[]);const f=v.useMemo(()=>({onMouseLeave(){c.current=!1},onFocus(h){if(c.current)return;const p=kr(h.nativeEvent);if(a&&Be(p)){if(bu()&&!h.relatedTarget){if(!u.current&&!W1(p))return}else if(!sT(p))return}r(!0,h.nativeEvent,"focus")},onBlur(h){c.current=!1;const p=h.relatedTarget,m=h.nativeEvent,g=Be(p)&&p.hasAttribute(Vo("focus-guard"))&&p.getAttribute("data-type")==="outside";d.current=window.setTimeout(()=>{var y;const w=qr(s.domReference?s.domReference.ownerDocument:document);!p&&w===s.domReference||Ct((y=i.current.floatingContext)==null?void 0:y.refs.floating.current,w)||Ct(s.domReference,w)||g||r(!1,m,"focus")})}}),[i,s.domReference,r,a]);return v.useMemo(()=>l?{reference:f}:{},[l,f])}function yu(t,e,n){const r=new Map,o=n==="item";let i=t;if(o&&t){const{[Bg]:s,[jg]:l,...a}=t;i=a}return{...n==="floating"&&{tabIndex:-1,[aA]:""},...i,...e.map(s=>{const l=s?s[n]:null;return typeof l=="function"?t?l(t):null:l}).concat(t).reduce((s,l)=>(l&&Object.entries(l).forEach(a=>{let[c,d]=a;if(!(o&&[Bg,jg].includes(c)))if(c.indexOf("on")===0){if(r.has(c)||r.set(c,[]),typeof d=="function"){var u;(u=r.get(c))==null||u.push(d),s[c]=function(){for(var f,h=arguments.length,p=new Array(h),m=0;m<h;m++)p[m]=arguments[m];return(f=r.get(c))==null?void 0:f.map(g=>g(...p)).find(g=>g!==void 0)}}}else s[c]=d}),s),{})}}function Xh(t){t===void 0&&(t=[]);const e=t.map(l=>l==null?void 0:l.reference),n=t.map(l=>l==null?void 0:l.floating),r=t.map(l=>l==null?void 0:l.item),o=v.useCallback(l=>yu(l,t,"reference"),e),i=v.useCallback(l=>yu(l,t,"floating"),n),s=v.useCallback(l=>yu(l,t,"item"),r);return v.useMemo(()=>({getReferenceProps:o,getFloatingProps:i,getItemProps:s}),[o,i,s])}const _A=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function PA(t,e){var n,r;e===void 0&&(e={});const{open:o,elements:i,floatingId:s}=t,{enabled:l=!0,role:a="dialog"}=e,c=Gh(),d=((n=i.domReference)==null?void 0:n.id)||c,u=v.useMemo(()=>{var w;return((w=Tf(i.floating))==null?void 0:w.id)||s},[i.floating,s]),f=(r=_A.get(a))!=null?r:a,p=Zh()!=null,m=v.useMemo(()=>f==="tooltip"||a==="label"?{["aria-"+(a==="label"?"labelledby":"describedby")]:o?u:void 0}:{"aria-expanded":o?"true":"false","aria-haspopup":f==="alertdialog"?"dialog":f,"aria-controls":o?u:void 0,...f==="listbox"&&{role:"combobox"},...f==="menu"&&{id:d},...f==="menu"&&p&&{role:"menuitem"},...a==="select"&&{"aria-autocomplete":"none"},...a==="combobox"&&{"aria-autocomplete":"list"}},[f,u,p,o,d,a]),g=v.useMemo(()=>{const w={id:u,...f&&{role:f}};return f==="tooltip"||a==="label"?w:{...w,...f==="menu"&&{"aria-labelledby":d}}},[f,u,d,a]),y=v.useCallback(w=>{let{active:k,selected:x}=w;const C={role:"option",...k&&{id:u+"-fui-option"}};switch(a){case"select":case"combobox":return{...C,"aria-selected":x}}return{}},[u,a]);return v.useMemo(()=>l?{reference:m,floating:g,item:y}:{},[l,m,g,y])}const Xg=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,n)=>(n?"-":"")+e.toLowerCase());function hi(t,e){return typeof t=="function"?t(e):t}function $A(t,e){const[n,r]=v.useState(t);return t&&!n&&r(!0),v.useEffect(()=>{if(!t&&n){const o=setTimeout(()=>r(!1),e);return()=>clearTimeout(o)}},[t,n,e]),n}function uv(t,e){e===void 0&&(e={});const{open:n,elements:{floating:r}}=t,{duration:o=250}=e,s=(typeof o=="number"?o:o.close)||0,[l,a]=v.useState("unmounted"),c=$A(n,s);return!c&&l==="close"&&a("unmounted"),Qe(()=>{if(r){if(n){a("initial");const d=requestAnimationFrame(()=>{Dr.flushSync(()=>{a("open")})});return()=>{cancelAnimationFrame(d)}}a("close")}},[n,r]),{isMounted:c,status:l}}function LA(t,e){e===void 0&&(e={});const{initial:n={opacity:0},open:r,close:o,common:i,duration:s=250}=e,l=t.placement,a=l.split("-")[0],c=v.useMemo(()=>({side:a,placement:l}),[a,l]),d=typeof s=="number",u=(d?s:s.open)||0,f=(d?s:s.close)||0,[h,p]=v.useState(()=>({...hi(i,c),...hi(n,c)})),{isMounted:m,status:g}=uv(t,{duration:s}),y=Pn(n),w=Pn(r),k=Pn(o),x=Pn(i);return Qe(()=>{const C=hi(y.current,c),E=hi(k.current,c),S=hi(x.current,c),M=hi(w.current,c)||Object.keys(C).reduce((N,A)=>(N[A]="",N),{});if(g==="initial"&&p(N=>({transitionProperty:N.transitionProperty,...S,...C})),g==="open"&&p({transitionProperty:Object.keys(M).map(Xg).join(","),transitionDuration:u+"ms",...S,...M}),g==="close"){const N=E||C;p({transitionProperty:Object.keys(N).map(Xg).join(","),transitionDuration:f+"ms",...S,...N})}},[f,k,y,w,x,u,g,c]),{isMounted:m,styles:h}}function fv(t,e,n){return n===void 0&&(n=!0),t.filter(o=>{var i;return o.parentId===e&&(!n||((i=o.context)==null?void 0:i.open))}).flatMap(o=>[o,...fv(t,o.id,n)])}function Qg(t,e){const[n,r]=t;let o=!1;const i=e.length;for(let s=0,l=i-1;s<i;l=s++){const[a,c]=e[s]||[0,0],[d,u]=e[l]||[0,0];c>=r!=u>=r&&n<=(d-a)*(r-c)/(u-c)+a&&(o=!o)}return o}function BA(t,e){return t[0]>=e.x&&t[0]<=e.x+e.width&&t[1]>=e.y&&t[1]<=e.y+e.height}function hv(t){t===void 0&&(t={});const{buffer:e=.5,blockPointerEvents:n=!1,requireIntent:r=!0}=t,o={current:-1};let i=!1,s=null,l=null,a=typeof performance<"u"?performance.now():0;function c(u,f){const h=performance.now(),p=h-a;if(s===null||l===null||p===0)return s=u,l=f,a=h,null;const m=u-s,g=f-l,w=Math.sqrt(m*m+g*g)/p;return s=u,l=f,a=h,w}const d=u=>{let{x:f,y:h,placement:p,elements:m,onClose:g,nodeId:y,tree:w}=u;return function(x){function C(){$t(o),g()}if($t(o),!m.domReference||!m.floating||p==null||f==null||h==null)return;const{clientX:E,clientY:S}=x,M=[E,S],N=vA(x),A=x.type==="mouseleave",R=pu(m.floating,N),P=pu(m.domReference,N),D=m.domReference.getBoundingClientRect(),T=m.floating.getBoundingClientRect(),_=p.split("-")[0],F=f>T.right-T.width/2,L=h>T.bottom-T.height/2,O=BA(M,D),V=T.width>D.width,U=T.height>D.height,re=(V?D:T).left,Z=(V?D:T).right,z=(U?D:T).top,ie=(U?D:T).bottom;if(R&&(i=!0,!A))return;if(P&&(i=!1),P&&!A){i=!0;return}if(A&&Be(x.relatedTarget)&&pu(m.floating,x.relatedTarget)||w&&fv(w.nodesRef.current,y).length)return;if(_==="top"&&h>=D.bottom-1||_==="bottom"&&h<=D.top+1||_==="left"&&f>=D.right-1||_==="right"&&f<=D.left+1)return C();let se=[];switch(_){case"top":se=[[re,D.top+1],[re,T.bottom-1],[Z,T.bottom-1],[Z,D.top+1]];break;case"bottom":se=[[re,T.top+1],[re,D.bottom-1],[Z,D.bottom-1],[Z,T.top+1]];break;case"left":se=[[T.right-1,ie],[T.right-1,z],[D.left+1,z],[D.left+1,ie]];break;case"right":se=[[D.right-1,ie],[D.right-1,z],[T.left+1,z],[T.left+1,ie]];break}function we(ye){let[me,fe]=ye;switch(_){case"top":{const Pe=[V?me+e/2:F?me+e*4:me-e*4,fe+e+1],$e=[V?me-e/2:F?me+e*4:me-e*4,fe+e+1],H=[[T.left,F||V?T.bottom-e:T.top],[T.right,F?V?T.bottom-e:T.top:T.bottom-e]];return[Pe,$e,...H]}case"bottom":{const Pe=[V?me+e/2:F?me+e*4:me-e*4,fe-e],$e=[V?me-e/2:F?me+e*4:me-e*4,fe-e],H=[[T.left,F||V?T.top+e:T.bottom],[T.right,F?V?T.top+e:T.bottom:T.top+e]];return[Pe,$e,...H]}case"left":{const Pe=[me+e+1,U?fe+e/2:L?fe+e*4:fe-e*4],$e=[me+e+1,U?fe-e/2:L?fe+e*4:fe-e*4];return[...[[L||U?T.right-e:T.left,T.top],[L?U?T.right-e:T.left:T.right-e,T.bottom]],Pe,$e]}case"right":{const Pe=[me-e,U?fe+e/2:L?fe+e*4:fe-e*4],$e=[me-e,U?fe-e/2:L?fe+e*4:fe-e*4],H=[[L||U?T.left+e:T.right,T.top],[L?U?T.left+e:T.right:T.left+e,T.bottom]];return[Pe,$e,...H]}}}if(!Qg([E,S],se)){if(i&&!O)return C();if(!A&&r){const ye=c(x.clientX,x.clientY);if(ye!==null&&ye<.1)return C()}Qg([E,S],we([f,h]))?!i&&r&&(o.current=window.setTimeout(C,40)):C()}}};return d.__options={blockPointerEvents:n},d}const Mi=new WeakMap,_a=new WeakMap,sc={current:[]};let vu=!1;const oa=new Set,eb=new Map;function pv(t){const e=Array.from(t).sort((n,r)=>n instanceof Ti&&n.options.deps.includes(r)?1:r instanceof Ti&&r.options.deps.includes(n)?-1:0);for(const n of e){if(sc.current.includes(n))continue;sc.current.push(n),n.recompute();const r=_a.get(n);if(r)for(const o of r){const i=Mi.get(o);i&&pv(i)}}}function jA(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function VA(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function HA(t){if(oa.add(t),!vu)try{for(vu=!0;oa.size>0;){const e=Array.from(oa);oa.clear();for(const n of e){const r=eb.get(n)??n.prevState;n.prevState=r,jA(n)}for(const n of e){const r=Mi.get(n);r&&(sc.current.push(n),pv(r))}for(const n of e){const r=Mi.get(n);if(r)for(const o of r)VA(o)}}}finally{vu=!1,sc.current=[],eb.clear()}}function FA(t){return typeof t=="function"}class Rf{constructor(e,n){this.listeners=new Set,this.subscribe=r=>{var o,i;this.listeners.add(r);const s=(i=(o=this.options)==null?void 0:o.onSubscribe)==null?void 0:i.call(o,r,this);return()=>{this.listeners.delete(r),s==null||s()}},this.prevState=e,this.state=e,this.options=n}setState(e){var n,r,o;this.prevState=this.state,(n=this.options)!=null&&n.updateFn?this.state=this.options.updateFn(this.prevState)(e):FA(e)?this.state=e(this.prevState):this.state=e,(o=(r=this.options)==null?void 0:r.onUpdate)==null||o.call(r),HA(this)}}class Ti{constructor(e){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const n=this.options.deps.length,r=new Array(n),o=new Array(n);for(let i=0;i<n;i++){const s=this.options.deps[i];r[i]=s.prevState,o[i]=s.state}return this.lastSeenDepValues=o,{prevDepVals:r,currDepVals:o,prevVal:this.prevState??void 0}},this.recompute=()=>{var n,r;this.prevState=this.state;const o=this.getDepVals();this.state=this.options.fn(o),(r=(n=this.options).onUpdate)==null||r.call(n)},this.checkIfRecalculationNeededDeeply=()=>{for(const i of this.options.deps)i instanceof Ti&&i.checkIfRecalculationNeededDeeply();let n=!1;const r=this.lastSeenDepValues,{currDepVals:o}=this.getDepVals();for(let i=0;i<o.length;i++)if(o[i]!==r[i]){n=!0;break}n&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const n of this._subscriptions)n()}),this.subscribe=n=>{var r,o;this.listeners.add(n);const i=(o=(r=this.options).onSubscribe)==null?void 0:o.call(r,n,this);return()=>{this.listeners.delete(n),i==null||i()}},this.options=e,this.state=e.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(e=this.options.deps){for(const n of e)if(n instanceof Ti)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof Rf){let r=Mi.get(n);r||(r=new Set,Mi.set(n,r)),r.add(this);let o=_a.get(this);o||(o=new Set,_a.set(this,o)),o.add(n)}}unregisterFromGraph(e=this.options.deps){for(const n of e)if(n instanceof Ti)this.unregisterFromGraph(n.options.deps);else if(n instanceof Rf){const r=Mi.get(n);r&&r.delete(this);const o=_a.get(this);o&&o.delete(n)}}}function zA(t,e=n=>n){return R1.useSyncExternalStoreWithSelector(t.subscribe,()=>t.state,()=>t.state,e,UA)}function UA(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[r,o]of t)if(!e.has(r)||!Object.is(o,e.get(r)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const r of t)if(!e.has(r))return!1;return!0}if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();const n=tb(t);if(n.length!==tb(e).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(e,n[r])||!Object.is(t[n[r]],e[n[r]]))return!1;return!0}function tb(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}var If=Symbol("originalFactory");function ve(t){if(typeof t=="object"&&"key"in t)return function e(){return t[If]=e,t};if(typeof t!="function")throw Error("factory must be a function");return function e(n){return r=>{let o=t({editor:r.editor,options:n});return o[If]=e,o}}}function go(t,e){return new Rf(t,e)}function mt(t){this.content=t}mt.prototype={constructor:mt,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return o==-1?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new mt(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new mt(n)},addToStart:function(t,e){return new mt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new mt(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(i==-1?o.length:i,0,e,n),new mt(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=mt.from(t),t.size?new mt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=mt.from(t),t.size?new mt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=mt.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};mt.from=function(t){if(t instanceof mt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new mt(e)};function mv(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)n++;return a&&a<s.length&&a<l.length&&yv(s.charCodeAt(a-1))&&bv(s.charCodeAt(a))&&n--,n}if(o.content.size||i.content.size){let s=mv(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function gv(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let c=s.text,d=l.text,u=c.length,f=d.length;for(;u>0&&f>0&&c[u-1]==d[f-1];)u--,f--,n--,r--;return u&&f&&u<c.length&&yv(c.charCodeAt(u-1))&&bv(c.charCodeAt(u))&&(n++,r++),{a:n,b:r}}if(s.content.size||l.content.size){let c=gv(s.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}function bv(t){return t>=56320&&t<57344}function yv(t){return t>=55296&&t<56320}class I{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,i){for(let s=0,l=0;l<n;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new I(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let i=0,s=0;s<n;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new I(r,o)}cutByIndex(e,n){return e==n?I.empty:e==0&&n==this.content.length?this:new I(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new I(o,i)}addToStart(e){return new I([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new I(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return mv(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return gv(this,e,n,r)}findIndex(e){if(e==0)return ia(0,e);if(e==this.size)return ia(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),i=r+o.nodeSize;if(i>=e)return i==e?ia(n+1,i):ia(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return I.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return I.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return I.empty;let n,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(n||(n=e.slice(0,o)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new I(n||e,r)}static from(e){if(!e)return I.empty;if(e instanceof I)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new I([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}I.empty=new I([],0);const wu={index:0,offset:0};function ia(t,e){return wu.index=t,wu.offset=e,wu}function lc(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!lc(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!lc(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Oe=class Of{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&lc(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Of.none;if(e instanceof Of)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};Oe.none=[];class qs extends Error{}class j{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=wv(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new j(r,this.openStart,this.openEnd)}removeBetween(e,n){return new j(vv(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return j.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new j(I.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new j(e,r,o)}}j.empty=new j(I.empty,0,0);function vv(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(vv(i.content,e-o-1,n-o-1)))}function wv(t,e,n,r,o,i){let{index:s,offset:l}=t.findIndex(e),a=t.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=wv(a.content,e-l-1,n,s==0?r-1:0,s==t.childCount-1?o-1:0,a);return c&&t.replaceChild(s,a.copy(c))}function WA(t,e,n){if(n.openStart>t.depth)throw new qs("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new qs("Inconsistent open depths");return kv(t,e,n,0)}function kv(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=kv(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,l=s.content;return Oo(s,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=qA(n,t);return Oo(i,Cv(t,s,l,e,r))}else return Oo(i,ac(t,e,r))}function xv(t,e){if(!e.type.compatibleContent(t.type))throw new qs("Cannot join "+e.type.name+" onto "+t.type.name)}function Df(t,e,n){let r=t.node(n);return xv(r,e.node(n)),r}function Io(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ps(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Io(t.nodeAfter,r),i++));for(let l=i;l<s;l++)Io(o.child(l),r);e&&e.depth==n&&e.textOffset&&Io(e.nodeBefore,r)}function Oo(t,e){if(!t.type.validContent(e))throw new qs("Invalid content for node "+t.type.name);return t.copy(e)}function Cv(t,e,n,r,o){let i=t.depth>o&&Df(t,e,o+1),s=r.depth>o&&Df(n,r,o+1),l=[];return Ps(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(xv(i,s),Io(Oo(i,Cv(t,e,n,r,o+1)),l)):(i&&Io(Oo(i,ac(t,e,o+1)),l),Ps(e,n,o,l),s&&Io(Oo(s,ac(n,r,o+1)),l)),Ps(r,null,o,l),new I(l)}function ac(t,e,n){let r=[];if(Ps(null,t,n,r),t.depth>n){let o=Df(t,e,n+1);Io(Oo(o,ac(t,e,n+1)),r)}return Ps(e,null,n,r),new I(r)}function qA(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(I.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class Gs{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Oe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Zs(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new Gs(n,r,i)}static resolveCached(e,n){let r=nb.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else nb.set(e,r=new GA);let o=r.elts[r.i]=Gs.resolve(e,n);return r.i=(r.i+1)%ZA,o}}class GA{constructor(){this.elts=[],this.i=0}}const ZA=12,nb=new WeakMap;class Zs{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const KA=Object.create(null);let Tr=class _f{constructor(e,n,r,o=Oe.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||I.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&lc(this.attrs,n||e.defaultAttrs||KA)&&Oe.sameSet(this.marks,r||Oe.none)}copy(e=null){return e==this.content?this:new _f(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _f(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return j.empty;let o=this.resolve(e),i=this.resolve(n),s=r?0:o.sharedDepth(n),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new j(c,o.depth-s,i.depth-s)}replace(e,n,r){return WA(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return Gs.resolveCached(this,e)}resolveNoCache(e){return Gs.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),Sv(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=I.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Oe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Oe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=I.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};Tr.prototype.text=void 0;class cc extends Tr{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Sv(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new cc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cc(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Sv(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ho{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new JA(e,n);if(r.next==null)return Ho.empty;let o=Ev(r);r.next&&r.err("Unexpected trailing text");let i=rN(nN(o));return oN(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let i=n;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!n||a.validEnd))return I.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let f=i(u,l.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
11
+ `)}}Ho.empty=new Ho(!0);class JA{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ev(t){let e=[];do e.push(YA(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function YA(t){let e=[];do e.push(XA(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function XA(t){let e=tN(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=QA(t,e);else break;return e}function rb(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function QA(t,e){let n=rb(t),r=n;return t.eat(",")&&(t.next!="}"?r=rb(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function eN(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function tN(t){if(t.eat("(")){let e=Ev(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=eN(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nN(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=n();o(i(s.expr,a),d),a=d}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=n();r(a,d),o(i(s.expr,a),d),a=d}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Mv(t,e){return e-t}function ob(t,e){let n=[];return r(e),n.sort(Mv);function r(o){let i=t[o];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&n.indexOf(a)==-1&&r(a)}}}function rN(t){let e=Object.create(null);return n(ob(t,0));function n(r){let o=[];r.forEach(s=>{t[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);ob(t,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Ho(r.indexOf(t.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Mv);i.next.push({type:o[s][0],next:e[l.join(",")]||n(l)})}return i}}function oN(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Tv(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Av(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(o===void 0){let i=t[r];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function Nv(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let o in t)t[o].validate&&t[o].validate(e[o])}function Rv(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new sN(t,r,e[r]);return n}let ib=class Iv{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Rv(e,r.attrs),this.defaultAttrs=Tv(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==Ho.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:Av(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Tr(this,this.computeAttrs(e),I.from(n),Oe.setFrom(r))}createChecked(e=null,n,r){return n=I.from(n),this.checkContent(n),new Tr(this,this.computeAttrs(e),n,Oe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=I.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let o=this.contentMatch.matchFragment(n),i=o&&o.fillBefore(I.empty,!0);return i?new Tr(this,e,n.append(i),Oe.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Nv(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Oe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new Iv(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function iN(t,e,n){let r=n.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class sN{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?iN(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Qc{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Rv(e,o.attrs),this.excluded=null;let i=Tv(this.attrs);this.instance=i?new Oe(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Oe(this,Av(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Qc(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Nv(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Ov=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=mt.from(e.nodes),n.marks=mt.from(e.marks||{}),this.nodes=ib.compile(this.spec.nodes,this),this.marks=Qc.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Ho.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?sb(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:sb(this,s.split(" "))}this.nodeFromJSON=o=>Tr.fromJSON(this,o),this.markFromJSON=o=>Oe.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ib){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new cc(r,r.defaultAttrs,e,Oe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function sb(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function lN(t){return t.tag!=null}function aN(t){return t.style!=null}let wn=class Pf{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(lN(o))this.tags.push(o);else if(aN(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new ab(this,n,!1);return r.addAll(e,Oe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ab(this,n,!0);return r.addAll(e,Oe.none,n.from,n.to),j.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(uN(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<n.length;s++){let l=n[s];if((l.priority==null?50:l.priority)<i)break}n.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=cb(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=cb(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pf(e,Pf.schemaRules(e)))}};const Dv={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},cN={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},_v={ol:!0,ul:!0},Ks=1,$f=2,$s=4;function lb(t,e,n){return e!=null?(e?Ks:0)|(e==="full"?$f:0):t&&t.whitespace=="pre"?Ks|$f:n&~$s}class sa{constructor(e,n,r,o,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=Oe.none,this.match=i||(s&$s?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(I.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ks)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=I.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(I.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Dv.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ab{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,i,s=lb(null,n.preserveWhitespace,0)|(r?$s:0);o?i=new sa(o.type,o.attrs,Oe.none,!0,n.topMatch||o.type.contentMatch,s):r?i=new sa(null,null,Oe.none,!0,null,s):i=new sa(e.schema.topNodeType,null,Oe.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,i=o.options&$f?"full":this.localPreserveWS||(o.options&Ks)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
12
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(s.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;_v.hasOwnProperty(s)&&this.parser.normalizeLists&&dN(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:cN.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Dv.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=a&&a.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
13
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,o){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)n=this.enterInner(o[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=Oe.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):db(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,o){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,o)),i}enterInner(e,n,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=lb(e,i,s.options);s.options&$s&&s.content.length==0&&(l|=$s);let a=Oe.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):db(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new sa(e,n,a,o,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Ks)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function dN(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&_v.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function uN(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cb(t){let e={};for(let n in t)e[n]=t[n];return e}function db(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&s(d))return!0}};if(s(o.contentMatch))return!0}}class cn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=la(n).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,n);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){if(e.isText)return la(n).createTextNode(e.text);let{dom:r,contentDOM:o}=Pa(la(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Pa(la(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return typeof n=="string"?{dom:e.createTextNode(n)}:Pa(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new cn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ub(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ub(e.marks)}}function ub(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function la(t){return t.document||window.document}const fb=new WeakMap;function fN(t){let e=fb.get(t);return e===void 0&&fb.set(t,e=hN(t)),e}function hN(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function Pa(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=fN(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(n=o.slice(0,s),o=o.slice(s+1));let l,a=n?t.createElementNS(n,o):t.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(t.createTextNode(f));else{let{dom:h,contentDOM:p}=Pa(t,f,n,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Pv=65535,$v=Math.pow(2,16);function pN(t,e){return t+e*$v}function hb(t){return t&Pv}function mN(t){return(t-(t&Pv))/$v}const Lv=1,Bv=2,$a=4,jv=8;class Lf{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&jv)>0}get deletedBefore(){return(this.delInfo&(Lv|$a))>0}get deletedAfter(){return(this.delInfo&(Bv|$a))>0}get deletedAcross(){return(this.delInfo&$a)>0}}class on{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&on.empty)return on.empty}recover(e){let n=0,r=hb(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+mN(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:n:n,h=a+o+(f<0?0:d);if(r)return h;let p=e==(n<0?a:u)?null:pN(l/3,e-a),m=e==a?Bv:e==u?Lv:$a;return(n<0?e!=a:e!=u)&&(m|=jv),new Lf(h,m,p)}o+=d-c}return r?e+o:new Lf(e+o,0,null)}touches(e,n){let r=0,o=hb(n),i=this.inverted?2:1,s=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+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+n],d=this.ranges[o+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new on(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?on.empty:new on(e<0?[0,-e,0]:[0,0,e])}}on.empty=new on([]);class Vi{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Vi(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new Vi;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Lf(e,o,null)}}const ku=Object.create(null);class Ot{getMap(){return on.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ku[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ku)throw new RangeError("Duplicate use of step JSON ID "+e);return ku[e]=n,n.prototype.jsonID=e,n}}class et{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new et(e,null)}static fail(e){return new et(null,e)}static fromReplace(e,n,r,o){try{return et.ok(e.replace(n,r,o))}catch(i){if(i instanceof qs)return et.fail(i.message);throw i}}}function Qh(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(Qh(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return I.fromArray(r)}class Yr extends Ot{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new j(Qh(n.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return et.fromReplace(e,this.from,this.to,i)}invert(){return new $n(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Yr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Yr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Yr(n.from,n.to,e.markFromJSON(n.mark))}}Ot.jsonID("addMark",Yr);class $n extends Ot{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new j(Qh(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return et.fromReplace(e,this.from,this.to,r)}invert(){return new Yr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new $n(n.pos,r.pos,this.mark)}merge(e){return e instanceof $n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new $n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new $n(n.from,n.to,e.markFromJSON(n.mark))}}Ot.jsonID("removeMark",$n);class Xr extends Ot{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return et.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return et.fromReplace(e,this.pos,this.pos+1,new j(I.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new Xr(this.pos,n.marks[o]);return new Xr(this.pos,this.mark)}}return new Fo(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Xr(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Xr(n.pos,e.markFromJSON(n.mark))}}Ot.jsonID("addNodeMark",Xr);class Fo extends Ot{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return et.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return et.fromReplace(e,this.pos,this.pos+1,new j(I.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Xr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Fo(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Fo(n.pos,e.markFromJSON(n.mark))}}Ot.jsonID("removeNodeMark",Fo);class Ke extends Ot{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&Bf(e,this.from,this.to)?et.fail("Structure replace would overwrite content"):et.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new on([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ke(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Ke.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Ke(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ke)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?j.empty:new j(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ke(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?j.empty:new j(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ke(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ke(n.from,n.to,j.fromJSON(e,n.slice),!!n.structure)}}Ke.MAP_BIAS=1;Ot.jsonID("replace",Ke);class Ye extends Ot{constructor(e,n,r,o,i,s,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Bf(e,this.from,this.gapFrom)||Bf(e,this.gapTo,this.to)))return et.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return et.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?et.fromReplace(e,this.from,this.to,r):et.fail("Content does not fit in gap")}getMap(){return new on([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ye(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||i>r.pos?null:new Ye(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ye(n.from,n.to,n.gapFrom,n.gapTo,j.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ot.jsonID("replaceAround",Ye);function Bf(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function gN(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(s&&s.to==f&&s.mark.eq(u[m])?s.to=h:o.push(s=new $n(f,h,u[m])));l&&l.to==f?l.to=h:i.push(l=new Yr(f,h,r))}}),o.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function bN(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Qc){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,n);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==i-1&&u.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=i):o.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>t.step(new $n(s.from,s.to,s.style)))}function ep(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new Ke(l,d,j.empty));else{r=u;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new $n(l,d,c.marks[f]));if(o&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new j(I.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),s.push(new Ke(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(I.empty,!0);t.replace(l,l,new j(a,0,0))}for(let a=s.length-1;a>=0;a--)t.step(s[a])}function yN(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function oi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,i=0;;--r){let s=t.$from.node(r),l=t.$from.index(r)+o,a=t.$to.indexAfter(r)-i;if(r<t.depth&&s.canReplace(l,a,n))return r;if(r==0||s.type.spec.isolating||!yN(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function vN(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,d=I.empty,u=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,d=I.from(r.node(p).copy(d)),u++):a--;let f=I.empty,h=0;for(let p=i,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=I.from(o.node(p).copy(f)),h++):c++;t.step(new Ye(a,c,s,l,new j(d.append(f),u,h),d.size-u,!0))}function Vv(t,e,n=null,r=t){let o=wN(t,e),i=o&&kN(r,e);return i?o.map(pb).concat({type:e,attrs:n}).concat(i.map(pb)):null}function pb(t){return{type:t,attrs:null}}function wN(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}function kN(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:s}function xN(t,e,n){let r=I.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let l=n[s].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=I.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new Ye(o,i,o,i,new j(r,0,0),n.length,!0))}function CN(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&SN(t.doc,t.mapping.slice(i).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&&Fv(t,s,l,i),ep(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return t.step(new Ye(u,f,u+1,f-1,new j(I.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Hv(t,s,l,i),!1}})}function Hv(t,e,n,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Fv(t,e,n,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
14
+ `))}})}function SN(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function EN(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ye(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new j(I.from(s),0,0),1,!0))}function Ar(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=n-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function MN(t,e,n=1,r){let o=t.doc.resolve(e),i=I.empty,s=I.empty;for(let l=o.depth,a=o.depth-n,c=n-1;l>a;l--,c--){i=I.from(o.node(l).copy(i));let d=r&&r[c];s=I.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}t.step(new Ke(e,e,new j(i.append(s),n,n),!0))}function bo(t,e){let n=t.resolve(e),r=n.index();return zv(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function TN(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function zv(t,e){return!!(t&&e&&!t.isLeaf&&TN(t,e))}function ed(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):n>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&zv(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function AN(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,i=t.doc.resolve(e-n),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Fv(t,d.node(),d.before(),l)}s.inlineContent&&ep(t,e+n-1,s,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Ke(c,a.map(e+n,-1),j.empty,!0)),r===!0){let d=t.doc.resolve(c);Hv(t,d.node(),d.before(),t.steps.length)}return t}function NN(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Uv(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let i=0;i<n.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function td(t,e,n=e,r=j.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return Wv(o,i,r)?new Ke(e,n,r):new RN(o,i,r).fit()}function Wv(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class RN{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=I.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=I.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new j(i,s,l);return e>-1?new Ye(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Ke(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=xu(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(s?c.matchType(s.type)||(u=c.fillBefore(I.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=xu(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new j(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=xu(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new j(Ms(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new j(Ms(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(qv(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ts(this.placed,n,I.from(d)),this.frontier[n].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?j.empty:new j(Ms(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new j(Ms(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Cu(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),s=Cu(e,n,o,r,i);if(s){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Cu(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ts(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Ts(this.placed,this.depth,I.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(I.empty,!0);n.childCount&&(this.placed=Ts(this.placed,this.frontier.length,n))}}function Ms(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ms(t.firstChild.content,e-1,n)))}function Ts(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ts(t.lastChild.content,e-1,n)))}function xu(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function qv(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,qv(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(I.empty,!0)))),t.copy(r)}function Cu(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!IN(n,i.content,s)?l:null}function IN(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ON(t){return t.spec.defining||t.spec.definingForContent}function DN(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if(Wv(o,i,r))return t.step(new Ke(e,n,r));let s=Zv(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=ON(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],y=!0;g<0&&(y=!1,g=-g);let w=o.node(g-1),k=o.index(g-1);if(w.canReplaceWith(k,k,p.type,p.marks))return t.replace(o.before(g),y?i.after(g):n,new j(Gv(r.content,0,r.openStart,h),h,r.openEnd))}}let u=t.steps.length;for(let f=s.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>u));f--){let h=s[f];h<0||(e=o.before(h),n=i.after(h))}}function Gv(t,e,n,r,o){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Gv(i.content,e+1,n,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(I.empty,!0))}return t}function _N(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=NN(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new j(I.from(r),0,0))}function PN(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(n),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.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=o.depth;a>0&&n==o.start(a);a--)n=o.before(a);r=t.doc.resolve(e),o=t.doc.resolve(n)}}let i=Zv(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return t.delete(r.before(s),n);t.delete(e,n)}function Zv(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(i<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class Ai extends Ot{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return et.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return et.fromReplace(e,this.pos,this.pos+1,new j(I.from(o),0,n.isLeaf?0:1))}getMap(){return on.empty}invert(e){return new Ai(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ai(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ai(n.pos,n.attr,n.value)}}Ot.jsonID("attr",Ai);class Js extends Ot{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return et.ok(r)}getMap(){return on.empty}invert(e){return new Js(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Js(n.attr,n.value)}}Ot.jsonID("docAttr",Js);let Hi=class extends Error{};Hi=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Hi.prototype=Object.create(Error.prototype);Hi.prototype.constructor=Hi;Hi.prototype.name="TransformError";class tp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Vi}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Hi(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),n=o.map(n,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=j.empty){let o=td(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new j(I.from(r),0,0))}delete(e,n){return this.replace(e,n,j.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return DN(this,e,n,r),this}replaceRangeWith(e,n,r){return _N(this,e,n,r),this}deleteRange(e,n){return PN(this,e,n),this}lift(e,n){return vN(this,e,n),this}join(e,n=1){return AN(this,e,n),this}wrap(e,n){return xN(this,e,n),this}setBlockType(e,n=e,r,o=null){return CN(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return EN(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Ai(e,n,r)),this}setDocAttribute(e,n){return this.step(new Js(e,n)),this}addNodeMark(e,n){return this.step(new Xr(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Oe)n.isInSet(r.marks)&&this.step(new Fo(e,n));else{let o=r.marks,i,s=[];for(;i=n.isInSet(o);)s.push(new Fo(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,n=1,r){return MN(this,e,n,r),this}addMark(e,n,r){return gN(this,e,n,r),this}removeMark(e,n,r){return bN(this,e,n,r),this}clearIncompatible(e,n,r){return ep(this,e,n,r),this}}const Su=Object.create(null);class ee{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Kv(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=j.empty){let r=n.content.lastChild,o=null;for(let l=0;l<n.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?j.empty:n),l==0&&bb(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),bb(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new W(e):yi(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=n<0?yi(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):yi(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Gt(e.node(0))}static atStart(e){return yi(e,e,0,0,1)||new Gt(e)}static atEnd(e){return yi(e,e,e.content.size,e.childCount,-1)||new Gt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Su[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Su)throw new RangeError("Duplicate use of selection JSON ID "+e);return Su[e]=n,n.prototype.jsonID=e,n}getBookmark(){return W.between(this.$anchor,this.$head).getBookmark()}}ee.prototype.visible=!0;class Kv{constructor(e,n){this.$from=e,this.$to=n}}let mb=!1;function gb(t){!mb&&!t.parent.inlineContent&&(mb=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class W extends ee{constructor(e,n=e){gb(e),gb(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ee.near(r);let o=e.resolve(n.map(this.anchor));return new W(o.parent.inlineContent?o:r,r)}replace(e,n=j.empty){if(super.replace(e,n),n==j.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof W&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new nd(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new W(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new W(e,n)}}ee.jsonID("text",W);class nd{constructor(e,n){this.anchor=e,this.head=n}map(e){return new nd(e.map(this.anchor),e.map(this.head))}resolve(e){return W.between(e.resolve(this.anchor),e.resolve(this.head))}}class G extends ee{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),i=e.resolve(o);return r?ee.near(i):new G(i)}content(){return new j(I.from(this.node),0,0)}eq(e){return e instanceof G&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new np(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new G(e.resolve(n.anchor))}static create(e,n){return new G(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}G.prototype.visible=!1;ee.jsonID("node",G);class np{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new nd(r,r):new np(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&G.isSelectable(r)?new G(n):ee.near(n)}}class Gt extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=j.empty){if(n==j.empty){e.delete(0,e.doc.content.size);let r=ee.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Gt(e)}map(e){return new Gt(e)}eq(e){return e instanceof Gt}getBookmark(){return $N}}ee.jsonID("all",Gt);const $N={map(){return this},resolve(t){return new Gt(t)}};function yi(t,e,n,r,o,i=!1){if(e.inlineContent)return W.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&G.isSelectable(l))return G.create(t,n-(o<0?l.nodeSize:0))}else{let a=yi(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function bb(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof Ke||o instanceof Ye))return;let i=t.mapping.maps[r],s;i.forEach((l,a,c,d)=>{s==null&&(s=d)}),t.setSelection(ee.near(t.doc.resolve(s),n))}const yb=1,aa=2,vb=4;let LN=class extends tp{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|yb)&~aa,this.storedMarks=null,this}get selectionSet(){return(this.updated&yb)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=aa,this}ensureMarks(e){return Oe.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&aa)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~aa,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Oe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ee.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=vb,this}get scrolledIntoView(){return(this.updated&vb)>0}};function wb(t,e){return!e||!t?t:t.bind(e)}class As{constructor(e,n,r){this.name=e,this.init=wb(n.init,r),this.apply=wb(n.apply,r)}}const BN=[new As("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new As("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new As("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new As("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Eu{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=BN.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new As(r.key,r.spec.state,r))})}}class ki{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,d=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<s?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),i=!0}o&&(o[s]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ki(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new LN(this)}static create(e){let n=new Eu(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ki(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new Eu(this.schema,e.plugins),r=n.fields,o=new ki(n);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Eu(e.schema,e.plugins),i=new ki(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Tr.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=ee.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=c.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function Jv(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Jv(o,e,{})),n[r]=o}return n}class ae{constructor(e){this.spec=e,this.props={},e.props&&Jv(e.props,this,this.props),this.key=e.key?e.key.key:Yv("plugin")}getState(e){return e[this.key]}}const Mu=Object.create(null);function Yv(t){return t in Mu?t+"$"+ ++Mu[t]:(Mu[t]=0,t+"$")}class Ce{constructor(e="key"){this.key=Yv(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Xv=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Qv(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const ew=(t,e,n)=>{let r=Qv(t,n);if(!r)return!1;let o=rp(r);if(!o){let s=r.blockRange(),l=s&&oi(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(cw(t,o,e,-1))return!0;if(r.parent.content.size==0&&(Fi(i,"end")||G.isSelectable(i)))for(let s=r.depth;;s--){let l=td(t.doc,r.before(s),r.after(s),j.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Fi(i,"end")?ee.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):G.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},jN=(t,e,n)=>{let r=Qv(t,n);if(!r)return!1;let o=rp(r);return o?tw(t,o,e):!1},VN=(t,e,n)=>{let r=rw(t,n);if(!r)return!1;let o=op(r);return o?tw(t,o,e):!1};function tw(t,e,n){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=td(t.doc,i,a,j.empty);if(!c||c.from!=i||c instanceof Ke&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(W.create(d.doc,i)),n(d.scrollIntoView())}return!0}function Fi(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const nw=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=rp(r)}let s=i&&i.nodeBefore;return!s||!G.isSelectable(s)?!1:(e&&e(t.tr.setSelection(G.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function rp(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function rw(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ow=(t,e,n)=>{let r=rw(t,n);if(!r)return!1;let o=op(r);if(!o)return!1;let i=o.nodeAfter;if(cw(t,o,e,1))return!0;if(r.parent.content.size==0&&(Fi(i,"start")||G.isSelectable(i))){let s=td(t.doc,r.before(),r.after(),j.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=t.tr.step(s);l.setSelection(Fi(i,"start")?ee.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):G.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},iw=(t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=op(r)}let s=i&&i.nodeAfter;return!s||!G.isSelectable(s)?!1:(e&&e(t.tr.setSelection(G.create(t.doc,i.pos)).scrollIntoView()),!0)};function op(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const HN=(t,e)=>{let n=t.selection,r=n instanceof G,o;if(r){if(n.node.isTextblock||!bo(t.doc,n.from))return!1;o=n.from}else if(o=ed(t.doc,n.from,-1),o==null)return!1;if(e){let i=t.tr.join(o);r&&i.setSelection(G.create(i.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},FN=(t,e)=>{let n=t.selection,r;if(n instanceof G){if(n.node.isTextblock||!bo(t.doc,n.to))return!1;r=n.to}else if(r=ed(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},zN=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&oi(o);return i==null?!1:(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)},sw=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
15
+ `).scrollIntoView()),!0)};function ip(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const UN=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=ip(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(ee.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},lw=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof Gt||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=ip(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=t.tr.insert(s,i.createAndFill());l.setSelection(W.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},aw=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ar(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),o=r&&oi(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function WN(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof G&&e.selection.node.isBlock)return!r.parentOffset||!Ar(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,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=ip(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),i.unshift(a&&l?{type:l}:null),s=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof W||e.selection instanceof Gt)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=Ar(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=Ar(d.doc,u,i.length,i)),!f)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(s).type!=l){let h=d.mapping.map(r.before(s)),p=d.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return n&&n(d.scrollIntoView()),!0}}const qN=WN(),GN=(t,e)=>{let{$from:n,to:r}=t.selection,o,i=n.sharedDepth(r);return i==0?!1:(o=n.before(i),e&&e(t.tr.setSelection(G.create(t.doc,o))),!0)};function ZN(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||bo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function cw(t,e,n,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&ZN(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(n){let h=e.pos+i.nodeSize,p=I.empty;for(let y=s.length-1;y>=0;y--)p=I.from(s[y].create(null,p));p=I.from(o.copy(p));let m=t.tr.step(new Ye(e.pos-1,h,e.pos,h,new j(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&bo(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:ee.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&oi(u);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(u,f).scrollIntoView()),!0;if(c&&Fi(i,"start",!0)&&Fi(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let y=I.empty;for(let k=p.length-1;k>=0;k--)y=I.from(p[k].copy(y));let w=t.tr.step(new Ye(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new j(y,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function dw(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(n&&n(e.tr.setSelection(W.create(e.doc,t<0?o.start(i):o.end(i)))),!0):!1}}const KN=dw(-1),JN=dw(1);function YN(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Vv(s,t,e);return l?(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0):!1}}function kb(t,e=null){return function(n,r){let o=!1;for(let i=0;i<n.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)o=!0;else{let d=n.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,t)}})}if(!o)return!1;if(r){let i=n.tr;for(let s=0;s<n.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[s];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function sp(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}sp(Xv,ew,nw);sp(Xv,ow,iw);sp(sw,lw,aw,qN);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function XN(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return QN(l,s,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function QN(t,e,n,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Zs(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Zs(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=Vv(i,n,r,e);return l?(t&&eR(t,e,l,o,n),!0):!1}function eR(t,e,n,r,o){let i=I.empty;for(let d=n.length-1;d>=0;d--)i=I.from(n[d].type.create(n[d].attrs,i));t.step(new Ye(e.start-(r?2:0),e.end,e.start,e.end,new j(i,0,0),n.length,!0));let s=0;for(let d=0;d<n.length;d++)n[d].type==o&&(s=d+1);let l=n.length-s,a=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&Ar(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return t}function tR(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&s.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?nR(e,n,t,i):rR(e,n,i):!0:!1}}function nR(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new Ye(i-1,s,i,s,new j(I.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Zs(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const l=oi(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(i,-1)-1);return bo(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function rR(t,e,n){let r=t.tr,o=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?I.empty:I.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new Ye(u-(l?1:0),f+(a?1:0),u+1,f-1,new j((l?I.empty:I.from(o.copy(I.empty))).append(a?I.empty:I.from(o.copy(I.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function oR(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,d=I.from(c?t.create():null),u=new j(I.from(t.create(null,I.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;n(e.tr.step(new Ye(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}const bt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},zi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let jf=null;const wr=function(t,e,n){let r=jf||(jf=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},iR=function(){jf=null},zo=function(t,e,n,r){return n&&(xb(t,e,n,r,-1)||xb(t,e,n,r,1))},sR=/^(img|br|input|textarea|hr)$/i;function xb(t,e,n,r,o){for(var i;;){if(t==n&&e==r)return!0;if(e==(o<0?0:gn(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Nl(t)||sR.test(t.nodeName)||t.contentEditable=="false")return!1;e=bt(t)+(o<0?0:1),t=s}else if(t.nodeType==1){let s=t.childNodes[e+(o<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else t=s,e=o<0?gn(t):0}else return!1}}function gn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function lR(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=gn(t)}else if(t.parentNode&&!Nl(t))e=bt(t),t=t.parentNode;else return null}}function aR(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Nl(t))e=bt(t)+1,t=t.parentNode;else return null}}function cR(t,e,n){for(let r=e==0,o=e==gn(t);r||o;){if(t==n)return!0;let i=bt(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==gn(t)}}function Nl(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const rd=function(t){return t.focusNode&&zo(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Eo(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function dR(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function uR(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(gn(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(gn(r.startContainer),r.startOffset)}}}const lr=typeof navigator<"u"?navigator:null,Cb=typeof document<"u"?document:null,yo=lr&&lr.userAgent||"",Vf=/Edge\/(\d+)/.exec(yo),uw=/MSIE \d/.exec(yo),Hf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yo),Zt=!!(uw||Hf||Vf),to=uw?document.documentMode:Hf?+Hf[1]:Vf?+Vf[1]:0,kn=!Zt&&/gecko\/(\d+)/i.test(yo);kn&&+(/Firefox\/(\d+)/.exec(yo)||[0,0])[1];const Ff=!Zt&&/Chrome\/(\d+)/.exec(yo),at=!!Ff,fw=Ff?+Ff[1]:0,Nt=!Zt&&!!lr&&/Apple Computer/.test(lr.vendor),Ui=Nt&&(/Mobile\/\w+/.test(yo)||!!lr&&lr.maxTouchPoints>2),mn=Ui||(lr?/Mac/.test(lr.platform):!1),hw=lr?/Win/.test(lr.platform):!1,xr=/Android \d/.test(yo),Rl=!!Cb&&"webkitFontSmoothing"in Cb.documentElement.style,fR=Rl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hR(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function gr(t,e){return typeof t=="number"?t:t[e]}function pR(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Sb(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;){if(s.nodeType!=1){s=zi(s);continue}let l=s,a=l==i.body,c=a?hR(i):pR(l),d=0,u=0;if(e.top<c.top+gr(r,"top")?u=-(c.top-e.top+gr(o,"top")):e.bottom>c.bottom-gr(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+gr(o,"top")-c.top:e.bottom-c.bottom+gr(o,"bottom")),e.left<c.left+gr(r,"left")?d=-(c.left-e.left+gr(o,"left")):e.right>c.right-gr(r,"right")&&(d=e.right-c.right+gr(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:zi(s)}}function mR(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=t.root.elementFromPoint(i,s);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:pw(t.dom)}}function pw(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=zi(r));return e}function gR({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;mw(n,r==0?0:r-e)}function mw(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let pi=null;function bR(t){if(t.setActive)return t.setActive();if(pi)return t.focus(pi);let e=pw(t);t.focus(pi==null?{get preventScroll(){return pi={preventScroll:!0},!0}}:void 0),pi||(pi=!1,mw(e,0))}function gw(t,e){let n,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let d=t.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=wr(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=d,r=m,o=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&a&&(n=a,o=c,r=0),n&&n.nodeType==3?yR(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:gw(n,o)}function yR(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=Fr(r,1);if(s.top!=s.bottom&&lp(e,s)){o={node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function lp(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function vR(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function wR(t,e,n){let{node:r,offset:o}=gw(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&n.left>(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function kR(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function bw(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let s=t.childNodes[i];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(lp(e,c))return bw(s,e,c)}}if((i=(i+1)%r)==o)break}return t}function xR(t,e){let n=t.dom.ownerDocument,r,o=0,i=uR(n,e.left,e.top);i&&({node:r,offset:o}=i);let s=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!s||!t.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=t.dom.getBoundingClientRect();if(!lp(e,c)||(s=bw(t.dom,e,c),!s))return null}if(Nt)for(let c=s;r&&c;c=zi(c))c.draggable&&(r=void 0);if(s=vR(s,e),r){if(kn&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Rl&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=kR(t,r,o,e))}l==null&&(l=wR(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Eb(t){return t.top<t.bottom||t.left<t.right}function Fr(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Eb(r))return r}return Array.prototype.find.call(n,Eb)||t.getBoundingClientRect()}const CR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function yw(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Rl||kn;if(r.nodeType==3)if(s&&(CR.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let a=Fr(wr(r,o,o),n);if(kn&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Fr(wr(r,o-1,o-1),-1);if(c.top==a.top){let d=Fr(wr(r,o,o+1),-1);if(d.top!=a.top)return vs(d,d.left<c.left)}}return a}else{let a=o,c=o,d=n<0?1:-1;return n<0&&!o?(c++,d=-1):n>=0&&o==r.nodeValue.length?(a--,d=1):n<0?a--:c++,vs(Fr(wr(r,a,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==gn(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Tu(a.getBoundingClientRect(),!1)}if(i==null&&o<gn(r)){let a=r.childNodes[o];if(a.nodeType==1)return Tu(a.getBoundingClientRect(),!0)}return Tu(r.getBoundingClientRect(),n>=0)}if(i==null&&o&&(n<0||o==gn(r))){let a=r.childNodes[o-1],c=a.nodeType==3?wr(a,gn(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return vs(Fr(c,1),!1)}if(i==null&&o<gn(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?wr(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return vs(Fr(c,-1),!0)}return vs(Fr(r.nodeType==3?wr(r):r,-n),n>=0)}function vs(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Tu(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function vw(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function SR(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return vw(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=yw(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=wr(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(n=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const ER=/[\u0590-\u08ac]/;function MR(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return l?!ER.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:vw(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let Mb=null,Tb=null,Ab=!1;function TR(t,e,n){return Mb==e&&Tb==n?Ab:(Mb=e,Tb=n,Ab=n=="up"||n=="down"?SR(t,e,n):MR(t,e,n))}const xn=0,Nb=1,Ao=2,ar=3;class Il{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=xn,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>bt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e||s instanceof kw){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof ww&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?bt(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?bt(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let d=s+a.border;if(e>=d&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=bt(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||l==this.children.length-1)){n=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=bt(u.dom);break}n+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let i=Math.min(e,n),s=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(i>p&&s<g)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((kn||Nt)&&e==n){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
16
+ `),u&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:bt(g)+1});break}let y=m.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let m=h.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(kn&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||u&&Nt)&&zo(l.node,l.offset,d.anchorNode,d.anchorOffset)&&zo(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(u&&kn)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>n){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let i=this.children[o],s=r+i.size;if(r==s?e<=s&&n>=r:e<s&&n>r){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Ao:Nb,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ar:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ao:ar}r=s}this.dirty=Ao}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ao:Nb;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ww extends Il{constructor(e,n,r,o){let i,s=n.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==xn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class AR extends Il{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Uo extends Il{constructor(e,n,r,o,i){super(e,[],r,o),this.mark=n,this.spec=i}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=cn.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Uo(e,n,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ar||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ar&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=xn){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=xn}}slice(e,n,r){let o=Uo.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;n<s&&(i=Uf(i,n,s,r)),e>0&&(i=Uf(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class no extends Il{constructor(e,n,r,o,i,s,l,a,c){super(e,[],i,s),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,n,r,o,i,s){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=cn.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Sw(d,r,n),c?a=new NR(e,n,r,o,d,u||null,f,c,i,s+1):n.isText?new od(e,n,r,o,d,f,i):new no(e,n,r,o,d,u||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>I.empty)}return e}matchesNode(e,n,r){return this.dirty==xn&&e.eq(this.node)&&dc(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new IR(this,s&&s.node,e);_R(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Oe.none:this.node.child(d).marks,r,e,d),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e,f);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(h=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ao)&&(s&&this.protectLocalComposition(e,s),xw(this.contentDOM,this.children,e),Ui&&PR(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof W)||r<n||o>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=$R(this.node.content,s,r-n,o-n);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new AR(this,i,n,o);e.input.compositionNodes.push(s),this.children=Uf(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==ar||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=xn}updateOuterDeco(e){if(dc(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Cw(this.dom,this.nodeDOM,zf(this.outerDeco,this.node,n),zf(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Rb(t,e,n,r,o){Sw(r,e,t);let i=new no(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class od extends no{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==ar||this.dirty!=xn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=xn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=xn,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new od(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ar)}get domAtom(){return!1}isText(e){return this.node.text==e}}class kw extends Il{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class NR extends no{constructor(e,n,r,o,i,s,l,a,c,d){super(e,n,r,o,i,s,l,c,d),this.spec=a}update(e,n,r,o){if(this.dirty==ar)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function xw(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==t){for(;l!=r;)r=Ib(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(l,r);if(s instanceof Uo){let a=r?r.previousSibling:t.lastChild;xw(s.contentDOM,s.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Ib(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const Ls=function(t){t&&(this.nodeName=t)};Ls.prototype=Object.create(null);const No=[new Ls];function zf(t,e,n){if(t.length==0)return No;let r=n?No[0]:new Ls,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new Ls(s.nodeName));for(let l in s){let a=s[l];a!=null&&(n&&o.length==1&&o.push(r=new Ls(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Cw(t,e,n,r){if(n==No&&r==No)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=n[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=t&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=No[0]),o=a}RR(o,l||No[0],s)}return o}function RR(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&t.classList.add(o[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function Sw(t,e,n){return Cw(t,t,No,zf(e,n,t.nodeType!=1))}function dc(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Ib(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class IR{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=OR(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=xn,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){a=d;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=Uo.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,o,i){let s=this.top.children[o];return s.dirty==ar&&s.dom==s.contentDOM&&(s.dirty=Ao),s.update(e,n,r,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof no){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=ar&&dc(n,a.outerDeco));if(!f&&a.update(e,n,r,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,n,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Ao,u.updateChildren(o,s+1),u.dirty=xn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,i,s){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!dc(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=no.create(this.top,n,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,o,i){let s=no.create(this.top,e,n,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new ww(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Uo;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof od)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Nt||at)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new kw(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function OR(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Uo)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function DR(t,e){return t.type.side-e.type.side}function _R(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,u;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(DR);for(let g=0;g<u.length;g++)n(u[g],c,!!a)}else n(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s<o.length&&o[s].from<g&&(g=o[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<p&&(a=f.cut(g-i),f=f.cut(0,g-i),p=g,h=-1)}else for(;s<o.length&&o[s].to<p;)s++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function PR(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function $R(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<t.childCount;){let c=t.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Uf(t,e,n,r,o){let i=[];for(let s=0,l=0;s<t.length;s++){let a=t[s],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(a.slice(n-c,a.size,r)))}return i}function ap(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(rd(n)){for(a=s;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&G.isSelectable(u)&&o.parent&&!(u.isInline&&cR(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new G(s==f?l:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=s,f=s;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);u=Math.min(u,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,s]=f==t.state.selection.anchor?[f,u]:[u,f],l=r.resolve(s)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=cp(t,d,l,u)}return c}function Ew(t){return t.editable?t.hasFocus():Tw(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Nr(t,e=!1){let n=t.state.selection;if(Mw(t,n),!Ew(t))return;let r=t.input.mouseDown;if(!e&&at&&r){let o=t.domSelectionRange(),i=t.domObserver.currentSelection;if(o.anchorNode&&i.anchorNode&&zo(o.anchorNode,o.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)BR(t);else{let{anchor:o,head:i}=n,s,l;Ob&&!(n instanceof W)&&(n.$from.parent.inlineContent||(s=Db(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Db(t,n.to))),t.docView.setSelection(o,i,t,e),Ob&&(s&&_b(s),l&&_b(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&LR(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Ob=Nt||at&&fw<63;function Db(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Nt&&o&&o.contentEditable=="false")return Au(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Au(o);if(i)return Au(i)}}function Au(t){return t.contentEditable="true",Nt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function _b(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function LR(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Ew(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function BR(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,bt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Zt&&to<=11&&(n.disabled=!0,n.disabled=!1)}function Mw(t,e){if(e instanceof G){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Pb(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Pb(t)}function Pb(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function cp(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||W.between(e,n,r)}function $b(t){return t.editable&&!t.hasFocus()?!1:Tw(t)}function Tw(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function jR(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return zo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Wf(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&ee.findFrom(i,e)}function zr(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Lb(t,e,n){let r=t.state.selection;if(r instanceof W)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return zr(t,new W(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=Wf(t.state,e);return o&&o instanceof G?zr(t,o):!1}else if(!(mn&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?G.isSelectable(i)?zr(t,new G(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):Rl?zr(t,new W(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof G&&r.node.isInline)return zr(t,new W(e>0?r.$to:r.$from));{let o=Wf(t.state,e);return o?zr(t,o):!1}}}function uc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Bs(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function mi(t,e){return e<0?VR(t):HR(t)}function VR(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(kn&&n.nodeType==1&&r<uc(n)&&Bs(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Bs(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Aw(n))break;{let l=n.previousSibling;for(;l&&Bs(l,-1);)o=n.parentNode,i=bt(l),l=l.previousSibling;if(l)n=l,r=uc(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?qf(t,n,r):o&&qf(t,o,i)}function HR(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=uc(n),i,s;for(;;)if(r<o){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Bs(l,1))i=n,s=++r;else break}else{if(Aw(n))break;{let l=n.nextSibling;for(;l&&Bs(l,1);)i=l.parentNode,s=bt(l)+1,l=l.nextSibling;if(l)n=l,r=0,o=uc(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}i&&qf(t,i,s)}function Aw(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function FR(t,e){for(;t&&e==t.childNodes.length&&!Nl(t);)e=bt(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function zR(t,e){for(;t&&!e&&!Nl(t);)e=bt(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function qf(t,e,n){if(e.nodeType!=3){let i,s;(s=FR(e,n))?(e=s,n=0):(i=zR(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(rd(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Nr(t)},50)}function Bb(t,e){let n=t.state.doc.resolve(e);if(!(at||hw)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),s=(i.top+i.bottom)/2;if(s>o.top&&s<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function jb(t,e,n){let r=t.state.selection;if(r instanceof W&&!r.empty||n.indexOf("s")>-1||mn&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Wf(t.state,e);if(s&&s instanceof G)return zr(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof Gt?ee.near(s,e):ee.findFrom(s,e);return l?zr(t,l):!1}return!1}function Vb(t,e){if(!(t.state.selection instanceof W))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function Hb(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function UR(t){if(!Nt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Hb(t,r,"true"),setTimeout(()=>Hb(t,r,"false"),20)}return!1}function WR(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function qR(t,e){let n=e.keyCode,r=WR(e);if(n==8||mn&&n==72&&r=="c")return Vb(t,-1)||mi(t,-1);if(n==46&&!e.shiftKey||mn&&n==68&&r=="c")return Vb(t,1)||mi(t,1);if(n==13||n==27)return!0;if(n==37||mn&&n==66&&r=="c"){let o=n==37?Bb(t,t.state.selection.from)=="ltr"?-1:1:-1;return Lb(t,o,r)||mi(t,o)}else if(n==39||mn&&n==70&&r=="c"){let o=n==39?Bb(t,t.state.selection.from)=="ltr"?1:-1:1;return Lb(t,o,r)||mi(t,o)}else{if(n==38||mn&&n==80&&r=="c")return jb(t,-1,r)||mi(t,-1);if(n==40||mn&&n==78&&r=="c")return UR(t)||jb(t,1,r)||mi(t,1);if(r==(mn?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function dp(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=t.someProp("clipboardSerializer")||cn.fromSchema(t.state.schema),l=_w(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Dw[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
17
+
18
+ `);return{dom:a,text:f,slice:e}}function Nw(t,e,n,r,o){let i=o.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,i||r,t)}),i)return l=new j(I.from(t.state.schema.text(e.replace(/\r\n?/g,`
19
+ `))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(u)l=u;else{let f=o.marks(),{schema:h}=t.state,p=cn.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),s=JR(n),Rl&&YR(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||wn.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!GR.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=XR(Fb(l,+d[1],+d[2]),d[4]);else if(l=j.maxOpen(ZR(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Fb(l,u,f)}return t.someProp("transformPasted",u=>{l=u(l,t,a)}),l}const GR=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function ZR(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),i,s=[];if(t.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Iw(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ow(s[s.length-1],i.length));let d=Rw(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return I.from(s)}return t}function Rw(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,I.from(t));return t}function Iw(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=Iw(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(I.from(Rw(n,t,o+1))))}}function Ow(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ow(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(I.empty,!0);return t.copy(n.append(r))}function Gf(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,l=s.content;return t.childCount>1&&(i=0),o<r-1&&(l=Gf(l,e,n,r,o+1,i)),o>=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(I.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function Fb(t,e,n){return e<t.openStart&&(t=new j(Gf(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new j(Gf(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Dw={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let zb=null;function _w(){return zb||(zb=document.implementation.createHTMLDocument("title"))}let Nu=null;function KR(t){let e=window.trustedTypes;return e?(Nu||(Nu=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Nu.createHTML(t)):t}function JR(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=_w().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&Dw[r[1].toLowerCase()])&&(t=o.map(i=>"<"+i+">").join("")+t+o.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=KR(t),o)for(let i=0;i<o.length;i++)n=n.querySelector(o[i])||n;return n}function YR(t){let e=t.querySelectorAll(at?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function XR(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=I.from(a.create(r[l+1],o)),i++,s++}return new j(o,i,s)}const Bt={},jt={},QR={touchstart:!0,touchmove:!0};class eI{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function tI(t){for(let e in Bt){let n=Bt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{rI(t,r)&&!up(t,r)&&(t.editable||!(r.type in jt))&&n(t,r)},QR[e]?{passive:!0}:void 0)}Nt&&t.dom.addEventListener("input",()=>null),Zf(t)}function Cr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function nI(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Zf(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>up(t,r))})}function up(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function rI(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function oI(t,e){!up(t,e)&&Bt[e.type]&&(t.editable||!(e.type in jt))&&Bt[e.type](t,e)}jt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Bw(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(xr&&at&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ui&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,Eo(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||qR(t,n)?n.preventDefault():Cr(t,"key")};jt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};jt.keypress=(t,e)=>{let n=e;if(Bw(t)||!n.charCode||n.ctrlKey&&!n.altKey||mn&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof W)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,o,i))&&t.dispatch(i()),n.preventDefault()}};function Ol(t){return{left:t.clientX,top:t.clientY}}function iI(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function fp(t,e,n,r,o){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(t.someProp(e,l=>s>i.depth?l(t,n,i.nodeAfter,i.before(s),o,!0):l(t,n,i.node(s),i.before(s),o,!1)))return!0;return!1}function Dl(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function sI(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&G.isSelectable(r)?(Dl(t,new G(n)),!0):!1}function lI(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof G&&(r=n.node);let i=t.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(G.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?o=i.before(n.$from.depth):o=i.before(s);break}}return o!=null?(Dl(t,G.create(t.state.doc,o)),!0):!1}function aI(t,e,n,r,o){return fp(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(o?lI(t,n):sI(t,n))}function cI(t,e,n,r){return fp(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function dI(t,e,n,r){return fp(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||uI(t,n,r)}function uI(t,e,n){if(n.button!=0)return!1;let r=Pw(t,e,!0),o=t.state.doc;return r?(Dl(t,r),r instanceof W&&o.eq(t.state.doc)&&(t.input.mouseDown=new hI(t,r)),!0):!1}function Pw(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?W.create(r,0,r.content.size):null;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)return W.create(r,l+1,l+1+s.content.size);if(n&&G.isSelectable(s))return G.create(r,l)}return null}function hp(t){return fc(t)}const $w=mn?"metaKey":"ctrlKey";Bt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=hp(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&iI(n,t.input.lastClick)&&!n[$w]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let s=t.posAtCoords(Ol(n));s&&(i=="singleClick"?t.input.mouseDown=new fI(t,s,n,!!r):(i=="doubleClick"?cI:dI)(t,s.pos,s.inside,n)?n.preventDefault():Cr(t,"pointer"))};class Lw{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class fI extends Lw{constructor(e,n,r,o){super(e),this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[$w],this.allowDefault=r.shiftKey;let i,s;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),s=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,s=d.depth?d.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof G&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&kn&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),Cr(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||Nr(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Ol(e))),this.updateAllowDefault(e),this.allowDefault||!n?Cr(this.view,"pointer"):aI(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Nt&&this.mightDrag&&!this.mightDrag.node.isAtom||at&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Dl(this.view,ee.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Cr(this.view,"pointer")}move(e){this.updateAllowDefault(e),Cr(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class hI extends Lw{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),Cr(this.view,"pointer");let n=this.view.posAtCoords(Ol(e)),r=n&&Pw(this.view,n.inside,!1);if(!r)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];Dl(this.view,W.create(o,s,l))}}Bt.touchstart=t=>{t.input.lastTouch=Date.now(),hp(t),Cr(t,"pointer")};Bt.touchmove=t=>{t.input.lastTouch=Date.now(),Cr(t,"pointer")};Bt.contextmenu=t=>hp(t);function Bw(t,e){return t.composing?!0:Nt&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const pI=xr?5e3:-1;jt.compositionstart=jt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof W&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||at&&hw&&mI(t)))t.markCursor=t.state.storedMarks||n.marks(),fc(t,!0),t.markCursor=null;else if(fc(t,!e.selection.empty),kn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=t.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}t.input.composing=!0}jw(t,pI)};function mI(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}jt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,jw(t,20))};function jw(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>fc(t),e))}function Vw(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function gI(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=lR(e.focusNode,e.focusOffset),r=aR(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function fc(t,e=!1){if(!(xr&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Vw(t),e||t.docView&&t.docView.dirty){let n=ap(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function bI(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Ys=Zt&&to<15||Ui&&fR<604;Bt.copy=jt.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let i=Ys?null:n.clipboardData,s=r.content(),{dom:l,text:a}=dp(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):bI(t,l),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yI(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function vI(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Xs(t,r.value,null,o,e):Xs(t,r.textContent,r.innerHTML,o,e)},50)}function Xs(t,e,n,r,o){let i=Nw(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,o,i||j.empty)))return!0;if(!i)return!1;let s=yI(i),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Hw(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}jt.paste=(t,e)=>{let n=e;if(t.composing&&!xr)return;let r=Ys?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Xs(t,Hw(r),r.getData("text/html"),o,n)?n.preventDefault():vI(t,n)};class Fw{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const wI=mn?"altKey":"ctrlKey";function zw(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[wI]}Bt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,i=o.empty?null:t.posAtCoords(Ol(n)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof G?o.to-1:o.to))){if(r&&r.mightDrag)s=G.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(s=G.create(t.state.doc,u.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:c,slice:d}=dp(t,l);(!n.dataTransfer.files.length||!at||fw>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ys?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ys||n.dataTransfer.setData("text/plain",c),t.dragging=new Fw(d,zw(t,n),s)};Bt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};jt.dragover=jt.dragenter=(t,e)=>e.preventDefault();jt.drop=(t,e)=>{try{kI(t,e,t.dragging)}finally{t.dragging=null}};function kI(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ol(e));if(!r)return;let o=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",h=>{i=h(i,t,!1)}):i=Nw(t,Hw(e.dataTransfer),Ys?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(n&&zw(t,e));if(t.someProp("handleDrop",h=>h(t,e,i||j.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Uv(t.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=t.state.tr;if(s){let{node:h}=n;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(u))return;let f=a.doc.resolve(c);if(d&&G.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new G(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,g,y)=>h=y),a.setSelection(cp(t,f,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Bt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Nr(t)},20))};Bt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Bt.beforeinput=(t,e)=>{if(at&&xr&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Eo(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in jt)Bt[t]=jt[t];function Qs(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class hc{constructor(e,n){this.toDOM=e,this.spec=n||Do,this.side=this.spec.side||0}map(e,n,r,o){let{pos:i,deleted:s}=e.mapResult(n.from+o,this.side<0?-1:1);return s?null:new Me(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof hc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Qs(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ro{constructor(e,n){this.attrs=e,this.spec=n||Do}map(e,n,r,o){let i=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new Me(i,s,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ro&&Qs(this.attrs,e.attrs)&&Qs(this.spec,e.spec)}static is(e){return e.type instanceof ro}destroy(){}}class pp{constructor(e,n){this.attrs=e,this.spec=n||Do}map(e,n,r,o){let i=e.mapResult(n.from+o,1);if(i.deleted)return null;let s=e.mapResult(n.to+o,-1);return s.deleted||s.pos<=i.pos?null:new Me(i.pos-r,s.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),i;return o==n.from&&!(i=e.child(r)).isText&&o+i.nodeSize==n.to}eq(e){return this==e||e instanceof pp&&Qs(this.attrs,e.attrs)&&Qs(this.spec,e.spec)}destroy(){}}class Me{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Me(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Me(e,e,new hc(n,r))}static inline(e,n,r,o){return new Me(e,n,new ro(r,o))}static node(e,n,r,o){return new Me(e,n,new pp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof ro}get widget(){return this.type instanceof hc}}const vi=[],Do={};class he{constructor(e,n){this.local=e.length?e:vi,this.children=n.length?n:vi}static create(e,n){return n.length?pc(n,e,0,Do):St}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<n&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,o+l,i)}}map(e,n,r){return this==St||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Do)}mapInner(e,n,r,o,i){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(n,a)?(s||(s=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?xI(this.children,s||[],e,n,r,o,i):s?new he(s.sort(_o),vi):St}add(e,n){return n.length?this==St?he.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Ww(n,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,pc(d,l,c+1,Do)),i+=3}});let s=Uw(i?qw(n):n,-r);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new he(s.length?this.local.concat(s).sort(_o):this.local,o||this.children)}remove(e){return e.length==0||this==St?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+n,a=r[i+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=St?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,n)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new he(o,r):St}forChild(e,n){if(this==St)return this;if(n.isLeaf)return he.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>i&&a.type instanceof ro){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new he(o.sort(_o),vi);return r?new Gr([l,r]):l}return r||St}eq(e){if(this==e)return!0;if(!(e instanceof he)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return mp(this.localsInner(e))}localsInner(e){if(this==St)return vi;if(e.inlineContent||!this.local.some(ro.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ro||n.push(this.local[r]);return n}forEachSet(e){e(this)}}he.empty=new he([],[]);he.removeOverlap=mp;const St=he.empty;class Gr{constructor(e){this.members=e}map(e,n){const r=this.members.map(o=>o.map(e,n,Do));return Gr.from(r)}forChild(e,n){if(n.isLeaf)return he.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,n);i!=St&&(i instanceof Gr?r=r.concat(i.members):r.push(i))}return Gr.from(r)}eq(e){if(!(e instanceof Gr)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let s=0;s<i.length;s++)n.push(i[s])}}return n?mp(r?n:n.sort(_o)):vi}static from(e){switch(e.length){case 0:return St;case 1:return e[0];default:return new Gr(e.every(n=>n instanceof he)?e:e.reduce((n,r)=>n.concat(r instanceof he?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function xI(t,e,n,r,o,i,s){let l=t.slice();for(let c=0,d=i;c<n.maps.length;c++){let u=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let w=l[y+1];if(w<0||f>w+d-u)continue;let k=l[y]+d-u;h>=k?l[y+1]=f<=k?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=n.map(t[c]+i),u=d-o;if(u<0||u>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(n,g,d+1,t[c]+i+1,s);y!=St?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=CI(l,t,e,n,o,i,s),d=pc(c,r,0,s);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new he(e.sort(_o),l)}function Uw(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new Me(o.from+e,o.to+e,o.type))}return n}function CI(t,e,n,r,o,i,s){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,o,c);u?n.push(u):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ww(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let i=0,s;i<t.length;i++)(s=t[i])&&s.from>n&&s.to<r&&((o||(o=[])).push(s),t[i]=null);return o}function qw(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function pc(t,e,n,r){let o=[],i=!1;e.forEach((l,a)=>{let c=Ww(t,l,a+n);if(c){i=!0;let d=pc(c,l,n+a+1,r);d!=St&&o.push(a,a+l.nodeSize,d)}});let s=Uw(i?qw(t):t,-n).sort(_o);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(r.onRemove&&r.onRemove(s[l].spec),s.splice(l--,1));return s.length||o.length?new he(s,o):St}function _o(t,e){return t.from-e.from||t.to-e.to}function mp(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Ub(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Ub(e,o,r.copy(i.from,r.to)));break}}}return e}function Ub(t,e,n){for(;e<t.length&&_o(n,t[e])>0;)e++;t.splice(e,0,n)}function Ru(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=St&&e.push(r)}),t.cursorWrapper&&e.push(he.create(t.state.doc,[t.cursorWrapper.deco])),Gr.from(e)}const SI={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},EI=Zt&&to<=11;class MI{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class TI{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MI,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);Zt&&to<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():Nt&&e.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),EI&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,SI)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if($b(this.view)){if(this.suppressingSelectionUpdates)return Nr(this.view);if(Zt&&to<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=zi(i))n.add(i);for(let i=e.anchorNode;i;i=zi(i))if(n.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&$b(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<n.length;d++){let u=this.registerMutation(n[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(l=!0))}if(a.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||at&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(kn&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||RI(e,u)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&rd(r)&&(c=ap(e))&&c.eq(ee.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Nr(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),AI(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,II(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Nr(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,i=e.nextSibling;if(Zt&&to<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let s=o&&o.parentNode==e.target?bt(o)+1:0,l=r.localPosFromDOM(e.target,s,-1),a=i&&i.parentNode==e.target?bt(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Wb=new WeakMap,qb=!1;function AI(t){if(!Wb.has(t)&&(Wb.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=kn,qb)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),qb=!0}}function Gb(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return zo(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function NI(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Gb(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Gb(t,n):null}function RI(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function II(t,e){var n;let{focusNode:r,focusOffset:o}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function OI(t,e,n){let{node:r,fromOffset:o,toOffset:i,from:s,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,d=a.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],rd(a)||c.push({node:a.focusNode,offset:a.focusOffset})),at&&t.input.lastKeyCode===8)for(let g=i;g>o;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){i=g;break}if(!w||w.size)break}let u=t.state.doc,f=t.someProp("domParser")||wn.fromSchema(t.state.schema),h=u.resolve(s),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:DI,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function DI(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Nt&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Nt&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const _I=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function PI(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let S=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,M=ap(t,S);if(M&&!t.state.selection.eq(M)){if(at&&xr&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",A=>A(t,Eo(13,"Enter"))))return;let N=t.state.tr.setSelection(M);S=="pointer"?N.setMeta("pointer",!0):S=="key"&&N.scrollIntoView(),i&&N.setMeta("composition",i),t.dispatch(N)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=OI(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=BI(u.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(Ui&&t.input.lastIOSEnter>Date.now()-225||xr)&&o.some(S=>S.nodeType==1&&!_I.test(S.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",S=>S(t,Eo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof W&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let S=Zb(t,t.state.doc,c.sel);if(S&&!S.eq(t.state.selection)){let M=t.state.tr.setSelection(S);i&&M.setMeta("composition",i),t.dispatch(M)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof W&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Zt&&to<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),w=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA;if((Ui&&t.input.lastIOSEnter>Date.now()-225&&(!w||o.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&t.someProp("handleKeyDown",S=>S(t,Eo(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&LI(d,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",S=>S(t,Eo(8,"Backspace")))){xr&&at&&t.domObserver.suppressSelectionUpdates();return}at&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),xr&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(S){return S(t,Eo(13,"Enter"))})},20));let k=p.start,x=p.endA,C=S=>{let M=S||t.state.tr.replace(k,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let N=Zb(t,M.doc,c.sel);N&&!(at&&t.composing&&N.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==k||N.head==M.mapping.map(x)-1)||Zt&&N.empty&&N.head==k)&&M.setSelection(N)}return i&&M.setMeta("composition",i),M.scrollIntoView()},E;if(w)if(m.pos==g.pos){Zt&&to<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Nr(t),20));let S=C(t.state.tr.delete(k,x)),M=d.resolve(p.start).marksAcross(d.resolve(p.endA));M&&S.ensureMarks(M),t.dispatch(S)}else if(p.endA==p.endB&&(E=$I(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let S=C(t.state.tr);E.type=="add"?S.addMark(k,x,E.mark):S.removeMark(k,x,E.mark),t.dispatch(S)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let S=m.parent.textBetween(m.parentOffset,g.parentOffset),M=()=>C(t.state.tr.insertText(S,k,x));t.someProp("handleTextInput",N=>N(t,k,x,S,M))||t.dispatch(M())}else t.dispatch(C());else t.dispatch(C())}function Zb(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:cp(t,e.resolve(n.anchor),e.resolve(n.head))}function $I(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,i=r,s,l,a;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(I.from(c).eq(t))return{mark:l,type:s}}function LI(t,e,n,r,o){if(n-e<=o.pos-r.pos||Iu(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(Iu(i,!0,!0));return!s.parent.isTextblock||s.pos>n||Iu(s,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Iu(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function BI(t,e,n,r,o){let i=t.findDiffStart(e,n),s=n+t.size,l=n+e.size;if(i==null)return null;let{a,b:c}=t.findDiffEnd(e,s,l);if(o=="end"){let d=Math.max(0,i-Math.min(a,c));r-=a+d-i}if(a<i&&s<l){let d=r<=i&&r>=a?i-r:0;i-=d,c=i+(c-a),a=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}class Gw{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new eI,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Qb),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Yb(this),Jb(this),this.nodeViews=Xb(this),this.docView=Rb(this.state.doc,Kb(this),Ru(this),this.dom,this),this.domObserver=new TI(this,(r,o,i,s)=>PI(this,r,o,i,s)),this.domObserver.start(),tI(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Zf(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qb),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Vw(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Xb(this);VI(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Zf(this),this.editable=Yb(this),Jb(this);let a=Ru(this),c=Kb(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&mR(this);if(s){this.domObserver.stop();let h=u&&(Zt||at)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&jI(o.selection,e.selection);if(u){let m=at?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=gI(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Rb(e.doc,c,a,this.dom,this)),m&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&jR(this)&&p.delaySelUpdate())?Nr(this,h):(Mw(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&gR(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof G){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Sb(this,n.getBoundingClientRect(),e)}else Sb(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Fw(e.slice,e.move,o<0?void 0:G.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=n?n(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=n?n(l):l))return o}}hasFocus(){if(Zt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&bR(this.dom),Nr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return xR(this,e)}coordsAtPos(e,n=1){return yw(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return TR(this,n||this.state,e)}pasteHTML(e,n){return Xs(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Xs(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return dp(this,e)}destroy(){this.docView&&(nI(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ru(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,iR())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return oI(this,e)}domSelectionRange(){let e=this.domSelection();return e?Nt&&this.root.nodeType===11&&dR(this.dom.ownerDocument)==this.dom&&NI(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Gw.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Kb(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Me.node(0,t.state.doc.content.size,e)]}function Jb(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Me.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Yb(t){return!t.someProp("editable",e=>e(t.state)===!1)}function jI(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Xb(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function VI(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Qb(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const HI=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),FI=typeof navigator<"u"&&/Win/.test(navigator.platform);function zI(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))HI?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),s&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function UI(t){let e=Object.create(null);for(let n in t)e[zI(n)]=t[n];return e}function Ou(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Zw(t){return new ae({props:{handleKeyDown:gp(t)}})}function gp(t){let e=UI(t);return function(n,r){let o=TM(r),i,s=e[Ou(o,r)];if(s&&s(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Ou(o,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(FI&&r.ctrlKey&&r.altKey)&&(i=AM[r.keyCode])&&i!=o){let l=e[Ou(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var WI=Object.defineProperty,bp=(t,e)=>{for(var n in e)WI(t,n,{get:e[n],enumerable:!0})};function id(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}var sd=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([s,l])=>[s,(...c)=>{const d=l(...c)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],l=!!t,a=t||o.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),s.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,f])=>[u,(...p)=>{const m=this.buildProps(a,e),g=f(...p)(m);return s.push(g),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,i=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:id({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(s)]))}};return s}},Kw={};bp(Kw,{blur:()=>qI,clearContent:()=>GI,clearNodes:()=>ZI,command:()=>KI,createParagraphNear:()=>JI,cut:()=>YI,deleteCurrentNode:()=>XI,deleteNode:()=>QI,deleteRange:()=>eO,deleteSelection:()=>rO,enter:()=>oO,exitCode:()=>iO,extendMarkRange:()=>sO,first:()=>lO,focus:()=>cO,forEach:()=>dO,insertContent:()=>uO,insertContentAt:()=>hO,joinBackward:()=>gO,joinDown:()=>mO,joinForward:()=>bO,joinItemBackward:()=>yO,joinItemForward:()=>vO,joinTextblockBackward:()=>wO,joinTextblockForward:()=>kO,joinUp:()=>pO,keyboardShortcut:()=>CO,lift:()=>SO,liftEmptyBlock:()=>EO,liftListItem:()=>MO,newlineInCode:()=>TO,resetAttributes:()=>AO,scrollIntoView:()=>NO,selectAll:()=>RO,selectNodeBackward:()=>IO,selectNodeForward:()=>OO,selectParentNode:()=>DO,selectTextblockEnd:()=>_O,selectTextblockStart:()=>PO,setContent:()=>$O,setMark:()=>eD,setMeta:()=>tD,setNode:()=>nD,setNodeSelection:()=>rD,setTextDirection:()=>oD,setTextSelection:()=>iD,sinkListItem:()=>sD,splitBlock:()=>lD,splitListItem:()=>aD,toggleList:()=>dD,toggleMark:()=>uD,toggleNode:()=>fD,toggleWrap:()=>hD,undoInputRule:()=>pD,unsetAllMarks:()=>mD,unsetMark:()=>gD,unsetTextDirection:()=>bD,updateAttributes:()=>yD,wrapIn:()=>vD,wrapInList:()=>wD});var qI=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),GI=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),ZI=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:i,$to:s})=>{t.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;const p=oi(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},KI=t=>e=>t(e),JI=()=>({state:t,dispatch:e})=>lw(t,e),YI=(t,e)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new W(r.doc.resolve(Math.max(s-1,0)))),!0},XI=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const o=t.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){const l=o.before(i),a=o.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function ft(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var QI=t=>({tr:e,state:n,dispatch:r})=>{const o=ft(t,n.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){const a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},eO=t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},tO=t=>t.content?/^text(\*|\+)/.test(t.content):!1,ey=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return tO(r)?n==="left"?t.start()-1:t.end()+1:t.pos},nO=(t,e,n)=>{const r=ey(t,n,"left"),o=ey(e,n,"right");return{from:r,to:o}},rO=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:o,to:i}=nO(n,r,t.schema);return e&&(t.tr.deleteRange(o,i).scrollIntoView(),e(t.tr)),!0},oO=()=>({commands:t})=>t.keyboardShortcut("Enter"),iO=()=>({state:t,dispatch:e})=>UN(t,e);function yp(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function mc(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:yp(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function Jw(t,e,n={}){return t.find(r=>r.type===e&&mc(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function ty(t,e,n={}){return!!Jw(t,e,n)}function ld(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(d=>d.type===e);c&&(n=c.attrs)}if(!Jw([...r.node.marks],e,n))return;let i=r.index,s=t.start()+r.offset,l=i+1,a=s+r.node.nodeSize;for(;i>0&&ty([...t.parent.child(i-1).marks],e,n);)i-=1,s-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&ty([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:s,to:a}}function Lr(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var sO=(t,e)=>({tr:n,state:r,dispatch:o})=>{const i=Lr(t,r.schema),{doc:s,selection:l}=n,{$from:a,from:c,to:d}=l;if(o){const u=ld(a,i,e);if(u&&u.from<=c&&u.to>=d){const f=W.create(s,u.from,u.to);n.setSelection(f)}}return!0},lO=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function vp(t){return t instanceof W}function Sr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Yw(t,e=null){if(!e)return null;const n=ee.atStart(t),r=ee.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const o=n.from,i=r.to;return e==="all"?W.create(t,Sr(0,o,i),Sr(t.content.size,o,i)):W.create(t,Sr(e,o,i),Sr(e,o,i))}function Kf(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function el(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function aO(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var cO=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{(el()||Kf())&&r.dom.focus(),aO()&&!el()&&!Kf()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!vp(n.state.selection))return s(),!0;const l=Yw(o.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},dO=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),uO=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Xw=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Xw(r)}return t};function ca(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Xw(n)}function tl(t,e,n){if(t instanceof Tr||t instanceof I)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return I.fromArray(t.map(l=>e.nodeFromJSON(l)));const s=e.nodeFromJSON(t);return n.errorOnInvalidContent&&s.check(),s}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),tl("",e,n)}if(o){if(n.errorOnInvalidContent){let s=!1,l="";const a=new Ov({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?wn.fromSchema(a).parseSlice(ca(t),n.parseOptions):wn.fromSchema(a).parse(ca(t),n.parseOptions),n.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=wn.fromSchema(e);return n.slice?i.parseSlice(ca(t),n.parseOptions).content:i.parse(ca(t),n.parseOptions)}return tl("",e,n)}function Qw(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof Ke||o instanceof Ye))return;const i=t.mapping.maps[r];let s=0;i.forEach((l,a,c,d)=>{s===0&&(s=d)}),t.setSelection(ee.near(t.doc.resolve(s),n))}var fO=t=>!("type"in t),hO=(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=g=>{i.emit("contentError",{editor:i,error:g,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{tl(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=tl(e,i.schema,{parseOptions:c,errorOnInvalidContent:(s=n.errorOnInvalidContent)!=null?s:i.options.enableContentCheck})}catch(g){return a(g),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((fO(l)?l:[l]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof I){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,d,u)}else{m=l;const g=r.doc.resolve(d),y=g.node(),w=g.parentOffset===0,k=y.isText||y.isTextblock,x=y.content.size>0;w&&k&&x&&h&&(d=Math.max(0,d-1)),r.replaceWith(d,u,m)}n.updateSelection&&Qw(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:m})}return!0},pO=()=>({state:t,dispatch:e})=>HN(t,e),mO=()=>({state:t,dispatch:e})=>FN(t,e),gO=()=>({state:t,dispatch:e})=>ew(t,e),bO=()=>({state:t,dispatch:e})=>ow(t,e),yO=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ed(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},vO=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ed(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},wO=()=>({state:t,dispatch:e})=>jN(t,e),kO=()=>({state:t,dispatch:e})=>VN(t,e);function ek(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xO(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,o,i,s;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))el()||ek()?s=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),s&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var CO=t=>({editor:e,view:n,tr:r,dispatch:o})=>{const i=xO(t).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function nl(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?ft(e,t.schema):null,l=[];t.doc.nodesBetween(r,o,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(o,f+u.nodeSize);l.push({node:u,from:h,to:p})});const a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>mc(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var SO=(t,e={})=>({state:n,dispatch:r})=>{const o=ft(t,n.schema);return nl(n,o,e)?zN(n,r):!1},EO=()=>({state:t,dispatch:e})=>aw(t,e),MO=t=>({state:e,dispatch:n})=>{const r=ft(t,e.schema);return tR(r)(e,n)},TO=()=>({state:t,dispatch:e})=>sw(t,e);function ad(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ny(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var AO=(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=ad(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=ft(t,r.schema)),l==="mark"&&(s=Lr(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{i&&i===d.type&&(a=!0,o&&n.setNodeMarkup(u,void 0,ny(d.attrs,e))),s&&d.marks.length&&d.marks.forEach(f=>{s===f.type&&(a=!0,o&&n.addMark(u,u+d.nodeSize,s.create(ny(f.attrs,e))))})})}),a},NO=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),RO=()=>({tr:t,dispatch:e})=>{if(e){const n=new Gt(t.doc);t.setSelection(n)}return!0},IO=()=>({state:t,dispatch:e})=>nw(t,e),OO=()=>({state:t,dispatch:e})=>iw(t,e),DO=()=>({state:t,dispatch:e})=>GN(t,e),_O=()=>({state:t,dispatch:e})=>JN(t,e),PO=()=>({state:t,dispatch:e})=>KN(t,e);function gc(t,e,n={},r={}){return tl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var $O=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=gc(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return s&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return s&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function tk(t,e){const n=Lr(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});const l=s.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function cd(t,e){const n=new tp(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function LO(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function bc(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(o,i)=>{n(o)&&r.push({node:o,pos:i})}),r}function nk(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function dd(t){return e=>nk(e.$from,t)}function K(t,e,n){return t.config[e]===void 0&&t.parent?K(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?K(t.parent,e,n):null}):t.config[e]}function wp(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=K(e,"addExtensions",n);return r?[e,...wp(r())]:e}).flat(10)}function kp(t,e){const n=cn.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function rk(t){return typeof t=="function"}function Ne(t,e=void 0,...n){return rk(t)?e?t.bind(e)(...n):t(...n):t}function BO(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Wi(t){const e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function ok(t){const e=[],{nodeExtensions:n,markExtensions:r}=Wi(t),o=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},s=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...s,...l];return t.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage,extensions:o},u=K(c,"addGlobalAttributes",d);if(!u)return;u().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=a:h.types==="nodes"?p=s:h.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...i,...y}})})})})}),o.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage},u=K(c,"addAttributes",d);if(!u)return;const f=u();Object.entries(f).forEach(([h,p])=>{const m={...i,...p};typeof(m==null?void 0:m.default)=="function"&&(m.default=m.default()),m!=null&&m.isRequired&&(m==null?void 0:m.default)===void 0&&delete m.default,e.push({type:c.name,name:h,attribute:m})})}),e}function jO(t){const e=[];let n="",r=!1,o=!1,i=0;const s=t.length;for(let l=0;l<s;l+=1){const a=t[l];if(a==="'"&&!o){r=!r,n+=a;continue}if(a==='"'&&!r){o=!o,n+=a;continue}if(!r&&!o){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function ry(t){const e=[],n=jO(t||""),r=n.length;for(let o=0;o<r;o+=1){const i=n[o],s=i.indexOf(":");if(s===-1)continue;const l=i.slice(0,s).trim(),a=i.slice(s+1).trim();l&&a&&e.push([l,a])}return e}function dn(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){const l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(d=>!a.includes(d));r[o]=[...a,...c].join(" ")}else if(o==="style"){const l=new Map([...ry(r[o]),...ry(i)]);r[o]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[o]=i}),r},{})}function rl(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>dn(n,r),{})}function VO(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function oy(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const o=e.reduce((i,s)=>{const l=s.attribute.parseHTML?s.attribute.parseHTML(n):VO(n.getAttribute(s.name));return l==null?i:{...i,[s.name]:l}},{});return{...r,...o}}}}function iy(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&BO(n)?!1:n!=null))}function sy(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function ik(t,e){var n;const r=ok(t),{nodeExtensions:o,markExtensions:i}=Wi(t),s=(n=o.find(c=>K(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(o.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,w)=>{const k=K(w,"extendNodeSchema",u);return{...y,...k?k(c):{}}},{}),h=iy({...f,content:Ne(K(c,"content",u)),marks:Ne(K(c,"marks",u)),group:Ne(K(c,"group",u)),inline:Ne(K(c,"inline",u)),atom:Ne(K(c,"atom",u)),selectable:Ne(K(c,"selectable",u)),draggable:Ne(K(c,"draggable",u)),code:Ne(K(c,"code",u)),whitespace:Ne(K(c,"whitespace",u)),linebreakReplacement:Ne(K(c,"linebreakReplacement",u)),defining:Ne(K(c,"defining",u)),isolating:Ne(K(c,"isolating",u)),attrs:Object.fromEntries(d.map(sy))}),p=Ne(K(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>oy(y,d)));const m=K(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:rl(y,d)}));const g=K(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,y)=>{const w=K(y,"extendMarkSchema",u);return{...g,...w?w(c):{}}},{}),h=iy({...f,inclusive:Ne(K(c,"inclusive",u)),excludes:Ne(K(c,"excludes",u)),group:Ne(K(c,"group",u)),spanning:Ne(K(c,"spanning",u)),code:Ne(K(c,"code",u)),attrs:Object.fromEntries(d.map(sy))}),p=Ne(K(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>oy(g,d)));const m=K(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:rl(g,d)})),[c.name,h]}));return new Ov({topNode:s,nodes:l,marks:a})}function HO(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function js(t){return t.sort((n,r)=>{const o=K(n,"priority")||100,i=K(r,"priority")||100;return o>i?-1:o<i?1:0})}function xp(t){const e=js(wp(t)),n=HO(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function FO(t,e){const n=xp(t);return ik(n,e)}function sk(t,e,n){const{from:r,to:o}=e,{blockSeparator:i=`
20
+
21
+ `,textSerializers:s={}}=n||{};let l="";return t.nodesBetween(r,o,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);const h=s==null?void 0:s[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)==null?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function zO(t,e){const n={from:0,to:t.content.size};return sk(t,n,e)}function lk(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function UO(t,e){const n=ft(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,l=>{i.push(l)});const s=i.reverse().find(l=>l.type.name===n.name);return s?{...s.attrs}:{}}function ak(t,e){const n=ad(typeof e=="string"?e:e.name,t.schema);return n==="node"?UO(t,e):n==="mark"?tk(t,e):{}}function WO(t,e=JSON.stringify){const n={};return t.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function qO(t){const e=WO(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,s)=>s!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Cp(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,i)=>{const s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),qO(r)}function Sp(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(o=>{const i=n.resolve(t),s=ld(i,o.type);s&&r.push({mark:o,...s})}):n.nodesBetween(t,e,(o,i)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}function ws(t,e){return e.nodes[t]||e.marks[t]||null}function La(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=t.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}var GO=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;const d=((c=(a=o.type.spec).toText)==null?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),n};function Jf(t,e,n={}){const{empty:r,ranges:o}=t.selection,i=e?Lr(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>mc(u.attrs,n,{strict:!1}));let s=0;const l=[];if(o.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),w=Math.min(p,g+m.nodeSize),k=w-y;s+=k,l.push(...m.marks.map(x=>({mark:x,from:y,to:w})))})}),s===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>mc(u.mark.attrs,n,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=s}function ZO(t,e,n={}){if(!e)return nl(t,null,n)||Jf(t,null,n);const r=ad(e,t.schema);return r==="node"?nl(t,e,n):r==="mark"?Jf(t,e,n):!1}function ly(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Du(t,e){const{nodeExtensions:n}=Wi(e),r=n.find(s=>s.name===t);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},i=Ne(K(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function Ep(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(i=>{o!==!1&&(Ep(i,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function KO(t){return t instanceof G}function JO({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){const{from:o,to:i}=t;return!!(o<=e&&i>=e+n||r&&vp(t)&&o>e&&i<e+n)}var ck=class dk{constructor(e){this.position=e}static fromJSON(e){return new dk(e.position)}toJSON(){return{position:this.position}}};function YO(t,e){const n=e.mapping.mapResult(t.position);return{position:new ck(n.pos),mapResult:n}}function XO(t){return new ck(t)}function Mp(t,e,n){const o=t.state.doc.content.size,i=Sr(e,0,o),s=Sr(n,0,o),l=t.coordsAtPos(i),a=t.coordsAtPos(s,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-u,p=d-c,y={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function QO(t,e,n){var r;const{selection:o}=e;let i=null;if(vp(o)&&(i=o.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var eD=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:l}=i,a=Lr(t,r.schema);if(o)if(s){const c=tk(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&n.addMark(p,m,a.create({...y.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return QO(r,n,a)},tD=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),nD=(t,e={})=>({state:n,dispatch:r,chain:o})=>{const i=ft(t,n.schema);let s;return n.selection.$anchor.sameParent(n.selection.$head)&&(s=n.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>kb(i,{...s,...e})(n)?!0:l.clearNodes()).command(({state:l})=>kb(i,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},rD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,o=Sr(t,0,r.content.size),i=G.create(r,o);e.setSelection(i)}return!0},oD=(t,e)=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=r;let s,l;return typeof e=="number"?(s=e,l=e):e&&"from"in e&&"to"in e?(s=e.from,l=e.to):(s=i.from,l=i.to),o&&n.doc.nodesBetween(s,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},iD=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:o,to:i}=typeof t=="number"?{from:t,to:t}:t,s=W.atStart(r).from,l=W.atEnd(r).to,a=Sr(o,s,l),c=Sr(i,s,l),d=W.create(r,a,c);e.setSelection(d)}return!0},sD=t=>({state:e,dispatch:n})=>{const r=ft(t,e.schema);return oR(r)(e,n)};function ay(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(o=>e==null?void 0:e.includes(o.type.name));t.tr.ensureMarks(r)}}var lD=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=La(c,l.node().type.name,l.node().attrs);if(i instanceof G&&i.node.isBlock)return!l.parentOffset||!Ar(s,l.pos)?!1:(r&&(t&&ay(n,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:LO(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=Ar(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ar(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof W&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&ay(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},aD=(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;const l=ft(t,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let y=I.empty;const w=a.index(-1)?1:a.index(-2)?2:3;for(let M=a.depth-w;M>=a.depth-3;M-=1)y=I.from(a.node(M).copy(y));const k=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,x={...La(f,a.node().type.name,a.node().attrs),...e},C=((s=l.contentMatch.defaultType)==null?void 0:s.createAndFill(x))||void 0;y=y.append(I.from(l.createAndFill(null,C)||void 0));const E=a.before(a.depth-(w-1));n.replace(E,a.after(-k),new j(y,4-w,0));let S=-1;n.doc.nodesBetween(E,n.doc.content.size,(M,N)=>{if(S>-1)return!1;M.isTextblock&&M.content.size===0&&(S=N+1)}),S>-1&&n.setSelection(W.near(n.doc.resolve(S))),n.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...La(f,u.type.name,u.attrs),...e},m={...La(f,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!Ar(n.doc,a.pos,2))return!1;if(o){const{selection:y,storedMarks:w}=r,{splittableMarks:k}=i.extensionManager,x=w||y.$to.parentOffset&&y.$from.marks();if(n.split(a.pos,2,g).scrollIntoView(),!x||!o)return!0;const C=x.filter(E=>k.includes(E.type.name));n.ensureMarks(C)}return!0};function cy(t){return!t||t==="1"?null:t}function uk(t,e){return cy(t)===cy(e)}var _u=(t,e)=>{const n=dd(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return!(n.node.type===(o==null?void 0:o.type)&&bo(t.doc,n.pos))||!uk(n.node.attrs.type,o==null?void 0:o.attrs.type)||t.join(n.pos),!0},Pu=(t,e)=>{const n=dd(s=>s.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return!(n.node.type===(o==null?void 0:o.type)&&bo(t.doc,r))||!uk(n.node.attrs.type,o==null?void 0:o.attrs.type)||t.join(r),!0};function cD(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),o=e.resolve(n.nodeSize-1);return W.between(r,o)}var dD=(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=o.extensionManager,h=ft(t,s.schema),p=ft(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:w}=m,k=y.blockRange(w),x=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;const C=dd(D=>Du(D.type.name,u))(m),E=m.from===0&&m.to===s.doc.content.size,S=s.doc.content.content,M=S.length===1?S[0]:null,N=E&&M&&Du(M.type.name,u)?{node:M,pos:0}:null,A=C??N,R=!!C&&k.depth>=1&&k.depth-C.depth<=1,P=!!N;if((R||P)&&A){if(A.node.type===h)return E&&P?a().command(({tr:D,dispatch:T})=>{const _=cD(D);return _?(D.setSelection(_),T&&T(D),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Du(A.node.type.name,u)&&h.validContent(A.node.content))return a().command(()=>(i.setNodeMarkup(A.pos,h),!0)).command(()=>_u(i,h)).command(()=>Pu(i,h)).run()}return!n||!x||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>_u(i,h)).command(()=>Pu(i,h)).run():a().command(()=>{const D=d().wrapInList(h,r),T=x.filter(_=>f.includes(_.type.name));return i.ensureMarks(T),D?!0:c.clearNodes()}).wrapInList(h,r).command(()=>_u(i,h)).command(()=>Pu(i,h)).run()},uD=(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=Lr(t,r.schema);return Jf(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},fD=(t,e,n={})=>({state:r,commands:o})=>{const i=ft(t,r.schema),s=ft(e,r.schema),l=nl(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,{...a,...n})},hD=(t,e={})=>({state:n,commands:r})=>{const o=ft(t,n.schema);return nl(n,o,e)?r.lift(o):r.wrapIn(o,e)},pD=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){const s=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},mD=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:o=!1}=t,{selection:i}=e,{empty:s,ranges:l}=i;if(s)return!0;const{nonClearableMarks:a}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(d=>o||!a.includes(d.name));l.forEach(d=>{for(const u of c)e.removeMark(d.$from.pos,d.$to.pos,u)})}return!0},gD=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:l}=n,a=Lr(t,r.schema),{$from:c,empty:d,ranges:u}=l;if(!o)return!0;if(d&&s){let{from:f,to:h}=l;const p=(i=c.marks().find(g=>g.type===a))==null?void 0:i.attrs,m=ld(c,a,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,a)}else u.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},bD=t=>({tr:e,state:n,dispatch:r})=>{const{selection:o}=n;let i,s;return typeof t=="number"?(i=t,s=t):t&&"from"in t&&"to"in t?(i=t.from,s=t.to):(i=o.from,s=o.to),r&&e.doc.nodesBetween(i,s,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},yD=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const l=ad(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=ft(t,r.schema)),l==="mark"&&(s=Lr(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(d,u,(g,y)=>{i&&i===g.type&&(a=!0,p=Math.max(y,d),m=Math.min(y+g.nodeSize,u),f=y,h=g)}):r.doc.nodesBetween(d,u,(g,y)=>{y<d&&i&&i===g.type&&(a=!0,p=Math.max(y,d),m=Math.min(y+g.nodeSize,u),f=y,h=g),y>=d&&y<=u&&(i&&i===g.type&&(a=!0,o&&n.setNodeMarkup(y,void 0,{...g.attrs,...e})),s&&g.marks.length&&g.marks.forEach(w=>{if(s===w.type&&(a=!0,o)){const k=Math.max(y,d),x=Math.min(y+g.nodeSize,u);n.addMark(k,x,s.create({...w.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),s&&h.marks.length&&h.marks.forEach(g=>{s===g.type&&o&&n.addMark(p,m,s.create({...g.attrs,...e}))}))}),a},vD=(t,e={})=>({state:n,dispatch:r})=>{const o=ft(t,n.schema);return YN(o,e)(n,r)},wD=(t,e={})=>({state:n,dispatch:r})=>{const o=ft(t,n.schema);return XN(o,e)(n,r)},kD=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function xD(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}function CD(t){return typeof t=="number"}function SD(t){return Object.prototype.toString.call(t).slice(8,-1)}function da(t){return SD(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}var ED={};bp(ED,{createAtomBlockMarkdownSpec:()=>MD,createBlockMarkdownSpec:()=>TD,createInlineMarkdownSpec:()=>RD,parseAttributes:()=>Tp,parseIndentedBlocks:()=>ID,renderNestedMarkdownContent:()=>OD,serializeAttributes:()=>Ap});function Tp(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),o=r.match(/(?:^|\s)\.([\w-]+)/g);if(o){const c=o.map(d=>d.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([\w-]+)/);i&&(e.id=i[1]);const s=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(s)).forEach(([,c,d])=>{var u;const f=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=n[f];h&&(e[c]=h.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function Ap(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function MD(t){const{nodeName:e,name:n,parseAttributes:r=Tp,serializeAttributes:o=Ap,defaultAttributes:i={},requiredAttributes:s=[],allowedAttributes:l}=t,a=n||e,c=d=>{if(!l)return d;const u={};return l.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{const f={...i,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const f=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=d.match(f))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);if(!p)return;const m=p[1]||"",g=r(m);if(!s.find(w=>!(w in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:d=>{const u=c(d.attrs||{}),f=o(u),h=f?` {${f}}`:"";return`:::${a}${h} :::`}}}function TD(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=Tp,serializeAttributes:i=Ap,defaultAttributes:s={},content:l="block",allowedAttributes:a}=t,c=n||e,d=u=>{if(!a)return u;const f={};return a.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){const m=r(u);h=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);const p={...s,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[y,w=""]=g,k=o(w);let x=1;const C=y.length;let E="";const S=/^:::([\w-]*)(\s.*)?/gm,M=u.slice(C);for(S.lastIndex=0;;){const N=S.exec(M);if(N===null)break;const A=N.index,R=N[1];if(!((p=N[2])!=null&&p.endsWith(":::"))){if(R)x+=1;else if(x-=1,x===0){const P=M.slice(0,A);E=P.trim();const D=u.slice(0,C+A+N[0].length);let T=[];if(E)if(l==="block")for(T=h.blockTokens(P),T.forEach(_=>{_.text&&(!_.tokens||_.tokens.length===0)&&(_.tokens=h.inlineTokens(_.text))});T.length>0;){const _=T[T.length-1];if(_.type==="paragraph"&&(!_.text||_.text.trim()===""))T.pop();else break}else T=h.inlineTokens(E);return{type:e,raw:D,attributes:k,content:E,tokens:T}}}}}},renderMarkdown:(u,f)=>{const h=d(u.attrs||{}),p=i(h),m=p?` {${p}}`:"",g=f.renderChildren(u.content||[],`
22
+
23
+ `);return`:::${c}${m}
24
+
25
+ ${g}
26
+
27
+ :::`}}}function AD(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,o,i,s]=r;e[o]=i||s,r=n.exec(t)}return e}function ND(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function RD(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=AD,serializeAttributes:i=ND,defaultAttributes:s={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,d=f=>{if(!a)return f;const h={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in f){const y=f[m];if(g!==void 0&&y===g)return;h[m]=y}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const p={...s,...f.attributes};if(l)return h.createNode(e,p);const m=r?r(f):f.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),m=p==null?void 0:p.index;return m!==void 0?m:-1},tokenize(f,h,p){const m=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=f.match(m);if(!g)return;let y="",w="";if(l){const[,x]=g;w=x}else{const[,x,C]=g;w=x,y=C||""}const k=o(w.trim());return{type:e,raw:g[0],content:y.trim(),attributes:k}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const p=d(f.attrs||{}),m=i(p),g=m?` ${m}`:"";return l?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function ID(t,e,n){var r,o,i,s;const l=t.split(`
28
+ `),a=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<l.length;){const f=l[d],h=f.match(e.itemPattern);if(!h){if(a.length>0)break;if(f.trim()===""){d+=1,c=`${c}${f}
29
+ `;continue}else return}const p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${f}
30
+ `;const y=[g];for(d+=1;d<l.length;){const C=l[d];if(C.trim()===""){const S=l.slice(d+1).findIndex(A=>A.trim()!=="");if(S===-1)break;if((((o=(r=l[d+1+S].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){y.push(C),c=`${c}${C}
31
+ `,d+=1;continue}else break}if((((s=(i=C.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:s.length)||0)>m)y.push(C),c=`${c}${C}
32
+ `,d+=1;else break}let w;const k=y.slice(1);if(k.length>0){const C=k.map(E=>E.slice(m+u)).join(`
33
+ `);C.trim()&&(e.customNestedParser?w=e.customNestedParser(C):w=n.blockTokens(C))}const x=e.createToken(p,w);a.push(x)}if(a.length!==0)return{items:a,raw:c}}function OD(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const o=typeof n=="function"?n(r):n,[i,...s]=t.content,l=e.renderChildren([i]);let a=`${o}${l}`;return s&&s.length>0&&s.forEach((c,d)=>{var u,f;const h=(f=(u=e.renderChild)==null?void 0:u.call(e,c,d+1))!=null?f:e.renderChildren([c]);if(h!=null){const p=h.split(`
34
+ `).map(m=>m?e.indent(m):e.indent("")).join(`
35
+ `);a+=c.type==="paragraph"?`
36
+
37
+ ${p}`:`
38
+ ${p}`}}),a}function fk(t,e){const n={...t};return da(t)&&da(e)&&Object.keys(e).forEach(r=>{da(e[r])&&da(t[r])?n[r]=fk(t[r],e[r]):n[r]=e[r]}),n}function DD(t,e,n={}){const{state:r}=e,{doc:o,tr:i}=r,s=t;o.descendants((l,a)=>{const c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(h=>{if(h!==s)return!1;u=h}),!u)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==u.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,h)}}),i.docChanged&&e.view.dispatch(i)}var hk=class{constructor(e){var n;this.find=e.find,this.handler=e.handler,this.undoable=(n=e.undoable)!=null?n:!0}},_D=(t,e)=>{if(yp(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function ua(t){var e;const{editor:n,from:r,to:o,text:i,rules:s,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=GO(c)+i;return s.forEach(f=>{if(d)return;const h=_D(u,f.find);if(!h)return;const p=a.state.tr,m=id({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:o},{commands:y,chain:w,can:k}=new sd({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:w,can:k})===null||!p.steps.length||(f.undoable&&p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),d=!0)}),d}function PD(t){const{editor:e,rules:n}=t,r=new ae({state:{init(){return null},apply(o,i,s){const l=o.getMeta(r);if(l)return l;const a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=kp(I.from(d),s.schema);const{from:u}=a,f=u+d.length;ua({editor:e,from:u,to:f,text:d,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return ua({editor:e,from:i,to:s,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:i}=o.state.selection;i&&ua({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;const{$cursor:s}=o.state.selection;return s?ua({editor:e,from:s.pos,to:s.pos,text:`
39
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Np=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Ne(K(this,"addOptions",{name:this.name}))}}get storage(){return{...Ne(K(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>fk(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Nn=class pk extends Np{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new pk(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const s=o.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const a=s.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},$D=class{constructor(t){this.find=t.find,this.handler=t.handler}},LD=(t,e,n)=>{if(yp(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(o=>{const i=[o.text];return i.index=o.index,i.input=t,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function BD(t){const{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=t,{commands:a,chain:c,can:d}=new sd({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,o,(h,p)=>{var m,g,y,w,k;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;const x=(k=(w=(y=h.content)==null?void 0:y.size)!=null?w:h.nodeSize)!=null?k:0,C=Math.max(r,p),E=Math.min(o,p+x);if(C>=E)return;const S=h.isText?h.text||"":h.textBetween(C-p,E-p,void 0,"");LD(S,i.find,s).forEach(N=>{if(N.index===void 0)return;const A=C+N.index+1,R=A+N[0].length,P={from:n.tr.mapping.map(A),to:n.tr.mapping.map(R)},D=i.handler({state:n,range:P,match:N,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(D)})}),u.every(h=>h!==null)}var fa=null,jD=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function VD(t){const{editor:e,rules:n}=t;let r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const m=d.tr,g=id({state:d,transaction:m});if(!(!BD({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(d=>new ae({view(u){const f=p=>{var m;r=(m=u.dom.parentElement)!=null&&m.contains(p.target)?u.dom.parentElement:null,r&&(fa=e)},h=()=>{fa&&(fa=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){const h=fa;h!=null&&h.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return s=f,o=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],m=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),w=!!y;if(!m&&!g&&!w)return;if(w){let{text:C}=y;typeof C=="string"?C=C:C=kp(I.from(C),h.schema);const{from:E}=y,S=E+C.length,M=jD(C);return a({rule:d,state:h,from:E,to:{b:S},pasteEvt:M})}const k=f.doc.content.findDiffStart(h.doc.content),x=f.doc.content.findDiffEnd(h.doc.content);if(!(!CD(k)||!x||k===x.b))return a({rule:d,state:h,from:k,to:x,pasteEvt:s})}}))}var ud=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=xp(t),this.schema=ik(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ws(e.name,this.schema)},r=K(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return js([...this.extensions].reverse()).flatMap(r=>{const o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ws(r.name,this.schema)},i=[],s=K(r,"addKeyboardShortcuts",o);let l={};if(r.type==="mark"&&K(r,"exitable",o)&&(l.ArrowRight=()=>Nn.handleExit({editor:t,mark:r})),s){const f=Object.fromEntries(Object.entries(s()).map(([h,p])=>[h,()=>p({editor:t})]));l={...l,...f}}const a=Zw(l);i.push(a);const c=K(r,"addInputRules",o);if(ly(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=PD({editor:t,rules:f}),p=Array.isArray(h)?h:[h];i.push(...p)}}const d=K(r,"addPasteRules",o);if(ly(r,t.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const h=VD({editor:t,rules:f});i.push(...h)}}const u=K(r,"addProseMirrorPlugins",o);if(u){const f=u();i.push(...f)}return i})}get attributes(){return ok(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Wi(this.extensions);return Object.fromEntries(e.filter(n=>!!K(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ft(n.name,this.schema)},i=K(n,"addNodeView",o);if(!i)return[];const s=i();if(!s)return[];const l=(a,c,d,u,f)=>{const h=rl(a,r);return s({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return js([...this.extensions].reverse()).reduceRight((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:ws(o.name,this.schema)},s=K(o,"dispatchTransaction",i);return s?l=>{s.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return js([...this.extensions]).reduce((r,o)=>{const i={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:ws(o.name,this.schema)},s=K(o,"transformPastedHTML",i);return s?(l,a)=>{const c=r(l,a);return s.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=Wi(this.extensions);return Object.fromEntries(e.filter(n=>!!K(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Lr(n.name,this.schema)},i=K(n,"addMarkView",o);if(!i)return[];const s=(l,a,c)=>{const d=rl(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{DD(l,t,u)}})};return[n.name,s]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n,r;const o={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ws(e.name,this.schema)};e.type==="mark"&&(((n=Ne(K(e,"keepOnSplit",o)))==null||n)&&this.splittableMarks.push(e.name),(r=Ne(K(e,"clearable",o)))==null||r||this.nonClearableMarks.push(e.name));const i=K(e,"onBeforeCreate",o),s=K(e,"onCreate",o),l=K(e,"onUpdate",o),a=K(e,"onSelectionUpdate",o),c=K(e,"onTransaction",o),d=K(e,"onFocus",o),u=K(e,"onBlur",o),f=K(e,"onDestroy",o);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};ud.resolve=xp;ud.sort=js;ud.flatten=wp;var wi={};bp(wi,{ClipboardTextSerializer:()=>gk,Commands:()=>bk,Delete:()=>yk,Drop:()=>vk,Editable:()=>wk,FocusEvents:()=>xk,Keymap:()=>Ck,Paste:()=>Sk,Tabindex:()=>Ek,TextDirection:()=>Mk,focusEventsPluginKey:()=>kk});var Ge=class mk extends Np{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new mk(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},gk=Ge.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ae({key:new Ce("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,i=lk(n),{blockSeparator:s}=this.options,l={...s!==void 0?{blockSeparator:s}:{},textSerializers:i};return[...o.ranges].sort((c,d)=>c.$from.pos-d.$from.pos).map(({$from:c,$to:d})=>sk(r,{from:c.pos,to:d.pos},l)).join(s??`
40
+
41
+ `)}}})]}}),bk=Ge.create({name:"commands",addCommands(){return{...Kw}}}),yk=Ge.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;const i=()=>{var s,l,a,c;if((c=(a=(l=(s=this.editor.options.coreExtensionOptions)==null?void 0:s.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const d=cd(t.before,[t,...e]);Cp(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,y=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:d.mapping.map(m),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((h,p)=>{var m,g;if(h instanceof $n){const y=f.slice(p).map(h.from,-1),w=f.slice(p).map(h.to),k=f.invert().map(y,-1),x=f.invert().map(w),C=y>0?(m=d.doc.nodeAt(y-1))==null?void 0:m.marks.some(S=>S.eq(h.mark)):!1,E=(g=d.doc.nodeAt(w))==null?void 0:g.marks.some(S=>S.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:x},newRange:{from:y,to:w},partial:!!(E||C),editor:this.editor,transaction:t,combinedTransform:d})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(i,0):i()}}),vk=Ge.create({name:"drop",addProseMirrorPlugins(){return[new ae({key:new Ce("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),wk=Ge.create({name:"editable",addProseMirrorPlugins(){return[new ae({key:new Ce("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kk=new Ce("focusEvents"),xk=Ge.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ae({key:kk,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Ck=Ge.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:ee.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return el()||ek()?i:o},addProseMirrorPlugins(){return[new ae({key:new Ce("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;const{empty:i,from:s,to:l}=e.selection,a=ee.atStart(e.doc).from,c=ee.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!Ep(n.doc))return;const f=n.tr,h=id({state:n,transaction:f}),{commands:p}=new sd({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Sk=Ge.create({name:"paste",addProseMirrorPlugins(){return[new ae({key:new Ce("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Ek=Ge.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new ae({key:new Ce("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),Mk=Ge.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Wi(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new ae({key:new Ce("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),HD=class Ns{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Ns(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ns(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ns(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,s=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!o&&!s&&a.depth<=this.depth)return;const c=new Ns(a,this.editor,o,o||s?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){const i=o.node.attrs,s=Object.keys(n);for(let l=0;l<s.length;l+=1){const a=s[l];if(i[a]!==n[a])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const i=Object.keys(n);return this.children.forEach(s=>{r&&o.length>0||(s.node.type.name===e&&i.every(a=>n[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,n,r))))}),o}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},FD=`.ProseMirror {
42
+ position: relative;
43
+ }
44
+
45
+ .ProseMirror {
46
+ word-wrap: break-word;
47
+ white-space: pre-wrap;
48
+ white-space: break-spaces;
49
+ -webkit-font-variant-ligatures: none;
50
+ font-variant-ligatures: none;
51
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
52
+ }
53
+
54
+ .ProseMirror [contenteditable="false"] {
55
+ white-space: normal;
56
+ }
57
+
58
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
59
+ white-space: pre-wrap;
60
+ }
61
+
62
+ .ProseMirror pre {
63
+ white-space: pre-wrap;
64
+ }
65
+
66
+ img.ProseMirror-separator {
67
+ display: inline !important;
68
+ border: none !important;
69
+ margin: 0 !important;
70
+ width: 0 !important;
71
+ height: 0 !important;
72
+ }
73
+
74
+ .ProseMirror-gapcursor {
75
+ display: none;
76
+ pointer-events: none;
77
+ position: absolute;
78
+ margin: 0;
79
+ }
80
+
81
+ .ProseMirror-gapcursor:after {
82
+ content: "";
83
+ display: block;
84
+ position: absolute;
85
+ top: -2px;
86
+ width: 20px;
87
+ border-top: 1px solid black;
88
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
89
+ }
90
+
91
+ @keyframes ProseMirror-cursor-blink {
92
+ to {
93
+ visibility: hidden;
94
+ }
95
+ }
96
+
97
+ .ProseMirror-hideselection *::selection {
98
+ background: transparent;
99
+ }
100
+
101
+ .ProseMirror-hideselection *::-moz-selection {
102
+ background: transparent;
103
+ }
104
+
105
+ .ProseMirror-hideselection * {
106
+ caret-color: transparent;
107
+ }
108
+
109
+ .ProseMirror-focused .ProseMirror-gapcursor {
110
+ display: block;
111
+ }`,zD=class extends kD{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:YO,createMappablePosition:XO},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:i})=>this.options.onDrop(r,o,i)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Yw(e,this.options.autofocus);this.editorState=ki.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=xD(FD,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=rk(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(o=>{const i=typeof o=="string"?`${o}$`:o.key;n=n.filter(s=>!s.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const i=[...this.options.enableCoreExtensions?[wk,gk.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),bk,xk,Ck,Ek.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),vk,Sk,yk,Mk.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new ud(i,this)}createCommandManager(){this.commandManager=new sd({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=gc(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=gc(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,s=this.extensionManager.transformPastedHTML(i);this.editorView=new Gw(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:o,transformPastedHTML:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const a=this.view.dom;a.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),l=s==null?void 0:s.getMeta("focus"),a=s==null?void 0:s.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:s}),a&&this.emit("blur",{editor:this,event:a.event,transaction:s}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return ak(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return ZO(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return kp(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
112
+
113
+ `,textSerializers:n={}}=t||{};return zO(this.state.doc,{blockSeparator:e,textSerializers:{...lk(this.schema),...n}})}get isEmpty(){return Ep(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new HD(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Wo(t){return new hk({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Ne(t.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:i}=e,s=r[r.length-1],l=r[0];if(s){const a=l.search(/\S/),c=n.from+l.indexOf(s),d=c+s.length;if(Sp(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;d<n.to&&i.delete(d,n.to),c>n.from&&i.delete(n.from+a,c);const f=n.from+a+s.length;i.addMark(n.from+a,f,t.type.create(o||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}var Kn=class Tk extends Np{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Tk(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},UD=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,o,i,s,l;const{view:a}=this.editor,c=t.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,f=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),k=d.getBoundingClientRect(),x=(o=t.offsetX)!=null?o:(r=t.nativeEvent)==null?void 0:r.offsetX,C=(s=t.offsetY)!=null?s:(i=t.nativeEvent)==null?void 0:i.offsetY;u=k.x-w.x+x,f=k.y-w.y+C}const h=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();h.style.width=`${Math.round(w.width)}px`,h.style.height=`${Math.round(w.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(h,u,f)}finally{p&&setTimeout(()=>{try{p==null||p.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const g=G.create(a.state.doc,m),y=a.state.tr.setSelection(g);a.dispatch(y)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const o=t.type.startsWith("drag"),i=t.type==="dragover"||t.type==="dragenter",s=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!s&&!o)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=G.isSelectable(this.node),f=t.type==="copy",h=t.type==="paste",p=t.type==="cut",m=t.type==="mousedown";if(!d&&u&&o&&t.target===this.dom&&t.preventDefault(),d&&o&&!c&&t.target===this.dom)return t.preventDefault(),!1;if(d&&a&&!c&&m){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||i||s||f||h||p||m&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(el()||Kf())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function qo(t){return new $D({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const i=Ne(t.getAttributes,void 0,r,o);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const d=a.search(/\S/),u=n.from+a.indexOf(l),f=u+l.length;if(Sp(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;f<n.to&&s.delete(f,n.to),u>n.from&&s.delete(n.from+d,u),c=n.from+d+l.length,s.addMark(n.from+d,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||s.removeStoredMark(t.type)}}})}const Un=Math.floor,Ba=Math.abs,Rr=(t,e)=>t<e?t:e,Wn=(t,e)=>t>e?t:e,Ak=t=>t!==0?t<0:1/t<0,dy=1,uy=2,$u=4,Lu=8,ol=32,Ir=64,Lt=128,WD=1<<29,fd=31,Yf=63,Po=127,qD=2147483647,GD=crypto.getRandomValues.bind(crypto),ZD=Math.random,Nk=()=>GD(new Uint32Array(1))[0],KD=t=>t[Un(ZD()*t.length)],JD="10000000-1000-4000-8000"+-1e11,Rp=()=>JD.replace(/[018]/g,t=>(t^Nk()&15>>t/4).toString(16));let Xf,Qf;if(typeof WeakMap<"u"){let t=new WeakMap;Xf=e=>t.get(e),Qf=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Xf=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Qf=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var je=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==n;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const l=(t+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(t){return Xf(t)||Qf(t,YD(t))}};function YD(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=XD(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=t.child(c);d++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:y,colwidth:w}=m.attrs;for(let k=0;k<y;k++){if(k+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-k});break}const x=o+k*e;for(let C=0;C<g;C++){r[x+C]==0?r[x+C]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-C});const E=w&&w[C];if(E){const S=(x+C)%e*2,M=s[S];M==null||M!=E&&s[S+1]==1?(s[S]=E,s[S+1]=1):M==E&&s[S+1]++}}}o+=g,d+=m.nodeSize}const f=(c+1)*e;let h=0;for(;o<f;)r[o++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),d++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new je(e,n,r,i);let a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<n&&(a=!0);return a&&QD(l,s,t),l}function XD(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const l=t.child(s);for(let a=0;a<l.childCount;a++){const c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function QD(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let c=0;c<a.colspan;c++){const d=e[(o+c)%t.width*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=e_(a)))[c]=d)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function e_(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Rt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const Zr=new Ce("selectingCells");function Go(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function t_(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Jn(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function hd(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Go(e.$head)||n_(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function n_(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function eh(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Rk(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Ip(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Op(t,e,n){const r=t.node(-1),o=je.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Zo(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Ik(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function r_(t,e,n){const r=Rt(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var Ae=class yr extends ee{constructor(e,n=e){const r=e.node(-1),o=je.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(d=>d!=n.pos-i);a.unshift(n.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw new RangeError(`No cell with offset ${d} found`);const f=i+d+1;return new Kv(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(eh(r)&&eh(o)&&Ip(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?yr.rowSelection(r,o):i&&this.isColSelection()?yr.colSelection(r,o):new yr(r,o)}return W.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=je.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*n.width+o.left,u=o.left;u<o.right;u++,d++){const f=n.map[d];if(i[f])continue;i[f]=!0;const h=n.findCell(f);let p=e.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=Zo(y,0,m)),g>0&&(y=Zo(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}s.push(e.child(a).copy(I.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new j(I.from(l),1,1)}replace(e,n=j.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?j.empty:n)}const i=ee.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new j(I.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=je.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=je.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new yr(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=je.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof yr&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=je.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(n.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new yr(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new yr(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new yr(e.resolve(n),e.resolve(r))}getBookmark(){return new o_(this.$anchorCell.pos,this.$headCell.pos)}};Ae.prototype.visible=!1;ee.jsonID("cell",Ae);var o_=class Ok{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ok(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Ip(n,r)?new Ae(n,r):ee.near(r,1)}};function i_(t){if(!(t.selection instanceof Ae))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Me.node(r,r+n.nodeSize,{class:"selectedCell"}))}),he.create(t.doc,e)}function s_({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function l_({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function a_(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof G&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=Ae.create(o,r.from);else if(s=="row"){const l=o.resolve(r.from+1);i=Ae.rowSelection(l,l)}else if(!n){const l=je.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Ae.create(o,a+1,c)}}else r instanceof W&&s_(r)?i=W.create(o,r.from):r instanceof W&&l_(r)&&(i=W.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const c_=new Ce("fix-tables");function Dk(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){const a=e.child(s);for(let c=l,d=Math.min(o,s+3);c<d;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<o&&t.child(l).sameMarkup(a)?Dk(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function d_(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=u_(t,o,i,n))};return e?e.doc!=t.doc&&Dk(e.doc,t.doc,0,r):t.doc.descendants(r),n}function u_(t,e,n,r){const o=je.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let f=0;f<u.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Zo(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=n+1;a<o.height;a++){const d=e.child(a),u=c+d.nodeSize,f=i[a];if(f>0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<f;g++){const y=Rt(t.schema)[h].createAndFill();y&&p.push(y)}const m=(a==0||s==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(m),p)}c=u}return r.setMeta(c_,{fixTables:!0})}function fr(t){const e=t.selection,n=hd(t),r=n.node(-1),o=n.start(-1),i=je.get(r);return{...e instanceof Ae?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function _k(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;r_(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,Ik(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{const a=i==null?Rt(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function f_(t,e){if(!Jn(t))return!1;if(e){const n=fr(t);e(_k(t.tr,n,n.left))}return!0}function h_(t,e){if(!Jn(t))return!1;if(e){const n=fr(t);e(_k(t.tr,n,n.right))}return!0}function p_(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const l=s*e.width+o,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Zo(d,o-e.colCount(a)));else{const u=t.mapping.slice(i).map(r+a);t.delete(u,u+c.nodeSize)}s+=d.rowspan}}function m_(t,e){if(!Jn(t))return!1;if(e){const n=fr(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;p_(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=je.get(i)}e(r)}return!0}function g_(t,e,n){var r;const o=Rt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function Pk(t,{map:e,tableStart:n,table:r},o){let i=n;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const s=[];let l=o>0?-1:0;g_(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c<e.width;c++,d++)if(o>0&&o<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],f=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;const u=l==null?Rt(r.type.schema).cell:(a=r.nodeAt(e.map[d+l*e.width]))===null||a===void 0?void 0:a.type,f=u==null?void 0:u.createAndFill();f&&s.push(f)}return t.insert(i,Rt(r.type.schema).row.create(null,s)),t}function b_(t,e){if(!Jn(t))return!1;if(e){const n=fr(t);e(Pk(t.tr,n,n.top))}return!0}function y_(t,e){if(!Jn(t))return!1;if(e){const n=fr(t);e(Pk(t.tr,n,n.bottom))}return!0}function v_(t,{map:e,table:n,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=n.child(c).nodeSize;const s=i+n.child(o).nodeSize,l=t.mapping.maps.length;t.delete(i+r,s+r);const a=new Set;for(let c=0,d=o*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),o>0&&u==e.map[d-e.width]){const f=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&u==e.map[d+e.width]){const f=n.nodeAt(u),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function w_(t,e){if(!Jn(t))return!1;if(e){const n=fr(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;v_(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=je.get(n.table)}e(r)}return!0}function fy(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function k_({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function x_(t,e){const n=t.selection;if(!(n instanceof Ae)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=fr(t),{map:o}=r;if(k_(o,r))return!1;if(e){const i=t.tr,s={};let l=I.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const f=o.map[d*o.width+u],h=r.table.nodeAt(f);if(!(s[f]||!h))if(s[f]=!0,a==null)a=f,c=h;else{fy(h)||(l=l.append(h.content));const p=i.mapping.map(f+r.tableStart);i.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...Ik(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const d=a+1+c.content.size,u=fy(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new Ae(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function C_(t,e){const n=Rt(t.schema);return S_(({node:r})=>n[r.type.spec.tableRole])(t,e)}function S_(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof Ae){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=t_(r.$from),!o)return!1;i=(s=Go(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=fr(e),u=e.tr;for(let h=0;h<d.right-d.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=d.top;h<d.bottom;h++){let p=d.map.positionAt(h,d.left,d.table);h==d.top&&(p+=o.nodeSize);for(let m=d.left,g=0;m<d.right;m++,g++)m==d.left&&h==d.top||u.insert(f=u.mapping.map(p+d.tableStart,1),t({node:o,row:h,col:m}).createAndFill(a[g]))}u.setNodeMarkup(i,t({node:o,row:d.top,col:d.left}),a[0]),r instanceof Ae&&u.setSelection(new Ae(u.doc.resolve(r.$anchorCell.pos),f?u.doc.resolve(f):void 0)),n(u)}return!0}}function E_(t){return function(e,n){if(!Jn(e))return!1;if(n){const r=Rt(e.schema),o=fr(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);n(i)}return!0}}function hy(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Dp(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?E_(t):function(n,r){if(!Jn(n))return!1;if(r){const o=Rt(n.schema),i=fr(n),s=n.tr,l=hy("row",i,o),a=hy("column",i,o),c=(t==="column"?l:t==="row"&&a)?1:0,d=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,u=t=="column"?a?o.cell:o.header_cell:t=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(d).forEach(f=>{const h=f+i.tableStart,p=s.doc.nodeAt(h);p&&s.setNodeMarkup(h,u,p.attrs)}),r(s)}return!0}}Dp("row",{useDeprecatedLogic:!0});Dp("column",{useDeprecatedLogic:!0});Dp("cell",{useDeprecatedLogic:!0});function M_(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function py(t){return function(e,n){if(!Jn(e))return!1;const r=M_(hd(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(W.between(o,Rk(o))).scrollIntoView())}return!0}}function ha(t,e){const n=t.selection;if(!(n instanceof Ae))return!1;if(e){const r=t.tr,o=Rt(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new j(o,0,0))}),r.docChanged&&e(r)}return!0}function T_(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,n-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=th(Rt(s).row,new j(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?th(Rt(s).row,new j(e,n,r)).content:e);else return null;return A_(s,l)}function A_(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(I.empty),n[o]<r){const i=Rt(t).cell.createAndFill(),s=[];for(let l=n[o];l<r;l++)s.push(i);e[o]=e[o].append(I.from(s))}return{height:e.length,width:r,rows:e}}function th(t,e){const n=t.createAndFill();return new tp(n).replace(0,n.content.size,e).doc}function N_({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let f=a.child(u%a.childCount);d+f.attrs.colspan>r&&(f=f.type.createChecked(Zo(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)i[l+h]=(i[l+h]||0)+f.attrs.colspan}s.push(I.from(c))}n=s,t=r}if(e!=o){const i=[];for(let s=0,l=0;s<o;s++,l++){const a=[],c=n[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);s+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(I.from(a))}n=i,e=o}return{width:t,height:e,rows:n}}function R_(t,e,n,r,o,i,s){const l=t.doc.type.schema,a=Rt(l);let c,d;if(o>e.width)for(let u=0,f=0;u<e.height;u++){const h=n.child(u);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);t.insert(t.mapping.slice(s).map(f-1+r),p)}if(i>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,I.from(u)),h=[];for(let p=e.height;p<i;p++)h.push(f);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),h)}return!!(c||d)}function my(t,e,n,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){const d=s*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const f=n.nodeAt(u),{top:h,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...f.attrs,rowspan:s-h}),t.insert(t.mapping.slice(l).map(e.positionAt(s,p,n)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function gy(t,e,n,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){const d=c*e.width+s,u=e.map[d];if(e.map[d-1]==u){a=!0;const f=n.nodeAt(u),h=e.colCount(u),p=t.mapping.slice(l).map(u+r);t.setNodeMarkup(p,null,Zo(f.attrs,s-h,f.attrs.colspan-(s-h))),t.insert(p+f.nodeSize,f.type.createAndFill(Zo(f.attrs,0,s-h))),c+=f.attrs.rowspan-1}}return a}function by(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=je.get(i);const{top:l,left:a}=r,c=a+o.width,d=l+o.height,u=t.tr;let f=0;function h(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");s=je.get(i),f=u.mapping.maps.length}R_(u,s,i,n,c,d,f)&&h(),my(u,s,i,n,a,c,l,f)&&h(),my(u,s,i,n,a,c,d,f)&&h(),gy(u,s,i,n,l,d,a,f)&&h(),gy(u,s,i,n,l,d,c,f)&&h();for(let p=l;p<d;p++){const m=s.positionAt(p,a,i),g=s.positionAt(p,c,i);u.replace(u.mapping.slice(f).map(m+n),u.mapping.slice(f).map(g+n),new j(o.rows[p-l],0,0))}h(),u.setSelection(new Ae(u.doc.resolve(n+s.positionAt(l,a,i)),u.doc.resolve(n+s.positionAt(d-1,c-1,i)))),e(u)}const I_=gp({ArrowLeft:pa("horiz",-1),ArrowRight:pa("horiz",1),ArrowUp:pa("vert",-1),ArrowDown:pa("vert",1),"Shift-ArrowLeft":ma("horiz",-1),"Shift-ArrowRight":ma("horiz",1),"Shift-ArrowUp":ma("vert",-1),"Shift-ArrowDown":ma("vert",1),Backspace:ha,"Mod-Backspace":ha,Delete:ha,"Mod-Delete":ha});function ja(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function pa(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof Ae)return ja(n,r,ee.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=$k(o,t,e);if(s==null)return!1;if(t=="horiz")return ja(n,r,ee.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(s),a=Op(l,t,e);let c;return a?c=ee.near(a,1):e<0?c=ee.near(n.doc.resolve(l.before(-1)),-1):c=ee.near(n.doc.resolve(l.after(-1)),1),ja(n,r,c)}}}function ma(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof Ae)s=i;else{const a=$k(o,t,e);if(a==null)return!1;s=new Ae(n.doc.resolve(a))}const l=Op(s.$headCell,t,e);return l?ja(n,r,new Ae(s.$anchorCell,l)):!1}}function O_(t,e){const n=t.state.doc,r=Go(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ae(r))),!0):!1}function D_(t,e,n){if(!Jn(t.state))return!1;let r=T_(n);const o=t.state.selection;if(o instanceof Ae){r||(r={width:1,height:1,rows:[I.from(th(Rt(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=je.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=N_(r,l.right-l.left,l.bottom-l.top),by(t.state,t.dispatch,s,l,r),!0}else if(r){const i=hd(t.state),s=i.start(-1);return by(t.state,t.dispatch,s,je.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function __(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=yy(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof Ae)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Go(t.state.selection.$anchor))!=null&&((n=Bu(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Bu(t,c);const u=Zr.getState(t.state)==null;if(!d||!Ip(a,d))if(u)d=a;else return;const f=new Ae(a,d);if(u||!t.state.selection.eq(f)){const h=t.state.tr.setSelection(f);u&&h.setMeta(Zr,a.pos),t.dispatch(h)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),Zr.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Zr,-1))}function l(a){const c=a,d=Zr.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(yy(t,c.target)!=r&&(u=Bu(t,e),!u))return s();u&&i(u,c)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function $k(t,e,n){if(!(t.state.selection instanceof W))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?s:null}}return null}function yy(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Bu(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&Go(t.state.doc.resolve(r))||Go(t.state.doc.resolve(o))}var Lk=class{constructor(t,e){this.node=t,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),nh(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,nh(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function nh(t,e,n,r,o,i){let s=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let u=0,f=0;u<c.childCount;u++){const{colspan:h,colwidth:p}=c.child(u).attrs;for(let m=0;m<h;m++,f++){const g=o==f?i:p&&p[m],y=g?g+"px":"";if(s+=g||r,g||(l=!1),a)a.style.width!=y&&(a.style.width=y),a=a.nextSibling;else{const w=document.createElement("col");w.style.width=y,e.appendChild(w)}}}for(;a;){var d;const u=a.nextSibling;(d=a.parentNode)===null||d===void 0||d.removeChild(a),a=u}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const sn=new Ce("tableColumnResizing");function P_({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=Lk,lastColumnResizable:o=!0}={}){const i=new ae({key:sn,state:{init(s,l){var a;const c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,d=Rt(l.schema).table.name;return r&&c&&(c[d]=(u,f)=>new r(u,n,f)),new $_(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{const l=sn.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{L_(s,l,t,o)},mouseleave:s=>{B_(s)},mousedown:(s,l)=>{j_(s,l,e,n)}},decorations:s=>{const l=sn.getState(s);if(l&&l.activeHandle>-1)return U_(s,l.activeHandle)},nodeViews:{}}});return i}var $_=class Va{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(sn);if(r&&r.setHandle!=null)return new Va(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Va(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return eh(e.doc.resolve(o))||(o=-1),new Va(o,n.dragging)}return n}};function L_(t,e,n,r){if(!t.editable)return;const o=sn.getState(t.state);if(o&&!o.dragging){const i=H_(e.target);let s=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?s=vy(t,e,"left",n):a-e.clientX<=n&&(s=vy(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const l=t.state.doc.resolve(s),a=l.node(-1),c=je.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Bk(t,s)}}}function B_(t){if(!t.editable)return;const e=sn.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Bk(t,-1)}function j_(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=sn.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const l=t.state.doc.nodeAt(s.activeHandle),a=V_(t,s.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(sn,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const f=sn.getState(t.state);f!=null&&f.dragging&&(F_(t,f.activeHandle,wy(f.dragging,u,n)),t.dispatch(t.state.tr.setMeta(sn,{setDragging:null})))}function d(u){if(!u.which)return c(u);const f=sn.getState(t.state);if(f&&f.dragging){const h=wy(f.dragging,u,n);ky(t,f.activeHandle,h,r)}}return ky(t,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function V_(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(s-=r[a],l--);return s/l}function H_(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function vy(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,l=Go(t.state.doc.resolve(s));if(!l)return-1;if(n=="right")return l.pos;const a=je.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function wy(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Bk(t,e){t.dispatch(t.state.tr.setMeta(sn,{setHandle:e}))}function F_(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=je.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],f=o.nodeAt(u).attrs,h=f.colspan==1?0:l-i.colCount(u);if(f.colwidth&&f.colwidth[h]==n)continue;const p=f.colwidth?f.colwidth.slice():z_(f.colspan);p[h]=n,a.setNodeMarkup(s+u,null,{...f,colwidth:p})}a.docChanged&&t.dispatch(a)}function ky(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=je.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=t.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&nh(i,a.firstChild,a,r,l,n)}function z_(t){return Array(t).fill(0)}function U_(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return he.empty;const i=je.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const d=l+c*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(c==0||i.map[d]!=i.map[d-i.width])){var a;const u=i.map[d],f=s+u+o.nodeAt(u).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",!((a=sn.getState(t))===null||a===void 0)&&a.dragging&&n.push(Me.node(s+u,s+u+o.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),n.push(Me.widget(f,h))}}return he.create(t.doc,n)}function W_({allowTableNodeSelection:t=!1}={}){return new ae({key:Zr,state:{init(){return null},apply(e,n){const r=e.getMeta(Zr);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:i_,handleDOMEvents:{mousedown:__},createSelectionBetween(e){return Zr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:O_,handleKeyDown:I_,handlePaste:D_},appendTransaction(e,n,r){return a_(r,d_(r,n),t)}})}var q_=class jk{constructor(e){this.cache=new Map(e)}get(e){return this.cache.get(e)}set(e,n,r){e<0||this.cache.set(e,[n,r])}replace(e,n,r,o){this.remove(e),this.set(n,r,o)}remove(e){this.cache.delete(e)}invalidate(e){const n=new jk(this.cache),r=e.mapping;return this.cache.forEach(([o,i],s)=>{if(s<0)return;const l=r.mapResult(s),a=e.doc.nodeAt(l.pos);if(l.deleted||!(a!=null&&a.eq(o)))n.remove(s);else if(s!==l.pos){const c=i.map(d=>d.map(r,0,0)).filter(d=>d!=null);n.replace(s,l.pos,a,c)}}),n}};function G_({parser:t,nodeTypes:e=["code_block","codeBlock"],languageExtractor:n=r=>r.attrs.language}){const r=new Ce("prosemirror-highlight");return new ae({key:r,state:{init(o,i){const s=new q_,[l,a]=xy(i.doc,t,e,n,s);return{cache:s,decorations:l,promises:a}},apply:(o,i)=>{var d;const s=i.cache.invalidate(o),l=!!o.getMeta("prosemirror-highlight-refresh");if(!o.docChanged&&!l)return{cache:s,decorations:(d=i.decorations)==null?void 0:d.map(o.mapping,o.doc),promises:i.promises};const[a,c]=xy(o.doc,t,e,n,s);return{cache:s,decorations:a,promises:c}}},view:o=>{const i=new Set,s=()=>{if(i.size>0||o.isDestroyed)return;const a=o.state.tr.setMeta("prosemirror-highlight-refresh",!0);o.dispatch(a)},l=()=>{const a=r.getState(o.state);for(const c of(a==null?void 0:a.promises)??[])i.add(c),c.then(()=>{i.delete(c),s()}).catch(d=>{console.error("[prosemirror-highlight] Error resolving parser:",d),i.delete(c)})};return l(),{update:()=>{l()}}},props:{decorations(o){var i;return(i=this.getState(o))==null?void 0:i.decorations}}})}function xy(t,e,n,r,o){const i=[],s=[],l=Z_(t,n);try{for(const[a,c]of l){const d=r(a),u=o.get(c);if(u){const[f,h]=u;h.length>0&&i.push(h)}else{const f=e({content:a.textContent,language:d||void 0,pos:c,size:a.nodeSize});f&&Array.isArray(f)?(o.set(c,a,f),f.length>0&&i.push(f)):f instanceof Promise?(o.remove(c),s.push(f)):console.error("[prosemirror-highlight] Invalid parser result:",f)}}}catch(a){console.error("[prosemirror-highlight] Error parsing code blocks:",a)}return[i.length>0?he.create(t,i.flat()):void 0,s]}function Z_(t,e){const n=[];return t.descendants((r,o)=>{if(r.type.isTextblock&&e.includes(r.type.name))return n.push([r,o]),!1}),n}function K_(t,e){return function({content:r,language:o,pos:i,size:s}){const l=[],{tokens:a,fg:c,bg:d,rootStyle:u}=t.codeToTokens(r,{lang:o,theme:t.getLoadedThemes()[0]}),f=u||(c&&d?`--prosemirror-highlight:${c};--prosemirror-highlight-bg:${d}`:"");if(f){const p=Me.node(i,i+s,{style:f});l.push(p)}let h=i+1;for(const p of a){for(const m of p){const g=h+m.content.length,y=Me.inline(h,g,{style:J_(m.htmlStyle??`color: ${m.color}`),class:"shiki"});l.push(y),h=g}h+=1}return l}}function J_(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const Cn=()=>new Map,rh=t=>{const e=Cn();return t.forEach((n,r)=>{e.set(r,n)}),e},hr=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},Y_=(t,e)=>{const n=[];for(const[r,o]of t)n.push(e(o,r));return n},X_=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Ko=()=>new Set,ju=t=>t[t.length-1],Q_=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},oo=Array.from,_p=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Pp=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},eP=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},qi=Array.isArray;class Vk{constructor(){this._observers=Cn()}on(e,n){return hr(this._observers,e,Ko).add(n),n}once(e,n){const r=(...o)=>{this.off(e,r),n(...o)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return oo((this._observers.get(e)||Cn()).values()).forEach(r=>r(...n))}destroy(){this._observers=Cn()}}const yc=Number.MAX_SAFE_INTEGER,Cy=Number.MIN_SAFE_INTEGER,tP=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Un(t)===t),Hk=String.fromCharCode,nP=t=>t.toLowerCase(),rP=/^\s*/g,oP=t=>t.replace(rP,""),iP=/([A-Z])/g,Sy=(t,e)=>oP(t.replace(iP,n=>`${e}${nP(n)}`)),sP=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=e.codePointAt(o);return r},il=typeof TextEncoder<"u"?new TextEncoder:null,lP=t=>il.encode(t),aP=il?lP:sP;let Vs=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Vs&&Vs.decode(new Uint8Array).length===1&&(Vs=null);const cP=(t,e)=>eP(e,()=>t).join("");class _l{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Pl=()=>new _l,dP=t=>{const e=Pl();return t(e),Ln(e)},uP=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Ln=t=>{const e=new Uint8Array(uP(t));let n=0;for(let r=0;r<t.bufs.length;r++){const o=t.bufs[r];e.set(o,n),n+=o.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},fP=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Wn(n,e)*2),t.cpos=0)},lt=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},oh=lt,ge=(t,e)=>{for(;e>Po;)lt(t,Lt|Po&e),e=Un(e/128);lt(t,Po&e)},$p=(t,e)=>{const n=Ak(e);for(n&&(e=-e),lt(t,(e>Yf?Lt:0)|(n?Ir:0)|Yf&e),e=Un(e/64);e>0;)lt(t,(e>Po?Lt:0)|Po&e),e=Un(e/128)},ih=new Uint8Array(3e4),hP=ih.length/3,pP=(t,e)=>{if(e.length<hP){const n=il.encodeInto(e,ih).written||0;ge(t,n);for(let r=0;r<n;r++)lt(t,ih[r])}else en(t,aP(e))},mP=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ge(t,r);for(let o=0;o<r;o++)lt(t,n.codePointAt(o))},Ni=il&&il.encodeInto?pP:mP,pd=(t,e)=>{const n=t.cbuf.length,r=t.cpos,o=Rr(n-r,e.length),i=e.length-o;t.cbuf.set(e.subarray(0,o),r),t.cpos+=o,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Wn(n*2,i)),t.cbuf.set(e.subarray(o)),t.cpos=i)},en=(t,e)=>{ge(t,e.byteLength),pd(t,e)},Lp=(t,e)=>{fP(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},gP=(t,e)=>Lp(t,4).setFloat32(0,e,!1),bP=(t,e)=>Lp(t,8).setFloat64(0,e,!1),yP=(t,e)=>Lp(t,8).setBigInt64(0,e,!1),Ey=new DataView(new ArrayBuffer(4)),vP=t=>(Ey.setFloat32(0,t),Ey.getFloat32(0)===t),Gi=(t,e)=>{switch(typeof e){case"string":lt(t,119),Ni(t,e);break;case"number":tP(e)&&Ba(e)<=qD?(lt(t,125),$p(t,e)):vP(e)?(lt(t,124),gP(t,e)):(lt(t,123),bP(t,e));break;case"bigint":lt(t,122),yP(t,e);break;case"object":if(e===null)lt(t,126);else if(qi(e)){lt(t,117),ge(t,e.length);for(let n=0;n<e.length;n++)Gi(t,e[n])}else if(e instanceof Uint8Array)lt(t,116),en(t,e);else{lt(t,118);const n=Object.keys(e);ge(t,n.length);for(let r=0;r<n.length;r++){const o=n[r];Ni(t,o),Gi(t,e[o])}}break;case"boolean":lt(t,e?120:121);break;default:lt(t,127)}};class My extends _l{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ge(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Ty=t=>{t.count>0&&($p(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ge(t.encoder,t.count-2))};class Ha{constructor(){this.encoder=new _l,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Ty(this),this.count=1,this.s=e)}toUint8Array(){return Ty(this),Ln(this.encoder)}}const Ay=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);$p(t.encoder,e),t.count>1&&ge(t.encoder,t.count-2)}};class Vu{constructor(){this.encoder=new _l,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Ay(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Ay(this),Ln(this.encoder)}}class wP{constructor(){this.sarr=[],this.s="",this.lensE=new Ha}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new _l;return this.sarr.push(this.s),this.s="",Ni(e,this.sarr.join("")),pd(e,this.lensE.toUint8Array()),Ln(e)}}const cr=t=>new Error(t),Sn=()=>{throw cr("Method unimplemented")},Vt=()=>{throw cr("Unexpected case")},Fk=cr("Unexpected end of array"),zk=cr("Integer out of Range");class md{constructor(e){this.arr=e,this.pos=0}}const ns=t=>new md(t),kP=t=>t.pos!==t.arr.length,xP=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},tn=t=>xP(t,pe(t)),Zi=t=>t.arr[t.pos++],pe=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const o=t.arr[t.pos++];if(e=e+(o&Po)*n,n*=128,o<Lt)return e;if(e>yc)throw zk}throw Fk},Bp=t=>{let e=t.arr[t.pos++],n=e&Yf,r=64;const o=(e&Ir)>0?-1:1;if((e&Lt)===0)return o*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Po)*r,r*=128,e<Lt)return o*n;if(n>yc)throw zk}throw Fk},CP=t=>{let e=pe(t);if(e===0)return"";{let n=String.fromCodePoint(Zi(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Zi(t));else for(;e>0;){const r=e<1e4?e:1e4,o=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,o),e-=r}return decodeURIComponent(escape(n))}},SP=t=>Vs.decode(tn(t)),Ri=Vs?SP:CP,jp=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},EP=t=>jp(t,4).getFloat32(0,!1),MP=t=>jp(t,8).getFloat64(0,!1),TP=t=>jp(t,8).getBigInt64(0,!1),AP=[t=>{},t=>null,Bp,EP,MP,TP,t=>!1,t=>!0,Ri,t=>{const e=pe(t),n={};for(let r=0;r<e;r++){const o=Ri(t);n[o]=sl(t)}return n},t=>{const e=pe(t),n=[];for(let r=0;r<e;r++)n.push(sl(t));return n},tn],sl=t=>AP[127-Zi(t)](t);class Ny extends md{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),kP(this)?this.count=pe(this)+1:this.count=-1),this.count--,this.s}}class Fa extends md{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Bp(this);const e=Ak(this.s);this.count=1,e&&(this.s=-this.s,this.count=pe(this)+2)}return this.count--,this.s}}class Hu extends md{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Bp(this),n=e&1;this.diff=Un(e/2),this.count=1,n&&(this.count=pe(this)+2)}return this.s+=this.diff,this.count--,this.s}}class NP{constructor(e){this.decoder=new Fa(e),this.str=Ri(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const RP=Date.now,Ry=t=>new Promise(t);Promise.all.bind(Promise);const Iy=t=>t===void 0?null:t;class IP{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let Uk=new IP,OP=!0;try{typeof localStorage<"u"&&localStorage&&(Uk=localStorage,OP=!1)}catch{}const DP=Uk,ll=Symbol("Equality"),Wk=(t,e)=>{var n;return t===e||!!((n=t==null?void 0:t[ll])!=null&&n.call(t,e))||!1},_P=t=>typeof t=="object",PP=Object.assign,qk=Object.keys,$P=(t,e)=>{for(const n in t)e(t[n],n)},vc=t=>qk(t).length,LP=t=>{for(const e in t)return!1;return!0},rs=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Vp=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),BP=(t,e)=>t===e||vc(t)===vc(e)&&rs(t,(n,r)=>(n!==void 0||Vp(e,r))&&Wk(e[r],n)),jP=Object.freeze,Gk=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&Gk(t[e])}return jP(t)},Hp=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Hp(t,e,n+1)}},VP=t=>t,za=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ll]!=null)return t[ll](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!za(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(vc(t)!==vc(e))return!1;for(const n in t)if(!Vp(t,n)||!za(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!za(t[n],e[n]))return!1;break;default:return!1}return!0},HP=(t,e)=>e.includes(t);var Zk={};const Ki=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Kk=typeof window<"u"&&typeof document<"u"&&!Ki;let Qn;const FP=()=>{if(Qn===void 0)if(Ki){Qn=Cn();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&Qn.set(e,""),e=r):e!==null&&(Qn.set(e,r),e=null)}e!==null&&Qn.set(e,"")}else typeof location=="object"?(Qn=Cn(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");Qn.set(`--${Sy(e,"-")}`,n),Qn.set(`-${Sy(e,"-")}`,n)}})):Qn=Cn();return Qn},sh=t=>FP().has(t),wc=t=>Iy(Ki?Zk[t.toUpperCase().replaceAll("-","_")]:DP.getItem(t)),Jk=t=>sh("--"+t)||wc(t)!==null,zP=Jk("production"),UP=Ki&&HP(Zk.FORCE_COLOR,["true","1","2"]),WP=UP||!sh("--no-colors")&&!Jk("no-color")&&(!Ki||process.stdout.isTTY)&&(!Ki||sh("--color")||wc("COLORTERM")!==null||(wc("TERM")||"").includes("color")),qP=t=>new Uint8Array(t),GP=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=Hk(t[n]);return btoa(e)},ZP=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),KP=Kk?GP:ZP,JP=t=>{const e=qP(t.byteLength);return e.set(t),e},YP=t=>dP(e=>Gi(e,t));class XP{constructor(e,n){this.left=e,this.right=n}}const br=(t,e)=>new XP(t,e),Oy=t=>t.next()>=.5,Fu=(t,e,n)=>Un(t.next()*(n+1-e)+e),Yk=(t,e,n)=>Un(t.next()*(n+1-e)+e),Fp=(t,e,n)=>Yk(t,e,n),QP=t=>Hk(Fp(t,97,122)),e$=(t,e=0,n=20)=>{const r=Fp(t,e,n);let o="";for(let i=0;i<r;i++)o+=QP(t);return o},zu=(t,e)=>e[Fp(t,0,e.length-1)],t$=Symbol("0schema");class n${constructor(){this._rerrs=[]}extend(e,n,r,o=null){this._rerrs.push({path:e,expected:n,has:r,message:o})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(cP(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
114
+ `)}}const lh=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[ll]?Wk(t,e):qi(t)?_p(t,n=>Pp(e,r=>lh(n,r))):_P(t)?rs(t,(n,r)=>lh(n,e[r])):!1;class Dt{extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),lh(n,r)}equals(e){return this.constructor===e.constructor&&za(this.shape,e.shape)}[t$](){return!0}[ll](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Sn()}get nullable(){return is(this,wd)}get optional(){return new ex(this)}cast(e){return Dy(e,this),e}expect(e){return Dy(e,this),e}}B(Dt,"_dilutes",!1);class zp extends Dt{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=(e==null?void 0:e.constructor)===this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name,(e==null?void 0:e.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}}const rt=(t,e=null)=>new zp(t,e);rt(zp);class Up extends Dt{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&(n==null||n.extend(null,"custom prop",e==null?void 0:e.constructor.name,"failed to check custom prop")),r}}const pt=t=>new Up(t);rt(Up);class gd extends Dt{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(o=>o===e);return!r&&(n==null||n.extend(null,this.shape.join(" | "),e.toString())),r}}const bd=(...t)=>new gd(t),Xk=rt(gd),r$=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),Qk=t=>{if(Ji.check(t))return[r$(t)];if(Xk.check(t))return t.shape.map(e=>e+"");if(cx.check(t))return["[+-]?\\d+.?\\d*"];if(dx.check(t))return[".*"];if(xc.check(t))return t.shape.map(Qk).flat(1);Vt()};class o$ extends Dt{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(Qk).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),e.toString(),"String doesn't match string template.")),r}}rt(o$);const i$=Symbol("optional");class ex extends Dt{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[i$](){return!0}}const s$=rt(ex);class l$ extends Dt{check(e,n){return n==null||n.extend(null,"never",typeof e),!1}}rt(l$);const Wc=class Wc extends Dt{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}get partial(){return new Wc(this.shape,!0)}check(e,n){return e==null?(n==null||n.extend(null,"object","null"),!1):rs(this.shape,(r,o)=>{const i=this._isPartial&&!Vp(e,o)||r.check(e[o],n);return!i&&(n==null||n.extend(o.toString(),r.toString(),typeof e[o],"Object property does not match")),i})}};B(Wc,"_dilutes",!0);let kc=Wc;const a$=t=>new kc(t),c$=rt(kc),d$=pt(t=>t!=null&&(t.constructor===Object||t.constructor==null));class tx extends Dt{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&rs(e,(r,o)=>{const i=this.shape.keys.check(o,n);return!i&&(n==null||n.extend(o+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value")),i&&this.shape.values.check(r,n)})}}const nx=(t,e)=>new tx(t,e),u$=rt(tx);class rx extends Dt{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&rs(this.shape,(r,o)=>{const i=r.check(e[o],n);return!i&&(n==null||n.extend(o.toString(),"Tuple",typeof r)),i})}}const f$=(...t)=>new rx(t);rt(rx);class ox extends Dt{constructor(e){super(),this.shape=e.length===1?e[0]:new yd(e)}check(e,n){const r=qi(e)&&_p(e,o=>this.shape.check(o));return!r&&(n==null||n.extend(null,"Array","")),r}}const ix=(...t)=>new ox(t),h$=rt(ox),p$=pt(t=>qi(t));class sx extends Dt{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&(n==null||n.extend(null,this.shape.name,e==null?void 0:e.constructor.name)),r}}const m$=(t,e=null)=>new sx(t,e);rt(sx);const g$=m$(Dt);class b$ extends Dt{constructor(e){super(),this.len=e.length-1,this.args=f$(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof e)),r}}const y$=rt(b$),v$=pt(t=>typeof t=="function");class w$ extends Dt{constructor(e){super(),this.shape=e}check(e,n){const r=_p(this.shape,o=>o.check(e,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof e)),r}}rt(w$,t=>t.shape.length>0);class yd extends Dt{constructor(e){super(),this.shape=e}check(e,n){const r=Pp(this.shape,o=>o.check(e,n));return n==null||n.extend(null,"Union",typeof e),r}}B(yd,"_dilutes",!0);const is=(...t)=>t.findIndex(e=>xc.check(e))>=0?is(...t.map(e=>al(e)).map(e=>xc.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new yd(t),xc=rt(yd),lx=()=>!0,Cc=pt(lx),k$=rt(Up,t=>t.shape===lx),Wp=pt(t=>typeof t=="bigint"),x$=pt(t=>t===Wp),ax=pt(t=>typeof t=="symbol");pt(t=>t===ax);const Ii=pt(t=>typeof t=="number"),cx=pt(t=>t===Ii),Ji=pt(t=>typeof t=="string"),dx=pt(t=>t===Ji),vd=pt(t=>typeof t=="boolean"),C$=pt(t=>t===vd),ux=bd(void 0);rt(gd,t=>t.shape.length===1&&t.shape[0]===void 0);bd(void 0);const wd=bd(null),S$=rt(gd,t=>t.shape.length===1&&t.shape[0]===null);rt(Uint8Array);rt(zp,t=>t.shape===Uint8Array);const E$=is(Ii,Ji,wd,ux,Wp,vd,ax);(()=>{const t=ix(Cc),e=nx(Ji,Cc),n=is(Ii,Ji,wd,vd,t,e);return t.shape=n,e.shape.values=n,n})();const al=t=>{if(g$.check(t))return t;if(d$.check(t)){const e={};for(const n in t)e[n]=al(t[n]);return a$(e)}else{if(p$.check(t))return is(...t.map(al));if(E$.check(t))return bd(t);if(v$.check(t))return rt(t)}Vt()},Dy=zP?()=>{}:(t,e)=>{const n=new n$;if(!e.check(t,n))throw cr(`Expected value to be of type ${e.constructor.name}.
115
+ ${n.toString()}`)};class M${constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:al(e),h:n}),this}else(e){return this.if(Cc,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const o=this.patterns[r];if(o.if.check(e))return o.h(e,n)}throw cr("Unhandled pattern")}}}const T$=t=>new M$(t),fx=T$(Cc).if(cx,(t,e)=>Fu(e,Cy,yc)).if(dx,(t,e)=>e$(e)).if(C$,(t,e)=>Oy(e)).if(x$,(t,e)=>BigInt(Fu(e,Cy,yc))).if(xc,(t,e)=>gi(e,zu(e,t.shape))).if(c$,(t,e)=>{const n={};for(const r in t.shape){let o=t.shape[r];if(s$.check(o)){if(Oy(e))continue;o=o.shape}n[r]=fx(o,e)}return n}).if(h$,(t,e)=>{const n=[],r=Yk(e,0,42);for(let o=0;o<r;o++)n.push(gi(e,t.shape));return n}).if(Xk,(t,e)=>zu(e,t.shape)).if(S$,(t,e)=>null).if(y$,(t,e)=>{const n=gi(e,t.res);return()=>n}).if(k$,(t,e)=>gi(e,zu(e,[Ii,Ji,wd,ux,Wp,vd,ix(Ii),nx(is("a","b","c"),Ii)]))).if(u$,(t,e)=>{const n={},r=Fu(e,0,3);for(let o=0;o<r;o++){const i=gi(e,t.shape.keys),s=gi(e,t.shape.values);n[i]=s}return n}).done(),gi=(t,e)=>fx(al(e),t),$l=typeof document<"u"?document:{};pt(t=>t.nodeType===O$);typeof DOMParser<"u"&&new DOMParser;pt(t=>t.nodeType===N$);pt(t=>t.nodeType===R$);const A$=t=>Y_(t,(e,n)=>`${n}:${e};`).join(""),N$=$l.ELEMENT_NODE,R$=$l.TEXT_NODE,I$=$l.DOCUMENT_NODE,O$=$l.DOCUMENT_FRAGMENT_NODE;pt(t=>t.nodeType===I$);const D$=t=>class{constructor(n){this._=n}destroy(){t(this._)}},_$=D$(clearTimeout),qp=(t,e)=>new _$(setTimeout(e,t)),Br=Symbol,hx=Br(),px=Br(),P$=Br(),$$=Br(),L$=Br(),mx=Br(),B$=Br(),Gp=Br(),j$=Br(),V$=t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const i=t[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const i=t[r];i instanceof Symbol||n.push(i)}return n},H$={[hx]:br("font-weight","bold"),[px]:br("font-weight","normal"),[P$]:br("color","blue"),[L$]:br("color","green"),[$$]:br("color","grey"),[mx]:br("color","red"),[B$]:br("color","purple"),[Gp]:br("color","orange"),[j$]:br("color","black")},F$=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Cn();let o=[],i=0;for(;i<t.length;i++){const l=t[i],a=H$[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=A$(r);i>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(i>0&&(o=n,o.unshift(e.join("")));i<t.length;i++){const l=t[i];l instanceof Symbol||o.push(l)}return o},gx=WP?F$:V$,z$=(...t)=>{console.log(...gx(t)),yx.forEach(e=>e.print(t))},bx=(...t)=>{console.warn(...gx(t)),t.unshift(Gp),yx.forEach(e=>e.print(t))},yx=Ko(),vx=t=>({[Symbol.iterator](){return this},next:t}),U$=(t,e)=>vx(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Uu=(t,e)=>vx(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class kd{constructor(e,n){this.clock=e,this.len=n}}class ss{constructor(){this.clients=new Map}}const io=(t,e,n)=>e.clients.forEach((r,o)=>{const i=t.doc.store.clients.get(o);if(i!=null){const s=i[i.length-1],l=s.id.clock+s.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])Dx(t,i,c.clock,c.len,n)}}),W$=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const o=Un((n+r)/2),i=t[o],s=i.clock;if(s<=e){if(e<s+i.len)return o;n=o+1}else r=o-1}return null},ls=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&W$(n,e.clock)!==null},Zp=t=>{t.clients.forEach(e=>{e.sort((o,i)=>o.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const o=e[r-1],i=e[n];o.clock+o.len>=i.clock?e[r-1]=new kd(o.clock,Wn(o.len,i.clock+i.len-o.clock)):(r<n&&(e[r]=i),r++)}e.length=r})},ah=t=>{const e=new ss;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,o)=>{if(!e.clients.has(o)){const i=r.slice();for(let s=n+1;s<t.length;s++)Q_(i,t[s].clients.get(o)||[]);e.clients.set(o,i)}});return Zp(e),e},cl=(t,e,n,r)=>{hr(t.clients,e,()=>[]).push(new kd(n,r))},wx=()=>new ss,kx=t=>{const e=wx();return t.clients.forEach((n,r)=>{const o=[];for(let i=0;i<n.length;i++){const s=n[i];if(s.deleted){const l=s.id.clock;let a=s.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;o.push(new kd(l,a))}}o.length>0&&e.clients.set(r,o)}),e},as=(t,e)=>{ge(t.restEncoder,e.clients.size),oo(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ge(t.restEncoder,n);const o=r.length;ge(t.restEncoder,o);for(let i=0;i<o;i++){const s=r[i];t.writeDsClock(s.clock),t.writeDsLen(s.len)}})},Kp=t=>{const e=new ss,n=pe(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const o=pe(t.restDecoder),i=pe(t.restDecoder);if(i>0){const s=hr(e.clients,o,()=>[]);for(let l=0;l<i;l++)s.push(new kd(t.readDsClock(),t.readDsLen()))}}return e},_y=(t,e,n)=>{const r=new ss,o=pe(t.restDecoder);for(let i=0;i<o;i++){t.resetDsCurVal();const s=pe(t.restDecoder),l=pe(t.restDecoder),a=n.clients.get(s)||[],c=Xe(n,s);for(let d=0;d<l;d++){const u=t.readDsClock(),f=u+t.readDsLen();if(u<c){c<f&&cl(r,s,c,f-c);let h=Tn(a,u),p=a[h];for(!p.deleted&&p.id.clock<u&&(a.splice(h+1,0,Rc(e,p,u-p.id.clock)),h++);h<a.length&&(p=a[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&a.splice(h,0,Rc(e,p,f-p.id.clock)),p.delete(e))}else cl(r,s,u,f-u)}}if(r.clients.size>0){const i=new Jo;return ge(i.restEncoder,0),as(i,r),i.toUint8Array()}return null},xx=Nk;class vo extends Vk{constructor({guid:e=Rp(),collectionid:n=null,gc:r=!0,gcFilter:o=()=>!0,meta:i=null,autoLoad:s=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=o,this.clientID=xx(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new Ix,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=s,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Ry(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>Ry(c=>{const d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ie(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(oo(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Ie(this,e,n)}get(e,n=ct){const r=hr(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),o=r.constructor;if(n!==ct&&o!==n)if(o===ct){const i=new n;i._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=i}),i._start=r._start;for(let s=i._start;s!==null;s=s.right)s.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,_i)}getText(e=""){return this.get(e,so)}getMap(e=""){return this.get(e,Xi)}getXmlElement(e=""){return this.get(e,vt)}getXmlFragment(e=""){return this.get(e,Yo)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,oo(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new vo({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Ie(e.parent.doc,r=>{const o=n.doc;e.deleted||r.subdocsAdded.add(o),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Cx{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return pe(this.restDecoder)}readDsLen(){return pe(this.restDecoder)}}class Sx extends Cx{readLeftID(){return oe(pe(this.restDecoder),pe(this.restDecoder))}readRightID(){return oe(pe(this.restDecoder),pe(this.restDecoder))}readClient(){return pe(this.restDecoder)}readInfo(){return Zi(this.restDecoder)}readString(){return Ri(this.restDecoder)}readParentInfo(){return pe(this.restDecoder)===1}readTypeRef(){return pe(this.restDecoder)}readLen(){return pe(this.restDecoder)}readAny(){return sl(this.restDecoder)}readBuf(){return JP(tn(this.restDecoder))}readJSON(){return JSON.parse(Ri(this.restDecoder))}readKey(){return Ri(this.restDecoder)}}class q${constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=pe(this.restDecoder),this.dsCurrVal}readDsLen(){const e=pe(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Yi extends q${constructor(e){super(e),this.keys=[],pe(e),this.keyClockDecoder=new Hu(tn(e)),this.clientDecoder=new Fa(tn(e)),this.leftClockDecoder=new Hu(tn(e)),this.rightClockDecoder=new Hu(tn(e)),this.infoDecoder=new Ny(tn(e),Zi),this.stringDecoder=new NP(tn(e)),this.parentInfoDecoder=new Ny(tn(e),Zi),this.typeRefDecoder=new Fa(tn(e)),this.lenDecoder=new Fa(tn(e))}readLeftID(){return new Oi(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Oi(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return sl(this.restDecoder)}readBuf(){return tn(this.restDecoder)}readJSON(){return sl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class Ex{constructor(){this.restEncoder=Pl()}toUint8Array(){return Ln(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ge(this.restEncoder,e)}writeDsLen(e){ge(this.restEncoder,e)}}class Ll extends Ex{writeLeftID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeRightID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeClient(e){ge(this.restEncoder,e)}writeInfo(e){oh(this.restEncoder,e)}writeString(e){Ni(this.restEncoder,e)}writeParentInfo(e){ge(this.restEncoder,e?1:0)}writeTypeRef(e){ge(this.restEncoder,e)}writeLen(e){ge(this.restEncoder,e)}writeAny(e){Gi(this.restEncoder,e)}writeBuf(e){en(this.restEncoder,e)}writeJSON(e){Ni(this.restEncoder,JSON.stringify(e))}writeKey(e){Ni(this.restEncoder,e)}}class Mx{constructor(){this.restEncoder=Pl(),this.dsCurrVal=0}toUint8Array(){return Ln(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ge(this.restEncoder,n)}writeDsLen(e){e===0&&Vt(),ge(this.restEncoder,e-1),this.dsCurrVal+=e}}class Jo extends Mx{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Vu,this.clientEncoder=new Ha,this.leftClockEncoder=new Vu,this.rightClockEncoder=new Vu,this.infoEncoder=new My(oh),this.stringEncoder=new wP,this.parentInfoEncoder=new My(oh),this.typeRefEncoder=new Ha,this.lenEncoder=new Ha}toUint8Array(){const e=Pl();return ge(e,0),en(e,this.keyClockEncoder.toUint8Array()),en(e,this.clientEncoder.toUint8Array()),en(e,this.leftClockEncoder.toUint8Array()),en(e,this.rightClockEncoder.toUint8Array()),en(e,Ln(this.infoEncoder)),en(e,this.stringEncoder.toUint8Array()),en(e,Ln(this.parentInfoEncoder)),en(e,this.typeRefEncoder.toUint8Array()),en(e,this.lenEncoder.toUint8Array()),pd(e,Ln(this.restEncoder)),Ln(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Gi(this.restEncoder,e)}writeBuf(e){en(this.restEncoder,e)}writeJSON(e){Gi(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const G$=(t,e,n,r)=>{r=Wn(r,e[0].id.clock);const o=Tn(e,r);ge(t.restEncoder,e.length-o),t.writeClient(n),ge(t.restEncoder,r);const i=e[o];i.write(t,r-i.id.clock);for(let s=o+1;s<e.length;s++)e[s].write(t,0)},Jp=(t,e,n)=>{const r=new Map;n.forEach((o,i)=>{Xe(e,i)>o&&r.set(i,o)}),Bl(e).forEach((o,i)=>{n.has(i)||r.set(i,0)}),ge(t.restEncoder,r.size),oo(r.entries()).sort((o,i)=>i[0]-o[0]).forEach(([o,i])=>{G$(t,e.clients.get(o),o,i)})},Z$=(t,e)=>{const n=Cn(),r=pe(t.restDecoder);for(let o=0;o<r;o++){const i=pe(t.restDecoder),s=new Array(i),l=t.readClient();let a=pe(t.restDecoder);n.set(l,{i:0,refs:s});for(let c=0;c<i;c++){const d=t.readInfo();switch(fd&d){case 0:{const u=t.readLen();s[c]=new bn(oe(l,a),u),a+=u;break}case 10:{const u=pe(t.restDecoder);s[c]=new yn(oe(l,a),u),a+=u;break}default:{const u=(d&(Ir|Lt))===0,f=new He(oe(l,a),null,(d&Lt)===Lt?t.readLeftID():null,null,(d&Ir)===Ir?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(d&ol)===ol?t.readString():null,tC(t,d));s[c]=f,a+=f.length}}}}return n},K$=(t,e,n)=>{const r=[];let o=oo(n.keys()).sort((h,p)=>h-p);if(o.length===0)return null;const i=()=>{if(o.length===0)return null;let h=n.get(o[o.length-1]);for(;h.refs.length===h.i;)if(o.pop(),o.length>0)h=n.get(o[o.length-1]);else return null;return h};let s=i();if(s===null)return null;const l=new Ix,a=new Map,c=(h,p)=>{const m=a.get(h);(m==null||m>p)&&a.set(h,p)};let d=s.refs[s.i++];const u=new Map,f=()=>{for(const h of r){const p=h.id.client,m=n.get(p);m?(m.i--,l.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):l.clients.set(p,[h]),o=o.filter(g=>g!==p)}r.length=0};for(;;){if(d.constructor!==yn){const p=hr(u,d.id.client,()=>Xe(e,d.id.client))-d.id.clock;if(p<0)r.push(d),c(d.id.client,d.id.clock-1),f();else{const m=d.getMissing(t,e);if(m!==null){r.push(d);const g=n.get(m)||{refs:[],i:0};if(g.refs.length===g.i)c(m,Xe(e,m)),f();else{d=g.refs[g.i++];continue}}else(p===0||p<d.length)&&(d.integrate(t,p),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(s!==null&&s.i<s.refs.length)d=s.refs[s.i++];else{if(s=i(),s===null)break;d=s.refs[s.i++]}}if(l.clients.size>0){const h=new Jo;return Jp(h,l,new Map),ge(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},J$=(t,e)=>Jp(t,e.doc.store,e.beforeState),Y$=(t,e,n,r=new Yi(t))=>Ie(e,o=>{o.local=!1;let i=!1;const s=o.doc,l=s.store,a=Z$(r,s),c=K$(o,l,a),d=l.pendingStructs;if(d){for(const[f,h]of d.missing)if(h<Xe(l,f)){i=!0;break}if(c){for(const[f,h]of c.missing){const p=d.missing.get(f);(p==null||p>h)&&d.missing.set(f,h)}d.update=Ec([d.update,c.update])}}else l.pendingStructs=c;const u=_y(r,o,l);if(l.pendingDs){const f=new Yi(ns(l.pendingDs));pe(f.restDecoder);const h=_y(f,o,l);u&&h?l.pendingDs=Ec([u,h]):l.pendingDs=u||h}else l.pendingDs=u;if(i){const f=l.pendingStructs.update;l.pendingStructs=null,Sc(o.doc,f)}},n,!1),Sc=(t,e,n,r=Yi)=>{const o=ns(e);Y$(o,t,n,new r(o))},Py=(t,e,n)=>Sc(t,e,n,Sx),X$=(t,e,n=new Map)=>{Jp(t,e.store,n),as(t,kx(e.store))},Q$=(t,e=new Uint8Array([0]),n=new Jo)=>{const r=Tx(e);X$(n,t,r);const o=[n.toUint8Array()];if(t.store.pendingDs&&o.push(t.store.pendingDs),t.store.pendingStructs&&o.push(y5(t.store.pendingStructs.update,e)),o.length>1){if(n.constructor===Ll)return g5(o.map((i,s)=>s===0?i:w5(i)));if(n.constructor===Jo)return Ec(o)}return o[0]},$y=(t,e)=>Q$(t,e,new Ll),e5=t=>{const e=new Map,n=pe(t.restDecoder);for(let r=0;r<n;r++){const o=pe(t.restDecoder),i=pe(t.restDecoder);e.set(o,i)}return e},Tx=t=>e5(new Cx(ns(t))),Ax=(t,e)=>(ge(t.restEncoder,e.size),oo(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{ge(t.restEncoder,n),ge(t.restEncoder,r)}),t),t5=(t,e)=>Ax(t,Bl(e.store)),n5=(t,e=new Mx)=>(t instanceof Map?Ax(e,t):t5(e,t),e.toUint8Array()),r5=t=>n5(t,new Ex);class o5{constructor(){this.l=[]}}const Ly=()=>new o5,By=(t,e)=>t.l.push(e),jy=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(o=>e!==o),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Nx=(t,e,n)=>Hp(t.l,[e,n]);class Oi{constructor(e,n){this.client=e,this.clock=n}}const xi=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,oe=(t,e)=>new Oi(t,e),dl=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Vt()},ul=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class fl{constructor(e,n,r,o=0){this.type=e,this.tname=n,this.item=r,this.assoc=o}}const Hs=t=>new fl(t.type==null?null:oe(t.type.client,t.type.clock),t.tname??null,t.item==null?null:oe(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class i5{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const s5=(t,e,n=0)=>new i5(t,e,n),ga=(t,e,n)=>{let r=null,o=null;return t._item===null?o=dl(t):r=oe(t._item.id.client,t._item.id.clock),new fl(r,o,e,n)},Wu=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return ga(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return ga(t,oe(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return ga(t,r.lastId,n);r=r.right}return ga(t,null,n)},l5=(t,e)=>{const n=Di(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},a5=(t,e,n=!0)=>{const r=e.store,o=t.item,i=t.type,s=t.tname,l=t.assoc;let a=null,c=0;if(o!==null){if(Xe(r,o.client)<=o.clock)return null;const d=n?fh(r,o):l5(r,o),u=d.item;if(!(u instanceof He))return null;if(a=u.parent,a._item===null||!a._item.deleted){c=u.deleted||!u.countable?0:d.diff+(l>=0?0:1);let f=u.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(s!==null)a=e.get(s);else if(i!==null){if(Xe(r,i.client)<=i.clock)return null;const{item:d}=n?fh(r,i):{item:Di(r,i)};if(d instanceof He&&d.content instanceof Yn)a=d.content.type;else return null}else throw Vt();l>=0?c=a._length:c=0}return s5(a,c,t.assoc)},Vy=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&xi(t.item,e.item)&&xi(t.type,e.type)&&t.assoc===e.assoc;class Yp{constructor(e,n){this.ds=e,this.sv=n}}const Rx=(t,e)=>new Yp(t,e),qu=t=>Rx(kx(t.store),Bl(t.store)),Mo=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ls(e.ds,t.id),ch=(t,e)=>{const n=hr(t.meta,ch,Ko),r=t.doc.store;n.has(e)||(e.sv.forEach((o,i)=>{o<Xe(r,i)&&Ut(t,oe(i,o))}),io(t,e.ds,o=>{}),n.add(e))};class Ix{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Bl=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const o=n[n.length-1];e.set(r,o.id.clock+o.length)}),e},Xe=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},Ox=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Vt()}n.push(e)},Tn=(t,e)=>{let n=0,r=t.length-1,o=t[r],i=o.id.clock;if(i===e)return r;let s=Un(e/(i+o.length-1)*r);for(;n<=r;){if(o=t[s],i=o.id.clock,i<=e){if(e<i+o.length)return s;n=s+1}else r=s-1;s=Un((n+r)/2)}throw Vt()},c5=(t,e)=>{const n=t.clients.get(e.client);return n[Tn(n,e.clock)]},Di=c5,dh=(t,e,n)=>{const r=Tn(e,n),o=e[r];return o.id.clock<n&&o instanceof He?(e.splice(r+1,0,Rc(t,o,n-o.id.clock)),r+1):r},Ut=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[dh(t,n,e.clock)]},Hy=(t,e,n)=>{const r=e.clients.get(n.client),o=Tn(r,n.clock),i=r[o];return n.clock!==i.id.clock+i.length-1&&i.constructor!==bn&&r.splice(o+1,0,Rc(t,i,n.clock-i.id.clock+1)),i},d5=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Tn(r,e.id.clock)]=n},Dx=(t,e,n,r,o)=>{if(r===0)return;const i=n+r;let s=dh(t,e,n),l;do l=e[s++],i<l.id.clock+l.length&&dh(t,e,i),o(l);while(s<e.length&&e[s].id.clock<i)};class u5{constructor(e,n,r){this.doc=e,this.deleteSet=new ss,this.beforeState=Bl(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Fy=(t,e)=>e.deleteSet.clients.size===0&&!X_(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Zp(e.deleteSet),J$(t,e),as(t,e.deleteSet),!0),zy=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&hr(t.changed,e,Ko).add(n)},Ua=(t,e)=>{let n=t[e],r=t[e-1],o=e;for(;o>0;n=r,r=t[--o-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof He&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-o;return i&&t.splice(e+1-i,i),i},f5=(t,e,n)=>{for(const[r,o]of t.clients.entries()){const i=e.clients.get(r);for(let s=o.length-1;s>=0;s--){const l=o[s],a=l.clock+l.len;for(let c=Tn(i,l.clock),d=i[c];c<i.length&&d.id.clock<a;d=i[++c]){const u=i[c];if(l.clock+l.len<=u.id.clock)break;u instanceof He&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},h5=(t,e)=>{t.clients.forEach((n,r)=>{const o=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const s=n[i],l=Rr(o.length-1,1+Tn(o,s.clock+s.len-1));for(let a=l,c=o[a];a>0&&c.id.clock>=s.clock;c=o[a])a-=1+Ua(o,a)}})},_x=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,o=r.store,i=n.deleteSet,s=n._mergeStructs;try{Zp(i),n.afterState=Bl(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(d=>d.target._item===null||!d.target._item.deleted),a.forEach(d=>{d.currentTarget=c,d._path=null}),a.sort((d,u)=>d.path.length-u.path.length),l.push(()=>{Nx(c._dEH,a,n)}))}),l.push(()=>r.emit("afterTransaction",[n,r])),l.push(()=>{n._needFormattingCleanup&&_5(n)})}),Hp(l,[])}finally{r.gc&&f5(i,o,r.gcFilter),h5(i,o),n.afterState.forEach((d,u)=>{const f=n.beforeState.get(u)||0;if(f!==d){const h=o.clients.get(u),p=Wn(Tn(h,f),1);for(let m=h.length-1;m>=p;)m-=1+Ua(h,m)}});for(let d=s.length-1;d>=0;d--){const{client:u,clock:f}=s[d].id,h=o.clients.get(u),p=Tn(h,f);p+1<h.length&&Ua(h,p+1)>1||p>0&&Ua(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(z$(Gp,hx,"[yjs] ",px,mx,"Changed the client-id because another client seems to be using it."),r.clientID=xx()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new Ll;Fy(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new Jo;Fy(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(d=>d.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):_x(t,e+1)}}},Ie=(t,e,n=null,r=!0)=>{const o=t._transactionCleanups;let i=!1,s=null;t._transaction===null&&(i=!0,t._transaction=new u5(t,n,r),o.push(t._transaction),o.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{s=e(t._transaction)}finally{if(i){const l=t._transaction===o[0];t._transaction=null,l&&_x(o,0)}}return s};class p5{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Uy=(t,e,n)=>{io(t,n.deletions,r=>{r instanceof He&&e.scope.some(o=>o===t.doc||ul(o,r))&&im(r,!1)})},Wy=(t,e,n)=>{let r=null;const o=t.doc,i=t.scope;Ie(o,l=>{for(;e.length>0&&t.currStackItem===null;){const a=o.store,c=e.pop(),d=new Set,u=[];let f=!1;io(l,c.insertions,h=>{if(h instanceof He){if(h.redone!==null){let{item:p,diff:m}=fh(a,h.id);m>0&&(p=Ut(l,oe(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>p===l.doc||ul(p,h))&&u.push(h)}}),io(l,c.deletions,h=>{h instanceof He&&i.some(p=>p===l.doc||ul(p,h))&&!ls(c.insertions,h.id)&&d.add(h)}),d.forEach(h=>{f=eC(l,h,d,c.insertions,t.ignoreRemoteMapChanges,t)!==null||f});for(let h=u.length-1;h>=0;h--){const p=u[h];t.deleteFilter(p)&&(p.delete(l),f=!0)}t.currStackItem=f?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const s=t.currStackItem;if(s!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return s};class Px extends Vk{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:o=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:l=qi(e)?e[0].doc:e instanceof vo?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=o,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(g=>a.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,d=this.redoing,u=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const f=new ss;a.afterState.forEach((g,y)=>{const w=a.beforeState.get(y)||0,k=g-w;k>0&&cl(f,y,w,k)});const h=RP();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&u.length>0&&!c&&!d){const g=u[u.length-1];g.deletions=ah([g.deletions,a.deleteSet]),g.insertions=ah([g.insertions,f])}else u.push(new p5(a.deleteSet,f)),p=!0;!c&&!d&&(this.lastChange=h),io(a,a.deleteSet,g=>{g instanceof He&&this.scope.some(y=>y===a.doc||ul(y,g))&&im(g,!0)});const m=[{stackItem:u[u.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=qi(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof ct?r.doc!==this.doc:r!==this.doc)&&bx("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(o=>Uy(r,this,o)),this.undoStack=[]),n&&(this.redoStack.forEach(o=>Uy(r,this,o)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Wy(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Wy(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*m5(t){const e=pe(t.restDecoder);for(let n=0;n<e;n++){const r=pe(t.restDecoder),o=t.readClient();let i=pe(t.restDecoder);for(let s=0;s<r;s++){const l=t.readInfo();if(l===10){const a=pe(t.restDecoder);yield new yn(oe(o,i),a),i+=a}else if((fd&l)!==0){const a=(l&(Ir|Lt))===0,c=new He(oe(o,i),null,(l&Lt)===Lt?t.readLeftID():null,null,(l&Ir)===Ir?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&ol)===ol?t.readString():null,tC(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new bn(oe(o,i),a),i+=a}}}}class Xp{constructor(e,n){this.gen=m5(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===yn);return this.curr}}class Qp{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const g5=t=>Ec(t,Sx,Ll),b5=(t,e)=>{if(t.constructor===bn){const{client:n,clock:r}=t.id;return new bn(oe(n,r+e),t.length-e)}else if(t.constructor===yn){const{client:n,clock:r}=t.id;return new yn(oe(n,r+e),t.length-e)}else{const n=t,{client:r,clock:o}=n.id;return new He(oe(r,o+e),null,oe(r,o+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Ec=(t,e=Yi,n=Jo)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(ns(d)));let o=r.map(d=>new Xp(d,!0)),i=null;const s=new n,l=new Qp(s);for(;o=o.filter(f=>f.curr!==null),o.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){const p=f.curr.id.clock-h.curr.id.clock;return p===0?f.curr.constructor===h.curr.constructor?0:f.curr.constructor===yn?1:-1:p}else return h.curr.id.client-f.curr.id.client}),o.length!==0;){const d=o[0],u=d.curr.id.client;if(i!==null){let f=d.curr,h=!1;for(;f!==null&&f.id.clock+f.length<=i.struct.id.clock+i.struct.length&&f.id.client>=i.struct.id.client;)f=d.next(),h=!0;if(f===null||f.id.client!==u||h&&f.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)Kr(l,i.struct,i.offset),i={struct:f,offset:0},d.next();else if(i.struct.id.clock+i.struct.length<f.id.clock)if(i.struct.constructor===yn)i.struct.length=f.id.clock+f.length-i.struct.id.clock;else{Kr(l,i.struct,i.offset);const p=f.id.clock-i.struct.id.clock-i.struct.length;i={struct:new yn(oe(u,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-f.id.clock;p>0&&(i.struct.constructor===yn?i.struct.length-=p:f=b5(f,p)),i.struct.mergeWith(f)||(Kr(l,i.struct,i.offset),i={struct:f,offset:0},d.next())}}else i={struct:d.curr,offset:0},d.next();for(let f=d.curr;f!==null&&f.id.client===u&&f.id.clock===i.struct.id.clock+i.struct.length&&f.constructor!==yn;f=d.next())Kr(l,i.struct,i.offset),i={struct:f,offset:0}}i!==null&&(Kr(l,i.struct,i.offset),i=null),em(l);const a=r.map(d=>Kp(d)),c=ah(a);return as(s,c),s.toUint8Array()},y5=(t,e,n=Yi,r=Jo)=>{const o=Tx(e),i=new r,s=new Qp(i),l=new n(ns(t)),a=new Xp(l,!1);for(;a.curr;){const d=a.curr,u=d.id.client,f=o.get(u)||0;if(a.curr.constructor===yn){a.next();continue}if(d.id.clock+d.length>f)for(Kr(s,d,Wn(f-d.id.clock,0)),a.next();a.curr&&a.curr.id.client===u;)Kr(s,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===u&&a.curr.id.clock+a.curr.length<=f;)a.next()}em(s);const c=Kp(l);return as(i,c),i.toUint8Array()},$x=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Ln(t.encoder.restEncoder)}),t.encoder.restEncoder=Pl(),t.written=0)},Kr=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&$x(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ge(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},em=t=>{$x(t);const e=t.encoder.restEncoder;ge(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ge(e,r.written),pd(e,r.restEncoder)}},v5=(t,e,n,r)=>{const o=new n(ns(t)),i=new Xp(o,!1),s=new r,l=new Qp(s);for(let c=i.curr;c!==null;c=i.next())Kr(l,e(c),0);em(l);const a=Kp(o);return as(s,a),s.toUint8Array()},w5=t=>v5(t,VP,Yi,Ll),qy="You must not compute changes after the event-handler fired.";class xd{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=k5(this.currentTarget,this.target))}deletes(e){return ls(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw cr(qy);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(o=>{if(o!==null){const i=n._map.get(o);let s,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))s="delete",l=ju(a.content.getContent());else return;else a!==null&&this.deletes(a)?(s="update",l=ju(a.content.getContent())):(s="add",l=void 0)}else if(this.deletes(i))s="delete",l=ju(i.content.getContent());else return;e.set(o,{action:s,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw cr(qy);const n=this.target,r=Ko(),o=Ko(),i=[];if(e={added:r,deleted:o,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,o.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const k5=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,o=e._item.parent._start;for(;o!==e._item&&o!==null;)!o.deleted&&o.countable&&(r+=o.length),o=o.right;n.unshift(r)}e=e._item.parent}return n},At=()=>{bx("Invalid access: Add Yjs type to a document before reading data.")},Lx=80;let tm=0;class x5{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=tm++}}const C5=t=>{t.timestamp=tm++},Bx=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=tm++},S5=(t,e,n)=>{if(t.length>=Lx){const r=t.reduce((o,i)=>o.timestamp<i.timestamp?o:i);return Bx(r,e,n),r}else{const r=new x5(e,n);return t.push(r),r}},Cd=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,s)=>Ba(e-i.index)<Ba(e-s.index)?i:s);let r=t._start,o=0;for(n!==null&&(r=n.p,o=n.index,C5(n));r.right!==null&&o<e;){if(!r.deleted&&r.countable){if(e<o+r.length)break;o+=r.length}r=r.right}for(;r.left!==null&&o>e;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return n!==null&&Ba(n.index-o)<r.parent.length/Lx?(Bx(n,r,o),n):S5(t._searchMarker,r,o)},hl=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const o=t[r];if(n>0){let i=o.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(o.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}o.p=i,i.marker=!0}(e<o.index||n>0&&e===o.index)&&(o.index=Wn(e,o.index+n))}},Sd=(t,e,n)=>{const r=t,o=e.changedParentTypes;for(;hr(o,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;Nx(r._eH,n,e)};class ct{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ly(),this._dEH=Ly(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Sn()}clone(){throw Sn()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){By(this._eH,e)}observeDeep(e){By(this._dEH,e)}unobserve(e){jy(this._eH,e)}unobserveDeep(e){jy(this._dEH,e)}toJSON(){}}const jx=(t,e,n)=>{t.doc??At(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const o=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const s=i.content.getContent();if(s.length<=e)e-=s.length;else{for(let l=e;l<s.length&&r>0;l++)o.push(s[l]),r--;e=0}}i=i.right}return o},Vx=t=>{t.doc??At();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let o=0;o<r.length;o++)e.push(r[o])}n=n.right}return e},Hx=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Mo(r,e)){const o=r.content.getContent();for(let i=0;i<o.length;i++)n.push(o[i])}r=r.right}return n},pl=(t,e)=>{let n=0,r=t._start;for(t.doc??At();r!==null;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let i=0;i<o.length;i++)e(o[i],n++,t)}r=r.right}},Fx=(t,e)=>{const n=[];return pl(t,(r,o)=>{n.push(e(r,o,t))}),n},E5=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const o=n[r++];return n.length<=r&&(n=null),{done:!1,value:o}}}},zx=(t,e)=>{t.doc??At();const n=Cd(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Mc=(t,e,n,r)=>{let o=n;const i=t.doc,s=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const d=()=>{c.length>0&&(o=new He(oe(s,Xe(l,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Xo(c)),o.integrate(t,0),c=[])};r.forEach(u=>{if(u===null)c.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:o=new He(oe(s,Xe(l,s)),o,o&&o.lastId,a,a&&a.id,e,null,new jl(new Uint8Array(u))),o.integrate(t,0);break;case vo:o=new He(oe(s,Xe(l,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Vl(u)),o.integrate(t,0);break;default:if(u instanceof ct)o=new He(oe(s,Xe(l,s)),o,o&&o.lastId,a,a&&a.id,e,null,new Yn(u)),o.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},Ux=()=>cr("Length exceeded!"),Wx=(t,e,n,r)=>{if(n>e._length)throw Ux();if(n===0)return e._searchMarker&&hl(e._searchMarker,n,r.length),Mc(t,e,null,r);const o=n,i=Cd(e,n);let s=e._start;for(i!==null&&(s=i.p,n-=i.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&Ut(t,oe(s.id.client,s.id.clock+n));break}n-=s.length}return e._searchMarker&&hl(e._searchMarker,o,r.length),Mc(t,e,s,r)},M5=(t,e,n)=>{let o=(e._searchMarker||[]).reduce((i,s)=>s.index>i.index?s:i,{index:0,p:e._start}).p;if(o)for(;o.right;)o=o.right;return Mc(t,e,o,n)},qx=(t,e,n,r)=>{if(r===0)return;const o=n,i=r,s=Cd(e,n);let l=e._start;for(s!==null&&(l=s.p,n-=s.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&Ut(t,oe(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&Ut(t,oe(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw Ux();e._searchMarker&&hl(e._searchMarker,o,-i+r)},Tc=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},nm=(t,e,n,r)=>{const o=e._map.get(n)||null,i=t.doc,s=i.clientID;let l;if(r==null)l=new Xo([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Xo([r]);break;case Uint8Array:l=new jl(r);break;case vo:l=new Vl(r);break;default:if(r instanceof ct)l=new Yn(r);else throw new Error("Unexpected content type")}new He(oe(s,Xe(i.store,s)),o,o&&o.lastId,null,null,e,n,l).integrate(t,0)},rm=(t,e)=>{t.doc??At();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Gx=t=>{const e={};return t.doc??At(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},Zx=(t,e)=>{t.doc??At();const n=t._map.get(e);return n!==void 0&&!n.deleted},T5=(t,e)=>{const n={};return t._map.forEach((r,o)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Mo(i,e)&&(n[o]=i.content.getContent()[i.length-1])}),n},ba=t=>(t.doc??At(),U$(t._map.entries(),e=>!e[1].deleted));class A5 extends xd{}class _i extends ct{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new _i;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new _i}clone(){const e=new _i;return e.insert(0,this.toArray().map(n=>n instanceof ct?n.clone():n)),e}get length(){return this.doc??At(),this._length}_callObserver(e,n){super._callObserver(e,n),Sd(this,e,new A5(this,e))}insert(e,n){this.doc!==null?Ie(this.doc,r=>{Wx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Ie(this.doc,n=>{M5(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Ie(this.doc,r=>{qx(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return zx(this,e)}toArray(){return Vx(this)}slice(e=0,n=this.length){return jx(this,e,n)}toJSON(){return this.map(e=>e instanceof ct?e.toJSON():e)}map(e){return Fx(this,e)}forEach(e){pl(this,e)}[Symbol.iterator](){return E5(this)}_write(e){e.writeTypeRef(Q5)}}const N5=t=>new _i;class R5 extends xd{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Xi extends ct{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,o)=>{this.set(o,r)}),this._prelimContent=null}_copy(){return new Xi}clone(){const e=new Xi;return this.forEach((n,r)=>{e.set(r,n instanceof ct?n.clone():n)}),e}_callObserver(e,n){Sd(this,e,new R5(this,e,n))}toJSON(){this.doc??At();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const o=n.content.getContent()[n.length-1];e[r]=o instanceof ct?o.toJSON():o}}),e}get size(){return[...ba(this)].length}keys(){return Uu(ba(this),e=>e[0])}values(){return Uu(ba(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Uu(ba(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??At(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ie(this.doc,n=>{Tc(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Ie(this.doc,r=>{nm(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return rm(this,e)}has(e){return Zx(this,e)}clear(){this.doc!==null?Ie(this.doc,e=>{this.forEach(function(n,r,o){Tc(e,o,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(e4)}}const I5=t=>new Xi,Qr=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&BP(t,e);class uh{constructor(e,n,r,o){this.left=e,this.right=n,this.index=r,this.currentAttributes=o}forward(){switch(this.right===null&&Vt(),this.right.content.constructor){case nt:this.right.deleted||cs(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Gy=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case nt:e.right.deleted||cs(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Ut(t,oe(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},ya=(t,e,n,r)=>{const o=new Map,i=r?Cd(e,n):null;if(i){const s=new uh(i.p.left,i.p,i.index,o);return Gy(t,s,n-i.index)}else{const s=new uh(null,e._start,0,o);return Gy(t,s,n)}},Kx=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===nt&&Qr(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=t.doc,i=o.clientID;r.forEach((s,l)=>{const a=n.left,c=n.right,d=new He(oe(i,Xe(o.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new nt(l,s));d.integrate(t,0),n.right=d,n.forward()})},cs=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Jx=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===nt&&Qr(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Yx=(t,e,n,r)=>{const o=t.doc,i=o.clientID,s=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!Qr(c,a)){s.set(l,c);const{left:d,right:u}=n;n.right=new He(oe(i,Xe(o.store,i)),d,d&&d.lastId,u,u&&u.id,e,null,new nt(l,a)),n.right.integrate(t,0),n.forward()}}return s},Gu=(t,e,n,r,o)=>{n.currentAttributes.forEach((f,h)=>{o[h]===void 0&&(o[h]=null)});const i=t.doc,s=i.clientID;Jx(n,o);const l=Yx(t,e,n,o),a=r.constructor===String?new qn(r):r instanceof ct?new Yn(r):new ii(r);let{left:c,right:d,index:u}=n;e._searchMarker&&hl(e._searchMarker,n.index,a.getLength()),d=new He(oe(s,Xe(i.store,s)),c,c&&c.lastId,d,d&&d.id,e,null,a),d.integrate(t,0),n.right=d,n.index=u,n.forward(),Kx(t,e,n,l)},Zy=(t,e,n,r,o)=>{const i=t.doc,s=i.clientID;Jx(n,o);const l=Yx(t,e,n,o);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===nt));){if(!n.right.deleted)switch(n.right.content.constructor){case nt:{const{key:a,value:c}=n.right.content,d=o[a];if(d!==void 0){if(Qr(d,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&Ut(t,oe(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
116
+ `;n.right=new He(oe(s,Xe(i.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new qn(a)),n.right.integrate(t,0),n.forward()}Kx(t,e,n,l)},Xx=(t,e,n,r,o)=>{let i=e;const s=Cn();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===nt){const c=i.content;s.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case nt:{const{key:d,value:u}=c,f=r.get(d)??null;(s.get(d)!==c||f===u)&&(e.delete(t),l++,!a&&(o.get(d)??null)===u&&f!==u&&(f===null?o.delete(d):o.set(d,f))),!a&&!e.deleted&&cs(o,c);break}}}e=e.right}return l},O5=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===nt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},D5=t=>{let e=0;return Ie(t.doc,n=>{let r=t._start,o=t._start,i=Cn();const s=rh(i);for(;o;){if(o.deleted===!1)switch(o.content.constructor){case nt:cs(s,o.content);break;default:e+=Xx(n,r,o,i,s),i=rh(s),r=o;break}o=o.right}}),e},_5=t=>{const e=new Set,n=t.doc;for(const[r,o]of t.afterState.entries()){const i=t.beforeState.get(r)||0;o!==i&&Dx(t,n.store.clients.get(r),i,o,s=>{!s.deleted&&s.content.constructor===nt&&s.constructor!==bn&&e.add(s.parent)})}Ie(n,r=>{io(t,t.deleteSet,o=>{if(o instanceof bn||!o.parent._hasFormatting||e.has(o.parent))return;const i=o.parent;o.content.constructor===nt?e.add(i):O5(r,o)});for(const o of e)D5(o)})},Ky=(t,e,n)=>{const r=n,o=rh(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Yn:case ii:case qn:n<e.right.length&&Ut(t,oe(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Xx(t,i,e.right,o,e.currentAttributes);const s=(e.left||e.right).parent;return s._searchMarker&&hl(s._searchMarker,e.index,-r+n),e};class P5 extends xd{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(o=>{o===null?this.childListChanged=!0:this.keysChanged.add(o)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Ie(e,r=>{const o=new Map,i=new Map;let s=this.target._start,l=null;const a={};let c="",d=0,u=0;const f=()=>{if(l!==null){let h=null;switch(l){case"delete":u>0&&(h={delete:u}),u=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},o.size>0&&(h.attributes={},o.forEach((p,m)=>{p!==null&&(h.attributes[m]=p)}))),c="";break;case"retain":d>0&&(h={retain:d},LP(a)||(h.attributes=PP({},a))),d=0;break}h&&n.push(h),l=null}};for(;s!==null;){switch(s.content.constructor){case Yn:case ii:this.adds(s)?this.deletes(s)||(f(),l="insert",c=s.content.getContent()[0],f()):this.deletes(s)?(l!=="delete"&&(f(),l="delete"),u+=1):s.deleted||(l!=="retain"&&(f(),l="retain"),d+=1);break;case qn:this.adds(s)?this.deletes(s)||(l!=="insert"&&(f(),l="insert"),c+=s.content.str):this.deletes(s)?(l!=="delete"&&(f(),l="delete"),u+=s.length):s.deleted||(l!=="retain"&&(f(),l="retain"),d+=s.length);break;case nt:{const{key:h,value:p}=s.content;if(this.adds(s)){if(!this.deletes(s)){const m=o.get(h)??null;Qr(m,p)?p!==null&&s.delete(r):(l==="retain"&&f(),Qr(p,i.get(h)??null)?delete a[h]:a[h]=p)}}else if(this.deletes(s)){i.set(h,p);const m=o.get(h)??null;Qr(m,p)||(l==="retain"&&f(),a[h]=m)}else if(!s.deleted){i.set(h,p);const m=a[h];m!==void 0&&(Qr(m,p)?m!==null&&s.delete(r):(l==="retain"&&f(),p===null?delete a[h]:a[h]=p))}s.deleted||(l==="insert"&&f(),cs(o,s.content));break}}s=s.right}for(f();n.length>0;){const h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class so extends ct{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??At(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new so}clone(){const e=new so;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new P5(this,e,n);Sd(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??At();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===qn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Ie(this.doc,r=>{const o=new uh(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const s=e[i];if(s.insert!==void 0){const l=!n&&typeof s.insert=="string"&&i===e.length-1&&o.right===null&&s.insert.slice(-1)===`
117
+ `?s.insert.slice(0,-1):s.insert;(typeof l!="string"||l.length>0)&&Gu(r,this,o,l,s.attributes||{})}else s.retain!==void 0?Zy(r,this,o,s.retain,s.attributes||{}):s.delete!==void 0&&Ky(r,o,s.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??At();const o=[],i=new Map,s=this.doc;let l="",a=this._start;function c(){if(l.length>0){const u={};let f=!1;i.forEach((p,m)=>{f=!0,u[m]=p});const h={insert:l};f&&(h.attributes=u),o.push(h),l=""}}const d=()=>{for(;a!==null;){if(Mo(a,e)||n!==void 0&&Mo(a,n))switch(a.content.constructor){case qn:{const u=i.get("ychange");e!==void 0&&!Mo(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!Mo(a,n)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):u!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case Yn:case ii:{c();const u={insert:a.content.getContent()[0]};if(i.size>0){const f={};u.attributes=f,i.forEach((h,p)=>{f[p]=h})}o.push(u);break}case nt:Mo(a,e)&&(c(),cs(i,a.content));break}a=a.right}c()};return e||n?Ie(s,u=>{e&&ch(u,e),n&&ch(u,n),d()},"cleanup"):d(),o}insert(e,n,r){if(n.length<=0)return;const o=this.doc;o!==null?Ie(o,i=>{const s=ya(i,this,e,!r);r||(r={},s.currentAttributes.forEach((l,a)=>{r[a]=l})),Gu(i,this,s,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const o=this.doc;o!==null?Ie(o,i=>{const s=ya(i,this,e,!r);Gu(i,this,s,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Ie(r,o=>{Ky(o,ya(o,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const o=this.doc;o!==null?Ie(o,i=>{const s=ya(i,this,e,!1);s.right!==null&&Zy(i,this,s,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Ie(this.doc,n=>{Tc(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Ie(this.doc,r=>{nm(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return rm(this,e)}getAttributes(){return Gx(this)}_write(e){e.writeTypeRef(t4)}}const $5=t=>new so;class Zu{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??At()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===vt||n.constructor===Yo)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Yo extends ct{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Yo}clone(){const e=new Yo;return e.insert(0,this.toArray().map(n=>n instanceof ct?n.clone():n)),e}get length(){return this.doc??At(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Zu(this,e)}querySelector(e){e=e.toUpperCase();const r=new Zu(this,o=>o.nodeName&&o.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),oo(new Zu(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Sd(this,e,new j5(this,n,e))}toString(){return Fx(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const o=e.createDocumentFragment();return r!==void 0&&r._createAssociation(o,this),pl(this,i=>{o.insertBefore(i.toDOM(e,n,r),null)}),o}insert(e,n){this.doc!==null?Ie(this.doc,r=>{Wx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Ie(this.doc,r=>{const o=e&&e instanceof ct?e._item:e;Mc(r,this,o,n)});else{const r=this._prelimContent,o=e===null?0:r.findIndex(i=>i===e)+1;if(o===0&&e!==null)throw cr("Reference item not found");r.splice(o,0,...n)}}delete(e,n=1){this.doc!==null?Ie(this.doc,r=>{qx(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return Vx(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return zx(this,e)}slice(e=0,n=this.length){return jx(this,e,n)}forEach(e){pl(this,e)}_write(e){e.writeTypeRef(r4)}}const L5=t=>new Yo;class vt extends Yo{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,o)=>{this.setAttribute(o,r)}),this._prelimAttrs=null}_copy(){return new vt(this.nodeName)}clone(){const e=new vt(this.nodeName),n=this.getAttributes();return $P(n,(r,o)=>{e.setAttribute(o,r)}),e.insert(0,this.toArray().map(r=>r instanceof ct?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const o=r.length;for(let l=0;l<o;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),s=n.length>0?" "+n.join(" "):"";return`<${i}${s}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?Ie(this.doc,n=>{Tc(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Ie(this.doc,r=>{nm(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return rm(this,e)}hasAttribute(e){return Zx(this,e)}getAttributes(e){return e?T5(this,e):Gx(this)}toDOM(e=document,n={},r){const o=e.createElement(this.nodeName),i=this.getAttributes();for(const s in i){const l=i[s];typeof l=="string"&&o.setAttribute(s,l)}return pl(this,s=>{o.appendChild(s.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(n4),e.writeKey(this.nodeName)}}const B5=t=>new vt(t.readKey());class j5 extends xd{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(o=>{o===null?this.childListChanged=!0:this.attributesChanged.add(o)})}}class Ac extends Xi{constructor(e){super(),this.hookName=e}_copy(){return new Ac(this.hookName)}clone(){const e=new Ac(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const o=n[this.hookName];let i;return o!==void 0?i=o.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(o4),e.writeKey(this.hookName)}}const V5=t=>new Ac(t.readKey());class ln extends so{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new ln}clone(){const e=new ln;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const o=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(o,this),o}toString(){return this.toDelta().map(e=>{const n=[];for(const o in e.attributes){const i=[];for(const s in e.attributes[o])i.push({key:s,value:e.attributes[o][s]});i.sort((s,l)=>s.key<l.key?-1:1),n.push({nodeName:o,attrs:i})}n.sort((o,i)=>o.nodeName<i.nodeName?-1:1);let r="";for(let o=0;o<n.length;o++){const i=n[o];r+=`<${i.nodeName}`;for(let s=0;s<i.attrs.length;s++){const l=i.attrs[s];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let o=n.length-1;o>=0;o--)r+=`</${n[o].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(i4)}}const H5=t=>new ln;class om{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Sn()}mergeWith(e){return!1}write(e,n,r){throw Sn()}integrate(e,n){throw Sn()}}const F5=0;class bn extends om{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),Ox(e.doc.store,this)}write(e,n){e.writeInfo(F5),e.writeLen(this.length-n)}getMissing(e,n){return null}}class jl{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new jl(this.content)}splice(e){throw Sn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const z5=t=>new jl(t.readBuf());class ml{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ml(this.len)}splice(e){const n=new ml(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){cl(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const U5=t=>new ml(t.readLen()),Qx=(t,e)=>new vo({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Vl{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Vl(Qx(this.doc.guid,this.opts))}splice(e){throw Sn()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const W5=t=>new Vl(Qx(t.readString(),t.readAny()));class ii{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ii(this.embed)}splice(e){throw Sn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const q5=t=>new ii(t.readJSON());class nt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new nt(this.key,this.value)}splice(e){throw Sn()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const G5=t=>new nt(t.readKey(),t.readJSON());class Nc{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Nc(this.arr)}splice(e){const n=new Nc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let o=n;o<r;o++){const i=this.arr[o];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const Z5=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const o=t.readString();o==="undefined"?n.push(void 0):n.push(JSON.parse(o))}return new Nc(n)},K5=wc("node_env")==="development";class Xo{constructor(e){this.arr=e,K5&&Gk(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Xo(this.arr)}splice(e){const n=new Xo(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let o=n;o<r;o++){const i=this.arr[o];e.writeAny(i)}}getRef(){return 8}}const J5=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Xo(n)};class qn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new qn(this.str)}splice(e){const n=new qn(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Y5=t=>new qn(t.readString()),X5=[N5,I5,$5,B5,L5,V5,H5],Q5=0,e4=1,t4=2,n4=3,r4=4,o4=5,i4=6;class Yn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Yn(this.type._copy())}splice(e){throw Sn()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const s4=t=>new Yn(X5[t.readTypeRef()](t)),fh=(t,e)=>{let n=e,r=0,o;do r>0&&(n=oe(n.client,n.clock+r)),o=Di(t,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof He);return{item:o,diff:r}},im=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Rc=(t,e,n)=>{const{client:r,clock:o}=e.id,i=new He(oe(r,o+n),e,oe(r,o+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=oe(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Jy=(t,e)=>Pp(t,n=>ls(n.deletions,e)),eC=(t,e,n,r,o,i)=>{const s=t.doc,l=s.store,a=s.clientID,c=e.redone;if(c!==null)return Ut(t,c);let d=e.parent._item,u=null,f;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||eC(t,d,n,r,o,i)===null))return null;for(;d.redone!==null;)d=Ut(t,d.redone)}const h=d===null?e.parent:d.content.type;if(e.parentSub===null){for(u=e.left,f=e;u!==null;){let y=u;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:Ut(t,y.redone);if(y!==null&&y.parent._item===d){u=y;break}u=u.left}for(;f!==null;){let y=f;for(;y!==null&&y.parent._item!==d;)y=y.redone===null?null:Ut(t,y.redone);if(y!==null&&y.parent._item===d){f=y;break}f=f.right}}else{if(f=null,e.right&&!o){for(u=e;u!==null&&u.right!==null&&(u.right.redone||ls(r,u.right.id)||Jy(i.undoStack,u.right.id)||Jy(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=Ut(t,u.redone);if(u&&u.right!==null)return null}else u=h._map.get(e.parentSub)||null;u!==null&&u.parent._item!==d&&(u=h._map.get(e.parentSub)||null)}const p=Xe(l,a),m=oe(a,p),g=new He(m,u,u&&u.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=m,im(g,!0),g.integrate(t,0),g};let He=class hh extends om{constructor(e,n,r,o,i,s,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=o,this.rightOrigin=i,this.parent=s,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?uy:0}set marker(e){(this.info&Lu)>0!==e&&(this.info^=Lu)}get marker(){return(this.info&Lu)>0}get keep(){return(this.info&dy)>0}set keep(e){this.keep!==e&&(this.info^=dy)}get countable(){return(this.info&uy)>0}get deleted(){return(this.info&$u)>0}set deleted(e){this.deleted!==e&&(this.info^=$u)}markDeleted(){this.info|=$u}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Xe(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Xe(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Oi&&this.id.client!==this.parent.client&&this.parent.clock>=Xe(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Hy(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ut(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===bn||this.right&&this.right.constructor===bn)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===hh?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===hh&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Oi){const r=Di(n,this.parent);r.constructor===bn?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Hy(e,e.doc.store,oe(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,o;if(r!==null)o=r.right;else if(this.parentSub!==null)for(o=this.parent._map.get(this.parentSub)||null;o!==null&&o.left!==null;)o=o.left;else o=this.parent._start;const i=new Set,s=new Set;for(;o!==null&&o!==this.right;){if(s.add(o),i.add(o),xi(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,i.clear();else if(xi(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&s.has(Di(e.doc.store,o.origin)))i.has(Di(e.doc.store,o.origin))||(r=o,i.clear());else break;o=o.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Ox(e.doc.store,this),this.content.integrate(e,this),zy(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new bn(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:oe(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&xi(e.origin,this.lastId)&&this.right===e&&xi(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),cl(e.deleteSet,this.id.client,this.id.clock,this.length),zy(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Vt();this.content.gc(e),n?d5(e,this,new bn(this.id,this.length)):this.content=new ml(this.length)}write(e,n){const r=n>0?oe(this.id.client,this.id.clock+n-1):this.origin,o=this.rightOrigin,i=this.parentSub,s=this.content.getRef()&fd|(r===null?0:Lt)|(o===null?0:Ir)|(i===null?0:ol);if(e.writeInfo(s),r!==null&&e.writeLeftID(r),o!==null&&e.writeRightID(o),r===null&&o===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=dl(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===Oi?(e.writeParentInfo(!1),e.writeLeftID(l)):Vt();i!==null&&e.writeString(i)}this.content.write(e,n)}};const tC=(t,e)=>l4[e&fd](t),l4=[()=>{Vt()},U5,Z5,z5,Y5,q5,G5,s4,J5,W5,()=>{Vt()}],a4=10;class yn extends om{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Vt()}write(e,n){e.writeInfo(a4),ge(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const nC=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},rC="__ $YJS$ __";nC[rC]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");nC[rC]=!0;const c4=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},d4=/[\uD800-\uDBFF]/,u4=/[\uDC00-\uDFFF]/,f4=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&d4.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&u4.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},h4=f4,Le=new Ce("y-sync"),or=new Ce("y-undo"),va=new Ce("yjs-cursor"),ir=(t,e)=>t>>>e|t<<32-e,p4=t=>ir(t,2)^ir(t,13)^ir(t,22),m4=t=>ir(t,6)^ir(t,11)^ir(t,25),g4=t=>ir(t,7)^ir(t,18)^t>>>3,b4=t=>ir(t,17)^ir(t,19)^t>>>10,y4=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),v4=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class w4{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(v4),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let u=16;u<64;u++)n[u]=b4(n[u-2])+n[u-7]+g4(n[u-15])+n[u-16];let r=e[0],o=e[1],i=e[2],s=e[3],l=e[4],a=e[5],c=e[6],d=e[7];for(let u=0,f,h;u<64;u++)f=d+m4(l)+(l&a^~l&c)+y4[u]+n[u]>>>0,h=p4(r)+(r&o^r&i^o&i)>>>0,d=c,c=a,a=l,l=s+f>>>0,s=i,i=o,o=r,r=f+h>>>0;e[0]+=r,e[1]+=o,e[2]+=i,e[3]+=s,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=d}digest(e){let n=0;for(;n+56<=e.length;){let s=0;for(;s<16&&n+3<e.length;s++)this._W[s]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,s,16);n<e.length;)this._W[s]|=e[n]<<(3-n%4)*8,n++;this._W[s]|=Lt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let o=0;for(;n<e.length;o++)for(let s=3;s>=0&&n<e.length;s--)this._W[o]|=e[n++]<<s*8;r||(this._W[o-(n%4===0?0:1)]|=Lt<<(3-n%4)*8),this._W[14]=e.byteLength/WD,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let s=0;s<this._H.length;s++)for(let l=0;l<4;l++)i[s*4+l]=this._H[s]>>>(3-l)*8;return i}}const k4=t=>new w4().digest(t),x4=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},C4=t=>KP(x4(k4(YP(t)))),Ic=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!ls(e.ds,t.id),S4=[{light:"#ecd44433",dark:"#ecd444"}],E4=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Ko();t.forEach(o=>r.add(o)),e=e.filter(o=>!r.has(o))}t.set(n,KD(e))}return t.get(n)},M4=(t,{colors:e=S4,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:o=()=>{},mapping:i}={})=>{let s=!1;const l=new A4(t,i),a=new ae({props:{editable:c=>{const d=Le.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Le,state:{init:(c,d)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(Le);if(u!==void 0){d=Object.assign({},d);for(const f in u)d[f]=u[f]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,l.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&qp(0,()=>{l.prosemirrorView!=null&&(u.restore==null?l._renderSnapshot(u.snapshot,u.prevSnapshot,d):(l._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),d}},view:c=>(l.initView(c),i==null&&l._forceRerender(),o(),{update:()=>{const d=a.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(s||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(s=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=or.getState(c.state),f=u&&u.undoManager;f&&f.stopCapturing()}l.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),l._prosemirrorChanged(c.state.doc)},Le)})}},destroy:()=>{l.destroy()}})});return a},T4=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Gt(t.doc));else if(e.type==="node"){const r=$o(n.doc,n.type,e.anchor,n.mapping);t.setSelection(G.create(t.doc,r))}else{const r=$o(n.doc,n.type,e.anchor,n.mapping),o=$o(n.doc,n.type,e.head,n.mapping);if(r!==null&&o!==null){const i=W.between(t.doc.resolve(r),t.doc.resolve(o));t.setSelection(i)}}},Oc=(t,e)=>({type:e.selection.jsonID,anchor:bl(e.selection.anchor,t.type,t.mapping),head:bl(e.selection.head,t.type,t.mapping)});class A4{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=c4(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Oc(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Kk&&this._domSelectionInView===null&&(qp(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const o=n.getBoundingClientRect(),i=$l.documentElement;return o.bottom>=0&&o.right>=0&&o.left<=(window.innerWidth||i.clientWidth||0)&&o.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=Rx(wx(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Le,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Wa(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(I.from(e),0,0));n.setMeta(Le,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(o=>Wa(o,this.prosemirrorView.state.schema,this)).filter(o=>o!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(I.from(n),0,0));if(e){const o=Rr(Wn(e.anchor,0),r.doc.content.size),i=Rr(Wn(e.head,0),r.doc.content.size);r.setSelection(W.create(r.doc,o,i))}this.prosemirrorView.dispatch(r.setMeta(Le,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let o=this.doc,i=this.type;if(e||(e=qu(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Vt(),o=new vo({gc:!1}),Sc(o,n),n=qu(o),Sc(o,e),e=qu(o),i._item===null){const s=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=o.getXmlFragment(s)}else{const s=o.store.clients.get(i._item.id.client)??[],l=Tn(s,i._item.id.clock);i=s[l].content.type}this.mapping.clear(),this.mux(()=>{o.transact(s=>{const l=r.permanentUserData;l&&l.dss.forEach(u=>{io(s,u,f=>{})});const a=(u,f)=>{const h=u==="added"?l.getUserByClientId(f.client):l.getUserByDeletedId(f);return{user:h,type:u,color:E4(r.colorMapping,r.colors,h)}},c=Hx(i,new Yp(n.ds,e.sv)).map(u=>!u._item.deleted||Ic(u._item,e)||Ic(u._item,n)?Wa(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(I.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Le,{isChangeOrigin:!0}))},Le)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Le.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const o=(l,a)=>this.mapping.delete(a);io(n,n.deleteSet,l=>{if(l.constructor===He){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(o),n.changedParentTypes.forEach(o);const i=this.type.toArray().map(l=>oC(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let s=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(I.from(i),0,0));T4(s,this.beforeTransactionSelection,this),s=s.setMeta(Le,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Px}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&s.scrollIntoView(),this.prosemirrorView.dispatch(s)})}_prosemirrorChanged(e){this.doc.transact(()=>{mh(this.doc,this.type,e,this),this.beforeTransactionSelection=Oc(this,this.prosemirrorView.state)},Le)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const oC=(t,e,n,r,o,i)=>{const s=n.mapping.get(t);if(s===void 0){if(t instanceof vt)return Wa(t,e,n,r,o,i);throw Sn()}return s},Wa=(t,e,n,r,o,i)=>{const s=[],l=a=>{var c,d;if(a instanceof vt){const u=oC(a,e,n,r,o,i);u!==null&&s.push(u)}else{const u=(d=(c=a._item.right)==null?void 0:c.content)==null?void 0:d.type;u instanceof so&&!u._item.deleted&&u._item.id.client===u.doc.clientID&&(a.applyDelta([{retain:a.length},...u.toDelta()]),u.doc.transact(h=>{u._item.delete(h)}));const f=N4(a,e,n,r,o,i);f!==null&&f.forEach(h=>{h!==null&&s.push(h)})}};r===void 0||o===void 0?t.toArray().forEach(l):Hx(t,new Yp(o.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Ic(t._item,r)?Ic(t._item,o)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,s);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Le),n.mapping.delete(t),null}},N4=(t,e,n,r,o,i)=>{const s=[],l=t.toDelta(r,o,i);try{for(let a=0;a<l.length;a++){const c=l[a];s.push(e.text(c.insert,P4(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Le),null}return s},R4=(t,e)=>{const n=new ln,r=t.map(o=>({insert:o.text,attributes:lC(o.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},I4=(t,e)=>{const n=new vt(t.type.name);for(const r in t.attrs){const o=t.attrs[r];o!==null&&r!=="ychange"&&n.setAttribute(r,o)}return n.insert(0,Ed(t).map(r=>ph(r,e))),e.mapping.set(n,t),n},ph=(t,e)=>t instanceof Array?R4(t,e):I4(t,e),Yy=t=>typeof t=="object"&&t!==null,sm=(t,e)=>{const n=Object.keys(t).filter(o=>t[o]!==null);let r=n.length===(e==null?0:Object.keys(e).filter(o=>e[o]!==null).length);for(let o=0;o<n.length&&r;o++){const i=n[o],s=t[i],l=e[i];r=i==="ychange"||s===l||Yy(s)&&Yy(l)&&sm(s,l)}return r},Ed=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const o=e[r];if(o.isText){const i=[];for(let s=e[r];r<e.length&&s.isText;s=e[++r])i.push(s);r--,n.push(i)}else n.push(o)}return n},iC=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,o)=>r.insert===e[o].text&&qk(r.attributes||{}).length===e[o].marks.length&&rs(r.attributes,(i,s)=>{var c;const l=sC(s),a=e[o].marks;return sm(i,(c=a.find(d=>d.type.name===l))==null?void 0:c.attrs)}))},gl=(t,e)=>{if(t instanceof vt&&!(e instanceof Array)&&gh(t,e)){const n=Ed(e);return t._length===n.length&&sm(t.getAttributes(),e.attrs)&&t.toArray().every((r,o)=>gl(r,n[o]))}return t instanceof ln&&e instanceof Array&&iC(t,e)},Dc=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Xy=(t,e,n)=>{const r=t.toArray(),o=Ed(e),i=o.length,s=r.length,l=Rr(s,i);let a=0,c=0,d=!1;for(;a<l;a++){const u=r[a],f=o[a];if(Dc(n.mapping.get(u),f))d=!0;else if(!gl(u,f))break}for(;a+c<l;c++){const u=r[s-c-1],f=o[i-c-1];if(Dc(n.mapping.get(u),f))d=!0;else if(!gl(u,f))break}return{equalityFactor:a+c,foundMappedChild:d}},O4=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof qn?e+=n.content.str:n.content instanceof nt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},D4=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:o}=O4(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,lC(c.marks,n))})),{insert:s,remove:l,index:a}=h4(o,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,s),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},_4=/(.*)(--[a-zA-Z0-9+/=]{8})$/,sC=t=>{var e;return((e=_4.exec(t))==null?void 0:e[1])??t},P4=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(sC(r),t[r]));return n},lC=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const o=hr(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[o?`${r.type.name}--${C4(r.toJSON())}`:r.type.name]=r.attrs}}),n},mh=(t,e,n,r)=>{if(e instanceof vt&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof vt){const u=e.getAttributes(),f=n.attrs;for(const h in f)f[h]!==null?u[h]!==f[h]&&h!=="ychange"&&e.setAttribute(h,f[h]):e.removeAttribute(h);for(const h in u)f[h]===void 0&&e.removeAttribute(h)}const o=Ed(n),i=o.length,s=e.toArray(),l=s.length,a=Rr(i,l);let c=0,d=0;for(;c<a;c++){const u=s[c],f=o[c];if(!Dc(r.mapping.get(u),f))if(gl(u,f))r.mapping.set(u,f);else break}for(;d+c<a;d++){const u=s[l-d-1],f=o[i-d-1];if(!Dc(r.mapping.get(u),f))if(gl(u,f))r.mapping.set(u,f);else break}t.transact(()=>{for(;l-c-d>0&&i-c-d>0;){const f=s[c],h=o[c],p=s[l-d-1],m=o[i-d-1];if(f instanceof ln&&h instanceof Array)iC(f,h)||D4(f,h,r),c+=1;else{let g=f instanceof vt&&gh(f,h),y=p instanceof vt&&gh(p,m);if(g&&y){const w=Xy(f,h,r),k=Xy(p,m,r);w.foundMappedChild&&!k.foundMappedChild?y=!1:!w.foundMappedChild&&k.foundMappedChild||w.equalityFactor<k.equalityFactor?g=!1:y=!1}g?(mh(t,f,h,r),c+=1):y?(mh(t,p,m,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[ph(h,r)]),c+=1)}}const u=l-c-d;if(l===1&&i===0&&s[0]instanceof ln?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):u>0&&(e.slice(c,c+u).forEach(f=>r.mapping.delete(f)),e.delete(c,u)),c+d<i){const f=[];for(let h=c;h<i-d;h++)f.push(ph(o[h],r));e.insert(c,f)}},Le)},gh=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let Fs=null;const $4=()=>{const t=Fs;Fs=null,t.forEach((e,n)=>{const r=n.state.tr,o=Le.getState(n.state);o&&o.binding&&!o.binding.isDestroyed&&(e.forEach((i,s)=>{r.setMeta(s,i)}),n.dispatch(r))})},L4=(t,e,n)=>{Fs||(Fs=new Map,qp(0,$4)),hr(Fs,t,Cn).set(e,n)},bl=(t,e,n)=>{if(t===0)return Wu(e,0,e.length===0?-1:0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof ln){if(r._length>=t)return Wu(r,t,e.length===0?-1:0);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const o=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<o)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&o>1)return new fl(r._item===null?null:r._item.id,r._item===null?dl(r):null,null);if(t-=o,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new fl(r._item===null?null:r._item.id,r._item===null?dl(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Vt();if(t===0&&r.constructor!==ln&&r!==e)return B4(r._item.parent,r._item)}return Wu(e,e._length,e.length===0?-1:0)},B4=(t,e)=>{let n=null,r=null;return t._item===null?r=dl(t):n=oe(t._item.id.client,t._item.id.clock),new fl(n,r,e.id)},$o=(t,e,n,r)=>{const o=a5(n,t);if(o===null||o.type!==e&&!ul(e,o.type._item))return null;let i=o.type,s=0;if(i.constructor===ln)s=o.index;else if(i._item===null||!i._item.deleted){let l=i._first,a=0;for(;a<i._length&&a<o.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof ln?s+=c._length:s+=r.get(c).nodeSize}l=l.right}s+=1}for(;i!==e&&i._item!==null;){const l=i._item.parent;if(l._item===null||!l._item.deleted){s+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===i)break;a.deleted||(c instanceof ln?s+=c._length:s+=r.get(c).nodeSize),a=a.right}}i=l}return s-1},j4=(t,e,n)=>t!==e,V4=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode("⁠"),o=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(o,null),e},aC=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),H4=/^#[0-9a-fA-F]{6}$/,Qy=(t,e,n,r,o)=>{const i=Le.getState(t),s=i.doc,l=[];return i.snapshot!=null||i.prevSnapshot!=null||i.binding.mapping.size===0?he.create(t.doc,[]):(e.getStates().forEach((a,c)=>{if(n(s.clientID,c,a)&&a.cursor!=null){const d=a.user||{};d.color==null?d.color="#ffa500":H4.test(d.color)||console.warn("A user uses an unsupported color format",d),d.name==null&&(d.name=`User: ${c}`);let u=$o(s,i.type,Hs(a.cursor.anchor),i.binding.mapping),f=$o(s,i.type,Hs(a.cursor.head),i.binding.mapping);if(u!==null&&f!==null){const h=Wn(t.doc.content.size-1,0);u=Rr(u,h),f=Rr(f,h),l.push(Me.widget(f,()=>r(d,c),{key:c+"",side:10}));const p=Rr(u,f),m=Wn(u,f);l.push(Me.inline(p,m,o(d,c),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),he.create(t.doc,l))},F4=(t,{awarenessStateFilter:e=j4,cursorBuilder:n=V4,selectionBuilder:r=aC,getSelection:o=s=>s.selection}={},i="cursor")=>new ae({key:va,state:{init(s,l){return Qy(l,t,e,n,r)},apply(s,l,a,c){const d=Le.getState(c),u=s.getMeta(va);return d&&d.isChangeOrigin||u&&u.awarenessUpdated?Qy(c,t,e,n,r):l.map(s.mapping,s.doc)}},props:{decorations:s=>va.getState(s)},view:s=>{const l=()=>{s.docView&&L4(s,va,{awarenessUpdated:!0})},a=()=>{const c=Le.getState(s.state),d=t.getLocalState()||{};if(s.hasFocus()){const u=o(s.state),f=bl(u.anchor,c.type,c.binding.mapping),h=bl(u.head,c.type,c.binding.mapping);(d.cursor==null||!Vy(Hs(d.cursor.anchor),f)||!Vy(Hs(d.cursor.head),h))&&t.setLocalStateField(i,{anchor:f,head:h})}else d.cursor!=null&&$o(c.doc,c.type,Hs(d.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(i,null)};return t.on("change",l),s.dom.addEventListener("focusin",a),s.dom.addEventListener("focusout",a),{update:a,destroy:()=>{s.dom.removeEventListener("focusin",a),s.dom.removeEventListener("focusout",a),t.off("change",l),t.setLocalStateField(i,null)}}}}),z4=t=>{var e,n;return((n=(e=or.getState(t))==null?void 0:e.undoManager)==null?void 0:n.undo())!=null},U4=t=>{var e,n;return((n=(e=or.getState(t))==null?void 0:e.undoManager)==null?void 0:n.redo())!=null},W4=(t,e)=>{var n,r;return e==null?(r=(n=or.getState(t))==null?void 0:n.undoManager)==null?void 0:r.canUndo():z4(t)},q4=(t,e)=>{var n,r;return e==null?(r=(n=or.getState(t))==null?void 0:n.undoManager)==null?void 0:r.canRedo():U4(t)},G4=new Set(["paragraph"]),Z4=(t,e)=>!(t instanceof He)||!(t.content instanceof Yn)||!(t.content.type instanceof so||t.content.type instanceof vt&&e.has(t.content.type.nodeName))||t.content.type._length===0,K4=({protectedNodes:t=G4,trackedOrigins:e=[],undoManager:n=null}={})=>new ae({key:or,state:{init:(r,o)=>{const i=Le.getState(o),s=n||new Px(i.type,{trackedOrigins:new Set([Le].concat(e)),deleteFilter:l=>Z4(l,t),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}},apply:(r,o,i,s)=>{const l=Le.getState(s).binding,a=o.undoManager,c=a.undoStack.length>0,d=a.redoStack.length>0;return l?{undoManager:a,prevSel:Oc(l,i),hasUndoOps:c,hasRedoOps:d}:c!==o.hasUndoOps||d!==o.hasRedoOps?Object.assign({},o,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):o}},view:r=>{const o=Le.getState(r.state),i=or.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:s})=>{const l=o.binding;l&&s.meta.set(l,or.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:s})=>{const l=o.binding;l&&(l.beforeTransactionSelection=s.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}});var e0=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},J4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Y4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Q4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,eL=Nn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return e0("strong",{...dn(this.options.HTMLAttributes,t),children:e0("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Wo({find:J4,type:this.type}),Wo({find:X4,type:this.type})]},addPasteRules(){return[qo({find:Y4,type:this.type}),qo({find:Q4,type:this.type})]}}),tL=eL,nL=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},rL=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},oL=Nn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",dn(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Wo({find:nL,type:this.type})]},addPasteRules(){return[qo({find:rL,type:this.type})]}}),iL=oL,sL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,aL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,cL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dL=Nn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",dn(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Wo({find:sL,type:this.type}),Wo({find:aL,type:this.type})]},addPasteRules(){return[qo({find:lL,type:this.type}),qo({find:cL,type:this.type})]}}),uL=dL,fL=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,hL=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,pL=Nn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",dn(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Wo({find:fL,type:this.type})]},addPasteRules(){return[qo({find:hL,type:this.type})]}}),mL=pL,gL=Nn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",dn(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const i=o[2].trim();return{type:"underline",raw:o[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),bL=gL;function yL(t,e=JSON.stringify){let n={};return t.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function vL(t){return yL(t.filter((e,n)=>t.indexOf(e)!==n))}var Md=Ge.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],setIdAttribute:!1,isWithinEditor:void 0,generateID:()=>{if(typeof window<"u"&&window.__TEST_OPTIONS){let t=window.__TEST_OPTIONS;return t.mockID===void 0?t.mockID=0:t.mockID++,t.mockID.toString()}return Rp()},filterTransaction:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>{let e={[`data-${this.options.attributeName}`]:t[this.options.attributeName]};return this.options.setIdAttribute?{...e,id:t[this.options.attributeName]}:e}}}}]},addProseMirrorPlugins(){let{isWithinEditor:t}=this.options,e=null,n=!1;return[new ae({key:new Ce("uniqueID"),appendTransaction:(r,o,i)=>{let s=r.some(p=>p.docChanged)&&!o.doc.eq(i.doc),l=this.options.filterTransaction&&r.some(p=>{var m,g;return!((g=(m=this.options).filterTransaction)!=null&&g.call(m,p))});if(!s||l)return;let{tr:a}=i,{types:c,attributeName:d,generateID:u}=this.options,f=cd(o.doc,r),{mapping:h}=f;if(Cp(f).forEach(({newRange:p})=>{let m=bc(i.doc,p,y=>c.includes(y.type.name)),g=vL(m.map(({node:y})=>y.attrs[d]).filter(y=>y!==null));m.forEach(({node:y,pos:w})=>{var C;let k=(C=a.doc.nodeAt(w))==null?void 0:C.attrs[d];if(k===null){let E=o.doc.type.createAndFill().content;if(o.doc.content.findDiffStart(E)===null){let S=JSON.parse(JSON.stringify(i.doc.toJSON()));if(S.content[0].content[0].attrs.id="initialBlockId",JSON.stringify(S.content)===JSON.stringify(E.toJSON())){a.setNodeMarkup(w,void 0,{...y.attrs,[d]:"initialBlockId"});return}}a.setNodeMarkup(w,void 0,{...y.attrs,[d]:u()});return}let{deleted:x}=h.invert().mapResult(w);x&&g.includes(k)&&a.setNodeMarkup(w,void 0,{...y.attrs,[d]:u()})})}),a.steps.length)return a.setMeta("uniqueID",!0),a},view(r){let o=i=>{let s=r.dom.parentElement;e=s!=null&&s.contains(i.target)||t!=null&&t(i.target)?s:null};return window.addEventListener("dragstart",o),{destroy(){window.removeEventListener("dragstart",o)}}},props:{handleDOMEvents:{drop:(r,o)=>{var i;return n=e!==r.dom.parentElement||((i=o.dataTransfer)==null?void 0:i.effectAllowed)==="copy",e=null,!1},paste:()=>(n=!0,!1)},transformPasted:r=>{if(!n)return r;let{types:o,attributeName:i}=this.options,s=l=>{let a=[];return l.forEach(c=>{if(c.isText){a.push(c);return}if(!o.includes(c.type.name)){a.push(c.copy(s(c.content)));return}let d=c.type.create({...c.attrs,[i]:null},s(c.content),c.marks);a.push(d)}),I.from(a)};return n=!1,new j(s(r.content),r.openStart,r.openEnd)}}})]}});function t0(t){return t.type==="link"}function cC(t){return typeof t!="string"&&t.type==="link"}function Qo(t){return typeof t!="string"&&t.type==="text"}function lo(t){var e,n,r,o,i;return ao(t)?{...t}:yl(t)?{type:"tableCell",content:[].concat(t.content),props:{backgroundColor:((e=t.props)==null?void 0:e.backgroundColor)??"default",textColor:((n=t.props)==null?void 0:n.textColor)??"default",textAlignment:((r=t.props)==null?void 0:r.textAlignment)??"left",colspan:((o=t.props)==null?void 0:o.colspan)??1,rowspan:((i=t.props)==null?void 0:i.rowspan)??1}}:{type:"tableCell",content:[].concat(t),props:{backgroundColor:"default",textColor:"default",textAlignment:"left",colspan:1,rowspan:1}}}function yl(t){return t!=null&&typeof t!="string"&&!Array.isArray(t)&&t.type==="tableCell"}function ao(t){return yl(t)&&t.props!==void 0&&t.content!==void 0}function ei(t){return ao(t)?t.props.colspan??1:1}function vl(t){return ao(t)?t.props.rowspan??1:1}var dr=class extends Error{constructor(t){super(`Unreachable case: ${t}`)}};function ce(t,e=!0){let{"data-test":n,...r}=t;if(Object.keys(r).length>0&&e)throw Error("Object must be empty "+JSON.stringify(t))}var wL=()=>typeof navigator<"u"&&(/Mac/.test(navigator.platform)||/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent));function pn(t,e="Ctrl"){return wL()?t.replace("Mod","⌘"):t.replace("Mod",e)}function De(...t){return[...new Set(t.filter(e=>e).join(" ").split(" "))].join(" ")}var bh=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function kL(t,e,n,r){let o=document.createElement("div");o.className=De("bn-block-content",n.class),o.setAttribute("data-content-type",t);for(let[s,l]of Object.entries(n))s!=="class"&&o.setAttribute(s,l);let i=document.createElement(e);i.className=De("bn-inline-content",r.class);for(let[s,l]of Object.entries(r))s!=="class"&&i.setAttribute(s,l);return o.appendChild(i),{dom:o,contentDOM:i}}var n0=(t,e)=>{let n=si(t,e.pmSchema);n.type.name==="blockContainer"&&(n=n.firstChild);let r=e.pmSchema.nodes[n.type.name].spec.toDOM;if(r===void 0)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let o=r(n);if(typeof o!="object"||!("dom"in o))throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");return o};function dC(t,e="<br>"){let n=t.querySelectorAll("p");if(n.length>1){let r=n[0];for(let o=1;o<n.length;o++){let i=n[o];r.innerHTML+=e+i.innerHTML,i.remove()}}}function wl(t){return"data-"+t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function r0(t){let e=t.split("/");return!e.length||e[e.length-1]===""?t:e[e.length-1]}function xL(t){var n;let e=["mp4","webm","ogg","mov","mkv","flv","avi","wmv","m4v"];try{let r=((n=new URL(t).pathname.split(".").pop())==null?void 0:n.toLowerCase())||"";return e.includes(r)}catch{return!1}}function CL(t){let e={};return Object.entries(t).forEach(([n,r])=>{e[n]={default:r.default,keepOnSplit:!0,parseHTML:o=>{let i=o.getAttribute(wl(n));if(i===null)return null;if(r.default===void 0&&r.type==="boolean"||r.default!==void 0&&typeof r.default=="boolean")return i==="true"?!0:i==="false"?!1:null;if(r.default===void 0&&r.type==="number"||r.default!==void 0&&typeof r.default=="number"){let s=parseFloat(i);return!Number.isNaN(s)&&Number.isFinite(s)?s:null}return i},renderHTML:o=>o[n]===r.default?{}:{[wl(n)]:o[n]}}}),e}function uC(t,e,n,r){let o=t();if(o===void 0)throw Error("Cannot find node position");let i=n.state.doc.resolve(o).node().attrs.id;if(!i)throw Error("Block doesn't have id");let s=e.getBlock(i);if(s.type!==r)throw Error("Block type does not match");return s}function yh(t,e,n,r,o=!1,i){let s=document.createElement("div");if(i!==void 0)for(let[l,a]of Object.entries(i))l!=="class"&&s.setAttribute(l,a);s.className=De("bn-block-content",(i==null?void 0:i.class)||""),s.setAttribute("data-content-type",e);for(let[l,a]of Object.entries(n))a!==r[l].default&&s.setAttribute(wl(l),a);return o&&s.setAttribute("data-file-block",""),s.appendChild(t.dom),t.contentDOM&&(t.contentDOM.className=De("bn-inline-content",t.contentDOM.className)),{...t,dom:s}}function SL(t,e,n){return{config:{type:t.type,content:t.content,propSchema:e},implementation:{node:t.node,render:n0,toExternalHTML:n0},extensions:n}}function EL(t,e){t.stopEvent=n=>(n.type==="mousedown"&&setTimeout(()=>{e.view.dom.blur()},10),!0)}function ML(t,e){let n=[{tag:"[data-content-type="+t.type+"]",contentElement:".bn-inline-content"}];return e.parse&&n.push({tag:"*",getAttrs(r){var i;if(typeof r=="string")return!1;let o=(i=e.parse)==null?void 0:i.call(e,r);return o===void 0?!1:o},preserveWhitespace:!0,getContent:t.content==="inline"||t.content==="none"?(r,o)=>{var i;if(e.parseContent){let s=e.parseContent({el:r,schema:o});if(s!==void 0)return s}if(t.content==="inline"){let s=r.cloneNode(!0);return dC(s,(i=e.meta)!=null&&i.code?`
118
+ `:"<br>"),wn.fromSchema(o).parse(s,{topNode:o.nodes.paragraph.create(),preserveWhitespace:!0}).content}return I.empty}:void 0}),n}function TL(t,e,n,r){var i,s,l,a;let o=e.node||Kn.create({name:t.type,content:t.content==="inline"?"inline*":t.content==="none"?"":t.content,group:"blockContent",selectable:((i=e.meta)==null?void 0:i.selectable)??!0,isolating:((s=e.meta)==null?void 0:s.isolating)??!0,code:((l=e.meta)==null?void 0:l.code)??!1,defining:((a=e.meta)==null?void 0:a.defining)??!0,priority:r,addAttributes(){return CL(t.propSchema)},parseHTML(){return ML(t,e)},renderHTML({HTMLAttributes:c}){var u;let d=document.createElement("div");return yh({dom:d,contentDOM:t.content==="inline"?d:void 0},t.type,{},t.propSchema,((u=e.meta)==null?void 0:u.fileBlockAccept)!==void 0,c)},addNodeView(){return c=>{var p,m;let d=this.options.editor,u=uC(c.getPos,d,this.editor,t.type),f=((p=this.options.domAttributes)==null?void 0:p.blockContent)||{},h=e.render.call({blockContentDOMAttributes:f,props:c,renderType:"nodeView"},u,d);return((m=e.meta)==null?void 0:m.selectable)===!1&&EL(h,this.editor),h}}});if(o.name!==t.type)throw Error("Node name does not match block type. This is a bug in BlockNote.");return{config:t,implementation:{...e,node:o,render(c,d){var f;let u=((f=o.options.domAttributes)==null?void 0:f.blockContent)||{};return e.render.call({blockContentDOMAttributes:u,props:void 0,renderType:"dom"},c,d)},toExternalHTML:(c,d,u)=>{var h,p;let f=((h=o.options.domAttributes)==null?void 0:h.blockContent)||{};return((p=e.toExternalHTML)==null?void 0:p.call({blockContentDOMAttributes:f},c,d,u))??e.render.call({blockContentDOMAttributes:f,renderType:"dom",props:void 0},c,d)}},extensions:n}}function un(t,e,n){return(r={})=>{let o=typeof t=="function"?t(r):t,i=typeof e=="function"?e(r):e,s=n?typeof n=="function"?n(r):n:void 0;return{config:o,implementation:{...i,toExternalHTML(l,a,c){var u,f;let d=(u=i.toExternalHTML)==null?void 0:u.call({blockContentDOMAttributes:this.blockContentDOMAttributes},l,a,c);if(d!==void 0)return yh(d,l.type,l.props,o.propSchema,((f=i.meta)==null?void 0:f.fileBlockAccept)!==void 0)},render(l,a){var c;return yh(i.render.call({blockContentDOMAttributes:this.blockContentDOMAttributes,renderType:this.renderType,props:this.props},l,a),l.type,l.props,o.propSchema,((c=i.meta)==null?void 0:c.fileBlockAccept)!==void 0,this.blockContentDOMAttributes)}},extensions:s}}}function co(t,e){let n=t.resolve(e);if(n.nodeAfter&&n.nodeAfter.type.isInGroup("bnBlock"))return{posBeforeNode:n.pos,node:n.nodeAfter};let r=n.depth,o=n.node(r);for(;r>0;){if(o.type.isInGroup("bnBlock"))return{posBeforeNode:n.before(r),node:o};r--,o=n.node(r)}let i=[];t.descendants((l,a)=>{l.type.isInGroup("bnBlock")&&i.push(a)}),console.warn(`Position ${e} is not within a blockContainer node.`);let s=t.resolve(i.find(l=>l>=e)||i[i.length-1]);return{posBeforeNode:s.pos,node:s.nodeAfter}}function lm(t,e){if(!t.type.isInGroup("bnBlock"))throw Error(`Attempted to get bnBlock node at position but found node of different type ${t.type.name}`);let n=t,r=e,o={node:n,beforePos:r,afterPos:r+n.nodeSize};if(n.type.name==="blockContainer"){let i,s;if(n.forEach((l,a)=>{if(l.type.spec.group==="blockContent"){let c=l,d=r+a+1;i={node:c,beforePos:d,afterPos:d+l.nodeSize}}else if(l.type.name==="blockGroup"){let c=l,d=r+a+1;s={node:c,beforePos:d,afterPos:d+l.nodeSize}}}),!i)throw Error(`blockContainer node does not contain a blockContent node in its children: ${n}`);return{isBlockContainer:!0,bnBlock:o,blockContent:i,childContainer:s,blockNoteType:i.node.type.name}}else{if(!o.node.type.isInGroup("childContainer"))throw Error(`bnBlock node is not in the childContainer group: ${o.node}`);return{isBlockContainer:!1,bnBlock:o,childContainer:o,blockNoteType:o.node.type.name}}}function Or(t){return lm(t.node,t.posBeforeNode)}function uo(t){if(!t.nodeAfter)throw Error(`Attempted to get blockContainer node at position ${t.pos} but a node at this position does not exist`);return lm(t.nodeAfter,t.pos)}function Ze(t){return Or(co(t.doc,t.selection.anchor))}function Hl(t){return Or(co(t.doc,t.selection.anchor))}function st(t){return"doc"in t?t.doc.type.schema:t.type.schema}function fC(t){return t.cached.blockNoteEditor}function Fl(t){return fC(t).schema}function am(t){return Fl(t).blockSchema}function cm(t){return Fl(t).inlineContentSchema}function ds(t){return Fl(t).styleSchema}function dm(t){return fC(t).blockCache}function hC(t,e,n){var i,s;let r={type:"tableContent",columnWidths:[],headerRows:void 0,headerCols:void 0,rows:[]},o=[];t.content.forEach((l,a,c)=>{let d={cells:[]};c===0&&l.content.forEach(u=>{let f=u.attrs.colwidth;f??(f=Array(u.attrs.colspan??1).fill(void 0)),r.columnWidths.push(...f)}),d.cells=l.content.content.map((u,f)=>(o[c]||(o[c]=[]),o[c][f]=u.type.name==="tableHeader",{type:"tableCell",content:u.content.content.map(h=>Td(h,e,n)).reduce((h,p)=>{if(!h.length)return p;let m=h[h.length-1],g=p[0];return g&&Qo(m)&&Qo(g)&&JSON.stringify(m.styles)===JSON.stringify(g.styles)?(m.text+=`
119
+ `+g.text,h.push(...p.slice(1)),h):(h.push(...p),h)},[]),props:{colspan:u.attrs.colspan,rowspan:u.attrs.rowspan,backgroundColor:u.attrs.backgroundColor,textColor:u.attrs.textColor,textAlignment:u.attrs.textAlignment}})),r.rows.push(d)});for(let l=0;l<o.length;l++)(i=o[l])!=null&&i.every(a=>a)&&(r.headerRows=(r.headerRows??0)+1);for(let l=0;l<((s=o[0])==null?void 0:s.length);l++)o!=null&&o.every(a=>a[l])&&(r.headerCols=(r.headerCols??0)+1);return r}function Td(t,e,n){let r=[],o;return t.content.forEach(i=>{if(i.type.name==="hardBreak"){if(o)if(Qo(o))o.text+=`
120
+ `;else if(t0(o))o.content[o.content.length-1].text+=`
121
+ `;else throw Error("unexpected");else o={type:"text",text:`
122
+ `,styles:{}};return}if(i.type.name!=="link"&&i.type.name!=="text"){if(!e[i.type.name]){console.warn("unrecognized inline content type",i.type.name);return}o&&(o=(r.push(o),void 0)),r.push(um(i,e,n));return}let s={},l;for(let a of i.marks)if(a.type.name==="link")l=a;else{let c=n[a.type.name];if(!c){if(a.type.spec.blocknoteIgnore)continue;throw Error(`style ${a.type.name} not found in styleSchema`)}if(c.propSchema==="boolean")s[c.type]=!0;else if(c.propSchema==="string")s[c.type]=a.attrs.stringValue;else throw new dr(c.propSchema)}o?Qo(o)?l?(r.push(o),o={type:"link",href:l.attrs.href,content:[{type:"text",text:i.textContent,styles:s}]}):JSON.stringify(o.styles)===JSON.stringify(s)?o.text+=i.textContent:(r.push(o),o={type:"text",text:i.textContent,styles:s}):t0(o)&&(l?o.href===l.attrs.href?JSON.stringify(o.content[o.content.length-1].styles)===JSON.stringify(s)?o.content[o.content.length-1].text+=i.textContent:o.content.push({type:"text",text:i.textContent,styles:s}):(r.push(o),o={type:"link",href:l.attrs.href,content:[{type:"text",text:i.textContent,styles:s}]}):(r.push(o),o={type:"text",text:i.textContent,styles:s})):o=l?{type:"link",href:l.attrs.href,content:[{type:"text",text:i.textContent,styles:s}]}:{type:"text",text:i.textContent,styles:s}}),o&&r.push(o),r}function um(t,e,n){if(t.type.name==="text"||t.type.name==="link")throw Error("unexpected");let r={},o=e[t.type.name];for(let[s,l]of Object.entries(t.attrs)){if(!o)throw Error("ic node is of an unrecognized type: "+t.type.name);s in o.propSchema&&(r[s]=l)}let i;return i=o.content==="styled"?Td(t,e,n):void 0,{type:t.type.name,props:r,content:i}}function qe(t,e,n=am(e),r=cm(e),o=ds(e),i=dm(e)){var m;if(!t.type.isInGroup("bnBlock"))throw Error("Node should be a bnBlock, but is instead: "+t.type.name);let s=i==null?void 0:i.get(t);if(s)return s;let l=lm(t,0),a=l.bnBlock.node.attrs.id;a===null&&(a=Md.options.generateID());let c=n[l.blockNoteType];if(!c)throw Error("Block is of an unrecognized type: "+l.blockNoteType);let d={};for(let[g,y]of Object.entries({...t.attrs,...l.isBlockContainer?l.blockContent.node.attrs:{}})){let w=c.propSchema;g in w&&!(w[g].default===void 0&&y===void 0)&&(d[g]=y)}let u=n[l.blockNoteType],f=[];(m=l.childContainer)==null||m.node.forEach(g=>{f.push(qe(g,e,n,r,o,i))});let h;if(u.content==="inline"){if(!l.isBlockContainer)throw Error("impossible");h=Td(l.blockContent.node,r,o)}else if(u.content==="table"){if(!l.isBlockContainer)throw Error("impossible");h=hC(l.blockContent.node,r,o)}else if(u.content==="none")h=void 0;else throw new dr(u.content);let p={id:a,type:u.type,props:d,content:h,children:f};return i==null||i.set(t,p),p}function AL(t,e=st(t),n=am(e),r=cm(e),o=ds(e),i=dm(e)){let s=[];return t.firstChild&&t.firstChild.descendants(l=>(s.push(qe(l,e,n,r,o,i)),!1)),s}function NL(t,e,n=am(e),r=cm(e),o=ds(e),i=dm(e)){function s(l,a,c){if(l.type.name!=="blockGroup")throw Error("unexpected");let d=[],u,f;return l.forEach((h,p,m)=>{if(h.type.name!=="blockContainer")throw Error("unexpected");if(h.childCount===0)return;if(h.childCount===0||h.childCount>2)throw Error("unexpected, blockContainer.childCount: "+h.childCount);let g=m===0,y=m===l.childCount-1;if(h.firstChild.type.name==="blockGroup"){if(!g)throw Error("unexpected");let C=s(h.firstChild,Math.max(0,a-1),y?Math.max(0,c-1):0);u=C.blockCutAtStart,y&&(f=C.blockCutAtEnd),d.push(...C.blocks);return}let w=qe(h,e,n,r,o,i),k=h.childCount>1?h.child(1):void 0,x=[];if(k){let C=s(k,0,y?Math.max(0,c-1):0);x=C.blocks,y&&(f=C.blockCutAtEnd)}y&&!k&&c>1&&(f=w.id),g&&a>1&&(u=w.id),d.push({...w,children:x})}),{blocks:d,blockCutAtStart:u,blockCutAtEnd:f}}if(t.content.childCount===0)return{blocks:[],blockCutAtStart:void 0,blockCutAtEnd:void 0};if(t.content.childCount!==1)throw Error("slice must be a single block, did you forget includeParents=true?");return s(t.content.firstChild,Math.max(t.openStart-1,0),Math.max(t.openEnd-1,0))}function pC(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,n.config]))}function RL(t){return t==="boolean"?{}:{stringValue:{default:void 0,keepOnSplit:!0,parseHTML:e=>e.getAttribute("data-value"),renderHTML:e=>e.stringValue===void 0?{}:{"data-value":e.stringValue}}}}function wa(t,e,n,r){return t.dom.setAttribute("data-style-type",e),r==="string"&&t.dom.setAttribute("data-value",n),t.contentDOM&&t.contentDOM.setAttribute("data-editable",""),t}function mC(t,e){return{config:t,implementation:e}}function ks(t,e){return mC({type:t.name,propSchema:e},{mark:t,render(n,r){let o=r.pmSchema.marks[t.name].spec.toDOM;if(o===void 0)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let i=r.pmSchema.mark(t.name,{stringValue:n}),s=cn.renderSpec(document,o(i,!0));if(typeof s!="object"||!("dom"in s))throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");return s},toExternalHTML(n,r){let o=r.pmSchema.marks[t.name].spec.toDOM;if(o===void 0)throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");let i=r.pmSchema.mark(t.name,{stringValue:n}),s=cn.renderSpec(document,o(i,!0));if(typeof s!="object"||!("dom"in s))throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");return s}})}function gC(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>[e,n.config]))}function IL(t,e){let n=[{tag:`[data-style-type="${t.type}"]`,contentElement:r=>{let o=r;return o.matches("[data-editable]")?o:o.querySelector("[data-editable]")||o}}];return e&&n.push({tag:"*",consuming:!1,getAttrs(r){if(typeof r=="string")return!1;let o=e==null?void 0:e(r);return o===void 0?!1:{stringValue:o}}}),n}function bC(t,e){let n=Nn.create({name:t.type,addAttributes(){return RL(t.propSchema)},parseHTML(){return IL(t,e.parse)},renderHTML({mark:r}){return wa((e.toExternalHTML||e.render)(r.attrs.stringValue),t.type,r.attrs.stringValue,t.propSchema)},addMarkView(){return({mark:r})=>wa(e.render(r.attrs.stringValue),t.type,r.attrs.stringValue,t.propSchema)}});return mC(t,{...e,mark:n,render:r=>wa(e.render(r),t.type,r,t.propSchema),toExternalHTML:r=>wa((e.toExternalHTML||e.render)(r),t.type,r,t.propSchema)})}function OL(t){let e=_L(t),{roots:n,nonRoots:r}=o0(e),o=[];for(;n.size;){o.push(n);let i=new Set;for(let s of n){let l=t.get(s);if(l)for(let a of l){let c=e.get(a);if(c===void 0)continue;let d=c-1;e.set(a,d),d===0&&i.add(a)}}n=i}if(r=o0(e).nonRoots,r.size)throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);return o}function DL(t){return OL(PL(t))}function _L(t){let e=new Map;for(let[n,r]of t.entries()){e.has(n)||e.set(n,0);for(let o of r){let i=e.get(o)??0;e.set(o,i+1)}}return e}function o0(t){let e=new Set,n=new Set;for(let[r,o]of t.entries())o===0?e.add(r):n.add(r);return{roots:e,nonRoots:n}}function PL(t){let e=new Map;for(let[n,r]of t.entries()){e.has(n)||e.set(n,new Set);for(let o of r)e.has(o)||e.set(o,new Set),e.get(o).add(n)}return e}function $L(){return new Map}function i0(t,e,n){return t.has(e)||t.set(e,new Set),t.get(e).add(n),t}function yC(t){let e=$L();for(let o of t)Array.isArray(o.runsBefore)&&o.runsBefore.length>0?o.runsBefore.forEach(i=>{i0(e,o.key,i)}):i0(e,"default",o.key);let n=DL(e),r=n.findIndex(o=>o.has("default"));return o=>91+(n.findIndex(i=>i.has(o))+r)*10}function s0(t){return t&&Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}var LL=class{constructor(e){B(this,"BlockNoteEditor","only for types");B(this,"Block","only for types");B(this,"PartialBlock","only for types");B(this,"inlineContentSpecs");B(this,"styleSpecs");B(this,"blockSpecs");B(this,"blockSchema");B(this,"inlineContentSchema");B(this,"styleSchema");this.opts=e;let{blockSpecs:n,inlineContentSpecs:r,styleSpecs:o,blockSchema:i,inlineContentSchema:s,styleSchema:l}=this.init();this.blockSpecs=n,this.styleSpecs=o,this.styleSchema=l,this.inlineContentSpecs=r,this.blockSchema=i,this.inlineContentSchema=s}init(){let e=yC(Object.entries({...this.opts.blockSpecs,...this.opts.inlineContentSpecs,...this.opts.styleSpecs}).map(([i,s])=>{var l;return{key:i,runsBefore:((l=s.implementation)==null?void 0:l.runsBefore)??[]}})),n=Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([i,s])=>[i,TL(s.config,s.implementation,s.extensions,e(i))])),r=Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([i,s])=>{var l;return typeof s.config=="object"?[i,{...s,implementation:{...s.implementation,node:(l=s.implementation)==null?void 0:l.node.extend({priority:e(i)})}}]:[i,s]})),o=Object.fromEntries(Object.entries(this.opts.styleSpecs).map(([i,s])=>{var l;return[i,{...s,implementation:{...s.implementation,mark:(l=s.implementation)==null?void 0:l.mark.extend({priority:e(i)})}}]}));return{blockSpecs:n,blockSchema:Object.fromEntries(Object.entries(n).map(([i,s])=>[i,s.config])),inlineContentSpecs:s0(r),styleSpecs:s0(o),inlineContentSchema:pC(r),styleSchema:gC(o)}}extend(e){Object.assign(this.opts.blockSpecs,e.blockSpecs),Object.assign(this.opts.inlineContentSpecs,e.inlineContentSpecs),Object.assign(this.opts.styleSpecs,e.styleSpecs);let{blockSpecs:n,inlineContentSpecs:r,styleSpecs:o,blockSchema:i,inlineContentSchema:s,styleSchema:l}=this.init();return this.blockSpecs=n,this.styleSpecs=o,this.styleSchema=l,this.inlineContentSpecs=r,this.blockSchema=i,this.inlineContentSchema=s,this}};function wo(t){let{height:e,width:n}=fm(t),r=Array(e).fill(!1).map(()=>Array(n).fill(null)),o=(i,s)=>{for(let l=i;l<e;l++)for(let a=s;a<n;a++)if(!r[l][a])return{row:l,col:a};throw Error("Unable to create occupancy grid for table, no more available cells")};for(let i=0;i<t.content.rows.length;i++)for(let s=0;s<t.content.rows[i].cells.length;s++){let l=lo(t.content.rows[i].cells[s]),a=vl(l),c=ei(l),{row:d,col:u}=o(i,s);for(let f=d;f<d+a;f++)for(let h=u;h<u+c;h++){if(r[f][h])throw Error(`Unable to create occupancy grid for table, cell at ${f},${h} is already occupied`);r[f][h]={row:i,col:s,rowspan:a,colspan:c,cell:l}}}return r}function kl(t){let e=new Set;return t.map(n=>({cells:n.map(r=>e.has(r.row+":"+r.col)?!1:(e.add(r.row+":"+r.col),r.cell)).filter(r=>r!==!1)}))}function ti(t,e,n=wo(e)){for(let r=0;r<n.length;r++)for(let o=0;o<n[r].length;o++){let i=n[r][o];if(i&&i.row===t.row&&i.col===t.col)return{row:r,col:o,cell:i.cell}}throw Error(`Unable to resolve relative table cell indices for table, cell at ${t.row},${t.col} is not occupied`)}function fm(t){let e=t.content.rows.length,n=0;return t.content.rows.forEach(r=>{let o=0;r.cells.forEach(i=>{o+=ei(i)}),n=Math.max(n,o)}),{height:e,width:n}}function vC(t,e,n=wo(e)){var o;let r=(o=n[t.row])==null?void 0:o[t.col];if(r)return{row:r.row,col:r.col,cell:r.cell}}function vh(t,e){var i;let n=wo(t);if(e<0||e>=n.length)return[];let r=0;for(let s=0;s<e;s++){let l=(i=n[r])==null?void 0:i[0];if(!l)return[];r+=l.rowspan}let o=Array(n[0].length).fill(!1).map((s,l)=>vC({row:r,col:l},t,n)).filter(s=>s!==void 0);return o.filter((s,l)=>o.findIndex(a=>a.row===s.row&&a.col===s.col)===l)}function wh(t,e){var i;let n=wo(t);if(e<0||e>=n[0].length)return[];let r=0;for(let s=0;s<e;s++){let l=(i=n[0])==null?void 0:i[r];if(!l)return[];r+=l.colspan}let o=Array(n.length).fill(!1).map((s,l)=>vC({row:l,col:r},t,n)).filter(s=>s!==void 0);return o.filter((s,l)=>o.findIndex(a=>a.row===s.row&&a.col===s.col)===l)}function BL(t,e,n,r=wo(t)){let{col:o}=ti({row:0,col:e},t,r),{col:i}=ti({row:0,col:n},t,r);return r.forEach(s=>{let[l]=s.splice(o,1);s.splice(i,0,l)}),kl(r)}function jL(t,e,n,r=wo(t)){let{row:o}=ti({row:e,col:0},t,r),{row:i}=ti({row:n,col:0},t,r),[s]=r.splice(o,1);return r.splice(i,0,s),kl(r)}function kh(t){return t?yl(t)?kh(t.content):typeof t=="string"?t.length===0:Array.isArray(t)?t.every(e=>typeof e=="string"?e.length===0:Qo(e)?e.text.length===0:cC(e)?typeof e.content=="string"?e.content.length===0:e.content.every(n=>n.text.length===0):!1):!1:!0}function VL(t,e,n=wo(t)){if(e==="columns"){let i=0;for(let s=n[0].length-1;s>=0&&n.every(l=>kh(l[s].cell)&&l[s].colspan===1);s--)i++;for(let s=n.length-1;s>=0;s--){let l=Math.max(n[s].length-i,1);n[s]=n[s].slice(0,l)}return kl(n)}let r=0;for(let i=n.length-1;i>=0&&n[i].every(s=>kh(s.cell)&&s.rowspan===1);i--)r++;let o=Math.min(r,n.length-1);return n.splice(n.length-o,o),kl(n)}function HL(t,e,n,r=wo(t)){let{width:o,height:i}=fm(t);if(e==="columns")r.forEach((s,l)=>{if(n>=0)for(let a=0;a<n;a++)s.push({row:l,col:Math.max(...s.map(c=>c.col))+1,rowspan:1,colspan:1,cell:lo("")});else s.splice(o+n,-1*n)});else if(n>0)for(let s=0;s<n;s++){let l=Array(o).fill(null).map((a,c)=>({row:i+s,col:c,rowspan:1,colspan:1,cell:lo("")}));r.push(l)}else n<0&&r.splice(i+n,-1*n);return kl(r)}function wC(t,e,n){let r=vh(t,n);if(!r.some(s=>vl(s.cell)>1))return!0;let o=n,i=n;return r.forEach(s=>{let l=vl(s.cell);o=Math.max(o,s.row+l-1),i=Math.min(i,s.row)}),e<n?n===o:n===i}function kC(t,e,n){let r=wh(t,n);if(!r.some(s=>ei(s.cell)>1))return!0;let o=n,i=n;return r.forEach(s=>{let l=ei(s.cell);o=Math.max(o,s.col+l-1),i=Math.min(i,s.col)}),e<n?n===o:n===i}function FL(t,e,n){let r=ti(t,n),o=ti(e,n);return r.col===o.col}function l0(t,e,n,r){let o=[];for(let[i,s]of Object.entries(t.styles||{})){let l=n[i];if(!l)throw Error(`style ${i} not found in styleSchema`);if(l.propSchema==="boolean")s&&o.push(e.mark(i));else if(l.propSchema==="string")s&&o.push(e.mark(i,{stringValue:s}));else throw new dr(l.propSchema)}return!r||!e.nodes[r].spec.code?t.text.split(/(\n)/g).filter(i=>i.length>0).map(i=>i===`
123
+ `?e.nodes.hardBreak.createChecked():e.text(i,o)):t.text.length>0?[e.text(t.text,o)]:[]}function zL(t,e,n){let r=e.marks.link.create({href:t.href});return xh(t.content,e,n).map(o=>{if(o.type.name==="text")return o.mark([...o.marks,r]);if(o.type.name==="hardBreak")return o;throw Error("unexpected node type")})}function xh(t,e,n,r){let o=[];if(typeof t=="string")return o.push(...l0({text:t,styles:{}},e,n,r)),o;for(let i of t)o.push(...l0(i,e,n,r));return o}function Gn(t,e,n,r=ds(e)){let o=[];for(let i of t)typeof i=="string"?o.push(...xh(i,e,r,n)):cC(i)?o.push(...zL(i,e,r)):Qo(i)?o.push(...xh([i],e,r,n)):o.push(xC(i,e,r));return o}function Ad(t,e,n=ds(e)){let r=[],o=Array(t.headerRows??0).fill(!0),i=Array(t.headerCols??0).fill(!0),s=t.columnWidths??[];for(let l=0;l<t.rows.length;l++){let a=t.rows[l],c=[],d=o[l];for(let f=0;f<a.cells.length;f++){let h=a.cells[f],p=i[f],m=null,g=ti({row:l,col:f},{content:t}),y=s[g.col]?[s[g.col]]:null;if(h)if(typeof h=="string")m=e.text(h);else if(yl(h)){h.content&&(m=Gn(h.content,e,"tableParagraph",n));let k=ei(h);k>1&&(y=Array(k).fill(!1).map((x,C)=>s[g.col+C]??void 0))}else m=Gn(h,e,"tableParagraph",n);let w=e.nodes[p||d?"tableHeader":"tableCell"].createChecked({...yl(h)?h.props:{},colwidth:y},e.nodes.tableParagraph.createChecked(void 0,m));c.push(w)}let u=e.nodes.tableRow.createChecked({},c);r.push(u)}return r}function xC(t,e,n){let r,o=t.type;if(o===void 0&&(o="paragraph"),!e.nodes[o])throw Error(`node type ${o} not found in schema`);if(!t.content)r=e.nodes[o].createChecked(t.props);else if(typeof t.content=="string"){let i=Gn([t.content],e,o,n);r=e.nodes[o].createChecked(t.props,i)}else if(Array.isArray(t.content)){let i=Gn(t.content,e,o,n);r=e.nodes[o].createChecked(t.props,i)}else if(t.content.type==="tableContent"){let i=Ad(t.content,e,n);r=e.nodes[o].createChecked(t.props,i)}else throw new dr(t.content.type);return r}function si(t,e,n=ds(e)){let r=t.id;r===void 0&&(r=Md.options.generateID());let o=[];if(t.children)for(let i of t.children)o.push(si(i,e,n));if(!t.type||e.nodes[t.type].isInGroup("blockContent")){let i=xC(t,e,n),s=o.length>0?e.nodes.blockGroup.createChecked({},o):void 0;return e.nodes.blockContainer.createChecked({id:r,...t.props},s?[i,s]:i)}else{if(e.nodes[t.type].isInGroup("bnBlock"))return e.nodes[t.type].create({id:r,...t.props},o);throw Error(`block type ${t.type} doesn't match blockContent or bnBlock group`)}}function Ht(t,e){let n,r;if(e.firstChild.descendants((o,i)=>n?!1:!hm(o)||o.attrs.id!==t?!0:(n=o,r=i+1,!1)),!(n===void 0||r===void 0))return{node:n,posBeforeNode:r}}function hm(t){return t.type.isInGroup("bnBlock")}var UL=(t,e)=>({tr:n,dispatch:r})=>(r&&Nd(n,t,e),!0);function Nd(t,e,n,r,o){let i=uo(t.doc.resolve(e)),s=null;i.blockNoteType==="table"&&(s=GL(t));let l=st(t),a=l.nodes[i.blockNoteType],c=l.nodes[n.type||i.blockNoteType],d=c.isInGroup("bnBlock")?c:l.nodes.blockContainer;if(i.isBlockContainer&&c.isInGroup("blockContent"))a0(n,t,i),WL(n,t,a,c,i);else if(!i.isBlockContainer&&c.isInGroup("bnBlock"))a0(n,t,i);else{let u=si({children:qe(i.bnBlock.node,l).children,...n},l);u.check(),t.replaceWith(i.bnBlock.beforePos,i.bnBlock.afterPos,u);return}t.setNodeMarkup(i.bnBlock.beforePos,d,{...i.bnBlock.node.attrs,...n.props}),s&&ZL(t,i,s)}function WL(t,e,n,r,o,i,s){let l=st(e),a="keep";if(t.content)if(typeof t.content=="string")a=Gn([t.content],l,r.name);else if(Array.isArray(t.content))a=Gn(t.content,l,r.name);else if(t.content.type==="tableContent")a=Ad(t.content,l);else throw new dr(t.content.type);else n.spec.content===""||r.spec.content!==n.spec.content&&(a=[]);a==="keep"?e.setNodeMarkup(o.blockContent.beforePos,r,{...o.blockContent.node.attrs,...t.props}):e.replaceWith(o.blockContent.beforePos,o.blockContent.afterPos,r.createChecked({...o.blockContent.node.attrs,...t.props},a))}function a0(t,e,n){let r=st(e);if(t.children!==void 0&&t.children.length>0){let o=t.children.map(i=>{let s=si(i,r);return s.check(),s});if(n.childContainer)e.step(new Ke(n.childContainer.beforePos+1,n.childContainer.afterPos-1,new j(I.from(o),0,0)));else{if(!n.isBlockContainer)throw Error("impossible");e.insert(n.blockContent.afterPos,r.nodes.blockGroup.createChecked({},o))}}}function qL(t,e,n,r,o){let i=typeof e=="string"?e:e.id,s=Ht(i,t.doc);if(!s)throw Error(`Block with ID ${i} not found`);return Nd(t,s.posBeforeNode,n),qe(t.doc.resolve(s.posBeforeNode+1).node(),st(t))}function GL(t){let e="selection"in t?t.selection:null;if(!(e instanceof W))return null;let n=t.doc.resolve(e.head),r=-1,o=-1;for(let p=n.depth;p>=0;p--){let m=n.node(p).type.name;if(r<0&&(m==="tableCell"||m==="tableHeader")&&(r=p),m==="table"){o=p;break}}if(r<0||o<0)return null;let i=n.before(r),s=n.before(o),l=t.doc.nodeAt(s);if(!l||l.type.name!=="table")return null;let a=je.get(l),c=i-(s+1),d=a.map.indexOf(c);if(d<0)return null;let u=Math.floor(d/a.width),f=d%a.width,h=i+1+1;return{row:u,col:f,offset:Math.max(0,e.head-h)}}function ZL(t,e,n){var m;if(e.blockNoteType!=="table")return!1;let r=-1;if(e.isBlockContainer)r=t.mapping.map(e.blockContent.beforePos);else{let g=t.mapping.map(e.bnBlock.beforePos),y=g+(((m=t.doc.nodeAt(g))==null?void 0:m.nodeSize)||0);t.doc.nodesBetween(g,y,(w,k)=>w.type.name==="table"?(r=k,!1):!0)}let o=r>=0?t.doc.nodeAt(r):null;if(!o||o.type.name!=="table")return!1;let i=je.get(o),s=Math.max(0,Math.min(n.row,i.height-1)),l=Math.max(0,Math.min(n.col,i.width-1)),a=s*i.width+l,c=i.map[a];if(c==null)return!1;let d=r+1+c+1,u=t.doc.nodeAt(d),f=d+1,h=u?u.content.size:0,p=f+Math.max(0,Math.min(n.offset,h));return"selection"in t&&t.setSelection(W.create(t.doc,p)),!0}var eo={gray:{text:"#9b9a97",background:"#ebeced"},brown:{text:"#64473a",background:"#e9e5e3"},red:{text:"#e03e3e",background:"#fbe4e4"},orange:{text:"#d9730d",background:"#f6e9d9"},yellow:{text:"#dfab01",background:"#fbf3db"},green:{text:"#4d6461",background:"#ddedea"},blue:{text:"#0b6e99",background:"#ddebf1"},purple:{text:"#6940a5",background:"#eae4f2"},pink:{text:"#ad1a72",background:"#f4dfeb"}},xe={backgroundColor:{default:"default"},textColor:{default:"default"},textAlignment:{default:"left",values:["left","center","right","justify"]}},kt=t=>{let e={};return t.hasAttribute("data-background-color")?e.backgroundColor=t.getAttribute("data-background-color"):t.style.backgroundColor&&(e.backgroundColor=t.style.backgroundColor),t.hasAttribute("data-text-color")?e.textColor=t.getAttribute("data-text-color"):t.style.color&&(e.textColor=t.style.color),e.textAlignment=xe.textAlignment.values.includes(t.style.textAlign)?t.style.textAlign:void 0,e},li=(t,e)=>{t.backgroundColor&&t.backgroundColor!==xe.backgroundColor.default&&(e.style.backgroundColor=t.backgroundColor in eo?eo[t.backgroundColor].background:t.backgroundColor),t.textColor&&t.textColor!==xe.textColor.default&&(e.style.color=t.textColor in eo?eo[t.textColor].text:t.textColor),t.textAlignment&&t.textAlignment!==xe.textAlignment.default&&(e.style.textAlign=t.textAlignment)},KL=(t="backgroundColor")=>({default:xe.backgroundColor.default,parseHTML:e=>e.hasAttribute("data-background-color")?e.getAttribute("data-background-color"):e.style.backgroundColor?e.style.backgroundColor:xe.backgroundColor.default,renderHTML:e=>e[t]===xe.backgroundColor.default?{}:{"data-background-color":e[t]}}),JL=(t="textColor")=>({default:xe.textColor.default,parseHTML:e=>e.hasAttribute("data-text-color")?e.getAttribute("data-text-color"):e.style.color?e.style.color:xe.textColor.default,renderHTML:e=>e[t]===xe.textColor.default?{}:{"data-text-color":e[t]}}),Rd=(t,e)=>{var r;let n=t.querySelector(e);if(n)return{targetElement:n,caption:((r=t.querySelector("figcaption"))==null?void 0:r.textContent)??void 0}},Bn=ve(({editor:t})=>{let e=go(void 0);function n(){e.setState(void 0)}return{key:"filePanel",store:e,mount({signal:r}){let o=t.onChange(n,!1),i=t.onSelectionChange(n,!1);r.addEventListener("abort",()=>{o(),i()})},closeMenu:n,showMenu(r){e.setState(r)}}}),YL=(t,e,n)=>{let r=document.createElement("div");r.className="bn-add-file-button";let o=document.createElement("div");o.className="bn-add-file-button-icon",n?o.appendChild(n):o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',r.appendChild(o);let i=document.createElement("p");i.className="bn-add-file-button-text",i.innerHTML=t.type in e.dictionary.file_blocks.add_button_text?e.dictionary.file_blocks.add_button_text[t.type]:e.dictionary.file_blocks.add_button_text.file,r.appendChild(i);let s=a=>{a.preventDefault(),a.stopPropagation()},l=()=>{var a;e.isEditable&&((a=e.getExtension(Bn))==null||a.showMenu(t.id))};return r.addEventListener("mousedown",s,!0),r.addEventListener("click",l,!0),{dom:r,destroy:()=>{r.removeEventListener("mousedown",s,!0),r.removeEventListener("click",l,!0)}}},XL='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>',QL=t=>{let e=document.createElement("div");e.className="bn-file-name-with-icon";let n=document.createElement("div");n.className="bn-file-icon",n.innerHTML=XL,e.appendChild(n);let r=document.createElement("p");return r.className="bn-file-name",r.textContent=t.props.name,e.appendChild(r),{dom:e}},pm=(t,e,n,r)=>{let o=t.props.url!==""&&!!t.props.caption,i=document.createElement(o?"figure":"div");if(i.className="bn-file-block-content-wrapper",t.props.url===""){let l=YL(t,e,r);i.appendChild(l.dom);let a=e.onUploadStart(c=>{if(c===t.id){i.removeChild(l.dom);let d=document.createElement("div");d.className="bn-file-loading-preview",d.textContent="Loading...",i.appendChild(d)}});return{dom:i,destroy:()=>{a(),l.destroy()}}}let s={dom:i};if(t.props.showPreview===!1||!n){let l=QL(t);i.appendChild(l.dom),s.destroy=()=>{var a;(a=l.destroy)==null||a.call(l)}}else i.appendChild(n.dom);if(t.props.caption){let l=document.createElement("figcaption");l.className="bn-file-caption",l.textContent=t.props.caption,i.appendChild(l)}return s},mm=(t,e)=>{let n=document.createElement("figure"),r=document.createElement("figcaption");return r.textContent=e,n.appendChild(t),n.appendChild(r),{dom:n}},Id=(t,e)=>{let n=document.createElement("div"),r=document.createElement("p");return r.textContent=e,n.appendChild(t),n.appendChild(r),{dom:n}},c0=t=>({url:t.src||void 0}),eB=t=>({type:"audio",propSchema:{backgroundColor:xe.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0}},content:"none"}),tB=(t={})=>e=>{if(e.tagName==="AUDIO"){if(e.closest("figure"))return;let{backgroundColor:n}=kt(e);return{...c0(e),backgroundColor:n}}if(e.tagName==="FIGURE"){let n=Rd(e,"audio");if(!n)return;let{targetElement:r,caption:o}=n,{backgroundColor:i}=kt(e);return{...c0(r),backgroundColor:i,caption:o}}},nB=(t={})=>(e,n)=>{let r=document.createElement("div");r.innerHTML=t.icon??'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';let o=document.createElement("audio");return o.className="bn-audio",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(i=>{o.src=i}):o.src=e.props.url,o.controls=!0,o.contentEditable="false",o.draggable=!1,pm(e,n,{dom:o},r.firstElementChild)},rB=(t={})=>(e,n)=>{if(!e.props.url)return{dom:document.createElement("audio")};let r;return e.props.showPreview?(r=document.createElement("audio"),r.src=e.props.url):(r=document.createElement("a"),r.href=e.props.url,r.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?mm(r,e.props.caption):Id(r,e.props.caption):{dom:r}},oB=un(eB,t=>({meta:{fileBlockAccept:["audio/*"]},parse:tB(t),render:nB(t),toExternalHTML:rB(t),runsBefore:["file"]})),d0=Symbol.for("blocknote.shikiParser"),Ku=Symbol.for("blocknote.shikiHighlighterPromise");function iB(t){let e=globalThis,n,r;return G_({parser:o=>{if(!t.createHighlighter)return[];if(!n)return e[Ku]=e[Ku]||t.createHighlighter(),e[Ku].then(s=>{n=s});let i=CC(t,o.language);return!i||i==="text"||i==="none"||i==="plaintext"||i==="txt"?[]:n.getLoadedLanguages().includes(i)?(r||(r=e[d0]||K_(n),e[d0]=r),r(o)):n.loadLanguage(i)},languageExtractor:o=>o.attrs.language,nodeTypes:["codeBlock"]})}var sB=({defaultLanguage:t="text"})=>({type:"codeBlock",propSchema:{language:{default:t}},content:"inline"}),lB=un(sB,t=>({meta:{code:!0,defining:!0,isolating:!1},parse:e=>{var r,o;if(e.tagName!=="PRE"||e.childElementCount!==1||((r=e.firstElementChild)==null?void 0:r.tagName)!=="CODE")return;let n=e.firstElementChild;return{language:n.getAttribute("data-language")||((o=n.className.split(" ").find(i=>i.includes("language-")))==null?void 0:o.replace("language-",""))}},parseContent:({el:e,schema:n})=>{let r=wn.fromSchema(n),o=e.firstElementChild;return r.parse(o,{preserveWhitespace:"full",topNode:n.nodes.codeBlock.create()}).content},render(e,n){let r=document.createDocumentFragment(),o=document.createElement("pre"),i=document.createElement("code");o.appendChild(i);let s;if(t.supportedLanguages){let l=document.createElement("select");if(Object.entries(t.supportedLanguages??{}).forEach(([c,{name:d}])=>{let u=document.createElement("option");u.value=c,u.text=d,l.appendChild(u)}),l.value=e.props.language||t.defaultLanguage||"text",n.isEditable){let c=d=>{let u=d.target.value;n.updateBlock(e.id,{props:{language:u}})};l.addEventListener("change",c),s=()=>l.removeEventListener("change",c)}else l.disabled=!0;let a=document.createElement("div");a.contentEditable="false",a.appendChild(l),r.appendChild(a)}return r.appendChild(o),{dom:r,contentDOM:i,destroy:()=>{s==null||s()}}},toExternalHTML(e){let n=document.createElement("pre"),r=document.createElement("code");return r.className=`language-${e.props.language}`,r.dataset.language=e.props.language,n.appendChild(r),{dom:n,contentDOM:r}}}),t=>[ve({key:"code-block-highlighter",prosemirrorPlugins:[iB(t)]}),ve({key:"code-block-keyboard-shortcuts",keyboardShortcuts:{Delete:({editor:e})=>e.transact(n=>{let{block:r}=e.getTextCursorPosition();if(r.type!=="codeBlock")return!1;let{$from:o}=n.selection;return o.parent.textContent?!1:(e.removeBlocks([r]),!0)}),Tab:({editor:e})=>t.indentLineWithTab===!1?!1:e.transact(n=>{let{block:r}=e.getTextCursorPosition();return r.type==="codeBlock"?(n.insertText(" "),!0):!1}),Enter:({editor:e})=>e.transact(n=>{let{block:r,nextBlock:o}=e.getTextCursorPosition();if(r.type!=="codeBlock")return!1;let{$from:i}=n.selection,s=i.parentOffset===i.parent.nodeSize-2,l=i.parent.textContent.endsWith(`
124
+
125
+ `);if(s&&l){if(n.delete(i.pos-2,i.pos),o)return e.setTextCursorPosition(o,"start"),!0;let[a]=e.insertBlocks([{type:"paragraph"}],r,"after");return e.setTextCursorPosition(a,"start"),!0}return n.insertText(`
126
+ `),!0}),"Shift-Enter":({editor:e})=>e.transact(()=>{let{block:n}=e.getTextCursorPosition();if(n.type!=="codeBlock")return!1;let[r]=e.insertBlocks([{type:"paragraph"}],n,"after");return e.setTextCursorPosition(r,"start"),!0})},inputRules:[{find:/^```(.*?)\s$/,replace:({match:e})=>{let n=e[1].trim();return{type:"codeBlock",props:{language:{language:CC(t,n)??n}.language},content:[]}}}]})]);function CC(t,e){var n;return(n=Object.entries(t.supportedLanguages??{}).find(([r,{aliases:o}])=>(o==null?void 0:o.includes(e))||r===e))==null?void 0:n[0]}var aB=()=>({type:"divider",propSchema:{},content:"none"}),cB=un(aB,{meta:{isolating:!1},parse(t){if(t.tagName==="HR")return{}},render(){return{dom:document.createElement("hr")}}},[ve({key:"divider-block-shortcuts",inputRules:[{find:RegExp("^---$"),replace(){return{type:"divider",props:{},content:[]}}}]})]),u0=t=>({url:t.src||void 0}),dB=()=>({type:"file",propSchema:{backgroundColor:xe.backgroundColor,name:{default:""},url:{default:""},caption:{default:""}},content:"none"}),uB=()=>t=>{if(t.tagName==="EMBED"){if(t.closest("figure"))return;let{backgroundColor:e}=kt(t);return{...u0(t),backgroundColor:e}}if(t.tagName==="FIGURE"){let e=Rd(t,"embed");if(!e)return;let{targetElement:n,caption:r}=e,{backgroundColor:o}=kt(t);return{...u0(n),backgroundColor:o,caption:r}}},fB=un(dB,{meta:{fileBlockAccept:["*/*"]},parse:uB(),render(t,e){return pm(t,e)},toExternalHTML(t){if(!t.props.url)return{dom:document.createElement("embed")};let e=document.createElement("a");return e.href=t.props.url,e.textContent=t.props.name||t.props.url,t.props.caption?Id(e,t.props.caption):{dom:e}}});function SC(t,e,n){var d;let r=wn.fromSchema(e),o=t.querySelector(":scope > summary"),i;if(o){let u=o.cloneNode(!0);dC(u),i=r.parse(u,{topNode:e.nodes.paragraph.create(),preserveWhitespace:!0}).content}else i=I.empty;let s=document.createElement("div");s.setAttribute("data-node-type","blockGroup");let l=!1;for(let u of Array.from(t.childNodes))u.tagName!=="SUMMARY"&&(u.nodeType===3&&!((d=u.textContent)!=null&&d.trim())||(l=!0,s.appendChild(u.cloneNode(!0))));let a=e.nodes[n].create({},i);if(!l)return a.content;let c=r.parse(s,{topNode:e.nodes.blockGroup.create()});return c.content.size>0?a.content.addToEnd(c):a.content}var hB={set:(t,e)=>window.localStorage.setItem(`toggle-${t.id}`,e?"true":"false"),get:t=>window.localStorage.getItem(`toggle-${t.id}`)==="true"},EC=(t,e,n,r=hB)=>{if("isToggleable"in t.props&&!t.props.isToggleable)return{dom:n};let o=document.createElement("div"),i=document.createElement("div");i.className="bn-toggle-wrapper";let s=document.createElement("button");s.className="bn-toggle-button",s.type="button",s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="CURRENTCOLOR"><path d="M320-200v-560l440 280-440 280Z"/></svg>';let l=p=>p.preventDefault();s.addEventListener("mousedown",l);let a=()=>{var p;i.getAttribute("data-show-children")==="true"?(i.setAttribute("data-show-children","false"),r.set(e.getBlock(t),!1),o.contains(c)&&o.removeChild(c)):(i.setAttribute("data-show-children","true"),r.set(e.getBlock(t),!0),e.isEditable&&((p=e.getBlock(t))==null?void 0:p.children.length)===0&&!o.contains(c)&&o.appendChild(c))};s.addEventListener("click",a),i.appendChild(s),i.appendChild(n);let c=document.createElement("button");c.className="bn-toggle-add-block-button",c.type="button",c.textContent=e.dictionary.toggle_blocks.add_block_button;let d=p=>p.preventDefault();c.addEventListener("mousedown",d);let u=()=>{e.transact(()=>{let p=e.updateBlock(t,{children:[{}]});e.setTextCursorPosition(p.children[0].id,"end"),e.focus()})};c.addEventListener("click",u),o.appendChild(i);let f=t.children.length,h=e.onChange(()=>{var m;let p=((m=e.getBlock(t))==null?void 0:m.children.length)??0;p>f?(i.getAttribute("data-show-children")==="false"&&(i.setAttribute("data-show-children","true"),r.set(e.getBlock(t),!0)),o.contains(c)&&o.removeChild(c)):p===0&&p<f&&(i.getAttribute("data-show-children")==="true"&&(i.setAttribute("data-show-children","false"),r.set(e.getBlock(t),!1)),o.contains(c)&&o.removeChild(c)),f=p});return r.get(t)?(i.setAttribute("data-show-children","true"),e.isEditable&&t.children.length===0&&o.appendChild(c)):i.setAttribute("data-show-children","false"),{dom:o,ignoreMutation:p=>p instanceof MutationRecord&&(p.type==="attributes"&&p.target===i&&p.attributeName==="data-show-children"||p.type==="childList"&&(p.addedNodes[0]===c||p.removedNodes[0]===c)),destroy:()=>{s.removeEventListener("mousedown",l),s.removeEventListener("click",a),c.removeEventListener("mousedown",d),c.removeEventListener("click",u),h==null||h()}}},MC=[1,2,3,4,5,6],pB=t=>({editor:e})=>{let n=e.getTextCursorPosition();return e.schema.blockSchema[n.block.type].content==="inline"?(e.updateBlock(n.block,{type:"heading",props:{level:t}}),!0):!1},mB=({defaultLevel:t=1,levels:e=MC,allowToggleHeadings:n=!0}={})=>({type:"heading",propSchema:{...xe,level:{default:t,values:e},...n?{isToggleable:{default:!1,optional:!0}}:{}},content:"inline"}),gB=un(mB,({allowToggleHeadings:t=!0}={})=>({meta:{isolating:!1},parse(e){if(t&&e.tagName==="DETAILS"){let r=e.querySelector(":scope > summary");if(!r)return;let o=r.querySelector("h1, h2, h3, h4, h5, h6");return o?{...kt(o),level:parseInt(o.tagName[1]),isToggleable:!0}:void 0}let n;switch(e.tagName){case"H1":n=1;break;case"H2":n=2;break;case"H3":n=3;break;case"H4":n=4;break;case"H5":n=5;break;case"H6":n=6;break;default:return}return{...kt(e),level:n}},...t?{parseContent:({el:e,schema:n})=>{if(e.tagName==="DETAILS")return SC(e,n,"heading")}}:{},runsBefore:["toggleListItem"],render(e,n){let r=document.createElement(`h${e.props.level}`);return t?{...EC(e,n,r),contentDOM:r}:{dom:r,contentDOM:r}},toExternalHTML(e){let n=document.createElement(`h${e.props.level}`);if(li(e.props,n),t&&e.props.isToggleable){let r=document.createElement("details");r.setAttribute("open","");let o=document.createElement("summary");return o.appendChild(n),r.appendChild(o),{dom:r,contentDOM:n,childrenDOM:r}}return{dom:n,contentDOM:n}}}),({levels:t=MC}={})=>[ve({key:"heading-shortcuts",keyboardShortcuts:Object.fromEntries(t.map(e=>[`Mod-Alt-${e}`,pB(e)])??[]),inputRules:t.map(e=>({find:RegExp(`^(#{${e}})\\s$`),replace({match:n}){return{type:"heading",props:{level:n[1].length}}}}))})]),TC=(t,e,n,r,o)=>{let{dom:i,destroy:s}=pm(t,e,n,o),l=i;l.style.position="relative",t.props.url&&t.props.showPreview&&(t.props.previewWidth?l.style.width=`${t.props.previewWidth}px`:l.style.width="fit-content");let a=document.createElement("div");a.className="bn-resize-handle",a.style.left="4px",a.style.display="none",r.appendChild(a);let c=document.createElement("div");c.className="bn-resize-handle",c.style.right="4px",c.style.display="none",r.appendChild(c);let d=document.createElement("div");d.style.position="absolute",d.style.height="100%",d.style.width="100%";let u,f=t.props.previewWidth,h=k=>{var E,S;if(!u){e.isEditable||(a.style.display="none",c.style.display="none");return}let x,C="touches"in k?k.touches[0].clientX:k.clientX;x=t.props.textAlignment==="center"?u.handleUsed==="left"?u.initialWidth+(u.initialClientX-C)*2:u.initialWidth+(C-u.initialClientX)*2:u.handleUsed==="left"?u.initialWidth+u.initialClientX-C:u.initialWidth+C-u.initialClientX,f=Math.min(Math.max(x,64),((S=(E=e.domElement)==null?void 0:E.firstElementChild)==null?void 0:S.clientWidth)||Number.MAX_VALUE),l.style.width=`${f}px`},p=k=>{(!k.target||!l.contains(k.target)||!e.isEditable)&&(a.style.display="none",c.style.display="none"),u&&(u=void 0,l.contains(d)&&l.removeChild(d),e.updateBlock(t,{props:{previewWidth:f}}))},m=()=>{e.isEditable&&(a.style.display="",c.style.display="")},g=k=>{k.relatedTarget===a||k.relatedTarget===c||u||e.isEditable&&(a.style.display="none",c.style.display="none")},y=k=>{k.preventDefault(),l.contains(d)||l.appendChild(d);let x="touches"in k?k.touches[0].clientX:k.clientX;u={handleUsed:"left",initialWidth:l.clientWidth,initialClientX:x}},w=k=>{k.preventDefault(),l.contains(d)||l.appendChild(d);let x="touches"in k?k.touches[0].clientX:k.clientX;u={handleUsed:"right",initialWidth:l.clientWidth,initialClientX:x}};return window.addEventListener("mousemove",h),window.addEventListener("touchmove",h),window.addEventListener("mouseup",p),window.addEventListener("touchend",p),l.addEventListener("mouseenter",m),l.addEventListener("mouseleave",g),a.addEventListener("mousedown",y),a.addEventListener("touchstart",y),c.addEventListener("mousedown",w),c.addEventListener("touchstart",w),{dom:l,destroy:()=>{s==null||s(),window.removeEventListener("mousemove",h),window.removeEventListener("touchmove",h),window.removeEventListener("mouseup",p),window.removeEventListener("touchend",p),l.removeEventListener("mouseenter",m),l.removeEventListener("mouseleave",g),a.removeEventListener("mousedown",y),a.removeEventListener("touchstart",y),c.removeEventListener("mousedown",w),c.removeEventListener("touchstart",w)}}},f0=t=>({url:t.src||void 0,previewWidth:t.width||void 0,name:t.alt||void 0}),bB=(t={})=>({type:"image",propSchema:{textAlignment:xe.textAlignment,backgroundColor:xe.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),yB=(t={})=>e=>{if(e.tagName==="IMG"){if(e.closest("figure"))return;let{backgroundColor:n}=kt(e);return{...f0(e),backgroundColor:n}}if(e.tagName==="FIGURE"){let n=Rd(e,"img");if(!n)return;let{targetElement:r,caption:o}=n,{backgroundColor:i}=kt(e);return{...f0(r),backgroundColor:i,caption:o}}},vB=(t={})=>(e,n)=>{let r=document.createElement("div");r.innerHTML=t.icon??'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>';let o=document.createElement("div");o.className="bn-visual-media-wrapper";let i=document.createElement("img");return i.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{i.src=s}):i.src=e.props.url,i.alt=e.props.name||"",i.contentEditable="false",i.draggable=!1,e.props.previewWidth&&(i.width=e.props.previewWidth),o.appendChild(i),TC(e,n,{dom:o},o,r.firstElementChild)},wB=(t={})=>(e,n)=>{if(!e.props.url)return{dom:document.createElement("img")};let r;return e.props.showPreview?(r=document.createElement("img"),r.src=e.props.url,r.alt=e.props.name||"",e.props.previewWidth&&(r.width=e.props.previewWidth)):(r=document.createElement("a"),r.href=e.props.url,r.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?mm(r,e.props.caption):Id(r,e.props.caption):{dom:r}},kB=un(bB,t=>({meta:{fileBlockAccept:["image/*"]},parse:yB(t),render:vB(t),toExternalHTML:wB(t),runsBefore:["file"]})),xB=(t,e,n)=>({state:r,dispatch:o})=>o?AC(r.tr,t,e,n):!0,AC=(t,e,n,r)=>{let o=Or(co(t.doc,e));if(!o.isBlockContainer)return!1;let i=st(t),s=[{type:o.bnBlock.node.type,attrs:r?{...o.bnBlock.node.attrs,id:void 0}:{}},{type:n?o.blockContent.node.type:i.nodes.paragraph,attrs:r?{...o.blockContent.node.attrs}:{}}];return t.split(e,2,s),!0},Od=(t,e)=>{let{blockInfo:n,selectionEmpty:r}=t.transact(s=>({blockInfo:Hl(s),selectionEmpty:s.selection.anchor===s.selection.head}));if(!n.isBlockContainer)return!1;let{bnBlock:o,blockContent:i}=n;return i.node.type.name!==e||!r?!1:i.node.childCount===0?(t.transact(s=>{Nd(s,o.beforePos,{type:"paragraph",props:{}})}),!0):i.node.childCount>0?t.transact(s=>(s.deleteSelection(),AC(s,s.selection.from,!0))):!1};function gm(t,e,n){var d,u,f;let r=wn.fromSchema(e),o=t,i=document.createElement("div");i.setAttribute("data-node-type","blockGroup");for(let h of Array.from(o.childNodes))i.appendChild(h.cloneNode(!0));let s=r.parse(i,{topNode:e.nodes.blockGroup.create()});((u=(d=s.firstChild)==null?void 0:d.firstChild)==null?void 0:u.type.name)==="checkListItem"&&(s=s.copy(s.content.cut(s.firstChild.firstChild.nodeSize+2)));let l=(f=s.firstChild)==null?void 0:f.firstChild;if(!(l!=null&&l.isTextblock))return I.from(s);let a=e.nodes[n].create({},l.content),c=s.content.cut(l.nodeSize+2);if(c.size>0){let h=s.copy(c);return a.content.addToEnd(h)}return a.content}var CB=()=>({type:"bulletListItem",propSchema:{...xe},content:"inline"}),SB=un(CB,{meta:{isolating:!1},parse(t){var n;if(t.tagName!=="LI")return;let e=t.parentElement;if(e===null||e.tagName==="UL"||e.tagName==="DIV"&&((n=e.parentElement)==null?void 0:n.tagName)==="UL"||!t.closest("ul, ol"))return kt(t)},parseContent:({el:t,schema:e})=>gm(t,e,"bulletListItem"),render(){let t=document.createElement("p");return{dom:t,contentDOM:t}},toExternalHTML(t){let e=document.createElement("li"),n=document.createElement("p");return li(t.props,e),e.appendChild(n),{dom:e,contentDOM:n}}},[ve({key:"bullet-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:t})=>Od(t,"bulletListItem"),"Mod-Shift-8":({editor:t})=>{let e=t.getTextCursorPosition();return t.schema.blockSchema[e.block.type].content==="inline"?(t.updateBlock(e.block,{type:"bulletListItem",props:{}}),!0):!1}},inputRules:[{find:/^\s?[-+*]\s$/,replace({editor:t}){if(Ze(t.prosemirrorState).blockNoteType!=="heading")return{type:"bulletListItem",props:{}}}}]})]),EB=()=>({type:"checkListItem",propSchema:{...xe,checked:{default:!1,type:"boolean"}},content:"inline"}),MB=un(EB,{meta:{isolating:!1},parse(t){var n;if(t.tagName==="input")return t.closest("[data-content-type]")||t.closest("li")?void 0:t.type==="checkbox"?{checked:t.checked}:void 0;if(t.tagName!=="LI")return;let e=t.parentElement;if(e!==null&&(e.tagName==="UL"||e.tagName==="DIV"&&((n=e.parentElement)==null?void 0:n.tagName)==="UL")){let r=t.querySelector("input[type=checkbox]")||null;return r===null?void 0:{...kt(t),checked:r.checked}}},parseContent:({el:t,schema:e})=>gm(t,e,"checkListItem"),render(t,e){let n=document.createDocumentFragment(),r=document.createElement("input");r.type="checkbox",r.checked=t.props.checked,t.props.checked&&r.setAttribute("checked",""),r.disabled=!e.isEditable,r.addEventListener("change",()=>{e.isEditable&&e.updateBlock(t,{props:{checked:!t.props.checked}})});let o=document.createElement("p"),i=document.createElement("div");return i.contentEditable="false",i.appendChild(r),n.appendChild(i),n.appendChild(o),{dom:n,contentDOM:o}},toExternalHTML(t){let e=document.createElement("li"),n=document.createElement("input");n.type="checkbox",n.checked=t.props.checked,t.props.checked&&n.setAttribute("checked","");let r=document.createElement("p");return li(t.props,e),e.appendChild(n),e.appendChild(r),{dom:e,contentDOM:r}},runsBefore:["bulletListItem"]},[ve({key:"check-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:t})=>Od(t,"checkListItem"),"Mod-Shift-9":({editor:t})=>{let e=t.getTextCursorPosition();return t.schema.blockSchema[e.block.type].content==="inline"?(t.updateBlock(e.block,{type:"checkListItem",props:{}}),!0):!1}},inputRules:[{find:/^\s?\[\s*\]\s$/,replace(){return{type:"checkListItem",props:{checked:!1}}}},{find:/^\s?\[[Xx]\]\s$/,replace(){return{type:"checkListItem",props:{checked:!0}}}}]})]);function TB(t,e,n,r){let o=!!t.firstChild.attrs.start,i=Or({posBeforeNode:e,node:t});if(!i.isBlockContainer)throw Error("impossible");let s=n.doc.resolve(i.bnBlock.beforePos).nodeBefore,l=s?r.get(s):void 0;if(l!==void 0){let y=l+1;return r.set(t,y),{index:y,isFirst:!1,hasStart:o}}let a=[{node:t,pos:e}],c=s,d=i.bnBlock.beforePos;for(;c&&r.get(c)===void 0;){let y=Or({posBeforeNode:d-c.nodeSize,node:c});if(y.blockNoteType!=="numberedListItem")break;a.push({node:c,pos:d-c.nodeSize});let w=n.doc.resolve(y.bnBlock.beforePos).nodeBefore;d=y.bnBlock.beforePos,c=w}let u,f,h=a[a.length-1],p=Or({posBeforeNode:h.pos,node:h.node});if(!p.isBlockContainer)throw Error("impossible");let m=n.doc.resolve(p.bnBlock.beforePos).nodeBefore,g=m?r.get(m):void 0;g===void 0?(u=(h.node.firstChild.attrs.start||1)-1,f=!0):(u=g,f=!1);for(let y=a.length-1;y>=0;y--){let w=a[y];f&&y<a.length-1&&(f=!1),u++,r.set(w.node,u)}return{index:u,isFirst:a.length===1?f||g===void 0:!1,hasStart:o}}function h0(t,e){let n=new Map,r=e.decorations.map(t.mapping,t.doc),o=t.changedRange()??{from:0,to:t.doc.nodeSize-2},i=[],s=new Set;t.doc.nodesBetween(o.from,t.doc.nodeSize-2,(a,c,d)=>{if(d&&s.has(d))return!1;if(a.type.name==="blockContainer"&&a.firstChild.type.name==="numberedListItem"){let{index:u,isFirst:f,hasStart:h}=TB(a,c,t,n),p=t.doc.nodeAt(c+1);if(r.find(c+1,c+1+p.nodeSize,m=>m.index===u&&m.isFirst===f&&m.hasStart===h).length===0)i.push(Me.node(c+1,c+1+p.nodeSize,{"data-index":u.toString()},{index:u,isFirst:f,hasStart:h}));else if(c>=o.to&&d)return s.add(d),!1}});let l=i.flatMap(a=>r.find(a.from,a.to));return{decorations:r.remove(l).add(t.doc,i)}}var AB=()=>new ae({key:new Ce("numbered-list-indexing-decorations"),state:{init(t,e){return h0(e.tr,{decorations:he.empty})},apply(t,e){return!t.docChanged&&e.decorations?e:h0(t,e)}},props:{decorations(t){var e;return((e=this.getState(t))==null?void 0:e.decorations)??he.empty}}}),NB=()=>({type:"numberedListItem",propSchema:{...xe,start:{default:void 0,type:"number"}},content:"inline"}),RB=un(NB,{meta:{isolating:!1},parse(t){var n;if(t.tagName!=="LI")return;let e=t.parentElement;if(e!==null&&(e.tagName==="OL"||e.tagName==="DIV"&&((n=e.parentElement)==null?void 0:n.tagName)==="OL")){let r=parseInt(e.getAttribute("start")||"1"),o=kt(t);return t.previousElementSibling||r===1?o:{...o,start:r}}},parseContent:({el:t,schema:e})=>gm(t,e,"numberedListItem"),render(){let t=document.createElement("p");return{dom:t,contentDOM:t}},toExternalHTML(t){let e=document.createElement("li"),n=document.createElement("p");return li(t.props,e),e.appendChild(n),{dom:e,contentDOM:n}}},[ve({key:"numbered-list-item-shortcuts",inputRules:[{find:/^\s?(\d+)\.\s$/,replace({match:t,editor:e}){if(Ze(e.prosemirrorState).blockNoteType==="heading")return;let n=parseInt(t[1]);return{type:"numberedListItem",props:{start:n===1?void 0:n}}}}],keyboardShortcuts:{Enter:({editor:t})=>Od(t,"numberedListItem"),"Mod-Shift-7":({editor:t})=>{let e=t.getTextCursorPosition();return t.schema.blockSchema[e.block.type].content==="inline"?(t.updateBlock(e.block,{type:"numberedListItem",props:{}}),!0):!1}},prosemirrorPlugins:[AB()]})]),IB=()=>({type:"toggleListItem",propSchema:{...xe},content:"inline"}),OB=un(IB,{meta:{isolating:!1},parse(t){var e;if(t.tagName==="DETAILS")return kt(t);if(t.tagName==="LI"){let n=t.parentElement;if(n&&(n.tagName==="UL"||n.tagName==="DIV"&&((e=n.parentElement)==null?void 0:e.tagName)==="UL")&&t.querySelector(":scope > details"))return kt(t)}},parseContent:({el:t,schema:e})=>{let n=t.tagName==="DETAILS"?t:t.querySelector(":scope > details");if(!n)throw Error("No details found in toggleListItem parseContent");return SC(n,e,"toggleListItem")},runsBefore:["bulletListItem"],render(t,e){let n=document.createElement("p");return{...EC(t,e,n),contentDOM:n}},toExternalHTML(t){let e=document.createElement("li"),n=document.createElement("details");n.setAttribute("open","");let r=document.createElement("summary"),o=document.createElement("p");return r.appendChild(o),n.appendChild(r),li(t.props,e),e.appendChild(n),{dom:e,contentDOM:o,childrenDOM:n}}},[ve({key:"toggle-list-item-shortcuts",keyboardShortcuts:{Enter:({editor:t})=>Od(t,"toggleListItem"),"Mod-Shift-6":({editor:t})=>{let e=t.getTextCursorPosition();return t.schema.blockSchema[e.block.type].content==="inline"?(t.updateBlock(e.block,{type:"toggleListItem",props:{}}),!0):!1}}})]),DB=()=>({type:"paragraph",propSchema:xe,content:"inline"}),NC=un(DB,{meta:{isolating:!1},parse:t=>{var e;if(t.tagName==="P"&&((e=t.textContent)!=null&&e.trim()))return kt(t)},render:()=>{let t=document.createElement("p");return{dom:t,contentDOM:t}},toExternalHTML:t=>{let e=document.createElement("p");return li(t.props,e),{dom:e,contentDOM:e}},runsBefore:["default","heading"]},[ve({key:"paragraph-shortcuts",keyboardShortcuts:{"Mod-Alt-0":({editor:t})=>{let e=t.getTextCursorPosition();return t.schema.blockSchema[e.block.type].content==="inline"?(t.updateBlock(e.block,{type:"paragraph",props:{}}),!0):!1}}})]),_B=()=>({type:"quote",propSchema:{backgroundColor:xe.backgroundColor,textColor:xe.textColor},content:"inline"}),PB=un(_B,{meta:{isolating:!1},parse(t){if(t.tagName==="BLOCKQUOTE"){let{backgroundColor:e,textColor:n}=kt(t);return{backgroundColor:e,textColor:n}}},render(){let t=document.createElement("blockquote");return{dom:t,contentDOM:t}},toExternalHTML(t){let e=document.createElement("blockquote");return li(t.props,e),{dom:e,contentDOM:e}}},[ve({key:"quote-block-shortcuts",keyboardShortcuts:{"Mod-Alt-q":({editor:t})=>{let e=t.getTextCursorPosition();return t.schema.blockSchema[e.block.type].content==="inline"?(t.updateBlock(e.block,{type:"quote",props:{}}),!0):!1}},inputRules:[{find:RegExp("^>\\s$"),replace(){return{type:"quote",props:{}}}},{find:RegExp("^\\p{Quotation_Mark}\\s$","u"),replace(){return{type:"quote",props:{}}}}]})]),$B=120,LB=31,BB=Ge.create({name:"BlockNoteTableExtension",addProseMirrorPlugins:()=>[P_({cellMinWidth:35,defaultCellMinWidth:120,View:null}),W_()],addKeyboardShortcuts(){return{Enter:()=>Jn(this.editor.state)?this.editor.commands.command(({state:t,dispatch:e})=>{let n=hd(t),r=n?Op(n,"vert",1):null;return r&&e&&e(t.tr.setSelection(W.between(r,Rk(r))).scrollIntoView()),!0}):!1,Backspace:()=>{let t=this.editor.state.selection,e=t.empty,n=t.$head.parentOffset===0,r=t.$head.node().type.name==="tableParagraph";return e&&n&&r},Tab:()=>this.editor.commands.command(({state:t,dispatch:e,view:n})=>py(1)(t,e,n)),"Shift-Tab":()=>this.editor.commands.command(({state:t,dispatch:e,view:n})=>py(-1)(t,e,n))}},extendNodeSchema(t){return{tableRole:Ne(K(t,"tableRole",{name:t.name,options:t.options,storage:t.storage}))}}}),RC={textColor:xe.textColor},jB=Kn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"tableContent+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getContent:(t,e)=>IC(t,e)}]},renderHTML({HTMLAttributes:t}){return["th",dn(this.options.HTMLAttributes,t),0]}}),VB=Kn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"tableContent+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{let e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getContent:(t,e)=>IC(t,e)}]},renderHTML({HTMLAttributes:t}){return["td",dn(this.options.HTMLAttributes,t),0]}}),HB=Kn.create({name:"table",content:"tableRow+",group:"blockContent",tableRole:"table",marks:"deletion insertion modification",isolating:!0,parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){var o,i,s;let n=kL(this.name,"table",{...((o=this.options.domAttributes)==null?void 0:o.blockContent)||{},...e},((i=this.options.domAttributes)==null?void 0:i.inlineContent)||{}),r=document.createElement("colgroup");for(let l of t.children[0].children)if(l.attrs.colwidth)for(let a of l.attrs.colwidth){let c=document.createElement("col");a&&(c.style=`width: ${a}px`),r.appendChild(c)}else r.appendChild(document.createElement("col"));return(s=n.dom.firstChild)==null||s.appendChild(r),n},addNodeView(){return({node:t,HTMLAttributes:e})=>{var r;class n extends Lk{constructor(i,s,l){super(i,s),this.node=i,this.cellMinWidth=s,this.blockContentHTMLAttributes=l;let a=document.createElement("div");a.className=De("bn-block-content",l.class),a.setAttribute("data-content-type","table");for(let[f,h]of Object.entries(l))f!=="class"&&a.setAttribute(f,h);let c=this.dom,d=document.createElement("div");d.className="tableWrapper-inner",d.appendChild(c.firstChild),c.appendChild(d),a.appendChild(c);let u=document.createElement("div");u.className="table-widgets-container",u.style.position="relative",c.appendChild(u),this.dom=a}ignoreMutation(i){return!i.target.closest(".tableWrapper-inner")||super.ignoreMutation(i)}update(i){if(!super.update(i))return!1;for(let[s,l]of Object.entries(RC)){let a=wl(s),c=i.attrs[s];c===l.default?this.dom.removeAttribute(a):this.dom.setAttribute(a,String(c))}return!0}}return new n(t,120,{...((r=this.options.domAttributes)==null?void 0:r.blockContent)||{},...e})}}}),FB=Kn.create({name:"tableParagraph",group:"tableContent",content:"inline*",parseHTML(){return[{tag:"p",getAttrs:t=>{if(typeof t=="string"||!t.textContent||!t.closest("[data-content-type]"))return!1;let e=t.parentElement;return e===null?!1:e.tagName==="TD"||e.tagName==="TH"?{}:!1},node:"tableParagraph"}]},renderHTML({HTMLAttributes:t}){return["p",t,0]}}),zB=Kn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)+",tableRole:"row",marks:"deletion insertion modification",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",dn(this.options.HTMLAttributes,t),0]}});function IC(t,e){let n=wn.fromSchema(e).parse(t,{topNode:e.nodes.blockGroup.create()}),r=[];return n.content.descendants(o=>{if(o.isInline)return r.push(o),!1}),I.fromArray(r)}var UB=()=>SL({node:HB,type:"table",content:"table"},RC,[ve({key:"table-extensions",tiptapExtensions:[BB,FB,jB,VB,zB]}),ve({key:"table-keyboard-delete",keyboardShortcuts:{Backspace:({editor:t})=>{if(!(t.prosemirrorState.selection instanceof Ae))return!1;let e=t.getTextCursorPosition().block,n=e.content,r=0;for(let i of n.rows)for(let s of i.cells){if("type"in s&&s.content.length>0||!("type"in s)&&s.length>0)return!1;r++}let o=0;return t.prosemirrorState.selection.forEachCell(()=>{o++}),o<r?!1:(t.transact(()=>{(t.getPrevBlock(e)||t.getNextBlock(e))&&t.setTextCursorPosition(e),t.removeBlocks([e])}),!0)}}})]),p0=t=>({url:t.src||void 0,previewWidth:t.width||void 0,name:t.getAttribute("data-name")||void 0}),WB=t=>({type:"video",propSchema:{textAlignment:xe.textAlignment,backgroundColor:xe.backgroundColor,name:{default:""},url:{default:""},caption:{default:""},showPreview:{default:!0},previewWidth:{default:void 0,type:"number"}},content:"none"}),qB=t=>e=>{if(e.tagName==="VIDEO"){if(e.closest("figure"))return;let{backgroundColor:n}=kt(e);return{...p0(e),backgroundColor:n}}if(e.tagName==="FIGURE"){let n=Rd(e,"video");if(!n)return;let{targetElement:r,caption:o}=n,{backgroundColor:i}=kt(e);return{...p0(r),backgroundColor:i,caption:o}}},GB=un(WB,t=>({meta:{fileBlockAccept:["video/*"]},parse:qB(),render(e,n){let r=document.createElement("div");r.innerHTML=t.icon??'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>';let o=document.createElement("div");o.className="bn-visual-media-wrapper";let i=document.createElement("video");return i.className="bn-visual-media",n.resolveFileUrl?n.resolveFileUrl(e.props.url).then(s=>{i.src=s}):i.src=e.props.url,i.controls=!0,i.contentEditable="false",i.draggable=!1,e.props.previewWidth&&(i.width=e.props.previewWidth),o.appendChild(i),TC(e,n,{dom:o},o,r.firstElementChild)},toExternalHTML(e){if(!e.props.url)return{dom:document.createElement("video")};let n;return e.props.showPreview?(n=document.createElement("video"),n.src=e.props.url,e.props.previewWidth&&(n.width=e.props.previewWidth)):(n=document.createElement("a"),n.href=e.props.url,n.textContent=e.props.name||e.props.url),e.props.caption?e.props.showPreview?mm(n,e.props.caption):Id(n,e.props.caption):{dom:n}},runsBefore:["file"]}));function Ue(t,e,n){if(!(e in t.schema.blockSpecs))return!1;if(!n)return!0;for(let[r,o]of Object.entries(n)){if(!(r in t.schema.blockSpecs[e].config.propSchema))return!1;if(typeof o=="string"){if(t.schema.blockSpecs[e].config.propSchema[r].default!==void 0&&typeof t.schema.blockSpecs[e].config.propSchema[r].default!==o||t.schema.blockSpecs[e].config.propSchema[r].type!==void 0&&t.schema.blockSpecs[e].config.propSchema[r].type!==o)return!1}else{if(t.schema.blockSpecs[e].config.propSchema[r].default!==o.default||t.schema.blockSpecs[e].config.propSchema[r].default===void 0&&o.default===void 0&&t.schema.blockSpecs[e].config.propSchema[r].type!==o.type||typeof t.schema.blockSpecs[e].config.propSchema[r].values!=typeof o.values)return!1;if(typeof t.schema.blockSpecs[e].config.propSchema[r].values=="object"&&typeof o.values=="object"){for(let i of o.values)if(!t.schema.blockSpecs[e].config.propSchema[r].values.includes(i))return!1}}}return!0}function Wt(t,e,n,r){return Ue(e,n,r)&&t.type===n}function Ch(t){return t instanceof Ae}var vn=ve(({editor:t})=>{let e=go(!1),n=()=>t.transact(r=>{if(r.selection.empty||r.selection instanceof W&&r.doc.textBetween(r.selection.from,r.selection.to).length===0)return!1;let o=!1;return r.selection.content().content.descendants(i=>(i.type.spec.code&&(o=!0),!o)),!o});return{key:"formattingToolbar",store:e,mount({dom:r,signal:o}){let i=!1,s=!1,l=t.onChange(()=>{i||s||e.setState(n())}),a=t.onSelectionChange(()=>{i||s||e.setState(n())});r.addEventListener("pointerdown",()=>{i=!0,e.setState(!1)},{signal:o}),t.prosemirrorView.root.addEventListener("pointerup",()=>{i=!1,t.isFocused()&&e.setState(n())},{signal:o,capture:!0}),r.addEventListener("pointercancel",()=>{i=!0},{signal:o,capture:!0}),t.prosemirrorView.root.addEventListener("dragstart",()=>{s=!0,e.setState(!1)},{signal:o}),t.prosemirrorView.root.addEventListener("dragend",()=>{s=!1},{signal:o}),o.addEventListener("abort",()=>{l(),a()})}}}),ka=new Map;function ZB(t){if(ka.has(t))return ka.get(t);let e=new Vi;return t._tiptapEditor.on("transaction",({transaction:n})=>{e.appendMapping(n.mapping)}),t._tiptapEditor.on("destroy",()=>{ka.delete(t)}),ka.set(t,e),e}function KB(t,e,n="left"){let r=Le.getState(t.prosemirrorState);if(!r){let i=ZB(t),s=i.maps.length;return()=>i.slice(s).map(e,n==="left"?-1:1)}let o=bl(e+(n==="right"?1:-1),r.binding.type,r.binding.mapping);return()=>{let i=Le.getState(t.prosemirrorState),s=$o(i.doc,i.binding.type,o,i.binding.mapping);if(s===null)throw Error("Position not found, cannot track positions");return s+(n==="right"?-1:1)}}var JB=dd(t=>t.type.name==="blockContainer"),YB=class{constructor(e,n,r){B(this,"state");B(this,"emitUpdate");B(this,"rootEl");B(this,"pluginState");B(this,"handleScroll",()=>{var e,n;if((e=this.state)!=null&&e.show){let r=(n=this.rootEl)==null?void 0:n.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);if(!r)return;this.state.referencePos=r.getBoundingClientRect().toJSON(),this.emitUpdate(this.pluginState.triggerCharacter)}});B(this,"closeMenu",()=>{this.editor.transact(e=>e.setMeta(Ro,null))});B(this,"clearQuery",()=>{this.pluginState!==void 0&&this.editor._tiptapEditor.chain().focus().deleteRange({from:this.pluginState.queryStartPos()-(this.pluginState.deleteTriggerCharacter?this.pluginState.triggerCharacter.length:0),to:this.editor.transact(e=>e.selection.from)}).run()});var o;this.editor=e,this.pluginState=void 0,this.emitUpdate=i=>{var s;if(!this.state)throw Error("Attempting to update uninitialized suggestions menu");n(i,{...this.state,ignoreQueryLength:(s=this.pluginState)==null?void 0:s.ignoreQueryLength})},this.rootEl=r.root,(o=this.rootEl)==null||o.addEventListener("scroll",this.handleScroll,!0)}update(e,n){var a;let r=Ro.getState(n),o=Ro.getState(e.state),i=r===void 0&&o!==void 0,s=r!==void 0&&o===void 0;if(!i&&!(r!==void 0&&o!==void 0)&&!s)return;if(this.pluginState=s?r:o,s||!this.editor.isEditable){this.state&&(this.state.show=!1),this.emitUpdate(this.pluginState.triggerCharacter);return}let l=(a=this.rootEl)==null?void 0:a.querySelector(`[data-decoration-id="${this.pluginState.decorationId}"]`);this.editor.isEditable&&l&&(this.state={show:!0,referencePos:l.getBoundingClientRect().toJSON(),query:this.pluginState.query},this.emitUpdate(this.pluginState.triggerCharacter))}destroy(){var e;(e=this.rootEl)==null||e.removeEventListener("scroll",this.handleScroll,!0)}},Ro=new Ce("SuggestionMenuPlugin"),En=ve(({editor:t})=>{let e=new Map,n,r=go(void 0);return{key:"suggestionMenu",store:r,addSuggestionMenu:o=>{e.set(o.triggerCharacter,o)},removeSuggestionMenu:o=>{e.delete(o)},closeMenu:()=>{n==null||n.closeMenu()},clearQuery:()=>{n==null||n.clearQuery()},shown:()=>{var o;return((o=n==null?void 0:n.state)==null?void 0:o.show)||!1},openSuggestionMenu:(o,i)=>{t.headless||(t.focus(),t.transact(s=>{i!=null&&i.deleteTriggerCharacter&&s.insertText(o),s.scrollIntoView().setMeta(Ro,{triggerCharacter:o,deleteTriggerCharacter:(i==null?void 0:i.deleteTriggerCharacter)||!1,ignoreQueryLength:(i==null?void 0:i.ignoreQueryLength)||!1})}))},prosemirrorPlugins:[new ae({key:Ro,view:o=>(n=new YB(t,(i,s)=>{r.setState({...s,triggerCharacter:i})},o),n),state:{init(){},apply:(o,i,s,l)=>{if(o.selection.$from.parent.type.spec.code)return i;let a=o.getMeta(Ro);if(typeof a=="object"&&a){i&&(n==null||n.closeMenu());let d=KB(t,l.selection.from-a.triggerCharacter.length);return{triggerCharacter:a.triggerCharacter,deleteTriggerCharacter:a.deleteTriggerCharacter!==!1,queryStartPos:()=>d()+a.triggerCharacter.length,query:"",decorationId:`id_${Math.floor(Math.random()*4294967295)}`,ignoreQueryLength:a==null?void 0:a.ignoreQueryLength}}if(i===void 0)return i;if(l.selection.from!==l.selection.to||a===null||o.getMeta("focus")||o.getMeta("blur")||o.getMeta("pointer")||i.triggerCharacter!==void 0&&l.selection.from<i.queryStartPos()||!l.selection.$from.sameParent(l.doc.resolve(i.queryStartPos())))return;let c={...i};return c.query=l.doc.textBetween(i.queryStartPos(),l.selection.from),c}},props:{handleTextInput(o,i,s,l){if(i===s){let a=o.state.doc;for(let[c,d]of e){let u=c.length>1?a.textBetween(i-c.length,i)+l:l;if(c===u){if(d.shouldOpen&&!d.shouldOpen(o.state.tr))continue;return o.dispatch(o.state.tr.insertText(l)),o.dispatch(o.state.tr.setMeta(Ro,{triggerCharacter:u}).scrollIntoView()),!0}}}return!1},decorations(o){let i=this.getState(o);if(i===void 0)return null;if(!i.deleteTriggerCharacter){let s=JB(o.selection);if(s)return he.create(o.doc,[Me.node(s.pos,s.pos+s.node.nodeSize,{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":i.decorationId})])}return he.create(o.doc,[Me.inline(i.queryStartPos()-i.triggerCharacter.length,i.queryStartPos(),{nodeName:"span",class:"bn-suggestion-decorator","data-decoration-id":i.decorationId})])}}})]}});function XB(t){let e=t.getTextCursorPosition().block,n=t.schema.blockSchema[e.type].content;for(;n==="none";){if(e=t.getTextCursorPosition().nextBlock,e===void 0)return;n=t.schema.blockSchema[e.type].content,t.setTextCursorPosition(e,"end")}}function xt(t,e){let n=t.getTextCursorPosition().block;if(n.content===void 0)throw Error("Slash Menu open in a block that doesn't contain content.");let r;return Array.isArray(n.content)&&(n.content.length===1&&Qo(n.content[0])&&n.content[0].type==="text"&&n.content[0].text==="/"||n.content.length===0)?(r=t.updateBlock(n,e),t.setTextCursorPosition(r)):(r=t.insertBlocks([e],n,"after")[0],t.setTextCursorPosition(t.getTextCursorPosition().nextBlock)),XB(t),r}function QB(t){let e=[];return Ue(t,"heading",{level:"number"})&&(t.schema.blockSchema.heading.propSchema.level.values||[]).filter(n=>n<=3).forEach(n=>{e.push({onItemClick:()=>{xt(t,{type:"heading",props:{level:n}})},badge:pn(`Mod-Alt-${n}`),key:n===1?"heading":`heading_${n}`,...t.dictionary.slash_menu[n===1?"heading":`heading_${n}`]})}),Ue(t,"quote")&&e.push({onItemClick:()=>{xt(t,{type:"quote"})},key:"quote",...t.dictionary.slash_menu.quote}),Ue(t,"toggleListItem")&&e.push({onItemClick:()=>{xt(t,{type:"toggleListItem"})},badge:pn("Mod-Shift-6"),key:"toggle_list",...t.dictionary.slash_menu.toggle_list}),Ue(t,"numberedListItem")&&e.push({onItemClick:()=>{xt(t,{type:"numberedListItem"})},badge:pn("Mod-Shift-7"),key:"numbered_list",...t.dictionary.slash_menu.numbered_list}),Ue(t,"bulletListItem")&&e.push({onItemClick:()=>{xt(t,{type:"bulletListItem"})},badge:pn("Mod-Shift-8"),key:"bullet_list",...t.dictionary.slash_menu.bullet_list}),Ue(t,"checkListItem")&&e.push({onItemClick:()=>{xt(t,{type:"checkListItem"})},badge:pn("Mod-Shift-9"),key:"check_list",...t.dictionary.slash_menu.check_list}),Ue(t,"paragraph")&&e.push({onItemClick:()=>{xt(t,{type:"paragraph"})},badge:pn("Mod-Alt-0"),key:"paragraph",...t.dictionary.slash_menu.paragraph}),Ue(t,"codeBlock")&&e.push({onItemClick:()=>{xt(t,{type:"codeBlock"})},badge:pn("Mod-Alt-c"),key:"code_block",...t.dictionary.slash_menu.code_block}),Ue(t,"divider")&&e.push({onItemClick:()=>{xt(t,{type:"divider"})},key:"divider",...t.dictionary.slash_menu.divider}),Ue(t,"table")&&e.push({onItemClick:()=>{xt(t,{type:"table",content:{type:"tableContent",rows:[{cells:["","",""]},{cells:["","",""]}]}})},badge:void 0,key:"table",...t.dictionary.slash_menu.table}),Ue(t,"image",{url:"string"})&&e.push({onItemClick:()=>{var r,o;let n=xt(t,{type:"image"});(r=t.getExtension(Bn))==null||r.showMenu(n.id),(o=t.getExtension(vn))==null||o.store.setState(!1)},key:"image",...t.dictionary.slash_menu.image}),Ue(t,"video",{url:"string"})&&e.push({onItemClick:()=>{var r,o;let n=xt(t,{type:"video"});(r=t.getExtension(Bn))==null||r.showMenu(n.id),(o=t.getExtension(vn))==null||o.store.setState(!1)},key:"video",...t.dictionary.slash_menu.video}),Ue(t,"audio",{url:"string"})&&e.push({onItemClick:()=>{var r,o;let n=xt(t,{type:"audio"});(r=t.getExtension(Bn))==null||r.showMenu(n.id),(o=t.getExtension(vn))==null||o.store.setState(!1)},key:"audio",...t.dictionary.slash_menu.audio}),Ue(t,"file",{url:"string"})&&e.push({onItemClick:()=>{var r,o;let n=xt(t,{type:"file"});(r=t.getExtension(Bn))==null||r.showMenu(n.id),(o=t.getExtension(vn))==null||o.store.setState(!1)},key:"file",...t.dictionary.slash_menu.file}),Ue(t,"heading",{level:"number",isToggleable:"boolean"})&&(t.schema.blockSchema.heading.propSchema.level.values||[]).filter(n=>n<=3).forEach(n=>{e.push({onItemClick:()=>{xt(t,{type:"heading",props:{level:n,isToggleable:!0}})},key:n===1?"toggle_heading":`toggle_heading_${n}`,...t.dictionary.slash_menu[n===1?"toggle_heading":`toggle_heading_${n}`]})}),Ue(t,"heading",{level:"number"})&&(t.schema.blockSchema.heading.propSchema.level.values||[]).filter(n=>n>3).forEach(n=>{e.push({onItemClick:()=>{xt(t,{type:"heading",props:{level:n}})},badge:pn(`Mod-Alt-${n}`),key:`heading_${n}`,...t.dictionary.slash_menu[`heading_${n}`]})}),e.push({onItemClick:()=>{var n;(n=t.getExtension(En))==null||n.openSuggestionMenu(":",{deleteTriggerCharacter:!0,ignoreQueryLength:!0})},key:"emoji",...t.dictionary.slash_menu.emoji}),e}function OC(t,e){return t.filter(({title:n,aliases:r})=>n.toLowerCase().includes(e.toLowerCase())||r&&r.filter(o=>o.toLowerCase().includes(e.toLowerCase())).length!==0)}var DC={audio:oB(),bulletListItem:SB(),checkListItem:MB(),codeBlock:lB(),divider:cB(),file:fB(),heading:gB(),image:kB(),numberedListItem:RB(),paragraph:NC(),quote:PB(),table:UB(),toggleListItem:OB(),video:GB()},e7=bC({type:"textColor",propSchema:"string"},{render:()=>{let t=document.createElement("span");return{dom:t,contentDOM:t}},toExternalHTML:t=>{let e=document.createElement("span");return t!==xe.textColor.default&&(e.style.color=t in eo?eo[t].text:t),{dom:e,contentDOM:e}},parse:t=>{if(t.tagName==="SPAN"&&t.style.color)return t.style.color}}),t7=bC({type:"backgroundColor",propSchema:"string"},{render:()=>{let t=document.createElement("span");return{dom:t,contentDOM:t}},toExternalHTML:t=>{let e=document.createElement("span");return t!==xe.backgroundColor.default&&(e.style.backgroundColor=t in eo?eo[t].background:t),{dom:e,contentDOM:e}},parse:t=>{if(t.tagName==="SPAN"&&t.style.backgroundColor)return t.style.backgroundColor}}),bm={bold:ks(tL,"boolean"),italic:ks(uL,"boolean"),underline:ks(bL,"boolean"),strike:ks(mL,"boolean"),code:ks(iL.extend({addInputRules(){return[Wo({find:/(^|[^`])`([^`]+)`(?!`)$/,type:this.type}),new hk({find:/(^|[^`])`([^`]+)`(?!`) $/,handler:({state:t,range:e,match:n})=>{let{tr:r,schema:o}=t,i=n[1],s=n[2];r.replaceWith(e.from+i.length,e.to,[o.text(s,[this.type.create()]),o.text(" ")])}})]}}),"boolean"),textColor:e7,backgroundColor:t7};gC(bm);var _C={text:{config:"text",implementation:{}},link:{config:"link",implementation:{}}},n7=pC(_C),ym=class PC extends LL{static create(e){return new PC({blockSpecs:(e==null?void 0:e.blockSpecs)??DC,inlineContentSpecs:(e==null?void 0:e.inlineContentSpecs)??_C,styleSpecs:(e==null?void 0:e.styleSpecs)??bm})}},Ju,m0;function r7(){return m0||(m0=1,Ju=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),Ju}var o7=r7();const i7=T1(o7);var _c=200,dt=function(){};dt.prototype.append=function(e){return e.length?(e=dt.from(e),!this.length&&e||e.length<_c&&this.leafAppend(e)||this.length<_c&&e.leafPrepend(this)||this.appendInner(e)):this};dt.prototype.prepend=function(e){return e.length?dt.from(e).append(this):this};dt.prototype.appendInner=function(e){return new s7(this,e)};dt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?dt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};dt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};dt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};dt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},n,r),o};dt.from=function(e){return e instanceof dt?e:e&&e.length?new $C(e):dt.empty};var $C=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=_c)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=_c)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(dt);dt.empty=new $C([]);var s7=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(dt);const l7=500;class Dn{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;n&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new er(u.map));let h=u.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new er(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new Dn(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,n,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new er(e.mapping.maps[d],u,n),h;(h=a&&a.merge(f))&&(f=h,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),n&&(s++,n=void 0),o||(a=f)}let c=s-r.depth;return c>c7&&(l=a7(l,c),s-=c),new Dn(l.append(i),s)}remapping(e,n){let r=new Vi;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,n),r}addMaps(e){return this.eventCount==0?this:new Dn(this.items.append(e.map(n=>new er(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=n;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new er(p,m,g))}else r.push(new er(p))},o);let c=[];for(let f=n;f<s;f++)c.push(new er(i.maps[f]));let d=this.items.slice(0,o).append(c).append(r),u=new Dn(d,l);return u.emptyItemCount()>l7&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=s.selection&&s.selection.map(n.slice(r));d&&i++;let u=new er(c.invert(),a,d),f,h=o.length-1;(f=o.length&&o[h].merge(u))?o[h]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new Dn(dt.from(o.reverse()),i)}}Dn.empty=new Dn(dt.empty,0);function a7(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}class er{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new er(n.getMap().invert(),n,this.selection)}}}class Ur{constructor(e,n,r,o,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}}const c7=20;function d7(t,e,n,r){let o=n.getMeta(Lo),i;if(o)return o.historyState;n.getMeta(LC)&&(t=new Ur(t.done,t.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(s&&s.getMeta(Lo))return s.getMeta(Lo).redo?new Ur(t.done.addTransform(n,void 0,r,qa(e)),t.undone,g0(n.mapping.maps),t.prevTime,t.prevComposition):new Ur(t.done,t.undone.addTransform(n,void 0,r,qa(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!s&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!u7(n,t.prevRanges)),c=s?Yu(t.prevRanges,n.mapping):g0(n.mapping.maps);return new Ur(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,qa(e)),Dn.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ur(t.done.rebased(n,i),t.undone.rebased(n,i),Yu(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ur(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Yu(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function u7(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(n=!0)}),n}function g0(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,i,s)=>e.push(i,s));return e}function Yu(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),i=e.map(t[r+1],-1);o<=i&&n.push(o,i)}return n}function f7(t,e,n){let r=qa(e),o=Lo.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),o,r),a=new Ur(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Lo,{redo:n,historyState:a})}let Xu=!1,b0=null;function qa(t){let e=t.plugins;if(b0!=e){Xu=!1,b0=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Xu=!0;break}}return Xu}function h7(t){return t.setMeta(LC,!0)}const Lo=new Ce("history"),LC=new Ce("closeHistory");function p7(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ae({key:Lo,state:{init(){return new Ur(Dn.empty,Dn.empty,null,0,-1)},apply(e,n,r){return d7(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?jC:r=="historyRedo"?VC:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function BC(t,e){return(n,r)=>{let o=Lo.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let i=f7(o,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const jC=BC(!1,!0),VC=BC(!0,!0);function HC(t){let e=Array.from(t.classList).filter(n=>!n.startsWith("bn-"))||[];e.length>0?t.className=e.join(" "):t.removeAttribute("class")}function FC(t,e,n,r){var s;let o;if(!e)throw Error("blockContent is required");if(typeof e=="string")o=Gn([e],t.pmSchema,r==null?void 0:r.blockType);else if(Array.isArray(e))o=Gn(e,t.pmSchema,r==null?void 0:r.blockType);else if(e.type==="tableContent")o=Ad(e,t.pmSchema);else throw new dr(e.type);let i=((r==null?void 0:r.document)??document).createDocumentFragment();for(let l of o)if(l.type.name!=="text"&&t.schema.inlineContentSchema[l.type.name]){let a=t.schema.inlineContentSpecs[l.type.name].implementation;if(a){let c=um(l,t.schema.inlineContentSchema,t.schema.styleSchema),d=a.toExternalHTML?a.toExternalHTML(c,t):a.render.call({renderType:"dom",props:void 0},c,()=>{},t);if(d){if(i.appendChild(d.dom),d.contentDOM){let u=n.serializeFragment(l.content,r);d.contentDOM.dataset.editable="",d.contentDOM.appendChild(u)}continue}}}else if(l.type.name==="text"){let a=document.createTextNode(l.textContent);for(let c of l.marks.toReversed())if(c.type.name in t.schema.styleSpecs){let d=(t.schema.styleSpecs[c.type.name].implementation.toExternalHTML??t.schema.styleSpecs[c.type.name].implementation.render)(c.attrs.stringValue,t);d.contentDOM.appendChild(a),a=d.dom}else{let d=c.type.spec.toDOM(c,!0),u=cn.renderSpec(document,d);u.contentDOM.appendChild(a),a=u.dom}i.appendChild(a)}else{let a=n.serializeFragment(I.from([l]),r);i.appendChild(a)}return i.childNodes.length===1&&((s=i.firstChild)==null?void 0:s.nodeType)===1&&HC(i.firstChild),i}function m7(t,e,n,r,o,i,s,l){var y,w,k,x,C,E,S,M,N;let a=(l==null?void 0:l.document)??document,c=e.pmSchema.nodes.blockContainer,d=n.props||{};for(let[A,R]of Object.entries(e.schema.blockSchema[n.type].propSchema))!(A in d)&&R.default!==void 0&&(d[A]=R.default);let u=(w=(y=c.spec)==null?void 0:y.toDOM)==null?void 0:w.call(y,c.create({id:n.id,...d})),f=Array.from(u.dom.attributes),h=e.blockImplementations[n.type].implementation,p=((k=h.toExternalHTML)==null?void 0:k.call({},{...n,props:d},e,{nestingLevel:s}))||h.render.call({},{...n,props:d},e),m=a.createDocumentFragment();if(p.dom.classList.contains("bn-block-content")){let A=[...f,...Array.from(p.dom.attributes)].filter(R=>R.name.startsWith("data")&&R.name!=="data-content-type"&&R.name!=="data-file-block"&&R.name!=="data-node-view-wrapper"&&R.name!=="data-node-type"&&R.name!=="data-id"&&R.name!=="data-editable");for(let R of A)p.dom.firstChild.setAttribute(R.name,R.value);HC(p.dom.firstChild),s>0&&p.dom.firstChild.setAttribute("data-nesting-level",s.toString()),m.append(...Array.from(p.dom.childNodes))}else m.append(p.dom),s>0&&p.dom.setAttribute("data-nesting-level",s.toString());if(p.contentDOM&&n.content){let A=FC(e,n.content,r,{...l,blockType:n.type});p.contentDOM.appendChild(A)}let g;if(o.has(n.type)?g="OL":i.has(n.type)&&(g="UL"),g){if(((x=t.lastChild)==null?void 0:x.nodeName)!==g){let A=a.createElement(g);g==="OL"&&"start"in d&&d.start&&(d==null?void 0:d.start)!==1&&A.setAttribute("start",d.start+""),t.append(A)}t.lastChild.appendChild(m)}else t.append(m);if(n.children&&n.children.length>0){let A=a.createDocumentFragment();if(zC(A,e,n.children,r,o,i,s+1,l),((C=t.lastChild)==null?void 0:C.nodeName)==="UL"||((E=t.lastChild)==null?void 0:E.nodeName)==="OL")for(;((S=A.firstChild)==null?void 0:S.nodeName)==="UL"||((M=A.firstChild)==null?void 0:M.nodeName)==="OL";)t.lastChild.lastChild.appendChild(A.firstChild);"childrenDOM"in p&&p.childrenDOM?p.childrenDOM.append(A):e.pmSchema.nodes[n.type].isInGroup("blockContent")?t.append(A):(N=p.contentDOM)==null||N.append(A)}}var zC=(t,e,n,r,o,i,s=0,l)=>{for(let a of n)m7(t,e,a,r,o,i,s,l)},g7=(t,e,n,r,o,i)=>{let s=((i==null?void 0:i.document)??document).createDocumentFragment();return zC(s,t,e,n,r,o,0,i),s},Dd=(t,e)=>{let n=cn.fromSchema(t);return{exportBlocks:(r,o)=>{let i=g7(e,r,n,new Set(["numberedListItem"]),new Set(["bulletListItem","checkListItem","toggleListItem"]),o),s=document.createElement("div");return s.append(i),s.innerHTML},exportInlineContent:(r,o)=>{let i=FC(e,r,n,o),s=document.createElement("div");return s.append(i.cloneNode(!0)),s.innerHTML}}};function b7(t,e){if(e===0)return;let n=t.resolve(e);for(let r=n.depth;r>0;r--){let o=n.node(r);if(hm(o))return o.attrs.id}}function y7(t){return t.getMeta("paste")?{type:"paste"}:t.getMeta("uiEvent")==="drop"?{type:"drop"}:t.getMeta("history$")?{type:t.getMeta("history$").redo?"redo":"undo"}:t.getMeta("y-sync$")?t.getMeta("y-sync$").isUndoRedoOperation?{type:"undo-redo"}:{type:"yjs-remote"}:{type:"local"}}function y0(t){let e={},n={},r=st(t);return t.descendants((o,i)=>{if(!hm(o))return!0;let s=b7(t,i),l=s??"__root__";n[l]||(n[l]=[]);let a=qe(o,r);return e[o.attrs.id]={block:a,parentId:s},n[l].push(o.attrs.id),!0}),{byId:e,childrenByParent:n}}function v7(t,e){let n=new Set;if(!t||!e)return n;let r=new Set(t),o=e.filter(m=>r.has(m)),i=t.filter(m=>o.includes(m));if(i.length<=1||o.length<=1)return n;let s={};for(let m=0;m<i.length;m++)s[i[m]]=m;let l=o.map(m=>s[m]),a=l.length,c=[],d=[],u=Array(a).fill(-1),f=(m,g)=>{let y=0,w=m.length;for(;y<w;){let k=y+w>>>1;m[k]<g?y=k+1:w=k}return y};for(let m=0;m<a;m++){let g=l[m],y=f(c,g);y>0&&(u[m]=d[y-1]),y===c.length?(c.push(g),d.push(m)):(c[y]=g,d[y]=m)}let h=new Set,p=d[d.length-1]??-1;for(;p!==-1;)h.add(p),p=u[p];for(let m=0;m<o.length;m++)h.has(m)||n.add(o[m]);return n}function UC(t,e=[]){let n=y7(t),r=cd(t.before,[t,...e]),o=y0(r.before),i=y0(r.doc),s=[],l=new Set;Object.keys(i.byId).filter(f=>!(f in o.byId)).forEach(f=>{s.push({type:"insert",block:i.byId[f].block,source:n,prevBlock:void 0}),l.add(f)}),Object.keys(o.byId).filter(f=>!(f in i.byId)).forEach(f=>{s.push({type:"delete",block:o.byId[f].block,source:n,prevBlock:void 0}),l.add(f)}),Object.keys(i.byId).filter(f=>f in o.byId).forEach(f=>{var m,g;let h=o.byId[f],p=i.byId[f];h.parentId===p.parentId?i7({...h.block,children:void 0},{...p.block,children:void 0})||(s.push({type:"update",block:p.block,prevBlock:h.block,source:n}),l.add(f)):(s.push({type:"move",block:p.block,prevBlock:h.block,source:n,prevParent:h.parentId?(m=o.byId[h.parentId])==null?void 0:m.block:void 0,currentParent:p.parentId?(g=i.byId[p.parentId])==null?void 0:g.block:void 0}),l.add(f))});let a=o.childrenByParent,c=i.childrenByParent,d=new Set([...Object.keys(a),...Object.keys(c)]),u=new Set;return d.forEach(f=>{let h=v7(a[f],c[f]);h.size!==0&&h.forEach(p=>{var y,w;let m=o.byId[p],g=i.byId[p];!m||!g||m.parentId===g.parentId&&(l.has(p)||(m.parentId??"__root__")===f&&(u.has(p)||(u.add(p),s.push({type:"move",block:g.block,prevBlock:m.block,source:n,prevParent:m.parentId?(y=o.byId[m.parentId])==null?void 0:y.block:void 0,currentParent:g.parentId?(w=i.byId[g.parentId])==null?void 0:w.block:void 0}),l.add(p))))})}),s}var WC=ve(()=>{let t=[];return{key:"blockChange",prosemirrorPlugins:[new ae({key:new Ce("blockChange"),filterTransaction:e=>{let n;return t.reduce((r,o)=>r===!1?r:o({getChanges(){return n||(n=UC(e),n)},tr:e})!==!1,!0)}})],subscribe(e){return t.push(e),()=>{t.splice(t.indexOf(e),1)}}}});function v0(t){let e=t.charAt(0)==="#"?t.substring(1,7):t,n=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),o=parseInt(e.substring(4,6),16),i=[n/255,r/255,o/255].map(s=>s<=.03928?s/12.92:((s+.055)/1.055)**2.4);return .2126*i[0]+.7152*i[1]+.0722*i[2]<=.179}function w7(t){let e=document.createElement("span");e.classList.add("bn-collaboration-cursor__base");let n=document.createElement("span");n.setAttribute("contentedEditable","false"),n.classList.add("bn-collaboration-cursor__caret"),n.setAttribute("style",`background-color: ${t.color}; color: ${v0(t.color)?"white":"black"}`);let r=document.createElement("span");return r.classList.add("bn-collaboration-cursor__label"),r.setAttribute("style",`background-color: ${t.color}; color: ${v0(t.color)?"white":"black"}`),r.insertBefore(document.createTextNode(t.name),null),n.insertBefore(r,null),e.insertBefore(document.createTextNode("⁠"),null),e.insertBefore(n,null),e.insertBefore(document.createTextNode("⁠"),null),e}var Sh=ve(({options:t})=>{let e=new Map,n=t.provider&&"awareness"in t.provider&&typeof t.provider.awareness=="object"?t.provider.awareness:void 0;return n&&("setLocalStateField"in n&&typeof n.setLocalStateField=="function"&&n.setLocalStateField("user",t.user),"on"in n&&typeof n.on=="function"&&t.showCursorLabels!=="always"&&n.on("change",({updated:r})=>{for(let o of r){let i=e.get(o);i&&(setTimeout(()=>{i.element.setAttribute("data-active","")},10),i.hideTimeout&&clearTimeout(i.hideTimeout),e.set(o,{element:i.element,hideTimeout:setTimeout(()=>{i.element.removeAttribute("data-active")},2e3)}))}})),{key:"yCursor",prosemirrorPlugins:[n?F4(n,{selectionBuilder:aC,cursorBuilder(r,o){let i=e.get(o);if(!i){let s=(t.renderCursor??w7)(r);t.showCursorLabels!=="always"&&(s.addEventListener("mouseenter",()=>{let l=e.get(o);l.element.setAttribute("data-active",""),l.hideTimeout&&(clearTimeout(l.hideTimeout),e.set(o,{element:l.element,hideTimeout:void 0}))}),s.addEventListener("mouseleave",()=>{let l=e.get(o);e.set(o,{element:l.element,hideTimeout:setTimeout(()=>{l.element.removeAttribute("data-active")},2e3)})})),i={element:s,hideTimeout:void 0},e.set(o,i)}return i.element}}):void 0].filter(Boolean),dependsOn:["ySync"],updateUser(r){n==null||n.setLocalStateField("user",r)}}}),Ga=ve(({options:t})=>({key:"ySync",prosemirrorPlugins:[M4(t.fragment)],runsBefore:["default"]})),Za=ve(()=>({key:"yUndo",prosemirrorPlugins:[K4()],dependsOn:["yCursor","ySync"],undoCommand:W4,redoCommand:q4}));function k7(t,e){let n=t.doc;if(t._item===null){let r=Array.from(n.share.keys()).find(o=>n.share.get(o)===t);if(r==null)throw Error("type does not exist in other ydoc");return e.get(r,t.constructor)}else{let r=t._item,o=e.store.clients.get(r.id.client)??[];return o[Tn(o,r.id.clock)].content.type}}var x7=ve(({editor:t,options:e})=>{let n,r=go({isForked:!1});return{key:"yForkDoc",store:r,fork(){if(n)return;let o=e.fragment;if(!o)throw Error("No fragment to fork from");let i=new vo;Py(i,$y(o.doc));let s=k7(o,i);n={undoStack:or.getState(t.prosemirrorState).undoManager.undoStack,originalFragment:o,forkedFragment:s},t.unregisterExtension([Za,Sh,Ga]);let l={...e,fragment:s};t.registerExtension([Ga(l),Za()]),r.setState({isForked:!0})},merge({keepChanges:o}){if(!n)return;t.unregisterExtension(["ySync","yCursor","yUndo"]);let{originalFragment:i,forkedFragment:s,undoStack:l}=n;if(t.registerExtension([Ga(e),Sh(e),Za()]),or.getState(t.prosemirrorState).undoManager.undoStack=l,o){let a=$y(s.doc,r5(i.doc));Py(i.doc,a,t)}n=void 0,r.setState({isForked:!1})}}}),qC=(t,e)=>{e(t),t.forEach(n=>{n instanceof vt&&qC(n,e)})},C7=[(t,e)=>{let n=new Map;return t.forEach(r=>{r instanceof vt&&qC(r,o=>{if(o.nodeName==="blockContainer"&&o.hasAttribute("id")){let i=o.getAttribute("textColor"),s=o.getAttribute("backgroundColor"),l={textColor:i===xe.textColor.default?void 0:i,backgroundColor:s===xe.backgroundColor.default?void 0:s};(l.textColor||l.backgroundColor)&&n.set(o.getAttribute("id"),l)}})}),n.size===0?!1:(e.doc.descendants((r,o)=>{if(r.type.name==="blockContainer"&&n.has(r.attrs.id)){let i=e.doc.nodeAt(o+1);if(!i)throw Error("No element found");e.setNodeMarkup(o+1,void 0,{...i.attrs,...n.get(r.attrs.id)})}}),!0)}],S7=ve(({options:t})=>{let e=!1;return{key:"schemaMigration",prosemirrorPlugins:[new ae({key:new Ce("schemaMigration"),appendTransaction:(n,r,o)=>{if(e||!n.some(s=>s.getMeta("y-sync$"))||n.every(s=>!s.docChanged)||!t.fragment.firstChild)return;let i=o.tr;for(let s of C7)s(t.fragment,i);if(e=!0,i.docChanged)return i}})]}});function w0(t,e){return!t||!e?!1:!!t.closest(`.${e}`)}function E7(t,e,n,r,o){let i=t.state.doc.resolve(e.pos);if(i.parent.inlineContent||e.orientation==="inline")return null;let s=i.nodeBefore,l=i.nodeAfter;if(!s&&!l)return null;let a=e.orientation==="block-vertical-left"||e.orientation==="block-vertical-right",c=a?e.pos:e.pos-(s?s.nodeSize:0),d=t.nodeDOM(c);if(!d)return null;let u=d.getBoundingClientRect();if(a){let p=n/2*r,m=e.orientation==="block-vertical-left"?u.left:u.right;return{left:m-p,right:m+p,top:u.top,bottom:u.bottom}}let f=s?u.bottom:u.top;s&&l&&(f=(f+t.nodeDOM(e.pos).getBoundingClientRect().top)/2);let h=n/2*o;return{left:u.left,right:u.right,top:f-h,bottom:f+h}}function M7(t,e,n,r){let o=t.coordsAtPos(e.pos),i=n/2*r;return{left:o.left-i,right:o.left+i,top:o.top,bottom:o.bottom}}function T7(t,e){t.classList.toggle("prosemirror-dropcursor-inline",e==="inline"),t.classList.toggle("prosemirror-dropcursor-block-horizontal",e==="block-horizontal"),t.classList.toggle("prosemirror-dropcursor-block-vertical-left",e==="block-vertical-left"),t.classList.toggle("prosemirror-dropcursor-block-vertical-right",e==="block-vertical-right"),t.classList.toggle("prosemirror-dropcursor-block",e==="block-horizontal"),t.classList.toggle("prosemirror-dropcursor-vertical",e==="block-vertical-left"||e==="block-vertical-right")}function A7(t){if(!t||t===document.body&&getComputedStyle(t).position==="static")return{parentLeft:-window.pageXOffset,parentTop:-window.pageYOffset};let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return{parentLeft:e.left-t.scrollLeft*n,parentTop:e.top-t.scrollTop*r}}var N7=ve(({editor:t,options:e})=>{var m,g,y,w;let n=null,r=null,o=-1,i=null,s={width:((m=e.dropCursor)==null?void 0:m.width)??5,color:((g=e.dropCursor)==null?void 0:g.color)??"#ddeeff",exclude:((y=e.dropCursor)==null?void 0:y.exclude)??"bn-drag-exclude",hooks:(w=e.dropCursor)==null?void 0:w.hooks},l=k=>{(k==null?void 0:k.pos)===(n==null?void 0:n.pos)&&(k==null?void 0:k.orientation)===(n==null?void 0:n.orientation)||(n=k,k==null?(r&&r.parentNode&&r.parentNode.removeChild(r),r=null):a())},a=()=>{if(!n)return;let k=t.prosemirrorView,x=k.dom,C=x.getBoundingClientRect(),E=C.width/x.offsetWidth,S=C.height/x.offsetHeight,M=E7(k,n,s.width,E,S)??M7(k,n,s.width,E),N=k.dom.offsetParent;r||(r=N.appendChild(document.createElement("div")),r.style.cssText="position: absolute; z-index: 50; pointer-events: none;",s.color&&(r.style.backgroundColor=s.color)),T7(r,n.orientation);let{parentLeft:A,parentTop:R}=A7(N);r.style.left=(M.left-A)/E+"px",r.style.top=(M.top-R)/S+"px",r.style.width=(M.right-M.left)/E+"px",r.style.height=(M.bottom-M.top)/S+"px"},c=k=>{clearTimeout(o),o=window.setTimeout(()=>l(null),k)},d=k=>{let x=k;i=x.target instanceof Element?x.target:null},u=k=>{var A;let x=k;if(i&&w0(i,s.exclude)||x.target instanceof Element&&w0(x.target,s.exclude))return;let C=t.prosemirrorView;if(!C.editable)return;let E=C.posAtCoords({left:x.clientX,top:x.clientY}),S=E&&E.inside>=0&&C.state.doc.nodeAt(E.inside),M=S&&S.type.spec.disableDropCursor,N=typeof M=="function"?M(C,E,x):M;if(E&&!N){let R=E.pos;if(C.dragging&&C.dragging.slice){let _=Uv(C.state.doc,R,C.dragging.slice);_!=null&&(R=_)}let P=!C.state.doc.resolve(R).parent.inlineContent,D={pos:R,orientation:P?"block-horizontal":"inline"},T=D;if((A=s.hooks)!=null&&A.computeDropPosition){let _=s.hooks.computeDropPosition({editor:t,event:x,view:C,defaultPosition:D});if(_===null){l(null);return}T=_}l(T),c(5e3)}},f=k=>{let x=k;(!(x.relatedTarget instanceof Node)||!t.prosemirrorView.dom.contains(x.relatedTarget))&&l(null)},h=()=>{c(20)},p=()=>{c(20),i=null};return{key:"dropCursor",mount({signal:k,dom:x,root:C}){C.addEventListener("dragstart",d,{capture:!0,signal:k}),x.addEventListener("dragover",u,{signal:k}),x.addEventListener("dragleave",f,{signal:k}),x.addEventListener("drop",h,{signal:k}),x.addEventListener("dragend",p,{signal:k}),k.addEventListener("abort",()=>{clearTimeout(o),l(null)})}}}),R7=ve(()=>({key:"history",prosemirrorPlugins:[p7()],undoCommand:jC,redoCommand:VC})),zl=ve(({editor:t})=>{function e(o){let i=t.prosemirrorView.nodeDOM(o);for(;i&&i.parentElement;){if(i.nodeName==="A")return i;i=i.parentElement}return null}function n(o){let i=t.getLinkMarkAtPos(o);if(i)return{range:{from:i.from,to:i.to},mark:{attrs:{href:i.href}},get text(){return i.text},get position(){return Mp(t.prosemirrorView,i.from,i.to).toJSON()}}}function r(){return t.transact(o=>{if(o.selection.empty)return n(o.selection.anchor)})}return{key:"linkToolbar",getLinkAtSelection:r,getLinkElementAtPos:e,getMarkAtPos(o,i){return n(o)},getLinkAtElement(o){return t.transact(()=>n(t.prosemirrorView.posAtDOM(o,0)+1))},editLink(o,i,s=t.transact(l=>l.selection.anchor)){t.editLink(o,i,s)},deleteLink(o=t.transact(i=>i.selection.anchor)){t.deleteLink(o)}}}),I7=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"],O7="https",D7=new Ce("node-selection-keyboard"),_7=ve(()=>({key:"nodeSelectionKeyboard",prosemirrorPlugins:[new ae({key:D7,props:{handleKeyDown:(t,e)=>{if("node"in t.state.selection){if(e.ctrlKey||e.metaKey)return!1;if(e.key.length===1)return e.preventDefault(),!0;if(e.key==="Enter"&&!e.isComposing&&!e.shiftKey&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let n=t.state.tr;return t.dispatch(n.insert(t.state.tr.selection.$to.after(),t.state.schema.nodes.paragraph.createChecked()).setSelection(new W(n.doc.resolve(t.state.tr.selection.$to.after()+1)))),!0}}return!1}}})]})),P7=new Ce("blocknote-placeholder"),$7=ve(({editor:t,options:e})=>{let n=e.placeholders;return{key:"placeholder",prosemirrorPlugins:[new ae({key:P7,view:r=>{let o=`placeholder-selector-${Rp()}`;r.dom.classList.add(o);let i=document.createElement("style"),s=t._tiptapEditor.options.injectNonce;s&&i.setAttribute("nonce",s),r.root instanceof window.ShadowRoot?r.root.append(i):r.root.head.appendChild(i);let l=i.sheet,a=(c="")=>`.${o} .bn-block-content${c}:has(.ProseMirror-trailingBreak:only-child):after`;try{let{default:c,emptyDocument:d,...u}=n||{};for(let[f,h]of Object.entries(u)){let p=`[data-content-type="${f}"]`;l.insertRule(`${a(p)} { content: ${JSON.stringify(h)}; }`)}l.insertRule(`${a("[data-is-only-empty-block]")} { content: ${JSON.stringify(d)}; }`),l.insertRule(`${a("[data-is-empty-and-focused]")} { content: ${JSON.stringify(c)}; }`)}catch(c){console.warn("Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",c)}return{destroy:()=>{r.root instanceof window.ShadowRoot?r.root.removeChild(i):r.root.head.removeChild(i)}}},props:{decorations:r=>{let{doc:o,selection:i}=r;if(!t.isEditable||!i.empty||i.$from.parent.type.spec.code)return;let s=[];r.doc.content.size===6&&s.push(Me.node(2,4,{"data-is-only-empty-block":"true"}));let l=i.$anchor,a=l.parent;if(a.content.size===0){let c=l.before();s.push(Me.node(c,c+a.nodeSize,{"data-is-empty-and-focused":"true"}))}return he.create(o,s)}}})]}}),k0=new Ce("previous-blocks"),L7={index:"index",level:"level",type:"type",depth:"depth","depth-change":"depth-change"},B7=ve(()=>{let t;return{key:"previousBlockType",prosemirrorPlugins:[new ae({key:k0,view(e){return{update:async(n,r)=>{var o;((o=this.key)==null?void 0:o.getState(n.state).updatedBlocks.size)>0&&(t=setTimeout(()=>{n.dispatch(n.state.tr.setMeta(k0,{clearUpdate:!0}))},0))},destroy:()=>{t&&clearTimeout(t)}}},state:{init(){return{prevTransactionOldBlockAttrs:{},currentTransactionOldBlockAttrs:{},updatedBlocks:new Set}},apply(e,n,r,o){if(n.currentTransactionOldBlockAttrs={},n.updatedBlocks.clear(),!e.docChanged)return n;let i=e.changedRange();if(!i)return n;let s=e.mapping.invert(),l={from:s.map(i.from,-1),to:s.map(i.to,1)},a={},c=bc(r.doc,l,f=>f.attrs.id),d=new Map(c.map(f=>[f.node.attrs.id,f])),u=bc(o.doc,i,f=>f.attrs.id);for(let f of u){let h=d.get(f.node.attrs.id),p=h==null?void 0:h.node.firstChild,m=f.node.firstChild;if(h&&p&&m){let g={index:m.attrs.index,level:m.attrs.level,type:m.type.name,depth:o.doc.resolve(f.pos).depth},y={index:p.attrs.index,level:p.attrs.level,type:p.type.name,depth:r.doc.resolve(h.pos).depth};a[f.node.attrs.id]=y,n.currentTransactionOldBlockAttrs[f.node.attrs.id]=y,(y.index!==g.index||y.level!==g.level||y.type!==g.type||y.depth!==g.depth)&&(y["depth-change"]=y.depth-g.depth,n.updatedBlocks.add(f.node.attrs.id))}}return n.prevTransactionOldBlockAttrs=a,n}},props:{decorations(e){let n=this.getState(e);if(n.updatedBlocks.size===0)return;let r=[];return e.doc.descendants((o,i)=>{if(!o.attrs.id||!n.updatedBlocks.has(o.attrs.id))return;let s=n.currentTransactionOldBlockAttrs[o.attrs.id],l={};for(let[a,c]of Object.entries(s))l["data-prev-"+L7[a]]=c||"none";r.push(Me.node(i,i+o.nodeSize,{...l}))}),he.create(e.doc,r)}}})]}});function GC(t,e){var n,r;for(;t&&t.parentElement&&t.parentElement!==e.dom&&((n=t.getAttribute)==null?void 0:n.call(t,"data-node-type"))!=="blockContainer";)t=t.parentElement;if(((r=t.getAttribute)==null?void 0:r.call(t,"data-node-type"))==="blockContainer")return{node:t,id:t.getAttribute("data-id")}}function j7(t){let e=document.createElement("div");return e.innerHTML=t,xl(e,{indent:"",inListItem:!1}).trim()+`
127
+ `}function xl(t,e){let n="",r=Array.from(t.childNodes);for(let o=0;o<r.length;o++){let i=r[o];n+=Pi(i,e)}return n}function Pi(t,e){if(t.nodeType===3)return t.textContent||"";if(t.nodeType!==1)return"";let n=t;switch(n.tagName.toLowerCase()){case"p":return V7(n,e);case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return ZC(n,e);case"blockquote":return H7(n,e);case"pre":return F7(n,e);case"ul":return U7(n,e);case"ol":return W7(n,e);case"table":return G7(n,e);case"hr":return e.indent+`***
128
+
129
+ `;case"img":return K7(n,e);case"video":return J7(n,e);case"audio":return Y7(n,e);case"embed":return X7(n,e);case"figure":return Q7(n,e);case"a":return YC(n,e);case"details":return n8(n,e);case"div":return xl(n,e);case"br":return"";default:return xl(n,e)}}function V7(t,e){let n=r8(gt(t));return e.inListItem?n:e.indent+n+`
130
+
131
+ `}function ZC(t,e){let n=parseInt(t.tagName[1],10),r="#".repeat(n)+" ",o=gt(t);return e.indent+r+o+`
132
+
133
+ `}function H7(t,e){let n=Array.from(t.children).filter(o=>{let i=o.tagName.toLowerCase();return["p","ul","ol","pre","blockquote","table","hr"].includes(i)}),r;if(n.length>0){let o=[];for(let i of n)i.tagName.toLowerCase()==="p"?o.push(gt(i)):o.push(Pi(i,{indent:"",inListItem:!1}).trim());r=o.join(`
134
+
135
+ `)}else r=gt(t);return r.split(`
136
+ `).map(o=>e.indent+"> "+o).join(`
137
+ `)+`
138
+
139
+ `}function F7(t,e){let n=t.querySelector("code");if(!n)return"";let r=n.getAttribute("data-language")||z7(n.className)||"",o=KC(n),i=Math.max(0,...(o.match(/`+/g)??[]).map(l=>l.length)),s="`".repeat(Math.max(3,i+1));return o?e.indent+s+r+`
140
+ `+o+(o.endsWith(`
141
+ `)?"":`
142
+ `)+s+`
143
+
144
+ `:e.indent+s+r+`
145
+ `+s+`
146
+
147
+ `}function KC(t){let e="";for(let n of Array.from(t.childNodes))n.nodeType===3?e+=n.textContent||"":n.nodeType===1&&(n.tagName.toLowerCase()==="br"?e+=`
148
+ `:e+=KC(n));return e}function z7(t){let e=t.match(/language-(\S+)/);return e?e[1]:""}function U7(t,e){let n="",r=Array.from(t.children).filter(o=>o.tagName.toLowerCase()==="li");for(let o of r)n+=JC(o,"bullet",e);return e.inListItem||(n+=`
149
+ `),n}function W7(t,e){let n="",r=Array.from(t.children).filter(i=>i.tagName.toLowerCase()==="li"),o=parseInt(t.getAttribute("start")||"1",10);for(let i=0;i<r.length;i++){let s=o+i;n+=JC(r[i],"ordered",e,s)}return e.inListItem||(n+=`
150
+ `),n}function JC(t,e,n,r){var p;let o=null,i=null;for(let m of Array.from(t.children)){let g=m.tagName.toLowerCase();g==="input"&&m.type==="checkbox"&&(o=m),g==="details"&&(i=m)}let s,l;o?(s=`* ${o.checked?"[x]":"[ ]"} `,l=2):e==="ordered"?(s=`${r}. `,l=s.length):(s="* ",l=2);let a,c;if(i){let m=(p=i.querySelector("summary"))==null?void 0:p.querySelector("p");c=i,a=m?gt(m):""}else c=q7(t,o),a=c?gt(c):"";let d=n.indent+s+a+`
151
+ `,u=n.indent+" ".repeat(l),f={indent:u,inListItem:!0};if(i){let m=i.querySelector("summary");for(let g of Array.from(i.children))if(g!==m)if(g.tagName.toLowerCase()==="p"){let y=gt(g);d+=`
152
+ `+u+y+`
153
+ `}else d+=Pi(g,f)}let h=Array.from(t.children);for(let m of h){let g=m.tagName.toLowerCase();if(!(m===c||m===o)&&g!=="input")if(g==="ul"||g==="ol")d+=Pi(m,f);else if(g==="p"){let y=gt(m);d+=`
154
+ `+u+y+`
155
+ `}else d+=`
156
+ `+Pi(m,f)}return d}function q7(t,e){for(let n of Array.from(t.children)){if(n===e||n.tagName.toLowerCase()==="input")continue;let r=n.tagName.toLowerCase();if(r==="p"||r==="span")return n}return null}function G7(t,e){let n=t.querySelector("colgroup"),r=0;n&&(r=n.querySelectorAll("col").length);let o=[],i=!1,s=t.querySelectorAll("tr"),l=[];s.forEach((d,u)=>{l[u]||(l[u]=[]);let f=d.querySelectorAll("th, td"),h=0;f.forEach(p=>{for(;l[u][h]!==void 0;)h++;u===0&&p.tagName.toLowerCase()==="th"&&(i=!0);let m=Z7(gt(p).trim()),g=parseInt(p.getAttribute("colspan")||"1",10),y=parseInt(p.getAttribute("rowspan")||"1",10);for(let w=0;w<y;w++)for(let k=0;k<g;k++){let x=u+w;l[x]||(l[x]=[]),l[x][h+k]=w===0&&k===0?m:""}h+=g}),l[u]&&(r=Math.max(r,l[u].length))});for(let d of l){let u=[];for(let f=0;f<r;f++)u.push(d&&d[f]!==void 0?d[f]??"":"");o.push(u)}if(o.length===0)return"";let a=[];for(let d=0;d<r;d++){let u=3;for(let f of o){let h=d<f.length?f[d].length:0;u=Math.max(u,h)}a.push(Math.max(u,10))}let c="";if(i){c+=e.indent+xa(o[0],a,r)+`
157
+ `,c+=e.indent+x0(a,r)+`
158
+ `;for(let d=1;d<o.length;d++)c+=e.indent+xa(o[d],a,r)+`
159
+ `}else{let d=Array(r).fill("");c+=e.indent+xa(d,a,r)+`
160
+ `,c+=e.indent+x0(a,r)+`
161
+ `;for(let u of o)c+=e.indent+xa(u,a,r)+`
162
+ `}return c+=`
163
+ `,c}function Z7(t){return t.replace(/\|/g,"\\|")}function xa(t,e,n){let r=[];for(let o=0;o<n;o++){let i=o<t.length?t[o]:"";r.push(" "+i.padEnd(e[o])+" ")}return"|"+r.join("|")+"|"}function x0(t,e){let n=[];for(let r=0;r<e;r++)n.push(" "+"-".repeat(t[r])+" ");return"|"+n.join("|")+"|"}function K7(t,e){let n=t.getAttribute("src")||"",r=t.getAttribute("alt")||"";return n?e.indent+`![${r}](${n})
164
+
165
+ `:`
166
+
167
+ `}function J7(t,e){let n=t.getAttribute("src")||t.getAttribute("data-url")||"",r=t.getAttribute("data-name")||t.getAttribute("title")||"";return n?e.indent+`![${r}](${n})
168
+
169
+ `:`
170
+
171
+ `}function Y7(t,e){let n=t.getAttribute("src")||"";return n?e.indent+`<audio src="${Rs(n)}" controls></audio>
172
+
173
+ `:`
174
+
175
+ `}function X7(t,e){let n=t.getAttribute("src")||"";return n?e.indent+`[](${n})
176
+
177
+ `:`
178
+
179
+ `}function Q7(t,e){var l,a;let n=t.querySelector("img"),r=t.querySelector("video"),o=t.querySelector("audio"),i=t.querySelector("a"),s=((a=(l=t.querySelector("figcaption"))==null?void 0:l.textContent)==null?void 0:a.trim())||"";return n?Qu("img",n.getAttribute("src")||"",n.getAttribute("alt")||"",s,e):r?Qu("video",r.getAttribute("src")||r.getAttribute("data-url")||"",r.getAttribute("data-name")||r.getAttribute("title")||"",s,e):o?Qu("audio",o.getAttribute("src")||"","",s,e):i?YC(i,e):""}function Qu(t,e,n,r,o){if(!e)return"";if(!r&&t!=="audio")return o.indent+`![${n}](${e})
180
+
181
+ `;let i=n&&n!==r?t==="img"?` alt="${Rs(n)}"`:t==="video"?` data-name="${Rs(n)}"`:"":"",s=t==="img"?`<img${i} src="${Rs(e)}">`:`<${t} src="${Rs(e)}"${i} controls></${t}>`,l=r?`<figcaption>${e8(r)}</figcaption>`:"";return o.indent+`<figure>${s}${l}</figure>
182
+
183
+ `}function Rs(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function e8(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function YC(t,e){var o;let n=t.getAttribute("href")||"",r=((o=t.textContent)==null?void 0:o.trim())||"";return n?e.indent+XC(r,n)+`
184
+
185
+ `:e.indent+r+`
186
+
187
+ `}function XC(t,e){return!t||t===e?e:`[${t}](${t8(e)})`}function t8(t){return t.replace(/[\\()]/g,"\\$&")}function n8(t,e){let n=t.querySelector("summary");if(!n)return xl(t,e);let r=n.querySelector("h1, h2, h3, h4, h5, h6");if(r){let o=ZC(r,e);for(let i of Array.from(t.children))i!==n&&(o+=Pi(i,e));return o}return xl(n,e)}function gt(t){let e="";for(let n of Array.from(t.childNodes))if(n.nodeType===3)e+=n.textContent||"";else if(n.nodeType===1){let r=n;switch(r.tagName.toLowerCase()){case"strong":case"b":{let{content:o,trailing:i}=C0(gt(r));o?e+=`**${o}**${i}`:e+=i;break}case"em":case"i":{let{content:o,trailing:i}=C0(gt(r));o?e+=`*${o}*${i}`:e+=i;break}case"s":case"del":e+=`~~${gt(r)}~~`;break;case"code":{let o=r.textContent||"",i=Math.max(0,...(o.match(/`+/g)??[]).map(a=>a.length)),s="`".repeat(i+1),l=o.startsWith("`")||o.endsWith("`");e+=s+(l?` ${o} `:o)+s;break}case"u":e+=gt(r);break;case"a":{let o=r.getAttribute("href")||"",i=gt(r);e+=XC(i,o);break}case"br":e+=`\\
188
+ `;break;case"span":e+=gt(r);break;case"img":{let o=r.getAttribute("src")||"",i=r.getAttribute("alt")||"";e+=`![${i}](${o})`;break}case"video":{let o=r.getAttribute("src")||r.getAttribute("data-url")||"",i=r.getAttribute("data-name")||r.getAttribute("title")||"";e+=`![${i}](${o})`;break}case"p":e+=gt(r);break;case"input":break;default:e+=gt(r);break}}return e}function C0(t){let e=t.match(/^(.*?)(\s*)$/);return e?{content:e[1],trailing:e[2]}:{content:t,trailing:""}}function r8(t){let e=t.replace(/^(\\\n)+/,"");return e=e.replace(/(\\\n)+$/,""),e}function vm(t){return j7(t)}function o8(t,e,n,r){return vm(Dd(e,n).exportBlocks(t,r))}function QC(t){let e=[];return t.descendants(n=>{var o,i;let r=st(n);return n.type.name==="blockContainer"&&((o=n.firstChild)==null?void 0:o.type.name)==="blockGroup"?!0:n.type.name==="columnList"&&n.childCount===1?((i=n.firstChild)==null||i.forEach(s=>{e.push(qe(s,r))}),!1):n.type.isInGroup("bnBlock")?(e.push(qe(n,r)),!1):!0}),e}var Eh=class Ka extends ee{constructor(n,r){super(n,r);B(this,"nodes");let o=n.node();this.nodes=[],n.doc.nodesBetween(n.pos,r.pos,(i,s,l)=>{if(l!==null&&l.eq(o))return this.nodes.push(i),!1})}static create(n,r,o=r){return new Ka(n.resolve(r),n.resolve(o))}content(){return new j(I.from(this.nodes),0,0)}eq(n){if(!(n instanceof Ka)||this.nodes.length!==n.nodes.length||this.from!==n.from||this.to!==n.to)return!1;for(let r=0;r<this.nodes.length;r++)if(!this.nodes[r].eq(n.nodes[r]))return!1;return!0}map(n,r){let o=r.mapResult(this.from),i=r.mapResult(this.to);return i.deleted?ee.near(n.resolve(o.pos)):o.deleted?ee.near(n.resolve(i.pos)):new Ka(n.resolve(o.pos),n.resolve(i.pos))}toJSON(){return{type:"multiple-node",anchor:this.anchor,head:this.head}}};ee.jsonID("multiple-node",Eh);var On;function i8(t,e){let n,r,o=e.resolve(t.from).node().type.spec.group==="blockContent",i=e.resolve(t.to).node().type.spec.group==="blockContent",s=Math.min(t.$anchor.depth,t.$head.depth);if(o&&i){let l=t.$from.start(s-1),a=t.$to.end(s-1);n=e.resolve(l-1).pos,r=e.resolve(a+1).pos}else n=t.from,r=t.to;return{from:n,to:r}}function S0(t,e,n=e){e===n&&(n+=t.state.doc.resolve(e+1).node().nodeSize);let r=t.domAtPos(e).node.cloneNode(!0),o=t.domAtPos(e).node,i=(c,d)=>Array.prototype.indexOf.call(c.children,d),s=i(o,t.domAtPos(e+1).node.parentElement),l=i(o,t.domAtPos(n-1).node.parentElement);for(let c=o.childElementCount-1;c>=0;c--)(c>l||c<s)&&r.removeChild(r.children[c]);eS(t.root),On=r,On.querySelectorAll("iframe, embed, object").forEach(c=>{var d;return(d=c.parentElement)==null?void 0:d.removeChild(c)});let a=t.dom.className.split(" ").filter(c=>c!=="ProseMirror"&&c!=="bn-root"&&c!=="bn-editor").join(" ");On.className=On.className+" bn-drag-preview "+a,t.root instanceof ShadowRoot?t.root.appendChild(On):t.root.body.appendChild(On)}function eS(t){On!==void 0&&(t instanceof ShadowRoot?t.removeChild(On):t.body.removeChild(On),On=void 0)}function s8(t,e,n){if(!t.dataTransfer||n.headless)return;let r=n.prosemirrorView,o=Ht(e.id,r.state.doc);if(!o)throw Error(`Block with ID ${e.id} not found`);let i=o.posBeforeNode;if(i!=null){let s=r.state.selection,l=r.state.doc,{from:a,to:c}=i8(s,l),d=a<=i&&i<c,u=s.$anchor.node()!==s.$head.node()||s instanceof Eh;d&&u?(r.dispatch(r.state.tr.setSelection(Eh.create(l,a,c))),S0(r,a,c)):(r.dispatch(r.state.tr.setSelection(G.create(r.state.doc,i))),S0(r,i));let f=r.state.selection.content(),h=n.pmSchema,p=r.serializeForClipboard(f).dom.innerHTML,m=Dd(h,n),g=QC(f.content),y=m.exportBlocks(g,{}),w=vm(y);t.dataTransfer.clearData(),t.dataTransfer.setData("blocknote/html",p),t.dataTransfer.setData("text/html",y),t.dataTransfer.setData("text/plain",w),t.dataTransfer.effectAllowed="move",t.dataTransfer.setDragImage(On,0,0)}}var E0=250;function Mh(t,e,n=!0){let r=t.root.elementsFromPoint(e.left,e.top);for(let o of r)if(t.dom.contains(o))return n&&o.closest("[data-node-type=columnList]")?Mh(t,{left:e.left+50,top:e.top},!1):GC(o,t)}function l8(t,e){if(!e.dom.firstChild)return;let n=e.dom.firstChild.getBoundingClientRect(),r=Mh(e,{left:Math.min(Math.max(n.left+10,t.x),n.right-10),top:t.y});if(r)return Mh(e,{left:r.node.getBoundingClientRect().right-10,top:t.y},!1)}var a8=class{constructor(e,n,r){B(this,"state");B(this,"emitUpdate");B(this,"mousePos");B(this,"hoveredBlock");B(this,"menuFrozen",!1);B(this,"isDragOrigin",!1);B(this,"updateState",e=>{this.state=e,this.emitUpdate(this.state)});B(this,"updateStateFromMousePos",()=>{var r,o,i,s,l;if(this.menuFrozen||!this.mousePos)return;let e=this.findClosestEditorElement({clientX:this.mousePos.x,clientY:this.mousePos.y});if((e==null?void 0:e.element)!==this.pmView.dom||e.distance>E0){(r=this.state)!=null&&r.show&&(this.state.show=!1,this.updateState(this.state));return}let n=l8(this.mousePos,this.pmView);if(!n||!this.editor.isEditable){(o=this.state)!=null&&o.show&&(this.state.show=!1,this.updateState(this.state));return}if(!((i=this.state)!=null&&i.show&&((s=this.hoveredBlock)!=null&&s.hasAttribute("data-id"))&&((l=this.hoveredBlock)==null?void 0:l.getAttribute("data-id"))===n.id)&&(this.hoveredBlock=n.node,this.editor.isEditable)){let a=n.node.getBoundingClientRect(),c=n.node.closest("[data-node-type=column]");this.state={show:!0,referencePos:new DOMRect(c?c.firstElementChild.getBoundingClientRect().x:this.pmView.dom.firstChild.getBoundingClientRect().x,a.y,a.width,a.height),block:this.editor.getBlock(this.hoveredBlock.getAttribute("data-id"))},this.updateState(this.state)}});B(this,"onDragStart",e=>{var i;let n=(i=e.dataTransfer)==null?void 0:i.getData("blocknote/html");if(!n||this.pmView.dragging)return;let r=document.createElement("div");r.innerHTML=n;let o=wn.fromSchema(this.pmView.state.schema).parse(r,{topNode:this.pmView.state.schema.nodes.blockGroup.create()});this.pmView.dragging={slice:new j(o.content,0,0),move:!0}});B(this,"findClosestEditorElement",e=>{let n=Array.from(this.pmView.root.querySelectorAll(".bn-editor"));if(n.length===0)return null;let r=n[0],o=Number.MAX_VALUE;return n.forEach(i=>{let s=i.querySelector(".bn-block-group").getBoundingClientRect(),l=e.clientX<s.left?s.left-e.clientX:e.clientX>s.right?e.clientX-s.right:0,a=e.clientY<s.top?s.top-e.clientY:e.clientY>s.bottom?e.clientY-s.bottom:0,c=Math.sqrt(l**2+a**2);c<o&&(o=c,r=i)}),{element:r,distance:o}});B(this,"onDragOver",e=>{var r;if(e.synthetic||!(this.pmView.dragging!==null||this.isDragOrigin||(r=e.dataTransfer)!=null&&r.types.includes("blocknote/html")||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;let n=this.getDragEventContext(e);if(!n||!n.isDropPoint){this.closeDropCursor();return}n.isDropPoint&&!n.isDropWithinEditorBounds&&this.dispatchSyntheticEvent(e)});B(this,"closeDropCursor",()=>{let e=new Event("dragleave",{bubbles:!1});e.synthetic=!0,this.pmView.dom.dispatchEvent(e)});B(this,"getDragEventContext",e=>{var a,c;if(!(this.pmView.dragging!==null||this.isDragOrigin||(a=e.dataTransfer)!=null&&a.types.includes("blocknote/html")||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;let n=!((c=e.dataTransfer)!=null&&c.types.includes("blocknote/html"))&&!!this.pmView.dragging,r=!!this.isDragOrigin,o=n||r,i=this.findClosestEditorElement(e);if(!i||i.distance>E0)return;let s=i.element===this.pmView.dom,l=s&&i.distance===0;if(!(!s&&!o))return{isDropPoint:s,isDropWithinEditorBounds:l,isDragOrigin:o}});B(this,"onDrop",e=>{var s;if(e.synthetic||!(this.pmView.dragging!==null||this.isDragOrigin||(s=e.dataTransfer)!=null&&s.types.includes("blocknote/html")||e.target instanceof Node&&this.pmView.dom.contains(e.target)))return;let n=this.getDragEventContext(e);if(!n){this.closeDropCursor();return}let{isDropPoint:r,isDropWithinEditorBounds:o,isDragOrigin:i}=n;if(!o&&r&&this.dispatchSyntheticEvent(e),r){if(this.pmView.dragging)return;this.pmView.dispatch(this.pmView.state.tr.setSelection(W.create(this.pmView.state.tr.doc,this.pmView.state.tr.selection.anchor)));return}else if(i){setTimeout(()=>this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),0);return}});B(this,"onDragEnd",e=>{e.synthetic||(this.pmView.dragging=null)});B(this,"onKeyDown",e=>{var n;(n=this.state)!=null&&n.show&&this.editor.isFocused()&&(this.state.show=!1,this.emitUpdate(this.state))});B(this,"onMouseMove",e=>{var r;if(this.menuFrozen)return;this.mousePos={x:e.clientX,y:e.clientY};let n=this.pmView.dom.getBoundingClientRect();if(this.mousePos.x>n.left&&this.mousePos.x<n.right&&this.mousePos.y>n.top&&this.mousePos.y<n.bottom&&e&&e.target&&!this.editor.isWithinEditor(e.target)){(r=this.state)!=null&&r.show&&(this.state.show=!1,this.emitUpdate(this.state));return}this.updateStateFromMousePos()});this.editor=e,this.pmView=n,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized side menu");r(this.state)},this.pmView.root.addEventListener("dragstart",this.onDragStart),this.pmView.root.addEventListener("dragover",this.onDragOver),this.pmView.root.addEventListener("drop",this.onDrop,!0),this.pmView.root.addEventListener("dragend",this.onDragEnd,!0),this.pmView.root.addEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.addEventListener("keydown",this.onKeyDown,!0)}dispatchSyntheticEvent(e){let n=new Event(e.type,e),r=this.pmView.dom.firstChild.getBoundingClientRect();n.clientX=e.clientX,n.clientY=e.clientY,n.clientX=Math.min(Math.max(e.clientX,r.left),r.left+r.width),n.clientY=Math.min(Math.max(e.clientY,r.top),r.top+r.height),n.dataTransfer=e.dataTransfer,n.preventDefault=()=>e.preventDefault(),n.synthetic=!0,this.pmView.dom.dispatchEvent(n)}update(e,n){var r;!n.doc.eq(this.pmView.state.doc)&&((r=this.state)!=null&&r.show)&&this.updateStateFromMousePos()}destroy(){var e;(e=this.state)!=null&&e.show&&(this.state.show=!1,this.emitUpdate(this.state)),this.pmView.root.removeEventListener("mousemove",this.onMouseMove,!0),this.pmView.root.removeEventListener("dragstart",this.onDragStart),this.pmView.root.removeEventListener("dragover",this.onDragOver),this.pmView.root.removeEventListener("drop",this.onDrop,!0),this.pmView.root.removeEventListener("dragend",this.onDragEnd,!0),this.pmView.root.removeEventListener("keydown",this.onKeyDown,!0)}},c8=new Ce("SideMenuPlugin"),An=ve(({editor:t})=>{let e,n=go(void 0);return{key:"sideMenu",store:n,prosemirrorPlugins:[new ae({key:c8,view:r=>(e=new a8(t,r,o=>{n.setState({...o})}),e)})],blockDragStart(r,o){e&&(e.isDragOrigin=!0),s8(r,o,t)},blockDragEnd(){eS(t.prosemirrorView.root),e&&(e.isDragOrigin=!1),t.blur()},freezeMenu(){e.menuFrozen=!0,e.state.show=!0,e.emitUpdate(e.state)},unfreezeMenu(){e.menuFrozen=!1,e.state.show=!1,e.emitUpdate(e.state)},hideMenuIfNotFrozen(){var r;!e.menuFrozen&&((r=e.state)!=null&&r.show)&&(e.state.show=!1,e.emitUpdate(e.state))}}}),ef;async function d8(){return ef||(ef=(async()=>{let[t,e]=await Promise.all([$i(()=>import("./module-D8iBLRih.js"),[]),$i(()=>import("./native-48B9X9Wg.js"),[])]),n="default"in t?t.default:t,r="default"in e?e.default:e;return await n.init({data:r}),{emojiMart:n,emojiData:r}})(),ef)}async function u8(t,e){if(!("text"in t.schema.inlineContentSchema)||t.schema.inlineContentSchema.text!==n7.text)return[];let{emojiData:n,emojiMart:r}=await d8();return(e.trim()===""?Object.values(n.emojis):await r.SearchIndex.search(e)).map(o=>({id:o.skins[0].native,onItemClick:()=>t.insertInlineContent(o.skins[0].native+" ")}))}var nn;function M0(t){nn||(nn=document.createElement("div"),nn.innerHTML="_",nn.style.opacity="0",nn.style.height="1px",nn.style.width="1px",t instanceof Document?t.body.appendChild(nn):t.appendChild(nn))}function f8(t){nn&&(nn=(t instanceof Document?t.body.removeChild(nn):t.removeChild(nn),void 0))}function Ca(t){return Array.prototype.indexOf.call(t.parentElement.childNodes,t)}function h8(t){let e=t;for(;e&&e.nodeName!=="TD"&&e.nodeName!=="TH"&&!e.classList.contains("tableWrapper");){if(e.classList.contains("ProseMirror"))return;let n=e.parentNode;if(!n||!(n instanceof Element))return;e=n}return e.nodeName==="TD"||e.nodeName==="TH"?{type:"cell",domNode:e,tbodyNode:e.closest("tbody")}:{type:"wrapper",domNode:e,tbodyNode:e.querySelector("tbody")}}function p8(t,e){let n=e.querySelectorAll(t);for(let r=0;r<n.length;r++)n[r].style.visibility="hidden"}var m8=class{constructor(e,n,r){B(this,"state");B(this,"emitUpdate");B(this,"tableId");B(this,"tablePos");B(this,"tableElement");B(this,"menuFrozen",!1);B(this,"mouseState","up");B(this,"prevWasEditable",null);B(this,"viewMousedownHandler",()=>{this.mouseState="down"});B(this,"mouseUpHandler",e=>{this.mouseState="up",this.mouseMoveHandler(e)});B(this,"mouseMoveHandler",e=>{var c,d,u,f,h,p,m,g;if(this.menuFrozen||this.mouseState==="selecting"||!(e.target instanceof Element)||!this.pmView.dom.contains(e.target))return;let n=h8(e.target);if((n==null?void 0:n.type)==="cell"&&this.mouseState==="down"&&!((c=this.state)!=null&&c.draggingState)){this.mouseState="selecting",(d=this.state)!=null&&d.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!n||!this.editor.isEditable){(u=this.state)!=null&&u.show&&(this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate());return}if(!n.tbodyNode)return;let r=n.tbodyNode.getBoundingClientRect(),o=GC(n.domNode,this.pmView);if(!o)return;this.tableElement=o.node;let i,s=this.editor.transact(y=>Ht(o.id,y.doc));if(!s)throw Error(`Block with ID ${o.id} not found`);let l=qe(s.node,this.editor.pmSchema,this.editor.schema.blockSchema,this.editor.schema.inlineContentSchema,this.editor.schema.styleSchema);if(Ue(this.editor,"table")&&(this.tablePos=s.posBeforeNode+1,i=l),!i)return;this.tableId=o.id;let a=(f=n.domNode.closest(".tableWrapper"))==null?void 0:f.querySelector(".table-widgets-container");if((n==null?void 0:n.type)==="wrapper"){let y=e.clientY>=r.bottom-1&&e.clientY<r.bottom+20,w=e.clientX>=r.right-1&&e.clientX<r.right+20,k=((h=this.state)==null?void 0:h.block.id)!==i.id||e.clientX>r.right||e.clientY>r.bottom;this.state={...this.state,show:!0,showAddOrRemoveRowsButton:y,showAddOrRemoveColumnsButton:w,referencePosTable:r,block:i,widgetContainer:a,colIndex:k||(p=this.state)==null?void 0:p.colIndex,rowIndex:k||(m=this.state)==null?void 0:m.rowIndex,referencePosCell:k||(g=this.state)==null?void 0:g.referencePosCell}}else{let y=Ca(n.domNode),w=Ca(n.domNode.parentElement),k=n.domNode.getBoundingClientRect();if(this.state!==void 0&&this.state.show&&this.tableId===o.id&&this.state.rowIndex===w&&this.state.colIndex===y)return;this.state={show:!0,showAddOrRemoveColumnsButton:y===i.content.rows[0].cells.length-1,showAddOrRemoveRowsButton:w===i.content.rows.length-1,referencePosTable:r,block:i,draggingState:void 0,referencePosCell:k,colIndex:y,rowIndex:w,widgetContainer:a}}return this.emitUpdate(),!1});B(this,"dragOverHandler",e=>{var u;if(((u=this.state)==null?void 0:u.draggingState)===void 0)return;e.preventDefault(),e.dataTransfer.dropEffect="move",p8(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",this.pmView.root);let n={left:Math.min(Math.max(e.clientX,this.state.referencePosTable.left+1),this.state.referencePosTable.right-1),top:Math.min(Math.max(e.clientY,this.state.referencePosTable.top+1),this.state.referencePosTable.bottom-1)},r=this.pmView.root.elementsFromPoint(n.left,n.top).filter(f=>f.tagName==="TD"||f.tagName==="TH");if(r.length===0)return;let o=r[0],i=!1,s=Ca(o.parentElement),l=Ca(o),a=this.state.draggingState.draggedCellOrientation==="row"?this.state.rowIndex:this.state.colIndex,c=(this.state.draggingState.draggedCellOrientation==="row"?s:l)!==a;(this.state.rowIndex!==s||this.state.colIndex!==l)&&(this.state.rowIndex=s,this.state.colIndex=l,this.state.referencePosCell=o.getBoundingClientRect(),i=!0);let d=this.state.draggingState.draggedCellOrientation==="row"?n.top:n.left;this.state.draggingState.mousePos!==d&&(this.state.draggingState.mousePos=d,i=!0),i&&this.emitUpdate(),c&&this.editor.transact(f=>f.setMeta(Is,!0))});B(this,"dropHandler",e=>{if(this.mouseState="up",this.state===void 0||this.state.draggingState===void 0)return!1;if(this.state.rowIndex===void 0||this.state.colIndex===void 0)throw Error("Attempted to drop table row or column, but no table block was hovered prior.");e.preventDefault();let{draggingState:n,colIndex:r,rowIndex:o}=this.state;this.state.draggingState=void 0;let i=this.state.block.content.columnWidths;if(n.draggedCellOrientation==="row"){if(!wC(this.state.block,n.originalIndex,o))return!1;let s=jL(this.state.block,n.originalIndex,o);this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,rows:s}})}else{if(!kC(this.state.block,n.originalIndex,r))return!1;let s=BL(this.state.block,n.originalIndex,r),[l]=i.splice(n.originalIndex,1);i.splice(r,0,l),this.editor.updateBlock(this.state.block,{type:"table",content:{...this.state.block.content,columnWidths:i,rows:s}})}return this.editor.setTextCursorPosition(this.state.block.id),!0});this.editor=e,this.pmView=n,this.emitUpdate=()=>{if(!this.state)throw Error("Attempting to update uninitialized image toolbar");r(this.state)},n.dom.addEventListener("mousemove",this.mouseMoveHandler),n.dom.addEventListener("mousedown",this.viewMousedownHandler),window.addEventListener("mouseup",this.mouseUpHandler),n.root.addEventListener("dragover",this.dragOverHandler),n.root.addEventListener("drop",this.dropHandler)}update(){var o;if(!this.state||!this.state.show)return;if(this.state.block=this.editor.getBlock(this.state.block.id),!this.state.block||this.state.block.type!=="table"||!((o=this.tableElement)!=null&&o.isConnected)){this.state.show=!1,this.state.showAddOrRemoveRowsButton=!1,this.state.showAddOrRemoveColumnsButton=!1,this.emitUpdate();return}let{height:e,width:n}=fm(this.state.block);this.state.rowIndex!==void 0&&this.state.colIndex!==void 0&&(this.state.rowIndex>=e&&(this.state.rowIndex=e-1),this.state.colIndex>=n&&(this.state.colIndex=n-1));let r=this.tableElement.querySelector("tbody");if(!r)throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");if(this.state.rowIndex!==void 0&&this.state.colIndex!==void 0){let i=r.children[this.state.rowIndex].children[this.state.colIndex];i?this.state.referencePosCell=i.getBoundingClientRect():(this.state.rowIndex=void 0,this.state.colIndex=void 0)}this.state.referencePosTable=r.getBoundingClientRect(),this.emitUpdate()}destroy(){this.pmView.dom.removeEventListener("mousemove",this.mouseMoveHandler),window.removeEventListener("mouseup",this.mouseUpHandler),this.pmView.dom.removeEventListener("mousedown",this.viewMousedownHandler),this.pmView.root.removeEventListener("dragover",this.dragOverHandler),this.pmView.root.removeEventListener("drop",this.dropHandler)}},Is=new Ce("TableHandlesPlugin"),_e=ve(({editor:t})=>{let e,n=go(void 0);return{key:"tableHandles",store:n,prosemirrorPlugins:[new ae({key:Is,view:r=>(e=new m8(t,r,o=>{n.setState(o.block?{...o,draggingState:o.draggingState?{...o.draggingState}:void 0}:void 0)}),e),props:{decorations:r=>{if(e===void 0||e.state===void 0||e.state.draggingState===void 0||e.tablePos===void 0)return;let o=e.state.draggingState.draggedCellOrientation==="row"?e.state.rowIndex:e.state.colIndex;if(o===void 0)return;let i=[],{block:s,draggingState:l}=e.state,{originalIndex:a,draggedCellOrientation:c}=l;if(o===a||!s||c==="row"&&!wC(s,a,o)||c==="col"&&!kC(s,a,o))return he.create(r.doc,i);let d=r.doc.resolve(e.tablePos+1);return e.state.draggingState.draggedCellOrientation==="row"?vh(e.state.block,o).forEach(({row:u,col:f})=>{let h=r.doc.resolve(d.posAtIndex(u)+1),p=r.doc.resolve(h.posAtIndex(f)+1),m=p.node(),g=p.pos+(o>a?m.nodeSize-2:0);i.push(Me.widget(g,()=>{let y=document.createElement("div");return y.className="bn-table-drop-cursor",y.style.left="0",y.style.right="0",o>a?y.style.bottom="-2px":y.style.top="-3px",y.style.height="4px",y}))}):wh(e.state.block,o).forEach(({row:u,col:f})=>{let h=r.doc.resolve(d.posAtIndex(u)+1),p=r.doc.resolve(h.posAtIndex(f)+1),m=p.node(),g=p.pos+(o>a?m.nodeSize-2:0);i.push(Me.widget(g,()=>{let y=document.createElement("div");return y.className="bn-table-drop-cursor",y.style.top="0",y.style.bottom="0",o>a?y.style.right="-2px":y.style.left="-3px",y.style.width="4px",y}))}),he.create(r.doc,i)}}})],colDragStart(r){if(e===void 0||e.state===void 0||e.state.colIndex===void 0)throw Error("Attempted to drag table column, but no table block was hovered prior.");e.state.draggingState={draggedCellOrientation:"col",originalIndex:e.state.colIndex,mousePos:r.clientX},e.emitUpdate(),t.transact(o=>o.setMeta(Is,{draggedCellOrientation:e.state.draggingState.draggedCellOrientation,originalIndex:e.state.colIndex,newIndex:e.state.colIndex,tablePos:e.tablePos})),!t.headless&&(M0(t.prosemirrorView.root),r.dataTransfer.setDragImage(nn,0,0),r.dataTransfer.effectAllowed="move")},rowDragStart(r){if(e.state===void 0||e.state.rowIndex===void 0)throw Error("Attempted to drag table row, but no table block was hovered prior.");e.state.draggingState={draggedCellOrientation:"row",originalIndex:e.state.rowIndex,mousePos:r.clientY},e.emitUpdate(),t.transact(o=>o.setMeta(Is,{draggedCellOrientation:e.state.draggingState.draggedCellOrientation,originalIndex:e.state.rowIndex,newIndex:e.state.rowIndex,tablePos:e.tablePos})),!t.headless&&(M0(t.prosemirrorView.root),r.dataTransfer.setDragImage(nn,0,0),r.dataTransfer.effectAllowed="copyMove")},dragEnd(){if(e.state===void 0)throw Error("Attempted to drag table row, but no table block was hovered prior.");e.state.draggingState=void 0,e.emitUpdate(),t.transact(r=>r.setMeta(Is,null)),!t.headless&&f8(t.prosemirrorView.root)},freezeHandles(){e.menuFrozen=!0},unfreezeHandles(){e.menuFrozen=!1},hideHandlesIfNotFrozen(){var r;!e.menuFrozen&&((r=e.state)!=null&&r.show)&&(e.state.show=!1,e.state.showAddOrRemoveRowsButton=!1,e.state.showAddOrRemoveColumnsButton=!1,e.emitUpdate())},getCellsAtRowHandle(r,o){return vh(r,o)},getCellsAtColumnHandle(r,o){return wh(r,o)},setCellSelection(r,o,i=o){if(!e)throw Error("Table handles view not initialized");let s=r.doc.resolve(e.tablePos+1),l=r.doc.resolve(s.posAtIndex(o.row)+1),a=r.doc.resolve(l.posAtIndex(o.col)),c=r.doc.resolve(s.posAtIndex(i.row)+1),d=r.doc.resolve(c.posAtIndex(i.col)),u=r.tr;return u.setSelection(new Ae(a,d)),r.apply(u)},addRowOrColumn(r,o){t.exec((i,s)=>{let l=this.setCellSelection(i,o.orientation==="row"?{row:r,col:0}:{row:0,col:r});return o.orientation==="row"?o.side==="above"?b_(l,s):y_(l,s):o.side==="left"?f_(l,s):h_(l,s)})},removeRowOrColumn(r,o){return o==="row"?t.exec((i,s)=>w_(this.setCellSelection(i,{row:r,col:0}),s)):t.exec((i,s)=>m_(this.setCellSelection(i,{row:0,col:r}),s))},mergeCells(r){return t.exec((o,i)=>x_(r?this.setCellSelection(o,r.relativeStartCell,r.relativeEndCell):o,i))},splitCell(r){return t.exec((o,i)=>C_(r?this.setCellSelection(o,r):o,i))},getCellSelection(){return t.transact(r=>{let o=r.selection,i=o.$from,s=o.$to;if(Ch(o)){let{ranges:m}=o;m.forEach(g=>{i=g.$from.min(i??g.$from),s=g.$to.max(s??g.$to)})}else if(i=r.doc.resolve(o.$from.pos-o.$from.parentOffset-1),s=r.doc.resolve(o.$to.pos-o.$to.parentOffset-1),i.pos===0||s.pos===0)return;let l=r.doc.resolve(i.pos-i.parentOffset-1),a=r.doc.resolve(s.pos-s.parentOffset-1),c=r.doc.resolve(l.pos-l.parentOffset-1),d=i.index(l.depth),u=l.index(c.depth),f=s.index(a.depth),h=a.index(c.depth),p=[];for(let m=u;m<=h;m++)for(let g=d;g<=f;g++)p.push({row:m,col:g});return{from:{row:u,col:d},to:{row:h,col:f},cells:p}})},getMergeDirection(r){return t.transact(o=>{let i=Ch(o.selection)?o.selection:void 0;if(!i||!r||i.ranges.length<=1)return;let s=this.getCellSelection();if(s)return FL(s.from,s.to,r)?"vertical":"horizontal"})},cropEmptyRowsOrColumns(r,o){return VL(r,o)},addRowsOrColumns(r,o,i){return HL(r,o,i)}}}),Sa=new Ce("trailingNode");function g8(t,e){var o;if(!e)return!1;let n=(o=t.lastChild)==null?void 0:o.lastChild,r=n==null?void 0:n.firstChild;return!((n==null?void 0:n.type.name)==="blockContainer"&&(r==null?void 0:r.type.name)==="paragraph"&&r.content.size===0)}var b8=ve(({editor:t})=>{function e(r){return Me.widget(r,()=>{let o=document.createElement("div");return o.className="bn-trailing-block",o.contentEditable="false",o.addEventListener("mousedown",i=>{var s;i.preventDefault(),t.transact(l=>{let[a]=t.insertBlocks([{type:"paragraph"}],t.document[t.document.length-1],"after");t.setTextCursorPosition(a,"start"),l.scrollIntoView()}),(s=t.prosemirrorView)==null||s.focus()}),o},{side:1})}function n(r,o,i){let s=o.map(r.mapping,r.doc),l=s.find(),a=l.length>0;return a===g8(r.doc,i)?s:a?s.remove(l):s.add(r.doc,[e(r.doc.content.size-1)])}return{key:"trailingNode",prosemirrorPlugins:[new ae({key:Sa,state:{init:(r,o)=>n(o.tr,he.empty,t.isEditable),apply:(r,o)=>!r.docChanged&&!r.getMeta(Sa)?o:n(r,o,t.isEditable)},view(r){let o=r.editable;return{update(i){i.editable!==o&&(o=i.editable,i.dispatch(i.state.tr.setMeta(Sa,!0)))}}},props:{decorations:r=>Sa.getState(r)}})]}}),T0=new Ce("blocknote-show-selection"),Pc=ve(({editor:t})=>{let e=go({enabledSet:new Set},{onUpdate(){t.transact(n=>n.setMeta(T0,{}))}});return{key:"showSelection",store:e,prosemirrorPlugins:[new ae({key:T0,props:{decorations:n=>{let{doc:r,selection:o}=n;if(e.state.enabledSet.size===0)return he.empty;let i=Me.inline(o.from,o.to,{"data-show-selection":"true"});return he.create(r,[i])}}})],showSelection(n,r){e.setState({enabledSet:n?new Set([...e.state.enabledSet,r]):new Set([...e.state.enabledSet].filter(o=>o!==r))})}}}),y8={slash_menu:{heading:{title:"Heading 1",subtext:"Top-level heading",aliases:["h","heading1","h1"],group:"Headings"},heading_2:{title:"Heading 2",subtext:"Key section heading",aliases:["h2","heading2","subheading"],group:"Headings"},heading_3:{title:"Heading 3",subtext:"Subsection and group heading",aliases:["h3","heading3","subheading"],group:"Headings"},heading_4:{title:"Heading 4",subtext:"Minor subsection heading",aliases:["h4","heading4","subheading4"],group:"Subheadings"},heading_5:{title:"Heading 5",subtext:"Small subsection heading",aliases:["h5","heading5","subheading5"],group:"Subheadings"},heading_6:{title:"Heading 6",subtext:"Lowest-level heading",aliases:["h6","heading6","subheading6"],group:"Subheadings"},toggle_heading:{title:"Toggle Heading 1",subtext:"Toggleable top-level heading",aliases:["h","heading1","h1","collapsable"],group:"Subheadings"},toggle_heading_2:{title:"Toggle Heading 2",subtext:"Toggleable key section heading",aliases:["h2","heading2","subheading","collapsable"],group:"Subheadings"},toggle_heading_3:{title:"Toggle Heading 3",subtext:"Toggleable subsection and group heading",aliases:["h3","heading3","subheading","collapsable"],group:"Subheadings"},quote:{title:"Quote",subtext:"Quote or excerpt",aliases:["quotation","blockquote","bq"],group:"Basic blocks"},toggle_list:{title:"Toggle List",subtext:"List with hideable sub-items",aliases:["li","list","toggleList","toggle list","collapsable list"],group:"Basic blocks"},numbered_list:{title:"Numbered List",subtext:"List with ordered items",aliases:["ol","li","list","numberedlist","numbered list"],group:"Basic blocks"},bullet_list:{title:"Bullet List",subtext:"List with unordered items",aliases:["ul","li","list","bulletlist","bullet list"],group:"Basic blocks"},check_list:{title:"Check List",subtext:"List with checkboxes",aliases:["ul","li","list","checklist","check list","checked list","checkbox"],group:"Basic blocks"},paragraph:{title:"Paragraph",subtext:"The body of your document",aliases:["p","paragraph"],group:"Basic blocks"},code_block:{title:"Code Block",subtext:"Code block with syntax highlighting",aliases:["code","pre"],group:"Basic blocks"},page_break:{title:"Page Break",subtext:"Page separator",aliases:["page","break","separator"],group:"Basic blocks"},table:{title:"Table",subtext:"Table with editable cells",aliases:["table"],group:"Advanced"},image:{title:"Image",subtext:"Resizable image with caption",aliases:["image","imageUpload","upload","img","picture","media","url"],group:"Media"},video:{title:"Video",subtext:"Resizable video with caption",aliases:["video","videoUpload","upload","mp4","film","media","url"],group:"Media"},audio:{title:"Audio",subtext:"Embedded audio with caption",aliases:["audio","audioUpload","upload","mp3","sound","media","url"],group:"Media"},file:{title:"File",subtext:"Embedded file",aliases:["file","upload","embed","media","url"],group:"Media"},emoji:{title:"Emoji",subtext:"Search for and insert an emoji",aliases:["emoji","emote","emotion","face"],group:"Others"},divider:{title:"Divider",subtext:"Visually divide blocks",aliases:["divider","hr","line","horizontal rule"],group:"Basic blocks"}},placeholders:{default:"Enter text or type '/' for commands",heading:"Heading",toggleListItem:"Toggle",bulletListItem:"List",numberedListItem:"List",checkListItem:"List",emptyDocument:void 0,new_comment:"Write a comment...",edit_comment:"Edit comment...",comment_reply:"Add comment..."},file_blocks:{add_button_text:{image:"Add image",video:"Add video",audio:"Add audio",file:"Add file"}},toggle_blocks:{add_block_button:"Empty toggle. Click to add a block."},side_menu:{add_block_label:"Add block",drag_handle_label:"Open block menu"},drag_handle:{delete_menuitem:"Delete",colors_menuitem:"Colors",header_row_menuitem:"Header row",header_column_menuitem:"Header column"},table_handle:{delete_column_menuitem:"Delete column",delete_row_menuitem:"Delete row",add_left_menuitem:"Add column left",add_right_menuitem:"Add column right",add_above_menuitem:"Add row above",add_below_menuitem:"Add row below",split_cell_menuitem:"Split cell",merge_cells_menuitem:"Merge cells",background_color_menuitem:"Background color"},suggestion_menu:{no_items_title:"No items found"},color_picker:{text_title:"Text",background_title:"Background",colors:{default:"Auto",gray:"Gray",brown:"Brown",red:"Red",orange:"Orange",yellow:"Yellow",green:"Green",blue:"Blue",purple:"Purple",pink:"Pink"}},formatting_toolbar:{bold:{tooltip:"Bold",secondary_tooltip:"Mod+B"},italic:{tooltip:"Italic",secondary_tooltip:"Mod+I"},underline:{tooltip:"Underline",secondary_tooltip:"Mod+U"},strike:{tooltip:"Strike",secondary_tooltip:"Mod+Shift+S"},code:{tooltip:"Code",secondary_tooltip:""},colors:{tooltip:"Colors"},link:{tooltip:"Create link",secondary_tooltip:"Mod+K"},file_caption:{tooltip:"Edit caption",input_placeholder:"Edit caption"},file_replace:{tooltip:{image:"Replace image",video:"Replace video",audio:"Replace audio",file:"Replace file"}},file_rename:{tooltip:{image:"Rename image",video:"Rename video",audio:"Rename audio",file:"Rename file"},input_placeholder:{image:"Rename image",video:"Rename video",audio:"Rename audio",file:"Rename file"}},file_download:{tooltip:{image:"Download image",video:"Download video",audio:"Download audio",file:"Download file"}},file_delete:{tooltip:{image:"Delete image",video:"Delete video",audio:"Delete audio",file:"Delete file"}},file_preview_toggle:{tooltip:"Toggle preview"},nest:{tooltip:"Nest block",secondary_tooltip:"Tab"},unnest:{tooltip:"Unnest block",secondary_tooltip:"Shift+Tab"},align_left:{tooltip:"Align text left"},align_center:{tooltip:"Align text center"},align_right:{tooltip:"Align text right"},align_justify:{tooltip:"Justify text"},table_cell_merge:{tooltip:"Merge cells"},comment:{tooltip:"Add comment"}},file_panel:{upload:{title:"Upload",file_placeholder:{image:"Upload image",video:"Upload video",audio:"Upload audio",file:"Upload file"},upload_error:"Error: Upload failed"},embed:{title:"Embed",embed_button:{image:"Embed image",video:"Embed video",audio:"Embed audio",file:"Embed file"},url_placeholder:"Enter URL"}},link_toolbar:{delete:{tooltip:"Remove link"},edit:{text:"Edit link",tooltip:"Edit"},open:{tooltip:"Open in new tab"},form:{title_placeholder:"Edit title",url_placeholder:"Edit URL"}},comments:{edited:"edited",save_button_text:"Save",cancel_button_text:"Cancel",deleted_reference_text:"Original content deleted",actions:{add_reaction:"Add reaction",resolve:"Resolve",reopen:"Re-open",edit_comment:"Edit comment",delete_comment:"Delete comment",more_actions:"More actions"},reactions:{reacted_by:"Reacted by"},sidebar:{marked_as_resolved:"Marked as resolved",more_replies:t=>`${t} more replies`}},generic:{ctrl_shortcut:"Ctrl"}},wm=class{constructor(){B(this,"callbacks",{})}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),()=>this.off(e,n)}emit(e,...n){let r=this.callbacks[e];r&&r.forEach(o=>o.apply(this,n))}off(e,n){let r=this.callbacks[e];r&&(n?this.callbacks[e]=r.filter(o=>o!==n):delete this.callbacks[e])}removeAllListeners(){this.callbacks={}}};class ai{constructor(e,n,r={}){B(this,"match");B(this,"handler");B(this,"undoable");B(this,"inCode");B(this,"inCodeMark");this.match=e,this.match=e,this.handler=typeof n=="string"?v8(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function v8(t){return function(e,n,r,o){let i=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);i+=n[0].slice(s+n[1].length),r+=s;let l=r-o;l>0&&(i=n[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}const w8=500;function k8({rules:t}){let e=new ae({state:{init(){return null},apply(n,r){let o=n.getMeta(this);return o||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,o,i){return A0(n,r,o,i,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&A0(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function A0(t,e,n,r,o,i){if(t.composing)return!1;const s=t.state.tr.insertText(r,e,n),l=s.mapping.map(e),a=s.mapping.map(n);let c=null,d=s.doc.resolve(l),u=d.parent.textBetween(Math.max(0,d.parentOffset-w8),d.parentOffset,null,"");for(let f=0;f<o.length;f++){let h=o[f];if(!h.inCodeMark&&d.marks().some(g=>g.type.spec.code))continue;if(d.parent.type.spec.code){if(!h.inCode)continue}else if(h.inCode==="only")continue;let p=h.match.exec(u);if(!p||p[0].length<r.length)continue;c??(c=t.state.apply(s));let m=h.handler(c,p,l-p[0].length,a);if(m)return t.dispatch(s),t.dispatch(h7(t.state.tr)),h.undoable&&m.setMeta(i,{transform:m,from:l,to:a,text:r}),t.dispatch(m),!0}return!1}new ai(/--$/,"—",{inCodeMark:!1});new ai(/\.\.\.$/,"…",{inCodeMark:!1});new ai(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new ai(/"$/,"”",{inCodeMark:!1});new ai(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new ai(/'$/,"’",{inCodeMark:!1});class Je extends ee{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Je.valid(r)?new Je(r):ee.near(r)}content(){return j.empty}eq(e){return e instanceof Je&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Je(e.resolve(n.pos))}getBookmark(){return new km(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!x8(e)||!C8(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Je.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=n;let a=e.doc.resolve(o);if(Je.valid(a))return a}for(;;){let s=n>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!G.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*n),r=!1;continue e}break}i=s,o+=n;let l=e.doc.resolve(o);if(Je.valid(l))return l}return null}}}Je.prototype.visible=!1;Je.findFrom=Je.findGapCursorFrom;ee.jsonID("gapcursor",Je);class km{constructor(e){this.pos=e}map(e){return new km(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Je.valid(n)?new Je(n):ee.near(n)}}function tS(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function x8(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||tS(o.type))return!0;if(o.inlineContent)return!1}}return!0}function C8(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||tS(o.type))return!0;if(o.inlineContent)return!1}}return!0}function S8(){return new ae({props:{decorations:A8,createSelectionBetween(t,e,n){return e.pos==n.pos&&Je.valid(n)?new Je(n):null},handleClick:M8,handleKeyDown:E8,handleDOMEvents:{beforeinput:T8}}})}const E8=gp({ArrowLeft:Ea("horiz",-1),ArrowRight:Ea("horiz",1),ArrowUp:Ea("vert",-1),ArrowDown:Ea("vert",1)});function Ea(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof W){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Je.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new Je(c))),!0):!1}}function M8(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Je.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&G.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Je(r))),!0)}function T8(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Je))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=I.empty;for(let s=r.length-1;s>=0;s--)o=I.from(r[s].createAndFill(null,o));let i=t.state.tr.replace(n.pos,n.pos,new j(o,0,0));return i.setSelection(W.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function A8(t){if(!(t.selection instanceof Je))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",he.create(t.doc,[Me.widget(t.selection.head,e,{key:"gapcursor"})])}var N8=Ge.create({name:"gapCursor",addProseMirrorPlugins(){return[S8()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ne(K(t,"allowGapCursor",n)))!=null?e:null}}}),R8=Kn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});function I8(t,e,n,r="before"){let o=typeof n=="string"?n:n.id,i=st(t),s=e.map(c=>{let d=si(c,i);return d.check(),d}),l=Ht(o,t.doc);if(!l)throw Error(`Block with ID ${o} not found`);let a=l.posBeforeNode;return r==="after"&&(a+=l.node.nodeSize),t.step(new Ke(a,a,new j(I.from(s),0,0))),s.map(c=>qe(c,i))}function Th(t){if(!t||t.type.name!=="column")throw Error("Invalid columnPos: does not point to column node.");let e=t.firstChild;if(!e)throw Error("Invalid column: does not have child node.");let n=e.firstChild;if(!n)throw Error("Invalid blockContainer: does not have child node.");return t.childCount===1&&e.childCount===1&&n.type.name==="paragraph"&&n.content.content.length===0}function O8(t,e){let n=t.doc.resolve(e),r=n.nodeAfter;if(!r||r.type.name!=="columnList")throw Error("Invalid columnListPos: does not point to columnList node.");for(let o=r.childCount-1;o>=0;o--){let i=t.doc.resolve(n.pos+1).posAtIndex(o),s=t.doc.resolve(i).nodeAfter;if(!s||s.type.name!=="column")throw Error("Invalid columnPos: does not point to column node.");Th(s)&&t.delete(i,i+s.nodeSize)}}function Ja(t,e){O8(t,e);let n=t.doc.resolve(e).nodeAfter;if(!n||n.type.name!=="columnList")throw Error("Invalid columnListPos: does not point to columnList node.");if(n.childCount>2)return;if(n.childCount<2)throw Error("Invalid columnList: contains fewer than two children.");let r=e+1,o=t.doc.resolve(r).nodeAfter,i=e+n.nodeSize-1,s=t.doc.resolve(i).nodeBefore;if(!o||!s)throw Error("Invalid columnList: does not contain children.");let l=Th(o),a=Th(s);if(l&&a){t.delete(e,e+n.nodeSize);return}if(l){t.step(new Ye(e,e+n.nodeSize,i-s.nodeSize+1,i-1,j.empty,0,!1));return}if(a){t.step(new Ye(e,e+n.nodeSize,r+1,r+o.nodeSize-1,j.empty,0,!1));return}}function N0(t,e,n){let r=st(t),o=n.map(d=>{let u=si(d,r);return u.check(),u}),i=new Set(e.map(d=>typeof d=="string"?d:d.id)),s=[],l=new Set,a=typeof e[0]=="string"?e[0]:e[0].id,c=0;if(t.doc.descendants((d,u)=>{if(i.size===0)return!1;if(!d.type.isInGroup("bnBlock")||!i.has(d.attrs.id))return!0;if(s.push(qe(d,r)),i.delete(d.attrs.id),n.length>0&&d.attrs.id===a){let m=t.doc.nodeSize;t.insert(u,o);let g=t.doc.nodeSize;c+=m-g}let f=t.doc.nodeSize,h=t.doc.resolve(u-c);h.node().type.name==="column"?l.add(h.before(-1)):h.node().type.name==="columnList"&&l.add(h.before()),h.node().type.name==="blockGroup"&&h.node(h.depth-1).type.name!=="doc"&&h.node().childCount===1?t.delete(h.before(),h.after()):t.delete(u-c,u-c+d.nodeSize);let p=t.doc.nodeSize;return c+=f-p,!1}),i.size>0){let d=[...i].join(`
189
+ `);throw Error("Blocks with the following IDs could not be found in the editor: "+d)}return l.forEach(d=>Ja(t,d)),{insertedBlocks:o.map(d=>qe(d,r)),removedBlocks:s}}function D8(t,e,n,r,o){let i;if(!e)throw Error("blockContent is required");if(typeof e=="string")i=Gn([e],t.pmSchema,r);else if(Array.isArray(e))i=Gn(e,t.pmSchema,r);else if(e.type==="tableContent")i=Ad(e,t.pmSchema);else throw new dr(e.type);let s=((o==null?void 0:o.document)??document).createDocumentFragment();for(let l of i)if(l.type.name!=="text"&&t.schema.inlineContentSchema[l.type.name]){let a=t.schema.inlineContentSpecs[l.type.name].implementation;if(a){let c=um(l,t.schema.inlineContentSchema,t.schema.styleSchema),d=a.render.call({renderType:"dom",props:void 0},c,()=>{},t);if(d){if(s.appendChild(d.dom),d.contentDOM){let u=n.serializeFragment(l.content,o);d.contentDOM.dataset.editable="",d.contentDOM.appendChild(u)}continue}}}else if(l.type.name==="text"){let a=document.createTextNode(l.textContent);for(let c of l.marks.toReversed())if(c.type.name in t.schema.styleSpecs){let d=t.schema.styleSpecs[c.type.name].implementation.render(c.attrs.stringValue,t);d.contentDOM.appendChild(a),a=d.dom}else{let d=c.type.spec.toDOM(c,!0),u=cn.renderSpec(document,d);u.contentDOM.appendChild(a),a=u.dom}s.appendChild(a)}else{let a=n.serializeFragment(I.from([l]),o);s.appendChild(a)}return s}function _8(t,e,n,r){var c,d,u,f,h;let o=t.pmSchema.nodes.blockContainer,i=e.props||{};for(let[p,m]of Object.entries(t.schema.blockSchema[e.type].propSchema))!(p in i)&&m.default!==void 0&&(i[p]=m.default);let s=e.children||[],l=t.blockImplementations[e.type].implementation.render.call({renderType:"dom",props:void 0},{...e,props:i,children:s},t);if(l.contentDOM&&e.content){let p=D8(t,e.content,n,e.type,r);l.contentDOM.appendChild(p)}if(t.pmSchema.nodes[e.type].isInGroup("bnBlock")){if(e.children&&e.children.length>0){let p=nS(t,e.children,n,r);(c=l.contentDOM)==null||c.append(p)}return l.dom}let a=(u=(d=o.spec)==null?void 0:d.toDOM)==null?void 0:u.call(d,o.create({id:e.id,...i}));return(f=a.contentDOM)==null||f.appendChild(l.dom),e.children&&e.children.length>0&&((h=a.contentDOM)==null||h.appendChild(rS(t,e.children,n,r))),a.dom}function nS(t,e,n,r){let o=((r==null?void 0:r.document)??document).createDocumentFragment();for(let i of e){let s=_8(t,i,n,r);o.appendChild(s)}return o}var rS=(t,e,n,r)=>{var l;let o=t.pmSchema.nodes.blockGroup,i=o.spec.toDOM(o.create({})),s=nS(t,e,n,r);return(l=i.contentDOM)==null||l.appendChild(s),i.dom},P8=t=>(t.querySelectorAll('[data-content-type="numberedListItem"]').forEach(e=>{var r,o;let n=(o=(r=e.closest(".bn-block-outer"))==null?void 0:r.previousElementSibling)==null?void 0:o.querySelector('[data-content-type="numberedListItem"]');if(!n)e.setAttribute("data-index",e.getAttribute("data-start")||"1");else{let i=n.getAttribute("data-index");e.setAttribute("data-index",(parseInt(i||"0")+1).toString())}}),t),$8=t=>(t.querySelectorAll('[data-content-type="checkListItem"] input').forEach(e=>{e.disabled=!0}),t),L8=t=>(t.querySelectorAll('.bn-toggle-wrapper[data-show-children="false"]').forEach(e=>{e.setAttribute("data-show-children","true")}),t),B8=t=>(t.querySelectorAll('[data-content-type="table"] table').forEach(e=>{e.setAttribute("style","--default-cell-min-width: 120px;"),e.setAttribute("data-show-children","true")}),t),j8=t=>(t.querySelectorAll('[data-content-type="table"] table').forEach(e=>{var o;let n=document.createElement("div");n.className="tableWrapper";let r=document.createElement("div");r.className="tableWrapper-inner",n.appendChild(r),(o=e.parentElement)==null||o.appendChild(n),n.appendChild(e)}),t),V8=t=>(t.querySelectorAll(".bn-inline-content:empty").forEach(e=>{let n=document.createElement("span");n.className="ProseMirror-trailingBreak",n.setAttribute("style","display: inline-block;"),e.appendChild(n)}),t),H8=(t,e)=>{let n=cn.fromSchema(t),r=[P8,$8,L8,B8,j8,V8];return{serializeBlocks:(o,i)=>{let s=rS(e,o,n,i);for(let l of r)s=l(s);return s.outerHTML}}};function F8(t){return t.transact(e=>{let n=co(e.doc,e.selection.anchor);if(e.selection instanceof Ae)return{type:"cell",anchorBlockId:n.node.attrs.id,anchorCellOffset:e.selection.$anchorCell.pos-n.posBeforeNode,headCellOffset:e.selection.$headCell.pos-n.posBeforeNode};if(e.selection instanceof G)return{type:"node",anchorBlockId:n.node.attrs.id};{let r=co(e.doc,e.selection.head);return{type:"text",anchorBlockId:n.node.attrs.id,headBlockId:r.node.attrs.id,anchorOffset:e.selection.anchor-n.posBeforeNode,headOffset:e.selection.head-r.posBeforeNode}}})}function z8(t,e){var o,i;let n=(o=Ht(e.anchorBlockId,t.doc))==null?void 0:o.posBeforeNode;if(n===void 0)throw Error(`Could not find block with ID ${e.anchorBlockId} to update selection`);let r;if(e.type==="cell")r=Ae.create(t.doc,n+e.anchorCellOffset,n+e.headCellOffset);else if(e.type==="node")r=G.create(t.doc,n+1);else{let s=(i=Ht(e.headBlockId,t.doc))==null?void 0:i.posBeforeNode;if(s===void 0)throw Error(`Could not find block with ID ${e.headBlockId} to update selection`);r=W.create(t.doc,n+e.anchorOffset,s+e.headOffset)}t.setSelection(r)}function U8(t){return t.flatMap(e=>e.type==="column"?e.children:[e])}function xm(t,e,n,r){t.transact(()=>{let o=t.getBlock(n);if((o==null?void 0:o.type)==="columnList"){let i=r==="after"?t.getNextBlock(o):t.getPrevBlock(o);i&&(n=i,r=r==="after"?"before":"after")}t.removeBlocks(e),t.insertBlocks(U8(e),n,r)})}function oS(t,e,n){t.transact(r=>{var s;let o=((s=t.getSelection())==null?void 0:s.blocks)||[t.getTextCursorPosition().block],i=F8(t);xm(t,o,e,n),z8(r,i)})}function iS(t){return!t||t.type!=="columnList"}function sS(t,e,n){let r,o;if(e?e.children.length>0?(r=e.children[e.children.length-1],o="after"):(r=e,o="before"):n&&(r=n,o="before"),!r||!o)return;let i=t.getParentBlock(r);return iS(i)?{referenceBlock:r,placement:o}:sS(t,o==="after"?r:t.getPrevBlock(r),i)}function lS(t,e,n){let r,o;if(e?e.children.length>0?(r=e.children[0],o="before"):(r=e,o="after"):n&&(r=n,o="after"),!r||!o)return;let i=t.getParentBlock(r);return iS(i)?{referenceBlock:r,placement:o}:lS(t,o==="before"?r:t.getNextBlock(r),i)}function W8(t,e){t.transact(()=>{var o;let n;if(e){if(n=t.getBlock(e),!n)return}else n=((o=t.getSelection())==null?void 0:o.blocks[0])||t.getTextCursorPosition().block;let r=sS(t,t.getPrevBlock(n),t.getParentBlock(n));r&&(e?xm(t,[n],r.referenceBlock,r.placement):oS(t,r.referenceBlock,r.placement))})}function q8(t,e){t.transact(()=>{let n;if(e){if(n=t.getBlock(e),!n)return}else{let o=t.getSelection();n=(o==null?void 0:o.blocks[(o==null?void 0:o.blocks.length)-1])||t.getTextCursorPosition().block}let r=lS(t,t.getNextBlock(n),t.getParentBlock(n));r&&(e?xm(t,[n],r.referenceBlock,r.placement):oS(t,r.referenceBlock,r.placement))})}function G8(t,e,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,h=>h.childCount>0&&(h.type.name==="blockGroup"||h.type.name==="column"));if(!i)return!1;let s=i.startIndex;if(s===0)return!1;let l=i.parent.child(s-1);if(l.type!==e)return!1;let a=l.lastChild&&l.lastChild.type===n,c=I.from(a?e.create():null),d=new j(I.from(e.create(null,I.from(n.create(null,c)))),a?3:1,0),u=i.start,f=i.end;return t.step(new Ye(u-(a?3:1),f,u,f,d,1,!0)).scrollIntoView(),!0}function aS(t){return t.transact(e=>G8(e,t.pmSchema.nodes.blockContainer,t.pmSchema.nodes.blockGroup))}function Z8(t,e,n,r){let o=r.end,i=r.$to.end(r.depth);if(o<i){let a=r.parent.child(r.endIndex-1),c=a.lastChild&&a.lastChild.type===n;t.step(new Ye(o-(c?2:1),i,o,i,new j(I.from(e.create(null,n.create())),c?2:1,0),+!c,!0)),r=new Zs(t.doc.resolve(r.$from.pos),t.doc.resolve(i),r.depth)}let s=oi(r);if(s==null)return!1;t.lift(r,s);let l=t.doc.resolve(t.mapping.map(o,-1)-1);return bo(t.doc,l.pos)&&l.nodeBefore.type===l.nodeAfter.type&&t.join(l.pos),t.scrollIntoView(),!0}function Ah(t,e,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,s=>s.childCount>0&&(s.type.name==="blockGroup"||s.type.name==="column"));return i&&r.node(i.depth-1).type===e?Z8(t,e,n,i):!1}function cS(t){return t.transact(e=>Ah(e,t.pmSchema.nodes.blockContainer,t.pmSchema.nodes.blockGroup))}function K8(t){return t.transact(e=>{let{bnBlock:n}=Hl(e);return e.doc.resolve(n.beforePos).nodeBefore!==null})}function J8(t){return t.transact(e=>{let{bnBlock:n}=Hl(e);return e.doc.resolve(n.beforePos).depth>1})}function Y8(t,e){let n=typeof e=="string"?e:e.id,r=st(t),o=Ht(n,t);if(o)return qe(o.node,r)}function X8(t,e){let n=Ht(typeof e=="string"?e:e.id,t),r=st(t);if(!n)return;let o=t.resolve(n.posBeforeNode).nodeBefore;if(o)return qe(o,r)}function Q8(t,e){let n=Ht(typeof e=="string"?e:e.id,t),r=st(t);if(!n)return;let o=t.resolve(n.posBeforeNode+n.node.nodeSize).nodeAfter;if(o)return qe(o,r)}function e9(t,e){let n=typeof e=="string"?e:e.id,r=st(t),o=Ht(n,t);if(!o)return;let i=t.resolve(o.posBeforeNode),s=i.node(),l=i.node(-1),a=l.type.name==="doc"?void 0:s.type.name==="blockGroup"?l:s;if(a)return qe(a,r)}var t9=class{constructor(t){this.editor=t}get document(){return this.editor.transact(t=>AL(t.doc,this.editor.pmSchema))}getBlock(t){return this.editor.transact(e=>Y8(e.doc,t))}getPrevBlock(t){return this.editor.transact(e=>X8(e.doc,t))}getNextBlock(t){return this.editor.transact(e=>Q8(e.doc,t))}getParentBlock(t){return this.editor.transact(e=>e9(e.doc,t))}forEachBlock(t,e=!1){let n=this.document.slice();e&&n.reverse();function r(o){for(let i of o)if(t(i)===!1||!r(e?i.children.slice().reverse():i.children))return!1;return!0}r(n)}insertBlocks(t,e,n="before"){return this.editor.transact(r=>I8(r,t,e,n))}updateBlock(t,e){return this.editor.transact(n=>qL(n,t,e))}removeBlocks(t){return this.editor.transact(e=>N0(e,t,[]).removedBlocks)}replaceBlocks(t,e){return this.editor.transact(n=>N0(n,t,e))}canNestBlock(){return K8(this.editor)}nestBlock(){aS(this.editor)}canUnnestBlock(){return J8(this.editor)}unnestBlock(){cS(this.editor)}moveBlocksUp(t){return W8(this.editor,t)}moveBlocksDown(t){return q8(this.editor,t)}},n9=class extends wm{constructor(t){super(),this.editor=t,t.on("create",()=>{t._tiptapEditor.on("update",({transaction:e,appendedTransactions:n})=>{this.emit("onChange",{editor:t,transaction:e,appendedTransactions:n})}),t._tiptapEditor.on("selectionUpdate",({transaction:e})=>{this.emit("onSelectionChange",{editor:t,transaction:e})}),t._tiptapEditor.on("mount",()=>{this.emit("onMount",{editor:t})}),t._tiptapEditor.on("unmount",()=>{this.emit("onUnmount",{editor:t})})})}onChange(t,e=!0){let n=({transaction:r,appendedTransactions:o})=>{!e&&R0(r)||t(this.editor,{getChanges(){return UC(r,o)}})};return this.on("onChange",n),()=>{this.off("onChange",n)}}onSelectionChange(t,e=!1){let n=r=>{!e&&R0(r.transaction)||t(this.editor)};return this.on("onSelectionChange",n),()=>{this.off("onSelectionChange",n)}}onMount(t){return this.on("onMount",t),()=>{this.off("onMount",t)}}onUnmount(t){return this.on("onUnmount",t),()=>{this.off("onUnmount",t)}}};function R0(t){return!!t.getMeta("y-sync$")}function r9(t){return Array.prototype.indexOf.call(t.parentElement.childNodes,t)}function o9(t){return t.nodeType===3&&!/\S/.test(t.nodeValue||"")}function i9(t){t.querySelectorAll("li > ul, li > ol").forEach(e=>{let n=r9(e),r=e.parentElement,o=Array.from(r.childNodes).slice(n+1);e.remove(),o.forEach(i=>{i.remove()}),r.insertAdjacentElement("afterend",e),o.reverse().forEach(i=>{if(o9(i))return;let s=document.createElement("li");s.append(i),e.insertAdjacentElement("afterend",s)}),r.childNodes.length===0&&r.remove()})}function s9(t){t.querySelectorAll("li + ul, li + ol").forEach(e=>{var i,s;let n=e.previousElementSibling,r=document.createElement("div");n.insertAdjacentElement("afterend",r),r.append(n);let o=document.createElement("div");for(o.setAttribute("data-node-type","blockGroup"),r.append(o);((i=r.nextElementSibling)==null?void 0:i.nodeName)==="UL"||((s=r.nextElementSibling)==null?void 0:s.nodeName)==="OL";)o.append(r.nextElementSibling)})}var l9=null;function a9(){return l9||(l9=document.implementation.createHTMLDocument("title"))}function c9(t){if(typeof t=="string"){let e=a9().createElement("div");e.innerHTML=t,t=e}return i9(t),s9(t),t}function d9(t){let e=t.ownerDocument.createTreeWalker(t,128),n;for(;n=e.nextNode();)if(/^\s*notionvc:/.test(n.nodeValue||""))return!0;return!1}function u9(t){let e=new Set(["PRE","CODE"]),n=t.ownerDocument.createTreeWalker(t,4,{acceptNode(i){let s=i.parentElement;for(;s&&s!==t;){if(e.has(s.tagName))return 2;s=s.parentElement}return 1}}),r=[],o;for(;o=n.nextNode();)r.push(o);for(let i of r)i.nodeValue&&/[\r\n]/.test(i.nodeValue)&&(i.nodeValue=i.nodeValue.replace(/[ \t\r\n\f]+/g," "))}function f9(t){d9(t)||u9(t)}function dS(t,e){let n=c9(t);f9(n);let r=wn.fromSchema(e).parse(n,{topNode:e.nodes.blockGroup.create()}),o=[];for(let i=0;i<r.childCount;i++)o.push(qe(r.child(i),e));return o}function rn(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function I0(t){return t?/\w/.test(t):!1}function Cm(t,e,n){let r=e>0?t[e-1]:void 0,o=e+n<t.length?t[e+n]:void 0;return I0(r)&&I0(o)}function h9(t,e){if(t[e]!=="\\"||e+1>=t.length)return null;let n=t[e+1];return n===`
190
+ `?{html:`<br>
191
+ `,end:e+2}:"\\`*_{}[]()#+-.!~|>".includes(n)?{html:rn(n),end:e+2}:null}function p9(t,e){return t[e]==="`"?N9(t,e):null}function m9(t,e){return t[e]!=="!"||t[e+1]!=="["?null:R9(t,e)}function g9(t,e){return t[e]==="["?I9(t,e):null}function b9(t,e){return t[e]!=="~"||t[e+1]!=="~"?null:_d(t,e,"~~","<del>","</del>")}function y9(t,e){return t[e]==="*"&&t[e+1]==="*"&&t[e+2]==="*"||t[e]==="_"&&t[e+1]==="_"&&t[e+2]==="_"&&!Cm(t,e,3)?_d(t,e,t.substring(e,e+3),"<strong><em>","</em></strong>"):null}function v9(t,e){return t[e]==="*"&&t[e+1]==="*"||t[e]==="_"&&t[e+1]==="_"&&!Cm(t,e,2)?_d(t,e,t.substring(e,e+2),"<strong>","</strong>"):null}function w9(t,e){return t[e]==="*"||t[e]==="_"&&!Cm(t,e,1)?_d(t,e,t[e],"<em>","</em>"):null}function k9(t,e){return t[e]===`
192
+ `?{html:`<br>
193
+ `,end:e+1}:null}var x9=/^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/,C9=/^<!--[\s\S]*?-->/,S9=/^<!\[CDATA\[[\s\S]*?\]\]>/,E9=/^<\?[\s\S]*?\?>/,M9=/^<![A-Za-z][\s\S]*?>/;function T9(t,e){if(t[e]!=="<")return null;let n=t.substring(e);for(let r of[C9,S9,E9,M9,x9]){let o=n.match(r);if(o)return{html:o[0],end:e+o[0].length}}return null}var O0=new Set("\\`![~*_\n<"),A9=[h9,p9,m9,g9,b9,y9,v9,w9,T9,k9];function fo(t){let e="",n=0;for(;n<t.length;){if(t[n]===`
194
+ `&&n>=2&&t[n-1]===" "&&t[n-2]===" "){e=e.replace(/ +$/,""),e+=`<br>
195
+ `,n++;continue}let r=!1;if(O0.has(t[n]))for(let o of A9){let i=o(t,n);if(i){e+=i.html,n=i.end,r=!0;break}}if(!r){let o=n;for(n++;n<t.length&&!O0.has(t[n]);)n++;e+=rn(t.substring(o,n))}}return e}function N9(t,e){let n=0,r=e;for(;r<t.length&&t[r]==="`";)n++,r++;let o=r;for(;o<t.length;)if(t[o]==="`"){let i=0,s=o;for(;o<t.length&&t[o]==="`";)i++,o++;if(i===n){let l=t.substring(r,s);return l=l.replace(/\n/g," "),l.length>=2&&l[0]===" "&&l[l.length-1]===" "&&/[^ ]/.test(l)&&(l=l.substring(1,l.length-1)),{html:`<code>${rn(l)}</code>`,end:o}}}else o++;return null}function R9(t,e){let n=uS(t,e+1);if(n===-1)return null;let r=e+2;if(t[n+1]!=="(")return null;let o=n+2,i=fS(t,o-1);if(i===-1)return null;let s=t.substring(r,n),{url:l,title:a}=hS(t.substring(o,i));if(xL(l)){let d=s||a;return{html:`<video src="${rn(l)}"${d?` data-name="${rn(d)}"`:""} data-url="${rn(l)}" controls></video>`,end:i+1}}let c=a===void 0?"":` title="${rn(a)}"`;return{html:`<img src="${rn(l)}" alt="${rn(s)}"${c}>`,end:i+1}}function I9(t,e){let n=e+1,r=uS(t,e);if(r===-1||t[r+1]!=="(")return null;let o=r+2,i=fS(t,r+1);if(i===-1)return null;let s=t.substring(n,r),{url:l,title:a}=hS(t.substring(o,i)),c=a===void 0?"":` title="${rn(a)}"`;return{html:`<a href="${rn(l)}"${c}>${fo(s)}</a>`,end:i+1}}function uS(t,e){let n=0;for(let r=e;r<t.length;r++){if(t[r]==="\\"&&r+1<t.length){r++;continue}if(t[r]==="["&&n++,t[r]==="]"&&(n--,n===0))return r}return-1}function fS(t,e){let n=0;for(let r=e;r<t.length;r++){if(t[r]==="\\"&&r+1<t.length){r++;continue}if(t[r]==="("&&n++,t[r]===")"&&(n--,n===0))return r}return-1}function hS(t){t=t.trim();let e,n;if(t.startsWith("<")){let o=t.indexOf(">");o===-1?(e=t.substring(1),n=""):(e=t.substring(1,o),n=t.substring(o+1).trim())}else{let o=t.length;for(let i=0;i<t.length;i++){if(t[i]==="\\"&&i+1<t.length){i++;continue}if(t[i]===" "||t[i]===" "||t[i]===`
196
+ `){o=i;break}}e=t.substring(0,o),n=t.substring(o).trim()}let r;if(n.length>0){let o=n.match(/^"([^"]*)"$|^'([^']*)'$|^\(([^)]*)\)$/);o&&(r=o[1]??o[2]??o[3])}return{url:e,title:r}}function _d(t,e,n,r,o){let i=n.length,s=e+i;if(s>=t.length||t[s]===" "||t[s]===" ")return null;let l=s;for(;l<t.length;){if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(t.substring(l,l+i)===n){if(t[l-1]===" "||t[l-1]===" "){l++;continue}if(i===1&&(l>0&&t[l-1]===n[0]&&!(l>=2&&t[l-2]==="\\")||l+i<t.length&&t[l+i]===n[0])){l++;continue}let a=t.substring(s,l);if(a.length===0){l++;continue}return{html:r+fo(a)+o,end:l+i}}l++}return null}var O9=new Set("address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));function D0(t){if(/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(t))return!0;let e=t.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);return e?O9.has(e[1].toLowerCase()):!1}function Sm(t){let e=t.split(`
197
+ `),n=[],r=0,o=!0;for(;r<e.length;){let i=e[r];if(i.trim()===""){o=!0,r++;continue}let s=i.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);if(s){let u=s[1],f=u[0],h=u.length,p=s[2].trim(),m=[];for(r++;r<e.length;){if(e[r].match(RegExp(`^ {0,3}${f}{${h},}\\s*$`))){r++;break}m.push(e[r]),r++}n.push({type:"codeBlock",language:p||"",code:m.join(`
198
+ `)}),o=!1;continue}let l=i.match(/^(#{1,6})\s+(.+?)(?:\s+#+\s*|\s*)$/);if(l){n.push({type:"heading",level:l[1].length,content:l[2]}),o=!1,r++;continue}if(/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(i)){let u=n[n.length-1];if(!o&&i.trim().match(/^-+$/)&&u&&u.type==="paragraph"){let f=u;n[n.length-1]={type:"heading",level:2,content:f.content},o=!1,r++;continue}n.push({type:"hr"}),o=!1,r++;continue}if(r+1<e.length){let u=e[r+1];if(/^={1,}\s*$/.test(u)&&i.trim().length>0){n.push({type:"heading",level:1,content:i.trim()}),o=!1,r+=2;continue}}let a=D9(e,r);if(a){n.push(a.token),r=a.nextLine,o=!1;continue}if(/^\s{0,3}>/.test(i)){let u=[];for(;r<e.length&&/^\s{0,3}>/.test(e[r]);)u.push(e[r].replace(/^\s{0,3}>\s?/,"")),r++;for(;r<e.length;){let f=e[r];if(f.trim()===""||/^\s{0,3}>/.test(f)||/^(#{1,6})\s/.test(f)||/^(`{3,}|~{3,})/.test(f)||/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(f)||/^\s*([-*+]|\d+[.)])\s+/.test(f)||/^\s*\|(.+\|)+\s*$/.test(f))break;u.push(f),r++}n.push({type:"blockquote",content:u.join(`
199
+ `)}),o=!1;continue}let c=i.match(/^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)$/);if(c){let u=c[1].length,f=c[2],h=c[3],p=c[4],m=c[5],g,y,w;p?(g="task",w=p.trim()!=="[ ]"):/^\d+[.)]$/.test(f)?(g="ordered",y=parseInt(f,10)):g="bullet";let k=u+f.length+h.length+(p?p.length:0),x=u+1,C=M=>{if(M.trim()==="")return!0;let N=M.match(/^\s*/)[0].length;return!!(N>=k||N>=x&&M.match(/^\s*([-*+]|\d+[.)])\s+/))};r++;let E=[];for(;r<e.length;){let M=e[r];if(M.trim()===""){let N=r+1;for(;N<e.length&&e[N].trim()==="";)N++;if(N<e.length&&C(e[N])){E.push(""),r++;continue}break}if(!C(M))break;M.match(/^\s*/)[0].length>=k?E.push(M.substring(k)):E.push(M.substring(x)),r++}let S=E.join(`
200
+ `).replace(/^\n+|\n+$/g,"");n.push({type:"listItem",listType:g,indent:u,content:m.trim(),start:y,checked:w,childContent:S||void 0}),o=!1;continue}if(D0(i)){let u=[];for(;r<e.length&&e[r].trim()!=="";)u.push(e[r]),r++;n.push({type:"rawHtml",content:u.join(`
201
+ `)}),o=!1;continue}let d=[i];for(r++;r<e.length;){let u=e[r];if(u.trim()===""||/^(#{1,6})\s/.test(u)||/^(`{3,}|~{3,})/.test(u)||/^\s{0,3}>/.test(u)||/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(u)||/^\s*([-*+]|\d+[.)])\s+/.test(u)||/^\s*\|(.+\|)+\s*$/.test(u)||D0(u)||r+1<e.length&&/^[=-]+\s*$/.test(e[r+1])&&u.trim().length>0)break;d.push(u),r++}n.push({type:"paragraph",content:d.map(u=>u.replace(/^ {1,3}/,"")).join(`
202
+ `).replace(/[ \t]+$/,"")}),o=!1}return n}function D9(t,e){if(e+1>=t.length)return null;let n=t[e],r=t[e+1];if(!r.includes("|")||!/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r)||!n.includes("|"))return null;let o=Nh(n),i=_9(r),s=[],l=e+2;for(;l<t.length;){let a=t[l];if(!a.includes("|"))break;s.push(Nh(a)),l++}return{token:{type:"table",headers:o,rows:s,alignments:i},nextLine:l}}function Nh(t){let e=t.trim(),n=e.startsWith("|")?e.substring(1):e,r=n.endsWith("|")?n.substring(0,n.length-1):n,o=[],i="";for(let s=0;s<r.length;s++)r[s]==="\\"&&s+1<r.length&&r[s+1]==="|"?(i+="|",s++):r[s]==="|"?(o.push(i.trim()),i=""):i+=r[s];return o.push(i.trim()),o}function _9(t){return Nh(t).map(e=>{let n=e.trim(),r=n.startsWith(":"),o=n.endsWith(":");return r&&o?"center":o?"right":r?"left":null})}function Em(t){let e="",n=0;for(;n<t.length;){let r=t[n];switch(r.type){case"heading":{let o=r;e+=`<h${o.level}>${fo(o.content)}</h${o.level}>`,n++;break}case"paragraph":e+=`<p>${fo(r.content)}</p>`,n++;break;case"codeBlock":{let o=r,i=o.language?` data-language="${rn(o.language)}"`:"";e+=`<pre><code${i}>${rn(o.code)}</code></pre>`,n++;break}case"blockquote":{let o=Em(Sm(r.content));e+=`<blockquote>${o}</blockquote>`,n++;break}case"hr":e+="<hr>",n++;break;case"listItem":{let o=P9(t,n);e+=o.html,n=o.nextIndex;break}case"table":e+=L9(r),n++;break;case"rawHtml":e+=r.content,n++;break;default:n++}}return e}function P9(t,e){let n="",r=e,o=null;for(;r<t.length&&t[r].type==="listItem";){let i=t[r],s=$9(i.listType);if(o!==null&&o!==s&&(n+=`</${o==="ordered"?"ol":"ul"}>`,o=null),o===null){if(s==="ordered"){let l=i.start!==void 0&&i.start!==1?` start="${i.start}"`:"";n+=`<ol${l}>`}else n+="<ul>";o=s}if(i.listType==="task"){let l=i.checked?" checked":"";n+=`<li><input type="checkbox" disabled${l}><p>${fo(i.content)}</p>`}else n+=`<li><p>${fo(i.content)}</p>`;if(i.childContent){let l=Sm(i.childContent);n+=Em(l)}n+="</li>",r++}return o!==null&&(n+=`</${o==="ordered"?"ol":"ul"}>`),{html:n,nextIndex:r}}function $9(t){return t==="ordered"?"ordered":"bullet"}function L9(t){let e="<table>",n=t.headers.every(o=>o.trim()===""),r=t.headers.length;if(!n){e+="<thead><tr>";for(let o=0;o<r;o++){let i=t.alignments[o],s=i?` align="${i}"`:"";e+=`<th${s}>${fo(t.headers[o])}</th>`}e+="</tr></thead>"}if(t.rows.length>0){e+="<tbody>";for(let o of t.rows){e+="<tr>";for(let i=0;i<r;i++){let s=i<o.length?o[i]:"",l=t.alignments[i],a=l?` align="${l}"`:"";e+=`<td${a}>${fo(s)}</td>`}e+="</tr>"}e+="</tbody>"}return e+="</table>",e}function B9(t){return Em(Sm(t))}function pS(t){return B9(t)}function j9(t,e){return dS(pS(t),e)}var V9=class{constructor(e){this.editor=e}blocksToHTMLLossy(e=this.editor.document){return Dd(this.editor.pmSchema,this.editor).exportBlocks(e,{})}blocksToFullHTML(e=this.editor.document){return H8(this.editor.pmSchema,this.editor).serializeBlocks(e,{})}tryParseHTMLToBlocks(e){return dS(e,this.editor.pmSchema)}blocksToMarkdownLossy(e=this.editor.document){return o8(e,this.editor.pmSchema,this.editor,{})}tryParseMarkdownToBlocks(e){return j9(e,this.editor.pmSchema)}pasteHTML(e,n=!1){var o;let r=e;if(!n){let i=this.tryParseHTMLToBlocks(e);r=this.blocksToFullHTML(i)}r&&((o=this.editor.prosemirrorView)==null||o.pasteHTML(r))}pasteText(e){var n;return(n=this.editor.prosemirrorView)==null?void 0:n.pasteText(e)}pasteMarkdown(e){let n=pS(e);return this.pasteHTML(n)}};function H9(t){let{bnBlock:e}=Hl(t),n=st(t.doc),r=t.doc.resolve(e.beforePos),o=r.nodeBefore,i=t.doc.resolve(e.afterPos).nodeAfter,s;return r.depth>1&&(s=r.node(),s.type.isInGroup("bnBlock")||(s=r.node(r.depth-1))),{block:qe(e.node,n),prevBlock:o===null?void 0:qe(o,n),nextBlock:i===null?void 0:qe(i,n),parentBlock:s===void 0?void 0:qe(s,n)}}function Mm(t,e,n="start"){let r=typeof e=="string"?e:e.id,o=Fl(st(t.doc)),i=Ht(r,t.doc);if(!i)throw Error(`Block with ID ${r} not found`);let s=Or(i),l=o.blockSchema[s.blockNoteType].content;if(s.isBlockContainer){let a=s.blockContent;if(l==="none"){t.setSelection(G.create(t.doc,a.beforePos));return}if(l==="inline")n==="start"?t.setSelection(W.create(t.doc,a.beforePos+1)):t.setSelection(W.create(t.doc,a.afterPos-1));else if(l==="table")n==="start"?t.setSelection(W.create(t.doc,a.beforePos+4)):t.setSelection(W.create(t.doc,a.afterPos-4));else throw new dr(l)}else Mm(t,(n==="start"?s.childContainer.node.firstChild:s.childContainer.node.lastChild).attrs.id,n)}var F9="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";function z9(t){let e=[],n=[],r=0;for(;r<t.length;){let o=0;for(;r+o<t.length&&t.charCodeAt(r+o)>=48&&t.charCodeAt(r+o)<=57;)o++;if(o>0){e.push(n.join(""));let i=parseInt(t.substring(r,r+o),10);for(;i-- >0;)n.pop();r+=o}else n.push(t[r]),r++}return e}var mS=new Set(z9(F9)),U9=new Set(["localhost"]),W9=/[.,;:!?"']+$/,q9=/(?:https?|ftp|ftps):\/\/[^\s]+/g,G9=/mailto:[^\s]+/g,Z9=/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g,K9=/(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;function J9(t){let e=t,n=!0;for(;n;){n=!1;let r=e;e=e.replace(W9,""),e!==r&&(n=!0);for(let[o,i]of[["(",")"],["[","]"]])for(;e.endsWith(i);){let s=_0(e,o);if(_0(e,i)>s)e=e.slice(0,-1),n=!0;else break}}return e}function _0(t,e){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function Y9(t){let e=t.split(".");return e[e.length-1].toLowerCase()}function P0(t){let e=Y9(t);return mS.has(e)}function gS(t,e,n){return e==="email"?"mailto:"+t:/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(t)||/^mailto:/i.test(t)?t:n+"://"+t}function bS(t,e){if(!t)return[];let n=(e==null?void 0:e.defaultProtocol)||"http",r=[];for(let l of t.matchAll(q9))r.push({type:"url",value:l[0],start:l.index,end:l.index+l[0].length});for(let l of t.matchAll(G9))r.push({type:"url",value:l[0],start:l.index,end:l.index+l[0].length});for(let l of t.matchAll(Z9))r.push({type:"email",value:l[0],start:l.index,end:l.index+l[0].length});for(let l of t.matchAll(K9))r.push({type:"url",value:l[0],start:l.index,end:l.index+l[0].length});r.sort((l,a)=>l.start-a.start||a.end-l.end);let o=[],i=-1;for(let l of r)l.start>=i&&(o.push(l),i=l.end);let s=[];for(let l of o){let a=J9(l.value);if(!a)continue;let c=l.start,d=c+a.length;if(l.type==="url"&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(a)){let f=new URL("http://"+a).hostname;if(!P0(f))continue}if(l.type==="email"){let f=a.split("@")[1];if(!P0(f))continue}let u=gS(a,l.type,n);s.push({type:l.type,value:a,isLink:!0,href:u,start:c,end:d})}return s}function X9(t,e="http"){if(!t)return[xs(t,0,0)];for(let[n,r]of[["(",")"],["[","]"],["{","}"]])if(t.startsWith(n)&&t.endsWith(r)&&t.length>2){let o=t.slice(1,-1);if(tf(o))return[xs(n,0,1),nf(o,1,1+o.length,e),xs(r,1+o.length,t.length)]}if(t.endsWith(".")&&t.length>1){let n=t.slice(0,-1);if(tf(n))return[nf(n,0,n.length,e),xs(".",n.length,t.length)]}return tf(t)?[nf(t,0,t.length,e)]:[xs(t,0,t.length)]}function tf(t){if(/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(t)||/^mailto:[^\s]+$/.test(t)||U9.has(t.toLowerCase()))return!0;let e=t.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);if(e){let n=e[1].toLowerCase();if(mS.has(n))return!0}return!1}function nf(t,e,n,r){let o=t.includes("@")&&!t.includes("://")&&!t.startsWith("mailto:")?"email":"url";return{type:o,value:t,isLink:!0,href:gS(t,o,r),start:e,end:n}}function xs(t,e,n){return{type:"text",value:t,isLink:!1,href:t,start:e,end:n}}var Tm="[\0-   ᠎ -\u2029  ]",Q9=new RegExp(Tm),ej=RegExp(`${Tm}$`),tj=new RegExp(Tm,"g");function nj(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function rj(t){return new ae({key:new Ce("autolink"),appendTransaction:(e,n,r)=>{let o=e.some(l=>l.docChanged)&&!n.doc.eq(r.doc),i=e.some(l=>l.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r;if(Cp(cd(n.doc,[...e])).forEach(({newRange:l})=>{let a=bc(r.doc,l,u=>u.isTextblock),c,d;if(a.length>1)c=a[0],d=r.doc.textBetween(c.pos,c.pos+c.node.nodeSize,void 0," ");else if(a.length){let u=r.doc.textBetween(l.from,l.to," "," ");if(!ej.test(u))return;c=a[0],d=r.doc.textBetween(c.pos,l.to,void 0," ")}if(c&&d){let u=d.split(Q9).filter(Boolean);if(u.length<=0)return;let f=u[u.length-1],h=c.pos+d.lastIndexOf(f);if(!f)return;let p=X9(f,t.defaultProtocol);if(!nj(p))return;p.filter(m=>m.isLink).map(m=>({...m,from:h+m.start+1,to:h+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>t.validate(m.value)).filter(m=>t.shouldAutoLink(m.value)).forEach(m=>{Sp(m.from,m.to,r.doc).some(g=>g.mark.type===t.type)||s.addMark(m.from,m.to,t.type.create({href:m.href}))})}}),s.steps.length)return s}})}function oj(t){return new ae({key:new Ce("handleClickLink"),props:{handleClick:(e,n,r)=>{if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement&&r.target.getAttribute("data-inline-content-type")==="link")o=r.target;else{let a=r.target;if(!a)return!1;let c=t.tiptapEditor.view.dom;o=a.closest('a[data-inline-content-type="link"]'),o&&!c.contains(o)&&(o=null)}if(!o)return!1;if(t.onClick){if(!t.editor)throw Error("BlockNoteEditor not found in Link click handler");return t.onClick(r,t.editor)??!0}let i=ak(e.state,t.type.name),s=o.href??i.href,l=o.target??i.target;return s?(window.open(s,l),!0):!1}}})}function ij(t){return new ae({key:new Ce("handlePasteLink"),props:{handlePaste:(e,n,r)=>{let{shouldAutoLink:o,isValidLink:i}=t,{state:s}=e,{selection:l}=s,{empty:a}=l;if(a)return!1;let c="";r.content.forEach(u=>{c+=u.textContent});let d=bS(c,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||!i(d.value)||o!==void 0&&!o(d.value)?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}var rf="https",sj=/^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;function lj(t){if(!t)return!0;let e=t.replace(tj,"");return sj.test(e)}function of(t){let e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;let r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}var aj=Nn.create({name:"link",keepOnSplit:!1,exitable:!0,inclusive:!1,addOptions(){return{HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",className:"bn-inline-content-section","data-inline-content-type":"link"},editor:void 0,onClick:void 0,isValidLink:lj}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}}}},parseHTML(){let t=this.options.isValidLink;return[{tag:"a[href]",getAttrs:e=>{let n=e.getAttribute("href");return!n||!t(n)?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isValidLink(t.href)?["a",dn(t,this.options.HTMLAttributes),0]:["a",dn({...t,href:""},this.options.HTMLAttributes),0]},addPasteRules(){let t=this.options.isValidLink;return[qo({find:e=>{let n=[];if(e){let r=bS(e,{defaultProtocol:rf}).filter(o=>o.isLink&&t(o.value));for(let o of r)of(o.value)&&n.push({text:o.value,data:{href:o.href},index:o.start})}return n},type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)==null?void 0:n.href}}})]},addProseMirrorPlugins(){let t=[];return t.push(rj({type:this.type,defaultProtocol:rf,validate:this.options.isValidLink,shouldAutoLink:of})),t.push(oj({type:this.type,tiptapEditor:this.editor,editor:this.options.editor,onClick:this.options.onClick})),t.push(ij({editor:this.editor,defaultProtocol:rf,type:this.type,shouldAutoLink:of,isValidLink:this.options.isValidLink})),t}}),cj=ve(({editor:t,options:e})=>({key:"link",tiptapExtensions:[aj.configure({HTMLAttributes:e.HTMLAttributes??{},editor:t,onClick:e.onClick,...e.isValidLink?{isValidLink:e.isValidLink}:{}})]})),Am=["vscode-editor-data","blocknote/html","text/markdown","text/html","text/plain","Files"];function dj(t,e){if(!t.startsWith(".")||!e.startsWith("."))throw Error("The strings provided are not valid file extensions.");return t===e}function uj(t,e){let n=t.split("/"),r=e.split("/");if(n.length!==2)throw Error(`The string ${t} is not a valid MIME type.`);if(r.length!==2)throw Error(`The string ${e} is not a valid MIME type.`);return n[1]==="*"||r[1]==="*"?n[0]===r[0]:(n[0]==="*"||r[0]==="*"||n[0]===r[0])&&n[1]===r[1]}function $0(t,e,n,r="after"){let o;return o=Array.isArray(e.content)&&e.content.length===0?t.updateBlock(e,n).id:t.insertBlocks([n],e,r)[0].id,o}async function yS(t,e){var i;if(!e.uploadFile){console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");return}let n="dataTransfer"in t?t.dataTransfer:t.clipboardData;if(n===null)return;let r=null;for(let s of Am)if(n.types.includes(s)){r=s;break}if(r!=="Files")return;let o=n.items;if(o){t.preventDefault();for(let s=0;s<o.length;s++){let l="file";for(let c of Object.values(e.schema.blockSpecs))for(let d of((i=c.implementation.meta)==null?void 0:i.fileBlockAccept)||[]){let u=d.startsWith("."),f=o[s].getAsFile();if(f&&(!u&&f.type&&uj(o[s].type,d)||u&&dj("."+f.name.split(".").pop(),d))){l=c.config.type;break}}let a=o[s].getAsFile();if(a){let c={type:l,props:{name:a.name}},d;if(t.type==="paste"){let h=e.getTextCursorPosition().block;d=$0(e,h,c)}else if(t.type==="drop"){let h={left:t.clientX,top:t.clientY},p=e.prosemirrorView.posAtCoords(h);if(!p)return;d=e.transact(m=>{var w,k;let g=co(m.doc,p.pos),y=(k=(w=e.domElement)==null?void 0:w.querySelector(`[data-id="${g.node.attrs.id}"]`))==null?void 0:k.getBoundingClientRect();return $0(e,e.getBlock(g.node.attrs.id),c,y&&(y.top+y.bottom)/2>h.top?"before":"after")})}else return;let u=await e.uploadFile(a,d),f=typeof u=="string"?{props:{url:u}}:{...u};e.updateBlock(d,f)}}}}var fj=t=>Ge.create({name:"dropFile",addProseMirrorPlugins(){return[new ae({props:{handleDOMEvents:{drop(e,n){if(!t.isEditable)return;let r=null;for(let o of Am)if(n.dataTransfer.types.includes(o)){r=o;break}return r===null?!0:r==="Files"?(yS(n,t),!0):!1}}}})]}}),hj=/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,pj=/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,mj=/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,gj=/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,bj=/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,yj=/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,vj=/\n{2} {0,3}-{2,48}\n{2}/,wj=/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,kj=/(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,xj=/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/,Cj=/^\s*\|(.+\|)+\s*$/m,Sj=/^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m,Ej=/^\s*\|(.+\|)+\s*$/m,Mj=t=>hj.test(t)||pj.test(t)||mj.test(t)||gj.test(t)||bj.test(t)||yj.test(t)||vj.test(t)||wj.test(t)||kj.test(t)||xj.test(t)||Cj.test(t)||Sj.test(t)||Ej.test(t);function Tj(t,e){var s;let{schema:n}=e.state;if(!t.clipboardData)return!1;let r=t.clipboardData.getData("text/plain");if(!r||!n.nodes.codeBlock)return!1;let o=t.clipboardData.getData("vscode-editor-data"),i=(s=o?JSON.parse(o):void 0)==null?void 0:s.mode;return i?(e.pasteHTML(`<pre><code class="language-${i}">${r.replace(/\r\n?/g,`
203
+ `)}</code></pre>`),!0):!1}function Aj({event:t,editor:e,prioritizeMarkdownOverHTML:n,plainTextAsMarkdown:r}){var s;if(e.transact(l=>l.selection.$from.parent.type.spec.code&&l.selection.$to.parent.type.spec.code)){let l=(s=t.clipboardData)==null?void 0:s.getData("text/plain");if(l)return e.pasteText(l),!0}let o;for(let l of Am)if(t.clipboardData.types.includes(l)){o=l;break}if(!o)return!0;if(o==="vscode-editor-data"){if(Tj(t,e.prosemirrorView))return!0;o="text/plain"}if(o==="Files")return yS(t,e),!0;let i=t.clipboardData.getData(o);if(o==="blocknote/html")return e.pasteHTML(i,!0),!0;if(o==="text/markdown")return e.pasteMarkdown(i),!0;if(n){let l=t.clipboardData.getData("text/plain");if(Mj(l))return e.pasteMarkdown(l),!0}return o==="text/html"?(e.pasteHTML(i),!0):r?(e.pasteMarkdown(i),!0):(e.pasteText(i),!0)}var Nj=(t,e)=>Ge.create({name:"pasteFromClipboard",addProseMirrorPlugins(){return[new ae({props:{handleDOMEvents:{paste(n,r){if(r.preventDefault(),t.isEditable)return e({event:r,editor:t,defaultPasteHandler:({prioritizeMarkdownOverHTML:o=!0,plainTextAsMarkdown:i=!0}={})=>Aj({event:r,editor:t,prioritizeMarkdownOverHTML:o,plainTextAsMarkdown:i})})}}}})]}});function Rj(t,e,n){var l;let r=!1,o=t.state.selection instanceof Ae;if(!o){let a=t.state.doc.slice(t.state.selection.from,t.state.selection.to,!1).content,c=[];for(let d=0;d<a.childCount;d++)c.push(a.child(d));r=c.find(d=>d.type.isInGroup("bnBlock")||d.type.name==="blockGroup"||d.type.spec.group==="blockContent")===void 0,r&&(e=a)}let i,s=Dd(t.state.schema,n);if(o){((l=e.firstChild)==null?void 0:l.type.name)==="table"&&(e=e.firstChild.content);let a=hC(e,n.schema.inlineContentSchema,n.schema.styleSchema);i=`<table>${s.exportInlineContent(a,{})}</table>`}else if(r){let a=Td(e,n.schema.inlineContentSchema,n.schema.styleSchema);i=s.exportInlineContent(a,{})}else{let a=QC(e);i=s.exportBlocks(a,{})}return i}function vS(t,e){var c;"node"in t.state.selection&&t.state.selection.node.type.spec.group==="blockContent"&&e.transact(d=>d.setSelection(new G(d.doc.resolve(t.state.selection.from-1))));let n=t.serializeForClipboard(t.state.selection.content()).dom.innerHTML,r=t.state.selection.content().content,o=Rj(t,r,e),{$from:i,$to:s}=t.state.selection,l=i.parent.type.name,a=e.blockImplementations[l];return{clipboardHTML:n,externalHTML:o,markdown:i.sameParent(s)&&((c=a==null?void 0:a.implementation.meta)==null?void 0:c.code)===!0?t.state.doc.textBetween(i.pos,s.pos):vm(o)}}var L0=t=>{if(t.state.selection.empty)return!0;let e=window.getSelection();if(e&&!e.isCollapsed){let n=e.focusNode;for(;n;){if(n instanceof HTMLElement&&n.getAttribute("contenteditable")==="false")return!0;n=n.parentElement}}return!1},B0=(t,e,n)=>{n.preventDefault(),n.clipboardData.clearData();let{clipboardHTML:r,externalHTML:o,markdown:i}=vS(e,t);n.clipboardData.setData("blocknote/html",r),n.clipboardData.setData("text/html",o),n.clipboardData.setData("text/plain",i)},Ij=t=>Ge.create({name:"copyToClipboard",addProseMirrorPlugins(){return[new ae({props:{handleDOMEvents:{copy(e,n){return L0(e)||B0(t,e,n),!0},cut(e,n){return L0(e)||(B0(t,e,n),e.editable&&e.dispatch(e.state.tr.deleteSelection())),!0},dragstart(e,n){if(!("node"in e.state.selection)||e.state.selection.node.type.spec.group!=="blockContent")return;t.transact(s=>s.setSelection(new G(s.doc.resolve(e.state.selection.from-1)))),n.preventDefault(),n.dataTransfer.clearData();let{clipboardHTML:r,externalHTML:o,markdown:i}=vS(e,t);return n.dataTransfer.setData("blocknote/html",r),n.dataTransfer.setData("text/html",o),n.dataTransfer.setData("text/plain",i),!0}}}})]}}),Oj=Ge.create({name:"blockBackgroundColor",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{backgroundColor:KL()}}]}}),Dj=Kn.create({name:"hardBreak",inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,priority:10,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",dn(this.options.HTMLAttributes,t)]},renderText(){return`
204
+ `}}),wS=(t,e)=>{var s;let n=t.resolve(e),r=n.depth-1;if(r<1)return;let o=n.before(r),i=t.resolve(o).nodeAfter;if(i)return(s=i.type.spec.group)!=null&&s.includes("bnBlock")?uo(t.resolve(o)):wS(t,o)},Os=(t,e)=>{let n=t.resolve(e),r=n.index();if(r===0)return;let o=n.posAtIndex(r-1);return uo(t.resolve(o))},Cs=(t,e)=>{let n=t.resolve(e),r=n.index();if(r===n.node().childCount-1)return;let o=n.posAtIndex(r+1);return uo(t.resolve(o))},Rh=(t,e)=>{for(;e.childContainer;){let n=e.childContainer.node,r=t.resolve(e.childContainer.beforePos+1).posAtIndex(n.childCount-1);e=uo(t.resolve(r))}return e},_j=(t,e)=>t.isBlockContainer&&t.blockContent.node.type.spec.content==="inline*"&&t.blockContent.node.childCount>0&&e.isBlockContainer&&e.blockContent.node.type.spec.content==="inline*",Pj=(t,e,n,r)=>{if(!r.isBlockContainer)throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);if(r.childContainer){let o=t.doc.resolve(r.childContainer.beforePos+1),i=t.doc.resolve(r.childContainer.afterPos-1),s=o.blockRange(i);if(e){let l=t.doc.resolve(r.bnBlock.beforePos);t.tr.lift(s,l.depth)}}if(e){if(!n.isBlockContainer)throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but previous block is not a block container`);e(t.tr.delete(n.blockContent.afterPos-1,r.blockContent.beforePos+1))}return!0},j0=t=>({state:e,dispatch:n})=>{let r=uo(e.doc.resolve(t)),o=Os(e.doc,r.bnBlock.beforePos);if(!o)return!1;let i=Rh(e.doc,o);return _j(i,r)?Pj(e,n,i,r):!1},$j=Ge.create({priority:50,addKeyboardShortcuts(){let t=()=>this.editor.commands.first(({chain:r,commands:o})=>[()=>o.deleteSelection(),()=>o.undoInputRule(),()=>o.command(({state:i})=>{let s=Ze(i);if(!s.isBlockContainer)return!1;let l=i.selection.from===s.blockContent.beforePos+1,a=s.blockContent.node.type.name==="paragraph";return l&&!a?o.command(UL(s.bnBlock.beforePos,{type:"paragraph",props:{}})):!1}),()=>o.command(({state:i,tr:s})=>{let l=Ze(i);if(!l.isBlockContainer)return!1;let{blockContent:a}=l;return i.selection.from===a.beforePos+1?Ah(s,s.doc.type.schema.nodes.blockContainer,s.doc.type.schema.nodes.blockGroup):!1}),()=>o.command(({state:i})=>{let s=Ze(i);if(!s.isBlockContainer)return!1;let{bnBlock:l,blockContent:a}=s,c=Os(i.doc,s.bnBlock.beforePos);if(!c||!c.isBlockContainer||c.blockContent.node.type.spec.content!=="inline*")return!1;let d=i.selection.from===a.beforePos+1,u=i.selection.empty,f=l.beforePos;return d&&u?r().command(j0(f)).scrollIntoView().run():!1}),()=>o.command(({state:i,tr:s,dispatch:l})=>{let a=Ze(i);if(!a.isBlockContainer||i.selection.from!==a.blockContent.beforePos+1)return!1;let c=Os(i.doc,a.bnBlock.beforePos);if(!c||c.isBlockContainer)return!1;if(l){let d=c.bnBlock.afterPos-1,u=s.doc.resolve(d-1);return s.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),s.insert(u.pos,a.bnBlock.node),s.setSelection(W.near(s.doc.resolve(u.pos+1))),!0}return!1}),()=>o.command(({state:i,tr:s,dispatch:l})=>{let a=Ze(i);if(!a.isBlockContainer||s.selection.from!==a.blockContent.beforePos+1)return!1;let c=s.doc.resolve(a.bnBlock.beforePos);if(c.nodeBefore||c.node().type.name!=="column")return!1;let d=s.doc.resolve(a.bnBlock.beforePos),u=s.doc.resolve(d.before()),f=u.before();return l&&(s.delete(a.bnBlock.beforePos,a.bnBlock.afterPos),Ja(s,f),u.pos===f+1?(s.insert(f,a.bnBlock.node),s.setSelection(W.near(s.doc.resolve(f)))):(s.insert(u.pos-1,a.bnBlock.node),s.setSelection(W.near(s.doc.resolve(u.pos))))),!0}),()=>o.command(({state:i})=>{var l;let s=Ze(i);if(!s.isBlockContainer)return!1;if(s.blockContent.node.childCount===0&&s.blockContent.node.type.spec.content==="inline*"){let a=Os(i.doc,s.bnBlock.beforePos);if(!a)return!1;let c=Rh(i.doc,a);if(!c.isBlockContainer||!c||!c.isBlockContainer)return!1;let d=r();if(s.childContainer&&d.insertContentAt(s.bnBlock.afterPos,(l=s.childContainer)==null?void 0:l.node.content),c.blockContent.node.type.spec.content==="tableRow+"){let u=s.bnBlock.beforePos-1-1-1-1-1;d=d.setTextSelection(u)}else if(c.blockContent.node.type.spec.content==="")d=d.setNodeSelection(c.blockContent.beforePos);else{let u=c.blockContent.afterPos-1;d=d.setTextSelection(u)}return d.deleteRange({from:s.bnBlock.beforePos,to:s.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>o.command(({state:i})=>{let s=Ze(i);if(!s.isBlockContainer)return!1;let l=i.selection.from===s.blockContent.beforePos+1,a=i.selection.empty,c=Os(i.doc,s.bnBlock.beforePos);if(c&&l&&a){let d=Rh(i.doc,c);if(!d.isBlockContainer)return!1;if(d.blockContent.node.type.spec.content===""||d.blockContent.node.type.spec.content==="inline*"&&d.blockContent.node.childCount===0)return r().cut({from:s.bnBlock.beforePos,to:s.bnBlock.afterPos},d.bnBlock.afterPos).deleteRange({from:d.bnBlock.beforePos,to:d.bnBlock.afterPos}).run()}return!1})]),e=()=>this.editor.commands.first(({chain:r,commands:o})=>[()=>o.deleteSelection(),()=>o.command(({state:i})=>{var f;let s=Ze(i);if(!s.isBlockContainer||!s.childContainer)return!1;let{blockContent:l,childContainer:a}=s,c=i.selection.from===l.afterPos-1,d=i.selection.empty,u=uo(i.doc.resolve(a.beforePos+1));if(!u.isBlockContainer)return!1;if(c&&d){let h=u.blockContent.node,p=h.type.spec.content==="inline*",m=l.node.type.spec.content==="inline*";return r().insertContentAt(u.bnBlock.afterPos,((f=u.childContainer)==null?void 0:f.node.content)||I.empty).deleteRange(a.node.childCount===1?{from:a.beforePos,to:a.afterPos}:{from:u.bnBlock.beforePos,to:u.bnBlock.afterPos}).insertContentAt(i.selection.from,p&&m?h.content:null).setTextSelection(i.selection.from).scrollIntoView().run()}return!1}),()=>o.command(({state:i})=>{let s=Ze(i);if(!s.isBlockContainer)return!1;let{bnBlock:l,blockContent:a}=s,c=Cs(i.doc,s.bnBlock.beforePos);if(!c||!c.isBlockContainer)return!1;let d=i.selection.from===a.afterPos-1,u=i.selection.empty,f=l.afterPos;return d&&u?r().command(j0(f)).scrollIntoView().run():!1}),()=>o.command(({state:i,tr:s,dispatch:l})=>{let a=Ze(i);if(!a.isBlockContainer||i.selection.from!==a.blockContent.afterPos-1)return!1;let c=Cs(i.doc,a.bnBlock.beforePos);if(!c||c.isBlockContainer)return!1;if(l){let d=c.bnBlock.beforePos+1,u=s.doc.resolve(d+1);return s.delete(u.pos,u.pos+u.nodeAfter.nodeSize),Ja(s,c.bnBlock.beforePos),s.insert(a.bnBlock.afterPos,u.nodeAfter),s.setSelection(W.near(s.doc.resolve(u.pos))),!0}return!1}),()=>o.command(({state:i,tr:s,dispatch:l})=>{let a=Ze(i);if(!a.isBlockContainer||s.selection.from!==a.blockContent.afterPos-1)return!1;let c=s.doc.resolve(a.bnBlock.afterPos);if(c.nodeAfter||c.node().type.name!=="column")return!1;let d=s.doc.resolve(a.bnBlock.afterPos),u=s.doc.resolve(d.after()),f=u.after();if(l){let h=u.pos===f-1?f:u.pos+1,p=uo(s.doc.resolve(h));s.delete(p.bnBlock.beforePos,p.bnBlock.afterPos),Ja(s,f-u.node().nodeSize),s.insert(d.pos,p.bnBlock.node),s.setSelection(W.near(s.doc.resolve(h)))}return!0}),()=>o.command(({state:i})=>{var d;let s=Ze(i);if(!s.isBlockContainer)return!1;let{blockContent:l}=s,a=i.selection.from===l.afterPos-1,c=i.selection.empty;if(a&&c){let u=(g,y)=>{let w=Cs(g,y);if(w)return w;let k=wS(g,y);if(k)return u(g,k.bnBlock.beforePos)},f=u(i.doc,s.bnBlock.beforePos);if(!f||!f.isBlockContainer)return!1;let h=f.blockContent.node,p=h.type.spec.content==="inline*",m=l.node.type.spec.content==="inline*";return r().insertContentAt(f.bnBlock.afterPos,((d=f.childContainer)==null?void 0:d.node.content)||I.empty).deleteRange({from:f.bnBlock.beforePos,to:f.bnBlock.afterPos}).insertContentAt(i.selection.from,p&&m?h.content:null).setTextSelection(i.selection.from).scrollIntoView().run()}return!1}),()=>o.command(({state:i})=>{let s=Ze(i);if(!s.isBlockContainer)return!1;if(s.blockContent.node.childCount===0&&s.blockContent.node.type.spec.content==="inline*"){let l=Cs(i.doc,s.bnBlock.beforePos);if(!l||!l.isBlockContainer)return!1;let a=r();if(l.blockContent.node.type.spec.content==="tableRow+"){let c=s.bnBlock.afterPos+1+1+1+1+1;a=a.setTextSelection(c)}else a=l.blockContent.node.type.spec.content===""?a.setNodeSelection(l.blockContent.beforePos):a.setTextSelection(l.blockContent.beforePos+1);return a.deleteRange({from:s.bnBlock.beforePos,to:s.bnBlock.afterPos}).scrollIntoView().run()}return!1}),()=>o.command(({state:i})=>{let s=Ze(i);if(!s.isBlockContainer)return!1;let l=i.selection.from===s.blockContent.afterPos-1,a=i.selection.empty,c=Cs(i.doc,s.bnBlock.beforePos);if(!c||!c.isBlockContainer)return!1;if(c&&l&&a&&(c.blockContent.node.type.spec.content===""||c.blockContent.node.type.spec.content==="inline*"&&c.blockContent.node.childCount===0)){let d=c.bnBlock.node.lastChild.content;return r().deleteRange({from:c.bnBlock.beforePos,to:c.bnBlock.afterPos}).insertContentAt(s.bnBlock.afterPos,c.bnBlock.node.childCount===2?d:null).run()}return!1})]),n=(r=!1)=>this.editor.commands.first(({commands:o,tr:i})=>[()=>o.command(({state:s,tr:l})=>{let a=Ze(s);if(!a.isBlockContainer)return!1;let{bnBlock:c,blockContent:d}=a,{depth:u}=s.doc.resolve(c.beforePos),f=s.selection.$anchor.parentOffset===0,h=s.selection.anchor===s.selection.head,p=d.node.childCount===0;return f&&h&&p&&u>1?Ah(l,l.doc.type.schema.nodes.blockContainer,l.doc.type.schema.nodes.blockGroup):!1}),()=>o.command(({state:s})=>{var c;let l=Ze(s),a=((c=this.options.editor.schema.blockSchema[l.blockNoteType].meta)==null?void 0:c.hardBreakShortcut)??"shift+enter";if(a==="none")return!1;if(a==="shift+enter"&&r||a==="enter"){let d=i.storedMarks||i.selection.$head.marks().filter(u=>this.editor.extensionManager.splittableMarks.includes(u.type.name));return i.insert(i.selection.head,i.doc.type.schema.nodes.hardBreak.create()).ensureMarks(d),!0}return!1}),()=>o.command(({state:s,dispatch:l,tr:a})=>{var m;let c=Ze(s);if(!c.isBlockContainer)return!1;let{bnBlock:d,blockContent:u}=c,f=s.selection.$anchor.parentOffset===0,h=s.selection.anchor===s.selection.head,p=u.node.childCount===0;if(f&&h&&p){let g=d.afterPos,y=g+2;if(l){let w=s.schema.nodes.blockContainer.createAndFill(void 0,[s.schema.nodes.paragraph.createAndFill()||void 0,(m=c.childContainer)==null?void 0:m.node].filter(k=>k!==void 0));a.insert(g,w).setSelection(new W(a.doc.resolve(y))).scrollIntoView(),c.childContainer&&a.delete(c.childContainer.beforePos,c.childContainer.afterPos)}return!0}return!1}),()=>o.command(({state:s,chain:l})=>{let a=Ze(s);if(!a.isBlockContainer)return!1;let{blockContent:c}=a,d=s.selection.$anchor.parentOffset===0;return c.node.childCount===0?!1:(l().deleteSelection().command(xB(s.selection.from,d,d)).run(),!0)})]);return{Backspace:t,Delete:e,Enter:()=>n(),"Shift-Enter":()=>n(!0),Tab:()=>{var r,o;return this.options.tabBehavior!=="prefer-indent"&&((r=this.options.editor.getExtension(vn))!=null&&r.store.state||((o=this.options.editor.getExtension(Bn))==null?void 0:o.store.state)!==void 0)?!1:aS(this.options.editor)},"Shift-Tab":()=>{var r,o;return this.options.tabBehavior!=="prefer-indent"&&((r=this.options.editor.getExtension(vn))!=null&&r.store.state||((o=this.options.editor.getExtension(Bn))==null?void 0:o.store.state)!==void 0)?!1:cS(this.options.editor)},"Shift-Mod-ArrowUp":()=>(this.options.editor.moveBlocksUp(),!0),"Shift-Mod-ArrowDown":()=>(this.options.editor.moveBlocksDown(),!0),"Mod-z":()=>this.options.editor.undo(),"Mod-y":()=>this.options.editor.redo(),"Shift-Mod-z":()=>this.options.editor.redo()}}}),Lj=Nn.create({name:"insertion",inclusive:!1,excludes:"deletion modification insertion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(t){return t.name==="insertion"?{blocknoteIgnore:!0,inclusive:!1,toDOM(e,n){return["ins",{"data-id":String(e.attrs.id),"data-inline":String(n),...!n&&{style:"display: contents"}},0]},parseDOM:[{tag:"ins",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10)}:!1}}]}:{}}}),Bj=Nn.create({name:"deletion",inclusive:!1,excludes:"insertion modification deletion",addAttributes(){return{id:{default:null,validate:"number"}}},extendMarkSchema(t){return t.name==="deletion"?{blocknoteIgnore:!0,inclusive:!1,toDOM(e,n){return["del",{"data-id":String(e.attrs.id),"data-inline":String(n),...!n&&{style:"display: contents"}},0]},parseDOM:[{tag:"del",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10)}:!1}}]}:{}}}),jj=Nn.create({name:"modification",inclusive:!1,excludes:"deletion insertion",addAttributes(){return{id:{default:null,validate:"number"},type:{validate:"string"},attrName:{default:null,validate:"string|null"},previousValue:{default:null},newValue:{default:null}}},extendMarkSchema(t){return t.name==="modification"?{blocknoteIgnore:!0,inclusive:!1,toDOM(e,n){return[n?"span":"div",{"data-type":"modification","data-id":String(e.attrs.id),"data-mod-type":e.attrs.type,"data-mod-prev-val":JSON.stringify(e.attrs.previousValue),"data-mod-new-val":JSON.stringify(e.attrs.newValue)},0]},parseDOM:[{tag:"span[data-type='modification']",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal,newValue:e.dataset.modNewVal}:!1}},{tag:"div[data-type='modification']",getAttrs(e){return e.dataset.id?{id:parseInt(e.dataset.id,10),type:e.dataset.modType,previousValue:e.dataset.modPrevVal}:!1}}]}:{}}}),Vj=Ge.create({name:"textAlignment",addGlobalAttributes(){return[{types:["tableCell","tableHeader"],attributes:{textAlignment:{default:"left",parseHTML:t=>t.getAttribute("data-text-alignment"),renderHTML:t=>t.textAlignment==="left"?{}:{"data-text-alignment":t.textAlignment}}}}]}}),Hj=Ge.create({name:"blockTextColor",addGlobalAttributes(){return[{types:["table","tableCell","tableHeader"],attributes:{textColor:JL()}}]}}),Fj={blockColor:"data-block-color",blockStyle:"data-block-style",id:"data-id",depth:"data-depth",depthChange:"data-depth-change"},zj=Kn.create({name:"blockContainer",group:"blockGroupChild bnBlock",content:"blockContent blockGroup?",priority:50,defining:!0,marks:"insertion modification deletion",parseHTML(){return[{tag:"div[data-node-type="+this.name+"]",getAttrs:t=>{if(typeof t=="string")return!1;let e={};for(let[n,r]of Object.entries(Fj))t.getAttribute(r)&&(e[n]=t.getAttribute(r));return e}},{tag:'div[data-node-type="blockOuter"]',skip:!0}]},renderHTML({HTMLAttributes:t}){var o;let e=document.createElement("div");e.className="bn-block-outer",e.setAttribute("data-node-type","blockOuter");for(let[i,s]of Object.entries(t))i!=="class"&&e.setAttribute(i,s);let n={...((o=this.options.domAttributes)==null?void 0:o.block)||{},...t},r=document.createElement("div");r.className=De("bn-block",n.class),r.setAttribute("data-node-type",this.name);for(let[i,s]of Object.entries(n))i!=="class"&&r.setAttribute(i,s);return e.appendChild(r),{dom:e,contentDOM:r}}}),Uj=Kn.create({name:"blockGroup",group:"childContainer",content:"blockGroupChild+",marks:"deletion insertion modification",parseHTML(){return[{tag:"div",getAttrs:t=>typeof t=="string"?!1:t.getAttribute("data-node-type")==="blockGroup"?null:!1}]},renderHTML({HTMLAttributes:t}){var r;let e={...((r=this.options.domAttributes)==null?void 0:r.blockGroup)||{},...t},n=document.createElement("div");n.className=De("bn-block-group",e.class),n.setAttribute("data-node-type","blockGroup");for(let[o,i]of Object.entries(e))o!=="class"&&n.setAttribute(o,i);return{dom:n,contentDOM:n}}}),Wj=Kn.create({name:"doc",topNode:!0,content:"blockGroup",marks:"insertion modification deletion"}),qj=ve(({options:t})=>({key:"collaboration",blockNoteExtensions:[x7(t),Sh(t),Ga(t),Za(),S7(t)]}));function Gj(t,e){return[wi.ClipboardTextSerializer,wi.Commands,wi.Editable,wi.FocusEvents,wi.Tabindex,N8,Md.configure({types:["blockContainer","columnList","column"],setIdAttribute:e.setIdAttribute,isWithinEditor:t.isWithinEditor}),Dj,R8,Lj,Bj,jj,...Object.values(t.schema.styleSpecs).map(n=>n.implementation.mark.configure({editor:t})),Hj,Oj,Vj,Ge.create({name:"OverrideEscape",addKeyboardShortcuts:()=>({Escape:()=>{var n;return(n=t.getExtension(En))!=null&&n.shown()?!1:(t.blur(),!0)}})}),Wj,zj.configure({editor:t,domAttributes:e.domAttributes}),$j.configure({editor:t,tabBehavior:e.tabBehavior}),Uj.configure({domAttributes:e.domAttributes}),...Object.values(t.schema.inlineContentSpecs).filter(n=>n.config!=="link"&&n.config!=="text").map(n=>n.implementation.node.configure({editor:t})),...Object.values(t.schema.blockSpecs).flatMap(n=>[..."node"in n.implementation?[n.implementation.node.configure({editor:t,domAttributes:e.domAttributes})]:[]]),Ij(t),Nj(t,e.pasteHandler||(n=>n.defaultPasteHandler())),fj(t)]}function Zj(t,e){var r,o,i;let n=[WC(),N7(e),Bn(e),vn(e),cj({HTMLAttributes:((r=e.links)==null?void 0:r.HTMLAttributes)??{},onClick:(o=e.links)==null?void 0:o.onClick,...(i=e.links)!=null&&i.isValidLink?{isValidLink:e.links.isValidLink}:{}}),zl(e),_7(),$7(e),Pc(e),An(e),En(e),...e.trailingBlock===!1?[]:[b8()]];return e.collaboration?n.push(qj(e.collaboration)):n.push(R7()),"table"in t.schema.blockSpecs&&n.push(_e(e)),e.animations!==!1&&n.push(B7()),n}var Kj=class{constructor(t,e){B(this,"disabledExtensions",new Set);B(this,"extensions",[]);B(this,"abortMap",new Map);B(this,"extensionFactories",new Map);B(this,"extensionPlugins",new Map);this.editor=t,this.options=e,t.onMount(()=>{for(let n of this.extensions)if(n.mount){let r=new window.AbortController,o=n.mount({dom:t.prosemirrorView.dom,root:t.prosemirrorView.root,signal:r.signal});o&&r.signal.addEventListener("abort",()=>{o()}),this.abortMap.set(n,r)}}),t.onUnmount(()=>{for(let[n,r]of this.abortMap.entries())this.abortMap.delete(n),r.abort()}),this.disabledExtensions=new Set(e.disableExtensions||[]);for(let n of Zj(this.editor,this.options))this.addExtension(n);for(let n of this.options.extensions??[])this.addExtension(n);for(let n of Object.values(this.editor.schema.blockSpecs))for(let r of n.extensions??[])this.addExtension(r)}registerExtension(t){var o;let e=[].concat(t).filter(Boolean);if(!e.length){console.warn("No extensions found to register",t);return}let n=e.map(i=>this.addExtension(i)).filter(Boolean),r=new Set;for(let i of n)i!=null&&i.tiptapExtensions&&console.warn(`Extension ${i.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,i),(o=i==null?void 0:i.inputRules)!=null&&o.length&&console.warn(`Extension ${i.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`,i),this.getProsemirrorPluginsFromExtension(i).plugins.forEach(s=>{r.add(s)});this.updatePlugins(i=>[...i,...r])}addExtension(t){let e;if(e=typeof t=="function"?t({editor:this.editor}):t,!(!e||this.disabledExtensions.has(e.key))){if(typeof t=="function"){let n=e[If];typeof n=="function"&&this.extensionFactories.set(n,e)}if(this.extensions.push(e),e.blockNoteExtensions)for(let n of e.blockNoteExtensions)this.addExtension(n);return e}}resolveExtensions(t){let e=[];if(typeof t=="function"){let n=this.extensionFactories.get(t);n&&e.push(n)}else if(Array.isArray(t))for(let n of t)e.push(...this.resolveExtensions(n));else if(typeof t=="object"&&"key"in t)e.push(t);else if(typeof t=="string"){let n=this.extensions.find(r=>r.key===t);n&&e.push(n)}return e}unregisterExtension(t){var o,i;let e=this.resolveExtensions(t);if(!e.length){console.warn("No extensions found to unregister",t);return}let n=!1,r=new Set;for(let s of e)this.extensions=this.extensions.filter(l=>l!==s),this.extensionFactories.forEach((l,a)=>{l===s&&this.extensionFactories.delete(a)}),(o=this.abortMap.get(s))==null||o.abort(),this.abortMap.delete(s),(i=this.extensionPlugins.get(s))==null||i.forEach(l=>{r.add(l)}),this.extensionPlugins.delete(s),s.tiptapExtensions&&!n&&(n=!0,console.warn(`Extension ${s.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`,t));this.updatePlugins(s=>s.filter(l=>!r.has(l)))}updatePlugins(t){let e=this.editor.prosemirrorState,n=e.reconfigure({plugins:t(e.plugins.slice())});this.editor.prosemirrorView.updateState(n)}getTiptapExtensions(){var r;let t=Gj(this.editor,this.options).filter(o=>!this.disabledExtensions.has(o.name)),e=yC(this.extensions),n=new Map;for(let o of this.extensions){o.tiptapExtensions&&t.push(...o.tiptapExtensions);let i=e(o.key),{plugins:s,inputRules:l}=this.getProsemirrorPluginsFromExtension(o);s.length&&t.push(Ge.create({name:o.key,priority:i,addProseMirrorPlugins:()=>s})),l.length&&(n.has(i)||n.set(i,[]),n.get(i).push(...l))}t.push(Ge.create({name:"blocknote-input-rules",addProseMirrorPlugins(){let o=[];Array.from(n.keys()).sort().reverse().forEach(s=>{o.push(...n.get(s))});let i=k8({rules:o});return[i,new ae({props:{handleKeyDown(s,l){var c;if(l.key!=="Enter"||l.shiftKey||l.ctrlKey||l.metaKey||l.altKey)return!1;let{$cursor:a}=s.state.selection;return a?!!((c=i.props.handleTextInput)!=null&&c.call(i,s,a.pos,a.pos,`
205
+ `,()=>s.state.tr.insertText(`
206
+ `,a.pos,a.pos))):!1}}})]}}));for(let o of((r=this.options._tiptapOptions)==null?void 0:r.extensions)??[])t.push(o);return t}getProsemirrorPluginsFromExtension(t){var r,o,i;let e=[...t.prosemirrorPlugins??[]],n=[];return!((r=t.prosemirrorPlugins)!=null&&r.length)&&!Object.keys(t.keyboardShortcuts||{}).length&&!((o=t.inputRules)!=null&&o.length)?{plugins:e,inputRules:n}:(this.extensionPlugins.set(t,e),(i=t.inputRules)!=null&&i.length&&n.push(...t.inputRules.map(s=>new ai(s.find,(l,a,c,d)=>{var f;let u=s.replace({match:a,range:{from:c,to:d},editor:this.editor});if(u){let h=l.tr,p=Hl(h);if(!p.isBlockContainer||((f=this.editor.schema.blockSchema[p.blockNoteType])==null?void 0:f.content)!=="inline")return null;h.deleteRange(c,d),Nd(h,p.bnBlock.beforePos,u);let m=p.bnBlock.node.attrs.id;return m&&Mm(h,m,"start"),h}return null},{undoable:!0}))),Object.keys(t.keyboardShortcuts||{}).length&&e.push(Zw(Object.fromEntries(Object.entries(t.keyboardShortcuts).map(([s,l])=>[s,()=>l({editor:this.editor})])))),{plugins:e,inputRules:n})}getExtensions(){return new Map(this.extensions.map(t=>[t.key,t]))}getExtension(t){if(typeof t=="string")return this.extensions.find(e=>e.key===t)||void 0;if(typeof t=="function")return this.extensionFactories.get(t)||void 0;throw Error(`Invalid extension type: ${typeof t}`)}hasExtension(t){return typeof t=="string"?this.extensions.some(e=>e.key===t):typeof t=="object"&&"key"in t?this.extensions.some(e=>e.key===t.key):typeof t=="function"?this.extensionFactories.has(t):!1}};function Jj(t,e){let{$from:n,$to:r}=e;if(n.pos>n.start()&&n.pos<t.content.size){let o=t.textBetween(n.pos,n.pos+1);if(/^[\w\p{P}]$/u.test(o)){let i=t.textBetween(n.start(),n.pos).match(/[\w\p{P}]+$/u);i&&(n=t.resolve(n.pos-i[0].length))}}if(r.pos<r.end()&&r.pos>0){let o=t.textBetween(r.pos-1,r.pos);if(/^[\w\p{P}]$/u.test(o)){let i=t.textBetween(r.pos,r.end()).match(/^[\w\p{P}]+/u);i&&(r=t.resolve(r.pos+i[0].length))}}return{$from:n,$to:r,from:n.pos,to:r.pos}}function Yj(t){let e=st(t);if(t.selection.empty||"node"in t.selection)return;let n=t.doc.resolve(co(t.doc,t.selection.from).posBeforeNode),r=t.doc.resolve(co(t.doc,t.selection.to).posBeforeNode),o=(c,d)=>{let u=n.posAtIndex(c,d),f=t.doc.resolve(u).nodeAfter;if(!f)throw Error(`Error getting selection - node not found at position ${u}`);return qe(f,e)},i=[],s=n.sharedDepth(r.pos),l=n.index(s),a=r.index(s);if(n.depth>s){i.push(qe(n.nodeAfter,e));for(let c=n.depth;c>s;c--)if(n.node(c).type.isInGroup("childContainer")){let d=n.index(c)+1,u=n.node(c).childCount;for(let f=d;f<u;f++)i.push(o(f,c))}}else i.push(o(l,s));for(let c=l+1;c<=a;c++)i.push(o(c,s));if(i.length===0)throw Error(`Error getting selection - selection doesn't span any blocks (${t.selection})`);return{blocks:i}}function Xj(t,e,n){let r=typeof e=="string"?e:e.id,o=typeof n=="string"?n:n.id,i=Fl(st(t));if(r===o)throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);let s=Ht(r,t.doc);if(!s)throw Error(`Block with ID ${r} not found`);let l=Ht(o,t.doc);if(!l)throw Error(`Block with ID ${o} not found`);let a=Or(s),c=Or(l),d=i.blockSchema[a.blockNoteType],u=i.blockSchema[c.blockNoteType];if(!a.isBlockContainer||d.content==="none")throw Error(`Attempting to set selection anchor in block without content (id ${r})`);if(!c.isBlockContainer||u.content==="none")throw Error(`Attempting to set selection anchor in block without content (id ${o})`);let f,h;if(d.content==="table"){let p=je.get(a.blockContent.node);f=a.blockContent.beforePos+p.positionAt(0,0,a.blockContent.node)+1+2}else f=a.blockContent.beforePos+1;if(u.content==="table"){let p=je.get(c.blockContent.node),m=c.blockContent.beforePos+p.positionAt(p.height-1,p.width-1,c.blockContent.node)+1;h=m+t.doc.resolve(m).nodeAfter.nodeSize-2}else h=c.blockContent.afterPos-1;t.setSelection(W.create(t.doc,f,h))}function Qj(t,e=!1){let n=st(t),r=e?Jj(t.doc,t.selection):t.selection,o=r.$from,i=r.$to;for(;i.parentOffset>=i.parent.nodeSize-2&&i.depth>0;)i=t.doc.resolve(i.pos+1);for(;i.parentOffset===0&&i.depth>0;)i=t.doc.resolve(i.pos-1);for(;o.parentOffset===0&&o.depth>0;)o=t.doc.resolve(o.pos-1);for(;o.parentOffset>=o.parent.nodeSize-2&&o.depth>0;)o=t.doc.resolve(o.pos+1);let s=NL(t.doc.slice(o.pos,i.pos,!0),n);return{_meta:{startPos:o.pos,endPos:i.pos},...s}}var eV=class{constructor(t){this.editor=t}getSelection(){return this.editor.transact(t=>Yj(t))}getSelectionCutBlocks(t=!1){return this.editor.transact(e=>Qj(e,t))}setSelection(t,e){return this.editor.transact(n=>Xj(n,t,e))}getTextCursorPosition(){return this.editor.transact(t=>H9(t))}setTextCursorPosition(t,e="start"){return this.editor.transact(n=>Mm(n,t,e))}getSelectionBoundingBox(){if(!this.editor.prosemirrorView)return;let{selection:t}=this.editor.prosemirrorState,{ranges:e}=t,n=Math.min(...e.map(o=>o.$from.pos)),r=Math.max(...e.map(o=>o.$to.pos));if(KO(t)){let o=this.editor.prosemirrorView.nodeDOM(n);if(o)return o.getBoundingClientRect()}return Mp(this.editor.prosemirrorView,n,r).toJSON()}},tV=class{constructor(t){B(this,"activeTransaction",null);B(this,"isInCan",!1);this.editor=t}can(t){try{return this.isInCan=!0,t()}finally{this.isInCan=!1}}exec(t){if(this.activeTransaction)throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");if(this.isInCan)return this.canExec(t);let e=this.prosemirrorState,n=this.prosemirrorView;return t(e,r=>this.prosemirrorView.dispatch(r),n)}canExec(t){if(this.activeTransaction)throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");let e=this.prosemirrorState,n=this.prosemirrorView;return t(e,void 0,n)}transact(t){if(this.activeTransaction)return t(this.activeTransaction);try{this.activeTransaction=this.editor._tiptapEditor.state.tr;let e=t(this.activeTransaction),n=this.activeTransaction;return this.activeTransaction=null,n&&(n.docChanged||n.selectionSet||n.scrolledIntoView||n.storedMarksSet||!n.isGeneric)&&this.prosemirrorView.dispatch(n),e}finally{this.activeTransaction=null}}get prosemirrorState(){if(this.activeTransaction)throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");return this.editor._tiptapEditor.state}get prosemirrorView(){return this.editor._tiptapEditor.view}isFocused(){var t;return((t=this.prosemirrorView)==null?void 0:t.hasFocus())||!1}focus(){var t;(t=this.prosemirrorView)==null||t.focus()}get isEditable(){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw Error("no editor, but also not headless?");return!1}return this.editor._tiptapEditor.isEditable===void 0?!0:this.editor._tiptapEditor.isEditable}set isEditable(t){if(!this.editor._tiptapEditor){if(!this.editor.headless)throw Error("no editor, but also not headless?");return}this.editor._tiptapEditor.options.editable!==t&&this.editor._tiptapEditor.setEditable(t)}undo(){let t=this.editor.getExtension("yUndo");if(t)return this.exec(t.undoCommand);let e=this.editor.getExtension("history");if(e)return this.exec(e.undoCommand);throw Error("No undo plugin found")}redo(){let t=this.editor.getExtension("yUndo");if(t)return this.exec(t.redoCommand);let e=this.editor.getExtension("history");if(e)return this.exec(e.redoCommand);throw Error("No redo plugin found")}};function nV(t,e,n,r={updateSelection:!0}){let{from:o,to:i}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},s=!0,l=!0,a="";if(n.forEach(c=>{c.check(),s&&c.isText&&c.marks.length===0?a+=c.text:s=!1,l=l?c.isBlock:!1}),o===i&&l){let{parent:c}=t.doc.resolve(o);c.isTextblock&&!c.type.spec.code&&!c.childCount&&(--o,i+=1)}return s?t.insertText(a,o,i):t.replaceWith(o,i,n),r.updateSelection&&Qw(t,t.steps.length-1,-1),!0}var rV=class{constructor(t){this.editor=t}insertInlineContent(t,{updateSelection:e=!1}={}){let n=Gn(t,this.editor.pmSchema);this.editor.transact(r=>{nV(r,{from:r.selection.from,to:r.selection.to},n,{updateSelection:e})})}getActiveStyles(){return this.editor.transact(t=>{let e={},n=t.selection.$to.marks();for(let r of n){let o=this.editor.schema.styleSchema[r.type.name];if(!o){r.type.name!=="link"&&!r.type.spec.blocknoteIgnore&&console.warn("mark not found in styleschema",r.type.name);continue}o.propSchema==="boolean"?e[o.type]=!0:e[o.type]=r.attrs.stringValue}return e})}addStyles(t){for(let[e,n]of Object.entries(t)){let r=this.editor.schema.styleSchema[e];if(!r)throw Error(`style ${e} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.setMark(e);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.setMark(e,{stringValue:n});else throw new dr(r.propSchema)}}removeStyles(t){for(let e of Object.keys(t))this.editor._tiptapEditor.commands.unsetMark(e)}toggleStyles(t){for(let[e,n]of Object.entries(t)){let r=this.editor.schema.styleSchema[e];if(!r)throw Error(`style ${e} not found in styleSchema`);if(r.propSchema==="boolean")this.editor._tiptapEditor.commands.toggleMark(e);else if(r.propSchema==="string")this.editor._tiptapEditor.commands.toggleMark(e,{stringValue:n});else throw new dr(r.propSchema)}}getSelectedText(){return this.editor.transact(t=>t.doc.textBetween(t.selection.from,t.selection.to))}getLinkMarkAtPos(t){return this.editor.transact(e=>{let n=e.doc.resolve(t),r=n.marks().find(i=>i.type.name==="link");if(!r)return;let o=ld(n,r.type);if(o)return{href:r.attrs.href,from:o.from,to:o.to,text:e.doc.textBetween(o.from,o.to)}})}getSelectedLinkUrl(){return this.editor.transact(t=>{var e;return(e=this.getLinkMarkAtPos(t.selection.from))==null?void 0:e.href})}createLink(t,e){t!==""&&this.editor.transact(n=>{let{from:r,to:o}=n.selection,i=this.editor.pmSchema.mark("link",{href:t});e?n.insertText(e,r,o).addMark(r,r+e.length,i):n.addMark(r,o,i)})}editLink(t,e,n=this.editor.transact(r=>r.selection.anchor)){this.editor.transact(r=>{let{from:o,to:i}=this.getLinkMarkAtPos(n+1)||{from:r.selection.from,to:r.selection.to},s=this.editor.pmSchema.mark("link",{href:t});e!==r.doc.textBetween(o,i)&&r.insertText(e,o,i),r.addMark(o,o+e.length,s)}),this.editor.prosemirrorView.focus()}deleteLink(t=this.editor.transact(e=>e.selection.anchor)){this.editor.transact(e=>{let{from:n,to:r}=this.getLinkMarkAtPos(t+1)||{from:e.selection.from,to:e.selection.to};e.removeMark(n,r,this.editor.pmSchema.marks.link).setMeta("preventAutolink",!0)}),this.editor.prosemirrorView.focus()}};function kS(t){return nk(t.state.selection.$from,e=>e.type.name==="tableCell"||e.type.name==="tableHeader")!==void 0}function xS(t,e){var o;let n=e.nodes.hardBreak,r=I.empty;return t.forEach(i=>{i.isTextblock&&i.childCount>0?(r=r.append(i.content),r=r.addToEnd(n.create())):i.isText?r=r.addToEnd(i):i.isBlock&&i.childCount>0&&(r=r.append(xS(i.content,e)),r=r.addToEnd(n.create()))}),((o=r.lastChild)==null?void 0:o.type)===n&&(r=r.cut(0,r.size-1)),r}function oV(t,e){let n=[];return t.forEach((r,o,i)=>{i!==e&&n.push(r)}),I.from(n)}function iV(t,e){let n=[];for(let r=0;r<t.childCount;r++)if(t.child(r).type.name==="tableRow")if(n.length>0&&n[n.length-1].type.name==="table"){let o=n[n.length-1],i=o.copy(o.content.addToEnd(t.child(r)));n[n.length-1]=i}else{let o=e.nodes.table.createChecked(void 0,t.child(r));n.push(o)}else n.push(t.child(r));return t=I.from(n),t}function sV(t,e){let n=I.from(t.content);n=iV(n,e.state.schema);let r=lV(n,e,t);if(r)return r;if(kS(e)){let o=!1;if(n.descendants(i=>{i.type.isInGroup("tableContent")&&(o=!0)}),!o&&!e.state.schema.nodes.tableParagraph.validContent(n))return new j(xS(n,e.state.schema),0,0)}if(!aV(n,e))return new j(n,t.openStart,t.openEnd);for(let o=0;o<n.childCount;o++)if(n.child(o).type.spec.group==="blockContent"){let i=[n.child(o)];if(o+1<n.childCount&&n.child(o+1).type.name==="blockGroup"){let l=n.child(o+1).child(0).child(0);(l.type.name==="bulletListItem"||l.type.name==="numberedListItem"||l.type.name==="checkListItem")&&(i.push(n.child(o+1)),n=oV(n,o+1))}let s=e.state.schema.nodes.blockContainer.createChecked(void 0,i);n=n.replaceChild(o,s)}return new j(n,t.openStart,t.openEnd)}function lV(t,e,n){if(kS(e)||e.dragging)return null;let r=Ze(e.state),o=r.isBlockContainer?r.blockContent.node:null;if(!o||o.type.name==="paragraph"||o.type.spec.content!=="inline*"||o.childCount>0)return null;let i=t.firstChild,s=i==null?void 0:i.firstChild,l=s==null?void 0:s.firstChild;if((i==null?void 0:i.type.name)!=="blockGroup"||(s==null?void 0:s.type.name)!=="blockContainer"||(l==null?void 0:l.type.name)!=="paragraph")return null;let a=o.type.create(o.attrs,l.content),c=s.copy(s.content.replaceChild(0,a)),d=i.copy(i.content.replaceChild(0,c));return new j(t.replaceChild(0,d),n.openStart,n.openEnd)}function aV(t,e){var i,s;let n=t.childCount===1,r=((i=t.firstChild)==null?void 0:i.type.spec.content)==="inline*",o=((s=t.firstChild)==null?void 0:s.type.spec.content)==="tableRow+";if(n){if(r)return!1;if(o){let l=Ze(e.state);if(l.isBlockContainer)return l.blockContent.node.type.spec.content!=="tableRow+"}}return!0}var cV={enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!1},dV=class CS extends wm{constructor(n){var c,d,u,f,h,p,m,g,y,w;super();B(this,"pmSchema");B(this,"_tiptapEditor");B(this,"elementRenderer",null);B(this,"blockCache",new WeakMap);B(this,"dictionary");B(this,"schema");B(this,"blockImplementations");B(this,"inlineContentImplementations");B(this,"styleImplementations");B(this,"uploadFile");B(this,"onUploadStartCallbacks",[]);B(this,"onUploadEndCallbacks",[]);B(this,"resolveFileUrl");B(this,"settings");B(this,"_blockManager");B(this,"_eventManager");B(this,"_exportManager");B(this,"_extensionManager");B(this,"_selectionManager");B(this,"_stateManager");B(this,"_styleManager");B(this,"unregisterExtension",(...n)=>this._extensionManager.unregisterExtension(...n));B(this,"registerExtension",(...n)=>this._extensionManager.registerExtension(...n));B(this,"getExtension",((...n)=>this._extensionManager.getExtension(...n)));B(this,"mount",(n,r)=>{let o=n.getRootNode(),i=typeof ShadowRoot<"u"&&o instanceof ShadowRoot;((r==null?void 0:r.portalTarget)??n.parentElement??(i?o:document.body)).appendChild(this.portalElement),this._tiptapEditor.mount({mount:n})});B(this,"unmount",()=>{var n;(n=this.portalElement)==null||n.remove(),this._tiptapEditor.unmount()});B(this,"_portalElement");B(this,"isWithinEditor",n=>{var r,o,i;return!!((o=(r=this.domElement)==null?void 0:r.parentElement)!=null&&o.contains(n)||(i=this.portalElement)!=null&&i.contains(n))});B(this,"headless",!0);this.options=n,this.dictionary=n.dictionary||y8,this.settings={tables:{splitCells:((c=n==null?void 0:n.tables)==null?void 0:c.splitCells)??!1,cellBackgroundColor:((d=n==null?void 0:n.tables)==null?void 0:d.cellBackgroundColor)??!1,cellTextColor:((u=n==null?void 0:n.tables)==null?void 0:u.cellTextColor)??!1,headers:((f=n==null?void 0:n.tables)==null?void 0:f.headers)??!1}};let r={defaultStyles:!0,schema:n.schema||ym.create(),...n,placeholders:{...this.dictionary.placeholders,...n.placeholders}};if(this.schema=r.schema,this.blockImplementations=r.schema.blockSpecs,this.inlineContentImplementations=r.schema.inlineContentSpecs,this.styleImplementations=r.schema.styleSpecs,r.uploadFile){let k=r.uploadFile;this.uploadFile=async(x,C)=>{this.onUploadStartCallbacks.forEach(E=>E.apply(this,[C]));try{return await k(x,C)}finally{this.onUploadEndCallbacks.forEach(E=>E.apply(this,[C]))}}}this.resolveFileUrl=r.resolveFileUrl,this._eventManager=new n9(this),this._extensionManager=new Kj(this,r);let o=this._extensionManager.getTiptapExtensions(),i=this._extensionManager.hasExtension("ySync")||this._extensionManager.hasExtension("liveblocksExtension");i&&r.initialContent&&console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");let s={...cV,...r._tiptapOptions,element:null,autofocus:r.autofocus??!1,extensions:o,editorProps:{...(h=r._tiptapOptions)==null?void 0:h.editorProps,attributes:{tabIndex:"0",...(m=(p=r._tiptapOptions)==null?void 0:p.editorProps)==null?void 0:m.attributes,...(g=r.domAttributes)==null?void 0:g.editor,class:De("bn-editor",r.defaultStyles?"bn-default-styles":"",((w=(y=r.domAttributes)==null?void 0:y.editor)==null?void 0:w.class)||"")},transformPasted:sV}};try{let k=r.initialContent||(i?[{type:"paragraph",id:"initialBlockId"}]:[{type:"paragraph",id:Md.options.generateID()}]);if(!Array.isArray(k)||k.length===0)throw Error("initialContent must be a non-empty array of blocks, received: "+k);let x=FO(s.extensions),C=gc({type:"doc",content:[{type:"blockGroup",content:k.map(E=>si(E,x,this.schema.styleSchema).toJSON())}]},x,s.parseOptions);this._tiptapEditor=new zD({...s,content:C.toJSON()}),this.pmSchema=this._tiptapEditor.schema}catch(k){throw Error("Error creating document from blocks passed as `initialContent`",{cause:k})}let l,a=this.pmSchema.nodes.doc.createAndFill;this.pmSchema.nodes.doc.createAndFill=(...k)=>{if(l)return l;let x=a.apply(this.pmSchema.nodes.doc,k),C=JSON.parse(JSON.stringify(x.toJSON()));return C.content[0].content[0].attrs.id="initialBlockId",l=Tr.fromJSON(this.pmSchema,C),l},this.pmSchema.cached.blockNoteEditor=this,this._tiptapEditor.on("mount",()=>{this.headless=!1}),this._tiptapEditor.on("unmount",()=>{this.headless=!0}),this._blockManager=new t9(this),this._exportManager=new V9(this),this._selectionManager=new eV(this),this._stateManager=new tV(this),this._styleManager=new rV(this),this.emit("create")}static create(n){return new CS(n??{})}get extensions(){return this._extensionManager.getExtensions()}exec(n){return this._stateManager.exec(n)}canExec(n){return this._stateManager.canExec(n)}transact(n){return this._stateManager.transact(n)}get prosemirrorState(){return this._stateManager.prosemirrorState}get prosemirrorView(){return this._stateManager.prosemirrorView}get domElement(){var n;if(!this.headless)return(n=this.prosemirrorView)==null?void 0:n.dom}get portalElement(){if(typeof document>"u")throw Error("Portal element accessed, but not available in headless mode");return this._portalElement||(this._portalElement=document.createElement("div")),this._portalElement}isFocused(){var n;return this.headless?!1:((n=this.prosemirrorView)==null?void 0:n.hasFocus())||!1}focus(){this.headless||this.prosemirrorView.focus()}blur(){var n;this.headless||((n=this.domElement)==null||n.blur())}onUploadStart(n){return this.onUploadStartCallbacks.push(n),()=>{let r=this.onUploadStartCallbacks.indexOf(n);r>-1&&this.onUploadStartCallbacks.splice(r,1)}}onUploadEnd(n){return this.onUploadEndCallbacks.push(n),()=>{let r=this.onUploadEndCallbacks.indexOf(n);r>-1&&this.onUploadEndCallbacks.splice(r,1)}}get topLevelBlocks(){return this.document}get document(){return this._blockManager.document}getBlock(n){return this._blockManager.getBlock(n)}getPrevBlock(n){return this._blockManager.getPrevBlock(n)}getNextBlock(n){return this._blockManager.getNextBlock(n)}getParentBlock(n){return this._blockManager.getParentBlock(n)}forEachBlock(n,r=!1){this._blockManager.forEachBlock(n,r)}onEditorContentChange(n){this._tiptapEditor.on("update",n)}onEditorSelectionChange(n){this._tiptapEditor.on("selectionUpdate",n)}onBeforeChange(n){return this._extensionManager.getExtension(WC).subscribe(n)}getTextCursorPosition(){return this._selectionManager.getTextCursorPosition()}setTextCursorPosition(n,r="start"){return this._selectionManager.setTextCursorPosition(n,r)}getSelection(){return this._selectionManager.getSelection()}getSelectionCutBlocks(n=!1){return this._selectionManager.getSelectionCutBlocks(n)}setSelection(n,r){return this._selectionManager.setSelection(n,r)}get isEditable(){return this._stateManager.isEditable}set isEditable(n){this._stateManager.isEditable=n}insertBlocks(n,r,o="before"){return this._blockManager.insertBlocks(n,r,o)}updateBlock(n,r){return this._blockManager.updateBlock(n,r)}removeBlocks(n){return this._blockManager.removeBlocks(n)}replaceBlocks(n,r){return this._blockManager.replaceBlocks(n,r)}undo(){return this._stateManager.undo()}redo(){return this._stateManager.redo()}insertInlineContent(n,{updateSelection:r=!1}={}){this._styleManager.insertInlineContent(n,{updateSelection:r})}getActiveStyles(){return this._styleManager.getActiveStyles()}addStyles(n){this._styleManager.addStyles(n)}removeStyles(n){this._styleManager.removeStyles(n)}toggleStyles(n){this._styleManager.toggleStyles(n)}getSelectedText(){return this._styleManager.getSelectedText()}getSelectedLinkUrl(){return this._styleManager.getSelectedLinkUrl()}createLink(n,r){this._styleManager.createLink(n,r)}getLinkMarkAtPos(n){return this._styleManager.getLinkMarkAtPos(n)}editLink(n,r,o){this._styleManager.editLink(n,r,o)}deleteLink(n){this._styleManager.deleteLink(n)}canNestBlock(){return this._blockManager.canNestBlock()}nestBlock(){this._blockManager.nestBlock()}canUnnestBlock(){return this._blockManager.canUnnestBlock()}unnestBlock(){this._blockManager.unnestBlock()}moveBlocksUp(n){return this._blockManager.moveBlocksUp(n)}moveBlocksDown(n){return this._blockManager.moveBlocksDown(n)}blocksToHTMLLossy(n=this.document){return this._exportManager.blocksToHTMLLossy(n)}blocksToFullHTML(n=this.document){return this._exportManager.blocksToFullHTML(n)}tryParseHTMLToBlocks(n){return this._exportManager.tryParseHTMLToBlocks(n)}blocksToMarkdownLossy(n=this.document){return this._exportManager.blocksToMarkdownLossy(n)}tryParseMarkdownToBlocks(n){return this._exportManager.tryParseMarkdownToBlocks(n)}onChange(n,r){return this._eventManager.onChange(n,r)}onSelectionChange(n,r){return this._eventManager.onSelectionChange(n,r)}onMount(n){return this._eventManager.onMount(n)}onUnmount(n){return this._eventManager.onUnmount(n)}getSelectionBoundingBox(){return this._selectionManager.getSelectionBoundingBox()}get isEmpty(){let n=this.document;return n.length===0||n.length===1&&n[0].type==="paragraph"&&n[0].content.length===0}pasteHTML(n,r=!1){this._exportManager.pasteHTML(n,r)}pasteText(n){return this._exportManager.pasteText(n)}pasteMarkdown(n){return this._exportManager.pasteMarkdown(n)}},sf,V0;function uV(){return V0||(V0=1,sf=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;for(o of e.entries())if(!t(o[1],n.get(o[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(e[o]!==n[o])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!(s==="_owner"&&e.$$typeof)&&!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n}),sf}var fV=uV();const hV=T1(fV);var SS=v.createContext(void 0);function Rn(t){return v.useContext(SS)}function ne(t){let e=Rn();if(!(e!=null&&e.editor))throw Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return e.editor}function Se(t,e){let n=((e==null?void 0:e.editor)??ne()).getExtension(t);if(!n)throw Error("Extension not found",{cause:{plugin:t}});return n}function Fe(t,e){let{store:n}=Se(t,e);if(!n)throw Error("Store not found on plugin",{cause:{plugin:t}});return zA(n,e==null?void 0:e.selector)}function pV(t){let e=new DOMRect,n="getBoundingClientRect"in t?()=>t.getBoundingClientRect():()=>t.element.getBoundingClientRect();return()=>t.element&&(t.cacheMountedBoundingClientRect??!0)?(t.element.isConnected&&(e=n()),e):n()}function mV(t,e){return t?e?(n,r,o)=>{let i=t(n,r,o),s=e(n,r,o);return()=>{i==null||i(),s==null||s()}}:t:e}var tr=t=>{var g,y,w,k,x,C;let e=ne(),n=t.portalElement===null?typeof document<"u"?document.body:void 0:t.portalElement??(e==null?void 0:e.portalElement);if(!n)throw Error("Portal element not found");let{whileElementsMounted:r,...o}=t.useFloatingOptions??{},{refs:i,floatingStyles:s,context:l}=Al({whileElementsMounted:mV(ji,(g=t.useFloatingOptions)==null?void 0:g.whileElementsMounted),...o}),{isMounted:a,styles:c}=LA(l,t.useTransitionStylesProps),{status:d}=uv(l,t.useTransitionStatusProps),{getFloatingProps:u}=Xh([dv(l,t.useDismissProps),Kh(l,{enabled:!1,...t.useHoverProps})]),f=v.useRef(""),h=v.useRef(null),p=lA([h,i.setFloating]);if(v.useEffect(()=>{var E;if(t.reference){let S="element"in t.reference?t.reference.element:void 0;S!==void 0&&((E=t.focusManagerProps)!=null&&E.disabled||!e.isWithinEditor(S))&&i.setReference(S),i.setPositionReference({getBoundingClientRect:pV(t.reference),contextElement:S})}},[t.reference,i,(y=t.focusManagerProps)==null?void 0:y.disabled,e]),v.useEffect(()=>{var E;(d==="initial"||d==="open")&&((E=h.current)!=null&&E.innerHTML)&&(f.current=h.current.innerHTML)},[d,t.reference,t.children]),!a)return!1;let m={...t.elementProps,style:{display:"flex",...(w=t.elementProps)==null?void 0:w.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${((x=(k=t.elementProps)==null?void 0:k.style)==null?void 0:x.zIndex)||0})`,...s,...c},...u()};return d==="close"?b.jsx(gu,{root:n,children:b.jsx("div",{ref:p,...m,dangerouslySetInnerHTML:{__html:f.current}})}):(C=t.focusManagerProps)!=null&&C.disabled?b.jsx(gu,{root:n,children:b.jsx("div",{ref:p,...m,children:t.children})}):b.jsx(gu,{root:n,children:b.jsx(NA,{...t.focusManagerProps,context:l,children:b.jsx("div",{ref:p,...m,children:t.children})})})},ES=v.createContext(void 0);function Y(){return v.useContext(ES)}function de(){return Rn().editor.dictionary}var gV=typeof window<"u"?v.useLayoutEffect:v.useEffect,bV=class{constructor(e){B(this,"transactionNumber",0);B(this,"lastTransactionNumber",0);B(this,"lastSnapshot");B(this,"editor");B(this,"subscribers",new Set);this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e,n){if(this.editor=e,this.editor){let r=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},o=this.editor._tiptapEditor,i={all:["transaction","create","mount","unmount"],mount:["create","mount","unmount"],selection:["selectionUpdate"],change:["update"]};for(let s of i[n])o.on(s,r);return()=>{for(let s of i[n])o.off(s,r)}}}};function ht(t){let e=Rn(),n=t.editor||(e==null?void 0:e.editor)||null,r=t.on||"all",[o]=v.useState(()=>new bV(n)),i=R1.useSyncExternalStoreWithSelector(o.subscribe,o.getSnapshot,o.getServerSnapshot,t.selector,t.equalityFn??hV);return gV(()=>o.watch(n,r),[n,o,r]),v.useDebugValue(i),i}function ci(t){let e=Rn();return t||(t=e==null?void 0:e.editor),ht({editor:t,selector:n=>{var r;return(r=n.editor)==null?void 0:r.domElement},equalityFn:(n,r)=>n===r,on:"mount"})}var MS=t=>{let{position:e,children:n,portalElement:r,...o}=t,{from:i,to:s}=e||{},l=ne(),a=ci();return b.jsx(tr,{reference:v.useMemo(()=>{if(!(i===void 0||s===void 0))return{element:(a==null?void 0:a.firstElementChild)||void 0,getBoundingClientRect:()=>Mp(l.prosemirrorView,i,s??i)}},[l,a,i,s]),portalElement:r,...o,children:e!==void 0&&n})},Nm=(t={},e=[])=>v.useMemo(()=>{let n=dV.create(t);return window&&(window.ProseMirror=n._tiptapEditor),n},e),TS=t=>{let[e,n]=v.useState(!1),r=ht({editor:t.editor,selector:({editor:l})=>l.isEmpty}),o=Y(),i=v.useCallback(()=>{n(!0)},[]),s=v.useCallback(()=>{n(!1)},[]);return v.useEffect(()=>{t.editable&&t.autoFocus&&t.editor.focus()},[t.autoFocus,t.editable,t.editor]),b.jsxs(b.Fragment,{children:[b.jsx(o.Comments.Editor,{autoFocus:t.autoFocus,className:"bn-comment-editor",editor:t.editor,onFocus:i,onBlur:s,editable:t.editable}),t.actions&&b.jsx("div",{className:"bn-comment-actions-wrapper",children:t.actions({isFocused:e,isEmpty:r})})]})},{textColor:hW,backgroundColor:pW,...yV}=bm,AS=ym.create({blockSpecs:{paragraph:NC()},styleSpecs:yV}),H0=Object.defineProperty,vV=(t,e)=>{let n={};for(var r in t)H0(n,r,{get:t[r],enumerable:!0});return H0(n,Symbol.toStringTag,{value:"Module"}),n},F0=Nn.create({name:"comment",excludes:"",inclusive:!1,keepOnSplit:!0,addAttributes(){return{orphan:{parseHTML:t=>!!t.getAttribute("data-orphan"),renderHTML:t=>t.orphan?{"data-orphan":"true"}:{},default:!1},threadId:{parseHTML:t=>t.getAttribute("data-bn-thread-id"),renderHTML:t=>({"data-bn-thread-id":t.threadId}),default:""}}},renderHTML({HTMLAttributes:t}){return["span",dn(t,{class:"bn-thread-mark"})]},parseHTML(){return[{tag:"span.bn-thread-mark"}]},extendMarkSchema(t){return t.name==="comment"?{blocknoteIgnore:!0}:{}}}),wV=class extends wm{constructor(e){super();B(this,"userCache",new Map);B(this,"loadingUsers",new Set);this.resolveUsers=e}async loadUsers(e){let n=e.filter(r=>!this.userCache.has(r)&&!this.loadingUsers.has(r));if(n.length!==0){for(let r of n)this.loadingUsers.add(r);try{let r=await this.resolveUsers(n);for(let o of r)this.userCache.set(o.id,o);this.emit("update",this.userCache)}finally{for(let r of n)this.loadingUsers.delete(r)}}}getUser(e){return this.userCache.get(e)}subscribe(e){return this.on("update",e)}},Ma=new Ce("blocknote-comments");function kV(t,e){let n=new Map;return t.descendants((r,o)=>{r.marks.forEach(i=>{if(i.type.name===e){let s=i.attrs.threadId;if(!s)return;let l=o,a=l+r.nodeSize,c=n.get(s)??{from:1/0,to:0};n.set(s,{from:Math.min(l,c.from),to:Math.max(a,c.to)})}})}),n}var Pr=ve(({editor:t,options:{schema:e,threadStore:n,resolveUsers:r}})=>{if(!r)throw Error("resolveUsers is required to be defined when using comments");if(!n)throw Error("threadStore is required to be defined when using comments");let o=F0.name,i=new wV(r),s=go({pendingComment:!1,selectedThreadId:void 0,threadPositions:new Map},{onUpdate(){s.state.selectedThreadId!==s.prevState.selectedThreadId&&t.transact(a=>a.setMeta(Ma,!0))}}),l=a=>{t.transact(c=>{c.doc.descendants((d,u)=>{d.marks.forEach(f=>{if(f.type.name===o){let h=f.type,p=f.attrs.threadId,m=a.get(p),g=!!(!m||m.resolved||m.deletedAt);if(g!==f.attrs.orphan){let y=Math.max(u,0),w=Math.min(u+d.nodeSize,c.doc.content.size-1,c.doc.content.size-1);c.removeMark(y,w,f),c.addMark(y,w,h.create({...f.attrs,orphan:g})),g&&s.state.selectedThreadId===p&&s.setState(k=>({...k,selectedThreadId:void 0}))}}})})})};return{key:"comments",store:s,runsBefore:["link"],tiptapExtensions:[F0],prosemirrorPlugins:[new ae({key:Ma,state:{init(){return{decorations:he.empty}},apply(a,c){let d=a.getMeta(Ma);if(!a.docChanged&&!d)return c;let u=a.docChanged?kV(a.doc,o):s.state.threadPositions;(u.size>0||s.state.threadPositions.size>0)&&s.setState(h=>({...h,threadPositions:u}));let f=[];if(s.state.selectedThreadId){let h=u.get(s.state.selectedThreadId);h&&f.push(Me.inline(h.from,h.to,{class:"bn-thread-mark-selected"}))}return{decorations:he.create(a.doc,f)}}},props:{decorations(a){var c;return((c=Ma.getState(a))==null?void 0:c.decorations)??he.empty},handleClick:(a,c,d)=>{if(d.button!==0)return!1;let u=a.state.doc.nodeAt(c);if(!u)return s.setState(p=>({...p,selectedThreadId:void 0})),!1;let f=u.marks.find(p=>p.type.name===o&&p.attrs.orphan!==!0);if(!f)return s.state.selectedThreadId!==void 0&&s.setState(p=>({...p,selectedThreadId:void 0})),!1;let h=f.attrs.threadId;return h===s.state.selectedThreadId?!1:(s.setState(p=>({...p,selectedThreadId:h})),!0)}}})],threadStore:n,mount(){let a=n.subscribe(l);l(n.getThreads());let c=t.onSelectionChange(()=>{s.state.pendingComment&&s.setState(d=>({...d,pendingComment:!1}))});return()=>{a(),c()}},selectThread(a,c=!0){var d,u;if(s.state.selectedThreadId!==a&&(s.setState(f=>({...f,pendingComment:!1,selectedThreadId:a})),a&&c)){let f=s.state.threadPositions.get(a);if(!f)return;(u=(d=t.prosemirrorView)==null?void 0:d.domAtPos(f.from).node)==null||u.scrollIntoView({behavior:"smooth",block:"center"})}},startPendingComment(){var a,c;s.setState(d=>({...d,selectedThreadId:void 0,pendingComment:!0})),(a=t.domElement)==null||a.focus(),(c=t.getExtension(Pc))==null||c.showSelection(!0,"comments")},stopPendingComment(){var a;s.setState(c=>({...c,selectedThreadId:void 0,pendingComment:!1})),(a=t.getExtension(Pc))==null||a.showSelection(!1,"comments")},async createThread(a){let c=await n.createThread(a);if(n.addThreadToDocument){let d=t.prosemirrorView,u=d.state.selection,f=Le.getState(d.state),h={prosemirror:{head:u.head,anchor:u.anchor},yjs:f?Oc(f.binding,d.state):void 0};await n.addThreadToDocument({threadId:c.id,selection:h})}else t._tiptapEditor.commands.setMark(o,{orphan:!1,threadId:c.id})},userStore:i,commentEditorSchema:e}}),NS={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},z0=tt.createContext&&tt.createContext(NS),xV=["attr","size","title"];function CV(t,e){if(t==null)return{};var n,r,o=SV(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function SV(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function $c(){return $c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$c.apply(null,arguments)}function U0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Lc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?U0(Object(n),!0).forEach(function(r){EV(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):U0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function EV(t,e,n){return(e=MV(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function MV(t){var e=TV(t,"string");return typeof e=="symbol"?e:e+""}function TV(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function RS(t){return t&&t.map((e,n)=>tt.createElement(e.tag,Lc({key:n},e.attr),RS(e.child)))}function X(t){return e=>tt.createElement(AV,$c({attr:Lc({},t.attr)},e),RS(t.child))}function AV(t){var e=n=>{var r=t.attr,o=t.size,i=t.title,s=CV(t,xV),l=o||n.size||"1em",a;return n.className&&(a=n.className),t.className&&(a=(a?a+" ":"")+t.className),tt.createElement("svg",$c({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:a,style:Lc(Lc({color:t.color||n.color},n.style),t.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),i&&tt.createElement("title",null,i),t.children)};return z0!==void 0?tt.createElement(z0.Consumer,null,n=>e(n)):e(NS)}function IS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM8 13H16C16 15.2091 14.2091 17 12 17C9.79086 17 8 15.2091 8 13ZM8 11C7.17157 11 6.5 10.3284 6.5 9.5C6.5 8.67157 7.17157 8 8 8C8.82843 8 9.5 8.67157 9.5 9.5C9.5 10.3284 8.82843 11 8 11ZM16 11C15.1716 11 14.5 10.3284 14.5 9.5C14.5 8.67157 15.1716 8 16 8C16.8284 8 17.5 8.67157 17.5 9.5C17.5 10.3284 16.8284 11 16 11Z"},child:[]}]})(t)}function NV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z"},child:[]}]})(t)}function RV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5 11V13H19V11H5Z"},child:[]}]})(t)}function IV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z"},child:[]}]})(t)}function OV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z"},child:[]}]})(t)}function DV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z"},child:[]}]})(t)}function _V(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM9 11V17H11V11H9ZM13 11V17H15V11H13ZM9 4V6H15V4H9Z"},child:[]}]})(t)}function PV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z"},child:[]}]})(t)}function $V(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z"},child:[]}]})(t)}function LV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z"},child:[]}]})(t)}function BV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"},child:[]}]})(t)}function OS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M22 18V20H2V18H22ZM2 3.5L10 8.5L2 13.5V3.5ZM22 11V13H12V11H22ZM22 4V6H12V4H22Z"},child:[]}]})(t)}function jV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z"},child:[]}]})(t)}function VV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z"},child:[]}]})(t)}function HV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"},child:[]}]})(t)}function FV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"},child:[]}]})(t)}function zV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z"},child:[]}]})(t)}function Rm(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"},child:[]}]})(t)}function UV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z"},child:[]}]})(t)}function WV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z"},child:[]}]})(t)}function DS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M21 4H3V6H21V4ZM21 11H8V13H21V11ZM21 18H8V20H21V18ZM5 11H3V20H5V11Z"},child:[]}]})(t)}function qV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M21 20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20C20.5523 3 21 3.44772 21 4V20ZM19 11V5H13.001V7H15L12 10L9 7H11V5H5V11H7V13H5V19H11V17H9L12 14L15 17H13.001V19H19V13H17V11H19ZM11 13H9V11H11V13ZM15 13H13V11H15V13Z"},child:[]}]})(t)}function GV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M20 3C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM11 5H5V10.999H7V9L10 12L7 15V13H5V19H11V17H13V19H19V13H17V15L14 12L17 9V10.999H19V5H13V7H11V5ZM13 13V15H11V13H13ZM13 9V11H11V9H13Z"},child:[]}]})(t)}function _S(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z"},child:[]}]})(t)}function PS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z"},child:[]}]})(t)}function $S(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z"},child:[]}]})(t)}function LS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z"},child:[]}]})(t)}function ZV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z"},child:[]}]})(t)}function KV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z"},child:[]}]})(t)}function W0(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z"},child:[]}]})(t)}function JV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z"},child:[]}]})(t)}function YV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z"},child:[]}]})(t)}function BS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M21.097 8L18.499 12.5C20.7091 12.5 22.5 14.2909 22.5 16.5C22.5 18.7091 20.7091 20.5 18.5 20.5C16.2909 20.5 14.5 18.7091 14.5 16.5C14.5 15.7636 14.699 15.0737 15.0461 14.4811L18.788 8H21.097ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 14.5C17.3954 14.5 16.5 15.3954 16.5 16.5C16.5 17.6046 17.3954 18.5 18.5 18.5C19.6046 18.5 20.5 17.6046 20.5 16.5C20.5 15.3954 19.6046 14.5 18.5 14.5Z"},child:[]}]})(t)}function jS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M22 8V10H17.6769L17.2126 12.6358C17.5435 12.5472 17.8912 12.5 18.25 12.5C20.4591 12.5 22.25 14.2909 22.25 16.5C22.25 18.7091 20.4591 20.5 18.25 20.5C16.4233 20.5 14.8827 19.2756 14.4039 17.6027L16.3271 17.0519C16.5667 17.8881 17.3369 18.5 18.25 18.5C19.3546 18.5 20.25 17.6046 20.25 16.5C20.25 15.3954 19.3546 14.5 18.25 14.5C17.6194 14.5 17.057 14.7918 16.6904 15.2478L14.8803 14.3439L16 8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z"},child:[]}]})(t)}function VS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM22 8V16H23.5V18H22V20H20V18H14.5V16.66L19.5 8H22ZM20 11.133L17.19 16H20V11.133Z"},child:[]}]})(t)}function Bc(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z"},child:[]}]})(t)}function jc(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z"},child:[]}]})(t)}function Vc(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z"},child:[]}]})(t)}function q0(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z"},child:[]}]})(t)}function XV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z"},child:[]}]})(t)}function QV(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z"},child:[]}]})(t)}function e3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"},child:[]}]})(t)}function t3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"},child:[]}]})(t)}function n3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z"},child:[]}]})(t)}function r3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z"},child:[]}]})(t)}function o3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z"},child:[]}]})(t)}function i3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"},child:[]}]})(t)}function HS(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M7.29117 20.8242L2 22L3.17581 16.7088C2.42544 15.3056 2 13.7025 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C10.2975 22 8.6944 21.5746 7.29117 20.8242ZM7.58075 18.711L8.23428 19.0605C9.38248 19.6745 10.6655 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 13.3345 4.32549 14.6175 4.93949 15.7657L5.28896 16.4192L4.63416 19.3658L7.58075 18.711Z"},child:[]}]})(t)}function s3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M7.24264 17.9967H3V13.754L14.435 2.319C14.8256 1.92848 15.4587 1.92848 15.8492 2.319L18.6777 5.14743C19.0682 5.53795 19.0682 6.17112 18.6777 6.56164L7.24264 17.9967ZM3 19.9967H21V21.9967H3V19.9967Z"},child:[]}]})(t)}function l3(t){return X({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z"},child:[]}]})(t)}var lf;async function a3(){return lf||(lf=(async()=>{let[t,e]=await Promise.all([$i(()=>import("./module-D8iBLRih.js"),[]),$i(()=>import("./native-48B9X9Wg.js"),[])]),n="default"in t?t.default:t,r="default"in e?e.default:e;return await n.init({data:r}),{emojiMart:n,emojiData:r}})(),lf)}function c3(t){let e=v.useRef(null),n=v.useRef(null);return n.current&&n.current.update(t),v.useEffect(()=>((async()=>{let{emojiMart:r}=await a3();n.current=new r.Picker({...t,ref:e})})(),()=>{n.current=null}),[]),tt.createElement("div",{ref:e})}var FS=t=>{var s;let[e,n]=v.useState(!1),r=Y(),o=Rn(),i=(s=o.editor)==null?void 0:s.portalElement;if(!i)throw Error("Portal root not found");return b.jsxs(r.Generic.Popover.Root,{open:e,portalRoot:i,children:[b.jsx(r.Generic.Popover.Trigger,{children:b.jsx("div",{onClick:l=>{var a;l.preventDefault(),l.stopPropagation(),n(!e),(a=t.onOpenChange)==null||a.call(t,!e)},style:{display:"flex",justifyContent:"center",alignItems:"center"},children:t.children})}),b.jsx(r.Generic.Popover.Content,{className:"bn-emoji-picker-popover",variant:"panel-popover",children:b.jsx(c3,{perLine:7,onClickOutside:()=>{var l;n(!1),(l=t.onOpenChange)==null||l.call(t,!1)},onEmojiSelect:l=>{var a;t.onEmojiSelect(l),n(!1),(a=t.onOpenChange)==null||a.call(t,!1)},theme:o==null?void 0:o.colorSchemePreference})})]})};function zS(t){return Pd([t]).get(t)}function Pd(t){let e=Se(Pr).userStore,n=v.useCallback(()=>{let o=new Map;for(let i of t){let s=e.getUser(i);s&&o.set(i,s)}return o},[e,t]),r=v.useMemo(()=>({current:n()}),[n]);return v.useSyncExternalStore(v.useCallback(o=>{let i=e.subscribe(s=>{r.current=n(),o()});return e.loadUsers(t),i},[e,n,t,r]),()=>r.current)}var d3=t=>{let e=Y(),n=de(),r=Se(Pr),o=t.comment.reactions.find(a=>a.emoji===t.emoji);if(!o)throw Error("Trying to render reaction badge for non-existing reaction");let[i,s]=v.useState([]),l=Pd(i);return b.jsx(e.Generic.Badge.Root,{className:De("bn-badge","bn-comment-reaction"),text:o.userIds.length.toString(),icon:o.emoji,isSelected:r.threadStore.auth.canDeleteReaction(t.comment,o.emoji),onClick:()=>t.onReactionSelect(o.emoji),onMouseEnter:()=>s(o.userIds),mainTooltip:n.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(l.values()).map(a=>a.username).join(`
207
+ `)}`},o.emoji)},u3=v.memo(({isEmpty:t,comment:e,isEditing:n,threadStore:r,onReactionSelect:o,onEditSubmit:i,onEditCancel:s,onEmojiPickerOpenChange:l,Components:a,dict:c})=>{let d=r.auth.canAddReaction(e);return b.jsxs(b.Fragment,{children:[e.reactions.length>0&&!n&&b.jsxs(a.Generic.Badge.Group,{className:De("bn-badge-group","bn-comment-reactions"),children:[e.reactions.map(u=>b.jsx(d3,{comment:e,emoji:u.emoji,onReactionSelect:o},u.emoji)),d&&b.jsx(FS,{onEmojiSelect:u=>o(u.native),onOpenChange:l,children:b.jsx(a.Generic.Badge.Root,{className:De("bn-badge","bn-comment-add-reaction"),text:"+",icon:b.jsx(IS,{size:16}),mainTooltip:c.comments.actions.add_reaction})})]}),n&&b.jsxs(a.Generic.Toolbar.Root,{variant:"action-toolbar",className:De("bn-action-toolbar","bn-comment-actions"),children:[b.jsx(a.Generic.Toolbar.Button,{mainTooltip:c.comments.save_button_text,variant:"compact",onClick:i,isDisabled:t,children:c.comments.save_button_text}),b.jsx(a.Generic.Toolbar.Button,{className:"bn-button",mainTooltip:c.comments.cancel_button_text,variant:"compact",onClick:s,children:c.comments.cancel_button_text})]})]})}),US=({comment:t,thread:e,showResolveButton:n})=>{let r=Se(Pr),o=de(),i=Nm({initialContent:t.body,trailingBlock:!1,dictionary:{...o,placeholders:{emptyDocument:o.placeholders.edit_comment}},schema:r.commentEditorSchema||AS}),s=Y(),[l,a]=v.useState(!1),[c,d]=v.useState(!1),u=r.threadStore,f=v.useCallback(()=>{a(!0)},[]),h=v.useCallback(()=>{i.replaceBlocks(i.document,t.body),a(!1)},[i,t.body]),p=v.useCallback(async A=>{await u.updateComment({commentId:t.id,comment:{body:i.document},threadId:e.id}),a(!1)},[t,e.id,i,u]),m=v.useCallback(async()=>{await u.deleteComment({commentId:t.id,threadId:e.id})},[t,e.id,u]),g=v.useCallback(async A=>{u.auth.canAddReaction(t,A)?await u.addReaction({threadId:e.id,commentId:t.id,emoji:A}):u.auth.canDeleteReaction(t,A)&&await u.deleteReaction({threadId:e.id,commentId:t.id,emoji:A})},[u,t,e.id]),y=v.useCallback(async()=>{await u.resolveThread({threadId:e.id})},[e.id,u]),w=v.useCallback(async()=>{await u.unresolveThread({threadId:e.id})},[e.id,u]),k=zS(t.userId);if(!t.body)return null;let x,C=u.auth.canAddReaction(t),E=u.auth.canDeleteComment(t),S=u.auth.canUpdateComment(t),M=n&&(e.resolved?u.auth.canUnresolveThread(e):u.auth.canResolveThread(e));l||(x=b.jsxs(s.Generic.Toolbar.Root,{className:De("bn-action-toolbar","bn-comment-actions"),variant:"action-toolbar",children:[C&&b.jsx(FS,{onEmojiSelect:A=>g(A.native),onOpenChange:d,children:b.jsx(s.Generic.Toolbar.Button,{mainTooltip:o.comments.actions.add_reaction,variant:"compact",children:b.jsx(IS,{size:16})},"add-reaction")}),M&&(e.resolved?b.jsx(s.Generic.Toolbar.Button,{mainTooltip:o.comments.actions.reopen,variant:"compact",onClick:w,children:b.jsx(l3,{size:16})},"reopen"):b.jsx(s.Generic.Toolbar.Button,{mainTooltip:o.comments.actions.resolve,variant:"compact",onClick:y,children:b.jsx($V,{size:16})},"resolve")),(E||S)&&b.jsxs(s.Generic.Menu.Root,{position:"bottom-start",children:[b.jsx(s.Generic.Menu.Trigger,{children:b.jsx(s.Generic.Toolbar.Button,{mainTooltip:o.comments.actions.more_actions,variant:"compact",children:b.jsx(IV,{size:16})},"more-actions")}),b.jsxs(s.Generic.Menu.Dropdown,{className:"bn-menu-dropdown",children:[S&&b.jsx(s.Generic.Menu.Item,{icon:b.jsx(s3,{}),onClick:f,children:o.comments.actions.edit_comment},"edit-comment"),E&&b.jsx(s.Generic.Menu.Item,{icon:b.jsx(_V,{}),onClick:m,children:o.comments.actions.delete_comment},"delete-comment")]})]})]}));let N=t.createdAt.toLocaleDateString(void 0,{month:"short",day:"numeric"});if(!t.body)throw Error("soft deletes are not yet supported");return b.jsx(s.Comments.Comment,{authorInfo:k??"loading",timeString:N,edited:t.updatedAt.getTime()!==t.createdAt.getTime(),showActions:"hover",actions:x,className:"bn-thread-comment",emojiPickerOpen:c,children:b.jsx(TS,{autoFocus:l,editor:i,editable:l,actions:t.reactions.length>0||l?({isFocused:A,isEmpty:R})=>b.jsx(u3,{isFocused:A,isEmpty:R,comment:t,isEditing:l,threadStore:u,onReactionSelect:g,onEditSubmit:p,onEditCancel:h,onEmojiPickerOpenChange:d,Components:s,dict:o}):void 0})})},WS=({thread:t,maxCommentsBeforeCollapse:e})=>{let n=Y(),r=de(),o=Pd(t.resolvedBy?[t.resolvedBy]:[]),i=t.comments.map((s,l)=>b.jsx(US,{thread:t,comment:s,showResolveButton:l===0},s.id+JSON.stringify(s.body||"{}")));if(t.resolved&&t.resolvedUpdatedAt&&t.resolvedBy){if(!o.get(t.resolvedBy))throw Error(`User ${t.resolvedBy} resolved thread ${t.id}, but their data could not be found.`);let s=t.comments.findLastIndex(l=>t.resolvedUpdatedAt.getTime()>l.createdAt.getTime())+1;i.splice(s,0,b.jsx(n.Comments.Comment,{className:"bn-thread-comment",authorInfo:t.resolvedBy&&o.get(t.resolvedBy)||"loading",timeString:t.resolvedUpdatedAt.toLocaleDateString(void 0,{month:"short",day:"numeric"}),edited:!1,showActions:!1,children:b.jsx("div",{className:"bn-resolved-text",children:r.comments.sidebar.marked_as_resolved})},"resolved-comment"))}return e&&i.length>e&&i.splice(1,i.length-2,b.jsx(n.Comments.ExpandSectionsPrompt,{className:"bn-thread-expand-prompt",children:r.comments.sidebar.more_replies(t.comments.length-2)},"expand-prompt")),i},f3=v.memo(({isEmpty:t,onNewCommentSave:e,Components:n,dict:r})=>t?null:b.jsx(n.Generic.Toolbar.Root,{variant:"action-toolbar",className:De("bn-action-toolbar","bn-comment-actions"),children:b.jsx(n.Generic.Toolbar.Button,{mainTooltip:r.comments.save_button_text,variant:"compact",isDisabled:t,onClick:e,children:r.comments.save_button_text})})),Im=({thread:t,selected:e,orphaned:n,referenceText:r,maxCommentsBeforeCollapse:o,onFocus:i,onBlur:s,tabIndex:l})=>{let a=Y(),c=de(),d=Se(Pr),u=Nm({trailingBlock:!1,dictionary:{...c,placeholders:{emptyDocument:c.placeholders.comment_reply}},schema:d.commentEditorSchema||AS}),f=v.useCallback(async()=>{await d.threadStore.addComment({comment:{body:u.document},threadId:t.id}),u.removeBlocks(u.document)},[d,u,t.id]);return b.jsxs(a.Comments.Card,{className:De("bn-thread",n&&"bn-thread-orphaned"),headerText:r,onFocus:i,onBlur:s,selected:e,tabIndex:l,children:[b.jsx(a.Comments.CardSection,{className:"bn-thread-comments",children:b.jsx(WS,{thread:t,maxCommentsBeforeCollapse:e?void 0:o||5})}),e&&b.jsx(a.Comments.CardSection,{className:"bn-thread-composer",children:b.jsx(TS,{autoFocus:!1,editable:!0,editor:u,actions:({isFocused:h,isEmpty:p})=>b.jsx(f3,{isFocused:h,isEmpty:p,onNewCommentSave:f,Components:a,dict:c})})})]})};function qS(){let t=Se(Pr).threadStore,e=v.useRef(void 0);return e.current||(e.current=t.getThreads()),v.useSyncExternalStore(v.useCallback(n=>t.subscribe(r=>{e.current=r,n()}),[t]),()=>e.current)}var h3=vV({default:()=>GS});function GS(t){let e=ne(),n=Se(Pr),r=Fe(Pr,{editor:e,selector:a=>a.selectedThreadId?{id:a.selectedThreadId,position:a.threadPositions.get(a.selectedThreadId)}:void 0}),o=qS(),i=v.useMemo(()=>r?o.get(r.id):void 0,[r,o]),s=v.useMemo(()=>{var a,c,d;return{...t.floatingUIOptions,useFloatingOptions:{open:!!r,onOpenChange:(u,f,h)=>{h==="escape-key"&&e.focus(),u||n.selectThread(void 0)},placement:"bottom",middleware:[Hn(10),ri(),jo()],...(a=t.floatingUIOptions)==null?void 0:a.useFloatingOptions},focusManagerProps:{disabled:!0,...(c=t.floatingUIOptions)==null?void 0:c.focusManagerProps},elementProps:{style:{zIndex:30},...(d=t.floatingUIOptions)==null?void 0:d.elementProps}}},[n,e,t.floatingUIOptions,r]),l=t.floatingThread||Im;return b.jsx(MS,{position:r==null?void 0:r.position,portalElement:t.portalElement,...s,children:i&&b.jsx(l,{thread:i,selected:!0})})}const p3=Object.freeze(Object.defineProperty({__proto__:null,a:WS,c:Pd,i:Im,n:h3,o:US,r:qS,s:zS,t:GS},Symbol.toStringTag,{value:"Module"}));function m3(t){return X({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z"},child:[]},{tag:"path",attr:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z"},child:[]}]})(t)}function g3(t){return X({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m7 10 5 5 5-5z"},child:[]}]})(t)}function ZS(t){return X({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"},child:[]}]})(t)}var b3=MM(),y3=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},v3=({contentComponent:t})=>{const e=b3.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return b.jsx(b.Fragment,{children:Object.values(e)})};function w3(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:A1.createPortal(r.reactElement,r.element,n)},t.forEach(o=>o())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(o=>o())}}}var k3=class extends tt.Component{constructor(t){super(t),this.editorContentRef=tt.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=w3(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return b.jsxs(b.Fragment,{children:[b.jsx("div",{ref:y3(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&b.jsx(v3,{contentComponent:t.contentComponent})]})}},x3=v.forwardRef((t,e)=>{const n=tt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return tt.createElement(k3,{key:n,innerRef:e,...t})}),C3=tt.memo(x3),KS=v.createContext({editor:null});KS.Consumer;var JS=v.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),YS=()=>v.useContext(JS),S3=tt.forwardRef((t,e)=>{const{onDragStart:n}=YS(),r=t.as||"div";return b.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function G0(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Z0(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function E3(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function M3(t){if(G0(t)||Z0(t))return!0;if(E3(t)){const e=t.type;if(e)return G0(e)||Z0(e)}return!1}function T3(){try{if(v.version)return parseInt(v.version.split(".")[0],10)>=19}catch{}return!1}var A3=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isEditorContentInitialized?Dr.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,o=T3(),i=M3(e),s={...n};s.ref&&!(o||i)&&delete s.ref,!s.ref&&(o||i)&&(s.ref=l=>{this.ref=l}),this.reactElement=b.jsx(e,{...s}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1;const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const o=n[r];if(t[o]!==this.props[o]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};tt.createContext({markViewContentRef:()=>{}});var N3=class extends UD{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{const r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,o){var i;return r==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode(),ref:v.createRef()};if(!this.component.displayName){const c=d=>d.charAt(0).toUpperCase()+d.substring(1);this.component.displayName=c(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&(c.hasAttribute("data-node-view-wrapper")&&c.removeAttribute("data-node-view-wrapper"),c.appendChild(this.contentDOMElement))}},i=this.component,s=v.memo(c=>b.jsx(JS.Provider,{value:o,children:v.createElement(i,c)}));s.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new A3(s,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const t=this.currentPos;if(typeof t!="number")return;if(JO({selection:this.editor.state.selection,pos:t,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=l=>{this.renderer.updateProps(l),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const l=this.node,a=this.decorations,c=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:l,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:c,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(!(t!==this.node))return this.node=t,this.decorations=e,this.innerDecorations=n,!0;const i=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=i;const s={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(s.getPos=()=>this.getPos()),r(s),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=rl(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function R3(t,e){return n=>n.editor.contentComponent?new N3(t,n,e):{}}var Om=v.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Om.displayName="TiptapContext";var I3=()=>v.useContext(Om);function XS({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const o=v.useMemo(()=>({editor:r}),[r]),i=v.useMemo(()=>({editor:r}),[r]);return b.jsx(KS.Provider,{value:i,children:b.jsx(Om.Provider,{value:o,children:n})})}XS.displayName="Tiptap";function QS({...t}){const{editor:e}=I3();return b.jsx(C3,{editor:e,...t})}QS.displayName="Tiptap.Content";Object.assign(XS,{Content:QS});var e2=t=>{let{blockId:e,children:n,portalElement:r,...o}=t,i=ne();return b.jsx(tr,{reference:v.useMemo(()=>i.transact(s=>{if(!e)return;let l=Ht(e,s.doc);if(!l)return;let{node:a}=i.prosemirrorView.domAtPos(l.posBeforeNode+1);if(a instanceof Element)return{element:a}}),[i,e]),portalElement:r,...o,children:e!==void 0&&n})},O3=t=>{let e=Y(),n=de(),r=ne(),o=r.getBlock(t.blockId),[i,s]=v.useState(""),l=v.useCallback(d=>{s(d.currentTarget.value)},[]),a=v.useCallback(d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&(d.preventDefault(),r.updateBlock(o.id,{props:{name:r0(i),url:i}}))},[r,o.id,i]),c=v.useCallback(()=>{r.updateBlock(o.id,{props:{name:r0(i),url:i}})},[r,o.id,i]);return b.jsxs(e.FilePanel.TabPanel,{className:"bn-tab-panel",children:[b.jsx(e.FilePanel.TextInput,{className:"bn-text-input",placeholder:n.file_panel.embed.url_placeholder,value:i,onChange:l,onKeyDown:a,"data-test":"embed-input"}),b.jsx(e.FilePanel.Button,{className:"bn-button",onClick:c,"data-test":"embed-input-button",children:n.file_panel.embed.embed_button[o.type]||n.file_panel.embed.embed_button.file})]})},D3=t=>{var u,f;let e=Y(),n=de(),{setLoading:r}=t,o=ne(),i=o.getBlock(t.blockId),[s,l]=v.useState(!1);v.useEffect(()=>{s&&setTimeout(()=>{l(!1)},3e3)},[s]);let a=v.useCallback(h=>{if(h===null)return;async function p(m){if(r(!0),o.uploadFile!==void 0)try{let g=await o.uploadFile(m,t.blockId);typeof g=="string"&&(g={props:{name:m.name,url:g}}),o.updateBlock(t.blockId,g)}catch{l(!0)}finally{r(!1)}}p(h)},[t.blockId,o,r]),c=o.schema.blockSpecs[i.type],d=(f=(u=c.implementation.meta)==null?void 0:u.fileBlockAccept)!=null&&f.length?c.implementation.meta.fileBlockAccept.join(","):"*/*";return b.jsxs(e.FilePanel.TabPanel,{className:"bn-tab-panel",children:[b.jsx(e.FilePanel.FileInput,{className:"bn-file-input","data-test":"upload-input",accept:d,placeholder:n.file_panel.upload.file_placeholder[i.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:a}),s&&b.jsx("div",{className:"bn-error-text",children:n.file_panel.upload.upload_error})]})},t2=t=>{let e=Y(),n=de(),r=ne(),[o,i]=v.useState(!1),s=t.tabs??[...r.uploadFile===void 0?[]:[{name:n.file_panel.upload.title,tabPanel:b.jsx(D3,{blockId:t.blockId,setLoading:i})}],{name:n.file_panel.embed.title,tabPanel:b.jsx(O3,{blockId:t.blockId})}],[l,a]=v.useState(t.defaultOpenTab||s[0].name);return b.jsx(e.FilePanel.Root,{className:"bn-panel",defaultOpenTab:l,openTab:l,setOpenTab:a,tabs:s,loading:o})},_3=t=>{let e=ne(),n=Se(Bn),r=Fe(Bn),o=v.useMemo(()=>{var s,l,a;return{...t.floatingUIOptions,useFloatingOptions:{open:!!r,onOpenChange:(c,d,u)=>{c||n.closeMenu(),u==="escape-key"&&e.focus()},middleware:[Hn(10),jo()],...(s=t.floatingUIOptions)==null?void 0:s.useFloatingOptions},focusManagerProps:{disabled:!0,...(l=t.floatingUIOptions)==null?void 0:l.focusManagerProps},elementProps:{style:{zIndex:90},...(a=t.floatingUIOptions)==null?void 0:a.elementProps}}},[r,e,n,t.floatingUIOptions]),i=t.filePanel||t2;return b.jsx(e2,{blockId:r,portalElement:t.portalElement,...o,children:r&&b.jsx(i,{blockId:r})})},P3={bold:QV,italic:KV,underline:zV,strike:WV,code:o3};function $3(t,e){return t in e.schema.styleSchema&&e.schema.styleSchema[t].type===t&&e.schema.styleSchema[t].propSchema==="boolean"}var Ta=t=>{let e=de(),n=Y(),r=ne(),o=ht({editor:r,selector:({editor:l})=>{var a;if(!(!l.isEditable||!$3(t.basicTextStyle,l)||!(((a=l.getSelection())==null?void 0:a.blocks)||[l.getTextCursorPosition().block]).find(c=>c.content!==void 0)))return t.basicTextStyle in l.getActiveStyles()?{active:!0}:{active:!1}}}),i=v.useCallback(l=>{r.focus(),r.toggleStyles({[l]:!0})},[r,t]);if(o===void 0)return null;let s=P3[t.basicTextStyle];return b.jsx(n.FormattingToolbar.Button,{className:"bn-button","data-test":t.basicTextStyle,onClick:()=>i(t.basicTextStyle),isSelected:o.active,label:e.formatting_toolbar[t.basicTextStyle].tooltip,mainTooltip:e.formatting_toolbar[t.basicTextStyle].tooltip,secondaryTooltip:pn(e.formatting_toolbar[t.basicTextStyle].secondary_tooltip,e.generic.ctrl_shortcut),icon:b.jsx(s,{})})},Ih=t=>{let e=t.textColor||"default",n=t.backgroundColor||"default",r=t.size||16;return b.jsx("div",{className:"bn-color-icon","data-background-color":n,"data-text-color":e,style:v.useMemo(()=>({pointerEvents:"none",fontSize:(r*.75).toString()+"px",height:r.toString()+"px",lineHeight:r.toString()+"px",textAlign:"center",width:r.toString()+"px"}),[r]),children:"A"})},K0=["default","gray","brown","red","orange","yellow","green","blue","purple","pink"],$d=t=>{let e=Y(),n=de();return b.jsxs(b.Fragment,{children:[b.jsx(()=>t.text?b.jsxs(b.Fragment,{children:[b.jsx(e.Generic.Menu.Label,{children:n.color_picker.text_title}),K0.map(r=>b.jsx(e.Generic.Menu.Item,{onClick:()=>{t.onClick&&t.onClick(),t.text.setColor(r)},"data-test":"text-color-"+r,icon:b.jsx(Ih,{textColor:r,size:t.iconSize}),checked:t.text.color===r,children:n.color_picker.colors[r]},"text-color-"+r))]}):null,{}),b.jsx(()=>t.background?b.jsxs(b.Fragment,{children:[b.jsx(e.Generic.Menu.Label,{children:n.color_picker.background_title}),K0.map(r=>b.jsx(e.Generic.Menu.Item,{onClick:()=>{t.onClick&&t.onClick(),t.background.setColor(r)},"data-test":"background-color-"+r,icon:b.jsx(Ih,{backgroundColor:r,size:t.iconSize}),checked:t.background.color===r,children:n.color_picker.colors[r]},"background-color-"+r))]}):null,{})]})};function Aa(t,e){return`${t}Color`in e.schema.styleSchema&&e.schema.styleSchema[`${t}Color`].type===`${t}Color`&&e.schema.styleSchema[`${t}Color`].propSchema==="string"}var L3=()=>{let t=Y(),e=de(),n=ne(),r=Aa("text",n),o=Aa("background",n),i=ht({editor:n,selector:({editor:a})=>{var u;if(!a.isEditable||!(((u=a.getSelection())==null?void 0:u.blocks)||[a.getTextCursorPosition().block]).find(f=>f.content!==void 0))return;let c=Aa("text",a),d=Aa("background",a);if(!(!c&&!d))return{textColor:c?a.getActiveStyles().textColor||"default":void 0,backgroundColor:d?a.getActiveStyles().backgroundColor||"default":void 0}}}),s=v.useCallback(a=>{if(!r)throw Error("Tried to set text color, but style does not exist in editor schema.");a==="default"?n.removeStyles({textColor:a}):n.addStyles({textColor:a}),setTimeout(()=>{n.focus()})},[n,r]),l=v.useCallback(a=>{if(!o)throw Error("Tried to set background color, but style does not exist in editor schema.");a==="default"?n.removeStyles({backgroundColor:a}):n.addStyles({backgroundColor:a}),setTimeout(()=>{n.focus()})},[o,n]);return i===void 0?null:b.jsxs(t.Generic.Menu.Root,{children:[b.jsx(t.Generic.Menu.Trigger,{children:b.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"colors",label:e.formatting_toolbar.colors.tooltip,mainTooltip:e.formatting_toolbar.colors.tooltip,icon:b.jsx(Ih,{textColor:i.textColor,backgroundColor:i.backgroundColor,size:20})})}),b.jsx(t.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-color-picker-dropdown",children:b.jsx($d,{text:i.textColor?{color:i.textColor,setColor:s}:void 0,background:i.backgroundColor?{color:i.backgroundColor,setColor:l}:void 0})})]})},J0=t=>{for(let e of I7)if(t.startsWith(e))return t;return`${O7}://${t}`},n2=t=>{let e=Y(),n=de(),{editLink:r}=Se(zl),{url:o,text:i,showTextField:s}=t,[l,a]=v.useState(o),[c,d]=v.useState(i);v.useEffect(()=>{a(o),d(i)},[i,o]);let u=v.useCallback(m=>{var g,y;m.key==="Enter"&&!m.nativeEvent.isComposing&&(m.preventDefault(),r(J0(l),c,t.range.from),(g=t.setToolbarOpen)==null||g.call(t,!1),(y=t.setToolbarPositionFrozen)==null||y.call(t,!1))},[r,l,c,t]),f=v.useCallback(m=>a(m.currentTarget.value),[]),h=v.useCallback(m=>d(m.currentTarget.value),[]),p=v.useCallback(()=>{var m,g;r(J0(l),c,t.range.from),(m=t.setToolbarOpen)==null||m.call(t,!1),(g=t.setToolbarPositionFrozen)==null||g.call(t,!1)},[r,l,c,t]);return b.jsxs(e.Generic.Form.Root,{children:[b.jsx(e.Generic.Form.TextInput,{className:"bn-text-input",name:"url",icon:b.jsx(LS,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:l,onKeyDown:u,onChange:f,onSubmit:p}),s!==!1&&b.jsx(e.Generic.Form.TextInput,{className:"bn-text-input",name:"title",icon:b.jsx(Rm,{}),placeholder:n.link_toolbar.form.title_placeholder,value:c,onKeyDown:u,onChange:h,onSubmit:p})]})};function B3(t){return"link"in t.schema.inlineContentSchema&&t.schema.inlineContentSchema.link==="link"}var j3=()=>{let t=ne(),e=ci(),n=Y(),r=de(),o=Se(vn),{showSelection:i}=Se(Pc),[s,l]=v.useState(!1);v.useEffect(()=>(i(s,"createLinkButton"),()=>i(!1,"createLinkButton")),[s,i]);let a=ht({editor:t,selector:({editor:c})=>{var d;if(!(!c.isEditable||!B3(c)||Ch(c.prosemirrorState.selection)||!(((d=c.getSelection())==null?void 0:d.blocks)||[c.getTextCursorPosition().block]).find(u=>u.content!==void 0)))return{url:c.getSelectedLinkUrl(),text:c.getSelectedText(),range:{from:c.prosemirrorState.selection.from,to:c.prosemirrorState.selection.to}}}});return v.useEffect(()=>{l(!1)},[a]),v.useEffect(()=>{let c=d=>{(d.ctrlKey||d.metaKey)&&d.key==="k"&&(l(!0),d.preventDefault())};return e==null||e.addEventListener("keydown",c),()=>{e==null||e.removeEventListener("keydown",c)}},[e]),a===void 0?null:b.jsxs(n.Generic.Popover.Root,{open:s,onOpenChange:l,children:[b.jsx(n.Generic.Popover.Trigger,{children:b.jsx(n.FormattingToolbar.Button,{className:"bn-button","data-test":"createLink",label:r.formatting_toolbar.link.tooltip,mainTooltip:r.formatting_toolbar.link.tooltip,secondaryTooltip:pn(r.formatting_toolbar.link.secondary_tooltip,r.generic.ctrl_shortcut),icon:b.jsx(LS,{}),onClick:()=>l(c=>!c)})}),b.jsx(n.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:b.jsx(n2,{url:a.url||"",text:a.text,range:a.range,showTextField:!1,setToolbarOpen:c=>o.store.setState(c)})})]})},V3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:a})=>{var u;if(!a.isEditable)return;let c=((u=a.getSelection())==null?void 0:u.blocks)||[a.getTextCursorPosition().block];if(c.length!==1)return;let d=c[0];if(Wt(d,a,d.type,{url:"string",caption:"string"}))return d}}),[o,i]=v.useState(!1),s=v.useCallback(a=>{r!==void 0&&Ue(n,r.type,{caption:"string"})&&n.updateBlock(r.id,{props:{caption:a.currentTarget.value}})},[r,n]),l=v.useCallback(a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),i(!1))},[]);return r===void 0?null:b.jsxs(e.Generic.Popover.Root,{open:o,onOpenChange:i,children:[b.jsx(e.Generic.Popover.Trigger,{children:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.file_caption.tooltip,mainTooltip:t.formatting_toolbar.file_caption.tooltip,icon:b.jsx(W0,{}),onClick:()=>i(a=>!a)})}),b.jsx(e.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:b.jsx(e.Generic.Form.Root,{children:b.jsx(e.Generic.Form.TextInput,{name:"file-caption",icon:b.jsx(W0,{}),value:r.props.caption,autoFocus:!0,placeholder:t.formatting_toolbar.file_caption.input_placeholder,onKeyDown:l,onChange:s})})})]})},H3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:i})=>{var a;if(!i.isEditable)return;let s=((a=i.getSelection())==null?void 0:a.blocks)||[i.getTextCursorPosition().block];if(s.length!==1)return;let l=s[0];if(Wt(l,i,l.type,{url:"string"}))return l}}),o=v.useCallback(()=>{r!==void 0&&(n.focus(),n.removeBlocks([r.id]))},[r,n]);return r===void 0?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.file_delete.tooltip[r.type]||t.formatting_toolbar.file_delete.tooltip.file,mainTooltip:t.formatting_toolbar.file_delete.tooltip[r.type]||t.formatting_toolbar.file_delete.tooltip.file,icon:b.jsx(PV,{}),onClick:o})},F3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:a})=>{var u;if(!a.isEditable)return;let c=((u=a.getSelection())==null?void 0:u.blocks)||[a.getTextCursorPosition().block];if(c.length!==1)return;let d=c[0];if(Wt(d,a,d.type,{url:"string",name:"string"}))return d}}),[o,i]=v.useState(!1),s=v.useCallback(a=>{r!==void 0&&Ue(n,r.type,{name:"string"})&&n.updateBlock(r.id,{props:{name:a.currentTarget.value}})},[r,n]),l=v.useCallback(a=>{a.key==="Enter"&&!a.nativeEvent.isComposing&&(a.preventDefault(),i(!1))},[]);return r===void 0?null:b.jsxs(e.Generic.Popover.Root,{open:o,onOpenChange:i,children:[b.jsx(e.Generic.Popover.Trigger,{children:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.file_rename.tooltip[r.type]||t.formatting_toolbar.file_rename.tooltip.file,mainTooltip:t.formatting_toolbar.file_rename.tooltip[r.type]||t.formatting_toolbar.file_rename.tooltip.file,icon:b.jsx(q0,{}),onClick:()=>i(a=>!a)})}),b.jsx(e.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:b.jsx(e.Generic.Form.Root,{children:b.jsx(e.Generic.Form.TextInput,{name:"file-name",icon:b.jsx(q0,{}),value:r.props.name,autoFocus:!0,placeholder:t.formatting_toolbar.file_rename.input_placeholder[r.type]||t.formatting_toolbar.file_rename.input_placeholder.file,onKeyDown:l,onChange:s})})})]})},z3=()=>{let t=de(),e=Y(),n=ht({editor:ne(),selector:({editor:r})=>{var s;if(!r.isEditable)return;let o=((s=r.getSelection())==null?void 0:s.blocks)||[r.getTextCursorPosition().block];if(o.length!==1)return;let i=o[0];if(Wt(i,r,i.type,{url:"string"}))return i}});return n===void 0?null:b.jsxs(e.Generic.Popover.Root,{position:"bottom",children:[b.jsx(e.Generic.Popover.Trigger,{children:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",mainTooltip:t.formatting_toolbar.file_replace.tooltip[n.type]||t.formatting_toolbar.file_replace.tooltip.file,label:t.formatting_toolbar.file_replace.tooltip[n.type]||t.formatting_toolbar.file_replace.tooltip.file,icon:b.jsx(jV,{})})}),b.jsx(e.Generic.Popover.Content,{className:"bn-popover-content bn-panel-popover",variant:"panel-popover",children:b.jsx(t2,{blockId:n.id})})]})},U3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:i})=>{var s;if(!(!i.isEditable||!(((s=i.getSelection())==null?void 0:s.blocks)||[i.getTextCursorPosition().block]).find(l=>l.content!==void 0)))return{canNestBlock:i.canNestBlock()}}}),o=v.useCallback(()=>{r!==void 0&&r.canNestBlock&&(n.focus(),n.nestBlock())},[n,r]);return r===void 0?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":"nestBlock",onClick:o,isDisabled:!r.canNestBlock,label:t.formatting_toolbar.nest.tooltip,mainTooltip:t.formatting_toolbar.nest.tooltip,secondaryTooltip:pn(t.formatting_toolbar.nest.secondary_tooltip,t.generic.ctrl_shortcut),icon:b.jsx(JV,{})})},W3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:i})=>{var s;if(!(!i.isEditable||!(((s=i.getSelection())==null?void 0:s.blocks)||[i.getTextCursorPosition().block]).find(l=>l.content!==void 0)))return{canUnnestBlock:i.canUnnestBlock()}}}),o=v.useCallback(()=>{r!==void 0&&r.canUnnestBlock&&(n.focus(),n.unnestBlock())},[n,r]);return r===void 0?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":"unnestBlock",onClick:o,isDisabled:!r.canUnnestBlock,label:t.formatting_toolbar.unnest.tooltip,mainTooltip:t.formatting_toolbar.unnest.tooltip,secondaryTooltip:pn(t.formatting_toolbar.unnest.secondary_tooltip,t.generic.ctrl_shortcut),icon:b.jsx(YV,{})})},q3=t=>[{name:t.slash_menu.paragraph.title,type:"paragraph",icon:Rm},{name:t.slash_menu.heading.title,type:"heading",props:{level:1,isToggleable:!1},icon:Vc},{name:t.slash_menu.heading_2.title,type:"heading",props:{level:2,isToggleable:!1},icon:jc},{name:t.slash_menu.heading_3.title,type:"heading",props:{level:3,isToggleable:!1},icon:Bc},{name:t.slash_menu.heading_4.title,type:"heading",props:{level:4,isToggleable:!1},icon:VS},{name:t.slash_menu.heading_5.title,type:"heading",props:{level:5,isToggleable:!1},icon:jS},{name:t.slash_menu.heading_6.title,type:"heading",props:{level:6,isToggleable:!1},icon:BS},{name:t.slash_menu.toggle_heading.title,type:"heading",props:{level:1,isToggleable:!0},icon:Vc},{name:t.slash_menu.toggle_heading_2.title,type:"heading",props:{level:2,isToggleable:!0},icon:jc},{name:t.slash_menu.toggle_heading_3.title,type:"heading",props:{level:3,isToggleable:!0},icon:Bc},{name:t.slash_menu.quote.title,type:"quote",icon:DS},{name:t.slash_menu.toggle_list.title,type:"toggleListItem",icon:OS},{name:t.slash_menu.bullet_list.title,type:"bulletListItem",icon:_S},{name:t.slash_menu.numbered_list.title,type:"numberedListItem",icon:PS},{name:t.slash_menu.check_list.title,type:"checkListItem",icon:$S}],G3=t=>{let e=Y(),n=ne(),r=ht({editor:n,selector:({editor:l})=>{var a;return((a=l.getSelection())==null?void 0:a.blocks)||[l.getTextCursorPosition().block]}}),o=r[0],i=v.useMemo(()=>(t.items||q3(n.dictionary)).filter(l=>Ue(n,l.type,Object.fromEntries(Object.entries(l.props||{}).map(([a,c])=>[a,typeof c])))),[n,t.items]),s=v.useMemo(()=>i.map(l=>{let a=l.icon,c=l.type===o.type,d=Object.entries(l.props||{}).filter(([u,f])=>f!==o.props[u]).length===0;return{text:l.name,icon:b.jsx(a,{size:16}),onClick:()=>{n.focus(),n.transact(()=>{for(let u of r)n.updateBlock(u,{type:l.type,props:l.props})})},isSelected:c&&d}}),[n,i,o.props,o.type,r]);return!v.useMemo(()=>s.find(l=>l.isSelected)!==void 0,[s])||!n.isEditable?null:b.jsx(e.FormattingToolbar.Select,{className:"bn-select",items:s})},Z3=()=>{let t=de(),e=Y(),n=Se("comments"),{store:r}=Se(vn),o=v.useCallback(()=>{n.startPendingComment(),r.setState(!1)},[n,r]);return b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.comment.tooltip,mainTooltip:t.formatting_toolbar.comment.tooltip,icon:b.jsx(HS,{}),onClick:o})},K3=()=>ne().getExtension("comments")?b.jsx(Z3,{}):null,J3=()=>{let t=de(),e=Y(),n=ne(),r=v.useCallback(()=>{n._tiptapEditor.chain().focus().addPendingComment().run()},[n]);return!n._tiptapEditor.commands.addPendingComment||!n.isEditable?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.comment.tooltip,mainTooltip:t.formatting_toolbar.comment.tooltip,icon:b.jsx(HS,{}),onClick:r})};function Oh(t,e){try{let n=new URL(t,e);if(n.protocol!=="javascript:")return n.href}catch{}return"#"}var Y3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:i})=>{var a;let s=((a=i.getSelection())==null?void 0:a.blocks)||[i.getTextCursorPosition().block];if(s.length!==1)return;let l=s[0];if(Wt(l,i,l.type,{url:"string"}))return l}}),o=v.useCallback(()=>{r!==void 0&&(n.focus(),n.resolveFileUrl?n.resolveFileUrl(r.props.url).then(i=>window.open(Oh(i,window.location.href))):window.open(Oh(r.props.url,window.location.href)))},[r,n]);return r===void 0?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.file_download.tooltip[r.type]||t.formatting_toolbar.file_download.tooltip.file,mainTooltip:t.formatting_toolbar.file_download.tooltip[r.type]||t.formatting_toolbar.file_download.tooltip.file,icon:b.jsx(DV,{}),onClick:o})},X3=()=>{let t=de(),e=Y(),n=ne(),r=ht({editor:n,selector:({editor:i})=>{var a;if(!i.isEditable)return;let s=((a=i.getSelection())==null?void 0:a.blocks)||[i.getTextCursorPosition().block];if(s.length!==1)return;let l=s[0];if(Wt(l,i,l.type,{url:"string",showPreview:"boolean"}))return l}}),o=v.useCallback(()=>{r!==void 0&&Ue(n,r.type,{showPreview:"boolean"})&&n.updateBlock(r.id,{props:{showPreview:!r.props.showPreview}})},[r,n]);return r===void 0?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:"Toggle preview",mainTooltip:t.formatting_toolbar.file_preview_toggle.tooltip,icon:b.jsx(VV,{}),isSelected:r.props.showPreview,onClick:o})},Q3=()=>{let t=de(),e=Y(),n=ne(),r=Se(_e),o=ht({editor:n,selector:({editor:s})=>{var c;if(!s.isEditable||!s.settings.tables.splitCells)return;let l=((c=s.getSelection())==null?void 0:c.blocks)||[s.getTextCursorPosition().block];if(l.length!==1)return;let a=l[0];if(a.type==="table")return{mergeDirection:r.getMergeDirection(a)}}}),i=v.useCallback(()=>{r==null||r.mergeCells()},[r]);return o===void 0?null:b.jsx(e.FormattingToolbar.Button,{className:"bn-button",label:t.formatting_toolbar.table_cell_merge.tooltip,mainTooltip:t.formatting_toolbar.table_cell_merge.tooltip,icon:o.mergeDirection==="horizontal"?b.jsx(GV,{}):b.jsx(qV,{}),onClick:i})},e6=()=>ne().getExtension(_e)?b.jsx(Q3,{}):null,t6={left:t3,center:r3,right:e3,justify:n3},af=t=>{let e=Y(),n=de(),r=ne(),o=ht({editor:r,selector:({editor:l})=>{var d,u;if(!l.isEditable)return;let a=((d=l.getSelection())==null?void 0:d.blocks)||[l.getTextCursorPosition().block],c=a[0];if(Wt(c,l,c.type,{textAlignment:xe.textAlignment}))return{textAlignment:c.props.textAlignment,blocks:a};if(a.length===1&&Wt(c,l,"table"))return(u=l.getExtension(_e))!=null&&u.getCellSelection()?{textAlignment:lo(c.content.rows[0].cells[0]).props.textAlignment,blocks:[c]}:void 0}}),i=v.useCallback(l=>{var a;if(o!==void 0){r.focus();for(let c of o.blocks)if(Wt(c,r,c.type,{textAlignment:xe.textAlignment})&&Ue(r,c.type,{textAlignment:xe.textAlignment}))r.updateBlock(c,{props:{textAlignment:l}});else if(c.type==="table"){let d=(a=r.getExtension(_e))==null?void 0:a.getCellSelection();if(!d)continue;let u=c.content.rows.map(f=>({...f,cells:f.cells.map(h=>lo(h))}));d.cells.forEach(({row:f,col:h})=>{u[f].cells[h].props.textAlignment=l}),r.updateBlock(c,{type:"table",content:{...c.content,type:"tableContent",rows:u}}),r.setTextCursorPosition(c)}}},[r,o]);if(o===void 0)return null;let s=t6[t.textAlignment];return b.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":`alignText${t.textAlignment.slice(0,1).toUpperCase()+t.textAlignment.slice(1)}`,onClick:()=>i(t.textAlignment),isSelected:o.textAlignment===t.textAlignment,label:n.formatting_toolbar[`align_${t.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${t.textAlignment}`].tooltip,icon:b.jsx(s,{})})},r2=t=>[b.jsx(G3,{items:t},"blockTypeSelect"),b.jsx(e6,{},"tableCellMergeButton"),b.jsx(V3,{},"fileCaptionButton"),b.jsx(z3,{},"replaceFileButton"),b.jsx(F3,{},"fileRenameButton"),b.jsx(H3,{},"fileDeleteButton"),b.jsx(Y3,{},"fileDownloadButton"),b.jsx(X3,{},"filePreviewButton"),b.jsx(Ta,{basicTextStyle:"bold"},"boldStyleButton"),b.jsx(Ta,{basicTextStyle:"italic"},"italicStyleButton"),b.jsx(Ta,{basicTextStyle:"underline"},"underlineStyleButton"),b.jsx(Ta,{basicTextStyle:"strike"},"strikeStyleButton"),b.jsx(af,{textAlignment:"left"},"textAlignLeftButton"),b.jsx(af,{textAlignment:"center"},"textAlignCenterButton"),b.jsx(af,{textAlignment:"right"},"textAlignRightButton"),b.jsx(L3,{},"colorStyleButton"),b.jsx(U3,{},"nestBlockButton"),b.jsx(W3,{},"unnestBlockButton"),b.jsx(j3,{},"createLinkButton"),b.jsx(K3,{},"addCommentButton"),b.jsx(J3,{},"addTiptapCommentButton")],o2=t=>b.jsx(Y().FormattingToolbar.Root,{className:"bn-toolbar bn-formatting-toolbar",children:t.children||r2(t.blockTypeSelectItems)}),n6=t=>{switch(t){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},i2=t=>{let e=ne(),n=Se(vn,{editor:e}),r=Fe(vn,{editor:e}),o=ht({editor:e,selector:({editor:a})=>n.store.state?{from:a.prosemirrorState.selection.from,to:a.prosemirrorState.selection.to}:void 0}),i=ht({editor:e,selector:({editor:a})=>{let c=a.getTextCursorPosition().block;return Wt(c,a,c.type,{textAlignment:xe.textAlignment})?n6(c.props.textAlignment):"top-start"}}),s=v.useMemo(()=>{var a,c,d;return{...t.floatingUIOptions,useFloatingOptions:{open:r,onOpenChange:(u,f,h)=>{n.store.setState(u),h==="escape-key"&&e.focus()},placement:i,middleware:[Hn(10),ri(),jo()],...(a=t.floatingUIOptions)==null?void 0:a.useFloatingOptions},focusManagerProps:{disabled:!0,...(c=t.floatingUIOptions)==null?void 0:c.focusManagerProps},elementProps:{style:{zIndex:40},...(d=t.floatingUIOptions)==null?void 0:d.elementProps}}},[r,i,t.floatingUIOptions,n.store,e]),l=t.formattingToolbar||o2;return b.jsx(MS,{position:o,portalElement:t.portalElement,...s,children:r&&b.jsx(l,{})})},r6=t=>{let e=Y(),n=de(),{deleteLink:r}=Se(zl);return b.jsx(e.LinkToolbar.Button,{className:"bn-button",label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:()=>{var o;r(t.range.from),(o=t.setToolbarOpen)==null||o.call(t,!1)},icon:b.jsx(ZV,{})})},o6=t=>{let e=Y(),n=de();return b.jsxs(e.Generic.Popover.Root,{onOpenChange:t.setToolbarPositionFrozen,children:[b.jsx(e.Generic.Popover.Trigger,{children:b.jsx(e.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.edit.tooltip,isSelected:!1,children:n.link_toolbar.edit.text})}),b.jsx(e.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:b.jsx(n2,{url:t.url,text:t.text,range:t.range,setToolbarOpen:t.setToolbarOpen,setToolbarPositionFrozen:t.setToolbarPositionFrozen})})]})},i6=t=>{let e=Y(),n=de();return b.jsx(e.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(Oh(t.url,window.location.href),"_blank")},icon:b.jsx(OV,{})})},s6=t=>b.jsx(Y().LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",children:t.children||b.jsxs(b.Fragment,{children:[b.jsx(o6,{url:t.url,text:t.text,range:t.range,setToolbarOpen:t.setToolbarOpen,setToolbarPositionFrozen:t.setToolbarPositionFrozen}),b.jsx(i6,{url:t.url}),b.jsx(r6,{range:t.range,setToolbarOpen:t.setToolbarOpen})]})}),l6=t=>{let e=ne(),[n,r]=v.useState(!1),[o,i]=v.useState(!1),s=ci(),l=Se(zl),[a,c]=v.useState(void 0);v.useEffect(()=>{let h=()=>{let y=l.getLinkAtSelection();if(!y){c(void 0),o||r(!1);return}c({cursorType:"text",url:y.mark.attrs.href,text:y.text,range:y.range,element:l.getLinkElementAtPos(y.range.from)}),o||r(!0)},p=y=>{if(a!==void 0&&a.cursorType==="text"||!(y.target instanceof HTMLElement))return;let w=l.getLinkAtElement(y.target);w&&c({cursorType:"mouse",url:w.mark.attrs.href,text:w.text,range:w.range,element:l.getLinkElementAtPos(w.range.from)})},m=e.onChange(h),g=e.onSelectionChange(h);return s==null||s.addEventListener("mouseover",p),()=>{m(),g(),s==null||s.removeEventListener("mouseover",p)}},[e,s,l,a,o]);let d=v.useMemo(()=>{var h,p,m,g;return{...t.floatingUIOptions,useFloatingOptions:{open:n,onOpenChange:(y,w,k)=>{o||a!==void 0&&a.cursorType==="text"&&k==="hover"||(k==="escape-key"&&e.focus(),r(y))},placement:"top-start",middleware:[Hn(10),jo()],...(h=t.floatingUIOptions)==null?void 0:h.useFloatingOptions},useHoverProps:{enabled:a!==void 0&&a.cursorType==="mouse",delay:{open:250,close:250},handleClose:hv(),...(p=t.floatingUIOptions)==null?void 0:p.useHoverProps},focusManagerProps:{disabled:!0,...(m=t.floatingUIOptions)==null?void 0:m.focusManagerProps},elementProps:{style:{zIndex:50},...(g=t.floatingUIOptions)==null?void 0:g.elementProps}}},[e,a,t.floatingUIOptions,n,o]),u=v.useMemo(()=>a!=null&&a.element?{element:a.element}:void 0,[a==null?void 0:a.element]);if(!e.isEditable)return null;let f=t.linkToolbar||s6;return b.jsx(tr,{reference:u,portalElement:t.portalElement,...d,children:a&&b.jsx(f,{url:a.url,text:a.text,range:a.range,setToolbarOpen:r,setToolbarPositionFrozen:i})})},a6=()=>{let t=Y(),e=de(),n=ne(),r=Se(En),o=Fe(An,{editor:n,selector:s=>s==null?void 0:s.block}),i=v.useCallback(()=>{if(o===void 0)return;let s=o.content;if(s!==void 0&&Array.isArray(s)&&s.length===0)n.setTextCursorPosition(o),r.openSuggestionMenu("/");else{let l=n.insertBlocks([{type:"paragraph"}],o,"after")[0];n.setTextCursorPosition(l),r.openSuggestionMenu("/")}},[o,n,r]);return o===void 0?null:b.jsx(t.SideMenu.Button,{className:"bn-button",label:e.side_menu.add_block_label,icon:b.jsx(m3,{size:24,onClick:i,"data-test":"dragHandleAdd"})})},c6=t=>{let e=Y(),n=ne(),r=Fe(An,{editor:n,selector:o=>o==null?void 0:o.block});return r===void 0||!Wt(r,n,r.type,{textColor:"string"})&&!Wt(r,n,r.type,{backgroundColor:"string"})?null:b.jsxs(e.Generic.Menu.Root,{position:"right",sub:!0,children:[b.jsx(e.Generic.Menu.Trigger,{sub:!0,children:b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:t.children})}),b.jsx(e.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:b.jsx($d,{iconSize:18,text:Wt(r,n,r.type,{textColor:"string"})&&Ue(n,r.type,{textColor:"string"})?{color:r.props.textColor,setColor:o=>n.updateBlock(r,{type:r.type,props:{textColor:o}})}:void 0,background:Wt(r,n,r.type,{backgroundColor:"string"})&&Ue(n,r.type,{backgroundColor:"string"})?{color:r.props.backgroundColor,setColor:o=>n.updateBlock(r,{props:{backgroundColor:o}})}:void 0})})]})},d6=t=>{let e=Y(),n=ne(),r=Fe(An,{editor:n,selector:o=>o==null?void 0:o.block});return r===void 0?null:b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",onClick:()=>{var s;let o=(s=n.getSelection())==null?void 0:s.blocks,i=o&&o.some(l=>l.id===r.id)?o:[r];n.removeBlocks(i)},children:t.children})},u6=t=>{let e=Y(),n=ne(),r=Fe(An,{editor:n,selector:i=>i==null?void 0:i.block});if(r===void 0||r.type!=="table"||!n.settings.tables.headers)return null;let o=!!r.content.headerRows;return b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",checked:o,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerRows:o?void 0:1}})},children:t.children})},f6=t=>{let e=Y(),n=ne(),r=Fe(An,{editor:n,selector:i=>i==null?void 0:i.block});if(r===void 0||r.type!=="table"||!n.settings.tables.headers)return null;let o=!!r.content.headerCols;return b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",checked:o,onClick:()=>{n.updateBlock(r,{content:{...r.content,headerCols:o?void 0:1}})},children:t.children})},h6=t=>{let e=Y(),n=de();return b.jsx(e.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-drag-handle-menu",children:t.children||b.jsxs(b.Fragment,{children:[b.jsx(d6,{children:n.drag_handle.delete_menuitem}),b.jsx(c6,{children:n.drag_handle.colors_menuitem}),b.jsx(u6,{children:n.drag_handle.header_row_menuitem}),b.jsx(f6,{children:n.drag_handle.header_column_menuitem})]})})},p6=t=>{let e=Y(),n=de(),r=Se(An),o=Fe(An,{selector:s=>s==null?void 0:s.block});if(o===void 0)return null;let i=t.dragHandleMenu||h6;return b.jsxs(e.Generic.Menu.Root,{onOpenChange:s=>{s?r.freezeMenu():r.unfreezeMenu()},position:"left",children:[b.jsx(e.Generic.Menu.Trigger,{children:b.jsx(e.SideMenu.Button,{label:n.side_menu.drag_handle_label,draggable:!0,onDragStart:s=>r.blockDragStart(s,o),onDragEnd:r.blockDragEnd,className:"bn-button",icon:b.jsx(ZS,{size:24,"data-test":"dragHandle"})})}),b.jsx(i,{children:t.children})]})},m6=t=>{let e=Y(),n=ne(),r=Fe(An,{editor:n,selector:i=>i==null?void 0:i.block}),o=v.useMemo(()=>{var s;if(r===void 0)return{};let i={"data-block-type":r.type};return r.type==="heading"&&(i["data-level"]=r.props.level.toString()),(s=n.schema.blockSpecs[r.type].implementation.meta)!=null&&s.fileBlockAccept&&(r.props.url?i["data-url"]="true":i["data-url"]="false"),i},[r,n.schema.blockSpecs]);return b.jsx(e.SideMenu.Root,{className:"bn-side-menu",...o,children:t.children||b.jsxs(b.Fragment,{children:[b.jsx(a6,{}),b.jsx(p6,{dragHandleMenu:t.dragHandleMenu})]})})},g6=t=>{let e=ne(),{show:n,block:r}=Fe(An,{selector:l=>l===void 0?void 0:{show:l.show,block:l.block}})||{},o=v.useCallback((l,a,c)=>{let d=!1;return ji(l,a,()=>{var u;if(!d){d=!0;return}(u=e.getExtension(An))==null||u.hideMenuIfNotFrozen()},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[e]),i=v.useMemo(()=>{var l,a,c,d;return{...t.floatingUIOptions,useFloatingOptions:{open:n,placement:"left-start",whileElementsMounted:o,...(l=t.floatingUIOptions)==null?void 0:l.useFloatingOptions},useDismissProps:{enabled:!1,...(a=t.floatingUIOptions)==null?void 0:a.useDismissProps},focusManagerProps:{disabled:!0,...(c=t.floatingUIOptions)==null?void 0:c.focusManagerProps},elementProps:{style:{zIndex:20},...(d=t.floatingUIOptions)==null?void 0:d.elementProps}}},[t.floatingUIOptions,n,o]),s=t.sideMenu||m6;return b.jsx(e2,{blockId:n?r==null?void 0:r.id:void 0,portalElement:t.portalElement,...i,children:(r==null?void 0:r.id)&&b.jsx(s,{})})};async function b6(t,e){return(await u8(t,e)).map(({id:n,onItemClick:r})=>({id:n,onItemClick:r,icon:n}))}function y6(t){let e=Y(),n=de(),{items:r,loadingState:o,selectedIndex:i,onItemClick:s,columns:l}=t,a=o==="loading-initial"||o==="loading"?b.jsx(e.GridSuggestionMenu.Loader,{className:"bn-grid-suggestion-menu-loader",columns:l}):null,c=v.useMemo(()=>{let d=[];for(let u=0;u<r.length;u++){let f=r[u];d.push(b.jsx(e.GridSuggestionMenu.Item,{className:"bn-grid-suggestion-menu-item",item:f,id:`bn-grid-suggestion-menu-item-${u}`,isSelected:u===i,onClick:()=>s==null?void 0:s(f)},f.id))}return d},[e,r,s,i]);return b.jsxs(e.GridSuggestionMenu.Root,{id:"bn-grid-suggestion-menu",columns:l,className:"bn-grid-suggestion-menu",children:[a,c,c.length===0&&t.loadingState==="loaded"&&b.jsx(e.GridSuggestionMenu.EmptyItem,{className:"bn-grid-suggestion-menu-empty-item",columns:l,children:n.suggestion_menu.no_items_title})]})}function s2(t,e,n,r=3){let o=v.useRef(0);v.useEffect(()=>{e!==void 0&&(t.length>0?o.current=e.length:e.length-o.current>r&&n())},[n,r,t.length,e])}function l2(t,e){let[n,r]=v.useState([]),[o,i]=v.useState(!1),s=v.useRef(void 0),l=v.useRef(void 0);return v.useEffect(()=>{let a=t;s.current=t,i(!0),e(t).then(c=>{s.current===a&&(r(c),i(!1),l.current=a)})},[t,e]),{items:n||[],usedQuery:l.current,loadingState:l.current===void 0?"loading-initial":o?"loading":"loaded"}}function v6(t,e,n,r,o){let i=ci(t),[s,l]=v.useState(0);return v.useEffect(()=>{let a=c=>(c.key==="ArrowLeft"&&(c.preventDefault(),n.length&&l((s-1+n.length)%n.length)),c.key==="ArrowRight"&&(c.preventDefault(),n.length&&l((s+1+n.length)%n.length)),c.key==="ArrowUp"?(c.preventDefault(),n.length&&l((s-r+n.length)%n.length),!0):c.key==="ArrowDown"?(c.preventDefault(),n.length&&l((s+r)%n.length),!0):c.key==="Enter"&&!c.isComposing?(c.stopPropagation(),c.preventDefault(),n.length&&(o==null||o(n[s])),!0):!1);return i==null||i.addEventListener("keydown",a,!0),()=>{i==null||i.removeEventListener("keydown",a,!0)}},[i,n,s,o,r,r!==void 0&&r>1]),v.useEffect(()=>{l(0)},[e]),{selectedIndex:n.length===0?void 0:s}}function w6(t){let e=Rn().setContentEditableProps,n=ne(),{getItems:r,gridSuggestionMenuComponent:o,query:i,clearQuery:s,closeMenu:l,onItemClick:a,columns:c}=t,d=v.useCallback(m=>{l(),s(),a==null||a(m)},[a,l,s]),{items:u,usedQuery:f,loadingState:h}=l2(i,r);s2(u,f,l);let{selectedIndex:p}=v6(n,i,u,c,d);return v.useEffect(()=>(e(m=>({...m,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{e(m=>({...m,"aria-expanded":!1,"aria-controls":void 0}))}),[e]),v.useEffect(()=>(e(m=>({...m,"aria-activedescendant":p?"bn-suggestion-menu-item-"+p:void 0})),()=>{e(m=>({...m,"aria-activedescendant":void 0}))}),[e,p]),b.jsx(o,{items:u,onItemClick:d,loadingState:h,selectedIndex:p,columns:c})}function k6(t){let e=ne(),n=ci(),{triggerCharacter:r,gridSuggestionMenuComponent:o,columns:i,shouldOpen:s,minQueryLength:l,onItemClick:a,getItems:c}=t,d=v.useMemo(()=>a||(g=>{g.onItemClick(e)}),[e,a]),u=v.useMemo(()=>c||(async g=>await b6(e,g)),[e,c]),f=Se(En);v.useEffect(()=>{f.addSuggestionMenu({triggerCharacter:r,shouldOpen:s})},[f,r,s]);let h=Fe(En),p=Fe(En,{selector:g=>({element:(n==null?void 0:n.firstChild)||void 0,getBoundingClientRect:()=>(g==null?void 0:g.referencePos)||new DOMRect})}),m=v.useMemo(()=>{var g,y,w;return{...t.floatingUIOptions,useFloatingOptions:{open:(h==null?void 0:h.show)&&(h==null?void 0:h.triggerCharacter)===r,onOpenChange:k=>{k||f.closeMenu()},placement:"bottom-start",middleware:[Hn(10),ov({allowedPlacements:["bottom-start","top-start"],padding:10}),ri(),Ws({apply({elements:k,availableHeight:x}){k.floating.style.maxHeight=`${Math.max(0,x)}px`},padding:10})],...(g=t.floatingUIOptions)==null?void 0:g.useFloatingOptions},focusManagerProps:{disabled:!0,...(y=t.floatingUIOptions)==null?void 0:y.focusManagerProps},elementProps:{onMouseDownCapture:k=>k.preventDefault(),style:{zIndex:70},...(w=t.floatingUIOptions)==null?void 0:w.elementProps}}},[t.floatingUIOptions,h==null?void 0:h.show,h==null?void 0:h.triggerCharacter,f,r]);return!h||!h.ignoreQueryLength&&l&&(h.query.startsWith(" ")||h.query.length<l)?null:b.jsx(tr,{reference:p,portalElement:t.portalElement,...m,children:r&&b.jsx(w6,{query:h.query,closeMenu:f.closeMenu,clearQuery:f.clearQuery,getItems:u,columns:i,gridSuggestionMenuComponent:o||y6,onItemClick:d})})}function x6(t){let e=Y(),n=de(),{items:r,loadingState:o,selectedIndex:i,onItemClick:s}=t,l=o==="loading-initial"||o==="loading"?b.jsx(e.SuggestionMenu.Loader,{className:"bn-suggestion-menu-loader"}):null,a=v.useMemo(()=>{let c,d=[];for(let u=0;u<r.length;u++){let f=r[u];f.group!==c&&(c=f.group,d.push(b.jsx(e.SuggestionMenu.Label,{className:"bn-suggestion-menu-label",children:c},c))),d.push(b.jsx(e.SuggestionMenu.Item,{className:De("bn-suggestion-menu-item",f.size==="small"?"bn-suggestion-menu-item-small":""),item:f,id:`bn-suggestion-menu-item-${u}`,isSelected:u===i,onClick:()=>s==null?void 0:s(f)},f.title))}return d},[e,r,s,i]);return b.jsxs(e.SuggestionMenu.Root,{id:"bn-suggestion-menu",className:"bn-suggestion-menu",children:[a,a.length===0&&(t.loadingState==="loading"||t.loadingState==="loaded")&&b.jsx(e.SuggestionMenu.EmptyItem,{className:"bn-suggestion-menu-item",children:n.suggestion_menu.no_items_title}),l]})}function C6(t,e){let[n,r]=v.useState(0);return{selectedIndex:n,setSelectedIndex:r,handler:o=>{if(o.key==="ArrowUp")return o.preventDefault(),t.length&&r((n-1+t.length)%t.length),!0;if(o.key==="ArrowDown")return o.preventDefault(),t.length&&r((n+1)%t.length),!0;if(o.key==="PageUp")return o.preventDefault(),t.length&&r(0),!0;if(o.key==="PageDown")return o.preventDefault(),t.length&&r(t.length-1),!0;let i=S6(o)?o.nativeEvent.isComposing:o.isComposing;return o.key==="Enter"&&!i?(o.preventDefault(),o.stopPropagation(),t.length&&(e==null||e(t[n])),!0):!1}}}function S6(t){return t.nativeEvent!==void 0}function E6(t,e,n,r,o){let i=ci(),{selectedIndex:s,setSelectedIndex:l,handler:a}=C6(n,r);return v.useEffect(()=>{let c=i;return c==null||c.addEventListener("keydown",a,!0),()=>{c==null||c.removeEventListener("keydown",a,!0)}},[i,n,s,r,o,a]),v.useEffect(()=>{l(0)},[e,l]),{selectedIndex:n.length===0?void 0:s}}function M6(t){let e=Rn().setContentEditableProps,n=ne(),{getItems:r,suggestionMenuComponent:o,query:i,clearQuery:s,closeMenu:l,onItemClick:a}=t,c=v.useCallback(p=>{l(),s(),a==null||a(p)},[a,l,s]),{items:d,usedQuery:u,loadingState:f}=l2(i,r);s2(d,u,l);let{selectedIndex:h}=E6(n,i,d,c);return v.useEffect(()=>(e(p=>({...p,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{e(p=>({...p,"aria-expanded":!1,"aria-controls":void 0}))}),[e]),v.useEffect(()=>(e(p=>({...p,"aria-activedescendant":h?"bn-suggestion-menu-item-"+h:void 0})),()=>{e(p=>({...p,"aria-activedescendant":void 0}))}),[e,h]),b.jsx(o,{items:d,onItemClick:c,loadingState:f,selectedIndex:h})}var T6={heading:Vc,heading_2:jc,heading_3:Bc,heading_4:VS,heading_5:jS,heading_6:BS,toggle_heading:Vc,toggle_heading_2:jc,toggle_heading_3:Bc,quote:DS,toggle_list:OS,numbered_list:PS,bullet_list:_S,check_list:$S,paragraph:Rm,table:UV,image:HV,video:FV,audio:BV,file:i3,emoji:NV,code_block:XV,divider:RV};function a2(t){return QB(t).map(e=>{let n=T6[e.key];return{...e,icon:b.jsx(n,{size:18})}})}function c2(t){let e=ne(),n=ci(),{triggerCharacter:r,suggestionMenuComponent:o,shouldOpen:i,minQueryLength:s,onItemClick:l,getItems:a}=t,c=v.useMemo(()=>l||(m=>{m.onItemClick(e)}),[e,l]),d=v.useMemo(()=>a||(async m=>OC(a2(e),m)),[e,a]),u=Se(En);v.useEffect(()=>{u.addSuggestionMenu({triggerCharacter:r,shouldOpen:i})},[u,r,i]);let f=Fe(En),h=Fe(En,{selector:m=>({element:(n==null?void 0:n.firstChild)||void 0,getBoundingClientRect:()=>(m==null?void 0:m.referencePos)||new DOMRect})}),p=v.useMemo(()=>{var m,g,y;return{...t.floatingUIOptions,useFloatingOptions:{open:(f==null?void 0:f.show)&&(f==null?void 0:f.triggerCharacter)===r,onOpenChange:w=>{w||u.closeMenu()},placement:"bottom-start",middleware:[Hn(10),ov({allowedPlacements:["bottom-start","top-start"],padding:10}),ri(),Ws({apply({elements:w,availableHeight:k}){w.floating.style.maxHeight=`${Math.max(0,k)}px`},padding:10})],...(m=t.floatingUIOptions)==null?void 0:m.useFloatingOptions},focusManagerProps:{disabled:!0,...(g=t.floatingUIOptions)==null?void 0:g.focusManagerProps},elementProps:{onMouseDownCapture:w=>w.preventDefault(),style:{zIndex:80},...(y=t.floatingUIOptions)==null?void 0:y.elementProps}}},[t.floatingUIOptions,f==null?void 0:f.show,f==null?void 0:f.triggerCharacter,u,r]);return!f||!f.ignoreQueryLength&&s&&(f.query.startsWith(" ")||f.query.length<s)?null:b.jsx(tr,{reference:h,portalElement:t.portalElement,...p,children:r&&b.jsx(M6,{query:f.query,closeMenu:u.closeMenu,clearQuery:u.clearQuery,getItems:d,suggestionMenuComponent:o||x6,onItemClick:c})})}var A6=(t,e=.3)=>{let n=Math.floor(t)+e,r=Math.ceil(t)-e;return t>=n&&t<=r?Math.round(t):t<n?Math.floor(t):Math.ceil(t)},N6=t=>{let e=Y(),n=ne(),r=Se(_e),o=Fe(_e,{selector:d=>d==null?void 0:d.block}),i=v.useRef(!1),[s,l]=v.useState(),a=v.useCallback(d=>{r.freezeHandles(),t.hideOtherElements(!0),o&&(l({originalContent:o.content,originalCroppedContent:{rows:r.cropEmptyRowsOrColumns(o,t.orientation==="addOrRemoveColumns"?"columns":"rows")},startPos:t.orientation==="addOrRemoveColumns"?d.clientX:d.clientY}),i.current=!1,d.preventDefault())},[o,t,r]),c=v.useCallback(()=>{!o||i.current||n.updateBlock(o,{type:"table",content:{...o.content,rows:t.orientation==="addOrRemoveColumns"?r.addRowsOrColumns(o,"columns",1):r.addRowsOrColumns(o,"rows",1)}})},[o,n,t.orientation,r]);return v.useEffect(()=>{let d=u=>{var y,w;if(!o)return;if(!s)throw Error("editingState is undefined");i.current=!0;let f=(t.orientation==="addOrRemoveColumns"?u.clientX:u.clientY)-s.startPos,h=t.orientation==="addOrRemoveColumns"?((y=s.originalCroppedContent.rows[0])==null?void 0:y.cells.length)??0:s.originalCroppedContent.rows.length,p=t.orientation==="addOrRemoveColumns"?((w=s.originalContent.rows[0])==null?void 0:w.cells.length)??0:s.originalContent.rows.length,m=t.orientation==="addOrRemoveColumns"?o.content.rows[0].cells.length:o.content.rows.length,g=p+A6(f/(t.orientation==="addOrRemoveColumns"?$B:LB),.3);g>=h&&g>0&&g!==m&&(n.updateBlock(o,{type:"table",content:{...o.content,rows:t.orientation==="addOrRemoveColumns"?r.addRowsOrColumns({type:"table",content:s.originalCroppedContent},"columns",g-h):r.addRowsOrColumns({type:"table",content:s.originalCroppedContent},"rows",g-h)}}),o.content&&n.setTextCursorPosition(o))};return s&&window.addEventListener("mousemove",d),()=>{window.removeEventListener("mousemove",d)}},[o,s,n,t.orientation,r]),v.useEffect(()=>{let d=()=>{t.hideOtherElements(!1),r.unfreezeHandles(),l(void 0)};return s&&window.addEventListener("mouseup",d),()=>{window.removeEventListener("mouseup",d)}},[s,t,r]),n.isEditable?b.jsx(e.TableHandle.ExtendButton,{className:De("bn-extend-button",t.orientation==="addOrRemoveColumns"?"bn-extend-button-add-remove-columns":"bn-extend-button-add-remove-rows",s===null?"":"bn-extend-button-editing"),onClick:c,onMouseDown:a,children:t.children||b.jsx(LV,{size:18,"data-test":"extendButton"})}):null},R6=t=>{var c,d;let e=Y(),n=de(),r=ne(),{block:o,colIndex:i,rowIndex:s}=Fe(_e,{selector:u=>({block:u==null?void 0:u.block,colIndex:u==null?void 0:u.colIndex,rowIndex:u==null?void 0:u.rowIndex})}),l=(u,f)=>{if(o===void 0||i===void 0||s===void 0)return;let h=o.content.rows.map(p=>({...p,cells:p.cells.map(m=>lo(m))}));f==="text"?h[s].cells[i].props.textColor=u:h[s].cells[i].props.backgroundColor=u,r.updateBlock(o,{type:"table",content:{...o.content,rows:h}}),r.setTextCursorPosition(o)};if(o===void 0||i===void 0||s===void 0)return null;let a=(d=(c=o.content.rows[s])==null?void 0:c.cells)==null?void 0:d[i];return!a||r.settings.tables.cellTextColor===!1&&r.settings.tables.cellBackgroundColor===!1?null:b.jsxs(e.Generic.Menu.Root,{position:"right",sub:!0,children:[b.jsx(e.Generic.Menu.Trigger,{sub:!0,children:b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:t.children||n.drag_handle.colors_menuitem})}),b.jsx(e.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:b.jsx($d,{iconSize:18,text:r.settings.tables.cellTextColor?{color:ao(a)?a.props.textColor:"default",setColor:u=>l(u,"text")}:void 0,background:r.settings.tables.cellBackgroundColor?{color:ao(a)?a.props.backgroundColor:"default",setColor:u=>l(u,"background")}:void 0})})]})},I6=()=>{var a,c;let t=Y(),e=de(),n=ne(),r=Se(_e),{block:o,colIndex:i,rowIndex:s}=Fe(_e,{selector:d=>({block:d==null?void 0:d.block,colIndex:d==null?void 0:d.colIndex,rowIndex:d==null?void 0:d.rowIndex})});if(o===void 0||i===void 0||s===void 0)return null;let l=(c=(a=o.content.rows[s])==null?void 0:a.cells)==null?void 0:c[i];return!l||!ao(l)||vl(l)===1&&ei(l)===1||!n.settings.tables.splitCells?null:b.jsx(t.Generic.Menu.Item,{onClick:()=>{r.splitCell({row:s,col:i})},children:e.table_handle.split_cell_menuitem})},O6=t=>b.jsx(Y().Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-table-handle-menu",children:t.children||b.jsxs(b.Fragment,{children:[b.jsx(I6,{}),b.jsx(R6,{})]})}),D6=t=>{let e=Y(),n=ne(),r=Se(_e),o=t.tableCellMenu||O6;return!n.settings.tables.splitCells&&!n.settings.tables.cellBackgroundColor&&!n.settings.tables.cellTextColor?null:b.jsxs(e.Generic.Menu.Root,{onOpenChange:i=>{i?(r.freezeHandles(),t.hideOtherElements(!0)):(r.unfreezeHandles(),t.hideOtherElements(!1),n.focus())},position:"right",children:[b.jsx(e.Generic.Menu.Trigger,{children:b.jsx(e.Generic.Menu.Button,{className:"bn-table-cell-handle",children:t.children||b.jsx(g3,{size:12,"data-test":"tableCellHandle"})})}),b.jsx(o,{})]})},Y0=t=>{let e=Y(),n=de(),r=Se(_e),o=Fe(_e,{selector:i=>t.orientation==="column"?i==null?void 0:i.colIndex:i==null?void 0:i.rowIndex});return r===void 0||o===void 0?null:b.jsx(e.Generic.Menu.Item,{onClick:()=>{r.addRowOrColumn(o,t.orientation==="row"?{orientation:"row",side:t.side}:{orientation:"column",side:t.side})},children:n.table_handle[`add_${t.side}_menuitem`]})},_6=t=>{let e=Y(),n=de(),r=Se(_e),o=Fe(_e,{selector:i=>t.orientation==="column"?i==null?void 0:i.colIndex:i==null?void 0:i.rowIndex});return r===void 0||o===void 0?null:b.jsx(e.Generic.Menu.Item,{onClick:()=>r.removeRowOrColumn(o,t.orientation),children:t.orientation==="row"?n.table_handle.delete_row_menuitem:n.table_handle.delete_column_menuitem})},P6=t=>{let e=Y(),n=de(),r=ne(),o=Se(_e),{block:i,index:s}=Fe(_e,{selector:d=>({block:d==null?void 0:d.block,index:t.orientation==="column"?d==null?void 0:d.colIndex:d==null?void 0:d.rowIndex})}),l=v.useMemo(()=>o===void 0||i===void 0||s===void 0?[]:t.orientation==="row"?o.getCellsAtRowHandle(i,s):o.getCellsAtColumnHandle(i,s),[i,s,t.orientation,o]),a=(d,u)=>{if(i===void 0)return;let f=i.content.rows.map(h=>({...h,cells:h.cells.map(p=>lo(p))}));l.forEach(({row:h,col:p})=>{u==="text"?f[h].cells[p].props.textColor=d:f[h].cells[p].props.backgroundColor=d}),r.updateBlock(i,{type:"table",content:{...i.content,rows:f}}),r.setTextCursorPosition(i)};if(!l||!l[0]||!o||r.settings.tables.cellTextColor===!1&&r.settings.tables.cellBackgroundColor===!1)return null;let c=lo(l[0].cell);return b.jsxs(e.Generic.Menu.Root,{position:"right",sub:!0,children:[b.jsx(e.Generic.Menu.Trigger,{sub:!0,children:b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:t.children||n.drag_handle.colors_menuitem})}),b.jsx(e.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:b.jsx($d,{iconSize:18,text:r.settings.tables.cellTextColor?{color:l.every(({cell:d})=>ao(d)&&d.props.textColor===c.props.textColor)?c.props.textColor:"default",setColor:d=>{a(d,"text")}}:void 0,background:r.settings.tables.cellBackgroundColor?{color:l.every(({cell:d})=>ao(d)&&d.props.backgroundColor===c.props.backgroundColor)?c.props.backgroundColor:"default",setColor:d=>a(d,"background")}:void 0})})]})},$6=t=>{let e=Y(),n=de(),r=ne(),o=Se(_e),{block:i,index:s}=Fe(_e,{selector:a=>({block:a==null?void 0:a.block,index:t.orientation==="column"?a==null?void 0:a.colIndex:a==null?void 0:a.rowIndex})});if(o===void 0||i===void 0||s!==0||t.orientation!=="row"||!r.settings.tables.headers)return null;let l=!!i.content.headerRows;return b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",checked:l,onClick:()=>{r.updateBlock(i,{...i,content:{...i.content,headerRows:l?void 0:1}})},children:n.drag_handle.header_row_menuitem})},L6=t=>{let e=Y(),n=de(),r=ne(),o=Se(_e),i=Fe(_e,{selector:a=>a==null?void 0:a.block}),s=Fe(_e,{selector:a=>t.orientation==="column"?a==null?void 0:a.colIndex:a==null?void 0:a.rowIndex});if(!o||s!==0||!i||t.orientation!=="column"||!r.settings.tables.headers)return null;let l=!!i.content.headerCols;return b.jsx(e.Generic.Menu.Item,{className:"bn-menu-item",checked:l,onClick:()=>{r.updateBlock(i,{...i,content:{...i.content,headerCols:l?void 0:1}})},children:n.drag_handle.header_column_menuitem})},B6=t=>b.jsx(Y().Generic.Menu.Dropdown,{className:"bn-table-handle-menu",children:t.children||b.jsxs(b.Fragment,{children:[b.jsx(_6,{orientation:t.orientation}),b.jsx(Y0,{orientation:t.orientation,side:t.orientation==="row"?"above":"left"}),b.jsx(Y0,{orientation:t.orientation,side:t.orientation==="row"?"below":"right"}),b.jsx($6,{orientation:t.orientation}),b.jsx(L6,{orientation:t.orientation}),b.jsx(P6,{orientation:t.orientation})]})}),j6=t=>{let e=ne(),n=Y(),[r,o]=v.useState(!1),i=t.tableHandleMenu||B6,s=Se(_e),l=Fe(_e),a=v.useMemo(()=>!s||!l||!l.block||l.block.type!=="table"?!1:t.orientation==="column"?s.getCellsAtColumnHandle(l.block,l.colIndex).every(({cell:c})=>ei(c)===1):s.getCellsAtRowHandle(l.block,l.rowIndex).every(({cell:c})=>vl(c)===1),[t.orientation,l,s]);return l?b.jsxs(n.Generic.Menu.Root,{onOpenChange:c=>{c?(s.freezeHandles(),t.hideOtherElements(!0)):(s.unfreezeHandles(),t.hideOtherElements(!1),e.focus())},position:"right",children:[b.jsx(n.Generic.Menu.Trigger,{children:b.jsx(n.TableHandle.Root,{className:De("bn-table-handle",r?"bn-table-handle-dragging":"",a?"":"bn-table-handle-not-draggable"),draggable:a,onDragStart:c=>{o(!0),t.hideOtherElements(!0),t.orientation==="column"?s.colDragStart(c):s.rowDragStart(c)},onDragEnd:()=>{s.dragEnd(),t.hideOtherElements(!1),o(!1)},style:t.orientation==="column"?{transform:"rotate(0.25turn)"}:void 0,children:t.children||b.jsx(ZS,{size:24,"data-test":"tableHandle"})})}),b.jsx(i,{orientation:t.orientation})]}):null},V6=t=>{let e=ne(),[n,r]=v.useState(),o=Fe(_e),i=v.useMemo(()=>{let u={};if(o===void 0)return{};let f=Ht(o.block.id,e.prosemirrorState.doc);if(!f)return{};let h=f.posBeforeNode+1,p=e.prosemirrorView.domAtPos(h+1).node;if(!(p instanceof Element))return{};if(u.tableReference={element:p},o.rowIndex===void 0||o.colIndex===void 0)return u;let m=e.prosemirrorState.doc.resolve(h+1).posAtIndex(o.rowIndex),g=e.prosemirrorState.doc.resolve(m+1).posAtIndex(o.colIndex),y=e.prosemirrorView.domAtPos(g+1).node;return y instanceof Element?(u.cellReference={element:y},u.rowReference={element:p,getBoundingClientRect:()=>{let w=p.getBoundingClientRect(),k=y.getBoundingClientRect();return new DOMRect(w.x,o.draggingState&&o.draggingState.draggedCellOrientation==="row"?o.draggingState.mousePos-k.height/2:k.y,w.width,k.height)}},u.columnReference={element:p,getBoundingClientRect:()=>{let w=p.getBoundingClientRect(),k=y.getBoundingClientRect();return new DOMRect(o.draggingState&&o.draggingState.draggedCellOrientation==="col"?o.draggingState.mousePos-k.width/2:k.x,w.y,k.width,w.height)}},u):{}},[e,o]),s=v.useCallback((u,f,h)=>{let p=!1;return ji(u,f,()=>{var m;if(!p){p=!0;return}(m=e.getExtension(_e))==null||m.hideHandlesIfNotFrozen()},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[e]),l=v.useMemo(()=>o===void 0?void 0:{rowTableHandle:{useFloatingOptions:{open:o.show&&o.rowIndex!==void 0&&(!n||n==="rowTableHandle"),placement:"left",middleware:[Hn(-10)],whileElementsMounted:s},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},columnTableHandle:{useFloatingOptions:{open:o.show&&o.colIndex!==void 0&&(!n||n==="columnTableHandle"),placement:"top",middleware:[Hn(-12)],whileElementsMounted:s},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},tableCellHandle:{useFloatingOptions:{open:o.show&&o.rowIndex!==void 0&&o.colIndex!==void 0&&(!n||n==="tableCellHandle"),placement:"top-end",middleware:[Hn({mainAxis:-15,crossAxis:-1})],whileElementsMounted:s},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendRowsButton:{useFloatingOptions:{open:o.show&&o.showAddOrRemoveRowsButton&&(!n||n==="extendRowsButton"),placement:"bottom",whileElementsMounted:s,middleware:[Ws({apply({rects:u,elements:f}){Object.assign(f.floating.style,{width:`${u.reference.width}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendColumnsButton:{useFloatingOptions:{open:o.show&&o.showAddOrRemoveColumnsButton&&(!n||n==="extendColumnsButton"),placement:"right",whileElementsMounted:s,middleware:[Ws({apply({rects:u,elements:f}){Object.assign(f.floating.style,{height:`${u.reference.height}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}}},[n,o,s]);if(!o)return null;let a=t.tableHandle||j6,c=t.extendButton||N6,d=t.tableCellHandle||D6;return b.jsxs(b.Fragment,{children:[b.jsx(tr,{reference:i==null?void 0:i.rowReference,portalElement:t.portalElement,...l==null?void 0:l.rowTableHandle,children:o.show&&o.rowIndex!==void 0&&(!n||n==="rowTableHandle")&&b.jsx(a,{orientation:"row",hideOtherElements:u=>r(u?"rowTableHandle":void 0)})}),b.jsx(tr,{reference:i==null?void 0:i.columnReference,portalElement:t.portalElement,...l==null?void 0:l.columnTableHandle,children:o.show&&o.colIndex!==void 0&&(!n||n==="columnTableHandle")&&b.jsx(a,{orientation:"column",hideOtherElements:u=>r(u?"columnTableHandle":void 0)})}),b.jsx(tr,{reference:i==null?void 0:i.cellReference,portalElement:t.portalElement,...l==null?void 0:l.tableCellHandle,children:o.show&&o.rowIndex!==void 0&&o.colIndex!==void 0&&(!n||n==="tableCellHandle")&&b.jsx(d,{hideOtherElements:u=>r(u?"tableCellHandle":void 0)})}),b.jsx(tr,{reference:i==null?void 0:i.tableReference,portalElement:t.portalElement,...l==null?void 0:l.extendRowsButton,children:o.show&&o.showAddOrRemoveRowsButton&&(!n||n==="extendRowsButton")&&b.jsx(c,{orientation:"addOrRemoveRows",hideOtherElements:u=>r(u?"extendRowsButton":void 0)})}),b.jsx(tr,{reference:i==null?void 0:i.tableReference,portalElement:t.portalElement,...l==null?void 0:l.extendColumnsButton,children:o.show&&o.showAddOrRemoveColumnsButton&&(!n||n==="extendColumnsButton")&&b.jsx(c,{orientation:"addOrRemoveColumns",hideOtherElements:u=>r(u?"extendColumnsButton":void 0)})})]})};function vr(t){if(t!==void 0){if(t===null)return typeof document<"u"?document.body:void 0;if(typeof t=="string"){if(typeof document>"u")return;let e=document.querySelector(t);if(!e){console.warn(`[BlockNote] portalElements selector "${t}" did not match any element`);return}return e}return t}}var H6=v.lazy(()=>$i(()=>import("./FloatingComposerController-5A3GJtK4-BqOKhUaC.js"),__vite__mapDeps([0,1,2,3,4,5])).then(t=>t.n)),F6=v.lazy(()=>$i(()=>Promise.resolve().then(()=>p3),void 0).then(t=>t.n));function z6(t){let e=ne();if(!e)throw Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");let n=t.portalElements,r=vr(n==null?void 0:n.formattingToolbar),o=vr(n==null?void 0:n.linkToolbar),i=vr(n==null?void 0:n.slashMenu),s=vr(n==null?void 0:n.emojiPicker),l=vr(n==null?void 0:n.sideMenu),a=vr(n==null?void 0:n.filePanel),c=vr(n==null?void 0:n.tableHandles),d=vr(n==null?void 0:n.comments);return b.jsxs(b.Fragment,{children:[e.getExtension(vn)&&t.formattingToolbar!==!1&&b.jsx(i2,{portalElement:r}),e.getExtension(zl)&&t.linkToolbar!==!1&&b.jsx(l6,{portalElement:o}),e.getExtension(En)&&t.slashMenu!==!1&&b.jsx(c2,{triggerCharacter:"/",shouldOpen:u=>!u.selection.$from.parent.type.isInGroup("tableContent"),portalElement:i}),e.getExtension(En)&&t.emojiPicker!==!1&&b.jsx(k6,{triggerCharacter:":",columns:10,minQueryLength:2,portalElement:s}),e.getExtension(An)&&t.sideMenu!==!1&&b.jsx(g6,{portalElement:l}),e.getExtension(Bn)&&t.filePanel!==!1&&b.jsx(_3,{portalElement:a}),e.getExtension(_e)&&t.tableHandles!==!1&&b.jsx(V6,{portalElement:c}),e.getExtension(Pr)&&t.comments!==!1&&b.jsxs(v.Suspense,{children:[b.jsx(H6,{portalElement:d}),b.jsx(F6,{portalElement:d})]})]})}function U6(t,e){let n=Rn();e||(e=n==null?void 0:n.editor),v.useEffect(()=>{if(!e)throw Error("'editor' is required, either from BlockNoteContext or as a function argument");return e.onChange(t)},[t,e])}function W6(t,e,n){let r=Rn();e||(e=r==null?void 0:r.editor),v.useEffect(()=>{if(!e)throw Error("'editor' is required, either from BlockNoteContext or as a function argument");return e.onSelectionChange(t,n)},[t,e,n])}var d2=()=>{let t=v.useMemo(()=>{var s;return(s=window.matchMedia)==null?void 0:s.call(window,"(prefers-color-scheme: dark)")},[]),e=v.useMemo(()=>{var s;return(s=window.matchMedia)==null?void 0:s.call(window,"(prefers-color-scheme: light)")},[]),n=t==null?void 0:t.matches,r=e==null?void 0:e.matches,[o,i]=v.useState(n?"dark":r?"light":"no-preference");return v.useEffect(()=>{i(n?"dark":r?"light":"no-preference")},[n,r]),v.useEffect(()=>{if(typeof(t==null?void 0:t.addEventListener)=="function"){let s=({matches:a})=>a&&i("dark"),l=({matches:a})=>a&&i("light");return t==null||t.addEventListener("change",s),e==null||e.addEventListener("change",l),()=>{t==null||t.removeEventListener("change",s),e==null||e.removeEventListener("change",l)}}else{let s=()=>i(t.matches?"dark":e.matches?"light":"no-preference");return t==null||t.addEventListener("change",s),e==null||e.addEventListener("change",s),()=>{t==null||t.removeEventListener("change",s),e==null||e.removeEventListener("change",s)}}},[t,e]),o},u2=v.createContext(void 0);function q6(){return v.useContext(u2)}function G6(){let t=new Set,e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:Dr.createPortal(r.reactElement,r.element,n)},t.forEach(o=>o())},removeRenderer(n){let r={...e};delete r[n],e=r,t.forEach(o=>o())}}}var Z6=({contentComponent:t})=>{let e=v.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return b.jsx(b.Fragment,{children:Object.values(e)})},K6=v.forwardRef((t,e)=>{let[n,r]=v.useState();return v.useImperativeHandle(e,()=>(o,i)=>{Dr.flushSync(()=>{r({node:o,container:i})}),r(void 0)},[]),b.jsx(b.Fragment,{children:n&&Dr.createPortal(n.node,n.container)})}),X0=()=>{};function J6(t,e){let{editor:n,className:r,theme:o,children:i,editable:s,onSelectionChange:l,onChange:a,formattingToolbar:c,linkToolbar:d,slashMenu:u,emojiPicker:f,sideMenu:h,filePanel:p,tableHandles:m,comments:g,portalElements:y,autoFocus:w,renderEditor:k=!0,...x}=t,C=v.useMemo(()=>vr(y==null?void 0:y.default)??null,[y==null?void 0:y.default]),[E,S]=v.useState(),M=Rn(),N=d2(),A=(M==null?void 0:M.colorSchemePreference)||N,R=o||(A==="dark"?"dark":"light"),P=Y(),D=v.useMemo(()=>({formattingToolbar:P?c:!1,linkToolbar:P?d:!1,sideMenu:P?h:!1,slashMenu:P?u:!1,filePanel:P?p:!1,tableHandles:P?m:!1,emojiPicker:P?f:!1,comments:P?g:!1,portalElements:y}),[g,P,f,p,c,d,h,u,m,y]);U6(a||X0,n),W6(l||X0,n);let T=v.useCallback(L=>{n.elementRenderer=L},[n]);v.useEffect(()=>{if(!n.portalElement)throw Error("Portal element not found");n.portalElement.className=De("bn-root",R,r||""),n.portalElement.setAttribute("data-color-scheme",R)},[n,R,r]);let _=v.useMemo(()=>({...M,editor:n,setContentEditableProps:S,colorSchemePreference:R}),[M,n,R]),F=v.useMemo(()=>({editorProps:{autoFocus:w,contentEditableProps:E,editable:s,portalTarget:C},defaultUIProps:D}),[w,E,s,D,C]);return b.jsx(SS.Provider,{value:_,children:b.jsxs(u2.Provider,{value:F,children:[b.jsx(K6,{ref:T}),b.jsx(Y6,{className:r,renderEditor:k,editorColorScheme:R,ref:e,...x,children:i})]})})}var Y6=tt.forwardRef(({className:t,renderEditor:e,editorColorScheme:n,children:r,...o},i)=>b.jsx("div",{className:De("bn-root","bn-container",n,t),"data-color-scheme":n,...o,ref:i,children:e?b.jsx(Q6,{children:r}):r})),X6=tt.forwardRef(J6),Q6=t=>{let e=q6(),n=ne(),r=v.useMemo(()=>G6(),[]),o=e.editorProps.portalTarget,i=v.useCallback(s=>{n.isEditable=e.editorProps.editable!==!1,n._tiptapEditor.contentComponent=r,s?n.mount(s,{portalTarget:o}):n.unmount()},[e.editorProps.editable,n,r,o]);return b.jsxs(b.Fragment,{children:[b.jsx(Z6,{contentComponent:r}),b.jsx(eH,{...e.editorProps,...t,mount:i}),b.jsx(z6,{...e.defaultUIProps}),t.children]})},eH=t=>{let{autoFocus:e,mount:n,contentEditableProps:r}=t;return b.jsx("div",{"aria-autocomplete":"list","aria-haspopup":"listbox","data-bn-autofocus":e,ref:n,...r})};function Q0(t,e){let n,r=document.createElement("div"),o;if(e!=null&&e.elementRenderer)e.elementRenderer(t(a=>n=a||void 0),r);else{if(!(e!=null&&e.headless))throw Error("elementRenderer not available, expected headless editor");o=pM.createRoot(r),Dr.flushSync(()=>{o.render(t(a=>n=a||void 0))})}if(!r.childElementCount)return console.warn("ReactInlineContentSpec: renderHTML() failed"),{dom:document.createElement("span")};n==null||n.setAttribute("data-tmp-find","true");let i=r.cloneNode(!0),s=i.firstElementChild,l=i.querySelector("[data-tmp-find]");return l==null||l.removeAttribute("data-tmp-find"),o==null||o.unmount(),{dom:s,contentDOM:l||void 0}}function cf(t){var e;return b.jsx(S3,{onDragOver:n=>n.preventDefault(),...Object.fromEntries(Object.entries(t.domAttributes||{}).filter(([n])=>n!=="class")),className:De("bn-block-content",((e=t.domAttributes)==null?void 0:e.class)||""),"data-content-type":t.blockType,...Object.fromEntries(Object.entries(t.blockProps).filter(([n,r])=>r!==t.propSchema[n].default).map(([n,r])=>[wl(n),r])),"data-file-block":t.isFileBlock===!0||void 0,children:t.children})}function f2(t,e,n){return(r={})=>{let o=typeof t=="function"?t(r):t,i=typeof e=="function"?e(r):e,s=n?typeof n=="function"?n(r):n:void 0;return{config:o,implementation:{...i,toExternalHTML(l,a,c){let d=i.toExternalHTML||i.render;return Q0(u=>{var f;return b.jsx(cf,{blockType:l.type,blockProps:l.props,propSchema:o.propSchema,domAttributes:this.blockContentDOMAttributes,isFileBlock:((f=i.meta)==null?void 0:f.fileBlockAccept)!==void 0,children:b.jsx(d,{block:l,editor:a,contentRef:h=>{u(h),h&&(h.className=De("bn-inline-content",h.className))},context:c})})},a)},render(l,a){if(this.renderType==="nodeView")return R3(c=>{var h;let d=uC(c.getPos,a,c.editor,o.type),u=YS().nodeViewContentRef;if(!u)throw Error("nodeViewContentRef is not set");let f=i.render;return b.jsx(cf,{blockType:d.type,blockProps:d.props,propSchema:o.propSchema,isFileBlock:!!((h=i.meta)!=null&&h.fileBlockAccept),domAttributes:this.blockContentDOMAttributes,children:b.jsx(f,{block:d,editor:a,contentRef:p=>{u(p),p&&(p.className=De("bn-inline-content",p.className),p.dataset.nodeViewContent="")}})})},{className:"bn-react-node-view-renderer"})(this.props);{let c=i.render;return Q0(d=>b.jsx(cf,{blockType:l.type,blockProps:l.props,propSchema:o.propSchema,domAttributes:this.blockContentDOMAttributes,children:b.jsx(c,{block:l,editor:a,contentRef:u=>{d(u),u&&(u.className=De("bn-inline-content",u.className))}})}),a)}}},extensions:s}}}tt.memo(({thread:t,selectedThreadId:e,maxCommentsBeforeCollapse:n,referenceText:r,orphaned:o})=>{let i=Se(Pr),s=v.useCallback(a=>{a.target.closest(".bn-action-toolbar")||i.selectThread(t.id)},[i,t.id]),l=v.useCallback(a=>{if(!a.relatedTarget||a.relatedTarget.closest(".bn-action-toolbar"))return;let c=a.target instanceof Node?a.target:null,d=a.relatedTarget instanceof Node?a.relatedTarget.closest(".bn-thread"):null;(!c||!d||!d.contains(c))&&i.selectThread(void 0)},[i]);return b.jsx(Im,{thread:t,selected:t.id===e,orphaned:o,referenceText:r,maxCommentsBeforeCollapse:n,onFocus:s,onBlur:l,tabIndex:0})});function h2(t,e){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=n.top<r.top,i=n.bottom>r.bottom;return o&&i?"both":o?"top":i?"bottom":"none"}function tH(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function sr(t){return Object.keys(t)}function df(t){return t&&typeof t=="object"&&!Array.isArray(t)}function Dm(t,e){const n={...t},r=e;return df(t)&&df(e)&&Object.keys(e).forEach(o=>{df(r[o])&&o in t?n[o]=Dm(n[o],r[o]):n[o]=r[o]}),n}function nH(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function rH(t){var e;return typeof t!="string"||!t.includes("var(--mantine-scale)")?t:(e=t.match(/^calc\((.*?)\)$/))==null?void 0:e[1].split("*")[0].trim()}function oH(t){const e=rH(t);return typeof e=="number"?e:typeof e=="string"?e.includes("calc")||e.includes("var")?e:e.includes("px")?Number(e.replace("px","")):e.includes("rem")?Number(e.replace("rem",""))*16:e.includes("em")?Number(e.replace("em",""))*16:Number(e):NaN}function e1(t){return t==="0rem"?"0rem":`calc(${t} * var(--mantine-scale))`}function p2(t,{shouldScale:e=!1}={}){function n(r){if(r===0||r==="0")return`0${t}`;if(typeof r=="number"){const o=`${r/16}${t}`;return e?e1(o):o}if(typeof r=="string"){if(r===""||r.startsWith("calc(")||r.startsWith("clamp(")||r.includes("rgba("))return r;if(r.includes(","))return r.split(",").map(i=>n(i)).join(",");if(r.includes(" "))return r.split(" ").map(i=>n(i)).join(" ");const o=r.replace("px","");if(!Number.isNaN(Number(o))){const i=`${Number(o)/16}${t}`;return e?e1(i):i}}return r}return n}const $=p2("rem",{shouldScale:!0}),t1=p2("em");function Ld(t){return Object.keys(t).reduce((e,n)=>(t[n]!==void 0&&(e[n]=t[n]),e),{})}function m2(t){if(typeof t=="number")return!0;if(typeof t=="string"){if(t.startsWith("calc(")||t.startsWith("var(")||t.includes(" ")&&t.trim()!=="")return!0;const e=/^[+-]?[0-9]+(\.[0-9]+)?(px|em|rem|ex|ch|lh|rlh|vw|vh|vmin|vmax|vb|vi|svw|svh|lvw|lvh|dvw|dvh|cm|mm|in|pt|pc|q|cqw|cqh|cqi|cqb|cqmin|cqmax|%)?$/;return t.trim().split(/\s+/).every(n=>e.test(n))}return!1}function g2(t){return Array.isArray(t)||t===null?!1:typeof t=="object"?t.type!==v.Fragment:!1}function Bd(t){const e=v.createContext(null);return[e,()=>{const r=v.use(e);if(r===null)throw new Error(t);return r}]}function n1(t,e){return n=>{if(typeof n!="string"||n.trim().length===0)throw new Error(e);return`${t}-${n}`}}function Hc(t,e){let n=t;for(;(n=n.parentElement)&&!n.matches(e););return n}function r1(t,e,n){for(let r=t-1;r>=0;r-=1)if(!e[r].disabled)return r;if(n){for(let r=e.length-1;r>-1;r-=1)if(!e[r].disabled)return r}return t}function o1(t,e,n){for(let r=t+1;r<e.length;r+=1)if(!e[r].disabled)return r;if(n){for(let r=0;r<e.length;r+=1)if(!e[r].disabled)return r}return t}function iH(t,e,n){return Hc(t,n)===Hc(e,n)}function jd({parentSelector:t,siblingSelector:e,onKeyDown:n,loop:r=!0,activateOnFocus:o=!1,dir:i="rtl",orientation:s}){return l=>{var p,m,g;n==null||n(l);const a=Array.from(((p=Hc(l.currentTarget,t))==null?void 0:p.querySelectorAll(e))||[]).filter(y=>iH(l.currentTarget,y,t)),c=a.findIndex(y=>l.currentTarget===y),d=o1(c,a,r),u=r1(c,a,r),f=i==="rtl"?u:d,h=i==="rtl"?d:u;switch(l.key){case"ArrowRight":s==="horizontal"&&(l.stopPropagation(),l.preventDefault(),a[f].focus(),o&&a[f].click());break;case"ArrowLeft":s==="horizontal"&&(l.stopPropagation(),l.preventDefault(),a[h].focus(),o&&a[h].click());break;case"ArrowUp":s==="vertical"&&(l.stopPropagation(),l.preventDefault(),a[u].focus(),o&&a[u].click());break;case"ArrowDown":s==="vertical"&&(l.stopPropagation(),l.preventDefault(),a[d].focus(),o&&a[d].click());break;case"Home":l.stopPropagation(),l.preventDefault(),(m=a[o1(-1,a,!1)])==null||m.focus();break;case"End":l.stopPropagation(),l.preventDefault(),(g=a[r1(a.length,a,!1)])==null||g.focus();break}}}const sH={app:100,modal:200,popover:300,overlay:400,max:9999};function Ul(t){return sH[t]}const lH=()=>{};function aH(t,e={active:!0}){return typeof t!="function"||!e.active?e.onKeyDown||lH:n=>{var r;n.key==="Escape"&&(t(n),(r=e.onTrigger)==null||r.call(e))}}function Ve(t,e="size",n=!0){if(t!==void 0)return m2(t)?n?$(t):t:`var(--${e}-${t})`}function Wl(t){return Ve(t,"mantine-spacing")}function _t(t){return t===void 0?"var(--mantine-radius-default)":Ve(t,"mantine-radius")}function Tt(t){return Ve(t,"mantine-font-size")}function cH(t){return Ve(t,"mantine-line-height",!1)}function b2(t){if(t)return Ve(t,"mantine-shadow",!1)}function We(t,e){return n=>{t==null||t(n),e==null||e(n)}}function dH(t,e,n){var r;return n?Array.from(((r=Hc(n,e))==null?void 0:r.querySelectorAll(t))||[]).findIndex(o=>o===n):null}function uH(t="mantine-"){return`${t}${Math.random().toString(36).slice(2,11)}`}function i1(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>((...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)}),[])}const fH=["mousedown","touchstart"];function hH(t,e,n,r=!0){const o=v.useRef(null),i=e||fH,s=v.useEffectEvent(a=>{const{target:c}=a??{};if(!document.body.contains(c)&&(c==null?void 0:c.tagName)!=="HTML")return;const d=a.composedPath();Array.isArray(n)?n.every(u=>!!u&&!d.includes(u))&&t(a):o.current&&!d.includes(o.current)&&t(a)}),l=i.join(",");return v.useEffect(()=>{if(!r)return;const a=l.split(",");return a.forEach(c=>document.addEventListener(c,s)),()=>{a.forEach(c=>document.removeEventListener(c,s))}},[l,r]),o}function pH(t,e){return typeof window<"u"&&"matchMedia"in window?window.matchMedia(t).matches:!1}function mH(t,e,{getInitialValueInEffect:n}={getInitialValueInEffect:!0}){const[r,o]=v.useState(n?e:pH(t));return v.useEffect(()=>{try{if("matchMedia"in window){const i=window.matchMedia(t);o(i.matches);const s=l=>o(l.matches);return i.addEventListener("change",s),()=>{i.removeEventListener("change",s)}}}catch{return}},[t]),r||!1}const ni=typeof document<"u"?v.useLayoutEffect:v.useEffect;function _m(t,e){const n=v.useRef(!1);v.useEffect(()=>()=>{n.current=!1},[]),v.useEffect(()=>{if(n.current)return t();n.current=!0},e)}function gH({opened:t,shouldReturnFocus:e=!0}){const n=v.useRef(null),r=()=>{var o;n.current&&"focus"in n.current&&typeof n.current.focus=="function"&&((o=n.current)==null||o.focus({preventScroll:!0}))};return _m(()=>{let o=-1;const i=s=>{s.key==="Tab"&&window.clearTimeout(o)};if(document.addEventListener("keydown",i),t)n.current=document.activeElement;else if(e){const s=document.activeElement;o=window.setTimeout(()=>{const l=document.activeElement;(l===null||l===document.body||l===s)&&r()},10)}return()=>{window.clearTimeout(o),document.removeEventListener("keydown",i)}},[t,e]),r}const bH=/input|select|textarea|button|object/,y2="a, input, select, textarea, button, object, [tabindex]";function yH(t){return t.style.display==="none"}function vH(t){if(t.getAttribute("aria-hidden")||t.getAttribute("hidden")||t.getAttribute("type")==="hidden")return!1;let e=t;for(;e&&!(e===document.body||e.nodeType===11);){if(yH(e))return!1;e=e.parentNode}return!0}function v2(t){let e=t.getAttribute("tabindex");return e===null&&(e=void 0),parseInt(e,10)}function Dh(t){const e=t.nodeName.toLowerCase(),n=!Number.isNaN(v2(t));return(bH.test(e)&&!t.disabled||t instanceof HTMLAnchorElement&&t.href||n)&&vH(t)}function w2(t){const e=v2(t);return(Number.isNaN(e)||e>=0)&&Dh(t)}function wH(t){return Array.from(t.querySelectorAll(y2)).filter(w2)}function kH(t,e){const n=wH(t);if(!n.length){e.preventDefault();return}const r=n[e.shiftKey?0:n.length-1],o=t.getRootNode();let i=r===o.activeElement||t===o.activeElement;const s=o.activeElement;if(s.tagName==="INPUT"&&s.getAttribute("type")==="radio"&&(i=n.filter(a=>a.getAttribute("type")==="radio"&&a.getAttribute("name")===s.getAttribute("name")).includes(r)),!i)return;e.preventDefault();const l=n[e.shiftKey?n.length-1:0];l&&l.focus()}function k2(t=!0){const e=v.useRef(null),n=o=>{let i=o.querySelector("[data-autofocus]");if(!i){const s=Array.from(o.querySelectorAll(y2));i=s.find(w2)||s.find(Dh)||null,!i&&Dh(o)&&(i=o)}i?i.focus({preventScroll:!0}):console.warn("[@mantine/hooks/use-focus-trap] Failed to find focusable element within provided node",o)},r=v.useCallback(o=>{if(t){if(o===null){e.current=null;return}e.current!==o&&(setTimeout(()=>{o.getRootNode()?n(o):console.warn("[@mantine/hooks/use-focus-trap] Ref node is not part of the dom",o)}),e.current=o)}},[t]);return v.useEffect(()=>{if(!t)return;e.current&&setTimeout(()=>{e.current&&n(e.current)});const o=i=>{i.key==="Tab"&&e.current&&kH(e.current,i)};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[t]),r}const xH=t=>(t+1)%1e6;function CH(){const[,t]=v.useReducer(xH,0);return t}function us(t){const[e,n]=v.useState(`mantine-${v.useId().replace(/:/g,"")}`),r=v.useRef(!1);return ni(()=>{r.current||(r.current=!0,n(uH()))},[]),typeof t=="string"?t:e}function Fc(t,e){if(typeof t=="function")return t(e);typeof t=="object"&&t!==null&&"current"in t&&(t.current=e)}function Vd(...t){const e=new Map;return n=>{if(t.forEach(r=>{const o=Fc(r,n);o&&e.set(r,o)}),e.size>0)return()=>{t.forEach(r=>{const o=e.get(r);o&&typeof o=="function"?o():Fc(r,null)}),e.clear()}}}function fn(...t){return v.useCallback(Vd(...t),t)}function pr({value:t,defaultValue:e,finalValue:n,onChange:r=()=>{}}){const[o,i]=v.useState(e!==void 0?e:n),s=(l,...a)=>{i(l),r==null||r(l,...a)};return t!==void 0?[t,r,!0]:[o,s,!1]}function SH(t,e){return mH("(prefers-reduced-motion: reduce)",t,e)}function EH(){const[t,e]=v.useState(!1),n=v.useRef(null),r=v.useCallback(()=>{e(!0)},[]),o=v.useCallback(()=>{e(!1)},[]);return{ref:v.useCallback(i=>(n.current&&(n.current.removeEventListener("mouseenter",r),n.current.removeEventListener("mouseleave",o)),i&&(i.addEventListener("mouseenter",r),i.addEventListener("mouseleave",o)),n.current=i,()=>{n.current=null,e(!1)}),[r,o]),hovered:t}}function MH(t){return t.currentTarget instanceof HTMLElement&&t.relatedTarget instanceof HTMLElement?t.currentTarget.contains(t.relatedTarget):!1}function TH({onBlur:t,onFocus:e}={}){const[n,r]=v.useState(!1),o=v.useRef(!1),i=v.useRef(null),s=i1(e),l=i1(t),a=v.useCallback(f=>{r(f),o.current=f},[]),c=v.useCallback(f=>{o.current||(a(!0),s(f))},[]),d=v.useCallback(f=>{o.current&&!MH(f)&&(a(!1),l(f))},[]),u=v.useCallback(f=>{f&&(i.current&&(i.current.removeEventListener("focusin",c),i.current.removeEventListener("focusout",d)),f.addEventListener("focusin",c),f.addEventListener("focusout",d),i.current=f)},[c,d]);return v.useEffect(()=>()=>{i.current&&(i.current.removeEventListener("focusin",c),i.current.removeEventListener("focusout",d))},[]),{ref:u,focused:n}}const AH=["mouse","touch"],NH=10;function RH(t,e={}){const{threshold:n=400,events:r=AH,cancelOnMove:o=!1,onStart:i,onFinish:s,onCancel:l}=e,a=v.useRef(!1),c=v.useRef(!1),d=v.useRef(-1),u=v.useRef(null);return v.useEffect(()=>()=>window.clearTimeout(d.current),[]),v.useMemo(()=>{if(typeof t!="function")return{};const f=o!==!1,h=o===!0?NH:o===!1?0:o,p=w=>{!l1(w)&&!_h(w)||(i&&i(w),u.current=s1(w),c.current=!0,d.current=window.setTimeout(()=>{t(w),a.current=!0},n))},m=w=>{!l1(w)&&!_h(w)||(a.current?s&&s(w):c.current&&l&&l(w),a.current=!1,c.current=!1,u.current=null,d.current!==-1&&(window.clearTimeout(d.current),d.current=-1))},g=w=>{if(!f||!c.current||a.current)return;const k=s1(w);if(!k||!u.current)return;const x=k.x-u.current.x,C=k.y-u.current.y;Math.sqrt(x*x+C*C)>h&&m(w)},y={};return r.includes("mouse")&&(y.onMouseDown=p,y.onMouseUp=m,y.onMouseLeave=m,f&&(y.onMouseMove=g)),r.includes("touch")&&(y.onTouchStart=p,y.onTouchEnd=m,y.onTouchCancel=m,f&&(y.onTouchMove=g)),y},[t,n,l,s,i,o,r.join(",")])}function s1(t){if(_h(t)){const e=t.touches[0]??t.changedTouches[0];return e?{x:e.clientX,y:e.clientY}:null}return{x:t.clientX,y:t.clientY}}function _h(t){return window.TouchEvent?t.nativeEvent instanceof TouchEvent:"touches"in t.nativeEvent}function l1(t){return t.nativeEvent instanceof MouseEvent}function Pm(t){var n;const e=tt.version;return typeof tt.version!="string"||e.startsWith("18.")?t==null?void 0:t.ref:(n=t==null?void 0:t.props)==null?void 0:n.ref}function di(t){const e=v.Children.toArray(t);return e.length!==1||!g2(e[0])?null:e[0]}const IH={};function OH(t){const e={};return t.forEach(n=>{Object.entries(n).forEach(([r,o])=>{e[r]?e[r]=$r(e[r],o):e[r]=o})}),e}function Cl({theme:t,classNames:e,props:n,stylesCtx:r}){return OH((Array.isArray(e)?e:[e]).map(o=>typeof o=="function"?o(t,n,r):o||IH))}function zc({theme:t,styles:e,props:n,stylesCtx:r}){const o=Array.isArray(e)?e:[e],i={};for(const s of o)typeof s=="function"?Object.assign(i,s(t,n,r)):s&&Object.assign(i,s);return i}function a1(t){return t==="auto"||t==="dark"||t==="light"}function DH({key:t="mantine-color-scheme-value"}={}){let e;return{get:n=>{if(typeof window>"u")return n;try{const r=window.localStorage.getItem(t);return a1(r)?r:n}catch{return n}},set:n=>{try{window.localStorage.setItem(t,n)}catch(r){console.warn("[@mantine/core] Local storage color scheme manager was unable to save color scheme.",r)}},subscribe:n=>{e=r=>{r.storageArea===window.localStorage&&r.key===t&&a1(r.newValue)&&n(r.newValue)},window.addEventListener("storage",e)},unsubscribe:()=>{window.removeEventListener("storage",e)},clear:()=>{window.localStorage.removeItem(t)}}}function Sl(t,e){return typeof t.primaryShade=="number"?t.primaryShade:e==="dark"?t.primaryShade.dark:t.primaryShade.light}function _H(t){return/^#?([0-9A-F]{3}){1,2}([0-9A-F]{2})?$/i.test(t)}function PH(t){let e=t.replace("#","");if(e.length===3){const r=e.split("");e=[r[0],r[0],r[1],r[1],r[2],r[2]].join("")}if(e.length===8){const r=parseInt(e.slice(6,8),16)/255;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16),a:r}}const n=parseInt(e,16);return{r:n>>16&255,g:n>>8&255,b:n&255,a:1}}function $H(t){const[e,n,r,o]=t.replace(/[^0-9,./]/g,"").split(/[/,]/).map(Number);return{r:e,g:n,b:r,a:o===void 0?1:o}}function LH(t){const e=t.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+%)\s*,\s*(\d+%)\s*(,\s*(0?\.\d+|\d+(\.\d+)?))?\s*\)$/i);if(!e)return{r:0,g:0,b:0,a:1};const n=parseInt(e[1],10),r=parseInt(e[2],10)/100,o=parseInt(e[3],10)/100,i=e[5]?parseFloat(e[5]):void 0,s=(1-Math.abs(2*o-1))*r,l=n/60,a=s*(1-Math.abs(l%2-1)),c=o-s/2;let d,u,f;return l>=0&&l<1?(d=s,u=a,f=0):l>=1&&l<2?(d=a,u=s,f=0):l>=2&&l<3?(d=0,u=s,f=a):l>=3&&l<4?(d=0,u=a,f=s):l>=4&&l<5?(d=a,u=0,f=s):(d=s,u=0,f=a),{r:Math.round((d+c)*255),g:Math.round((u+c)*255),b:Math.round((f+c)*255),a:i||1}}function $m(t){return _H(t)?PH(t):t.startsWith("rgb")?$H(t):t.startsWith("hsl")?LH(t):{r:0,g:0,b:0,a:1}}function uf(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function BH(t){const e=t.match(/oklch\((.*?)%\s/);return e?parseFloat(e[1]):null}function jH(t){if(t.startsWith("oklch("))return(BH(t)||0)/100;const{r:e,g:n,b:r}=$m(t),o=e/255,i=n/255,s=r/255,l=uf(o),a=uf(i),c=uf(s);return .2126*l+.7152*a+.0722*c}function Ss(t,e=.179){return t.startsWith("var(")?!1:jH(t)>e}function ko({color:t,theme:e,colorScheme:n}){if(typeof t!="string")throw new Error(`[@mantine/core] Failed to parse color. Expected color to be a string, instead got ${typeof t}`);if(t==="bright")return{color:t,value:n==="dark"?e.white:e.black,shade:void 0,isThemeColor:!1,isLight:Ss(n==="dark"?e.white:e.black,e.luminanceThreshold),variable:"--mantine-color-bright"};if(t==="dimmed")return{color:t,value:n==="dark"?e.colors.dark[2]:e.colors.gray[7],shade:void 0,isThemeColor:!1,isLight:Ss(n==="dark"?e.colors.dark[2]:e.colors.gray[6],e.luminanceThreshold),variable:"--mantine-color-dimmed"};if(t==="white"||t==="black")return{color:t,value:t==="white"?e.white:e.black,shade:void 0,isThemeColor:!1,isLight:Ss(t==="white"?e.white:e.black,e.luminanceThreshold),variable:`--mantine-color-${t}`};const[r,o]=t.split("."),i=o?Number(o):void 0,s=r in e.colors;if(s){const l=i!==void 0?e.colors[r][i]:e.colors[r][Sl(e,n||"light")];return{color:r,value:l,shade:i,isThemeColor:s,isLight:Ss(l,e.luminanceThreshold),variable:o?`--mantine-color-${r}-${i}`:`--mantine-color-${r}-filled`}}return{color:t,value:t,isThemeColor:s,isLight:Ss(t,e.luminanceThreshold),shade:i,variable:void 0}}function ho(t,e){const n=ko({color:t||e.primaryColor,theme:e});return n.variable?`var(${n.variable})`:t}function Lm(t){return!!t&&typeof t=="object"&&"mantine-virtual-color"in t}function To(t,e){if(t.startsWith("var("))return`color-mix(in srgb, ${t}, black ${e*100}%)`;const{r:n,g:r,b:o,a:i}=$m(t),s=1-e,l=a=>Math.round(a*s);return`rgba(${l(n)}, ${l(r)}, ${l(o)}, ${i})`}function Ph(t,e){const n={from:(t==null?void 0:t.from)||e.defaultGradient.from,to:(t==null?void 0:t.to)||e.defaultGradient.to,deg:(t==null?void 0:t.deg)??e.defaultGradient.deg??0},r=ho(n.from,e),o=ho(n.to,e);return`linear-gradient(${n.deg}deg, ${r} 0%, ${o} 100%)`}function Wr(t,e){if(typeof t!="string"||e>1||e<0)return"rgba(0, 0, 0, 1)";if(t.startsWith("var("))return`color-mix(in srgb, ${t}, transparent ${(1-e)*100}%)`;if(t.startsWith("oklch"))return t.includes("/")?t.replace(/\/\s*[\d.]+\s*\)/,`/ ${e})`):t.replace(")",` / ${e})`);const{r:n,g:r,b:o}=$m(t);return`rgba(${n}, ${r}, ${o}, ${e})`}const c1=Wr,VH=({color:t,theme:e,variant:n,gradient:r,autoContrast:o})=>{const i=ko({color:t,theme:e}),s=typeof o=="boolean"?o:e.autoContrast;if(n==="none")return{background:"transparent",hover:"transparent",color:"inherit",border:"none"};if(n==="filled"){const l=i.isThemeColor&&i.shade===void 0&&Lm(e.colors[i.color]),a=s?l?`var(--mantine-color-${i.color}-contrast)`:i.isLight?"var(--mantine-color-black)":"var(--mantine-color-white)":"var(--mantine-color-white)";return i.isThemeColor?i.shade===void 0?{background:`var(--mantine-color-${t}-filled)`,hover:`var(--mantine-color-${t}-filled-hover)`,color:a,border:`${$(1)} solid transparent`}:{background:`var(--mantine-color-${i.color}-${i.shade})`,hover:`var(--mantine-color-${i.color}-${i.shade===9?8:i.shade+1})`,color:a,border:`${$(1)} solid transparent`}:{background:t,hover:To(t,.1),color:a,border:`${$(1)} solid transparent`}}if(n==="light"){if(i.isThemeColor){if(i.shade===void 0)return{background:`var(--mantine-color-${t}-light)`,hover:`var(--mantine-color-${t}-light-hover)`,color:`var(--mantine-color-${t}-light-color)`,border:`${$(1)} solid transparent`};const l=e.colors[i.color][i.shade];return{background:l,hover:To(l,.1),color:`var(--mantine-color-${i.color}-light-color)`,border:`${$(1)} solid transparent`}}return{background:Wr(t,.1),hover:Wr(t,.12),color:t,border:`${$(1)} solid transparent`}}if(n==="outline")return i.isThemeColor?i.shade===void 0?{background:"transparent",hover:`var(--mantine-color-${t}-outline-hover)`,color:`var(--mantine-color-${t}-outline)`,border:`${$(1)} solid var(--mantine-color-${t}-outline)`}:{background:"transparent",hover:Wr(e.colors[i.color][i.shade],.05),color:`var(--mantine-color-${i.color}-${i.shade})`,border:`${$(1)} solid var(--mantine-color-${i.color}-${i.shade})`}:{background:"transparent",hover:Wr(t,.05),color:t,border:`${$(1)} solid ${t}`};if(n==="subtle"){if(i.isThemeColor){if(i.shade===void 0)return{background:"transparent",hover:`var(--mantine-color-${t}-light-hover)`,color:`var(--mantine-color-${t}-light-color)`,border:`${$(1)} solid transparent`};const l=e.colors[i.color][i.shade];return{background:"transparent",hover:Wr(l,.12),color:`var(--mantine-color-${i.color}-${Math.min(i.shade,6)})`,border:`${$(1)} solid transparent`}}return{background:"transparent",hover:Wr(t,.12),color:t,border:`${$(1)} solid transparent`}}return n==="transparent"?i.isThemeColor?i.shade===void 0?{background:"transparent",hover:"transparent",color:`var(--mantine-color-${t}-light-color)`,border:`${$(1)} solid transparent`}:{background:"transparent",hover:"transparent",color:`var(--mantine-color-${i.color}-${Math.min(i.shade,6)})`,border:`${$(1)} solid transparent`}:{background:"transparent",hover:"transparent",color:t,border:`${$(1)} solid transparent`}:n==="white"?i.isThemeColor?i.shade===void 0?{background:"var(--mantine-color-white)",hover:To(e.white,.01),color:`var(--mantine-color-${t}-filled)`,border:`${$(1)} solid transparent`}:{background:"var(--mantine-color-white)",hover:To(e.white,.01),color:`var(--mantine-color-${i.color}-${i.shade})`,border:`${$(1)} solid transparent`}:{background:"var(--mantine-color-white)",hover:To(e.white,.01),color:t,border:`${$(1)} solid transparent`}:n==="gradient"?{background:Ph(r,e),hover:Ph(r,e),color:"var(--mantine-color-white)",border:"none"}:n==="default"?{background:"var(--mantine-color-default)",hover:"var(--mantine-color-default-hover)",color:"var(--mantine-color-default-color)",border:`${$(1)} solid var(--mantine-color-default-border)`}:{}};function Bm({color:t,theme:e,autoContrast:n,colorScheme:r}){return(typeof n=="boolean"?n:e.autoContrast)&&ko({color:t||e.primaryColor,theme:e,colorScheme:r}).isLight?"var(--mantine-color-black)":"var(--mantine-color-white)"}function $h(t,e,n){return Bm({color:n==="dark"?t.dark:t.light,theme:e,colorScheme:n,autoContrast:!0})}function d1(t,e){const n=t.colors[t.primaryColor];return Lm(n)?t.autoContrast?$h(n,t,e):"var(--mantine-color-white)":Bm({color:n[Sl(t,e)],theme:t,autoContrast:null})}function HH(t,e){return typeof t=="boolean"?t:e.autoContrast}const jm=v.createContext(null);function jr(){const t=v.use(jm);if(!t)throw new Error("[@mantine/core] MantineProvider was not found in tree");return t}function FH(){return jr().cssVariablesResolver}function zH(){return jr().classNamesPrefix}function Vm(){return jr().getStyleNonce}function UH(){return jr().withStaticClasses}function WH(){return jr().headless}function qH(){var t;return(t=jr().stylesTransform)==null?void 0:t.sx}function GH(){var t;return(t=jr().stylesTransform)==null?void 0:t.styles}function Hd(){return jr().env||"default"}function x2(){return jr().deduplicateInlineStyles}function bi(t,e){var o,i;const n=typeof window<"u"&&"matchMedia"in window&&((o=window.matchMedia("(prefers-color-scheme: dark)"))==null?void 0:o.matches),r=t!=="auto"?t:n?"dark":"light";(i=e())==null||i.setAttribute("data-mantine-color-scheme",r)}function ZH({manager:t,defaultColorScheme:e,getRootElement:n,forceColorScheme:r}){const o=v.useRef(null),[i,s]=v.useState(()=>t.get(e)),l=r||i,a=v.useCallback(d=>{r||(bi(d,n),s(d),t.set(d))},[t.set,l,r]),c=v.useCallback(()=>{s(e),bi(e,n),t.clear()},[t.clear,e]);return v.useEffect(()=>(t.subscribe(a),t.unsubscribe),[t.subscribe,t.unsubscribe]),ni(()=>{bi(t.get(e),n)},[]),v.useEffect(()=>{var u;if(r)return bi(r,n),()=>{};r===void 0&&bi(i,n),typeof window<"u"&&"matchMedia"in window&&(o.current=window.matchMedia("(prefers-color-scheme: dark)"));const d=f=>{i==="auto"&&bi(f.matches?"dark":"light",n)};return(u=o.current)==null||u.addEventListener("change",d),()=>{var f;return(f=o.current)==null?void 0:f.removeEventListener("change",d)}},[i,r]),{colorScheme:l,setColorScheme:a,clearColorScheme:c}}const KH={dark:["#C9C9C9","#b8b8b8","#828282","#696969","#424242","#3b3b3b","#2e2e2e","#242424","#1f1f1f","#141414"],gray:["#f8f9fa","#f1f3f5","#e9ecef","#dee2e6","#ced4da","#adb5bd","#868e96","#495057","#343a40","#212529"],red:["#fff5f5","#ffe3e3","#ffc9c9","#ffa8a8","#ff8787","#ff6b6b","#fa5252","#f03e3e","#e03131","#c92a2a"],pink:["#fff0f6","#ffdeeb","#fcc2d7","#faa2c1","#f783ac","#f06595","#e64980","#d6336c","#c2255c","#a61e4d"],grape:["#f8f0fc","#f3d9fa","#eebefa","#e599f7","#da77f2","#cc5de8","#be4bdb","#ae3ec9","#9c36b5","#862e9c"],violet:["#f3f0ff","#e5dbff","#d0bfff","#b197fc","#9775fa","#845ef7","#7950f2","#7048e8","#6741d9","#5f3dc4"],indigo:["#edf2ff","#dbe4ff","#bac8ff","#91a7ff","#748ffc","#5c7cfa","#4c6ef5","#4263eb","#3b5bdb","#364fc7"],blue:["#e7f5ff","#d0ebff","#a5d8ff","#74c0fc","#4dabf7","#339af0","#228be6","#1c7ed6","#1971c2","#1864ab"],cyan:["#e3fafc","#c5f6fa","#99e9f2","#66d9e8","#3bc9db","#22b8cf","#15aabf","#1098ad","#0c8599","#0b7285"],teal:["#e6fcf5","#c3fae8","#96f2d7","#63e6be","#38d9a9","#20c997","#12b886","#0ca678","#099268","#087f5b"],green:["#ebfbee","#d3f9d8","#b2f2bb","#8ce99a","#69db7c","#51cf66","#40c057","#37b24d","#2f9e44","#2b8a3e"],lime:["#f4fce3","#e9fac8","#d8f5a2","#c0eb75","#a9e34b","#94d82d","#82c91e","#74b816","#66a80f","#5c940d"],yellow:["#fff9db","#fff3bf","#ffec99","#ffe066","#ffd43b","#fcc419","#fab005","#f59f00","#f08c00","#e67700"],orange:["#fff4e6","#ffe8cc","#ffd8a8","#ffc078","#ffa94d","#ff922b","#fd7e14","#f76707","#e8590c","#d9480f"]},u1="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji",Hm={scale:1,fontSmoothing:!0,focusRing:"auto",white:"#fff",black:"#000",colors:KH,primaryShade:{light:6,dark:8},primaryColor:"blue",variantColorResolver:VH,autoContrast:!1,luminanceThreshold:.3,fontFamily:u1,fontFamilyMonospace:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace",respectReducedMotion:!1,cursorType:"default",defaultGradient:{from:"blue",to:"cyan",deg:45},defaultRadius:"md",activeClassName:"mantine-active",focusClassName:"",headings:{fontFamily:u1,fontWeight:"700",textWrap:"wrap",sizes:{h1:{fontSize:$(34),lineHeight:"1.3"},h2:{fontSize:$(26),lineHeight:"1.35"},h3:{fontSize:$(22),lineHeight:"1.4"},h4:{fontSize:$(18),lineHeight:"1.45"},h5:{fontSize:$(16),lineHeight:"1.5"},h6:{fontSize:$(14),lineHeight:"1.5"}}},fontSizes:{xs:$(12),sm:$(14),md:$(16),lg:$(18),xl:$(20)},lineHeights:{xs:"1.4",sm:"1.45",md:"1.55",lg:"1.6",xl:"1.65"},fontWeights:{regular:"400",medium:"600",bold:"700"},radius:{xs:$(2),sm:$(4),md:$(8),lg:$(16),xl:$(32)},spacing:{xs:$(10),sm:$(12),md:$(16),lg:$(20),xl:$(32)},breakpoints:{xs:"36em",sm:"48em",md:"62em",lg:"75em",xl:"88em"},shadows:{xs:`0 ${$(1)} ${$(3)} rgba(0, 0, 0, 0.05), 0 ${$(1)} ${$(2)} rgba(0, 0, 0, 0.1)`,sm:`0 ${$(1)} ${$(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${$(10)} ${$(15)} ${$(-5)}, rgba(0, 0, 0, 0.04) 0 ${$(7)} ${$(7)} ${$(-5)}`,md:`0 ${$(1)} ${$(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${$(20)} ${$(25)} ${$(-5)}, rgba(0, 0, 0, 0.04) 0 ${$(10)} ${$(10)} ${$(-5)}`,lg:`0 ${$(1)} ${$(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${$(28)} ${$(23)} ${$(-7)}, rgba(0, 0, 0, 0.04) 0 ${$(12)} ${$(12)} ${$(-7)}`,xl:`0 ${$(1)} ${$(3)} rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 0 ${$(36)} ${$(28)} ${$(-7)}, rgba(0, 0, 0, 0.04) 0 ${$(17)} ${$(17)} ${$(-7)}`},other:{},components:{}},JH="[@mantine/core] MantineProvider: Invalid theme.primaryColor, it accepts only key of theme.colors, learn more – https://mantine.dev/theming/colors/#primary-color",f1="[@mantine/core] MantineProvider: Invalid theme.primaryShade, it accepts only 0-9 integers or an object { light: 0-9, dark: 0-9 }";function ff(t){return t<0||t>9?!1:parseInt(t.toString(),10)===t}function h1(t){if(!(t.primaryColor in t.colors))throw new Error(JH);if(typeof t.primaryShade=="object"&&(!ff(t.primaryShade.dark)||!ff(t.primaryShade.light)))throw new Error(f1);if(typeof t.primaryShade=="number"&&!ff(t.primaryShade))throw new Error(f1)}function YH(t,e){var r;if(!e)return h1(t),t;const n=Dm(t,e);return e.fontFamily&&!((r=e.headings)!=null&&r.fontFamily)&&(n.headings={...n.headings,fontFamily:e.fontFamily}),h1(n),n}const Fm=v.createContext(null),XH=()=>v.use(Fm)||Hm;function Kt(){const t=v.use(Fm);if(!t)throw new Error("@mantine/core: MantineProvider was not found in component tree, make sure you have it in your app");return t}function C2({theme:t,children:e,inherit:n=!0}){const r=XH();return b.jsx(Fm,{value:v.useMemo(()=>YH(n?r:Hm,t),[t,r,n]),children:e})}C2.displayName="@mantine/core/MantineThemeProvider";function hf(t){return Object.entries(t).map(([e,n])=>`${e}: ${n};`).join("")}function S2(t,e){const n=e?[e]:[":root",":host"],r=hf(t.variables),o=r?`${n.join(", ")}{${r}}`:"",i=hf(t.dark),s=hf(t.light),l=a=>n.map(c=>c===":host"?`${c}([data-mantine-color-scheme="${a}"])`:`${c}[data-mantine-color-scheme="${a}"]`).join(", ");return`${o}
208
+
209
+ ${i?`${l("dark")}{${i}}`:""}
210
+
211
+ ${s?`${l("light")}{${s}}`:""}`}function Na({theme:t,color:e,colorScheme:n,name:r=e,withColorValues:o=!0}){if(!t.colors[e])return{};if(n==="light"){const l=Sl(t,"light"),a={[`--mantine-color-${r}-text`]:`var(--mantine-color-${r}-filled)`,[`--mantine-color-${r}-filled`]:`var(--mantine-color-${r}-${l})`,[`--mantine-color-${r}-filled-hover`]:`var(--mantine-color-${r}-${l===9?8:l+1})`,[`--mantine-color-${r}-light`]:`var(--mantine-color-${r}-1)`,[`--mantine-color-${r}-light-hover`]:`var(--mantine-color-${r}-2)`,[`--mantine-color-${r}-light-color`]:`var(--mantine-color-${r}-9)`,[`--mantine-color-${r}-outline`]:`var(--mantine-color-${r}-${l})`,[`--mantine-color-${r}-outline-hover`]:c1(t.colors[e][l],.05)};return o?{[`--mantine-color-${r}-0`]:t.colors[e][0],[`--mantine-color-${r}-1`]:t.colors[e][1],[`--mantine-color-${r}-2`]:t.colors[e][2],[`--mantine-color-${r}-3`]:t.colors[e][3],[`--mantine-color-${r}-4`]:t.colors[e][4],[`--mantine-color-${r}-5`]:t.colors[e][5],[`--mantine-color-${r}-6`]:t.colors[e][6],[`--mantine-color-${r}-7`]:t.colors[e][7],[`--mantine-color-${r}-8`]:t.colors[e][8],[`--mantine-color-${r}-9`]:t.colors[e][9],...a}:a}const i=Sl(t,"dark"),s={[`--mantine-color-${r}-text`]:`var(--mantine-color-${r}-4)`,[`--mantine-color-${r}-filled`]:`var(--mantine-color-${r}-${i})`,[`--mantine-color-${r}-filled-hover`]:`var(--mantine-color-${r}-${i===9?8:i+1})`,[`--mantine-color-${r}-light`]:To(t.colors[e][9],.5),[`--mantine-color-${r}-light-hover`]:To(t.colors[e][9],.3),[`--mantine-color-${r}-light-color`]:`var(--mantine-color-${r}-0)`,[`--mantine-color-${r}-outline`]:`var(--mantine-color-${r}-${Math.max(i-4,0)})`,[`--mantine-color-${r}-outline-hover`]:c1(t.colors[e][Math.max(i-4,0)],.05)};return o?{[`--mantine-color-${r}-0`]:t.colors[e][0],[`--mantine-color-${r}-1`]:t.colors[e][1],[`--mantine-color-${r}-2`]:t.colors[e][2],[`--mantine-color-${r}-3`]:t.colors[e][3],[`--mantine-color-${r}-4`]:t.colors[e][4],[`--mantine-color-${r}-5`]:t.colors[e][5],[`--mantine-color-${r}-6`]:t.colors[e][6],[`--mantine-color-${r}-7`]:t.colors[e][7],[`--mantine-color-${r}-8`]:t.colors[e][8],[`--mantine-color-${r}-9`]:t.colors[e][9],...s}:s}function So(t,e,n){sr(e).forEach(r=>Object.assign(t,{[`--mantine-${n}-${r}`]:e[r]}))}const E2=t=>{const e=Sl(t,"light"),n=t.defaultRadius in t.radius?t.radius[t.defaultRadius]:$(t.defaultRadius),r={variables:{"--mantine-z-index-app":"100","--mantine-z-index-modal":"200","--mantine-z-index-popover":"300","--mantine-z-index-overlay":"400","--mantine-z-index-max":"9999","--mantine-scale":t.scale.toString(),"--mantine-cursor-type":t.cursorType,"--mantine-webkit-font-smoothing":t.fontSmoothing?"antialiased":"unset","--mantine-moz-font-smoothing":t.fontSmoothing?"grayscale":"unset","--mantine-color-white":t.white,"--mantine-color-black":t.black,"--mantine-line-height":t.lineHeights.md,"--mantine-font-family":t.fontFamily,"--mantine-font-family-monospace":t.fontFamilyMonospace,"--mantine-font-family-headings":t.headings.fontFamily,"--mantine-heading-font-weight":t.headings.fontWeight,"--mantine-heading-text-wrap":t.headings.textWrap,"--mantine-radius-default":n,"--mantine-primary-color-filled":`var(--mantine-color-${t.primaryColor}-filled)`,"--mantine-primary-color-filled-hover":`var(--mantine-color-${t.primaryColor}-filled-hover)`,"--mantine-primary-color-light":`var(--mantine-color-${t.primaryColor}-light)`,"--mantine-primary-color-light-hover":`var(--mantine-color-${t.primaryColor}-light-hover)`,"--mantine-primary-color-light-color":`var(--mantine-color-${t.primaryColor}-light-color)`},light:{"--mantine-color-scheme":"light","--mantine-primary-color-contrast":d1(t,"light"),"--mantine-color-bright":"var(--mantine-color-black)","--mantine-color-text":t.black,"--mantine-color-body":t.white,"--mantine-color-error":"var(--mantine-color-red-6)","--mantine-color-success":"var(--mantine-color-teal-8)","--mantine-color-placeholder":"var(--mantine-color-gray-5)","--mantine-color-anchor":`var(--mantine-color-${t.primaryColor}-${e})`,"--mantine-color-default":"var(--mantine-color-white)","--mantine-color-default-hover":"var(--mantine-color-gray-0)","--mantine-color-default-color":"var(--mantine-color-black)","--mantine-color-default-border":"var(--mantine-color-gray-4)","--mantine-color-dimmed":"var(--mantine-color-gray-6)","--mantine-color-disabled":"var(--mantine-color-gray-2)","--mantine-color-disabled-color":"var(--mantine-color-gray-5)","--mantine-color-disabled-border":"var(--mantine-color-gray-3)"},dark:{"--mantine-color-scheme":"dark","--mantine-primary-color-contrast":d1(t,"dark"),"--mantine-color-bright":"var(--mantine-color-white)","--mantine-color-text":"var(--mantine-color-dark-0)","--mantine-color-body":"var(--mantine-color-dark-7)","--mantine-color-error":"var(--mantine-color-red-8)","--mantine-color-success":"var(--mantine-color-teal-8)","--mantine-color-placeholder":"var(--mantine-color-dark-3)","--mantine-color-anchor":`var(--mantine-color-${t.primaryColor}-4)`,"--mantine-color-default":"var(--mantine-color-dark-6)","--mantine-color-default-hover":"var(--mantine-color-dark-5)","--mantine-color-default-color":"var(--mantine-color-white)","--mantine-color-default-border":"var(--mantine-color-dark-4)","--mantine-color-dimmed":"var(--mantine-color-dark-2)","--mantine-color-disabled":"var(--mantine-color-dark-6)","--mantine-color-disabled-color":"var(--mantine-color-dark-3)","--mantine-color-disabled-border":"var(--mantine-color-dark-4)"}};So(r.variables,t.breakpoints,"breakpoint"),So(r.variables,t.spacing,"spacing"),So(r.variables,t.fontSizes,"font-size"),So(r.variables,t.lineHeights,"line-height"),So(r.variables,t.shadows,"shadow"),So(r.variables,t.radius,"radius"),So(r.variables,t.fontWeights,"font-weight"),t.colors[t.primaryColor].forEach((i,s)=>{r.variables[`--mantine-primary-color-${s}`]=`var(--mantine-color-${t.primaryColor}-${s})`}),sr(t.colors).forEach(i=>{const s=t.colors[i];if(Lm(s)){Object.assign(r.light,Na({theme:t,name:s.name,color:s.light,colorScheme:"light",withColorValues:!0})),Object.assign(r.dark,Na({theme:t,name:s.name,color:s.dark,colorScheme:"dark",withColorValues:!0})),r.light[`--mantine-color-${s.name}-contrast`]=$h(s,t,"light"),r.dark[`--mantine-color-${s.name}-contrast`]=$h(s,t,"dark");return}s.forEach((l,a)=>{r.variables[`--mantine-color-${i}-${a}`]=l}),Object.assign(r.light,Na({theme:t,color:i,colorScheme:"light",withColorValues:!1})),Object.assign(r.dark,Na({theme:t,color:i,colorScheme:"dark",withColorValues:!1}))});const o=t.headings.sizes;return sr(o).forEach(i=>{r.variables[`--mantine-${i}-font-size`]=o[i].fontSize,r.variables[`--mantine-${i}-line-height`]=o[i].lineHeight,r.variables[`--mantine-${i}-font-weight`]=o[i].fontWeight||t.headings.fontWeight}),r};function QH(){const t=Kt(),e=Vm(),n=sr(t.breakpoints).reduce((r,o)=>{const i=t.breakpoints[o].includes("px"),s=oH(t.breakpoints[o]);return`${r}@media (max-width: ${i?`${s-.1}px`:t1(s-.1)}) {.mantine-visible-from-${o} {display: none !important;}}@media (min-width: ${i?`${s}px`:t1(s)}) {.mantine-hidden-from-${o} {display: none !important;}}`},"");return b.jsx("style",{"data-mantine-styles":"classes",nonce:e==null?void 0:e(),dangerouslySetInnerHTML:{__html:n}})}function eF({theme:t,generator:e}){const n=E2(t),r=e==null?void 0:e(t);return r?Dm(n,r):n}const pf=E2(Hm);function tF(t){const e={variables:{},light:{},dark:{}};return sr(t.variables).forEach(n=>{pf.variables[n]!==t.variables[n]&&(e.variables[n]=t.variables[n])}),sr(t.light).forEach(n=>{pf.light[n]!==t.light[n]&&(e.light[n]=t.light[n])}),sr(t.dark).forEach(n=>{pf.dark[n]!==t.dark[n]&&(e.dark[n]=t.dark[n])}),e}function nF(t){return S2({variables:{},dark:{"--mantine-color-scheme":"dark"},light:{"--mantine-color-scheme":"light"}},t)}function M2({cssVariablesSelector:t,deduplicateCssVariables:e}){const n=Kt(),r=Vm(),o=eF({theme:n,generator:FH()}),i=(t===void 0||t===":root"||t===":host")&&e,s=S2(i?tF(o):o,t);return s?b.jsx("style",{"data-mantine-styles":!0,nonce:r==null?void 0:r(),dangerouslySetInnerHTML:{__html:`${s}${i?"":nF(t)}`}}):null}M2.displayName="@mantine/CssVariables";function rF({respectReducedMotion:t,getRootElement:e}){ni(()=>{var n;t&&((n=e())==null||n.setAttribute("data-respect-reduced-motion","true"))},[t])}function T2({theme:t,children:e,getStyleNonce:n,withStaticClasses:r=!0,withGlobalClasses:o=!0,deduplicateCssVariables:i=!0,withCssVariables:s=!0,cssVariablesSelector:l,classNamesPrefix:a="mantine",colorSchemeManager:c=DH(),defaultColorScheme:d="light",getRootElement:u=()=>document.documentElement,cssVariablesResolver:f,forceColorScheme:h,stylesTransform:p,env:m,deduplicateInlineStyles:g=!1}){const{colorScheme:y,setColorScheme:w,clearColorScheme:k}=ZH({defaultColorScheme:d,forceColorScheme:h,manager:c,getRootElement:u});return rF({respectReducedMotion:(t==null?void 0:t.respectReducedMotion)||!1,getRootElement:u}),b.jsx(jm,{value:{colorScheme:y,setColorScheme:w,clearColorScheme:k,getRootElement:u,classNamesPrefix:a,getStyleNonce:n,cssVariablesResolver:f,cssVariablesSelector:l??":root",withStaticClasses:r,stylesTransform:p,env:m,deduplicateInlineStyles:g},children:b.jsxs(C2,{theme:t,children:[s&&b.jsx(M2,{cssVariablesSelector:l,deduplicateCssVariables:i}),o&&b.jsx(QH,{}),e]})})}T2.displayName="@mantine/core/MantineProvider";function q(t,e,n){var s;const r=Kt(),o=(Array.isArray(t)?t:[t]).filter(Boolean);let i={};for(const l of o){const a=(s=r.components[l])==null?void 0:s.defaultProps,c=typeof a=="function"?a(r):a;c&&(i={...i,...c})}return{...e,...i,...Ld(n)}}function Fd({classNames:t,styles:e,props:n,stylesCtx:r}){const o=Kt();return{resolvedClassNames:t===void 0?void 0:Cl({theme:o,classNames:t,props:n,stylesCtx:r||void 0}),resolvedStyles:e===void 0?void 0:zc({theme:o,styles:e,props:n,stylesCtx:r||void 0})}}const oF={always:"mantine-focus-always",auto:"mantine-focus-auto",never:"mantine-focus-never"};function iF({theme:t,options:e,unstyled:n}){return $r((e==null?void 0:e.focusable)&&!n&&(t.focusClassName||oF[t.focusRing]),(e==null?void 0:e.active)&&!n&&t.activeClassName)}function sF({selector:t,stylesCtx:e,options:n,props:r,theme:o}){return Cl({theme:o,classNames:n==null?void 0:n.classNames,props:(n==null?void 0:n.props)||r,stylesCtx:e})[t]}function lF({selector:t,stylesCtx:e,theme:n,classNames:r,props:o}){return Cl({theme:n,classNames:r,props:o,stylesCtx:e})[t]}function aF({rootSelector:t,selector:e,className:n}){return t===e?n:void 0}function cF({selector:t,classes:e,unstyled:n}){return n?void 0:e[t]}function dF({themeName:t,classNamesPrefix:e,selector:n,withStaticClass:r}){return r===!1?[]:t.map(o=>`${e}-${o}-${n}`)}function uF({options:t,classes:e,selector:n,unstyled:r}){return t!=null&&t.variant&&!r?e[`${n}--${t.variant}`]:void 0}function fF({theme:t,options:e,themeName:n,selector:r,classNamesPrefix:o,resolvedClassNames:i,resolvedThemeClassNames:s,classes:l,unstyled:a,className:c,rootSelector:d,props:u,stylesCtx:f,withStaticClasses:h,headless:p,transformedStyles:m}){return $r(iF({theme:t,options:e,unstyled:a||p}),s.map(g=>g[r]),uF({options:e,classes:l,selector:r,unstyled:a||p}),i[r],lF({selector:r,stylesCtx:f,theme:t,classNames:m,props:u}),sF({selector:r,stylesCtx:f,options:e,props:u,theme:t}),aF({rootSelector:d,selector:r,className:c}),cF({selector:r,classes:l,unstyled:a||p}),h&&!p&&dF({themeName:n,classNamesPrefix:o,selector:r,withStaticClass:e==null?void 0:e.withStaticClass}),e==null?void 0:e.className)}function zm({style:t,theme:e}){return Array.isArray(t)?t.reduce((n,r)=>({...n,...zm({style:r,theme:e})}),{}):typeof t=="function"?t(e):t??{}}function hF({theme:t,selector:e,options:n,props:r,stylesCtx:o,rootSelector:i,withStylesTransform:s,resolvedStyles:l,resolvedThemeStyles:a,resolvedVars:c,resolvedRootStyle:d}){return{...a[e],...l[e],...!s&&zc({theme:t,styles:n==null?void 0:n.styles,props:(n==null?void 0:n.props)||r,stylesCtx:o})[e],...c[e],...i===e?d:null,...zm({style:n==null?void 0:n.style,theme:t})}}function pF(t){return t.reduce((e,n)=>(n&&Object.keys(n).forEach(r=>{e[r]={...e[r],...Ld(n[r])}}),e),{})}function mF({props:t,stylesCtx:e,themeName:n,theme:r}){var s;const o=(s=GH())==null?void 0:s();return{getTransformedStyles:l=>o?[...l.map(a=>o(a,{props:t,theme:r,ctx:e})),...n.map(a=>{var c;return o((c=r.components[a])==null?void 0:c.styles,{props:t,theme:r,ctx:e})})].filter(Boolean):[],withStylesTransform:!!o}}function be({name:t,classes:e,props:n,stylesCtx:r,className:o,style:i,rootSelector:s="root",unstyled:l,classNames:a,styles:c,vars:d,varsResolver:u,attributes:f}){var A;const h=Kt(),p=zH(),m=UH(),g=WH(),y=(Array.isArray(t)?t:[t]).filter(R=>R),{withStylesTransform:w,getTransformedStyles:k}=mF({props:n,stylesCtx:r,themeName:y,theme:h}),x=Cl({theme:h,classNames:a,props:n,stylesCtx:r}),C=y.map(R=>{var P;return Cl({theme:h,classNames:(P=h.components[R])==null?void 0:P.classNames,props:n,stylesCtx:r})}),E=w?{}:zc({theme:h,styles:c,props:n,stylesCtx:r}),S={};if(!w)for(const R of y){const P=zc({theme:h,styles:(A=h.components[R])==null?void 0:A.styles,props:n,stylesCtx:r});for(const D of Object.keys(P))S[D]={...S[D],...P[D]}}const M=pF([g?{}:u==null?void 0:u(h,n,r),...y.map(R=>{var P,D,T;return(T=(D=(P=h.components)==null?void 0:P[R])==null?void 0:D.vars)==null?void 0:T.call(D,h,n,r)}),d==null?void 0:d(h,n,r)]),N=zm({style:i,theme:h});return(R,P)=>({...f==null?void 0:f[R],className:fF({theme:h,options:P,themeName:y,selector:R,classNamesPrefix:p,resolvedClassNames:x,resolvedThemeClassNames:C,classes:e,unstyled:l,className:o,rootSelector:s,props:n,stylesCtx:r,withStaticClasses:m,headless:g,transformedStyles:k([P==null?void 0:P.styles,c])}),style:hF({theme:h,selector:R,options:P,props:n,stylesCtx:r,rootSelector:s,withStylesTransform:w,resolvedStyles:E,resolvedThemeStyles:S,resolvedVars:M,resolvedRootStyle:N})})}function zs(t){return sr(t).reduce((e,n)=>t[n]!==void 0?`${e}${nH(n)}:${t[n]};`:e,"").trim()}function gF({selector:t,styles:e,media:n,container:r}){const o=e?zs(e):"",i=Array.isArray(n)?n.map(l=>`@media${l.query}{${t}{${zs(l.styles)}}}`):[],s=Array.isArray(r)?r.map(l=>`@container ${l.query}{${t}{${zs(l.styles)}}}`):[];return`${o?`${t}{${o}}`:""}${i.join("")}${s.join("")}`.trim()}function bF(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)&4294967295;return(e>>>0).toString(36)}function A2({deduplicate:t,...e}){const n=Vm(),r=gF(e);return t?b.jsx("style",{href:`mantine-${bF(r)}`,precedence:"mantine",nonce:n==null?void 0:n(),children:r}):b.jsx("style",{"data-mantine-styles":"inline",nonce:n==null?void 0:n(),dangerouslySetInnerHTML:{__html:r}})}function yF(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)&4294967295;return(e>>>0).toString(36)}function N2(t,e){return`__mdi__-${yF(`${t?zs(t):""}|${Array.isArray(e)?e.map(n=>`${n.query}:${zs(n.styles)}`).join("|"):""}`)}`}function zd(t){const{m:e,mx:n,my:r,mt:o,mb:i,ml:s,mr:l,me:a,ms:c,mis:d,mie:u,p:f,px:h,py:p,pt:m,pb:g,pl:y,pr:w,pe:k,ps:x,pis:C,pie:E,bd:S,bdrs:M,bg:N,c:A,opacity:R,ff:P,fz:D,fw:T,lts:_,ta:F,lh:L,fs:O,tt:V,td:U,w:re,miw:Z,maw:z,h:ie,mih:se,mah:we,bgsz:ye,bgp:me,bgr:fe,bga:Pe,pos:$e,top:H,left:Q,bottom:J,right:ke,inset:Ee,display:le,flex:ot,hiddenFrom:it,visibleFrom:ze,lightHidden:Xt,darkHidden:hn,sx:Ft,...Te}=t;return{styleProps:Ld({m:e,mx:n,my:r,mt:o,mb:i,ml:s,mr:l,me:a,ms:c,mis:d,mie:u,p:f,px:h,py:p,pt:m,pb:g,pl:y,pr:w,pis:C,pie:E,pe:k,ps:x,bd:S,bg:N,c:A,opacity:R,ff:P,fz:D,fw:T,lts:_,ta:F,lh:L,fs:O,tt:V,td:U,w:re,miw:Z,maw:z,h:ie,mih:se,mah:we,bgsz:ye,bgp:me,bgr:fe,bga:Pe,pos:$e,top:H,left:Q,bottom:J,right:ke,inset:Ee,display:le,flex:ot,bdrs:M,hiddenFrom:it,visibleFrom:ze,lightHidden:Xt,darkHidden:hn,sx:Ft}),rest:Te}}const vF={m:{type:"spacing",property:"margin"},mt:{type:"spacing",property:"marginTop"},mb:{type:"spacing",property:"marginBottom"},ml:{type:"spacing",property:"marginLeft"},mr:{type:"spacing",property:"marginRight"},ms:{type:"spacing",property:"marginInlineStart"},me:{type:"spacing",property:"marginInlineEnd"},mis:{type:"spacing",property:"marginInlineStart"},mie:{type:"spacing",property:"marginInlineEnd"},mx:{type:"spacing",property:"marginInline"},my:{type:"spacing",property:"marginBlock"},p:{type:"spacing",property:"padding"},pt:{type:"spacing",property:"paddingTop"},pb:{type:"spacing",property:"paddingBottom"},pl:{type:"spacing",property:"paddingLeft"},pr:{type:"spacing",property:"paddingRight"},ps:{type:"spacing",property:"paddingInlineStart"},pe:{type:"spacing",property:"paddingInlineEnd"},pis:{type:"spacing",property:"paddingInlineStart"},pie:{type:"spacing",property:"paddingInlineEnd"},px:{type:"spacing",property:"paddingInline"},py:{type:"spacing",property:"paddingBlock"},bd:{type:"border",property:"border"},bdrs:{type:"radius",property:"borderRadius"},bg:{type:"color",property:"background"},c:{type:"textColor",property:"color"},opacity:{type:"identity",property:"opacity"},ff:{type:"fontFamily",property:"fontFamily"},fz:{type:"fontSize",property:"fontSize"},fw:{type:"identity",property:"fontWeight"},lts:{type:"size",property:"letterSpacing"},ta:{type:"identity",property:"textAlign"},lh:{type:"lineHeight",property:"lineHeight"},fs:{type:"identity",property:"fontStyle"},tt:{type:"identity",property:"textTransform"},td:{type:"identity",property:"textDecoration"},w:{type:"spacing",property:"width"},miw:{type:"spacing",property:"minWidth"},maw:{type:"spacing",property:"maxWidth"},h:{type:"spacing",property:"height"},mih:{type:"spacing",property:"minHeight"},mah:{type:"spacing",property:"maxHeight"},bgsz:{type:"size",property:"backgroundSize"},bgp:{type:"identity",property:"backgroundPosition"},bgr:{type:"identity",property:"backgroundRepeat"},bga:{type:"identity",property:"backgroundAttachment"},pos:{type:"identity",property:"position"},top:{type:"size",property:"top"},left:{type:"size",property:"left"},bottom:{type:"size",property:"bottom"},right:{type:"size",property:"right"},inset:{type:"size",property:"inset"},display:{type:"identity",property:"display"},flex:{type:"identity",property:"flex"}};function Um(t,e){const n=ko({color:t,theme:e});return n.color==="dimmed"?"var(--mantine-color-dimmed)":n.color==="bright"?"var(--mantine-color-bright)":n.variable?`var(${n.variable})`:n.color}function wF(t,e){const n=ko({color:t,theme:e});return n.isThemeColor&&n.shade===void 0?`var(--mantine-color-${n.color}-text)`:Um(t,e)}function kF(t,e){if(typeof t=="number")return $(t);if(typeof t=="string"){const[n,r,...o]=t.split(" ").filter(s=>s.trim()!=="");let i=`${$(n)}`;return r&&(i+=` ${r}`),o.length>0&&(i+=` ${Um(o.join(" "),e)}`),i.trim()}return t}const p1={text:"var(--mantine-font-family)",mono:"var(--mantine-font-family-monospace)",monospace:"var(--mantine-font-family-monospace)",heading:"var(--mantine-font-family-headings)",headings:"var(--mantine-font-family-headings)"};function xF(t){return typeof t=="string"&&t in p1?p1[t]:t}const CF=["h1","h2","h3","h4","h5","h6"];function SF(t,e){return typeof t=="string"&&t in e.fontSizes?`var(--mantine-font-size-${t})`:typeof t=="string"&&CF.includes(t)?`var(--mantine-${t}-font-size)`:typeof t=="number"||typeof t=="string"?$(t):t}function EF(t){return t}const MF=["h1","h2","h3","h4","h5","h6"];function TF(t,e){return typeof t=="string"&&t in e.lineHeights?`var(--mantine-line-height-${t})`:typeof t=="string"&&MF.includes(t)?`var(--mantine-${t}-line-height)`:t}function AF(t,e){return typeof t=="string"&&t in e.radius?`var(--mantine-radius-${t})`:typeof t=="number"||typeof t=="string"?$(t):t}function NF(t){return typeof t=="number"?$(t):t}function RF(t,e){if(typeof t=="number")return $(t);if(typeof t=="string"){const n=t.replace("-","");if(!(n in e.spacing))return $(t);const r=`--mantine-spacing-${n}`;return t.startsWith("-")?`calc(var(${r}) * -1)`:`var(${r})`}return t}const mf={color:Um,textColor:wF,fontSize:SF,spacing:RF,radius:AF,identity:EF,size:NF,lineHeight:TF,fontFamily:xF,border:kF};function m1(t){return t.replace("(min-width: ","").replace("em)","")}function IF({media:t,...e}){const n=Object.keys(t).sort((r,o)=>Number(m1(r))-Number(m1(o))).map(r=>({query:r,styles:t[r]}));return{...e,media:n}}function OF(t){if(typeof t!="object"||t===null)return!1;const e=Object.keys(t);return!(e.length===1&&e[0]==="base")}function DF(t){return typeof t=="object"&&t!==null?"base"in t?t.base:void 0:t}function _F(t){return typeof t=="object"&&t!==null?sr(t).filter(e=>e!=="base"):[]}function PF(t,e){return typeof t=="object"&&t!==null&&e in t?t[e]:t}function R2({styleProps:t,data:e,theme:n}){return IF(sr(t).reduce((r,o)=>{if(o==="hiddenFrom"||o==="visibleFrom"||o==="sx")return r;const i=e[o],s=Array.isArray(i.property)?i.property:[i.property],l=DF(t[o]);if(!OF(t[o]))return s.forEach(c=>{r.inlineStyles[c]=mf[i.type](l,n)}),r;r.hasResponsiveStyles=!0;const a=_F(t[o]);return s.forEach(c=>{l!=null&&(r.styles[c]=mf[i.type](l,n)),a.forEach(d=>{const u=`(min-width: ${n.breakpoints[d]})`;r.media[u]={...r.media[u],[c]:mf[i.type](PF(t[o],d),n)}})}),r},{hasResponsiveStyles:!1,styles:{},inlineStyles:{},media:{}}))}function I2(){return`__m__-${v.useId().replace(/[:«»]/g,"")}`}function O2(t,e){return Array.isArray(t)?[...t].reduce((n,r)=>({...n,...O2(r,e)}),{}):typeof t=="function"?t(e):t??{}}function $F(t){return t}const LF=$F;function D2(t){return t}function ue(t){const e=t;return e.extend=D2,e.withProps=n=>{const r=o=>b.jsx(e,{...n,...o});return r.extend=e.extend,r.displayName=`WithProps(${e.displayName})`,r},e}function Wm(t){return ue(t)}function Pt(t){const e=t;return e.withProps=n=>{const r=o=>b.jsx(e,{...n,...o});return r.extend=e.extend,r.displayName=`WithProps(${e.displayName})`,r},e.extend=D2,e}function _2(t){return`data-${(t.startsWith("data-")?t.slice(5):t).replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`}function BF(t){return Object.keys(t).reduce((e,n)=>{const r=t[n];return r===void 0||r===""||r===!1||r===null||(e[_2(n)]=t[n]),e},{})}function P2(t){return t?typeof t=="string"?{[_2(t)]:!0}:Array.isArray(t)?[...t].reduce((e,n)=>({...e,...P2(n)}),{}):BF(t):null}function Lh(t,e){return Array.isArray(t)?[...t].reduce((n,r)=>({...n,...Lh(r,e)}),{}):typeof t=="function"?t(e):t??{}}function jF({theme:t,style:e,vars:n,styleProps:r}){const o=Lh(e,t),i=Lh(n,t);return{...o,...i,...r}}function $2({component:t,style:e,__vars:n,className:r,variant:o,mod:i,size:s,hiddenFrom:l,visibleFrom:a,lightHidden:c,darkHidden:d,renderRoot:u,__size:f,ref:h,...p}){var N,A;const m=Kt(),g=t||"div",{styleProps:y,rest:w}=zd(p),k=(A=(N=qH())==null?void 0:N())==null?void 0:A(y.sx),x=I2(),C=R2({styleProps:y,theme:m,data:vF}),E=x2(),S=E&&C.hasResponsiveStyles?N2(C.styles,C.media):x,M={ref:h,style:jF({theme:m,style:e,vars:n,styleProps:C.inlineStyles}),className:$r(r,k,{[S]:C.hasResponsiveStyles,"mantine-light-hidden":c,"mantine-dark-hidden":d,[`mantine-hidden-from-${l}`]:l,[`mantine-visible-from-${a}`]:a}),"data-variant":o,"data-size":m2(s)?void 0:s||void 0,size:f,...P2(i),...w};return b.jsxs(b.Fragment,{children:[C.hasResponsiveStyles&&b.jsx(A2,{selector:`.${S}`,styles:C.styles,media:C.media,deduplicate:E}),typeof u=="function"?u(M):b.jsx(g,{...M})]})}$2.displayName="@mantine/core/Box";const te=LF($2),VF=v.createContext({dir:"ltr",toggleDirection:()=>{},setDirection:()=>{}});function Vr(){return v.use(VF)}var L2={root:"m_87cf2631"};const HF={__staticSelector:"UnstyledButton"},Hr=Pt(t=>{const e=q("UnstyledButton",HF,t),{className:n,component:r="button",__staticSelector:o,unstyled:i,classNames:s,styles:l,style:a,attributes:c,...d}=e;return b.jsx(te,{...be({name:o,props:e,classes:L2,className:n,style:a,classNames:s,styles:l,unstyled:i,attributes:c})("root",{focusable:!0}),component:r,type:r==="button"?"button":void 0,...d})});Hr.classes=L2;Hr.displayName="@mantine/core/UnstyledButton";var B2={root:"m_515a97f8"};const qm=ue(t=>{const e=q("VisuallyHidden",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,attributes:a,...c}=e;return b.jsx(te,{component:"span",...be({name:"VisuallyHidden",classes:B2,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:a})("root"),...c})});qm.classes=B2;qm.displayName="@mantine/core/VisuallyHidden";var j2={root:"m_1b7284a3"};const V2=(t,{radius:e,shadow:n})=>({root:{"--paper-radius":e===void 0?void 0:_t(e),"--paper-shadow":b2(n)}}),Ud=Pt(t=>{const e=q("Paper",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,withBorder:l,vars:a,radius:c,shadow:d,variant:u,mod:f,attributes:h,...p}=e,m=be({name:"Paper",props:e,classes:j2,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:h,vars:a,varsResolver:V2});return b.jsx(te,{mod:[{"data-with-border":l},f],...m("root"),variant:u,...p})});Ud.classes=j2;Ud.varsResolver=V2;Ud.displayName="@mantine/core/Paper";function g1(t,e,n,r){return t==="center"||r==="center"?{top:e}:t==="end"?{bottom:n}:t==="start"?{top:n}:{}}function b1(t,e,n,r,o){return t==="center"||r==="center"?{left:e}:t==="end"?{[o==="ltr"?"right":"left"]:n}:t==="start"?{[o==="ltr"?"left":"right"]:n}:{}}const FF={bottom:"borderTopLeftRadius",left:"borderTopRightRadius",right:"borderBottomLeftRadius",top:"borderBottomRightRadius"};function zF({position:t,arrowSize:e,dir:n}){const[r,o]=t.split("-");if(!o)return;const i={width:e,height:e,position:"absolute"};if(r==="bottom"){const s=o==="start",l=s?n==="ltr"?"left":"right":n==="ltr"?"right":"left";return{...i,top:-e,[l]:0,clipPath:s!==(n==="rtl")?"polygon(0% 0%, 0% 100%, 100% 100%)":"polygon(100% 0%, 0% 100%, 100% 100%)"}}if(r==="top"){const s=o==="start",l=s?n==="ltr"?"left":"right":n==="ltr"?"right":"left";return{...i,bottom:-e,[l]:0,clipPath:s!==(n==="rtl")?"polygon(0% 0%, 100% 0%, 0% 100%)":"polygon(0% 0%, 100% 0%, 100% 100%)"}}if(r==="left")return{...i,right:-e,[o==="start"?"top":"bottom"]:0,clipPath:o==="start"?"polygon(0% 0%, 100% 0%, 0% 100%)":"polygon(0% 0%, 0% 100%, 100% 100%)"};if(r==="right")return{...i,left:-e,[o==="start"?"top":"bottom"]:0,clipPath:o==="start"?"polygon(0% 0%, 100% 0%, 100% 100%)":"polygon(100% 0%, 0% 100%, 100% 100%)"}}function UF({position:t,arrowSize:e,arrowOffset:n,arrowRadius:r,arrowPosition:o,arrowX:i,arrowY:s,dir:l}){if(o==="merge"){const f=zF({position:t,arrowSize:e,dir:l});if(f)return f}const[a,c="center"]=t.split("-"),d={width:e,height:e,transform:"rotate(45deg)",position:"absolute",[FF[a]]:r},u=-e/2;return a==="left"?{...d,...g1(c,s,n,o),right:u,borderLeftColor:"transparent",borderBottomColor:"transparent",clipPath:"polygon(100% 0, 0 0, 100% 100%)"}:a==="right"?{...d,...g1(c,s,n,o),left:u,borderRightColor:"transparent",borderTopColor:"transparent",clipPath:"polygon(0 100%, 0 0, 100% 100%)"}:a==="top"?{...d,...b1(c,i,n,o,l),bottom:u,borderTopColor:"transparent",borderLeftColor:"transparent",clipPath:"polygon(0 100%, 100% 100%, 100% 0)"}:a==="bottom"?{...d,...b1(c,i,n,o,l),top:u,borderBottomColor:"transparent",borderRightColor:"transparent",clipPath:"polygon(0 100%, 0 0, 100% 0)"}:{}}function H2({position:t,dir:e}){const[n,r]=t.split("-");if(!r)return;const o=r==="start"&&e==="ltr"||r==="end"&&e==="rtl";if(n==="bottom")return o?{borderTopLeftRadius:0}:{borderTopRightRadius:0};if(n==="top")return o?{borderBottomLeftRadius:0}:{borderBottomRightRadius:0};if(n==="left")return r==="start"?{borderTopRightRadius:0}:{borderBottomRightRadius:0};if(n==="right")return r==="start"?{borderTopLeftRadius:0}:{borderBottomLeftRadius:0}}function Uc({position:t,arrowSize:e,arrowOffset:n,arrowRadius:r,arrowPosition:o,visible:i,arrowX:s,arrowY:l,style:a,...c}){const{dir:d}=Vr();return i?b.jsx("div",{role:"presentation",...c,style:{...a,...UF({position:t,arrowSize:e,arrowOffset:n,arrowRadius:r,arrowPosition:o,dir:d,arrowX:s,arrowY:l})}}):null}Uc.displayName="@mantine/core/FloatingArrow";function Gm(t,e){if(t==="rtl"&&(e.includes("right")||e.includes("left"))){const[n,r]=e.split("-"),o=n==="right"?"left":"right";return r===void 0?o:`${o}-${r}`}return e}function WF({open:t,close:e,openDelay:n,closeDelay:r}){const o=v.useRef(-1),i=v.useRef(-1),s=()=>{window.clearTimeout(o.current),window.clearTimeout(i.current)},l=()=>{s(),n===0||n===void 0?t():o.current=window.setTimeout(t,n)},a=()=>{s(),r===0||r===void 0?e():i.current=window.setTimeout(e,r)};return v.useEffect(()=>s,[]),{openDropdown:l,closeDropdown:a}}var F2={root:"m_9814e45f"};const qF={zIndex:Ul("modal")},z2=(t,{gradient:e,color:n,backgroundOpacity:r,blur:o,radius:i,zIndex:s})=>({root:{"--overlay-bg":e||(n!==void 0||r!==void 0)&&Wr(n||"#000",r??.6)||void 0,"--overlay-filter":o?`blur(${$(o)})`:void 0,"--overlay-radius":i===void 0?void 0:_t(i),"--overlay-z-index":s==null?void 0:s.toString()}}),Qi=Pt(t=>{const e=q("Overlay",qF,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,fixed:a,center:c,children:d,radius:u,zIndex:f,gradient:h,blur:p,color:m,backgroundOpacity:g,mod:y,attributes:w,...k}=e;return b.jsx(te,{...be({name:"Overlay",props:e,classes:F2,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:w,vars:l,varsResolver:z2})("root"),mod:[{center:c,fixed:a},y],...k,children:d})});Qi.classes=F2;Qi.varsResolver=z2;Qi.displayName="@mantine/core/Overlay";function gf(t){const e=document.createElement("div");return e.setAttribute("data-portal","true"),typeof t.className=="string"&&e.classList.add(...t.className.split(" ").filter(Boolean)),typeof t.style=="object"&&Object.assign(e.style,t.style),typeof t.id=="string"&&e.setAttribute("id",t.id),e}function GF({target:t,reuseTargetNode:e,...n}){if(t)return typeof t=="string"?document.querySelector(t)||gf(n):t;if(e){const r=document.querySelector("[data-mantine-shared-portal-node]");if(r)return r;const o=gf(n);return o.setAttribute("data-mantine-shared-portal-node","true"),document.body.appendChild(o),o}return gf(n)}const ZF={reuseTargetNode:!0},U2=ue(t=>{const{children:e,target:n,reuseTargetNode:r,ref:o,...i}=q("Portal",ZF,t),[s,l]=v.useState(!1),a=v.useRef(null);return ni(()=>(l(!0),a.current=GF({target:n,reuseTargetNode:r,...i}),Fc(o,a.current),!n&&!r&&a.current&&document.body.appendChild(a.current),()=>{!n&&!r&&a.current&&document.body.removeChild(a.current)}),[n]),!s||!a.current?null:Dr.createPortal(b.jsx(b.Fragment,{children:e}),a.current)});U2.displayName="@mantine/core/Portal";const es=ue(({withinPortal:t=!0,children:e,...n})=>Hd()==="test"||!t?b.jsx(b.Fragment,{children:e}):b.jsx(U2,{...n,children:e}));es.displayName="@mantine/core/OptionalPortal";const Es=t=>({in:{opacity:1,transform:"scale(1)"},out:{opacity:0,transform:`scale(.9) translateY(${t==="bottom"?10:-10}px)`},transitionProperty:"transform, opacity"}),Ra={fade:{in:{opacity:1},out:{opacity:0},transitionProperty:"opacity"},"fade-up":{in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(30px)"},transitionProperty:"opacity, transform"},"fade-down":{in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(-30px)"},transitionProperty:"opacity, transform"},"fade-left":{in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(30px)"},transitionProperty:"opacity, transform"},"fade-right":{in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(-30px)"},transitionProperty:"opacity, transform"},scale:{in:{opacity:1,transform:"scale(1)"},out:{opacity:0,transform:"scale(0)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"scale-y":{in:{opacity:1,transform:"scaleY(1)"},out:{opacity:0,transform:"scaleY(0)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"scale-x":{in:{opacity:1,transform:"scaleX(1)"},out:{opacity:0,transform:"scaleX(0)"},common:{transformOrigin:"left"},transitionProperty:"transform, opacity"},"skew-up":{in:{opacity:1,transform:"translateY(0) skew(0deg, 0deg)"},out:{opacity:0,transform:"translateY(-20px) skew(-10deg, -5deg)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"skew-down":{in:{opacity:1,transform:"translateY(0) skew(0deg, 0deg)"},out:{opacity:0,transform:"translateY(20px) skew(-10deg, -5deg)"},common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity"},"rotate-left":{in:{opacity:1,transform:"translateY(0) rotate(0deg)"},out:{opacity:0,transform:"translateY(20px) rotate(-5deg)"},common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity"},"rotate-right":{in:{opacity:1,transform:"translateY(0) rotate(0deg)"},out:{opacity:0,transform:"translateY(20px) rotate(5deg)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"slide-down":{in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(-100%)"},common:{transformOrigin:"top"},transitionProperty:"transform, opacity"},"slide-up":{in:{opacity:1,transform:"translateY(0)"},out:{opacity:0,transform:"translateY(100%)"},common:{transformOrigin:"bottom"},transitionProperty:"transform, opacity"},"slide-left":{in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(100%)"},common:{transformOrigin:"left"},transitionProperty:"transform, opacity"},"slide-right":{in:{opacity:1,transform:"translateX(0)"},out:{opacity:0,transform:"translateX(-100%)"},common:{transformOrigin:"right"},transitionProperty:"transform, opacity"},pop:{...Es("bottom"),common:{transformOrigin:"center center"}},"pop-bottom-left":{...Es("bottom"),common:{transformOrigin:"bottom left"}},"pop-bottom-right":{...Es("bottom"),common:{transformOrigin:"bottom right"}},"pop-top-left":{...Es("top"),common:{transformOrigin:"top left"}},"pop-top-right":{...Es("top"),common:{transformOrigin:"top right"}}},y1={entering:"in",entered:"in",exiting:"out",exited:"out","pre-exiting":"out","pre-entering":"out"};function v1({transition:t,state:e,duration:n,timingFunction:r}){const o={WebkitBackfaceVisibility:"hidden",transitionDuration:`${n}ms`,transitionTimingFunction:r};return typeof t=="string"?t in Ra?{transitionProperty:Ra[t].transitionProperty,...o,...Ra[t].common,...Ra[t][y1[e]]}:{}:{transitionProperty:t.transitionProperty,...o,...t.common,...t[y1[e]]}}function KF({duration:t,exitDuration:e,timingFunction:n,mounted:r,onEnter:o,onExit:i,onEntered:s,onExited:l,enterDelay:a,exitDelay:c}){const d=Kt(),u=SH(),f=d.respectReducedMotion?u:!1,[h,p]=v.useState(f?0:t),[m,g]=v.useState(r?"entered":"exited"),y=v.useRef(-1),w=v.useRef(-1),k=v.useRef(-1);function x(){window.clearTimeout(y.current),window.clearTimeout(w.current),cancelAnimationFrame(k.current)}const C=S=>{x();const M=S?o:i,N=S?s:l,A=f?0:S?t:e;p(A),A===0?(typeof M=="function"&&M(),typeof N=="function"&&N(),g(S?"entered":"exited")):k.current=requestAnimationFrame(()=>{A1.flushSync(()=>{g(S?"pre-entering":"pre-exiting")}),k.current=requestAnimationFrame(()=>{typeof M=="function"&&M(),g(S?"entering":"exiting"),y.current=window.setTimeout(()=>{typeof N=="function"&&N(),g(S?"entered":"exited")},A)})})},E=S=>{if(x(),typeof(S?a:c)!="number"){C(S);return}w.current=window.setTimeout(()=>{C(S)},S?a:c)};return _m(()=>{E(r)},[r]),v.useEffect(()=>()=>{x()},[]),{transitionDuration:h,transitionStatus:m,transitionTimingFunction:n||"ease"}}function po({keepMounted:t,keepMountedMode:e="activity",transition:n="fade",duration:r=250,exitDuration:o=r,mounted:i,children:s,timingFunction:l="ease",onExit:a,onEntered:c,onEnter:d,onExited:u,enterDelay:f,exitDelay:h}){const p=Hd(),{transitionDuration:m,transitionStatus:g,transitionTimingFunction:y}=KF({mounted:i,exitDuration:o,duration:r,timingFunction:l,onExit:a,onEntered:c,onEnter:d,onExited:u,enterDelay:f,exitDelay:h});if(p==="test")return i?b.jsx(b.Fragment,{children:s({})}):t?s({display:"none"}):null;if(m===0)return t?e==="display-none"?i?b.jsx(b.Fragment,{children:s({})}):s({display:"none"}):b.jsx(v.Activity,{mode:i?"visible":"hidden",children:s({})}):i?b.jsx(b.Fragment,{children:s({})}):null;const w=g==="exited";if(t){const k=s(w?e==="display-none"?{display:"none"}:{}:v1({transition:n,duration:m,state:g,timingFunction:y}));return e==="display-none"?k:b.jsx(v.Activity,{mode:w?"hidden":"visible",children:k})}return w?null:b.jsx(b.Fragment,{children:s(v1({transition:n,duration:m,state:g,timingFunction:y}))})}po.displayName="@mantine/core/Transition";const JF={duration:100,transition:"fade"};function w1(t,e){return{...JF,...e,...t}}const[YF,Wd]=Bd("Popover component was not found in the tree");function W2({childProps:t,disabled:e,opened:n,longPressDelay:r=500,setReference:o,open:i}){const s=v.useRef(!1),l=v.useRef(!1),a=v.useRef(null),c=v.useRef(e);c.current=e;const d=(p,m,g)=>{o({getBoundingClientRect:()=>({x:p,y:m,width:0,height:0,top:m,left:p,right:p,bottom:m,toJSON:()=>{}}),contextElement:g}),i()},u=We(t.onMouseDown,p=>{e||p.button===2&&p.stopPropagation()}),f=We(t.onContextMenu,p=>{e||p.defaultPrevented||(p.preventDefault(),!l.current&&(d(p.clientX,p.clientY,p.currentTarget),s.current&&(l.current=!0)))}),h=RH(p=>{if(c.current||l.current)return;const m=p,g=m.touches[0]??m.changedTouches[0];g&&(d(g.clientX,g.clientY,a.current),l.current=!0)},{threshold:r,events:["touch"],cancelOnMove:!0,onStart:p=>{s.current=!0,l.current=!1,a.current=p.currentTarget},onFinish:p=>{s.current=!1,l.current=!1,c.current||p.preventDefault()},onCancel:()=>{s.current=!1,l.current=!1}});return{onContextMenu:f,onMouseDown:u,onTouchStart:We(t.onTouchStart,h.onTouchStart),onTouchEnd:We(t.onTouchEnd,h.onTouchEnd),onTouchCancel:We(t.onTouchCancel,h.onTouchCancel),onTouchMove:We(t.onTouchMove,h.onTouchMove),style:e?t.style:{...t.style,WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"},"data-expanded":n?!0:void 0}}function q2(t){const{children:e,disabled:n,longPressDelay:r}=q("PopoverContextMenu",null,t),o=di(e);if(!o)throw new Error("Popover.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const i=Wd();return v.cloneElement(o,W2({childProps:o.props,disabled:n||i.disabled,opened:i.opened,longPressDelay:r,setReference:i.reference,open:()=>{i.opened||i.onToggle()}}))}q2.displayName="@mantine/core/PopoverContextMenu";function Zm({children:t,active:e=!0,refProp:n="ref",innerRef:r}){const o=fn(k2(e),r),i=di(t);return i?v.cloneElement(i,{[n]:o}):t}function G2(t){return b.jsx(qm,{tabIndex:-1,"data-autofocus":!0,...t})}Zm.displayName="@mantine/core/FocusTrap";G2.displayName="@mantine/core/FocusTrapInitialFocus";Zm.InitialFocus=G2;var Z2={dropdown:"m_38a85659",arrow:"m_a31dc6c1",overlay:"m_3d7bc908"};const qd=ue(t=>{var w,k,x,C;const e=q("PopoverDropdown",null,t),{className:n,style:r,vars:o,children:i,onKeyDownCapture:s,variant:l,classNames:a,styles:c,ref:d,...u}=e,f=Wd(),{dir:h}=Vr(),p=f.arrowPosition==="merge"&&f.withArrow?H2({position:f.placement,dir:h}):void 0,m=gH({opened:f.opened,shouldReturnFocus:f.returnFocus}),g=f.withRoles?{"aria-labelledby":f.getTargetId(),id:f.getDropdownId(),role:"dialog",tabIndex:-1}:{},y=fn(d,f.floating);return f.disabled?null:b.jsx(es,{...f.portalProps,withinPortal:f.withinPortal,children:b.jsx(po,{mounted:f.opened,...f.transitionProps,transition:((w=f.transitionProps)==null?void 0:w.transition)||"fade",duration:((k=f.transitionProps)==null?void 0:k.duration)??150,keepMounted:f.keepMounted,keepMountedMode:f.keepMountedMode,exitDuration:typeof((x=f.transitionProps)==null?void 0:x.exitDuration)=="number"?f.transitionProps.exitDuration:(C=f.transitionProps)==null?void 0:C.duration,children:E=>{var S;return b.jsx(Zm,{active:f.trapFocus&&f.opened,innerRef:y,children:b.jsxs(te,{...g,...u,variant:l,onKeyDownCapture:aH(()=>{var M,N;(M=f.onClose)==null||M.call(f),(N=f.onDismiss)==null||N.call(f)},{active:f.closeOnEscape,onTrigger:m,onKeyDown:s}),"data-position":f.placement,"data-fixed":f.floatingStrategy==="fixed"||void 0,...f.getStyles("dropdown",{className:n,props:e,classNames:a,styles:c,style:[{...E,...p,zIndex:f.zIndex,top:f.y??0,left:f.x??0,width:f.width==="target"?void 0:$(f.width),...f.referenceHidden?{display:"none"}:null},(S=f.resolvedStyles)==null?void 0:S.dropdown,c==null?void 0:c.dropdown,r]}),children:[i,b.jsx(Uc,{ref:f.arrowRef,arrowX:f.arrowX,arrowY:f.arrowY,visible:f.withArrow,position:f.placement,arrowSize:f.arrowSize,arrowRadius:f.arrowRadius,arrowOffset:f.arrowOffset,arrowPosition:f.arrowPosition,...f.getStyles("arrow",{props:e,classNames:a,styles:c})})]})})}})})});qd.classes=Z2;qd.displayName="@mantine/core/PopoverDropdown";const XF={refProp:"ref",popupType:"dialog"},Km=ue(t=>{const{children:e,refProp:n,popupType:r,ref:o,...i}=q("PopoverTarget",XF,t),s=di(e);if(!s)throw new Error("Popover.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const l=i,a=Wd(),c=fn(a.reference,Pm(s),o),d=a.withRoles?{"aria-haspopup":r,"aria-expanded":a.opened,"aria-controls":a.opened?a.getDropdownId():void 0,id:a.getTargetId()}:{},u=s.props;return v.cloneElement(s,{...l,...d,...a.targetProps,className:$r(a.targetProps.className,l.className,u.className),[n]:c,...a.controlled?null:{onClick:f=>{var h;a.onToggle(),(h=u.onClick)==null||h.call(u,f)}}})});Km.displayName="@mantine/core/PopoverTarget";function QF(t){if(t===void 0)return{shift:!0,flip:!0};const e={...t};return t.shift===void 0&&(e.shift=!0),t.flip===void 0&&(e.flip=!0),e}function ez(t,e,n,r){const o=QF(t.middlewares),i=[Hn(t.offset),sA()];if(o.flip&&!n){const s=typeof o.flip=="boolean"?{}:o.flip,l=r?{fallbackStrategy:"initialPlacement",...s}:s;i.push(jo(l))}if(o.shift){const s=typeof o.shift=="boolean"?{}:o.shift;i.push(ri(l=>{const a=l.placement.startsWith("top")||l.placement.startsWith("bottom");return{limiter:iA(),padding:5,...t.width==="target"&&a?{mainAxis:!1}:null,...s}}))}return o.inline&&i.push(typeof o.inline=="boolean"?_s():_s(o.inline)),i.push(iv({element:t.arrowRef,padding:t.arrowOffset})),(o.size||t.width==="target")&&i.push(Ws({...typeof o.size=="boolean"?{}:o.size,apply({rects:s,availableWidth:l,availableHeight:a,...c}){var u;const d=((u=e().refs.floating.current)==null?void 0:u.style)??{};o.size&&(typeof o.size=="object"&&o.size.apply?o.size.apply({rects:s,availableWidth:l,availableHeight:a,...c}):Object.assign(d,{maxWidth:`${l}px`,maxHeight:`${a}px`})),t.width==="target"&&Object.assign(d,{width:`${s.reference.width}px`})}})),i}function tz(t){const[e,n]=pr({value:t.opened,defaultValue:t.defaultOpened,finalValue:!1,onChange:t.onChange}),r=v.useRef(e),[o,i]=v.useState(null),s=t.preventPositionChangeWhenVisible!==!1,l=v.useRef(e);e!==l.current&&(l.current=e,e&&o!==null&&i(null));const a=v.useCallback(()=>i(null),[]),c=()=>{e&&!t.disabled&&n(!1)},d=()=>{t.disabled||n(!e)},u=Al({open:e,strategy:t.strategy,placement:s?o??t.position:t.position,middleware:ez(t,()=>u,s&&o!==null,s),whileElementsMounted:t.keepMounted?void 0:ji});v.useEffect(()=>{if(!t.keepMounted)return;const p=u.refs.reference.current,m=u.refs.floating.current;if(e&&p&&m)return ji(p,m,u.update)},[t.keepMounted,e,u.update,u.elements.reference,u.elements.floating]);const f=v.useRef(!1);ni(()=>{if(!e){f.current=!1;return}if(!s||o!==null)return;const p=u.refs.floating.current;if(!(!p||p.offsetHeight===0||p.offsetWidth===0)){if(!f.current){f.current=!0,u.update();return}u.isPositioned&&i(u.placement)}},[s,e,u.isPositioned,u.placement,o,u.update]);const h=v.useRef(u.placement);return ni(()=>{var p;h.current!==u.placement&&(h.current=u.placement,(p=t.onPositionChange)==null||p.call(t,u.placement))},[u.placement]),_m(()=>{var p,m;e!==r.current&&(e?(m=t.onOpen)==null||m.call(t):(p=t.onClose)==null||p.call(t)),r.current=e},[e,t.onClose,t.onOpen]),{floating:u,controlled:typeof t.opened=="boolean",opened:e,onClose:c,onToggle:d,resetLockedPlacement:a}}const nz={position:"bottom",offset:8,transitionProps:{transition:"fade",duration:150},middlewares:{flip:!0,shift:!0,inline:!1},arrowSize:7,arrowOffset:5,arrowRadius:0,arrowPosition:"side",closeOnClickOutside:!0,withinPortal:!0,closeOnEscape:!0,trapFocus:!1,withRoles:!0,returnFocus:!1,withOverlay:!1,hideDetached:!0,preventPositionChangeWhenVisible:!0,clickOutsideEvents:["mousedown","touchstart"],zIndex:Ul("popover"),__staticSelector:"Popover",width:"max-content"},K2=(t,{radius:e,shadow:n})=>({dropdown:{"--popover-radius":e===void 0?void 0:_t(e),"--popover-shadow":b2(n)}});function wt(t){var pg,mg,gg,bg,yg,vg,wg;const e=q("Popover",nz,t),{children:n,position:r,offset:o,onPositionChange:i,opened:s,transitionProps:l,onExitTransitionEnd:a,onEnterTransitionEnd:c,width:d,middlewares:u,withArrow:f,arrowSize:h,arrowOffset:p,arrowRadius:m,arrowPosition:g,unstyled:y,classNames:w,styles:k,closeOnClickOutside:x,withinPortal:C,portalProps:E,closeOnEscape:S,clickOutsideEvents:M,trapFocus:N,onClose:A,onDismiss:R,onOpen:P,onChange:D,zIndex:T,radius:_,shadow:F,id:L,defaultOpened:O,__staticSelector:V,withRoles:U,disabled:re,returnFocus:Z,variant:z,keepMounted:ie,keepMountedMode:se,vars:we,floatingStrategy:ye,withOverlay:me,overlayProps:fe,hideDetached:Pe,attributes:$e,preventPositionChangeWhenVisible:H,...Q}=e,J=be({name:V,props:e,classes:Z2,classNames:w,styles:k,unstyled:y,attributes:$e,rootSelector:"dropdown",vars:we,varsResolver:K2}),{resolvedStyles:ke}=Fd({classNames:w,styles:k,props:e}),Ee=v.useRef(null),[le,ot]=v.useState(null),[it,ze]=v.useState(null),{dir:Xt}=Vr(),hn=Hd(),Ft=us(L),Te=tz({middlewares:u,width:d,position:Gm(Xt,r),offset:typeof o=="number"?o+(f?h/2:0):o,arrowRef:Ee,arrowOffset:p,onPositionChange:i,opened:s,defaultOpened:O,onChange:D,onOpen:P,onClose:A,onDismiss:R,strategy:ye,disabled:re,preventPositionChangeWhenVisible:H,keepMounted:ie});hH(()=>{x&&(Te.onClose(),R==null||R())},M,[le,it]);const ea=v.useCallback(Qt=>{ot(Qt),Te.floating.refs.setReference(Qt)},[Te.floating.refs.setReference]),aM=v.useCallback(Qt=>{ze(Qt),Te.floating.refs.setFloating(Qt)},[Te.floating.refs.setFloating]),cM=v.useCallback(()=>{var Qt;(Qt=l==null?void 0:l.onExited)==null||Qt.call(l),a==null||a(),Te.resetLockedPlacement()},[l==null?void 0:l.onExited,a,Te.resetLockedPlacement]),dM=v.useCallback(()=>{var Qt;(Qt=l==null?void 0:l.onEntered)==null||Qt.call(l),c==null||c()},[l==null?void 0:l.onEntered,c]);return b.jsxs(YF,{value:{returnFocus:Z,disabled:re,controlled:Te.controlled,reference:ea,floating:aM,x:Te.floating.x,y:Te.floating.y,arrowX:(gg=(mg=(pg=Te.floating)==null?void 0:pg.middlewareData)==null?void 0:mg.arrow)==null?void 0:gg.x,arrowY:(vg=(yg=(bg=Te.floating)==null?void 0:bg.middlewareData)==null?void 0:yg.arrow)==null?void 0:vg.y,opened:Te.opened,arrowRef:Ee,transitionProps:{...l,onExited:cM,onEntered:dM},width:d,withArrow:f,arrowSize:h,arrowOffset:p,arrowRadius:m,arrowPosition:g,placement:Te.floating.placement,trapFocus:N,withinPortal:C,portalProps:E,zIndex:T,radius:_,shadow:F,closeOnEscape:S,onDismiss:R,onClose:Te.onClose,onToggle:Te.onToggle,getTargetId:()=>Ft,getDropdownId:()=>`${Ft}-dropdown`,withRoles:U,targetProps:Q,__staticSelector:V,classNames:w,styles:k,unstyled:y,variant:z,keepMounted:ie,keepMountedMode:se,getStyles:J,resolvedStyles:ke,floatingStrategy:ye,referenceHidden:Pe&&hn!=="test"?(wg=Te.floating.middlewareData.hide)==null?void 0:wg.referenceHidden:!1},children:[n,me&&b.jsx(po,{transition:"fade",mounted:Te.opened,duration:(l==null?void 0:l.duration)||250,exitDuration:(l==null?void 0:l.exitDuration)||250,children:Qt=>b.jsx(es,{withinPortal:C,children:b.jsx(Qi,{...fe,...J("overlay",{className:fe==null?void 0:fe.className,style:[Qt,fe==null?void 0:fe.style]})})})})]})}wt.Target=Km;wt.Dropdown=qd;wt.ContextMenu=q2;wt.varsResolver=K2;wt.displayName="@mantine/core/Popover";wt.extend=t=>t;wt.withProps=t=>{const e=n=>b.jsx(wt,{...t,...n});return e.extend=wt.extend,e.displayName=`WithProps(${wt.displayName})`,e};var jn={root:"m_5ae2e3c",barsLoader:"m_7a2bd4cd",bar:"m_870bb79","bars-loader-animation":"m_5d2b3b9d",dotsLoader:"m_4e3f22d7",dot:"m_870c4af","loader-dots-animation":"m_aac34a1",ovalLoader:"m_b34414df","oval-loader-animation":"m_f8e89c4b"};const J2=({className:t,...e})=>b.jsxs(te,{component:"span",className:$r(jn.barsLoader,t),...e,children:[b.jsx("span",{className:jn.bar}),b.jsx("span",{className:jn.bar}),b.jsx("span",{className:jn.bar})]});J2.displayName="@mantine/core/Bars";const Y2=({className:t,...e})=>b.jsxs(te,{component:"span",className:$r(jn.dotsLoader,t),...e,children:[b.jsx("span",{className:jn.dot}),b.jsx("span",{className:jn.dot}),b.jsx("span",{className:jn.dot})]});Y2.displayName="@mantine/core/Dots";const X2=({className:t,...e})=>b.jsx(te,{component:"span",className:$r(jn.ovalLoader,t),...e});X2.displayName="@mantine/core/Oval";const Q2={bars:J2,oval:X2,dots:Y2},rz={loaders:Q2,type:"oval"},eE=(t,{size:e,color:n})=>({root:{"--loader-size":Ve(e,"loader-size"),"--loader-color":n?ho(n,t):void 0}}),mr=ue(t=>{const e=q("Loader",rz,t),{size:n,color:r,type:o,vars:i,className:s,style:l,classNames:a,styles:c,unstyled:d,loaders:u,variant:f,children:h,attributes:p,...m}=e,g=be({name:"Loader",props:e,classes:jn,className:s,style:l,classNames:a,styles:c,unstyled:d,attributes:p,vars:i,varsResolver:eE});return h?b.jsx(te,{...g("root"),...m,children:h}):b.jsx(te,{...g("root"),component:u[o],variant:f,size:n,...m})});mr.defaultLoaders=Q2;mr.classes=jn;mr.varsResolver=eE;mr.displayName="@mantine/core/Loader";var fs={root:"m_8d3f4000",icon:"m_8d3afb97",loader:"m_302b9fb1",group:"m_1a0f1b21",groupSection:"m_437b6484"};const oz={orientation:"horizontal"},tE=(t,{borderWidth:e})=>({group:{"--ai-border-width":$(e)}}),Gd=ue(t=>{const e=q("ActionIconGroup",oz,t),{className:n,style:r,classNames:o,styles:i,unstyled:s,orientation:l,vars:a,borderWidth:c,variant:d,mod:u,attributes:f,...h}=e;return b.jsx(te,{...be({name:"ActionIconGroup",props:e,classes:fs,className:n,style:r,classNames:o,styles:i,unstyled:s,attributes:f,vars:a,varsResolver:tE,rootSelector:"group"})("group"),variant:d,mod:[{"data-orientation":l},u],role:"group",...h})});Gd.classes=fs;Gd.varsResolver=tE;Gd.displayName="@mantine/core/ActionIconGroup";const nE=(t,{radius:e,color:n,gradient:r,variant:o,autoContrast:i,size:s})=>{const l=t.variantColorResolver({color:n||t.primaryColor,theme:t,gradient:r,variant:o||"filled",autoContrast:i});return{groupSection:{"--section-height":Ve(s,"section-height"),"--section-padding-x":Ve(s,"section-padding-x"),"--section-fz":Tt(s),"--section-radius":e===void 0?void 0:_t(e),"--section-bg":n||o?l.background:void 0,"--section-color":l.color,"--section-bd":n||o?l.border:void 0}}},Zd=ue(t=>{const e=q("ActionIconGroupSection",null,t),{className:n,style:r,classNames:o,styles:i,unstyled:s,vars:l,variant:a,gradient:c,radius:d,autoContrast:u,attributes:f,...h}=e;return b.jsx(te,{...be({name:"ActionIconGroupSection",props:e,classes:fs,className:n,style:r,classNames:o,styles:i,unstyled:s,attributes:f,vars:l,varsResolver:nE,rootSelector:"groupSection"})("groupSection"),variant:a,...h})});Zd.classes=fs;Zd.varsResolver=nE;Zd.displayName="@mantine/core/ActionIconGroupSection";const rE=(t,{size:e,radius:n,variant:r,gradient:o,color:i,autoContrast:s})=>{const l=t.variantColorResolver({color:i||t.primaryColor,theme:t,gradient:o,variant:r||"filled",autoContrast:s});return{root:{"--ai-size":Ve(e,"ai-size"),"--ai-radius":n===void 0?void 0:_t(n),"--ai-bg":i||r?l.background:void 0,"--ai-hover":i||r?l.hover:void 0,"--ai-hover-color":i||r?l.hoverColor:void 0,"--ai-color":l.color,"--ai-bd":i||r?l.border:void 0}}},xo=Pt(t=>{const e=q("ActionIcon",null,t),{className:n,unstyled:r,variant:o,classNames:i,styles:s,style:l,loading:a,loaderProps:c,size:d,color:u,radius:f,__staticSelector:h,gradient:p,vars:m,children:g,disabled:y,"data-disabled":w,autoContrast:k,mod:x,attributes:C,...E}=e,S=be({name:["ActionIcon",h],props:e,className:n,style:l,classes:fs,classNames:i,styles:s,unstyled:r,attributes:C,vars:m,varsResolver:rE});return b.jsxs(Hr,{...S("root",{active:!y&&!a&&!w}),"aria-busy":a||void 0,...E,unstyled:r,variant:o,size:d,disabled:y||a,mod:[{loading:a,disabled:y||w},x],children:[typeof a=="boolean"&&b.jsx(po,{mounted:a,transition:"slide-down",duration:150,children:M=>b.jsx(te,{component:"span",...S("loader",{style:M}),"aria-hidden":!0,children:b.jsx(mr,{color:"var(--ai-color)",size:"calc(var(--ai-size) * 0.55)",...c})})}),b.jsx(te,{component:"span",mod:{loading:a},...S("icon"),children:g})]})});xo.classes=fs;xo.varsResolver=rE;xo.displayName="@mantine/core/ActionIcon";xo.Group=Gd;xo.GroupSection=Zd;function oE({size:t="var(--cb-icon-size, 70%)",style:e,...n}){return b.jsx("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{...e,width:t,height:t},...n,children:b.jsx("path",{d:"M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}oE.displayName="@mantine/core/CloseIcon";var iE={root:"m_86a44da5","root--subtle":"m_220c80f2"};const iz={variant:"subtle"},sE=(t,{size:e,radius:n,iconSize:r})=>({root:{"--cb-size":Ve(e,"cb-size"),"--cb-radius":n===void 0?void 0:_t(n),"--cb-icon-size":$(r)}}),ql=Pt(t=>{const e=q("CloseButton",iz,t),{iconSize:n,children:r,vars:o,radius:i,className:s,classNames:l,style:a,styles:c,unstyled:d,"data-disabled":u,disabled:f,variant:h,icon:p,mod:m,attributes:g,__staticSelector:y,...w}=e,k=be({name:y||"CloseButton",props:e,className:s,style:a,classes:iE,classNames:l,styles:c,unstyled:d,attributes:g,vars:o,varsResolver:sE});return b.jsxs(Hr,{...w,unstyled:d,variant:h,disabled:f,mod:[{disabled:f||u},m],...k("root",{variant:h,active:!f&&!u}),children:[p||b.jsx(oE,{}),r]})});ql.classes=iE;ql.varsResolver=sE;ql.displayName="@mantine/core/CloseButton";function sz(t){return v.Children.toArray(t).filter(Boolean)}var lE={root:"m_4081bf90"};const lz={preventGrowOverflow:!0,gap:"md",align:"center",justify:"flex-start",wrap:"wrap"},aE=(t,{grow:e,preventGrowOverflow:n,gap:r,align:o,justify:i,wrap:s},{childWidth:l})=>({root:{"--group-child-width":e&&n?l:void 0,"--group-gap":Wl(r),"--group-align":o,"--group-justify":i,"--group-wrap":s}}),ut=ue(t=>{const e=q("Group",lz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,children:l,gap:a,align:c,justify:d,wrap:u,grow:f,preventGrowOverflow:h,vars:p,variant:m,__size:g,mod:y,attributes:w,...k}=e,x=sz(l),C=x.length,E=Wl(a??"md");return b.jsx(te,{...be({name:"Group",props:e,stylesCtx:{childWidth:`calc(${100/C}% - (${E} - ${E} / ${C}))`},className:r,style:o,classes:lE,classNames:n,styles:i,unstyled:s,attributes:w,vars:p,varsResolver:aE})("root"),variant:m,mod:[{grow:f},y],size:g,...k,children:x})});ut.classes=lE;ut.varsResolver=aE;ut.displayName="@mantine/core/Group";const cE=v.createContext({size:"sm"}),dE=ue(t=>{const e=q("InputClearButton",null,t),{size:n,variant:r,vars:o,classNames:i,styles:s,...l}=e,a=v.use(cE),{resolvedClassNames:c,resolvedStyles:d}=Fd({classNames:i,styles:s,props:e});return b.jsx(ql,{variant:r||"transparent",size:n||(a==null?void 0:a.size)||"sm",classNames:c,styles:d,__staticSelector:"InputClearButton",style:{pointerEvents:"all",background:"var(--input-bg)",...l.style},...l})});dE.displayName="@mantine/core/InputClearButton";const az={xs:7,sm:8,md:10,lg:12,xl:15};function cz({__clearable:t,__clearSection:e,rightSection:n,__defaultRightSection:r,size:o="sm",__clearSectionMode:i="both"}){const s=t&&e;return i==="rightSection"?n===null?null:n||r:i==="clear"?n===null?null:s||r:s&&(n||r)?b.jsxs("div",{"data-combined-clear-section":!0,style:{display:"flex",gap:2,alignItems:"center",paddingInlineEnd:az[o]},children:[s,n||r]}):n===null?null:n||s||r}const hs=v.createContext({offsetBottom:!1,offsetTop:!1,describedBy:void 0,getStyles:null,inputId:void 0,labelId:void 0});var Jt={wrapper:"m_6c018570",input:"m_8fb7ebe7",bottomSection:"m_93f4ed57",section:"m_82577fc2",placeholder:"m_88bacfd0",root:"m_46b77525",label:"m_8fdc1311",required:"m_78a94662",error:"m_8f816625",success:"m_9d9d40e0",description:"m_fe47ce59"};const uE=(t,{size:e})=>({description:{"--input-description-size":e===void 0?void 0:`calc(${Tt(e)} - ${$(2)})`}}),Gl=ue(t=>{const e=q("InputDescription",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,__staticSelector:a,__inheritStyles:c=!0,attributes:d,...u}=q("InputDescription",null,e),f=v.use(hs),h=be({name:["InputWrapper",a],props:e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:d,rootSelector:"description",vars:l,varsResolver:uE});return b.jsx(te,{component:"p",...(c&&(f==null?void 0:f.getStyles)||h)("description",f!=null&&f.getStyles?{className:r,style:o}:void 0),...u})});Gl.classes=Jt;Gl.varsResolver=uE;Gl.displayName="@mantine/core/InputDescription";const fE=(t,{size:e})=>({error:{"--input-error-size":e===void 0?void 0:`calc(${Tt(e)} - ${$(2)})`}}),Zl=ue(t=>{const e=q("InputError",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,attributes:a,__staticSelector:c,__inheritStyles:d=!0,...u}=e,f=be({name:["InputWrapper",c],props:e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:a,rootSelector:"error",vars:l,varsResolver:fE}),h=v.use(hs);return b.jsx(te,{component:"p",...(d&&(h==null?void 0:h.getStyles)||f)("error",h!=null&&h.getStyles?{className:r,style:o}:void 0),...u})});Zl.classes=Jt;Zl.varsResolver=fE;Zl.displayName="@mantine/core/InputError";const dz={labelElement:"label"},hE=(t,{size:e})=>({label:{"--input-label-size":Tt(e),"--input-asterisk-color":void 0}}),Kl=ue(t=>{const e=q("InputLabel",dz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,labelElement:a,required:c,htmlFor:d,onMouseDown:u,children:f,__staticSelector:h,mod:p,attributes:m,...g}=e,y=be({name:["InputWrapper",h],props:e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:m,rootSelector:"label",vars:l,varsResolver:hE}),w=v.use(hs),k=(w==null?void 0:w.getStyles)||y;return b.jsxs(te,{...k("label",w!=null&&w.getStyles?{className:r,style:o}:void 0),component:a,htmlFor:a==="label"?d:void 0,mod:[{required:c},p],onMouseDown:x=>{u==null||u(x),!x.defaultPrevented&&x.detail>1&&x.preventDefault()},...g,children:[f,c&&b.jsx("span",{...k("required"),"aria-hidden":!0,children:" *"})]})});Kl.classes=Jt;Kl.varsResolver=hE;Kl.displayName="@mantine/core/InputLabel";const Jm=ue(t=>{const e=q("InputPlaceholder",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,__staticSelector:a,error:c,mod:d,attributes:u,...f}=e;return b.jsx(te,{...be({name:["InputPlaceholder",a],props:e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:u,rootSelector:"placeholder"})("placeholder"),mod:[{error:!!c},d],component:"span",...f})});Jm.classes=Jt;Jm.displayName="@mantine/core/InputPlaceholder";const pE=(t,{size:e})=>({success:{"--input-success-size":e===void 0?void 0:`calc(${Tt(e)} - ${$(2)})`}}),Jl=ue(t=>{const e=q("InputSuccess",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,attributes:a,__staticSelector:c,__inheritStyles:d=!0,...u}=e,f=be({name:["InputWrapper",c],props:e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:a,rootSelector:"success",vars:l,varsResolver:pE}),h=v.use(hs);return b.jsx(te,{component:"p",...(d&&(h==null?void 0:h.getStyles)||f)("success",h!=null&&h.getStyles?{className:r,style:o}:void 0),...u})});Jl.classes=Jt;Jl.varsResolver=pE;Jl.displayName="@mantine/core/InputSuccess";function uz(t,{hasDescription:e,hasError:n}){const r=t.findIndex(l=>l==="input"),o=t.slice(0,r),i=t.slice(r+1),s=e&&o.includes("description")||n&&o.includes("error");return{offsetBottom:e&&i.includes("description")||n&&i.includes("error"),offsetTop:s}}const fz={labelElement:"label",inputContainer:t=>t,inputWrapperOrder:["label","description","input","error"]},mE=(t,{size:e})=>({label:{"--input-label-size":Tt(e),"--input-asterisk-color":void 0},error:{"--input-error-size":e===void 0?void 0:`calc(${Tt(e)} - ${$(2)})`},success:{"--input-success-size":e===void 0?void 0:`calc(${Tt(e)} - ${$(2)})`},description:{"--input-description-size":e===void 0?void 0:`calc(${Tt(e)} - ${$(2)})`}}),Kd=ue(t=>{const e=q("InputWrapper",fz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,size:a,variant:c,__staticSelector:d,inputContainer:u,inputWrapperOrder:f,label:h,error:p,success:m,description:g,labelProps:y,descriptionProps:w,errorProps:k,successProps:x,labelElement:C,children:E,withAsterisk:S,id:M,required:N,__stylesApiProps:A,mod:R,attributes:P,...D}=e,T=be({name:["InputWrapper",d],props:A||e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:P,vars:l,varsResolver:mE}),_={size:a,variant:c,__staticSelector:d},F=us(M),L=typeof S=="boolean"?S:N,O=(k==null?void 0:k.id)||`${F}-error`,V=(x==null?void 0:x.id)||`${F}-success`,U=(w==null?void 0:w.id)||`${F}-description`,re=F,Z=!!p&&typeof p!="boolean",z=!!m&&typeof m!="boolean"&&!p,ie=!!g,se=Z&&f.includes("error"),we=z&&f.includes("error"),ye=ie&&f.includes("description"),me=`${se?O:""} ${we?V:""} ${ye?U:""}`,fe=me.trim().length>0?me.trim():void 0,Pe=(y==null?void 0:y.id)||`${F}-label`,$e=h&&b.jsx(Kl,{labelElement:C,id:Pe,htmlFor:re,required:L,..._,...y,children:h},"label"),H=ie&&b.jsx(Gl,{...w,..._,size:(w==null?void 0:w.size)||_.size,id:(w==null?void 0:w.id)||U,children:g},"description"),Q=b.jsx(v.Fragment,{children:u(E)},"input"),J=Z&&v.createElement(Zl,{...k,..._,size:(k==null?void 0:k.size)||_.size,key:"error",id:(k==null?void 0:k.id)||O},p),ke=z&&v.createElement(Jl,{...x,..._,size:(x==null?void 0:x.size)||_.size,key:"success",id:(x==null?void 0:x.id)||V},m),Ee=f.map(le=>{switch(le){case"label":return $e;case"input":return Q;case"description":return H;case"error":return J||ke;default:return null}});return b.jsx(hs,{value:{getStyles:T,describedBy:fe,inputId:re,labelId:Pe,...uz(f,{hasDescription:ie,hasError:Z||z})},children:b.jsx(te,{variant:c,size:a,mod:[{error:!!p,success:!!m&&!p},R],id:C==="label"?void 0:M,...T("root"),...D,children:Ee})})});Kd.classes=Jt;Kd.varsResolver=mE;Kd.displayName="@mantine/core/InputWrapper";const hz={variant:"default",leftSectionPointerEvents:"none",rightSectionPointerEvents:"none",withAria:!0,withErrorStyles:!0,withSuccessStyles:!0,size:"sm",loading:!1,loadingPosition:"right"},gE=(t,e,n)=>({wrapper:{"--input-margin-top":n.offsetTop?"calc(var(--mantine-spacing-xs) / 2)":void 0,"--input-margin-bottom":n.offsetBottom?"calc(var(--mantine-spacing-xs) / 2)":void 0,"--input-height":Ve(e.size,"input-height"),"--input-fz":Tt(e.size),"--input-radius":e.radius===void 0?void 0:_t(e.radius),"--input-left-section-width":e.leftSectionWidth!==void 0?$(e.leftSectionWidth):void 0,"--input-right-section-width":e.rightSectionWidth!==void 0?$(e.rightSectionWidth):void 0,"--input-padding-y":e.multiline?Ve(e.size,"input-padding-y"):void 0,"--input-left-section-pointer-events":e.leftSectionPointerEvents,"--input-right-section-pointer-events":e.rightSectionPointerEvents}}),It=Pt(t=>{const e=q("Input",hz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,required:l,__staticSelector:a,__stylesApiProps:c,size:d,wrapperProps:u,error:f,success:h,disabled:p,leftSection:m,leftSectionProps:g,leftSectionWidth:y,rightSection:w,rightSectionProps:k,rightSectionWidth:x,rightSectionPointerEvents:C,leftSectionPointerEvents:E,variant:S,vars:M,pointer:N,multiline:A,radius:R,id:P,withAria:D,withErrorStyles:T,withSuccessStyles:_,mod:F,inputSize:L,attributes:O,__clearSection:V,__clearable:U,__clearSectionMode:re,__defaultRightSection:Z,loading:z,loadingPosition:ie,__bottomSection:se,__bottomSectionProps:we,rootRef:ye,dir:me,...fe}=e,{styleProps:Pe,rest:$e}=zd(fe),H=v.use(hs),Q={offsetBottom:H==null?void 0:H.offsetBottom,offsetTop:H==null?void 0:H.offsetTop},J=be({name:["Input",a],props:c||e,classes:Jt,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:O,stylesCtx:Q,rootSelector:"wrapper",vars:M,varsResolver:gE}),ke=D?{required:l,disabled:p,"aria-invalid":f?!0:void 0,"aria-describedby":H==null?void 0:H.describedBy,id:(H==null?void 0:H.inputId)||P}:{},Ee=z?b.jsx(mr,{size:ie==="left"?"calc(var(--input-left-section-size) / 2)":"calc(var(--input-right-section-size) / 2)"}):null,le=z&&ie==="left"?Ee:m,ot=cz({__clearable:U,__clearSection:V,rightSection:z&&ie==="right"?Ee:w,__defaultRightSection:Z,size:d,__clearSectionMode:re});return b.jsx(cE,{value:{size:d||"sm"},children:b.jsxs(te,{ref:ye,dir:me,...J("wrapper"),...Pe,...u,mod:[{error:!!f&&T,success:!!h&&!f&&_,pointer:N,disabled:p,multiline:A,"data-with-right-section":!!ot,"data-with-left-section":!!le,"data-with-bottom-section":!!se},F],variant:S,size:d,children:[le&&b.jsx("div",{...g,"data-position":"left",...J("section",{className:g==null?void 0:g.className,style:g==null?void 0:g.style}),children:le}),b.jsx(te,{component:"input",...$e,...ke,required:l,mod:{disabled:p,error:!!f&&T,success:!!h&&!f&&_},variant:S,__size:L,...J("input")}),se&&b.jsx("div",{...we,...J("bottomSection",{className:we==null?void 0:we.className,style:we==null?void 0:we.style}),children:se}),ot&&b.jsx("div",{...k,"data-position":"right",...J("section",{className:k==null?void 0:k.className,style:k==null?void 0:k.style}),children:ot})]})})});It.classes=Jt;It.varsResolver=gE;It.Wrapper=Kd;It.Label=Kl;It.Error=Zl;It.Success=Jl;It.Description=Gl;It.Placeholder=Jm;It.ClearButton=dE;It.displayName="@mantine/core/Input";function pz(t,e,n){const r=q(["Input","InputWrapper",t],e,n),{label:o,description:i,error:s,success:l,required:a,classNames:c,styles:d,className:u,unstyled:f,__staticSelector:h,__stylesApiProps:p,errorProps:m,successProps:g,labelProps:y,descriptionProps:w,wrapperProps:k,id:x,size:C,style:E,inputContainer:S,inputWrapperOrder:M,withAsterisk:N,variant:A,vars:R,mod:P,attributes:D,...T}=r,{styleProps:_,rest:F}=zd(T),L={label:o,description:i,error:s,success:l,required:a,classNames:c,className:u,__staticSelector:h,__stylesApiProps:p||r,errorProps:m,successProps:g,labelProps:y,descriptionProps:w,unstyled:f,styles:d,size:C,style:E,inputContainer:S,inputWrapperOrder:M,withAsterisk:N,variant:A,id:x,mod:P,attributes:D,...k};return{...F,classNames:c,styles:d,unstyled:f,wrapperProps:{...L,..._},inputProps:{required:a,classNames:c,styles:d,unstyled:f,size:C,__staticSelector:h,__stylesApiProps:p||r,error:s,success:l,variant:A,id:x,attributes:D}}}const mz={__staticSelector:"InputBase",withAria:!0,size:"sm"},ps=Pt(t=>{const{inputProps:e,wrapperProps:n,...r}=pz("InputBase",mz,t);return b.jsx(It.Wrapper,{...n,children:b.jsx(It,{...e,...r})})});ps.classes={...It.classes,...It.Wrapper.classes};ps.displayName="@mantine/core/InputBase";const gz={gap:{type:"spacing",property:"gap"},rowGap:{type:"spacing",property:"rowGap"},columnGap:{type:"spacing",property:"columnGap"},align:{type:"identity",property:"alignItems"},justify:{type:"identity",property:"justifyContent"},wrap:{type:"identity",property:"flexWrap"},direction:{type:"identity",property:"flexDirection"}};var bE={root:"m_8bffd616"};const Ym=Pt(t=>{const e=q("Flex",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,gap:a,rowGap:c,columnGap:d,align:u,justify:f,wrap:h,direction:p,attributes:m,...g}=e,y=be({name:"Flex",classes:bE,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:m,vars:l}),w=Kt(),k=I2(),x=R2({styleProps:{gap:a,rowGap:c,columnGap:d,align:u,justify:f,wrap:h,direction:p},theme:w,data:gz}),C=x2(),E=C&&x.hasResponsiveStyles?N2(x.styles,x.media):k;return b.jsxs(b.Fragment,{children:[x.hasResponsiveStyles&&b.jsx(A2,{selector:`.${E}`,styles:x.styles,media:x.media,deduplicate:C}),b.jsx(te,{...y("root",{className:E,style:Ld(x.inlineStyles)}),...g})]})});Ym.classes=bE;Ym.displayName="@mantine/core/Flex";function yE({style:t,size:e=16,...n}){return b.jsx("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{...t,width:$(e),height:$(e),display:"block"},...n,children:b.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}yE.displayName="@mantine/core/AccordionChevron";var vE={root:"m_b6d8b162"};function bz(t){if(t==="start")return"start";if(t==="end"||t)return"end"}const yz={inherit:!1},wE=(t,{variant:e,lineClamp:n,gradient:r,size:o,textWrap:i})=>({root:{"--text-fz":Tt(o),"--text-lh":cH(o),"--text-gradient":e==="gradient"?Ph(r,t):void 0,"--text-line-clamp":typeof n=="number"?n.toString():void 0,"--text-text-wrap":i}}),Zn=Pt(t=>{const e=q("Text",yz,t),{lineClamp:n,truncate:r,inline:o,inherit:i,gradient:s,span:l,textWrap:a,__staticSelector:c,vars:d,className:u,style:f,classNames:h,styles:p,unstyled:m,variant:g,mod:y,size:w,attributes:k,...x}=e;return b.jsx(te,{...be({name:["Text",c],props:e,classes:vE,className:u,style:f,classNames:h,styles:p,unstyled:m,attributes:k,vars:d,varsResolver:wE})("root",{focusable:!0}),component:l?"span":"p",variant:g,mod:[{"data-truncate":bz(r),"data-line-clamp":typeof n=="number","data-inline":o,"data-inherit":i},y],size:w,...x})});Zn.classes=vE;Zn.varsResolver=wE;Zn.displayName="@mantine/core/Text";function Jd({size:t,style:e,...n}){return b.jsx("svg",{viewBox:"0 0 10 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:t!==void 0?{width:$(t),height:$(t),...e}:e,"aria-hidden":!0,...n,children:b.jsx("path",{d:"M4 4.586L1.707 2.293A1 1 0 1 0 .293 3.707l3 3a.997.997 0 0 0 1.414 0l5-5A1 1 0 1 0 8.293.293L4 4.586z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}var Yd={group:"m_11def92b",root:"m_f85678b6",image:"m_11f8ac07",placeholder:"m_104cd71f"};const kE=v.createContext({withinGroup:!1}),xE=(t,{spacing:e})=>({group:{"--ag-spacing":Wl(e)}}),Xd=ue(t=>{const e=q("AvatarGroup",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,spacing:a,attributes:c,...d}=e;return b.jsx(kE,{value:{withinGroup:!0},children:b.jsx(te,{...be({name:"AvatarGroup",classes:Yd,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:c,vars:l,varsResolver:xE,rootSelector:"group"})("group"),...d})})});Xd.classes=Yd;Xd.varsResolver=xE;Xd.displayName="@mantine/core/AvatarGroup";function vz(t){return b.jsx("svg",{...t,"data-avatar-placeholder-icon":!0,viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{d:"M0.877014 7.49988C0.877014 3.84219 3.84216 0.877045 7.49985 0.877045C11.1575 0.877045 14.1227 3.84219 14.1227 7.49988C14.1227 11.1575 11.1575 14.1227 7.49985 14.1227C3.84216 14.1227 0.877014 11.1575 0.877014 7.49988ZM7.49985 1.82704C4.36683 1.82704 1.82701 4.36686 1.82701 7.49988C1.82701 8.97196 2.38774 10.3131 3.30727 11.3213C4.19074 9.94119 5.73818 9.02499 7.50023 9.02499C9.26206 9.02499 10.8093 9.94097 11.6929 11.3208C12.6121 10.3127 13.1727 8.97172 13.1727 7.49988C13.1727 4.36686 10.6328 1.82704 7.49985 1.82704ZM10.9818 11.9787C10.2839 10.7795 8.9857 9.97499 7.50023 9.97499C6.01458 9.97499 4.71624 10.7797 4.01845 11.9791C4.97952 12.7272 6.18765 13.1727 7.49985 13.1727C8.81227 13.1727 10.0206 12.727 10.9818 11.9787ZM5.14999 6.50487C5.14999 5.207 6.20212 4.15487 7.49999 4.15487C8.79786 4.15487 9.84999 5.207 9.84999 6.50487C9.84999 7.80274 8.79786 8.85487 7.49999 8.85487C6.20212 8.85487 5.14999 7.80274 5.14999 6.50487ZM7.49999 5.10487C6.72679 5.10487 6.09999 5.73167 6.09999 6.50487C6.09999 7.27807 6.72679 7.90487 7.49999 7.90487C8.27319 7.90487 8.89999 7.27807 8.89999 6.50487C8.89999 5.73167 8.27319 5.10487 7.49999 5.10487Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}function wz(t){let e=0;for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);e=(e<<5)-e+r,e|=0}return e}const kz=["blue","cyan","grape","green","indigo","lime","orange","pink","red","teal","violet"];function xz(t,e=kz){const n=wz(t);return e[Math.abs(n)%e.length]}function Cz(t,e=2){const n=t.split(" ");return n.length===1?t.slice(0,e).toUpperCase():n.map(r=>r[0]).slice(0,e).join("").toUpperCase()}const CE=(t,{size:e,radius:n,variant:r,gradient:o,color:i,autoContrast:s,name:l,allowedInitialsColors:a})=>{const c=i==="initials"&&typeof l=="string"?xz(l,a):i,d=t.variantColorResolver({color:c||"gray",theme:t,gradient:o,variant:r||"light",autoContrast:s});return{root:{"--avatar-size":Ve(e,"avatar-size"),"--avatar-radius":n===void 0?void 0:_t(n),"--avatar-bg":c||r?d.background:void 0,"--avatar-color":c||r?d.color:void 0,"--avatar-bd":c||r?d.border:void 0}}},Yl=Pt(t=>{const e=q("Avatar",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,src:a,alt:c,radius:d,color:u,gradient:f,imageProps:h,children:p,autoContrast:m,mod:g,name:y,allowedInitialsColors:w,attributes:k,...x}=e,C=v.use(kE),[E,S]=v.useState(!a),M=be({name:"Avatar",props:e,classes:Yd,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:k,vars:l,varsResolver:CE});return v.useEffect(()=>S(!a),[a]),b.jsx(te,{...M("root"),mod:[{"within-group":C.withinGroup},g],...x,children:E||!a?b.jsx("span",{...M("placeholder"),title:c,children:p||typeof y=="string"&&Cz(y)||b.jsx(vz,{})}):b.jsx("img",{...h,...M("image"),src:a,alt:c,onError:N=>{var A;S(!0),(A=h==null?void 0:h.onError)==null||A.call(h,N)}})})});Yl.classes=Yd;Yl.varsResolver=CE;Yl.displayName="@mantine/core/Avatar";Yl.Group=Xd;var SE={root:"m_347db0ec","root--dot":"m_fbd81e3d",label:"m_5add502a",section:"m_91fdda9b"};const EE=(t,{radius:e,color:n,gradient:r,variant:o,size:i,autoContrast:s,circle:l})=>{const a=t.variantColorResolver({color:n||t.primaryColor,theme:t,gradient:r,variant:o||"filled",autoContrast:s});return{root:{"--badge-height":Ve(i,"badge-height"),"--badge-padding-x":Ve(i,"badge-padding-x"),"--badge-fz":Ve(i,"badge-fz"),"--badge-radius":l||e===void 0?void 0:_t(e),"--badge-bg":n||o?a.background:void 0,"--badge-color":n||o?a.color:void 0,"--badge-bd":n||o?a.border:void 0,"--badge-dot-color":o==="dot"?ho(n,t):void 0}}},Qd=Pt(t=>{const e=q("Badge",null,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,radius:a,color:c,gradient:d,leftSection:u,rightSection:f,children:h,variant:p,fullWidth:m,autoContrast:g,circle:y,mod:w,attributes:k,...x}=e,C=be({name:"Badge",props:e,classes:SE,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:k,vars:l,varsResolver:EE});return b.jsxs(te,{variant:p,mod:[{block:m,circle:y,"with-right-section":!!f,"with-left-section":!!u},w],...C("root",{variant:p}),...x,children:[u&&b.jsx("span",{...C("section"),"data-position":"left",children:u}),b.jsx("span",{...C("label"),children:h}),f&&b.jsx("span",{...C("section"),"data-position":"right",children:f})]})});Qd.classes=SE;Qd.varsResolver=EE;Qd.displayName="@mantine/core/Badge";var ms={root:"m_77c9d27d",inner:"m_80f1301b",label:"m_811560b9",section:"m_a74036a",loader:"m_a25b86ee",group:"m_80d6d844",groupSection:"m_70be2a01"};const k1={orientation:"horizontal"},ME=(t,{borderWidth:e})=>({group:{"--button-border-width":$(e)}}),eu=ue(t=>{const e=q("ButtonGroup",k1,t),{className:n,style:r,classNames:o,styles:i,unstyled:s,orientation:l,vars:a,borderWidth:c,mod:d,attributes:u,...f}=q("ButtonGroup",k1,t);return b.jsx(te,{...be({name:"ButtonGroup",props:e,classes:ms,className:n,style:r,classNames:o,styles:i,unstyled:s,attributes:u,vars:a,varsResolver:ME,rootSelector:"group"})("group"),mod:[{"data-orientation":l},d],role:"group",...f})});eu.classes=ms;eu.varsResolver=ME;eu.displayName="@mantine/core/ButtonGroup";const TE=(t,{radius:e,color:n,gradient:r,variant:o,autoContrast:i,size:s})=>{const l=t.variantColorResolver({color:n||t.primaryColor,theme:t,gradient:r,variant:o||"filled",autoContrast:i});return{groupSection:{"--section-height":Ve(s,"section-height"),"--section-padding-x":Ve(s,"section-padding-x"),"--section-fz":s!=null&&s.includes("compact")?Tt(s.replace("compact-","")):Tt(s),"--section-radius":e===void 0?void 0:_t(e),"--section-bg":n||o?l.background:void 0,"--section-color":l.color,"--section-bd":n||o?l.border:void 0}}},tu=ue(t=>{const e=q("ButtonGroupSection",null,t),{className:n,style:r,classNames:o,styles:i,unstyled:s,vars:l,gradient:a,radius:c,autoContrast:d,attributes:u,...f}=e;return b.jsx(te,{...be({name:"ButtonGroupSection",props:e,classes:ms,className:n,style:r,classNames:o,styles:i,unstyled:s,attributes:u,vars:l,varsResolver:TE,rootSelector:"groupSection"})("groupSection"),...f})});tu.classes=ms;tu.varsResolver=TE;tu.displayName="@mantine/core/ButtonGroupSection";const Sz={in:{opacity:1,transform:`translate(-50%, calc(-50% + ${$(1)}))`},out:{opacity:0,transform:"translate(-50%, -200%)"},common:{transformOrigin:"center"},transitionProperty:"transform, opacity"},AE=(t,{radius:e,color:n,gradient:r,variant:o,size:i,justify:s,autoContrast:l})=>{const a=t.variantColorResolver({color:n||t.primaryColor,theme:t,gradient:r,variant:o||"filled",autoContrast:l});return{root:{"--button-justify":s,"--button-height":Ve(i,"button-height"),"--button-padding-x":Ve(i,"button-padding-x"),"--button-fz":i!=null&&i.includes("compact")?Tt(i.replace("compact-","")):Tt(i),"--button-radius":e===void 0?void 0:_t(e),"--button-bg":n||o?a.background:void 0,"--button-hover":n||o?a.hover:void 0,"--button-color":a.color,"--button-bd":n||o?a.border:void 0,"--button-hover-color":n||o?a.hoverColor:void 0}}},In=Pt(t=>{const e=q("Button",null,t),{style:n,vars:r,className:o,color:i,disabled:s,children:l,leftSection:a,rightSection:c,fullWidth:d,variant:u,radius:f,loading:h,loaderProps:p,gradient:m,classNames:g,styles:y,unstyled:w,"data-disabled":k,autoContrast:x,mod:C,attributes:E,...S}=e,M=be({name:"Button",props:e,classes:ms,className:o,style:n,classNames:g,styles:y,unstyled:w,attributes:E,vars:r,varsResolver:AE}),N=!!a,A=!!c;return b.jsxs(Hr,{...M("root",{active:!s&&!h&&!k}),unstyled:w,variant:u,disabled:s||h,mod:[{disabled:s||k,loading:h,block:d,"with-left-section":N,"with-right-section":A},C],...S,children:[typeof h=="boolean"&&b.jsx(po,{mounted:h,transition:Sz,duration:150,children:R=>b.jsx(te,{component:"span",...M("loader",{style:R}),"aria-hidden":!0,children:b.jsx(mr,{color:"var(--button-color)",size:"calc(var(--button-height) / 1.8)",...p})})}),b.jsxs("span",{...M("inner"),children:[a&&b.jsx(te,{component:"span",...M("section"),mod:{position:"left"},children:a}),b.jsx(te,{component:"span",mod:{loading:h},...M("label"),children:l}),c&&b.jsx(te,{component:"span",...M("section"),mod:{position:"right"},children:c})]})]})});In.classes=ms;In.varsResolver=AE;In.displayName="@mantine/core/Button";In.Group=eu;In.GroupSection=tu;const[Ez,Mz]=Bd("Card component was not found in tree");var Xm={root:"m_e615b15f",section:"m_599a2148"};const nu=Pt(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,withBorder:s,inheritPadding:l,mod:a,...c}=q("CardSection",null,t),d=Mz();return b.jsx(te,{mod:[{"with-border":s,"inherit-padding":l},a],...d.getStyles("section",{className:n,style:r,styles:o,classNames:e}),...c})});nu.classes=Xm;nu.displayName="@mantine/core/CardSection";const NE=(t,{padding:e})=>({root:{"--card-padding":Wl(e)}}),Tz={orientation:"vertical"},gs=Pt(t=>{const e=q("Card",Tz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,children:a,padding:c,attributes:d,orientation:u,...f}=e,h=be({name:"Card",props:e,classes:Xm,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:d,vars:l,varsResolver:NE}),p=v.Children.toArray(a),m=p.map((g,y)=>{var w;return typeof g=="object"&&g&&"type"in g&&(g.type===nu||((w=g.type)==null?void 0:w.displayName)==="@mantine/core/CardSection")?v.cloneElement(g,{"data-orientation":u,"data-first-section":y===0||void 0,"data-last-section":y===p.length-1||void 0}):g});return b.jsx(Ez,{value:{getStyles:h},children:b.jsx(Ud,{unstyled:s,"data-orientation":u,...h("root"),...f,children:m})})});gs.classes=Xm;gs.varsResolver=NE;gs.displayName="@mantine/core/Card";gs.Section=nu;const RE=Wm(t=>{const{value:e,defaultValue:n,onChange:r,multiple:o,children:i}=q("ChipGroup",null,t),[s,l]=pr({value:e,defaultValue:n,finalValue:o?[]:null,onChange:r}),a=d=>Array.isArray(s)?s.includes(d):d===s,c=d=>{const u=d.currentTarget.value;Array.isArray(s)?l(s.includes(u)?s.filter(f=>f!==u):[...s,u]):l(u)};return b.jsx(IE,{value:{isChipSelected:a,onChange:c,multiple:o},children:i})});RE.displayName="@mantine/core/ChipGroup";const IE=v.createContext(null);var OE={root:"m_f59ffda3",label:"m_be049a53","label--outline":"m_3904c1af","label--filled":"m_fa109255","label--light":"m_f7e165c3",iconWrapper:"m_9ac86df9",checkIcon:"m_d6d72580",input:"m_bde07329"};const Az={type:"checkbox"},DE=(t,{size:e,radius:n,variant:r,color:o,autoContrast:i})=>{const s=t.variantColorResolver({color:o||t.primaryColor,theme:t,variant:r||"filled",autoContrast:i});return{root:{"--chip-fz":Tt(e),"--chip-size":Ve(e,"chip-size"),"--chip-radius":n===void 0?void 0:_t(n),"--chip-checked-padding":Ve(e,"chip-checked-padding"),"--chip-padding":Ve(e,"chip-padding"),"--chip-icon-size":Ve(e,"chip-icon-size"),"--chip-bg":o||r?s.background:void 0,"--chip-hover":o||r?s.hover:void 0,"--chip-color":o||r?s.color:void 0,"--chip-bd":o||r?s.border:void 0,"--chip-spacing":Ve(e,"chip-spacing")}}},Xl=ue(t=>{const e=q("Chip",Az,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,id:a,checked:c,defaultChecked:d,onChange:u,value:f,wrapperProps:h,type:p,disabled:m,children:g,size:y,variant:w,icon:k,rootRef:x,autoContrast:C,mod:E,attributes:S,...M}=e,N=be({name:"Chip",classes:OE,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:S,vars:l,varsResolver:DE}),A=v.use(IE),R=us(a),{styleProps:P,rest:D}=zd(M),[T,_]=pr({value:c,defaultValue:d,finalValue:!1,onChange:u}),F=A?{checked:A.isChipSelected(f),onChange:O=>{A.onChange(O),u==null||u(O.currentTarget.checked)},type:A.multiple?"checkbox":"radio"}:{},L=F.checked||T;return b.jsxs(te,{size:y,variant:w,ref:x,mod:E,...N("root"),...P,...h,children:[b.jsx("input",{type:p,...N("input"),checked:L,onChange:O=>_(O.currentTarget.checked),id:R,disabled:m,value:f,...F,...D}),b.jsxs(te,{component:"label",htmlFor:R,mod:{checked:L,disabled:m},...N("label",{variant:w||"filled"}),children:[L&&k!==null&&k!==!1&&b.jsx("span",{...N("iconWrapper"),children:k===void 0?b.jsx(Jd,{...N("checkIcon")}):k}),b.jsx("span",{children:g})]})]})});Xl.classes=OE;Xl.varsResolver=DE;Xl.displayName="@mantine/core/Chip";Xl.Group=RE;var _E={root:"m_3eebeb36",label:"m_9e365f20"};const Nz={orientation:"horizontal"},PE=(t,{color:e,variant:n,size:r})=>({root:{"--divider-color":e?ho(e,t):void 0,"--divider-border-style":n,"--divider-size":Ve(r,"divider-size")}}),ru=ue(t=>{const e=q("Divider",Nz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,color:a,orientation:c,label:d,labelPosition:u,mod:f,attributes:h,...p}=e,m=be({name:"Divider",classes:_E,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:h,vars:l,varsResolver:PE});return b.jsx(te,{mod:[{orientation:c,withLabel:!!d},f],role:"separator",...m("root"),...p,children:d&&b.jsx(te,{component:"span",mod:{position:u},...m("label"),children:d})})});ru.classes=_E;ru.varsResolver=PE;ru.displayName="@mantine/core/Divider";const $E=Wm(t=>{const{onChange:e,children:n,multiple:r,accept:o,name:i,form:s,resetRef:l,disabled:a,capture:c,inputProps:d,ref:u,...f}=q("FileButton",null,t),h=v.useRef(null),p=()=>{var y;!a&&((y=h.current)==null||y.click())},m=y=>{if(y.currentTarget.files===null)return e(r?[]:null);e(r?Array.from(y.currentTarget.files):y.currentTarget.files[0]||null)};return Fc(l,()=>{h.current&&(h.current.value="")}),b.jsxs(b.Fragment,{children:[b.jsx("input",{style:{display:"none"},type:"file",accept:o,multiple:r,onChange:m,ref:fn(u,h),name:i,form:s,capture:c,...d}),n({onClick:p,...f})]})});$E.displayName="@mantine/core/FileButton";const Rz=({value:t})=>b.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Array.isArray(t)?t.map(e=>e.name).join(", "):t==null?void 0:t.name}),Iz={valueComponent:Rz,size:"sm"},Qm=Wm(t=>{const e=q(["Input","InputWrapper","FileInput"],Iz,t),{unstyled:n,vars:r,onChange:o,value:i,defaultValue:s,multiple:l,accept:a,name:c,form:d,valueComponent:u,clearable:f,clearSectionMode:h,clearButtonProps:p,readOnly:m,capture:g,fileInputProps:y,rightSection:w,size:k,placeholder:x,component:C,resetRef:E,classNames:S,styles:M,attributes:N,...A}=e,R=v.useRef(null),{resolvedClassNames:P,resolvedStyles:D}=Fd({classNames:S,styles:M,props:e}),[T,_]=pr({value:i,defaultValue:s,onChange:o,finalValue:l?[]:null}),F=Array.isArray(T)?T.length!==0:T!==null,L=b.jsx(ql,{...p,variant:"subtle",onClick:()=>_(l?[]:null),size:k,unstyled:n}),O=f&&F&&!m;return v.useEffect(()=>{var V;(Array.isArray(T)&&T.length===0||T===null)&&((V=R.current)==null||V.call(R))},[T]),b.jsx($E,{onChange:_,multiple:l,accept:a,name:c,form:d,resetRef:fn(R,E),disabled:m,capture:g,inputProps:y,children:V=>b.jsx(ps,{component:C||"button",rightSection:w,__clearSection:L,__clearable:O,__clearSectionMode:h,...V,...A,__staticSelector:"FileInput",multiline:!0,type:"button",pointer:!0,__stylesApiProps:e,unstyled:n,size:k,classNames:S,styles:M,attributes:N,children:F?b.jsx(u,{value:T}):b.jsx(It.Placeholder,{__staticSelector:"FileInput",classNames:P,styles:D,attributes:N,children:x})})})});Qm.classes=ps.classes;Qm.displayName="@mantine/core/FileInput";var LE={root:"m_6e45937b",loader:"m_e8eb006c",overlay:"m_df587f17"};const x1={transitionProps:{transition:"fade",duration:0},overlayProps:{backgroundOpacity:.75},zIndex:Ul("overlay")},BE=(t,{zIndex:e})=>({root:{"--lo-z-index":e==null?void 0:e.toString()}}),ou=ue(t=>{const e=q("LoadingOverlay",x1,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,transitionProps:a,loaderProps:c,overlayProps:d,visible:u,zIndex:f,attributes:h,onEnter:p,onEntered:m,onExit:g,onExited:y,...w}=e,k=Kt(),x=be({name:"LoadingOverlay",classes:LE,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:h,vars:l,varsResolver:BE}),C={...x1.overlayProps,...d};return b.jsx(po,{transition:"fade",...a,mounted:!!u,onEnter:p,onEntered:m,onExit:g,onExited:y,children:E=>b.jsxs(te,{...x("root",{style:E}),...w,children:[b.jsx(mr,{unstyled:s,...c,...x("loader",{className:c==null?void 0:c.className,style:c==null?void 0:c.style})}),b.jsx(Qi,{...C,...x("overlay",{className:C==null?void 0:C.className,style:C==null?void 0:C.style}),darkHidden:!0,unstyled:s,color:(d==null?void 0:d.color)||k.white}),b.jsx(Qi,{...C,...x("overlay",{className:C==null?void 0:C.className,style:C==null?void 0:C.style}),lightHidden:!0,unstyled:s,color:(d==null?void 0:d.color)||k.colors.dark[5]})]})})});ou.classes=LE;ou.varsResolver=BE;ou.displayName="@mantine/core/LoadingOverlay";const[Oz,Yt]=Bd("Menu component was not found in the tree"),jE=v.createContext(null);function VE(t){const{value:e,defaultValue:n,onChange:r,children:o}=q("MenuCheckboxGroup",null,t),[i,s]=pr({value:e,defaultValue:n,finalValue:[],onChange:r});return b.jsx(jE,{value:{values:i,onChange:v.useCallback(l=>{s(i.includes(l)?i.filter(a=>a!==l):[...i,l])},[i,s])},children:o})}VE.displayName="@mantine/core/MenuCheckboxGroup";const ts=v.createContext(null);function HE({role:t,checked:e,indicator:n,onSelect:r,color:o,closeMenuOnClick:i,rightSection:s,children:l,disabled:a,dataDisabled:c,className:d,style:u,styles:f,classNames:h,buttonRef:p,others:m}){const g=Yt(),y=v.use(ts),w=Kt(),{dir:k}=Vr(),x=v.useRef(null),C=We(m.onClick,()=>{c||(r(),i&&g.closeDropdownImmediately())}),E=We(m.onMouseMove,()=>{var P;if(!g.hasSearch)return;const R=(P=x.current)==null?void 0:P.closest("[data-menu-dropdown]");R&&R.querySelectorAll("[data-menu-active]").forEach(D=>{D!==x.current&&D.closest("[data-menu-dropdown]")===R&&D.removeAttribute("data-menu-active")})}),S=We(m.onKeyDown,R=>{R.key==="ArrowLeft"&&y&&(y.close(),y.focusParentItem())}),M=o?w.variantColorResolver({color:o,theme:w,variant:"light"}):void 0,N=o?ko({color:o,theme:w}):null,A=g.alignItemsLabels!=="none"||e;return b.jsxs(Hr,{onMouseDown:R=>R.preventDefault(),...m,unstyled:g.unstyled,tabIndex:g.menuItemTabIndex,...g.getStyles("item",{className:d,style:u,styles:f,classNames:h}),ref:fn(x,p),role:t,"aria-checked":e,disabled:a,"data-menu-item":!0,"data-checked":e||void 0,"data-disabled":a||c||void 0,"data-mantine-stop-propagation":!0,onClick:C,onMouseMove:E,onKeyDown:jd({siblingSelector:"[data-menu-item]:not([data-disabled])",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:g.loop,dir:k,orientation:"vertical",onKeyDown:S}),__vars:{"--menu-item-color":N!=null&&N.isThemeColor&&(N==null?void 0:N.shade)===void 0?`var(--mantine-color-${N.color}-6)`:M==null?void 0:M.color,"--menu-item-hover":M==null?void 0:M.hover},children:[A&&b.jsx("div",{...g.getStyles("itemIndicator",{styles:f,classNames:h}),"data-checked":e||void 0,children:e?n:null}),l&&b.jsx("div",{...g.getStyles("itemLabel",{styles:f,classNames:h}),"data-menu-item-label":!0,children:l}),s&&b.jsx("div",{...g.getStyles("itemSection",{styles:f,classNames:h}),"data-position":"right",children:s})]})}var Xn={dropdown:"m_dc9b7c9f",label:"m_9bfac126",divider:"m_efdf90cb",item:"m_99ac2aa1",search:"m_ef8769b6",itemLabel:"m_5476e0d3",itemIndicator:"m_8395186e",itemSection:"m_8b75e504",chevron:"m_b85b0bed"};const eg=ue(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,color:s,closeMenuOnClick:l,rightSection:a,children:c,disabled:d,"data-disabled":u,value:f,checked:h,defaultChecked:p,onChange:m,checkIcon:g,ref:y,...w}=q("MenuCheckboxItem",null,t),k=Yt(),x=v.use(jE),C=x&&f!==void 0?x.values.includes(f):void 0,[E,S]=pr({value:h??C,defaultValue:p,finalValue:!1,onChange:m});return b.jsx(HE,{role:"menuitemcheckbox",checked:E,indicator:g??k.checkIcon??b.jsx(Jd,{size:10}),onSelect:()=>{m?S(!E):x&&f!==void 0?x.onChange(f):S(!E)},color:s,closeMenuOnClick:l,rightSection:a,disabled:d,dataDisabled:u,className:n,style:r,styles:o,classNames:e,buttonRef:y,others:w,children:c})});eg.classes=Xn;eg.displayName="@mantine/core/MenuCheckboxItem";function FE(t){const{children:e,disabled:n,longPressDelay:r}=q("MenuContextMenu",null,t),o=di(e);if(!o)throw new Error("Menu.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const i=Yt(),s=Wd();return v.cloneElement(o,W2({childProps:o.props,disabled:n||s.disabled,opened:i.opened,longPressDelay:r,setReference:s.reference,open:()=>i.openDropdown()}))}FE.displayName="@mantine/core/MenuContextMenu";const tg=ue(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,...s}=q("MenuDivider",null,t);return b.jsx(te,{...Yt().getStyles("divider",{className:n,style:r,styles:o,classNames:e}),...s})});tg.classes=Xn;tg.displayName="@mantine/core/MenuDivider";const Dz=500;function C1(t){return((t.querySelector("[data-menu-item-label]")??t).textContent??"").trim().toLowerCase()}function _z(t){return t.length>1&&t.split("").every(e=>e===t[0])}function zE({enabled:t,opened:e,getDropdown:n}){const r=v.useRef({buffer:"",timeoutId:null});return v.useEffect(()=>{if(e&&t)return;const o=r.current;o.timeoutId!==null&&(window.clearTimeout(o.timeoutId),o.timeoutId=null),o.buffer=""},[e,t]),v.useEffect(()=>()=>{const{timeoutId:o}=r.current;o!==null&&window.clearTimeout(o)},[]),o=>{if(!t||o.defaultPrevented||o.ctrlKey||o.metaKey||o.altKey||o.key.length!==1||o.key===" ")return;const i=o.target;if(i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.tagName==="SELECT"||i.isContentEditable))return;const s=n();if(!s)return;const l=Array.from(s.querySelectorAll("[data-menu-item]:not([data-disabled])")).filter(f=>f.closest("[data-menu-dropdown]")===s);if(l.length===0)return;const a=r.current;a.buffer=(a.buffer+o.key).toLowerCase(),a.timeoutId!==null&&window.clearTimeout(a.timeoutId),a.timeoutId=window.setTimeout(()=>{a.buffer="",a.timeoutId=null},Dz);const c=document.activeElement,d=c?l.indexOf(c):-1;let u=null;if(a.buffer.length===1||_z(a.buffer)){const f=a.buffer[0],h=d+1;for(let p=0;p<l.length;p+=1){const m=(h+p)%l.length;if(C1(l[m]).startsWith(f)){u=l[m];break}}}else for(let f=0;f<l.length;f+=1)if(C1(l[f]).startsWith(a.buffer)){u=l[f];break}u&&(o.preventDefault(),u.focus())}}const ng=ue(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,onMouseEnter:s,onMouseLeave:l,onKeyDown:a,children:c,ref:d,...u}=q("MenuDropdown",null,t),f=v.useRef(null),h=Yt(),p=zE({enabled:!h.hasSearch,opened:h.opened,getDropdown:()=>f.current}),m=We(a,w=>{var k,x;p(w),!(w.defaultPrevented||h.hasSearch)&&(w.key==="ArrowUp"||w.key==="ArrowDown")&&(w.preventDefault(),(x=(k=f.current)==null?void 0:k.querySelectorAll("[data-menu-item]:not(:disabled)")[0])==null||x.focus())}),g=We(s,()=>(h.trigger==="hover"||h.trigger==="click-hover")&&h.openDropdown()),y=We(l,()=>(h.trigger==="hover"||h.trigger==="click-hover")&&h.closeDropdown());return b.jsxs(wt.Dropdown,{...u,onMouseEnter:g,onMouseLeave:y,role:"menu","aria-orientation":"vertical",ref:fn(d,f),...h.getStyles("dropdown",{className:n,style:r,styles:o,classNames:e,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:m,children:[h.withInitialFocusPlaceholder&&!h.hasSearch&&b.jsx("div",{role:"presentation",tabIndex:-1,"data-autofocus":!0,"data-mantine-stop-propagation":!0,style:{outline:0}}),c]})});ng.classes=Xn;ng.displayName="@mantine/core/MenuDropdown";const rg=Pt(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,color:s,closeMenuOnClick:l,leftSection:a,rightSection:c,children:d,disabled:u,"data-disabled":f,ref:h,...p}=q("MenuItem",null,t),m=Yt(),g=v.use(ts),y=Kt(),{dir:w}=Vr(),k=v.useRef(null),x=p,C=We(x.onClick,()=>{f||(typeof l=="boolean"?l&&m.closeDropdownImmediately():m.closeOnItemClick&&m.closeDropdownImmediately())}),E=We(x.onMouseMove,()=>{var R;if(!m.hasSearch)return;const A=(R=k.current)==null?void 0:R.closest("[data-menu-dropdown]");A&&A.querySelectorAll("[data-menu-active]").forEach(P=>{P!==k.current&&P.closest("[data-menu-dropdown]")===A&&P.removeAttribute("data-menu-active")})}),S=s?y.variantColorResolver({color:s,theme:y,variant:"light"}):void 0,M=s?ko({color:s,theme:y}):null,N=We(x.onKeyDown,A=>{A.key==="ArrowLeft"&&g&&(g.close(),g.focusParentItem())});return b.jsxs(Hr,{onMouseDown:A=>A.preventDefault(),...p,unstyled:m.unstyled,tabIndex:m.menuItemTabIndex,...m.getStyles("item",{className:n,style:r,styles:o,classNames:e}),ref:fn(k,h),role:"menuitem",disabled:u,"data-menu-item":!0,"data-disabled":u||f||void 0,"data-mantine-stop-propagation":!0,onClick:C,onMouseMove:E,onKeyDown:jd({siblingSelector:"[data-menu-item]:not([data-disabled])",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:m.loop,dir:w,orientation:"vertical",onKeyDown:N}),__vars:{"--menu-item-color":M!=null&&M.isThemeColor&&(M==null?void 0:M.shade)===void 0?`var(--mantine-color-${M.color}-6)`:S==null?void 0:S.color,"--menu-item-hover":S==null?void 0:S.hover},children:[m.alignItemsLabels==="all"&&b.jsx("div",{...m.getStyles("itemIndicator",{styles:o,classNames:e}),"data-placeholder":!0}),a&&b.jsx("div",{...m.getStyles("itemSection",{styles:o,classNames:e}),"data-position":"left",children:a}),d&&b.jsx("div",{...m.getStyles("itemLabel",{styles:o,classNames:e}),"data-menu-item-label":!0,children:d}),c&&b.jsx("div",{...m.getStyles("itemSection",{styles:o,classNames:e}),"data-position":"right",children:c})]})});rg.classes=Xn;rg.displayName="@mantine/core/MenuItem";const og=ue(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,...s}=q("MenuLabel",null,t);return b.jsx(te,{...Yt().getStyles("label",{className:n,style:r,styles:o,classNames:e}),...s})});og.classes=Xn;og.displayName="@mantine/core/MenuLabel";const UE=v.createContext(null);function WE(t){const{value:e,defaultValue:n,onChange:r,children:o}=q("MenuRadioGroup",null,t),[i,s]=pr({value:e,defaultValue:n,finalValue:null,onChange:r});return b.jsx(UE,{value:{value:i,onChange:l=>s(l)},children:o})}WE.displayName="@mantine/core/MenuRadioGroup";function Pz({size:t,style:e,...n}){return b.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 5 5",style:{width:$(t),height:$(t),...e},"aria-hidden":!0,...n,children:b.jsx("circle",{cx:"2.5",cy:"2.5",r:"2.5",fill:"currentColor"})})}const ig=ue(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,color:s,closeMenuOnClick:l,rightSection:a,children:c,disabled:d,"data-disabled":u,value:f,checked:h,onChange:p,checkIcon:m,ref:g,...y}=q("MenuRadioItem",null,t),w=Yt(),k=v.use(UE),x=h??(k?k.value===f:!1);return b.jsx(HE,{role:"menuitemradio",checked:x,indicator:m??w.checkIcon??b.jsx(Pz,{size:5}),onSelect:()=>{x||(p?p(f):k&&k.onChange(f))},color:s,closeMenuOnClick:l,rightSection:a,disabled:d,dataDisabled:u,className:n,style:r,styles:o,classNames:e,buttonRef:g,others:y,children:c})});ig.classes=Xn;ig.displayName="@mantine/core/MenuRadioItem";const $z="[data-menu-item]:not([data-disabled])",Lz="[data-menu-active]";function bf(t){return t==null?void 0:t.closest("[data-menu-dropdown]")}function Bz(t){return t?Array.from(t.querySelectorAll($z)).filter(e=>e.closest("[data-menu-dropdown]")===t):[]}function Bh(t){t&&t.querySelectorAll(Lz).forEach(e=>{e.closest("[data-menu-dropdown]")===t&&e.removeAttribute("data-menu-active")})}function Ia(t,e){Bh(e),t&&(t.setAttribute("data-menu-active","true"),t.scrollIntoView({block:"nearest"}))}function yf(t){return t.findIndex(e=>e.hasAttribute("data-menu-active"))}const jz={clearSearchOnClose:!0},sg=ue(t=>{const{classNames:e,styles:n,onKeyDown:r,onChange:o,size:i,clearSearchOnClose:s,ref:l,...a}=q("MenuSearch",jz,t),c=Yt(),d=v.useRef(null),u=fn(l,d),f=v.useRef(o);f.current=o,v.useEffect(()=>c.registerSearch(),[c.registerSearch]),v.useEffect(()=>{s?c.searchExitClearRef.current=()=>{var g;(g=f.current)==null||g.call(f,{currentTarget:{value:""}})}:c.searchExitClearRef.current=null},[s,c.searchExitClearRef]),v.useEffect(()=>{c.opened||Bh(bf(d.current))},[c.opened]);const h=We(o,g=>{Bh(bf(g.currentTarget))}),p=We(r,g=>{if(g.defaultPrevented)return;const y=bf(g.currentTarget),w=Bz(y);if(g.key==="ArrowDown"){if(g.preventDefault(),w.length===0)return;const k=yf(w);Ia(w[k>=w.length-1?c.loop?0:k:k+1]??null,y)}else if(g.key==="ArrowUp"){if(g.preventDefault(),w.length===0)return;const k=yf(w);Ia(w[k<=0?k===-1||c.loop?w.length-1:0:k-1]??null,y)}else if(g.key==="Home")g.preventDefault(),w.length>0&&Ia(w[0],y);else if(g.key==="End")g.preventDefault(),w.length>0&&Ia(w[w.length-1],y);else if(g.key==="Enter"){if(g.nativeEvent.isComposing||g.nativeEvent.keyCode===229)return;const k=w[yf(w)];k&&(g.preventDefault(),k.hasAttribute("data-sub-menu-item")?(k.focus(),k.dispatchEvent(new KeyboardEvent("keydown",{key:"ArrowRight",bubbles:!0}))):k.click())}}),m=c.getStyles("search");return b.jsx(It,{"data-autofocus":!0,"data-mantine-stop-propagation":!0,type:"search",size:i,...a,ref:u,classNames:[{input:m.className},e],styles:[{input:m.style},n],onKeyDown:p,onChange:h,__staticSelector:"Menu"})});sg.classes=Xn;sg.displayName="@mantine/core/MenuSearch";const lg=ue(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,onMouseEnter:s,onMouseLeave:l,onPointerEnter:a,onPointerLeave:c,onKeyDown:d,children:u,ref:f,...h}=q("MenuSubDropdown",null,t),p=v.useRef(null),m=Yt(),g=v.use(ts),y=zE({enabled:!m.hasSearch,opened:(g==null?void 0:g.opened)??!1,getDropdown:()=>p.current}),w=We(d,x=>{y(x),!x.ctrlKey&&!x.metaKey&&!x.altKey&&x.key.length===1&&x.key!==" "&&x.stopPropagation()}),k=g==null?void 0:g.getFloatingProps({onMouseEnter:s,onMouseLeave:l,onPointerEnter:a,onPointerLeave:c});return b.jsx(wt.Dropdown,{...h,...k,role:"menu","aria-orientation":"vertical",ref:fn(f,p,g==null?void 0:g.setFloating),...m.getStyles("dropdown",{className:n,style:r,styles:o,classNames:e,withStaticClass:!1}),tabIndex:-1,"data-menu-dropdown":!0,onKeyDown:w,children:u})});lg.classes=Xn;lg.displayName="@mantine/core/MenuSubDropdown";const ag=Pt(t=>{const{classNames:e,className:n,style:r,styles:o,vars:i,color:s,leftSection:l,rightSection:a,children:c,disabled:d,"data-disabled":u,closeMenuOnClick:f,ref:h,...p}=q("MenuSubItem",null,t),m=Yt(),g=v.use(ts),y=Kt(),{dir:w}=Vr(),k=v.useRef(null),x=p,C=s?y.variantColorResolver({color:s,theme:y,variant:"light"}):void 0,E=s?ko({color:s,theme:y}):null,S=We(x.onKeyDown,R=>{R.key==="ArrowRight"&&(g==null||g.open(),g==null||g.focusFirstItem()),R.key==="ArrowLeft"&&(g!=null&&g.parentContext)&&(g.parentContext.close(),g.parentContext.focusParentItem())}),M=We(x.onClick,()=>{!u&&f&&m.closeDropdownImmediately()}),N=We(x.onMouseMove,()=>{var P;if(!m.hasSearch)return;const R=(P=k.current)==null?void 0:P.closest("[data-menu-dropdown]");R&&R.querySelectorAll("[data-menu-active]").forEach(D=>{D!==k.current&&D.closest("[data-menu-dropdown]")===R&&D.removeAttribute("data-menu-active")})}),A=g==null?void 0:g.getReferenceProps({onMouseEnter:x.onMouseEnter,onMouseLeave:x.onMouseLeave,onPointerEnter:x.onPointerEnter,onPointerLeave:x.onPointerLeave});return b.jsxs(Hr,{onMouseDown:R=>R.preventDefault(),...p,...A,unstyled:m.unstyled,tabIndex:m.menuItemTabIndex,...m.getStyles("item",{className:n,style:r,styles:o,classNames:e}),ref:fn(k,h,g==null?void 0:g.setReference),role:"menuitem",disabled:d,"data-menu-item":!0,"data-sub-menu-item":!0,"data-disabled":d||u||void 0,"data-mantine-stop-propagation":!0,onClick:M,onMouseMove:N,onKeyDown:jd({siblingSelector:"[data-menu-item]:not([data-disabled])",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:m.loop,dir:w,orientation:"vertical",onKeyDown:S}),__vars:{"--menu-item-color":E!=null&&E.isThemeColor&&(E==null?void 0:E.shade)===void 0?`var(--mantine-color-${E.color}-6)`:C==null?void 0:C.color,"--menu-item-hover":C==null?void 0:C.hover},children:[m.alignItemsLabels==="all"&&b.jsx("div",{...m.getStyles("itemIndicator",{styles:o,classNames:e}),"data-placeholder":!0}),l&&b.jsx("div",{...m.getStyles("itemSection",{styles:o,classNames:e}),"data-position":"left",children:l}),c&&b.jsx("div",{...m.getStyles("itemLabel",{styles:o,classNames:e}),"data-menu-item-label":!0,children:c}),b.jsx("div",{...m.getStyles("itemSection",{styles:o,classNames:e}),"data-position":"right",children:a||b.jsx(yE,{...m.getStyles("chevron"),size:14})})]})});ag.classes=Xn;ag.displayName="@mantine/core/MenuSubItem";function qE({children:t,refProp:e}){if(!g2(t))throw new Error("Menu.Sub.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");return Yt(),b.jsx(wt.Target,{refProp:e,popupType:"menu",children:t})}qE.displayName="@mantine/core/MenuSubTarget";const Vz={offset:0,position:"right-start",safeAreaPolygon:!0,transitionProps:{duration:0},openDelay:0,middlewares:{shift:{crossAxis:!0}}};function bs(t){const{children:e,closeDelay:n,openDelay:r,position:o,safeAreaPolygon:i,opened:s,onChange:l,...a}=q("MenuSub",Vz,t),c=us(),[d,u]=pr({value:s,finalValue:!1,onChange:l}),f=v.use(ts),h=Yt(),{dir:p}=Vr(),m=Gm(p,o),g=(f==null?void 0:f.registerOpenSub)??h.registerOpenSub,y=v.useRef(null),w=v.useCallback(P=>{const D=y.current;return D&&D!==P&&D(),y.current=P,()=>{y.current===P&&(y.current=null)}},[]),k=v.useRef(u);k.current=u;const x=v.useCallback(()=>k.current(!0),[]),C=v.useCallback(()=>k.current(!1),[]);v.useEffect(()=>{if(d)return g(C)},[d,g,C]);const{context:E,refs:S}=Al({placement:m,open:d,onOpenChange:P=>{P?x():C()}}),{getReferenceProps:M,getFloatingProps:N}=Xh([Kh(E,{handleClose:i?hv(typeof i=="object"?i:void 0):void 0,delay:{open:r,close:n}})]),A=()=>window.setTimeout(()=>{var P,D;(D=(P=document.getElementById(`${c}-dropdown`))==null?void 0:P.querySelectorAll("[data-menu-item]:not([data-disabled])")[0])==null||D.focus()},16),R=()=>window.setTimeout(()=>{var P;(P=document.getElementById(`${c}-target`))==null||P.focus()},16);return b.jsx(ts,{value:{opened:d,close:C,open:x,focusFirstItem:A,focusParentItem:R,parentContext:f,setReference:S.setReference,setFloating:S.setFloating,getReferenceProps:M,getFloatingProps:N,registerOpenSub:w},children:b.jsx(wt,{opened:d,onChange:P=>P?x():C(),withinPortal:!1,withArrow:!1,id:c,position:o,...a,children:e})})}bs.extend=t=>t;bs.displayName="@mantine/core/MenuSub";bs.Target=qE;bs.Dropdown=lg;bs.Item=ag;const Hz={refProp:"ref"};function GE(t){const{children:e,refProp:n,...r}=q("MenuTarget",Hz,t),o=di(e);if(!o)throw new Error("Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");const i=Yt(),s=o.props,l=We(s.onClick,()=>{i.trigger==="click"?i.toggleDropdown():i.trigger==="click-hover"&&(i.setOpenedViaClick(!0),i.opened||i.openDropdown())}),a=We(s.onMouseEnter,()=>(i.trigger==="hover"||i.trigger==="click-hover")&&i.openDropdown()),c=We(s.onMouseLeave,()=>{(i.trigger==="hover"||i.trigger==="click-hover"&&!i.openedViaClick)&&i.closeDropdown()});return b.jsx(wt.Target,{refProp:n,popupType:"menu",...r,children:v.cloneElement(o,{onClick:l,onMouseEnter:a,onMouseLeave:c,"data-expanded":i.opened?!0:void 0})})}GE.displayName="@mantine/core/MenuTarget";const Fz={trapFocus:!0,closeOnItemClick:!0,withInitialFocusPlaceholder:!0,clickOutsideEvents:["mousedown","touchstart","keydown"],loop:!0,trigger:"click",openDelay:0,closeDelay:100,menuItemTabIndex:-1,alignItemsLabels:"with-indicators"},Re=ue(t=>{const e=q("Menu",Fz,t),{children:n,onOpen:r,onClose:o,opened:i,defaultOpened:s,trapFocus:l,onChange:a,closeOnItemClick:c,loop:d,closeOnEscape:u,trigger:f,openDelay:h,closeDelay:p,classNames:m,styles:g,unstyled:y,variant:w,vars:k,menuItemTabIndex:x,keepMounted:C,withInitialFocusPlaceholder:E,attributes:S,onExitTransitionEnd:M,alignItemsLabels:N,checkIcon:A,...R}=e,P=be({name:"Menu",classes:Xn,props:e,classNames:m,styles:g,unstyled:y,attributes:S}),[D,T]=pr({value:i,defaultValue:s,finalValue:!1,onChange:a}),[_,F]=v.useState(!1),L=()=>{T(!1),F(!1),D&&(o==null||o())},O=()=>{T(!0),!D&&(r==null||r())},V=()=>{D?L():O()},{openDropdown:U,closeDropdown:re}=WF({open:O,close:L,closeDelay:p,openDelay:h}),Z=v.useRef(null),z=v.useCallback(Q=>{const J=Z.current;return J&&J!==Q&&J(),Z.current=Q,()=>{Z.current===Q&&(Z.current=null)}},[]),ie=v.useRef(0),[se,we]=v.useState(!1),ye=v.useCallback(()=>(ie.current+=1,ie.current===1&&we(!0),()=>{ie.current-=1,ie.current===0&&we(!1)}),[]),me=v.useRef(null),fe=()=>{var Q;(Q=me.current)==null||Q.call(me),M==null||M()},Pe=Q=>dH("[data-menu-item]","[data-menu-dropdown]",Q),{resolvedClassNames:$e,resolvedStyles:H}=Fd({classNames:m,styles:g,props:e});return b.jsx(Oz,{value:{getStyles:P,opened:D,toggleDropdown:V,getItemIndex:Pe,openedViaClick:_,setOpenedViaClick:F,closeOnItemClick:c,closeDropdown:f==="click"?L:re,openDropdown:f==="click"?O:U,closeDropdownImmediately:L,loop:d,trigger:f,unstyled:y,menuItemTabIndex:x,withInitialFocusPlaceholder:E,registerOpenSub:z,hasSearch:se,registerSearch:ye,searchExitClearRef:me,alignItemsLabels:N,checkIcon:A},children:b.jsx(wt,{returnFocus:!0,...R,opened:D,onChange:V,defaultOpened:s,trapFocus:C?!1:l,closeOnEscape:u,__staticSelector:"Menu",classNames:$e,styles:H,unstyled:y,variant:w,keepMounted:C,onExitTransitionEnd:fe,children:n})})});Re.displayName="@mantine/core/Menu";Re.classes=Xn;Re.Item=rg;Re.Label=og;Re.Dropdown=ng;Re.Target=GE;Re.Divider=tg;Re.Search=sg;Re.Sub=bs;Re.CheckboxItem=eg;Re.CheckboxGroup=VE;Re.RadioItem=ig;Re.RadioGroup=WE;Re.ContextMenu=FE;function zz({offset:t,position:e,defaultOpened:n}){const[r,o]=v.useState(n),i=v.useRef(null),{x:s,y:l,elements:a,refs:c,update:d,placement:u}=Al({placement:e,middleware:[ri({crossAxis:!0,padding:5,rootBoundary:"document"})]}),f=u.includes("right")?t:e.includes("left")?t*-1:0,h=u.includes("bottom")?t:e.includes("top")?t*-1:0,p=v.useCallback(({clientX:m,clientY:g})=>{c.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:m,y:g,left:m+f,top:g+h,right:m,bottom:g}}})},[a.reference]);return v.useEffect(()=>{if(c.floating.current){const m=i.current;m.addEventListener("mousemove",p);const g=Mr(c.floating.current);return g.forEach(y=>{y.addEventListener("scroll",d)}),()=>{m.removeEventListener("mousemove",p),g.forEach(y=>{y.removeEventListener("scroll",d)})}}},[a.reference,c.floating.current,d,p,r]),{handleMouseMove:p,x:s,y:l,opened:r,setOpened:o,boundaryRef:i,floating:c.setFloating}}var iu={tooltip:"m_1b3c8819",arrow:"m_f898399f"};const Uz={refProp:"ref",withinPortal:!0,offset:10,position:"right",zIndex:Ul("popover")},ZE=(t,{radius:e,color:n})=>({tooltip:{"--tooltip-radius":e===void 0?void 0:_t(e),"--tooltip-bg":n?ho(n,t):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),su=ue(t=>{const e=q("TooltipFloating",Uz,t),{children:n,refProp:r,withinPortal:o,style:i,className:s,classNames:l,styles:a,unstyled:c,radius:d,color:u,label:f,offset:h,position:p,multiline:m,zIndex:g,disabled:y,defaultOpened:w,variant:k,vars:x,portalProps:C,attributes:E,ref:S,...M}=e,N=Kt(),A=be({name:"TooltipFloating",props:e,classes:iu,className:s,style:i,classNames:l,styles:a,unstyled:c,attributes:E,rootSelector:"tooltip",vars:x,varsResolver:ZE}),{handleMouseMove:R,x:P,y:D,opened:T,boundaryRef:_,floating:F,setOpened:L}=zz({offset:h,position:p,defaultOpened:w}),O=di(n);if(!O)throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const V=fn(_,Pm(O),S),U=O.props,re=z=>{var ie;(ie=U.onMouseEnter)==null||ie.call(U,z),R(z),L(!0)},Z=z=>{var ie;(ie=U.onMouseLeave)==null||ie.call(U,z),L(!1)};return b.jsxs(b.Fragment,{children:[b.jsx(es,{...C,withinPortal:o,children:b.jsx(te,{...M,...A("tooltip",{style:{...O2(i,N),zIndex:g,display:!y&&T?"block":"none",top:(D&&Math.round(D))??"",left:(P&&Math.round(P))??""}}),variant:k,ref:F,mod:{multiline:m},children:f})}),v.cloneElement(O,{...U,[r]:V,onMouseEnter:re,onMouseLeave:Z})]})});su.classes=iu;su.varsResolver=ZE;su.displayName="@mantine/core/TooltipFloating";const KE=v.createContext({withinGroup:!1}),Wz={openDelay:0,closeDelay:0};function cg(t){const{openDelay:e,closeDelay:n,children:r}=q("TooltipGroup",Wz,t);return b.jsx(KE,{value:{withinGroup:!0},children:b.jsx(bA,{delay:{open:e,close:n},children:r})})}cg.displayName="@mantine/core/TooltipGroup";cg.extend=t=>t;function qz(t){if(t===void 0)return{shift:!0,flip:!0};const e={...t};return t.shift===void 0&&(e.shift=!0),t.flip===void 0&&(e.flip=!0),e}function Gz(t){const e=qz(t.middlewares),n=[Hn(t.offset)];return e.shift&&n.push(ri(typeof e.shift=="boolean"?{padding:8}:{padding:8,...e.shift})),e.flip&&n.push(typeof e.flip=="boolean"?jo():jo(e.flip)),n.push(iv({element:t.arrowRef,padding:t.arrowOffset})),e.inline?n.push(typeof e.inline=="boolean"?_s():_s(e.inline)):t.inline&&n.push(_s()),n}function Zz(t){var C,E,S;const[e,n]=v.useState(t.defaultOpened),r=typeof t.opened=="boolean"?t.opened:e,o=v.use(KE).withinGroup,i=us(),s=v.useCallback(M=>{n(M),M&&g(i)},[i]),{x:l,y:a,context:c,refs:d,placement:u,middlewareData:{arrow:{x:f,y:h}={}}}=Al({strategy:t.strategy,placement:t.position,open:r,onOpenChange:s,middleware:Gz(t),whileElementsMounted:ji}),{delay:p,currentId:m,setCurrentId:g}=yA(c,{id:i}),{getReferenceProps:y,getFloatingProps:w}=Xh([Kh(c,{enabled:(C=t.events)==null?void 0:C.hover,delay:o?p:{open:t.openDelay,close:t.closeDelay},mouseOnly:!((E=t.events)!=null&&E.touch)}),DA(c,{enabled:(S=t.events)==null?void 0:S.focus,visibleOnly:!0}),PA(c,{role:"tooltip"}),dv(c,{enabled:typeof t.opened>"u"})]),k=v.useRef(u);ni(()=>{var M;k.current!==u&&(k.current=u,(M=t.onPositionChange)==null||M.call(t,u))},[u]);const x=r&&m&&m!==i;return{x:l,y:a,arrowX:f,arrowY:h,reference:d.setReference,floating:d.setFloating,getFloatingProps:w,getReferenceProps:y,isGroupPhase:x,opened:r,placement:u}}const Kz={position:"top",refProp:"ref",withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:Ul("popover"),middlewares:{flip:!0,shift:!0,inline:!1}},JE=(t,{radius:e,color:n,variant:r,autoContrast:o})=>{const i=t.variantColorResolver({theme:t,color:n||t.primaryColor,autoContrast:o,variant:r||"filled"});return{tooltip:{"--tooltip-radius":e===void 0?void 0:_t(e),"--tooltip-bg":n?i.background:void 0,"--tooltip-color":n?i.color:void 0}}},ui=ue(t=>{const e=q("Tooltip",Kz,t),{children:n,position:r,refProp:o,label:i,openDelay:s,closeDelay:l,onPositionChange:a,opened:c,defaultOpened:d,withinPortal:u,radius:f,color:h,classNames:p,styles:m,unstyled:g,style:y,className:w,withArrow:k,arrowSize:x,arrowOffset:C,arrowRadius:E,arrowPosition:S,offset:M,transitionProps:N,multiline:A,events:R,zIndex:P,disabled:D,onClick:T,onMouseEnter:_,onMouseLeave:F,inline:L,variant:O,keepMounted:V,vars:U,portalProps:re,mod:Z,floatingStrategy:z,middlewares:ie,autoContrast:se,attributes:we,target:ye,ref:me,...fe}=e,{dir:Pe}=Vr(),$e=v.useRef(null),H=Zz({position:Gm(Pe,r),closeDelay:l,openDelay:s,onPositionChange:a,opened:c,defaultOpened:d,events:R,arrowRef:$e,arrowOffset:C,offset:typeof M=="number"?M+(k?x/2:0):M,inline:L,strategy:z,middlewares:ie});v.useEffect(()=>{const ze=ye instanceof HTMLElement?ye:typeof ye=="string"?document.querySelector(ye):(ye==null?void 0:ye.current)||null;ze&&H.reference(ze)},[ye,H]);const Q=be({name:"Tooltip",props:e,classes:iu,className:w,style:y,classNames:p,styles:m,unstyled:g,attributes:we,rootSelector:"tooltip",vars:U,varsResolver:JE}),J=di(n);if(!ye&&!J)throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const ke=Q("tooltip"),Ee=S==="merge"&&k?H2({position:H.placement,dir:Pe}):void 0;if(ye){const ze=w1(N,{duration:100,transition:"fade"});return b.jsx(b.Fragment,{children:b.jsx(es,{...re,withinPortal:u,children:b.jsx(po,{...ze,keepMounted:V,mounted:!D&&!!H.opened,duration:H.isGroupPhase?10:ze.duration,children:Xt=>b.jsxs(te,{...fe,"data-fixed":z==="fixed"||void 0,variant:O,mod:[{multiline:A},Z],...ke,...H.getFloatingProps({ref:H.floating,className:ke.className,style:{...ke.style,...Xt,...Ee,zIndex:P,top:H.y??0,left:H.x??0}}),children:[i,b.jsx(Uc,{ref:$e,arrowX:H.arrowX,arrowY:H.arrowY,visible:k,position:H.placement,arrowSize:x,arrowOffset:C,arrowRadius:E,arrowPosition:S,...Q("arrow")})]})})})})}const le=J.props,ot=fn(H.reference,Pm(J),me),it=w1(N,{duration:100,transition:"fade"});return b.jsxs(b.Fragment,{children:[b.jsx(es,{...re,withinPortal:u,children:b.jsx(po,{...it,keepMounted:V,mounted:!D&&!!H.opened,duration:H.isGroupPhase?10:it.duration,children:ze=>b.jsxs(te,{...fe,"data-fixed":z==="fixed"||void 0,variant:O,mod:[{multiline:A},Z],...H.getFloatingProps({ref:H.floating,className:Q("tooltip").className,style:{...Q("tooltip").style,...ze,...Ee,zIndex:P,top:H.y??0,left:H.x??0}}),children:[i,b.jsx(Uc,{ref:$e,arrowX:H.arrowX,arrowY:H.arrowY,visible:k,position:H.placement,arrowSize:x,arrowOffset:C,arrowRadius:E,arrowPosition:S,...Q("arrow")})]})})}),v.cloneElement(J,H.getReferenceProps({onClick:T,onMouseEnter:_,onMouseLeave:F,onMouseMove:e.onMouseMove,onPointerDown:e.onPointerDown,onPointerEnter:e.onPointerEnter,...le,className:$r(w,le.className),[o]:ot}))]})});ui.classes=iu;ui.varsResolver=JE;ui.displayName="@mantine/core/Tooltip";ui.Floating=su;ui.Group=cg;var YE={root:"m_18320242","skeleton-fade":"m_299c329c"};const Jz={visible:!0,animate:!0},XE=(t,{width:e,height:n,radius:r,circle:o})=>({root:{"--skeleton-height":$(n),"--skeleton-width":$(o?n:e),"--skeleton-radius":o?"1000px":r===void 0?void 0:_t(r)}}),El=ue(t=>{const e=q("Skeleton",Jz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,width:a,height:c,circle:d,visible:u,radius:f,animate:h,mod:p,attributes:m,...g}=e;return b.jsx(te,{...be({name:"Skeleton",classes:YE,props:e,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:m,vars:l,varsResolver:XE})("root"),mod:[{visible:u,animate:h},p],...g})});El.classes=YE;El.varsResolver=XE;El.displayName="@mantine/core/Skeleton";var QE={root:"m_6d731127"};const Yz={gap:"md",align:"stretch",justify:"flex-start"},eM=(t,{gap:e,align:n,justify:r})=>({root:{"--stack-gap":Wl(e),"--stack-align":n,"--stack-justify":r}}),ys=ue(t=>{const e=q("Stack",Yz,t),{classNames:n,className:r,style:o,styles:i,unstyled:s,vars:l,align:a,justify:c,gap:d,variant:u,attributes:f,...h}=e;return b.jsx(te,{...be({name:"Stack",props:e,classes:QE,className:r,style:o,classNames:n,styles:i,unstyled:s,attributes:f,vars:l,varsResolver:eM})("root"),variant:u,...h})});ys.classes=QE;ys.varsResolver=eM;ys.displayName="@mantine/core/Stack";const[Xz,dg]=Bd("Tabs component was not found in the tree");var Ql={root:"m_89d60db1","list--default":"m_576c9d4",list:"m_89d33d6d",tab:"m_4ec4dce6",panel:"m_b0c91715",tabSection:"m_fc420b1f",tabLabel:"m_42bbd1ae","tab--default":"m_539e827b","list--outline":"m_6772fbd5","tab--outline":"m_b59ab47c","tab--pills":"m_c3381914"};const ug=ue(t=>{const e=q("TabsList",null,t),{children:n,className:r,grow:o,justify:i,classNames:s,styles:l,style:a,mod:c,...d}=e,u=dg();return b.jsx(te,{...u.getStyles("list",{className:r,style:a,classNames:s,styles:l,props:e,variant:u.variant}),role:"tablist",variant:u.variant,mod:[{grow:o,orientation:u.orientation,placement:u.orientation==="vertical"&&u.placement,inverted:u.inverted},c],"aria-orientation":u.orientation,__vars:{"--tabs-justify":i},...d,children:n})});ug.classes=Ql;ug.displayName="@mantine/core/TabsList";const fg=ue(t=>{const e=q("TabsPanel",null,t),{children:n,className:r,value:o,classNames:i,styles:s,style:l,mod:a,keepMounted:c,...d}=e,u=Hd(),f=dg();v.useEffect(()=>(f.setMountedPanel(o,!0),()=>{f.setMountedPanel(o,!1)}),[o]);const h=f.value===o,p=f.keepMounted||c,m=f.keepMountedMode!=="display-none",g=p&&m&&u!=="test"?b.jsx(v.Activity,{mode:h?"visible":"hidden",children:n}):p||h?n:null;return b.jsx(te,{...f.getStyles("panel",{className:r,classNames:i,styles:s,style:[l,h?void 0:{display:"none"}],props:e}),mod:[{orientation:f.orientation},a],role:"tabpanel",id:f.getPanelId(o),"aria-labelledby":f.getTabId(o),...d,children:g})});fg.classes=Ql;fg.displayName="@mantine/core/TabsPanel";const hg=ue(t=>{const e=q("TabsTab",null,t),{className:n,children:r,rightSection:o,leftSection:i,value:s,onClick:l,onKeyDown:a,disabled:c,color:d,style:u,classNames:f,styles:h,vars:p,mod:m,tabIndex:g,...y}=e,w=Kt(),{dir:k}=Vr(),x=dg(),C=s===x.value,E=M=>{x.onChange(x.allowTabDeactivation&&s===x.value?null:s),l==null||l(M)},S={classNames:f,styles:h,props:e};return b.jsxs(Hr,{...x.getStyles("tab",{className:n,style:u,variant:x.variant,...S}),disabled:c,unstyled:x.unstyled,variant:x.variant,mod:[{active:C,disabled:c,orientation:x.orientation,inverted:x.inverted,placement:x.orientation==="vertical"&&x.placement},m],role:"tab",id:x.getTabId(s),"aria-selected":C,tabIndex:g!==void 0?g:C||x.value===null?0:-1,"aria-controls":x.mountedPanels.current.has(s)?x.getPanelId(s):void 0,onClick:E,__vars:{"--tabs-color":d?ho(d,w):void 0},onKeyDown:jd({siblingSelector:'[role="tab"]',parentSelector:'[role="tablist"]',activateOnFocus:x.activateTabWithKeyboard,loop:x.loop,orientation:x.orientation||"horizontal",dir:k,onKeyDown:a}),...y,children:[i&&b.jsx("span",{...x.getStyles("tabSection",S),"data-position":"left",children:i}),r&&b.jsx("span",{...x.getStyles("tabLabel",S),children:r}),o&&b.jsx("span",{...x.getStyles("tabSection",S),"data-position":"right",children:o})]})});hg.classes=Ql;hg.displayName="@mantine/core/TabsTab";const S1="Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value",Qz={keepMounted:!0,keepMountedMode:"activity",orientation:"horizontal",loop:!0,activateTabWithKeyboard:!0,variant:"default",placement:"left"},tM=(t,{radius:e,color:n,autoContrast:r})=>({root:{"--tabs-radius":_t(e),"--tabs-color":ho(n,t),"--tabs-text-color":HH(r,t)?Bm({color:n,theme:t,autoContrast:r}):void 0}}),nr=ue(t=>{const e=q("Tabs",Qz,t),{defaultValue:n,value:r,onChange:o,orientation:i,children:s,loop:l,id:a,activateTabWithKeyboard:c,allowTabDeactivation:d,variant:u,color:f,radius:h,inverted:p,placement:m,keepMounted:g,keepMountedMode:y,classNames:w,styles:k,unstyled:x,className:C,style:E,vars:S,autoContrast:M,mod:N,attributes:A,...R}=e,P=us(a),D=v.useRef(new Set),T=CH(),_=v.useCallback((V,U)=>{const re=D.current;U&&!re.has(V)?(re.add(V),T()):!U&&re.has(V)&&(re.delete(V),T())},[]),[F,L]=pr({value:r,defaultValue:n,finalValue:null,onChange:o}),O=be({name:"Tabs",props:e,classes:Ql,className:C,style:E,classNames:w,styles:k,unstyled:x,attributes:A,vars:S,varsResolver:tM});return b.jsx(Xz,{value:{placement:m,value:F,orientation:i,id:P,loop:l,activateTabWithKeyboard:c,getTabId:n1(`${P}-tab`,S1),getPanelId:n1(`${P}-panel`,S1),onChange:L,allowTabDeactivation:d,variant:u,color:f,radius:h,inverted:p,keepMounted:g,keepMountedMode:y,unstyled:x,getStyles:O,mountedPanels:D,setMountedPanel:_},children:b.jsx(te,{id:P,variant:u,mod:[{orientation:i,inverted:i==="horizontal"&&p,placement:i==="vertical"&&m},N],...O("root"),...R,children:s})})});nr.classes=Ql;nr.varsResolver=tM;nr.displayName="@mantine/core/Tabs";nr.Tab=hg;nr.Panel=fg;nr.List=ug;const lu=ue(t=>b.jsx(ps,{component:"input",...q(["Input","InputWrapper","TextInput"],null,t),__staticSelector:"TextInput"}));lu.classes=ps.classes;lu.displayName="@mantine/core/TextInput";function eU(t){return X({attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"},child:[]}]})(t)}var nM=(t,e,n=!1)=>{let r=[];function o(i,s="--bn"){for(let l in i){let a=`${s}-${l.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`;typeof i[l]=="object"?o(i[l],a):(typeof i[l]=="number"&&(i[l]=`${i[l]}px`),n?e.style.removeProperty(a):e.style.setProperty(a,i[l].toString()))}}return o(t),r},E1=(t,e)=>nM(t,e),tU={colors:{editor:{text:void 0,background:void 0},menu:{text:void 0,background:void 0},tooltip:{text:void 0,background:void 0},hovered:{text:void 0,background:void 0},selected:{text:void 0,background:void 0},disabled:{text:void 0,background:void 0},shadow:void 0,border:void 0,sideMenu:void 0,highlights:{gray:{text:void 0,background:void 0},brown:{text:void 0,background:void 0},red:{text:void 0,background:void 0},orange:{text:void 0,background:void 0},yellow:{text:void 0,background:void 0},green:{text:void 0,background:void 0},blue:{text:void 0,background:void 0},purple:{text:void 0,background:void 0},pink:{text:void 0,background:void 0}}},borderRadius:void 0,fontFamily:void 0},nU=t=>nM(tU,t,!0),rM=t=>b.jsxs(ys,{gap:0,className:"bn-tooltip",children:[b.jsx(Zn,{size:"sm",lineClamp:5,children:t.mainTooltip}),t.secondaryTooltip&&b.jsx(Zn,{size:"xs",lineClamp:5,children:t.secondaryTooltip})]}),vf=v.forwardRef((t,e)=>{let{className:n,children:r,mainTooltip:o,secondaryTooltip:i,icon:s,isSelected:l,isDisabled:a,onClick:c,label:d,variant:u,...f}=t;ce(f,!1);let[h,p]=v.useState(!1),m=r?b.jsx(In,{"aria-label":d,className:n,onMouseDown:g=>{bh()&&g.currentTarget.focus()},onClick:g=>{p(!0),c==null||c(g)},onPointerLeave:()=>p(!1),"aria-pressed":l,"data-selected":l||void 0,"data-test":o?o.slice(0,1).toLowerCase()+o.replace(/\s+/g,"").slice(1):void 0,size:u==="compact"?"compact-xs":"xs",disabled:a||!1,ref:e,...f,children:r}):b.jsx(xo,{className:n,"aria-label":d,onMouseDown:g=>{bh()&&g.currentTarget.focus()},onClick:g=>{p(!0),c==null||c(g)},onPointerLeave:()=>p(!1),"aria-pressed":l,"data-selected":l||void 0,"data-test":o?o.slice(0,1).toLowerCase()+o.replace(/\s+/g,"").slice(1):void 0,size:u==="compact"?20:30,disabled:a||!1,ref:e,...f,children:s});return o?b.jsx(ui,{disabled:h,withinPortal:!1,label:b.jsx(rM,{mainTooltip:o,secondaryTooltip:i}),children:m}):m}),rU=v.forwardRef((t,e)=>{let{className:n,text:r,icon:o,isSelected:i,mainTooltip:s,secondaryTooltip:l,onClick:a,onMouseEnter:c,...d}=t;ce(d,!1);let[u,f]=v.useState(!1),h=b.jsxs(Xl,{className:n,checked:i===!0,wrapperProps:{onMouseEnter:c,onMouseLeave:()=>f(!1),onClick:p=>{f(!0),a==null||a(p)}},variant:"light",icon:null,ref:e,children:[b.jsx("span",{children:o}),b.jsx("span",{children:r})]});return!s||u?h:b.jsx(ui,{refProp:"rootRef",withinPortal:!1,label:b.jsx(rM,{mainTooltip:s,secondaryTooltip:l}),children:h})}),oU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o),b.jsx(ut,{className:n,ref:e,children:r})}),iU=v.forwardRef((t,e)=>{let{className:n,children:r,headerText:o,selected:i,onFocus:s,onBlur:l,tabIndex:a,...c}=t;return ce(c,!1),b.jsxs(gs,{className:De(n,i?"selected":""),onFocus:s,onBlur:l,tabIndex:a,ref:e,children:[o&&b.jsx(Zn,{className:"bn-header-text",children:o}),r]})}),sU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o,!1),b.jsx(gs.Section,{className:n,ref:e,children:r})}),lU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o,!1),b.jsx(ru,{className:n,label:b.jsx(Zn,{children:r}),ref:e})}),aU=v.forwardRef((t,e)=>{let{authorInfo:n,timeString:r,edited:o,...i}=t,s=de();return ce(i,!1),n==="loading"?b.jsxs(ut,{children:[b.jsx(El,{height:24,width:24}),b.jsx("div",{children:b.jsx(El,{height:12,width:100})})]}):b.jsxs(ut,{children:[b.jsx(Yl,{src:n.avatarUrl,alt:n.username,radius:"xl",size:"sm",color:"initials"}),b.jsxs(Zn,{fz:"sm",fw:"bold",children:[n.username,b.jsxs(Zn,{fz:"xs",c:"dimmed",span:!0,ml:"xs",children:[r," ",o&&`(${s.comments.edited})`]})]})]})}),cU=v.forwardRef((t,e)=>{let{className:n,showActions:r,authorInfo:o,timeString:i,edited:s,actions:l,emojiPickerOpen:a,children:c,...d}=t,{hovered:u,ref:f}=EH(),h=tH([e,f]);return ce(d,!1),b.jsxs(ut,{pos:"relative",ref:h,className:n,children:[l&&(r===!0||r===void 0||r==="hover"&&u||a)?b.jsx(ut,{style:{position:"absolute",right:0,top:0,zIndex:10},children:l}):null,b.jsx(aU,{...t}),c]})}),dU=v.forwardRef((t,e)=>{let{className:n,autoFocus:r,onFocus:o,onBlur:i,editor:s,editable:l,...a}=t;ce(a,!1);let c=Rn();return b.jsx(oM,{autoFocus:r,className:n,editor:t.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:l,theme:c==null?void 0:c.colorSchemePreference,ref:e,onFocus:o,onBlur:i,children:b.jsx(i2,{formattingToolbar:uU})})}),uU=()=>b.jsx(o2,{blockTypeSelectItems:[],children:r2([]).filter(t=>t.key!=="nestBlockButton"&&t.key!=="unnestBlockButton")}),fU=v.forwardRef((t,e)=>{let{className:n,name:r,label:o,variant:i,icon:s,value:l,autoFocus:a,placeholder:c,disabled:d,onKeyDown:u,onChange:f,onSubmit:h,autoComplete:p,"aria-activedescendant":m,rightSection:g,...y}=t;return ce(y),b.jsx(lu,{size:"xs",className:De(n||"",i==="large"?"bn-mt-input-large":""),ref:e,name:r,label:o,leftSection:s,value:l,autoFocus:a,"data-autofocus":a?"true":void 0,rightSection:g,placeholder:c,disabled:d,onKeyDown:u,onChange:f,onSubmit:h,autoComplete:p,"aria-activedescendant":m})}),hU=v.createContext(void 0),pU=t=>{let{children:e,onOpenChange:n,position:r,sub:o,...i}=t;return ce(i),o?b.jsx(Re.Sub,{transitionProps:{duration:250,exitDelay:250},withinPortal:!1,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onChange:n,position:r,children:e}):b.jsx(Re,{withinPortal:!1,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onChange:n,position:r,returnFocus:!1,children:e})},mU=v.forwardRef((t,e)=>{let{className:n,children:r,icon:o,checked:i,subTrigger:s,onClick:l,...a}=t;return ce(a,!1),b.jsx(s?Re.Sub.Item:Re.Item,{className:n,ref:e,leftSection:o,rightSection:i?b.jsx(Jd,{size:10}):i===!1?b.jsx("div",{className:"bn-tick-space"}):null,onClick:l,...a,children:r})}),gU=t=>{let{children:e,sub:n,...r}=t;return ce(r),b.jsx(n?Re.Sub.Target:Re.Target,{children:e})},bU=v.forwardRef((t,e)=>{let{className:n,children:r,sub:o,...i}=t;ce(i);let s=v.useContext(hU);return b.jsx(o?Re.Sub.Dropdown:Re.Dropdown,{className:n,ref:e,onMouseOver:s==null?void 0:s.onMenuMouseOver,onMouseLeave:s==null?void 0:s.onMenuMouseLeave,children:r})}),yU=v.forwardRef((t,e)=>{let{className:n,...r}=t;return ce(r),b.jsx(Re.Divider,{className:n,ref:e})}),vU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o),b.jsx(Re.Label,{className:n,ref:e,children:r})}),wU=v.forwardRef((t,e)=>{let{className:n,children:r,icon:o,onClick:i,onDragEnd:s,onDragStart:l,draggable:a,label:c,...d}=t;return ce(d,!1),o?b.jsx(xo,{size:24,className:n,ref:e,onClick:i,onDragEnd:s,onDragStart:l,draggable:a,"aria-label":c,...d,children:o}):b.jsx(In,{className:n,ref:e,onClick:i,onDragEnd:s,onDragStart:l,draggable:a,"aria-label":c,...d,children:r})}),kU=v.forwardRef((t,e)=>{let{className:n,tabs:r,defaultOpenTab:o,openTab:i,setOpenTab:s,loading:l,...a}=t;return ce(a),b.jsx(ut,{className:n,ref:e,children:b.jsxs(nr,{value:i,defaultValue:o,onChange:s,children:[l&&b.jsx(ou,{visible:l}),b.jsx(nr.List,{children:r.map(c=>b.jsx(nr.Tab,{"data-test":`${c.name.toLowerCase()}-tab`,value:c.name,children:c.name},c.name))}),r.map(c=>b.jsx(nr.Panel,{value:c.name,children:c.tabPanel},c.name))]})})}),xU=v.forwardRef((t,e)=>{let{className:n,children:r,onClick:o,label:i,...s}=t;return ce(s),b.jsx(In,{size:"xs","aria-label":i,className:n,ref:e,onClick:o,...s,children:r})}),CU=v.forwardRef((t,e)=>{let{className:n,accept:r,value:o,placeholder:i,onChange:s,...l}=t;return ce(l),b.jsx(Qm,{size:"xs",className:n,ref:e,accept:r,value:o,placeholder:i,onChange:s,...l})}),SU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o),b.jsx("div",{className:n,ref:e,children:r})}),EU=v.forwardRef((t,e)=>{let{className:n,value:r,placeholder:o,onKeyDown:i,onChange:s,...l}=t;return ce(l),b.jsx(lu,{size:"xs","data-test":"embed-input",className:n,ref:e,value:r,placeholder:o,onKeyDown:i,onChange:s})}),MU=t=>{let{open:e,onOpenChange:n,position:r,portalRoot:o,children:i,...s}=t;return ce(s),b.jsx(wt,{middlewares:{size:{padding:20}},withinPortal:!!o,portalProps:o?{target:o}:void 0,opened:e,onChange:n,position:r,children:i})},TU=t=>{let{children:e,...n}=t;return ce(n),b.jsx(Km,{children:e})},AU=v.forwardRef((t,e)=>{let{className:n,children:r,variant:o,...i}=t;return ce(i),b.jsx(qd,{className:n,ref:e,children:r})}),NU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o,!1),b.jsx(ut,{align:"center",gap:0,className:n,ref:e,...o,children:r})}),RU=v.forwardRef((t,e)=>{let{className:n,children:r,icon:o,onClick:i,onDragEnd:s,onDragStart:l,draggable:a,label:c,...d}=t;return ce(d,!1),o?b.jsx(xo,{size:24,className:n,ref:e,onClick:i,onDragEnd:s,onDragStart:l,draggable:a,"aria-label":c,...d,children:o}):b.jsx(In,{className:n,ref:e,onClick:i,onDragEnd:s,onDragStart:l,draggable:a,"aria-label":c,...d,children:r})}),IU=v.forwardRef((t,e)=>{let{className:n,children:r,id:o,...i}=t;return ce(i),b.jsx(ys,{gap:0,className:n,ref:e,id:o,role:"listbox",children:r})}),OU=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o),b.jsx(ut,{className:n,ref:e,children:b.jsx(ut,{className:"bn-mt-suggestion-menu-item-title",children:r})})}),DU=v.forwardRef((t,e)=>{let{className:n,isSelected:r,onClick:o,item:i,id:s,...l}=t;ce(l);let a=v.useRef(null);return v.useEffect(()=>{!a.current||!r||h2(a.current,a.current.closest(".bn-suggestion-menu, #ai-suggestion-menu"))!=="none"&&a.current.scrollIntoView({block:"nearest"})},[r]),b.jsxs(ut,{gap:0,className:n,ref:Vd(e,a),id:s,role:"option",onMouseDown:c=>c.preventDefault(),onClick:o,"aria-selected":r||void 0,children:[i.icon&&b.jsx(ut,{className:"bn-mt-suggestion-menu-item-section","data-position":"left",children:i.icon}),b.jsxs(ys,{gap:0,className:"bn-mt-suggestion-menu-item-body",children:[b.jsx(Zn,{className:"bn-mt-suggestion-menu-item-title",children:i.title}),b.jsx(Zn,{className:"bn-mt-suggestion-menu-item-subtitle",children:i.subtext})]}),i.badge&&b.jsx(ut,{"data-position":"right",className:"bn-mt-suggestion-menu-item-section",children:b.jsx(Qd,{size:"xs",children:i.badge})})]})}),_U=v.forwardRef((t,e)=>{let{className:n,children:r,...o}=t;return ce(o),b.jsx(ut,{className:n,ref:e,children:r})}),PU=v.forwardRef((t,e)=>{let{className:n,...r}=t;return ce(r),b.jsx("div",{ref:e,children:b.jsx(mr,{className:n,type:"dots",size:16})})}),$U=v.forwardRef((t,e)=>{let{className:n,children:r,id:o,columns:i,...s}=t;return ce(s),b.jsx("div",{className:n,style:{gridTemplateColumns:`repeat(${i}, 1fr)`},ref:e,id:o,role:"grid",children:r})}),LU=v.forwardRef((t,e)=>{let{className:n,children:r,columns:o,...i}=t;return ce(i),b.jsx(ut,{className:n,style:{gridColumn:`1 / ${o+1}`},ref:e,children:b.jsx(ut,{className:"bn-mt-suggestion-menu-item-title",children:r})})}),BU=v.forwardRef((t,e)=>{let{className:n,isSelected:r,onClick:o,item:i,id:s,...l}=t;ce(l);let a=v.useRef(null);return v.useEffect(()=>{!a.current||!r||h2(a.current,a.current.closest(".bn-grid-suggestion-menu"))!=="none"&&a.current.scrollIntoView({block:"nearest"})},[r]),b.jsx("div",{className:n,ref:Vd(e,a),id:s,role:"option",onClick:o,"aria-selected":r||void 0,children:i.icon})}),jU=v.forwardRef((t,e)=>{let{className:n,children:r,columns:o,...i}=t;return ce(i),b.jsx("div",{style:{gridColumn:`1 / ${o+1}`},ref:e,children:b.jsx(mr,{className:n,type:"dots"})})}),VU=v.forwardRef((t,e)=>{let{children:n,className:r,onMouseDown:o,onClick:i,...s}=t;return ce(s,!1),b.jsx(In,{className:r,ref:e,onMouseDown:o,onClick:i,...s,children:n})}),HU=v.forwardRef((t,e)=>{let{className:n,children:r,draggable:o,onDragStart:i,onDragEnd:s,style:l,label:a,...c}=t;return ce(c,!1),b.jsx(In,{className:n,ref:e,"aria-label":a,draggable:o,onDragStart:i,onDragEnd:s,style:l,...c,children:r})}),wf=v.forwardRef((t,e)=>{let{className:n,children:r,onMouseEnter:o,onMouseLeave:i,variant:s,...l}=t;ce(l);let{ref:a,focused:c}=TH();return b.jsx(Ym,{className:n,ref:Vd(e,a,k2(c)),role:"toolbar",onMouseEnter:o,onMouseLeave:i,gap:s==="action-toolbar"?2:void 0,children:r})}),kf=v.forwardRef((t,e)=>{let{className:n,items:r,isDisabled:o,...i}=t;ce(i);let s=r.filter(l=>l.isSelected)[0];return s?b.jsxs(Re,{withinPortal:!1,transitionProps:{exitDuration:0},disabled:o,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},children:[b.jsx(Re.Target,{children:b.jsx(In,{onMouseDown:l=>{bh()&&l.currentTarget.focus()},leftSection:s.icon,rightSection:b.jsx(eU,{}),size:"xs",variant:"subtle",disabled:o,children:s.text})}),b.jsx(Re.Dropdown,{className:n,ref:e,children:r.map(l=>b.jsx(Re.Item,{onClick:l.onClick,leftSection:l.icon,rightSection:l.isSelected?b.jsx(Jd,{size:10,className:"bn-tick-icon"}):b.jsx("div",{className:"bn-tick-space"}),disabled:l.isDisabled,children:l.text},l.text))})]}):null}),FU={FormattingToolbar:{Root:wf,Button:vf,Select:kf},FilePanel:{Root:kU,Button:xU,FileInput:CU,TabPanel:SU,TextInput:EU},GridSuggestionMenu:{Root:$U,Item:BU,EmptyItem:LU,Loader:jU},LinkToolbar:{Root:wf,Button:vf,Select:kf},SideMenu:{Root:NU,Button:RU},SuggestionMenu:{Root:IU,Item:DU,EmptyItem:OU,Label:_U,Loader:PU},TableHandle:{Root:HU,ExtendButton:VU},Generic:{Badge:{Root:rU,Group:oU},Form:{Root:t=>b.jsx("div",{children:t.children}),TextInput:fU},Menu:{Root:pU,Trigger:gU,Dropdown:bU,Divider:yU,Label:vU,Item:mU,Button:wU},Popover:{Root:MU,Trigger:TU,Content:AU},Toolbar:{Root:wf,Button:vf,Select:kf}},Comments:{Comment:cU,Editor:dU,Card:iU,CardSection:sU,ExpandSectionsPrompt:lU}},oM=t=>{let{className:e,theme:n,editor:r,...o}=t,i=Rn(),s=d2(),l=(i==null?void 0:i.colorSchemePreference)||s,a=typeof n=="string"?n:l==="no-preference"?"light":l,c=v.useCallback(f=>{if(f&&(nU(f),typeof n=="object")){if("light"in n&&"dark"in n){E1(n[l==="dark"?"dark":"light"],f);return}E1(n,f);return}},[l,n]);v.useEffect(()=>{if(!r.portalElement)throw Error("Portal element not found");r.portalElement.setAttribute("data-mantine-color-scheme",a),c(r.portalElement)},[r,c,a]);let d=v.useContext(jm),u=b.jsx(ES.Provider,{value:FU,children:b.jsx(X6,{"data-mantine-color-scheme":a,className:De("bn-mantine",e||""),theme:typeof n=="object"?void 0:n,editor:r,...o,ref:c})});return d?u:b.jsx(T2,{withCssVariables:!1,getRootElement:()=>{},children:u})};const iM={width:{default:0},height:{default:0}};function sM({block:t,editor:e,minHeight:n,children:r}){const o=v.useRef(null),i=()=>{const s=o.current;if(!s)return;const l=s.getBoundingClientRect(),a=Math.round(l.width),c=Math.round(l.height);(a!==(t.props.width||0)||c!==(t.props.height||0))&&e.updateBlock(t.id,{props:{width:a,height:c}})};return b.jsx("div",{ref:o,contentEditable:!1,onMouseUp:i,className:"my-1 rounded-lg",style:{border:"1px solid var(--color-border-muted)",resize:"both",overflow:"auto",minHeight:n,minWidth:240,maxWidth:"100%",width:t.props.width||void 0,height:t.props.height||void 0},children:r})}function lM(){const{pageId:t,projectId:e}=jh(),[n,r]=v.useState([]),o=v.useCallback(()=>{xM(t).then(r)},[t]);v.useEffect(()=>{o()},[o]);const i=v.useCallback(async a=>{const c=await CM(e,{...a,page_id:t});return r(d=>[...d,c]),c},[e,t]),s=v.useCallback(async(a,c)=>{const d=await SM(a,c);r(u=>u.map(f=>f.id===a?d:f))},[]),l=v.useCallback(async a=>{await EM(a),r(c=>c.filter(d=>d.id!==a))},[]);return{items:n,reload:o,add:i,update:s,remove:l}}function zU(){const{t}=N1(),{openConvert:e}=jh(),{items:n,reload:r,add:o,update:i,remove:s}=lM(),[l,a]=v.useState(""),c=async()=>{const d=l.trim();d&&(a(""),await o({title:d}))};return b.jsxs(b.Fragment,{children:[n.map(d=>{const u=d.status==="done";return b.jsxs("div",{className:"group flex items-center gap-2 px-3 py-1.5",style:{borderBottom:"1px solid var(--color-border-muted)"},children:[b.jsx("button",{onClick:()=>i(d.id,{status:u?"pending":"done"}),className:"text-warm-400 hover:text-accent flex-shrink-0",children:u?b.jsx(RM,{size:16,className:"text-emerald-500"}):b.jsx(mM,{size:16})}),b.jsx("input",{defaultValue:d.title,onBlur:f=>{const h=f.target.value.trim();h&&h!==d.title&&i(d.id,{title:h})},onKeyDown:f=>{f.key==="Enter"&&f.target.blur()},className:`flex-1 bg-transparent text-sm outline-none ${u?"line-through text-warm-400":""}`,style:{color:u?void 0:"var(--color-text-primary)"}}),b.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[b.jsx("button",{title:t("planner.convertToTask"),onClick:()=>e(d,"todo",r),className:"p-1 text-warm-400 hover:text-warm-600",children:b.jsx(gM,{size:13})}),b.jsx("button",{title:t("planner.convertToSchedule"),onClick:()=>e(d,"schedule",r),className:"p-1 text-warm-400 hover:text-warm-600",children:b.jsx(bM,{size:13})}),b.jsx("button",{title:t("planner.convertToTerminal"),onClick:()=>e(d,"session",r),className:"p-1 text-warm-400 hover:text-warm-600",children:b.jsx(yM,{size:13})}),b.jsx("button",{title:t("planner.delete"),onClick:()=>s(d.id),className:"p-1 text-warm-400 hover:text-red-500",children:b.jsx(vM,{size:13})})]})]},d.id)}),b.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",children:[b.jsx(wM,{size:15,className:"text-warm-400 flex-shrink-0"}),b.jsx("input",{value:l,onChange:d=>a(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),c())},onBlur:c,placeholder:t("planner.block.addTask"),className:"flex-1 bg-transparent text-sm outline-none placeholder:text-warm-300",style:{color:"var(--color-text-primary)"}})]})]})}const UU=f2({type:"tasklist",propSchema:iM,content:"none"},{render:({block:t,editor:e})=>b.jsx(sM,{block:t,editor:e,minHeight:120,children:b.jsx(zU,{})})});function WU(){const{openConvert:t,existingTags:e}=jh(),{items:n,reload:r,add:o,remove:i}=lM(),s=v.useMemo(()=>new Map(e.map(l=>[l.name,l.color])),[e]);return b.jsx(kM,{view:"month",items:n,tagColors:s,onQuickAdd:l=>o({title:"New task",due_date:l}),onEditItem:()=>{},onConvert:(l,a)=>t(l,a,r),onDeleteItem:l=>i(l)})}const qU=f2({type:"calendar",propSchema:iM,content:"none"},{render:({block:t,editor:e})=>b.jsx(sM,{block:t,editor:e,minHeight:320,children:b.jsx(WU,{})})}),GU=ym.create({blockSpecs:{...DC,tasklist:UU(),calendar:qU()}});function ZU(){const[t,e]=v.useState(()=>document.documentElement.dataset.theme==="dark"?"dark":"light");return v.useEffect(()=>{const n=new MutationObserver(()=>{e(document.documentElement.dataset.theme==="dark"?"dark":"light")});return n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>n.disconnect()},[]),t}function KU(t){if(t)try{const e=JSON.parse(t);return Array.isArray(e)&&e.length>0?e:void 0}catch{return}}function JU({initialContent:t,onChange:e}){const{t:n}=N1(),r=ZU(),o=Nm({schema:GU,initialContent:KU(t)}),i=s=>{const l=o.getTextCursorPosition().block;o.replaceBlocks([l],[{type:s},{type:"paragraph"}])};return b.jsx(oM,{editor:o,theme:r,slashMenu:!1,onChange:()=>e(JSON.stringify(o.document)),children:b.jsx(c2,{triggerCharacter:"/",getItems:async s=>OC([...a2(o),{title:n("planner.block.tasklist"),aliases:["todo","task","tasklist","할일","체크리스트"],group:n("planner.title"),onItemClick:()=>i("tasklist")},{title:n("planner.block.calendar"),aliases:["calendar","cal","캘린더","달력"],group:n("planner.title"),onItemClick:()=>i("calendar")}],s)})})}const mW=Object.freeze(Object.defineProperty({__proto__:null,default:JU},Symbol.toStringTag,{value:"Module"}));export{de as B,De as D,MS as G,Nm as K,ne as M,Se as N,Fe as P,W as T,ht as U,AS as Z,mW as a,jo as f,Hn as o,TS as q,ri as s,vV as t,Pr as v,Y as z};