@juki-team/base-ui 1.4.129 → 1.4.135
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.
- package/dist/esm/{ArrowForwardIcon-IN9agpuQ.js → ArrowForwardIcon-9VrCQrla.js} +1 -1
- package/dist/esm/{BarChart-BnEygCik.js → BarChart-BYCvk2RN.js} +1 -1
- package/dist/esm/{CartesianChart-46JvJlt2.js → CartesianChart-D1L2w_VG.js} +1 -1
- package/dist/esm/{ChangePasswordModal-W7o3d5xv.js → ChangePasswordModal-DOBon_ok.js} +1 -1
- package/dist/esm/{CodeEditor-btUZu2Dy.js → CodeEditor-B6YXqauq.js} +1 -1
- package/dist/esm/{DataGrid-C-1PcbQ9.js → DataGrid-Dy2MSOK0.js} +1 -1
- package/dist/esm/{DataViewer-DdoMfhBT.js → DataViewer-DebzEZj0.js} +1 -1
- package/dist/esm/{DrawerView-C59g89Qq.js → DrawerView-C6KbvsgW.js} +1 -1
- package/dist/esm/{ExcalidrawButton-7RauNqcW.js → ExcalidrawButton-rCOaM390.js} +1 -1
- package/dist/esm/{GraphvizViewer-Cdd3s9Pz.js → GraphvizViewer-DQ_3zkqP.js} +1 -1
- package/dist/esm/{ImageLoaderCropper-By7-NpjH.js → ImageLoaderCropper-DCPp73Ao.js} +1 -1
- package/dist/esm/{InputCellPhoneNumber-BoliLbve.js → InputCellPhoneNumber-UNqdq7Va.js} +1 -1
- package/dist/esm/{InputColor-B6fjWGPV.js → InputColor-DLE6PJz7.js} +1 -1
- package/dist/esm/{LineChart-yzQzjap8.js → LineChart-DxN-I5Kl.js} +1 -1
- package/dist/esm/{MdMath-DcAukZc5.js → MdMath-BQs4hBpa.js} +1 -1
- package/dist/esm/{MdMathEditor-Ckf7tXlp.js → MdMathEditor-BHfoWvp_.js} +1 -1
- package/dist/esm/{Popover-DOgPkWfK.js → Popover-CIsKcwr_.js} +2 -2
- package/dist/esm/{ReplyIcon-DrZrr78M.js → ReplyIcon-rPXXCIKg.js} +1 -1
- package/dist/esm/{SettingsIcon-DM1F7UIb.js → SettingsIcon-DnAtSsRm.js} +1 -1
- package/dist/esm/{SlideDeck-yImvO_hq.js → SlideDeck-c69qGz1J.js} +1 -1
- package/dist/esm/{TableOfContents-KP3dhzIR.js → TableOfContents-CL2MOKlA.js} +1 -1
- package/dist/esm/{TextHeadCell-CtlRYJ1U.js → TextHeadCell-CExu2jw7.js} +1 -1
- package/dist/esm/{Tooltip-CQx5RC2x.js → Tooltip-C-DKzZ8R.js} +1 -1
- package/dist/esm/{UserCodeEditor-DVycUyoi.js → UserCodeEditor-CAg3dvAT.js} +2 -2
- package/dist/esm/{ViewModuleIcon-CBJGd2NB.js → ViewModuleIcon-B7qvToID.js} +1 -1
- package/dist/esm/{VirtualizedRowsFixed-CJRctik-.js → VirtualizedRowsFixed-Bks5JFSx.js} +1 -1
- package/dist/esm/{WorksheetAsSlides-33duB_50.js → WorksheetAsSlides-B1YaxqYO.js} +1 -1
- package/dist/esm/{WorksheetBodies-Ptk1_moK.js → WorksheetBodies-BnGXG6wi.js} +1 -1
- package/dist/esm/{WorksheetContents-WKXb5Uk4.js → WorksheetContents-CJbNoWXT.js} +1 -1
- package/dist/esm/{WorksheetEditor-z9ucL22I.js → WorksheetEditor-B37fFHcY.js} +1 -1
- package/dist/esm/{WorksheetNode-DdlERlmz.js → WorksheetNode-DjqZZQRs.js} +1 -1
- package/dist/esm/{WorksheetViewer-C8lplKFc.js → WorksheetViewer-DE_XAr2A.js} +1 -1
- package/dist/esm/{architectureDiagram-3BPJPVTR-mkUe-O1b.js → architectureDiagram-3BPJPVTR-DaZ9rWVO.js} +1 -1
- package/dist/esm/{blockDiagram-GPEHLZMM-DI6f452i.js → blockDiagram-GPEHLZMM-CgMTM8qx.js} +1 -1
- package/dist/esm/{c4Diagram-AAUBKEIU-CprJ4eDK.js → c4Diagram-AAUBKEIU-DF5dBD4X.js} +1 -1
- package/dist/esm/channel-DtX7K8fH.js +1 -0
- package/dist/esm/{chunk-2J33WTMH-CRrW12Q1.js → chunk-2J33WTMH-BSF8-_lr.js} +1 -1
- package/dist/esm/{chunk-4BX2VUAB-DP1enpjM.js → chunk-4BX2VUAB-DLCx-_ir.js} +1 -1
- package/dist/esm/{chunk-55IACEB6-Qy7BShb8.js → chunk-55IACEB6-Ce1Mc1lZ.js} +1 -1
- package/dist/esm/{chunk-727SXJPM-DCaL4Ssn.js → chunk-727SXJPM-Cc0QJGYk.js} +1 -1
- package/dist/esm/{chunk-AQP2D5EJ-MvQ9vOa8.js → chunk-AQP2D5EJ-D7lU0Qk0.js} +1 -1
- package/dist/esm/{chunk-FMBD7UC4-C_QBV__I.js → chunk-FMBD7UC4-BGLWSSaQ.js} +1 -1
- package/dist/esm/{chunk-ND2GUHAM-Cz6MG9Ip.js → chunk-ND2GUHAM-BD5ZdCjv.js} +1 -1
- package/dist/esm/{chunk-QZHKN3VN-CNeKC3i9.js → chunk-QZHKN3VN-aadBLkdn.js} +1 -1
- package/dist/esm/{classDiagram-4FO5ZUOK-CIl1HCsD.js → classDiagram-4FO5ZUOK-B6nVlqWv.js} +1 -1
- package/dist/esm/{classDiagram-v2-Q7XG4LA2-CIl1HCsD.js → classDiagram-v2-Q7XG4LA2-B6nVlqWv.js} +1 -1
- package/dist/esm/{contest--aeYKKxf.js → contest-hvD3tLnF.js} +1 -1
- package/dist/esm/{cose-bilkent-S5V4N54A-BU_DfNnH.js → cose-bilkent-S5V4N54A-C1xAVZwJ.js} +1 -1
- package/dist/esm/{dagre-BM42HDAG-B0jhlami.js → dagre-BM42HDAG-BTH23OkS.js} +1 -1
- package/dist/esm/{diagram-2AECGRRQ-BoG6bCz0.js → diagram-2AECGRRQ-s_eIY8Ju.js} +1 -1
- package/dist/esm/{diagram-5GNKFQAL-CmPEF4Gb.js → diagram-5GNKFQAL-BQ7iPFrS.js} +1 -1
- package/dist/esm/{diagram-KO2AKTUF-otFu6fY1.js → diagram-KO2AKTUF-BwauQwgA.js} +1 -1
- package/dist/esm/{diagram-LMA3HP47-BNvQPERF.js → diagram-LMA3HP47-VgneUbzF.js} +1 -1
- package/dist/esm/{diagram-OG6HWLK6-GT5ck18c.js → diagram-OG6HWLK6-CQXmLp-X.js} +1 -1
- package/dist/esm/{erDiagram-TEJ5UH35-DOTojUvv.js → erDiagram-TEJ5UH35-BrtUM8g8.js} +1 -1
- package/dist/esm/{flowDiagram-I6XJVG4X-DMNWQIoP.js → flowDiagram-I6XJVG4X-BVuY5iRd.js} +1 -1
- package/dist/esm/{ganttDiagram-6RSMTGT7-UueSCT2P.js → ganttDiagram-6RSMTGT7-Dp3J7m4L.js} +1 -1
- package/dist/esm/{gitGraphDiagram-PVQCEYII-BMejzE3B.js → gitGraphDiagram-PVQCEYII-DDvUv1py.js} +1 -1
- package/dist/esm/helpers.js +1 -1
- package/dist/esm/{index-CroDROK5.js → index-B8yg8iZ5.js} +1 -1
- package/dist/esm/{index-2vw3cISu.js → index-CCoeYJCH.js} +1 -1
- package/dist/esm/{index-CCC14puG.js → index-CICkoZjG.js} +1 -1
- package/dist/esm/{index-P3Cb0cjc.js → index-DUSXBI7E.js} +1 -1
- package/dist/esm/index-DoTjNc47.js +2 -0
- package/dist/esm/{infoDiagram-5YYISTIA-BSxjrZJf.js → infoDiagram-5YYISTIA-D0QNaNgu.js} +1 -1
- package/dist/esm/{ishikawaDiagram-YF4QCWOH-B2-9liDF.js → ishikawaDiagram-YF4QCWOH-C5VX82DI.js} +1 -1
- package/dist/esm/{journeyDiagram-JHISSGLW-DBQd4ic_.js → journeyDiagram-JHISSGLW-BVEghM8I.js} +1 -1
- package/dist/esm/{kanban-definition-UN3LZRKU-DFolGaRv.js → kanban-definition-UN3LZRKU-2IZxapBL.js} +1 -1
- package/dist/esm/main.js +1 -1
- package/dist/esm/{mermaid.core-EsBL2ECN.js → mermaid.core-DoQpgFF5.js} +1 -1
- package/dist/esm/{mindmap-definition-RKZ34NQL-BIQZzlCy.js → mindmap-definition-RKZ34NQL-D-7AMujv.js} +1 -1
- package/dist/esm/{pieDiagram-4H26LBE5-DZBAcvRC.js → pieDiagram-4H26LBE5-mrgU3sOl.js} +1 -1
- package/dist/esm/{quadrantDiagram-W4KKPZXB-b5MVV3Rk.js → quadrantDiagram-W4KKPZXB-O8NSasGc.js} +1 -1
- package/dist/esm/{requirementDiagram-4Y6WPE33-CLn9X-PZ.js → requirementDiagram-4Y6WPE33-CQHcM086.js} +1 -1
- package/dist/esm/{sankeyDiagram-5OEKKPKP-D4-b_g7U.js → sankeyDiagram-5OEKKPKP-DFihOSab.js} +1 -1
- package/dist/esm/{sequenceDiagram-3UESZ5HK-CCdY9Q3W.js → sequenceDiagram-3UESZ5HK-CR8iCSRR.js} +1 -1
- package/dist/esm/server.js +1 -1
- package/dist/esm/settings.js +1 -1
- package/dist/esm/{stateDiagram-AJRCARHV-BSMAHoem.js → stateDiagram-AJRCARHV-CRmD_B8Z.js} +1 -1
- package/dist/esm/{stateDiagram-v2-BHNVJYJU-BeJ_O1Tl.js → stateDiagram-v2-BHNVJYJU-BQMQV-zB.js} +1 -1
- package/dist/esm/{timeline-definition-PNZ67QCA-o-UlOwfU.js → timeline-definition-PNZ67QCA-BSXJOTVE.js} +1 -1
- package/dist/esm/{types-TNt9NcVE.js → types-DYOIqA8v.js} +1 -1
- package/dist/esm/{vennDiagram-CIIHVFJN-CySj1ueN.js → vennDiagram-CIIHVFJN-BGumey1i.js} +1 -1
- package/dist/esm/{wardleyDiagram-YWT4CUSO-B7YSHlE3.js → wardleyDiagram-YWT4CUSO-CXmvZufs.js} +1 -1
- package/dist/esm/{xychartDiagram-2RQKCTM6-D6EqpoC5.js → xychartDiagram-2RQKCTM6-DZBDvK3P.js} +1 -1
- package/dist/module-types/src/components/helpers/problem.d.ts +11 -0
- package/dist/module-types/src/components/hooks/useJukiUser.d.ts +1 -4
- package/dist/module-types/src/components/organisms/MdMathViewer/types.d.ts +0 -8
- package/dist/module-types/src/settings/ApiManager.d.ts +1 -5
- package/package.json +3 -3
- package/dist/esm/channel-B3QafhkE.js +0 -1
- package/dist/esm/index-MXDpbG5L.js +0 -2
- package/dist/module-types/src/components/organisms/MdMathViewer/MemoMdMath.deprecated.d.ts +0 -3
- package/dist/module-types/src/components/organisms/MdMathViewer/MemoMdMathViewer.deprecated.d.ts +0 -2
- package/dist/module-types/src/components/organisms/_layz_/MdMathEditor/MdMathEditor.deprecated.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{a5 as n,o as r,e as o,f as i,l as s,C as a,c as l,b as c,J as d,a6 as u,a8 as h,X as p,Z as f,_ as m,O as g,K as v,a2 as y,aj as w,z as b,q as x,s as k,n as C,ad as S,y as M,W as N,Y as E,t as O,B as T,af as A,$ as D,R as I,v as _,a9 as R,aa as B,a4 as L,F as P,p as z}from"./light-CK5396YO.js";import{l as j,m as V,i as H,j as $,u as q,F,n as W,A as U,x as G,D as K,S as J,E as Z,v as Y,o as X,w as Q,C as ee}from"./types-TNt9NcVE.js";import te,{useRef as ne,useState as re,useMemo as oe,createContext as ie,useContext as se,useCallback as ae,useLayoutEffect as le,useEffect as ce,useImperativeHandle as de,memo as ue}from"react";import{dd as he,cW as pe,dk as fe,dg as me,aq as ge,b4 as ve,ba as ye,L as we,X as be}from"./index-MXDpbG5L.js";import{R as xe,i as ke,l as Ce,t as Se}from"./ViewModuleIcon-CBJGd2NB.js";import{C as Me,d as Ne,i as Ee}from"./index-P3Cb0cjc.js";import{c as Oe}from"./clsx-BeLtu-UY.js";import{p as Te}from"./purify.es-J-_UhghA.js";import{c as Ae,f as De,o as Ie,s as _e,b as Re}from"./floating-ui.dom-D1Wb0QDy.js";import{t as Be,d as Le}from"./throttle-_MCmQvyw.js";import{v as Pe,g as ze,c as je}from"./isSymbol-BuOnvf7n.js";import{c as Ve,i as He}from"./toNumber-DP6YK8S3.js";import{i as $e}from"./viz-BjPw9uNj.js";import{am as qe}from"./mermaid.core-EsBL2ECN.js";import{S as Fe,B as We}from"./contest--aeYKKxf.js";import{v as Ue}from"./worksheet-BBAH_yZC.js";import{i as Ge,T as Ke}from"./index-Dwi3ag-n.js";import{C as Je}from"./settings-DgLs6IK_.js";import"./enums.js";import"./date-D28INXpp.js";import"motion/react";import"react-dom";import"./time-BHcZPeyw.js";import"swr";import"@ably/spaces";import"@ably/spaces/react";import"ably";import"ably/liveobjects";import"ably/react";import"@ably/spaces/dist/mjs/react";import"./string-CQk_HvWX.js";const Ze={}.hasOwnProperty;function Ye(e,t){let n,r=-1;if(t.extensions)for(;++r<t.extensions.length;)Ye(e,t.extensions[r]);for(n in t)if(Ze.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":Xe(e[n],t[n]);break;case"handlers":Qe(e[n],t[n]);break;default:e.options[n]=t[n]}return e}function Xe(e,t){t&&e.push(...t)}function Qe(e,t){t&&Object.assign(e,t)}const et=[function(e,t,n,r){if("code"===t.type&&j(t,r)&&("list"===e.type||e.type===t.type&&j(e,r)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&V(t,r)))return;return n.spread?1:0}}];const tt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],nt=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:tt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:tt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:tt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"~"}];function rt(e){return e.label||!e.identifier?e.label||"":H(e.identifier)}function ot(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function it(e,t,n,r){let o=r.join.length;for(;o--;){const i=r.join[o](e,t,n,r);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const st=/\r?\n|\r/g;function at(e,t){const n=[];let r,o=0,i=0;for(;r=st.exec(e);)s(e.slice(o,r.index)),n.push(r[0]),o=r.index+r[0].length,i++;return s(e.slice(o)),n.join("");function s(e){n.push(t(e,i,!e))}}function lt(e,t){return e-t}function ct(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=e+t;let s,a=-1,l=0;for(;s=n.exec(i);)r.push(s.index);for(;++a<r.length;)l!==r[a]&&o.push(e.slice(l,r[a])),o.push("\\"),l=r[a];return o.push(e.slice(l)),o.join("")}function dt(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,o=n.line||1,i=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return o+=n.length-1,i=1===n.length?i+s.length:1+s.length+r,t},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(e){r+=e}}}function ut(e,t){const n={associationId:rt,containerPhrasing:mt,containerFlow:gt,createTracker:dt,compilePattern:ot,enter:function(e){return n.stack.push(e),function(){n.stack.pop()}},handlers:{...W},handle:void 0,indentLines:at,indexStack:[],join:[...et],options:{},safe:vt,stack:[],unsafe:[...nt]};Ye(n,t||{}),n.options.tightDefinitions&&n.join.push(ft),n.handle=F("type",{invalid:ht,unknown:pt,handlers:n.handlers});let r=n.handle(e,void 0,n,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return r&&10!==r.charCodeAt(r.length-1)&&13!==r.charCodeAt(r.length-1)&&(r+="\n"),r}function ht(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function pt(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function ft(e,t){if("definition"===e.type&&e.type===t.type)return 0}function mt(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=[];let s,a=-1,l=n.before;r.push(-1);let c=t.createTracker(n);for(;++a<o.length;){const d=o[a];let u;if(r[r.length-1]=a,a+1<o.length){let n=t.handle.handlers[o[a+1].type];n&&n.peek&&(n=n.peek),u=n?n(o[a+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else u=n.after;i.length>0&&("\r"===l||"\n"===l)&&"html"===d.type&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=t.createTracker(n),c.move(i.join("")));let h=t.handle(d,e,t,{...c.current(),after:u,before:l});s&&s===h.slice(0,1)&&(h=$(s.charCodeAt(0))+h.slice(1));const p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,p&&(i.length>0&&p.before&&l===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+$(l.charCodeAt(0))),p.after&&(s=u)),c.move(h),i.push(h),l=h.slice(-1)}return r.pop(),i.join("")}(e,this,t)}function gt(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=t.createTracker(n),s=[];let a=-1;for(r.push(-1);++a<o.length;){const n=o[a];r[r.length-1]=a,s.push(i.move(t.handle(n,e,t,{before:"\n",after:"\n",...i.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),a<o.length-1&&s.push(i.move(it(n,o[a+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function vt(e,t){return function(e,t,n){const r=(n.before||"")+(t||"")+(n.after||""),o=[],i=[],s={};let a=-1;for(;++a<e.unsafe.length;){const t=e.unsafe[a];if(!q(e.stack,t))continue;const n=e.compilePattern(t);let i;for(;i=n.exec(r);){const e="before"in t||Boolean(t.atBreak),n="after"in t,r=i.index+(e?i[1].length:0);o.includes(r)?(s[r].before&&!e&&(s[r].before=!1),s[r].after&&!n&&(s[r].after=!1)):(o.push(r),s[r]={before:e,after:n})}}o.sort(lt);let l=n.before?n.before.length:0;const c=r.length-(n.after?n.after.length:0);for(a=-1;++a<o.length;){const e=o[a];e<l||e>=c||e+1<c&&o[a+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||o[a-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(l!==e&&i.push(ct(r.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(i.push($(r.charCodeAt(e))),l++):i.push("\\"))}return i.push(ct(r.slice(l,c),n.after)),i.join("")}(this,e,t)}var yt=function(e){return e.docTypeError="docTypeError",e.contextNotFound="contextNotFound",e.timerNotFound="timerNotFound",e.ctxCallOutOfScope="ctxCallOutOfScope",e.createNodeInParserFail="createNodeInParserFail",e.stackOverFlow="stackOverFlow",e.parserMatchError="parserMatchError",e.serializerMatchError="serializerMatchError",e.getAtomFromSchemaFail="getAtomFromSchemaFail",e.expectDomTypeError="expectDomTypeError",e.callCommandBeforeEditorView="callCommandBeforeEditorView",e.missingRootElement="missingRootElement",e.missingNodeInSchema="missingNodeInSchema",e.missingMarkInSchema="missingMarkInSchema",e.ctxNotBind="ctxNotBind",e.missingYjsDoc="missingYjsDoc",e.aiProviderError="aiProviderError",e.aiBuildContextError="aiBuildContextError",e}({}),wt=class extends Error{constructor(e,t,n){super(t,n),this.name="MilkdownError",this.code=e,void 0!==n?.cause&&(this.cause=n.cause)}},bt=(e,t)=>"function"==typeof t?"[Function]":t,xt=e=>JSON.stringify(e,bt);function kt(){return new wt(yt.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Ct(){return new wt(yt.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function St(e){return new wt(yt.expectDomTypeError,`Expect to be a dom, but get: ${xt(e)}.`)}function Mt(){return new wt(yt.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Nt(e){return new wt(yt.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Et(e){try{return xt(e)}catch{return"[Unserializable]"}}var Ot=class{constructor(){this.sliceMap=new Map,this.get=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw n="string"==typeof e?e:e.name,new wt(yt.contextNotFound,`Context "${n}" not found, do you forget to inject it?`);var n;return t},this.remove=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Tt=class{#e;#t;#n;constructor(e,t,n){this.#e=[],this.#n=()=>{this.#e.forEach(e=>e(this.#t))},this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){const t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},At=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw kt()}}create(e,t=this._defaultValue){return new Tt(e,t,this)}},Dt=(e,t)=>new At(e,t),It=class{#r;#o;#i;#s;#a;#l;#c;constructor(e,t,n){this.#s=new Set,this.#a=new Set,this.#l=new Map,this.#c=new Map,this.read=()=>({metadata:this.#r,injectedSlices:[...this.#s].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),consumedSlices:[...this.#a].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),recordedTimers:[...this.#l].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)})),waitTimers:[...this.#c].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)}))}),this.onRecord=e=>{this.#l.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#l.delete(e)},this.onDone=e=>{const t=this.#l.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{const n=Date.now();t.finally(()=>{this.#c.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#s.add(e)},this.onRemove=e=>{this.#s.delete(e)},this.onUse=e=>{this.#a.add(e)},this.#d=e=>this.#o.get(e).get(),this.#u=e=>this.#i.get(e).status,this.#o=e,this.#i=t,this.#r=n}#d;#u},_t=class e{#o;#i;#r;#h;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#o,this.#i,{...t}):this,this.inject=(e,t)=>{const n=e.create(this.#o.sliceMap);return null!=t&&n.set(t),this.#h?.onInject(e),this},this.remove=e=>(this.#o.remove(e),this.#h?.onRemove(e),this),this.record=e=>(e.create(this.#i.store),this.#h?.onRecord(e),this),this.clearTimer=e=>(this.#i.remove(e),this.#h?.onClear(e),this),this.isInjected=e=>this.#o.has(e),this.isRecorded=e=>this.#i.has(e),this.use=e=>(this.#h?.onUse(e),this.#o.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#i.get(e),this.done=e=>{this.timer(e).done(),this.#h?.onDone(e)},this.wait=e=>{const t=this.timer(e).start();return this.#h?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#o=t,this.#i=n,this.#r=r,r&&(this.#h=new It(t,n,r))}get meta(){return this.#r}get inspector(){return this.#h}},Rt=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw n=e.name,new wt(yt.timerNotFound,`Timer "${n}" not found, do you forget to record it?`);var n;return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},Bt=class{#p;#f;#m;#g;constructor(e,t){this.#p=null,this.#f=null,this.#g="pending",this.start=()=>(this.#p??=new Promise((e,t)=>{this.#f=t=>{t instanceof CustomEvent&&t.detail.id===this.#m&&(this.#g="resolved",this.#v(),t.stopImmediatePropagation(),e())},this.#y(()=>{"pending"===this.#g&&(this.#g="rejected"),this.#v(),t(new Error(`Timing ${this.type.name} timeout.`))}),this.#g="pending",addEventListener(this.type.name,this.#f)}),this.#p),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:this.#m}});dispatchEvent(e)},this.#v=()=>{this.#f&&removeEventListener(this.type.name,this.#f)},this.#y=e=>{setTimeout(()=>{e()},this.type.timeout)},this.#m=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#g}#v;#y},Lt=class{constructor(e,t=3e3){this.create=e=>new Bt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Pt=(e,t=3e3)=>new Lt(e,t);function zt(e){const t=this;t.compiler=function(n){return ut(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function jt(e){this.content=e}function Vt(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let e=0;o.text[e]==i.text[e];e++)n++;return n}if(o.content.size||i.content.size){let e=Vt(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Ht(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let e=Ht(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}jt.prototype={constructor:jt,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new jt(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new jt(n)},addToStart:function(e,t){return new jt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new jt(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new jt(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=jt.from(e)).size?new jt(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=jt.from(e)).size?new jt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=jt.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},jt.from=function(e){if(e instanceof jt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new jt(t)};let $t=class e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),n,r+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.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<t.content.length;i++)o.push(t.content[i]);return new e(o,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let r=[],o=0;if(n>t)for(let e=0,i=0;i<n;e++){let s=this.content[e],a=i+s.nodeSize;a>t&&((i<t||a>n)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,n-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,n-i-1))),r.push(s),o+=s.nodeSize),i=a}return new e(r,o)}cutByIndex(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new e(o,i)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Vt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ht(this,e,t,n)}findIndex(e){if(0==e)return Ft(0,e);if(e==this.size)return Ft(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?Ft(t+1,r):Ft(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let o=t[e];r+=o.nodeSize,e&&o.isText&&t[e-1].sameMarkup(o)?(n||(n=t.slice(0,e)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};$t.empty=new $t([],0);const qt={index:0,offset:0};function Ft(e,t){return qt.index=e,qt.offset=t,qt}function Wt(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Wt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Wt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Ut{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Ut.none;if(e instanceof Ut)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Ut.none=[];class Gt extends Error{}class Kt{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Zt(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new Kt(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Kt(Jt(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Kt.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Kt($t.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Kt(e,n,r)}}function Jt(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(o==t||i.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Jt(i.content,t-o-1,n-o-1)))}function Zt(e,t,n,r,o,i){let{index:s,offset:a}=e.findIndex(t),l=e.maybeChild(s);if(a==t||l.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Zt(l.content,t-a-1,n,0==s?r-1:0,s==e.childCount-1?o-1:0,l);return c&&e.replaceChild(s,l.copy(c))}function Yt(e,t,n){if(n.openStart>e.depth)throw new Gt("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Gt("Inconsistent open depths");return Xt(e,t,n,0)}function Xt(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=Xt(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy($t.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return rn(i,on(e,o,s,t,r))}{let r=e.parent,o=r.content;return rn(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return rn(i,sn(e,t,r))}function Qt(e,t){if(!t.type.compatibleContent(e.type))throw new Gt("Cannot join "+t.type.name+" onto "+e.type.name)}function en(e,t,n){let r=e.node(n);return Qt(r,t.node(n)),r}function tn(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function nn(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(tn(e.nodeAfter,r),i++));for(let e=i;e<s;e++)tn(o.child(e),r);t&&t.depth==n&&t.textOffset&&tn(t.nodeBefore,r)}function rn(e,t){return e.type.checkContent(t),e.copy(t)}function on(e,t,n,r,o){let i=e.depth>o&&en(e,t,o+1),s=r.depth>o&&en(n,r,o+1),a=[];return nn(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(Qt(i,s),tn(rn(i,on(e,t,n,r,o+1)),a)):(i&&tn(rn(i,sn(e,t,o+1)),a),nn(t,n,o,a),s&&tn(rn(s,sn(n,r,o+1)),a)),nn(r,null,o,a),new $t(a)}function sn(e,t,n){let r=[];if(nn(null,e,n,r),e.depth>n){tn(rn(en(e,t,n+1),sn(e,t,n+1)),r)}return nn(t,null,n,r),new $t(r)}Kt.empty=new Kt($t.empty,0,0);class an{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Ut.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new un(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new an(t,n,o)}static resolveCached(e,t){let n=dn.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else dn.set(e,n=new ln);let r=n.elts[n.i]=an.resolve(e,t);return n.i=(n.i+1)%cn,r}}class ln{constructor(){this.elts=[],this.i=0}}const cn=12,dn=new WeakMap;class un{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}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 hn=Object.create(null);class pn{constructor(e,t,n,r=Ut.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||$t.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Wt(this.attrs,t||e.defaultAttrs||hn)&&Ut.sameSet(this.marks,n||Ut.none)}copy(e=null){return e==this.content?this:new pn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Kt.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new Kt(a,r.depth-i,o.depth-i)}replace(e,t,n){return Yt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return an.resolveCached(this,e)}resolveNoCache(e){return an.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),mn(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=$t.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}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=Ut.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Ut.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=$t.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}}pn.prototype.text=void 0;let fn=class e extends pn{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):mn(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function mn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class gn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new vn(e,t);if(null==n.next)return gn.empty;let r=yn(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(Sn(e,0));function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);Sn(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new gn(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(Cn);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();o(i(e.expr,s),t),s=t}if(-1==e.max)o(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),o(i(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(e.exprs[r],t);if(r==e.exprs.length-1)return s;o(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function o(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return $t.from(s.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.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=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}gn.empty=new gn(!0);class vn{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function yn(e){let t=[];do{t.push(wn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function wn(e){let t=[];do{t.push(bn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function bn(e){let t=function(e){if(e.eat("(")){let t=yn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=kn(e,t)}return t}function xn(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function kn(e,t){let n=xn(e),r=n;return e.eat(",")&&(r="}"!=e.next?xn(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Cn(e,t){return t-e}function Sn(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Cn)}function Mn(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Nn(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function En(e,t,n,r){for(let r in t)if(!(r in e))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function On(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new An(e,r,t[r]);return n}let Tn=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=On(e,n.attrs),this.defaultAttrs=Mn(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==gn.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:Nn(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pn(this,this.computeAttrs(e),$t.from(t),Ut.setFrom(n))}createChecked(e=null,t,n){return t=$t.from(t),this.checkContent(t),new pn(this,this.computeAttrs(e),t,Ut.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=$t.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore($t.empty,!0);return o?new pn(this,e,t.append(o),Ut.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).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){En(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Ut.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,o)=>r[t]=new e(t,n,o));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 e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class An{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Dn{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=On(e,r.attrs),this.excluded=null;let o=Mn(this.attrs);this.instance=o?new Ut(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ut(this,Nn(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new Dn(e,r++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){En(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class In{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=jt.from(e.nodes),t.marks=jt.from(e.marks||{}),this.nodes=Tn.compile(this.spec.nodes,this),this.marks=Dn.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=gn.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?_n(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:_n(this,n.split(" "))}this.nodeFromJSON=e=>pn.fromJSON(this,e),this.markFromJSON=e=>Ut.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Tn))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new fn(n,n.defaultAttrs,e,Ut.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function _n(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Rn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Vn(this,t,!1);return n.addAll(e,Ut.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Vn(this,t,!0);return n.addAll(e,Ut.none,t.from,t.to),Kt.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Hn(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=$n(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=$n(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Rn(e,Rn.schemaRules(e)))}}const Bn={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},Ln={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pn={ol:!0,ul:!0};function zn(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class jn{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=Ut.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($t.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=$t.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($t.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Bn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Vn{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=zn(null,t.preserveWhitespace,0)|(n?4:0);r=o?new jn(o.type,o.attrs,Ut.none,!0,t.topMatch||o.type.contentMatch,i):new jn(n?null:e.schema.topNodeType,null,Ut.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Pn.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Pn.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Ln.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);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 n,r=this.needsBlock;if(Bn.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=a&&a.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+i)&&(r=a,o=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Ut.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):qn(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=zn(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=Ut.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):qn(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new jn(e,t,a,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Hn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function $n(e){let t={};for(let n in e)t[n]=e[n];return t}function qn(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Fn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Un(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Un(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Jn(Un(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Jn(Un(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:Jn(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Fn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Wn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Wn(e.marks)}}function Wn(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Un(e){return e.document||window.document}const Gn=new WeakMap;function Kn(e){let t=Gn.get(e);return void 0===t&&Gn.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function Jn(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Kn(r))&&o.indexOf(t)>-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,a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let l=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&l.style?l.style.cssText=c[e]:l.setAttribute(e,c[e])}}for(let o=d;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof i)l.appendChild(e.createTextNode(i));else{let{dom:t,contentDOM:o}=Jn(e,i,n,r);if(l.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:l,contentDOM:s}}const Zn=Math.pow(2,16);function Yn(e,t){return e+t*Zn}function Xn(e){return 65535&e}class Qn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class er{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&er.empty)return er.empty}recover(e){let t=0,n=Xn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Zn}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(e<=d){let o=a+r+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?a:d)?null:Yn(s/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new Qn(o,u,i)}r+=c-l}return n?e+r:new Qn(e+r,0,null)}touches(e,t){let n=0,r=Xn(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+o];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}}invert(){return new er(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?er.empty:new er(e<0?[0,-e,0]:[0,0,e])}}er.empty=new er([]);class tr{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new tr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new tr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new Qn(e,r,null)}}const nr=Object.create(null);class rr{getMap(){return er.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=nr[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in nr)throw new RangeError("Duplicate use of step JSON ID "+e);return nr[e]=t,t.prototype.jsonID=e,t}}class or{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new or(e,null)}static fail(e){return new or(null,e)}static fromReplace(e,t,n,r){try{return or.ok(e.replace(t,n,r))}catch(e){if(e instanceof Gt)return or.fail(e.message);throw e}}}function ir(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(ir(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return $t.fromArray(r)}class sr extends rr{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new Kt(ir(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return or.fromReplace(e,this.from,this.to,o)}invert(){return new ar(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new sr(t.pos,n.pos,this.mark)}merge(e){return e instanceof sr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new sr(t.from,t.to,e.markFromJSON(t.mark))}}rr.jsonID("addMark",sr);class ar extends rr{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Kt(ir(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return or.fromReplace(e,this.from,this.to,n)}invert(){return new sr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ar(t.pos,n.pos,this.mark)}merge(e){return e instanceof ar&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ar(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ar(t.from,t.to,e.markFromJSON(t.mark))}}rr.jsonID("removeMark",ar);class lr extends rr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return or.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return or.fromReplace(e,this.pos,this.pos+1,new Kt($t.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new lr(this.pos,t.marks[n]);return new lr(this.pos,this.mark)}}return new cr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new lr(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new lr(t.pos,e.markFromJSON(t.mark))}}rr.jsonID("addNodeMark",lr);class cr extends rr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return or.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return or.fromReplace(e,this.pos,this.pos+1,new Kt($t.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new lr(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new cr(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new cr(t.pos,e.markFromJSON(t.mark))}}rr.jsonID("removeNodeMark",cr);class dr extends rr{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&hr(e,this.from,this.to)?or.fail("Structure replace would overwrite content"):or.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new er([this.from,this.to-this.from,this.slice.size])}invert(e){return new dr(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&dr.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new dr(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof dr)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new dr(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new dr(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new dr(t.from,t.to,Kt.fromJSON(e,t.slice),!!t.structure)}}dr.MAP_BIAS=1,rr.jsonID("replace",dr);class ur extends rr{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(hr(e,this.from,this.gapFrom)||hr(e,this.gapTo,this.to)))return or.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return or.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?or.fromReplace(e,this.from,this.to,n):or.fail("Content does not fit in gap")}getMap(){return new er([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ur(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new ur(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ur(t.from,t.to,t.gapFrom,t.gapTo,Kt.fromJSON(e,t.slice),t.insert,!!t.structure)}}function hr(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function pr(e,t,n,r=n.contentMatch,o=!0){let i=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<i.childCount;t++){let l=i.child(t),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new ar(a,c,l.marks[t]));if(o&&l.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(l.text);)t||(t=new Kt($t.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new dr(a+e.index,a+e.index+e[0].length,t))}}else s.push(new dr(a,c,Kt.empty));a=c}if(!r.validEnd){let t=r.fillBefore($t.empty,!0);e.replace(a,a,new Kt(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function fr(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function mr(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,a,t))return n;if(0==n||i.type.spec.isolating||!fr(i,s,a))break;s&&(r=1),a<i.childCount&&(o=1)}return null}function gr(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<o;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return i?o.map(vr).concat({type:t,attrs:n}).concat(i.map(vr)):null}function vr(e){return{type:e,attrs:null}}function yr(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function wr(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function br(e,t,n=1,r){let o=e.resolve(t),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 e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function xr(e,t){let n=e.resolve(t),r=n.index();return o=n.nodeBefore,i=n.nodeAfter,!(!o||!i||o.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(o,i))&&n.parent.canReplace(r,r+1);var o,i}function kr(e,t,n=t,r=Kt.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Cr(o,i,r)?new dr(t,n,r):new Sr(o,i,r).fit()}function Cr(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}rr.jsonID("replaceAround",ur);class Sr{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=$t.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=$t.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new Kt(o,i,s);return e>-1?new ur(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new dr(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Er(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore($t.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(2==t&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Er(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Kt(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Er(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Kt(Mr(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Kt(Mr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=s.size+e-(i.content.size-i.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(d=t,c.push(Or(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let p=l==s.childCount;p||(h=-1),this.placed=Nr(this.placed,t,$t.from(c)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Kt.empty:new Kt(Mr(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Kt(Mr(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Tr(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Tr(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Tr(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Nr(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Nr(this.placed,this.depth,$t.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore($t.empty,!0);e.childCount&&(this.placed=Nr(this.placed,this.frontier.length,e))}}function Mr(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Mr(e.firstChild.content,t-1,n)))}function Nr(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Nr(e.lastChild.content,t-1,n)))}function Er(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Or(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Or(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore($t.empty,!0)))),e.copy(r)}function Tr(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Ar(e){return e.spec.defining||e.spec.definingForContent}function Dr(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(Dr(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore($t.empty,!0))}return e}function Ir(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class _r extends rr{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return or.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return or.fromReplace(e,this.pos,this.pos+1,new Kt($t.from(r),0,t.isLeaf?0:1))}getMap(){return er.empty}invert(e){return new _r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new _r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new _r(t.pos,t.attr,t.value)}}rr.jsonID("attr",_r);class Rr extends rr{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return or.ok(n)}getMap(){return er.empty}invert(e){return new Rr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Rr(t.attr,t.value)}}rr.jsonID("docAttr",Rr);let Br=class extends Error{};Br=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Br.prototype=Object.create(Error.prototype)).constructor=Br,Br.prototype.name="TransformError";class Lr{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Br(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,o,i)=>{e=Math.min(e,o),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Kt.empty){let r=kr(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Kt($t.from(n),0,0))}delete(e,t){return this.replace(e,t,Kt.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Cr(o,i,r))return e.step(new dr(t,n,r));let s=Ir(o,i);0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=Ar(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.openStart+1),u=c[a];if(u)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let h=o.node(c-1),p=o.index(c-1);if(h.canReplaceWith(p,p,u.type,u.marks))return e.replace(o.before(c),d?i.after(c):n,new Kt(Dr(r.content,0,r.openStart,a),a,r.openEnd))}}let u=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>u));a--){let e=s[a];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Kt($t.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){let i=r.sharedDepth(n),s=!1;for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=o.depth;e>0&&n==o.start(e);e--)n=o.before(e);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let i=Ir(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=$t.empty,u=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=$t.from(r.node(e).copy(d)),u++):l--;let h=$t.empty,p=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=$t.from(o.node(e).copy(h)),p++):c++;e.step(new ur(l,c,s,a,new Kt(d.append(h),u,p),d.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);wr(e,r.node(),r.before(),a)}s.inlineContent&&pr(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new dr(c,l.map(t+n,-1),Kt.empty,!0)),!0===r){let t=e.doc.resolve(c);yr(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=$t.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=$t.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new ur(o,i,o,i,new Kt(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&wr(e,t,n,i),pr(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new ur(l,c,l+1,c-1,new Kt($t.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&yr(e,t,n,i),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);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 e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ur(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Kt($t.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new _r(e,t,n)),this}setDocAttribute(e,t){return this.step(new Rr(e,t)),this}addNodeMark(e,t){return this.step(new lr(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Ut)t.isInSet(n.marks)&&this.step(new cr(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new cr(e,r)),o=r.removeFromSet(o);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),i=$t.empty,s=$t.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){i=$t.from(o.node(e).copy(i));let t=r&&r[a];s=$t.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new dr(t,t,new Kt(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=u:s.push(o=new ar(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new sr(c,u,r))}}),s.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof Dn){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&l.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,t),to:r,step:i})}}}),o.forEach(t=>e.step(new ar(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return pr(this,e,t,n),this}}const Pr=Object.create(null);class zr{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new jr(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Kt.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Kt.empty:t),0==s&&Jr(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Jr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new $r(e):Kr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Kr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Kr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ur(e.node(0))}static atStart(e){return Kr(e,e,0,0,1)||new Ur(e)}static atEnd(e){return Kr(e,e,e.content.size,e.childCount,-1)||new Ur(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Pr[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Pr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Pr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $r.between(this.$anchor,this.$head).getBookmark()}}zr.prototype.visible=!0;class jr{constructor(e,t){this.$from=e,this.$to=t}}let Vr=!1;function Hr(e){Vr||e.parent.inlineContent||(Vr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class $r extends zr{constructor(e,t=e){Hr(e),Hr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return zr.near(n);let r=e.resolve(t.map(this.anchor));return new $r(r.parent.inlineContent?r:n,n)}replace(e,t=Kt.empty){if(super.replace(e,t),t==Kt.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof $r&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new qr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new $r(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=zr.findFrom(t,n,!0)||zr.findFrom(t,-n,!0);if(!e)return zr.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(zr.findFrom(e,-n,!0)||zr.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new $r(e,t)}}zr.jsonID("text",$r);class qr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new qr(e.map(this.anchor),e.map(this.head))}resolve(e){return $r.between(e.resolve(this.anchor),e.resolve(this.head))}}class Fr extends zr{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?zr.near(o):new Fr(o)}content(){return new Kt($t.from(this.node),0,0)}eq(e){return e instanceof Fr&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wr(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Fr(e.resolve(t.anchor))}static create(e,t){return new Fr(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Fr.prototype.visible=!1,zr.jsonID("node",Fr);class Wr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new qr(n,n):new Wr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Fr.isSelectable(n)?new Fr(t):zr.near(t)}}class Ur extends zr{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Kt.empty){if(t==Kt.empty){e.delete(0,e.doc.content.size);let t=zr.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ur(e)}map(e){return new Ur(e)}eq(e){return e instanceof Ur}getBookmark(){return Gr}}zr.jsonID("all",Ur);const Gr={map(){return this},resolve:e=>new Ur(e)};function Kr(e,t,n,r,o,i=!1){if(t.inlineContent)return $r.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Fr.isSelectable(r))return Fr.create(e,n-(o<0?r.nodeSize:0))}else{let t=Kr(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Jr(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof dr||i instanceof ur)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==o&&(o=r)}),e.setSelection(zr.near(e.doc.resolve(o),n)))}class Zr extends Lr{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=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Ut.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ut.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(zr.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Yr(e,t){return t&&e?e.bind(t):e}class Xr{constructor(e,t,n){this.name=e,this.init=Yr(t.init,n),this.apply=Yr(t.apply,n)}}const Qr=[new Xr("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Xr("selection",{init:(e,t)=>e.selection||zr.atStart(t.doc),apply:e=>e.selection}),new Xr("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Xr("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class eo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qr.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Xr(e.key,e.spec.state,e))})}}class to{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new to(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Zr(this)}static create(e){let t=new eo(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new to(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new eo(this.schema,e.plugins),n=t.fields,r=new to(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new eo(e.schema,e.plugins),o=new to(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=pn.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=zr.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=a.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}}),o}}function no(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=no(o,t,{})),n[r]=o}return n}class ro{constructor(e){this.spec=e,this.props={},e.props&&no(e.props,this,this.props),this.key=e.key?e.key.key:io("plugin")}getState(e){return e[this.key]}}const oo=Object.create(null);function io(e){return e in oo?e+"$"+ ++oo[e]:(oo[e]=0,e+"$")}class so{constructor(e="key"){this.key=io(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ao=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const co=(e,t,n)=>{let r=lo(e,n);if(!r)return!1;let o=fo(r);if(!o){let n=r.blockRange(),o=n&&mr(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(wo(e,o,t,-1))return!0;if(0==r.parent.content.size&&(ho(i,"end")||Fr.isSelectable(i)))for(let n=r.depth;;n--){let s=kr(e.doc,r.before(n),r.after(n),Kt.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ho(i,"end")?zr.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Fr.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0)},uo=(e,t,n)=>{let r=lo(e,n);if(!r)return!1;let o=fo(r);return!!o&&function(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=e}let s=t.nodeAfter,a=s,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let c=kr(e.doc,i,l,Kt.empty);if(!c||c.from!=i||c instanceof dr&&c.slice.size>=l-i)return!1;if(n){let t=e.tr.step(c);t.setSelection($r.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,o,t)};function ho(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const po=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=fo(r)}let s=i&&i.nodeBefore;return!(!s||!Fr.isSelectable(s))&&(t&&t(e.tr.setSelection(Fr.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function fo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function mo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function go(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const vo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=go(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(zr.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0};const yo=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Fr&&e.selection.node.isBlock)return!(!n.parentOffset||!br(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,i,s=[],a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),i=go(n.node(e-1).contentMatchAt(n.indexAfter(e-1))),s.unshift(a&&i?{type:i}:null),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof $r||e.selection instanceof Ur)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=br(c.doc,d,s.length,s);if(u||(s[0]=i?{type:i}:null,u=br(c.doc,d,s.length,s)),!u)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0};function wo(e,t,n,r){let o,i,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!xr(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,i=$t.empty;for(let e=o.length-1;e>=0;e--)i=$t.from(o[e].create(null,i));i=$t.from(s.copy(i));let l=e.tr.step(new ur(t.pos-1,r,t.pos,r,new Kt(i,1,0),o.length,!0)),c=l.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&xr(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:zr.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),h=u&&mr(u);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(u,h).scrollIntoView()),!0;if(c&&ho(a,"start",!0)&&ho(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=$t.empty;for(let e=o.length-1;e>=0;e--)r=$t.from(o[e].copy(r));n(e.tr.step(new ur(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Kt(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function bo(e){return function(t,n){let r=t.selection,o=e<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(t.tr.setSelection($r.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const xo=bo(-1),ko=bo(1);function Co(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&gr(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function So(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function Mo(e,t=null,n){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r<t.length;r++){let{$from:o,$to:i}=t[r],s=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.pos,i.pos,(e,t)=>{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}(n.doc,s,e))return!1;if(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o,i=n.tr;o=!s.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e));for(let n=0;n<s.length;n++){let{$from:r,$to:a}=s[n];if(o){let n=r.pos,o=a.pos,s=r.nodeAfter,l=a.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+c<o&&(n+=c,o-=d),i.addMark(n,o,e.create(t))}else i.removeMark(r.pos,a.pos,e)}r(i.scrollIntoView())}return!0}}function No(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Eo=No(ao,co,po),Oo=No(ao,(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;let o=mo(r);if(!o)return!1;let i=o.nodeAfter;if(wo(e,o,t,1))return!0;if(0==r.parent.content.size&&(ho(i,"start")||Fr.isSelectable(i))){let n=kr(e.doc,r.before(),r.after(),Kt.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(ho(i,"start")?zr.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Fr.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=mo(r)}let s=i&&i.nodeAfter;return!(!s||!Fr.isSelectable(s))&&(t&&t(e.tr.setSelection(Fr.create(e.doc,i.pos)).scrollIntoView()),!0)});const To={Enter:No((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Ur||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=go(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection($r.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(br(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&mr(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)},yo),"Mod-Enter":vo,Backspace:Eo,"Mod-Backspace":Eo,"Shift-Backspace":Eo,Delete:Oo,"Mod-Delete":Oo,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Ur(e.doc))),!0)},Ao={"Ctrl-h":To.Backspace,"Alt-Backspace":To["Mod-Backspace"],"Ctrl-d":To.Delete,"Ctrl-Alt-Backspace":To["Mod-Delete"],"Alt-Delete":To["Mod-Delete"],"Alt-d":To["Mod-Delete"],"Ctrl-a":xo,"Ctrl-e":ko};for(let e in To)Ao[e]=To[e];const Do=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Ao:To;class Io{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,o){let i=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let r=(n+=e)-o;r>0&&(i=t[0].slice(e-r,e)+i,n=o)}return e.tr.insertText(i,n,o)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const _o=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function Ro(e,t,n=null,r){return new Io(e,(e,o,i,s)=>{let a=n instanceof Function?n(o):n,l=e.tr.delete(i,s),c=l.doc.resolve(i).blockRange(),d=c&&gr(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(i-1).nodeBefore;return u&&u.type==t&&xr(l.doc,i-1)&&(!r||r(o,u))&&l.join(i-1),l})}function Bo(e,t,n=null){return new Io(e,(e,r,o,i)=>{let s=e.doc.resolve(o),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,a):null})}new Io(/--$/,"—",{inCodeMark:!1}),new Io(/\.\.\.$/,"…",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new Io(/"$/,"”",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new Io(/'$/,"’",{inCodeMark:!1});const Lo="undefined"!=typeof navigator?navigator:null,Po="undefined"!=typeof document?document:null,zo=Lo&&Lo.userAgent||"",jo=/Edge\/(\d+)/.exec(zo),Vo=/MSIE \d/.exec(zo),Ho=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zo),$o=!!(Vo||Ho||jo),qo=Vo?document.documentMode:Ho?+Ho[1]:jo?+jo[1]:0,Fo=!$o&&/gecko\/(\d+)/i.test(zo),Wo=Fo&&+(/Firefox\/(\d+)/.exec(zo)||[0,0])[1],Uo=!$o&&/Chrome\/(\d+)/.exec(zo),Go=!!Uo,Ko=Uo?+Uo[1]:0,Jo=!$o&&!!Lo&&/Apple Computer/.test(Lo.vendor),Zo=Jo&&(/Mobile\/\w+/.test(zo)||!!Lo&&Lo.maxTouchPoints>2),Yo=Zo||!!Lo&&/Mac/.test(Lo.platform),Xo=/Android \d/.test(zo),Qo=!!Po&&"webkitFontSmoothing"in Po.documentElement.style,ei=Qo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var ti=Object.freeze({__proto__:null,android:Xo,chrome:Go,chrome_version:Ko,gecko:Fo,gecko_version:Wo,ie:$o,ie_version:qo,ios:Zo,mac:Yo,safari:Jo,webkit:Qo,webkit_version:ei});function ni(e,t,n,r,o,i){if(e.composing)return!1;const s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;const l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a of o){const o=a,c=o.match.exec(l),d=c&&c[0]&&o.handler(s,c,t-(c[0].length-r.length),n);if(d)return!1!==o.undoable&&d.setMeta(i,{transform:d,from:t,to:n,text:r}),e.dispatch(d),!0}return!1}const ri=new so("MILKDOWN_CUSTOM_INPUTRULES");function oi({rules:e}){const t=new ro({key:ri,isInputRules:!0,state:{init:()=>null,apply(e,t){const n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>ni(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&ni(n,r.pos,r.pos,"",e,t)}),!1),keydown:(e,t)=>!(!Xo||!Go||"Enter"!==t.key)&&(!e.composing&&(!!e.someProp("handleKeyDown",n=>n(e,t))&&(t.preventDefault(),!0)))},handleKeyDown(n,r){if("Enter"!==r.key)return!1;const{$cursor:o}=n.state.selection;return!!o&&ni(n,o.pos,o.pos,"\n",e,t)}}});return t}function ii(e,t,n={}){return new Io(e,(e,r,o,i)=>{var s,a,l,c;const{tr:d}=e;let u,h=r[r.length-1],p=r[0],f=[];const m={group:h,fullMatch:p,start:o,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:h,fullMatch:p,start:o,end:i}=m),null===p)return null;if(""===(null==h?void 0:h.trim()))return null;if(h){const e=p.search(/\S/),s=o+p.indexOf(h),m=s+h.length;f=null!=(a=d.storedMarks)?a:[],m<i&&d.delete(m,i),s>o&&d.delete(o+e,s),u=o+e+h.length;const g=null==(l=n.getAttr)?void 0:l.call(n,r);d.addMark(o,u,t.create(g)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:o,end:i,tr:d})}return d})}var si=Object.defineProperty,ai=Object.defineProperties,li=Object.getOwnPropertyDescriptors,ci=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable,hi=(e,t,n)=>t in e?si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function pi(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function fi(e,t,n){const r=e.state.doc.content.size,o=pi(t,0,r),i=pi(n,0,r),s=e.coordsAtPos(o),a=e.coordsAtPos(i,-1),l=Math.min(s.top,a.top),c=Math.max(s.bottom,a.bottom),d=Math.min(s.left,a.left),u=Math.max(s.right,a.right),h={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return p=((e,t)=>{for(var n in t||(t={}))di.call(t,n)&&hi(e,n,t[n]);if(ci)for(var n of ci(t))ui.call(t,n)&&hi(e,n,t[n]);return e})({},h),ai(p,li({toJSON:()=>h}));var p}function mi(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function gi(e){if(1===e.content.childCount){const t=e.content.firstChild;if("text"===(null==t?void 0:t.type.name)&&0===t.marks.length)return t;if("paragraph"===(null==t?void 0:t.type.name)&&1===t.childCount){const e=t.firstChild;if("text"===(null==e?void 0:e.type.name)&&0===e.marks.length)return e}}return!1}function vi(e){return t=>{for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r)){return{from:t.before(n),to:t.after(n),node:r}}}}}function yi(e,t){const n=t.nodes[e];if(!n)throw function(e,t){return new wt(yt.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}("node",e);return n}function wi(e){return t=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function bi(e,t){if(!(e instanceof Fr))return;const{node:n,$from:r}=e;return function(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}(t,n)?{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}:void 0}const xi=(e,t)=>{const{selection:n,doc:r}=e;if(n instanceof Fr)return{hasNode:n.node.type===t,pos:n.from,target:n.node};const{from:o,to:i}=n;let s=!1,a=-1,l=null;return r.nodesBetween(o,i,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}},ki="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ci="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Si(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);ki?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Mi(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Ni(e){return new ro({props:{handleKeyDown:Ei(e)}})}function Ei(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Si(n)]=e[n];return t}(e);return function(e,o){let i,s=n(o),a=t[Mi(s,o)];if(a&&a(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(o.shiftKey){let n=t[Mi(s,o,!1)];if(n&&n(e.state,e.dispatch,e))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Ci&&o.ctrlKey&&o.altKey)&&(i=r[o.keyCode])&&i!=s){let n=t[Mi(i,o)];if(n&&n(e.state,e.dispatch,e))return!0}}return!1}}var Oi=class{},Ti=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw Ct();return e}}},Ai=class e extends Oi{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Di=class extends Ti{#w;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.#w=Ut.none,this.#b=e=>e.isText,this.#x=(e,t)=>{if(this.#b(e)&&this.#b(t)&&Ut.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)},this.#k=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw function(e){return new wt(yt.parserMatchError,`Cannot match target parser for node: ${xt(e)}.`)}(e);return t},this.#C=e=>{const t=this.#k(e);t.spec.parseMarkdown.runner(this,e,t)},this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Ai.create(e,[],t)),this),this.#S=()=>{this.#w=Ut.none;const e=this.close();return this.#M(e.type,e.attrs,e.content)},this.closeNode=()=>{try{this.#S()}catch(e){console.error(e)}return this},this.#M=(e,t,n)=>{const r=e.createAndFill(t,n,this.#w);if(!r)throw function(e,t,n){const r=`Cannot create node for ${"name"in e?e.name:e}`,o=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(o).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},i=[["[Description]",r],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:o(e):"null")]].reduce((e,[t,n])=>{const r=`${t}: ${o(n)}.`;return e.concat(r)},[]);return new wt(yt.createNodeInParserFail,i.join("\n"))}(e,t,n);return this.push(r),r},this.addNode=(e,t,n)=>{try{this.#M(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>{const n=e.create(t);return this.#w=n.addToSet(this.#w),this},this.closeMark=e=>(this.#w=e.removeFromSet(this.#w),this),this.addText=e=>{try{const t=this.top();if(!t)throw Ct();const n=t.pop(),r=this.schema.text(e,this.#w);if(!n)return t.push(r),this;const o=this.#x(n,r);return o?(t.push(o),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do{e=this.#S()}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#C(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{const n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#b;#x;#k;#C;#S;#M},Ii=class e extends Oi{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,o={})=>new e(t,n,r,o)}},_i=class extends Ti{#w;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.#w=Ut.none,this.#k=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw function(e){return new wt(yt.serializerMatchError,`Cannot match target serializer for node: ${xt(e)}.`)}(e.type);return t},this.#N=e=>this.#k(e).spec.toMarkdown.runner(this,e),this.#E=(e,t)=>this.#k(e).spec.toMarkdown.runner(this,e,t),this.#C=e=>{const{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#E(t,e))&&this.#N(e),t.forEach(e=>this.#O(e))},this.#T=(e,t)=>{if(e.type===t)return e;if(1!==e.children?.length)return e;const n=e=>{if(e.type===t)return null!=e.value?null:e;if(1!==e.children?.length)return null;const[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;const o=r.children?[...r.children]:void 0,i={...e,children:o};return i.children=o,r.children=[i],r},this.#A=e=>{const{children:t}=e;return t?(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];const r=e.at(-1);if(r&&r.isMark&&t.isMark){t=this.#T(t,r.type);const{children:n,...o}=t,{children:i,...s}=r;if(t.type===r.type&&n&&i&&JSON.stringify(o)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(this.#A(t))}}return e.concat(t)},[]),e):e},this.#D=e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t},this.openNode=(e,t,n)=>(this.open(Ii.create(e,void 0,t,n)),this),this.#I=(e,t)=>{let n="",r="";const o=e.children;let i=-1,s=-1;if(o){(a=o)&&a.forEach((e,t)=>{"text"===e.type&&e.value&&(i<0&&(i=t),s=t)});const e=o?.[s],t=o?.[i];if(e&&e.value.endsWith(" ")){const t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){const e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}var a;n.length&&this.#M("text",void 0,n);const l=t();return r.length&&this.#M("text",void 0,r),l},this.#S=(e=!1)=>{const t=this.close(),n=()=>this.#M(t.type,t.children,t.value,t.props);return e?this.#I(t,n):n()},this.closeNode=()=>(this.#S(),this),this.#M=(e,t,n,r)=>{const o=Ii.create(e,t,n,r),i=this.#A(this.#D(o));return this.push(i),i},this.addNode=(e,t,n,r)=>(this.#M(e,t,n,r),this),this.#_=(e,t,n,r)=>e.isInSet(this.#w)?this:(this.#w=e.addToSet(this.#w),this.openNode(t,n,{...r,isMark:!0})),this.#O=e=>{e.isInSet(this.#w)&&(this.#w=e.type.removeFromSet(this.#w),this.#S(!0))},this.withMark=(e,t,n,r)=>(this.#_(e,t,n,r),this),this.closeMark=e=>(this.#O(e),this),this.build=()=>{let e=null;do{e=this.#S()}while(this.size());return e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach(e=>{this.#C(e)}),this):(this.#C(e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#k;#N;#E;#C;#T;#A;#D;#I;#S;#M;#_;#O};const Ri=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Bi=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Li=null;const Pi=function(e,t,n){let r=Li||(Li=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},zi=function(e,t,n,r){return n&&(Vi(e,t,n,r,-1)||Vi(e,t,n,r,1))},ji=/^(img|br|input|textarea|hr)$/i;function Vi(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Hi(e))){let n=e.parentNode;if(!n||1!=n.nodeType||$i(e)||ji.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ri(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?Hi(e):0}}}}function Hi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function $i(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const qi=function(e){return e.focusNode&&zi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Fi(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Wi="undefined"!=typeof navigator?navigator:null,Ui="undefined"!=typeof document?document:null,Gi=Wi&&Wi.userAgent||"",Ki=/Edge\/(\d+)/.exec(Gi),Ji=/MSIE \d/.exec(Gi),Zi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Gi),Yi=!!(Ji||Zi||Ki),Xi=Ji?document.documentMode:Zi?+Zi[1]:Ki?+Ki[1]:0,Qi=!Yi&&/gecko\/(\d+)/i.test(Gi);Qi&&(/Firefox\/(\d+)/.exec(Gi)||[0,0])[1];const es=!Yi&&/Chrome\/(\d+)/.exec(Gi),ts=!!es,ns=es?+es[1]:0,rs=!Yi&&!!Wi&&/Apple Computer/.test(Wi.vendor),is=rs&&(/Mobile\/\w+/.test(Gi)||!!Wi&&Wi.maxTouchPoints>2),ss=is||!!Wi&&/Mac/.test(Wi.platform),as=!!Wi&&/Win/.test(Wi.platform),ls=/Android \d/.test(Gi),cs=!!Ui&&"webkitFontSmoothing"in Ui.documentElement.style,ds=cs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function us(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function hs(e,t){return"number"==typeof e?e:e[t]}function ps(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function fs(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Bi(s);continue}let e=s,n=e==i.body,a=n?us(i):ps(e),l=0,c=0;if(t.top<a.top+hs(r,"top")?c=-(a.top-t.top+hs(o,"top")):t.bottom>a.bottom-hs(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+hs(o,"top")-a.top:t.bottom-a.bottom+hs(o,"bottom")),t.left<a.left+hs(r,"left")?l=-(a.left-t.left+hs(o,"left")):t.right>a.right-hs(r,"right")&&(l=t.right-a.right+hs(o,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Bi(s)}}function ms(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Bi(r));return t}function gs(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let vs=null;function ys(e,t){let n,r,o,i,s=2e8,a=0,l=t.top,c=t.top;for(let d=e.firstChild,u=0;d;d=d.nextSibling,u++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Pi(d).getClientRects()}for(let h=0;h<e.length;h++){let p=e[h];if(p.top<=l&&p.bottom>=c){l=Math.max(p.bottom,l),c=Math.min(p.top,c);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=d,s=e,r=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==d.nodeType&&e&&(a=u+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=d,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=u+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n,r=e.nodeValue.length,o=document.createRange();for(let i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);let r=Cs(o,1);if(r.top!=r.bottom&&ws(t,r)){n={node:e,offset:i+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:a}:ys(n,r)}function ws(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function bs(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(ws(t,o))return bs(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function xs(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Hi(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Hi(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!ws(t,n))return null;if(a=bs(e.dom,t,n),!a)return null}if(rs)for(let e=a;n&&e;e=Bi(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(Qi&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;cs&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=ys(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function ks(e){return e.top<e.bottom||e.left<e.right}function Cs(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(ks(e))return e}return Array.prototype.find.call(n,ks)||e.getBoundingClientRect()}const Ss=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ms(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=cs||Qi;if(3==r.nodeType){if(!s||!Ss.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Ns(Cs(Pi(r,e,t),i),i<0)}{let e=Cs(Pi(r,o,o),n);if(Qi&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Cs(Pi(r,o-1,o-1),-1);if(t.top==e.top){let n=Cs(Pi(r,o,o+1),-1);if(n.top!=e.top)return Ns(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Hi(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Es(e.getBoundingClientRect(),!1)}if(null==i&&o<Hi(r)){let e=r.childNodes[o];if(1==e.nodeType)return Es(e.getBoundingClientRect(),!0)}return Es(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Hi(r))){let e=r.childNodes[o-1],t=3==e.nodeType?Pi(e,Hi(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ns(Cs(t,1),!1)}if(null==i&&o<Hi(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Pi(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ns(Cs(t,-1),!0)}return Ns(Cs(3==r.nodeType?Pi(r):r,-n),n>=0)}function Ns(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Es(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Os(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Ts=/[\u0590-\u08ac]/;let As=null,Ds=null,Is=!1;function _s(e,t,n){return As==t&&Ds==n?Is:(As=t,Ds=n,Is="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Os(e,t,()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Ms(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Pi(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return a?Ts.test(r.parent.textContent)&&a.modify?Os(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&o==u;try{a.collapse(i,s),t&&(t!=i||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),h}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class Rs{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].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 t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.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,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Ri(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof Hs){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Bs&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Ri(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Ri(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Ri(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Ri(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(o>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((Qi||rs)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:Ri(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Qi&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&rs)&&zi(s.node,s.offset,c.anchorNode,c.anchorOffset)&&zi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!Qi)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Bs extends Rs{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||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 Ls extends Rs{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Ps extends Rs{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=Fn.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Ps(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Ps.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=ea(o,t,i,n)),e>0&&(o=ea(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zs extends Rs{constructor(e,t,n,r,o,i,s,a,l){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Fn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Js(c,n,t),l?s=new $s(e,t,n,r,c,d||null,u,l,o,i+1):t.isText?new Vs(e,t,n,r,c,u,o):new zs(e,t,n,r,c,d||null,u,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>$t.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Zs(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new Xs(this,i&&i.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,h,p;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(Qs);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)p=-1,h=l,l=null;else{if(!(c<e.childCount))break;p=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-i),h=h.cut(0,e-i),f=e,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,h),p),i=f}}(this.node,this.innerDeco,(t,o,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,o):t.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?Ut.none:this.node.child(o).marks,n,e,o),a.placeWidget(t,e,r)},(t,i,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,i,l,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,i,l,d,e)||a.updateNextNode(t,i,l,e,c,r)||a.addNode(t,i,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),qs(this.contentDOM,this.children,e),is&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof $r)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Ls(this,o,t,r);e.input.compositionNodes.push(i),this.children=ea(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Zs(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Gs(this.dom,this.nodeDOM,Us(this.outerDeco,this.node,t),Us(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function js(e,t,n,r,o){Js(r,t,e);let i=new zs(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Vs extends zs{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new Vs(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Hs extends Rs{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class $s extends zs{constructor(e,t,n,r,o,i,s,a,l,c){super(e,t,n,r,o,i,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function qs(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=Ys(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(a,r);if(s instanceof Ps){let t=r?r.previousSibling:e.lastChild;qs(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Ys(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Fs=function(e){e&&(this.nodeName=e)};Fs.prototype=Object.create(null);const Ws=[new Fs];function Us(e,t,n){if(0==e.length)return Ws;let r=n?Ws[0]:new Fs,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Fs(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Fs(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Gs(e,t,n,r){if(n==Ws&&r==Ws)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Ws[0]),o=t}Ks(o,s||Ws[0],i)}return o}function Ks(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Js(e,t,n){return Gs(e,e,Ws,Us(t,n,1!=e.nodeType))}function Zs(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Ys(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Xs{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Ps)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let o=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){o=t;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let r=Ps.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof zs){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let c,d=a.dom,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&Zs(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zs(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=zs.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=zs.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Bs(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ps;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Vs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((rs||ts)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Hs(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Qs(e,t){return e.type.side-t.type.side}function ea(e,t,n,r,o){let i=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function ta(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(qi(n)){for(a=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&Fr.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==Hi(e);r||o;){if(e==n)return!0;let t=Ri(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Hi(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;l=new Fr(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!l){l=da(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function na(e){return e.editable?e.hasFocus():ha(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ra(e,t=!1){let n=e.state.selection;if(la(e,n),na(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&ts){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&zi(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Ri(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Yi&&Xi<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!oa||n instanceof $r||(n.$from.parent.inlineContent||(r=ia(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=ia(e,n.to))),e.docView.setSelection(i,s,e,t),oa&&(r&&aa(r),o&&aa(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{na(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const oa=rs||ts&&ns<63;function ia(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(rs&&o&&"false"==o.contentEditable)return sa(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return sa(o);if(i)return sa(i)}}function sa(e){return e.contentEditable="true",rs&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function aa(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function la(e,t){if(t instanceof Fr){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ca(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ca(e)}function ca(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function da(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||$r.between(t,n,r)}function ua(e){return!(e.editable&&!e.hasFocus())&&ha(e)}function ha(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function pa(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&zr.findFrom(i,t)}function fa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ma(e,t,n){let r=e.state.selection;if(!(r instanceof $r)){if(r instanceof Fr&&r.node.isInline)return fa(e,new $r(t>0?r.$to:r.$from));{let n=pa(e.state,t);return!!n&&fa(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return fa(e,new $r(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=pa(e.state,t);return!!(n&&n instanceof Fr)&&fa(e,n)}if(!(ss&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Fr.isSelectable(i)?fa(e,new Fr(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!cs&&fa(e,new $r(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function ga(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function va(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function ya(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;Qi&&1==n.nodeType&&r<ga(n)&&va(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(va(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(wa(n))break;{let t=n.previousSibling;for(;t&&va(t,-1);)o=n.parentNode,i=Ri(t),t=t.previousSibling;if(t)n=t,r=ga(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?ba(e,n,r):o&&ba(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=ga(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!va(n.childNodes[r],1))break;o=n,i=++r}else{if(wa(n))break;{let t=n.nextSibling;for(;t&&va(t,1);)o=t.parentNode,i=Ri(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=ga(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&ba(e,o,i)}(e)}function wa(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function ba(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!$i(e);)t=Ri(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!$i(e);)t=Ri(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(qi(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&ra(e)},50)}function xa(e,t){let n=e.state.doc.resolve(t);if(!ts&&!as&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ka(e,t,n){let r=e.state.selection;if(r instanceof $r&&!r.empty||n.indexOf("s")>-1)return!1;if(ss&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=pa(e.state,t);if(n&&n instanceof Fr)return fa(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Ur?zr.near(n,t):zr.findFrom(n,t);return!!s&&fa(e,s)}return!1}function Ca(e,t){if(!(e.state.selection instanceof $r))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Sa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ma(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||ss&&72==n&&"c"==r)return Ca(e,-1)||ya(e,-1);if(46==n&&!t.shiftKey||ss&&68==n&&"c"==r)return Ca(e,1)||ya(e,1);if(13==n||27==n)return!0;if(37==n||ss&&66==n&&"c"==r){let t=37==n?"ltr"==xa(e,e.state.selection.from)?-1:1:-1;return ma(e,t,r)||ya(e,t)}if(39==n||ss&&70==n&&"c"==r){let t=39==n?"ltr"==xa(e,e.state.selection.from)?1:-1:1;return ma(e,t,r)||ya(e,t)}return 38==n||ss&&80==n&&"c"==r?ka(e,-1,r)||ya(e,-1):40==n||ss&&78==n&&"c"==r?function(e){if(!rs||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Sa(e,n,"true"),setTimeout(()=>Sa(e,n,"false"),20)}return!1}(e)||ka(e,1,r)||ya(e,1):r==(ss?"m":"c")&&(66==n||73==n||89==n||90==n)}function Na(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Fn.fromSchema(e.state.schema),a=La(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,u=0;for(;d&&1==d.nodeType&&(c=Ra[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Ea(e,t,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new Kt($t.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,o,r,e));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=Fn.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=La().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&Ra[o[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;Pa||(Pa=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return Pa.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),cs&&function(e){let t=e.querySelectorAll(ts?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Rn.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Oa.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=$t.from(t.create(n[e+1],o)),i++,s++}return new Kt(o,i,s)}(_a(s,+d[1],+d[2]),d[4]);else if(s=Kt.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Aa(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Da(i[i.length-1],r.length));let t=Ta(e,n);i.push(t),o=o.matchType(t.type),r=n}}),i)return $t.from(i)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=_a(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const Oa=/^(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 Ta(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,$t.from(e));return e}function Aa(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Aa(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append($t.from(Ta(n,e,o+1))))}}function Da(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Da(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore($t.empty,!0);return e.copy(n.append(r))}function Ia(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),o<r-1&&(a=Ia(a,t,n,r,o+1,i)),o>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore($t.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function _a(e,t,n){return t<e.openStart&&(e=new Kt(Ia(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Kt(Ia(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ra={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 Ba=null;function La(){return Ba||(Ba=document.implementation.createHTMLDocument("title"))}let Pa=null;const za={},ja={},Va={touchstart:!0,touchmove:!0};class Ha{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 $a(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function qa(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Fa(e,t))})}function Fa(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Wa(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Ua(e){return{left:e.clientX,top:e.clientY}}function Ga(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function Ka(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Ja(e,t,n,r,o){return Ga(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Fr&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(Fr.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Ka(e,Fr.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Fr.isSelectable(r))&&(Ka(e,new Fr(n)),!0)}(e,n))}function Za(e,t,n,r){return Ga(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Ya(e,t,n,r){return Ga(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Ka(e,$r.create(r,0,r.content.size)),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)Ka(e,$r.create(r,i+1,i+1+n.content.size));else{if(!Fr.isSelectable(n))continue;Ka(e,Fr.create(r,i))}return!0}}(e,n,r)}function Xa(e){return sl(e)}ja.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!tl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!ls||!ts||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!is||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Ma(e,n)?n.preventDefault():$a(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},ja.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ja.keypress=(e,t)=>{let n=t;if(tl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||ss&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof $r&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,o))||e.dispatch(o()),n.preventDefault()}};const Qa=ss?"metaKey":"ctrlKey";za.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Xa(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[Qa]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(Ua(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new el(e,s,n,!!r)):("doubleClick"==i?Za:Ya)(e,s.pos,s.inside,n)?n.preventDefault():$a(e,"pointer"))};class el{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Qa],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Fr&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Qi||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),$a(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ra(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ua(e))),this.updateAllowDefault(e),this.allowDefault||!t?$a(this.view,"pointer"):Ja(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||rs&&this.mightDrag&&!this.mightDrag.node.isAtom||ts&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ka(this.view,zr.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):$a(this.view,"pointer")}move(e){this.updateAllowDefault(e),$a(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function tl(e,t){return!!e.composing||!!(rs&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}za.touchstart=e=>{e.input.lastTouch=Date.now(),Xa(e),$a(e,"pointer")},za.touchmove=e=>{e.input.lastTouch=Date.now(),$a(e,"pointer")},za.contextmenu=e=>Xa(e);const nl=ls?5e3:-1;function rl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>sl(e),t))}function ol(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function il(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Hi(e=e.childNodes[t-1])}else{if(!e.parentNode||$i(e))return null;t=Ri(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||$i(e))return null;t=Ri(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function sl(e,t=!1){if(!(ls&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ol(e),t||e.docView&&e.docView.dirty){let n=ta(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ja.compositionstart=ja.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof $r&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||ts&&as&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),sl(e,!0),e.markCursor=null;else if(sl(e,!t.selection.empty),Qi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}rl(e,nl)},ja.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,rl(e,20))};const al=Yi&&Xi<15||is&&ds<604;function ll(e,t,n,r,o){let i=Ea(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,i||Kt.empty)))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function cl(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}za.copy=ja.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=al?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Na(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ja.paste=(e,t)=>{let n=t;if(e.composing&&!ls)return;let r=al?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ll(e,cl(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ll(e,r.value,null,o,t):ll(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class dl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const ul=ss?"altKey":"ctrlKey";function hl(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[ul]}za.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Ua(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Fr?i.to-1:i.to));else if(r&&r.mightDrag)o=Fr.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Fr.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:c,slice:d}=Na(e,a);(!n.dataTransfer.files.length||!ts||ns>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(al?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",al||n.dataTransfer.setData("text/plain",c),e.dragging=new dl(d,hl(e,n),o)},za.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ja.dragover=ja.dragenter=(e,t)=>t.preventDefault(),ja.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Ua(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Ea(e,cl(t.dataTransfer),al?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!n||!hl(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||Kt.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let a=i?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,u=l.doc;d?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i);if(l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&Fr.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new Fr(h));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),l.setSelection(da(e,h,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},za.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ra(e)},20))},za.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},za.beforeinput=(e,t)=>{if(ts&&ls&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,Fi(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ja)za[e]=ja[e];function pl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class fl{constructor(e,t){this.toDOM=e,this.spec=t||wl,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new vl(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof fl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ml{constructor(e,t){this.attrs=e,this.spec=t||wl}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new vl(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ml&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}static is(e){return e.type instanceof ml}destroy(){}}class gl{constructor(e,t){this.attrs=e,this.spec=t||wl}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new vl(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof gl&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}destroy(){}}class vl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new vl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new vl(e,e,new fl(t,n))}static inline(e,t,n,r){return new vl(e,t,new ml(n,r))}static node(e,t,n,r){return new vl(e,t,new gl(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof ml}get widget(){return this.type instanceof fl}}const yl=[],wl={};class bl{constructor(e,t){this.local=e.length?e:yl,this.children=t.length?t:yl}static create(e,t){return t.length?Nl(t,e,0,wl):xl}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==xl||0==e.maps.length?this:this.mapInner(e,t,0,0,n||wl)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||e>i+t-r)continue;let l=a[o]+t-r;n>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-o;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=xl?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,o,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(r,o,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+i+1);return n}(a,e,t,n,o,i,s),c=Nl(l,r,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new bl(t.sort(El),a)}(this.children,i||[],e,t,n,r,o):i?new bl(i.sort(El),yl):xl}add(e,t){return t.length?this==xl?bl.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,a=i+n;if(s=Sl(t,e,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,a+1):r.splice(o,0,i,i+e.nodeSize,Nl(s,e,a+1,wl)),o+=3}});let i=Cl(o?Ml(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new bl(i.length?this.local.concat(i).sort(El):this.local,r||this.children)}remove(e){return 0==e.length||this==xl?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=xl?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new bl(r,n):xl}forChild(e,t){if(this==xl)return this;if(t.isLeaf)return bl.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof ml){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new bl(r.sort(El),yl);return n?new kl([e,n]):e}return n||xl}eq(e){if(this==e)return!0;if(!(e instanceof bl)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ol(this.localsInner(e))}localsInner(e){if(this==xl)return yl;if(e.inlineContent||!this.local.some(ml.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof ml||t.push(this.local[e]);return t}forEachSet(e){e(this)}}bl.empty=new bl([],[]),bl.removeOverlap=Ol;const xl=bl.empty;class kl{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,wl));return kl.from(n)}forChild(e,t){if(t.isLeaf)return bl.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=xl&&(o instanceof kl?n=n.concat(o.members):n.push(o))}return kl.from(n)}eq(e){if(!(e instanceof kl)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Ol(n?t:t.sort(El)):yl}static from(e){switch(e.length){case 0:return xl;case 1:return e[0];default:return new kl(e.every(e=>e instanceof bl)?e:e.reduce((e,t)=>e.concat(t instanceof bl?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cl(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new vl(o.from+t,o.to+t,o.type))}return n}function Sl(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Ml(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Nl(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let a=Sl(e,t,s+n);if(a){i=!0;let e=Nl(a,t,n+s+1,r);e!=xl&&o.push(s,s+t.nodeSize,e)}});let s=Cl(i?Ml(e):e,-n).sort(El);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new bl(s,o):xl}function El(e,t){return e.from-t.from||e.to-t.to}function Ol(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Tl(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Tl(t,o+1,i.copy(r.to,i.to)))}}return t}function Tl(e,t,n){for(;t<e.length&&El(n,e[t])>0;)t++;e.splice(t,0,n)}function Al(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=xl&&t.push(r)}),e.cursorWrapper&&t.push(bl.create(e.state.doc,[e.cursorWrapper.deco])),kl.from(t)}const Dl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Il=Yi&&Xi<=11;class _l{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 Rl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _l,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Yi&&Xi<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():rs&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Il&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Dl)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(ua(this.view)){if(this.suppressingSelectionUpdates)return ra(this.view);if(Yi&&Xi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zi(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 t,n=new Set;for(let t=e.focusNode;t;t=Bi(t))n.add(t);for(let r=e.anchorNode;r;r=Bi(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 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 t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ua(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(!a.some(e=>"BR"==e.nodeName)||8!=e.input.lastKeyCode&&46!=e.input.lastKeyCode){if(Qi&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&zl(e,n)==t||r.remove()}}}}else for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}let l=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qi(n)&&(l=ta(e))&&l.eq(zr.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ra(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(Bl.has(e))return;if(Bl.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Qi,Ll)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."),Ll=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if("TR"==(null===(n=i.parentNode)||void 0===n?void 0:n.nodeName)){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(o,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ra(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(Yi&&Xi<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Ri(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?Ri(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Bl=new WeakMap,Ll=!1;function Pl(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return zi(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function zl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function jl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(rs&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||rs&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Vl=/^(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 Hl(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ta(e,t);if(n&&!e.state.selection.eq(n)){if(ts&&ls&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(n);t=s.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,d=e.state.selection,u=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],qi(c)||r.push({node:c.focusNode,offset:c.focusOffset})),ts&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let u=e.state.doc,h=e.someProp("domParser")||Rn.fromSchema(e.state.schema),p=u.resolve(a),f=null,m=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:jl,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),h=e.state.doc,p=h.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,o){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==o){r-=s+Math.max(0,i-Math.min(s,a))-i}if(s<i&&e.size<t.size){let e=r<=i&&r>=s?i-r:0;i-=e,i&&i<t.size&&Fl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-s),s=i}else if(a<i){let t=r<=i&&r>=a?i-r:0;i-=t,i&&i<e.size&&Fl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(p.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(is&&e.input.lastIOSEnter>Date.now()-225||ls)&&o.some(e=>1==e.nodeType&&!Vl.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof $r&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=$l(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof $r&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),Yi&&Xi<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>u.from&&" "==u.doc.textBetween(f.start-u.from-1,f.start-u.from+1)&&(f.start--,f.endA--,f.endB--);let m=u.doc.resolveNoCache(f.start-u.from),g=u.doc.resolveNoCache(f.endB-u.from),v=h.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA;if((is&&e.input.lastIOSEnter>Date.now()-225&&(!y||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&m.pos<u.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(u.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||ql(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(ql(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||ql(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(h,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,Fi(8,"Backspace"))))return void(ls&&ts&&e.domObserver.suppressSelectionUpdates());ts&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),ls&&!y&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==f.endA&&(f.endB-=2,g=u.doc.resolveNoCache(f.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,Fi(13,"Enter"))})},20));let w,b=f.start,x=f.endA,k=t=>{let n=t||e.state.tr.replace(b,x,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=$l(e,n.doc,u.sel);t&&!(ts&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1)||Yi&&t.empty&&t.head==b)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){Yi&&Xi<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>ra(e),20));let t=k(e.state.tr.delete(b,x)),n=h.resolve(f.start).marksAcross(h.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(w=function(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,a=i,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<i.length;e++)l=i[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if($t.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start())))){let t=k(e.state.tr);"add"==w.type?t.addMark(b,x,w.mark):t.removeMark(b,x,w.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>k(e.state.tr.insertText(t,b,x));e.someProp("handleTextInput",r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())}function $l(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:da(e,t.resolve(n.anchor),t.resolve(n.head))}function ql(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}function Fl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class Wl{constructor(e,t){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 Ha,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Zl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Kl(this),Gl(this),this.nodeViews=Jl(this),this.docView=js(this.state.doc,Ul(this),Al(this),this.dom,this),this.domObserver=new Rl(this,(e,t,n,r)=>Hl(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in za){let n=za[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Wa(e,t)||Fa(e,t)||!e.editable&&t.type in ja||n(e,t)},Va[t]?{passive:!0}:void 0)}rs&&e.dom.addEventListener("input",()=>null),qa(e)}(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&qa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Zl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(ol(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Jl(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&qa(this),this.editable=Kl(this),Gl(this);let a=Al(this),l=Ul(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(r.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:ms(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(Yi||ts)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(d){let n=ts?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=il(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=js(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return zi(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?ra(this,t):(la(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;gs(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof Fr){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&fs(this,t.getBoundingClientRect(),e)}else fs(this,this.coordsAtPos(this.state.selection.head,1),e);else;}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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new dl(e.slice,e.move,r<0?void 0:Fr.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(Yi){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(vs)return e.focus(vs);let t=ms(e);e.focus(null==vs?{get preventScroll(){return vs={preventScroll:!0},!0}}:void 0),vs||(vs=!1,gs(t,0))}(this.dom),ra(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return xs(this,e)}coordsAtPos(e,t=1){return Ms(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return _s(this,t||this.state,e)}pasteHTML(e,t){return ll(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ll(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Na(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Al(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Li=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Fa(e,t)||!za[t.type]||!e.editable&&t.type in ja||za[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?rs&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Pl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Pl(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ul(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[vl.node(0,e.state.doc.content.size,t)]}function Gl(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:vl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Kl(e){return!e.someProp("editable",t=>!1===t(e.state))}function Jl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Zl(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function Yl(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}Wl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};var Xl={text:(e,t,n,r)=>{const o=e.value;return/^[^*_\\]*\s+$/.test(o)?o:n.safe(o,{...r,encode:[]})},strong:(e,t,n,r)=>{const o=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(r);let a=s.move(o+o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o+o),i(),a},emphasis:(e,t,n,r)=>{const o=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(r);let a=s.move(o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o),i(),a}},Ql=Dt({},"editorView"),ec=Dt({},"editorState"),tc=Dt([],"initTimer"),nc=Dt({},"editor"),rc=Dt([],"inputRules"),oc=Dt([],"prosePlugins"),ic=Dt([],"remarkPlugins"),sc=Dt([],"nodeView"),ac=Dt([],"markView"),lc=Dt(U().use(G).use(zt),"remark"),cc=Dt({handlers:Xl,encode:[]},"remarkStringifyOptions"),dc=Pt("ConfigReady");var uc=Pt("InitReady");function hc(e){const t=t=>(t.inject(nc,e).inject(oc,[]).inject(ic,[]).inject(rc,[]).inject(sc,[]).inject(ac,[]).inject(cc,{handlers:Xl,encode:[]}).inject(lc,U().use(G).use(zt)).inject(tc,[dc]).record(uc),async()=>{await t.waitTimers(tc);const e=t.get(cc);return t.set(lc,U().use(G).use(zt,e)),t.done(uc),()=>{t.remove(nc).remove(oc).remove(ic).remove(rc).remove(sc).remove(ac).remove(cc).remove(lc).remove(tc).clearTimer(uc)}});return Yl(t,{displayName:"Init"}),t}var pc=Pt("SchemaReady"),fc=Dt([],"schemaTimer"),mc=Dt({},"schema"),gc=Dt([],"nodes"),vc=Dt([],"marks");function yc(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var wc=e=>(e.inject(mc,{}).inject(gc,[]).inject(vc,[]).inject(fc,[uc]).record(pc),async()=>{await e.waitTimers(fc);const t=e.get(lc),n=e.get(ic).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(lc,n);const r=new In({nodes:Object.fromEntries(e.get(gc).map(([e,t])=>[e,yc(t)])),marks:Object.fromEntries(e.get(vc).map(([e,t])=>[e,yc(t)]))});return e.set(mc,r),e.done(pc),()=>{e.remove(mc).remove(gc).remove(vc).remove(fc).clearTimer(pc)}});Yl(wc,{displayName:"Schema"});var bc=class{constructor(){this.#o=new Ot,this.#R=null,this.setCtx=e=>{this.#R=e},this.chain=()=>{if(null==this.#R)throw Mt();const e=this.#R,t=[],n=this.get.bind(this),r={run:()=>{const n=No(...t),r=e.get(Ql);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:function(e,o){const i=n(e);return t.push(i(o)),r}.bind(this)};return r}}#o;#R;get ctx(){return this.#R}create(e,t){const n=e.create(this.#o.sliceMap);return n.set(t),n}get(e){return this.#o.get(e).get()}remove(e){return this.#o.remove(e)}call(e,t){if(null==this.#R)throw Mt();const n=this.get(e)(t),r=this.#R.get(Ql);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#R)throw Mt();const t=this.#R.get(Ql);return e(t.state,t.dispatch,t)}};var xc=Dt(new bc,"commands"),kc=Dt([pc],"commandsTimer"),Cc=Pt("CommandsReady"),Sc=e=>{const t=new bc;return t.setCtx(e),e.inject(xc,t).inject(kc,[pc]).record(Cc),async()=>(await e.waitTimers(kc),e.done(Cc),()=>{e.remove(xc).remove(kc).clearTimer(Cc)})};Yl(Sc,{displayName:"Commands"});var Mc=class{constructor(){this.#R=null,this.#B=[],this.setCtx=e=>{this.#R=e},this.add=e=>(this.#B.push(e),()=>{this.#B=this.#B.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){const r={key:e,onRun:()=>n};this.#B.push(r),t.push(()=>{this.#B=this.#B.filter(e=>e!==r)})}else this.#B.push(n),t.push(()=>{this.#B=this.#B.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{const e=function(e){return e.Backspace=No(_o,ao,uo,po),e}(Do);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#B.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{const n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{const o=this.#R;if(null==o)throw kt();return No(...n.map(e=>e.onRun(o)))(e,t,r)}]}))}}#R;#B;get ctx(){return this.#R}},Nc=Dt(new Mc,"keymap"),Ec=Dt([pc],"keymapTimer"),Oc=Pt("KeymapReady"),Tc=e=>{const t=new Mc;return t.setCtx(e),e.inject(Nc,t).inject(Ec,[pc]).record(Oc),async()=>(await e.waitTimers(Ec),e.done(Oc),()=>{e.remove(Nc).remove(Ec).clearTimer(Oc)})},Ac=Pt("ParserReady"),Dc=()=>{throw kt()},Ic=Dt(Dc,"parser"),_c=Dt([],"parserTimer"),Rc=e=>(e.inject(Ic,Dc).inject(_c,[pc]).record(Ac),async()=>{await e.waitTimers(_c);const t=e.get(lc),n=e.get(mc);return e.set(Ic,Di.create(n,t)),e.done(Ac),()=>{e.remove(Ic).remove(_c).clearTimer(Ac)}});Yl(Rc,{displayName:"Parser"});var Bc=Pt("SerializerReady"),Lc=Dt([],"serializerTimer"),Pc=()=>{throw kt()},zc=Dt(Pc,"serializer"),jc=e=>(e.inject(zc,Pc).inject(Lc,[pc]).record(Bc),async()=>{await e.waitTimers(Lc);const t=e.get(lc),n=e.get(mc);return e.set(zc,_i.create(n,t)),e.done(Bc),()=>{e.remove(zc).remove(Lc).clearTimer(Bc)}});Yl(jc,{displayName:"Serializer"});var Vc=Dt("","defaultValue"),Hc=Dt(e=>e,"stateOptions"),$c=Dt([],"editorStateTimer"),qc=Pt("EditorStateReady");function Fc(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return Rn.fromSchema(n).parse(e.dom);if("json"===e.type)return pn.fromJSON(n,e.value);throw r=e,new wt(yt.docTypeError,`Doc type error, unsupported type: ${xt(r)}`);var r}var Wc=new so("MILKDOWN_STATE_TRACKER"),Uc=e=>(e.inject(Vc,"").inject(ec,{}).inject(Hc,e=>e).inject($c,[Ac,Bc,Cc,Oc]).record(qc),async()=>{await e.waitTimers($c);const t=e.get(mc),n=e.get(Ic),r=e.get(rc),o=e.get(Hc),i=e.get(oc),s=Fc(e.get(Vc),n,t),a=e.get(Nc),l=a.addBaseKeymap(),c=[...i,new ro({key:Wc,state:{init:()=>{},apply:(t,n,r,o)=>{e.set(ec,o)}}}),oi({rules:r}),Ni(a.build())];e.set(oc,c);const d=o({schema:t,doc:s,plugins:c}),u=to.create(d);return e.set(ec,u),e.done(qc),()=>{l(),e.remove(Vc).remove(ec).remove(Hc).remove($c).clearTimer(qc)}});Yl(Uc,{displayName:"EditorState"});var Gc=Dt([],"pasteRule"),Kc=Dt([pc],"pasteRuleTimer"),Jc=Pt("PasteRuleReady"),Zc=e=>(e.inject(Gc,[]).inject(Kc,[pc]).record(Jc),async()=>(await e.waitTimers(Kc),e.done(Jc),()=>{e.remove(Gc).remove(Kc).clearTimer(Jc)}));Yl(Zc,{displayName:"PasteRule"});var Yc=Pt("EditorViewReady"),Xc=Dt([],"editorViewTimer"),Qc=Dt({},"editorViewOptions"),ed=Dt(null,"root"),td=Dt(null,"rootDOM"),nd=Dt({},"rootAttrs");var rd=new so("MILKDOWN_VIEW_CLEAR"),od=e=>(e.inject(ed,document.body).inject(Ql,{}).inject(Qc,{}).inject(td,null).inject(nd,{}).inject(Xc,[qc,Jc]).record(Yc),async()=>{await e.wait(uc);const t=e.get(ed)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(oc,t=>[new ro({key:rd,view:t=>{const r=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(td,n);const r=t.get(nd);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}(n,e):void 0;return(()=>{if(r&&n){const e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(Xc);const r=e.get(ec),o=e.get(Qc),i=new Wl(n,{state:r,nodeViews:Object.fromEntries(e.get(sc)),markViews:Object.fromEntries(e.get(ac)),transformPasted:(t,n,r)=>(e.get(Gc).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});var s;return(s=i.dom).classList.add("editor"),s.setAttribute("role","textbox"),e.set(Ql,i),e.done(Yc),()=>{i?.destroy(),e.remove(ed).remove(Ql).remove(Qc).remove(td).remove(nd).remove(Xc).clearTimer(Yc)}});Yl(od,{displayName:"EditorView"});var id=function(e){return e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e}({}),sd=class e{constructor(){this.#L=!1,this.#g=id.Idle,this.#P=[],this.#z=()=>{},this.#o=new Ot,this.#i=new Rt,this.#j=new Map,this.#V=new Map,this.#R=new _t(this.#o,this.#i),this.#H=()=>{const e=function(e){const t=t=>(t.record(dc),async()=>(await e(t),t.done(dc),()=>{t.clearTimer(dc)}));return Yl(t,{displayName:"Config"}),t}(async e=>{await Promise.all(this.#P.map(t=>Promise.resolve(t(e))))}),t=[wc,Rc,jc,Sc,Tc,Zc,Uc,od,hc(this),e];this.#$(t,this.#V)},this.#$=(e,t)=>{e.forEach(e=>{const n=this.#R.produce(this.#L?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#q=(e,t=!1)=>Promise.all([e].flat().map(async e=>{const n=this.#j.get(e)?.cleanup;return t?this.#j.delete(e):this.#j.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof n?n():n})),this.#F=async()=>{await Promise.all([...this.#V.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#V.clear()},this.#W=e=>{this.#g=e,this.#z(e)},this.#U=e=>[...e.entries()].map(async([t,n])=>{const{ctx:r,handler:o}=n;if(!o)return;const i=await o();e.set(t,{ctx:r,handler:o,cleanup:i})}),this.enableInspector=(e=!0)=>(this.#L=e,this),this.onStatusChange=e=>(this.#z=e,this),this.config=e=>(this.#P.push(e),this),this.removeConfig=e=>(this.#P=this.#P.filter(t=>t!==e),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(e=>{this.#j.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#g===id.Created&&this.#$(t,this.#j),this},this.remove=async e=>this.#g===id.OnCreate?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#q([e].flat(),!0),this),this.create=async()=>(this.#g===id.OnCreate||(this.#g===id.Created&&await this.destroy(),this.#W(id.OnCreate),this.#H(),this.#$([...this.#j.keys()],this.#j),await Promise.all([this.#U(this.#V),this.#U(this.#j)].flat()),this.#W(id.Created)),this),this.destroy=async(e=!1)=>this.#g===id.Destroyed||this.#g===id.OnDestroy?this:this.#g===id.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#P=[]),this.#W(id.OnDestroy),await this.#q([...this.#j.keys()],e),await this.#F(),this.#W(id.Destroyed),this),this.action=e=>e(this.#R),this.inspect=()=>this.#L?[...this.#V.values(),...this.#j.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>Boolean(e)):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#L;#g;#P;#z;#o;#i;#j;#V;#R;#H;#$;#q;#F;#W;#U;get ctx(){return this.#R}get status(){return this.#g}};let ad=e=>crypto.getRandomValues(new Uint8Array(e)),ld=(e,t=21)=>((e,t,n)=>{let r=256-256%e.length;if(256===r){let r=e.length-1;return(o=t)=>{if(!o)return"";let i="";for(;;){let t=n(o),s=o;for(;s--;)if(i+=e[t[s]&r],i.length>=o)return i}}}let o=Math.ceil(409.6*t/r);return(i=t)=>{if(!i)return"";let s="";for(;;){let t=n(o),a=o;for(;a--;)if(t[a]<r&&(s+=e[t[a]%e.length],s.length>=i))return s}}})(e,0|t,ad);function cd(e,t){const n=function(e="cmdKey"){return Dt(()=>()=>!1,e)}(e),r=o=>async()=>{r.key=n,await o.wait(Cc);const i=t(o);return o.get(xc).create(n,i),r.run=t=>o.get(xc).call(e,t),()=>{o.get(xc).remove(n)}};return r}function dd(e){const t=n=>async()=>{await n.wait(pc);const r=e(n);return n.update(rc,e=>[...e,r]),t.inputRule=r,()=>{n.update(rc,e=>e.filter(e=>e!==r))}};return t}function ud(e,t){const n=r=>async()=>{const o=t(r);return r.update(vc,t=>[...t.filter(t=>t[0]!==e),[e,o]]),n.id=e,n.schema=o,()=>{r.update(vc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(mc).marks[e];if(!n)throw r=e,new wt(yt.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${r}" in schema.`);var r;return n},n}function hd(e,t){const n=r=>async()=>{const o=t(r);return r.update(gc,t=>[...t.filter(t=>t[0]!==e),[e,o]]),n.id=e,n.schema=o,()=>{r.update(gc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(mc).nodes[e];if(!n)throw Nt(e);return n},n}function pd(e){let t;const n=n=>async()=>(await n.wait(pc),t=e(n),n.update(oc,e=>[...e,t]),()=>{n.update(oc,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function fd(e){const t=n=>async()=>{await n.wait(Oc);const r=n.get(Nc),o=e(n),i=r.addObjectKeymap(o);return t.keymap=o,()=>{i()}};return t}function md(e,t){const n=r=>async()=>{await r.wait(pc);const o=t(r);return e.type(r)instanceof Tn?r.update(sc,t=>[...t,[e.id,o]]):r.update(ac,t=>[...t,[e.id,o]]),n.view=o,n.type=e,()=>{e.type(r)instanceof Tn?r.update(sc,t=>t.filter(t=>t[0]!==e.id)):r.update(ac,t=>t.filter(t=>t[0]!==e.id))}};return n}function gd(e,t){const n=Dt(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function vd(e,t){const n=gd(t,e),r=hd(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.node=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>vd(e,n(t)),o}function yd(e,t){const n=gd(t,e),r=ud(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.mark=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>yd(e,n(t)),o}function wd(e,t){const n=gd(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=fd(e=>{const r=e.get(n.key),o=Object.entries(t).flatMap(([e,{command:t}])=>{const n=r[e],o=[n.shortcuts].flat(),i=n.priority;return o.map(e=>[e,{key:e,onRun:t,priority:i}])});return Object.fromEntries(o)}),o=[n,r];return o.ctx=n,o.shortcuts=r,o.key=n.key,o.keymap=r.keymap,o}ld("abcedfghicklmn",10);var bd=(e,t=()=>({}))=>gd(t,`${e}Attr`),xd=(e,t=()=>({}))=>gd(t,`${e}Attr`);function kd(e,t,n){const r=gd({},e),o=e=>async()=>{await e.wait(uc);const n={plugin:t(e),options:e.get(r.key)};return e.update(ic,e=>[...e,n]),()=>{e.update(ic,e=>e.filter(e=>e!==n))}},i=[r,o];return i.id=e,i.plugin=o,i.options=r,i}function Cd(e){return e=>{const t=e.get(Ql);e.get(mc);return e.get(zc)(t.state.doc)}}var Sd=ie({});var Md=()=>{const e=function(){const{dom:e,editor:t,setLoading:n,editorFactory:r}=se(Sd),o=ne(null);return ce(()=>{const i=o.current;if(!r)return;if(!i)return;e.current=i;const s=r(i);return s?(n(!0),s.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}):void 0},[e,t,r,n]),o}();return te.createElement("div",{"data-milkdown-root":!0,ref:e})},Nd=({children:e})=>{const t=ne(void 0),[n,r]=re(void 0),o=ne(void 0),[i,s]=re(!0),a=oe(()=>({loading:i,dom:t,editor:o,setLoading:s,editorFactory:n,setEditorFactory:r}),[i,n]);return te.createElement(Sd.Provider,{value:a},e)};function Ed(){const e=se(Sd),t=ae(()=>e.editor.current,[e.editor]);return[e.loading,t]}function Od(e){return new i(s.define(e))}function Td(e){return import("./index-wgkxcuUd.js").then(t=>t.sql({dialect:t[e]}))}const Ad=[o.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-mPuca8dy.js").then(e=>e.cpp())}),o.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-mPuca8dy.js").then(e=>e.cpp())}),o.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Td("Cassandra")}),o.of({name:"CSS",extensions:["css"],load:()=>import("./index-CQTsT8Zj.js").then(e=>e.css())}),o.of({name:"Go",extensions:["go"],load:()=>import("./index-XKEYn2Wr.js").then(e=>e.go())}),o.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-Ci0TIrsP.js").then(e=>e.html())}),o.of({name:"Java",extensions:["java"],load:()=>import("./index-CYal7RVq.js").then(e=>e.java())}),o.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript())}),o.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-DQ_RDg2x.js").then(e=>e.jinja())}),o.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-4xl-oI83.js").then(e=>e.json())}),o.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript({jsx:!0}))}),o.of({name:"LESS",extensions:["less"],load:()=>import("./index-uScqGt-h.js").then(e=>e.less())}),o.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index-DPqNWk5z.js").then(e=>e.liquid())}),o.of({name:"MariaDB SQL",load:()=>Td("MariaSQL")}),o.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-CWWVtFL-.js").then(e=>e.markdown())}),o.of({name:"MS SQL",load:()=>Td("MSSQL")}),o.of({name:"MySQL",load:()=>Td("MySQL")}),o.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-3RT03X12.js").then(e=>e.php())}),o.of({name:"PLSQL",extensions:["pls"],load:()=>Td("PLSQL")}),o.of({name:"PostgreSQL",load:()=>Td("PostgreSQL")}),o.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-C_iDYl6D.js").then(e=>e.python())}),o.of({name:"Rust",extensions:["rs"],load:()=>import("./index-BozcvZKO.js").then(e=>e.rust())}),o.of({name:"Sass",extensions:["sass"],load:()=>import("./index-D2MvgUx2.js").then(e=>e.sass({indented:!0}))}),o.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-D2MvgUx2.js").then(e=>e.sass())}),o.of({name:"SQL",extensions:["sql"],load:()=>Td("StandardSQL")}),o.of({name:"SQLite",load:()=>Td("SQLite")}),o.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}),o.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript({typescript:!0}))}),o.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-CU5b90xS.js").then(e=>e.wast())}),o.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-DI4w9v5q.js").then(e=>e.xml())}),o.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-CZHb8PSE.js").then(e=>e.yaml())}),o.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-CXdQSnD-.js").then(e=>Od(e.apl))}),o.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D5V0T9Cu.js").then(e=>Od(e.asciiArmor))}),o.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DWPaVWf6.js").then(e=>Od(e.asn1({})))}),o.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-B46aRdXb.js").then(e=>Od(e.asterisk))}),o.of({name:"Brainfuck",extensions:["b","bf"],load:()=>import("./brainfuck-CtZaYBKt.js").then(e=>Od(e.brainfuck))}),o.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-stawOqaz.js").then(e=>Od(e.cobol))}),o.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.csharp))}),o.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Od(e.clojure))}),o.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Od(e.clojure))}),o.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-C4GSMmGA.js").then(e=>Od(e.gss))}),o.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DXn5xaP-.js").then(e=>Od(e.cmake))}),o.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-BTDxI-eT.js").then(e=>Od(e.coffeeScript))}),o.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-vq6DHwts.js").then(e=>Od(e.commonLisp))}),o.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-gJDei3ni.js").then(e=>Od(e.cypher))}),o.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-On6Xi21R.js").then(e=>Od(e.cython))}),o.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-CRzZ78HM.js").then(e=>Od(e.crystal))}),o.of({name:"D",extensions:["d"],load:()=>import("./d-BShv7fp-.js").then(e=>Od(e.d))}),o.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.dart))}),o.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-UJJ5BM9S.js").then(e=>Od(e.diff))}),o.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DVQ9Q8O9.js").then(e=>Od(e.dockerFile))}),o.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-DI9Herc-.js").then(e=>Od(e.dtd))}),o.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-DkEP81N9.js").then(e=>Od(e.dylan))}),o.of({name:"EBNF",load:()=>import("./ebnf-B-Df8AvO.js").then(e=>Od(e.ebnf))}),o.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-DPFc0Uaf.js").then(e=>Od(e.ecl))}),o.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Od(e.clojure))}),o.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-DR5c0IrL.js").then(e=>Od(e.eiffel))}),o.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DompmV0j.js").then(e=>Od(e.elm))}),o.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-BuqgqA5h.js").then(e=>Od(e.erlang))}),o.of({name:"Esper",load:()=>import("./sql-ByLYq2fX.js").then(e=>Od(e.esper))}),o.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-Bk9_H-XT.js").then(e=>Od(e.factor))}),o.of({name:"FCL",load:()=>import("./fcl-CVaBTCzQ.js").then(e=>Od(e.fcl))}),o.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-POgR1ypr.js").then(e=>Od(e.forth))}),o.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-DL7KluxX.js").then(e=>Od(e.fortran))}),o.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Od(e.fSharp))}),o.of({name:"Gas",extensions:["s"],load:()=>import("./gas-8mz5Q3qN.js").then(e=>Od(e.gas))}),o.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-B6X1vGSW.js").then(e=>Od(e.gherkin))}),o.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-DnIzCrpZ.js").then(e=>Od(e.groovy))}),o.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-CLQs6EAM.js").then(e=>Od(e.haskell))}),o.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Od(e.haxe))}),o.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Od(e.hxml))}),o.of({name:"HTTP",load:()=>import("./http-BKJkqRj4.js").then(e=>Od(e.http))}),o.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-pcmmZuaN.js").then(e=>Od(e.idl))}),o.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BVaBnk3P.js").then(e=>Od(e.jsonld))}),o.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-DjdwvFuI.js").then(e=>Od(e.julia))}),o.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.kotlin))}),o.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-HO6ttBFx.js").then(e=>Od(e.liveScript))}),o.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-BvgfYBhq.js").then(e=>Od(e.lua))}),o.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DkvFAiy5.js").then(e=>Od(e.mirc))}),o.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-IIbmv7SK.js").then(e=>Od(e.mathematica))}),o.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-DSrSSXCg.js").then(e=>Od(e.modelica))}),o.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-zvxmGV4l.js").then(e=>Od(e.mumps))}),o.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-z_N2Mo3d.js").then(e=>Od(e.mbox))}),o.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-B4hAVlXN.js").then(e=>Od(e.nginx))}),o.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-Cx8FAvMN.js").then(e=>Od(e.nsis))}),o.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-BSwWqoLa.js").then(e=>Od(e.ntriples))}),o.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.objectiveC))}),o.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.objectiveCpp))}),o.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Od(e.oCaml))}),o.of({name:"Octave",extensions:["m"],load:()=>import("./octave-C4hdQ5Hf.js").then(e=>Od(e.octave))}),o.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-qQq7irPq.js").then(e=>Od(e.oz))}),o.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-CafrKXZF.js").then(e=>Od(e.pascal))}),o.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-tdMlh9QA.js").then(e=>Od(e.perl))}),o.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CwGJVRC4.js").then(e=>Od(e.pig))}),o.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D1ly3AHC.js").then(e=>Od(e.powerShell))}),o.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-_nPj978X.js").then(e=>Od(e.properties))}),o.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-B4y9do6W.js").then(e=>Od(e.protobuf))}),o.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Dlfivyh-.js").then(e=>Od(e.pug))}),o.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-Bc-yJKzi.js").then(e=>Od(e.puppet))}),o.of({name:"Q",extensions:["q"],load:()=>import("./q-mUfi2b_o.js").then(e=>Od(e.q))}),o.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-BA4EbLKE.js").then(e=>Od(e.r))}),o.of({name:"RPM Changes",load:()=>import("./rpm-DI_rRufH.js").then(e=>Od(e.rpmChanges))}),o.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-DI_rRufH.js").then(e=>Od(e.rpmSpec))}),o.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-CR-u2WLS.js").then(e=>Od(e.ruby))}),o.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-Bqaci40L.js").then(e=>Od(e.sas))}),o.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.scala))}),o.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-qjP0V5Ag.js").then(e=>Od(e.scheme))}),o.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BLav31RL.js").then(e=>Od(e.shell))}),o.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-r025o_jW.js").then(e=>Od(e.sieve))}),o.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-C7J3IyEP.js").then(e=>Od(e.smalltalk))}),o.of({name:"Solr",load:()=>import("./solr-78MBEUkU.js").then(e=>Od(e.solr))}),o.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Od(e.sml))}),o.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-BRLJFz69.js").then(e=>Od(e.sparql))}),o.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CGlWr0eM.js").then(e=>Od(e.spreadsheet))}),o.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.squirrel))}),o.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Bdo_Aemu.js").then(e=>Od(e.stylus))}),o.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-B_XXVlXX.js").then(e=>Od(e.swift))}),o.of({name:"sTeX",load:()=>Promise.resolve().then(function(){return _d}).then(e=>Od(e.stex))}),o.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>Promise.resolve().then(function(){return _d}).then(e=>Od(e.stex))}),o.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Od(e.verilog))}),o.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-B2fODqDH.js").then(e=>Od(e.tcl))}),o.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BuVhTOzU.js").then(e=>Od(e.textile))}),o.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-BgR6AEZu.js").then(e=>Od(e.tiddlyWiki))}),o.of({name:"Tiki wiki",load:()=>import("./tiki-CI-ztowC.js").then(e=>Od(e.tiki))}),o.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BVJm5Fzd.js").then(e=>Od(e.toml))}),o.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Ce85hlLp.js").then(e=>Od(e.troff))}),o.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-BxnYHtq8.js").then(e=>Od(e.ttcn))}),o.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-CKJxb-l2.js").then(e=>Od(e.ttcnCfg))}),o.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-BkSuIpt-.js").then(e=>Od(e.turtle))}),o.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-CGwyPRYs.js").then(e=>Od(e.webIDL))}),o.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-BHgjm0DN.js").then(e=>Od(e.vb))}),o.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VzWlGt02.js").then(e=>Od(e.vbScript))}),o.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BdD_26Jv.js").then(e=>Od(e.velocity))}),o.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Od(e.verilog))}),o.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-CWWH2SUo.js").then(e=>Od(e.vhdl))}),o.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-CVDBqZPY.js").then(e=>Od(e.xQuery))}),o.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-I8QjZlxf.js").then(e=>Od(e.yacas))}),o.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-DMVFMNEx.js").then(e=>Od(e.z80))}),o.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Od(e.mscgen))}),o.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Od(e.xu))}),o.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Od(e.msgenny))}),o.of({name:"Vue",extensions:["vue"],load:()=>import("./index-C7UTkWm2.js").then(e=>e.vue())}),o.of({name:"Angular Template",load:()=>import("./index-B8r5j97Z.js").then(e=>e.angular())})];function Dd(e){function t(e,t){e.cmdState.push(t)}function n(e){return e.cmdState.length>0?e.cmdState[e.cmdState.length-1]:null}function r(e,t,n){return function(){this.name=e,this.bracketNo=0,this.style=t,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var o={};function i(e,t){e.f=t}function s(e,r){var s;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return t(r,s=new(s=o.hasOwnProperty(c)?o[c]:o.DEFAULT)),i(r,l),s.style}if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/\\]/))return"tag";if(e.match("\\["))return i(r,function(e,t){return a(e,t,"\\]")}),"keyword";if(e.match("\\("))return i(r,function(e,t){return a(e,t,"\\)")}),"keyword";if(e.match("$$"))return i(r,function(e,t){return a(e,t,"$$")}),"keyword";if(e.match("$"))return i(r,function(e,t){return a(e,t,"$")}),"keyword";var d=e.next();return"%"==d?(e.skipToEnd(),"comment"):"}"==d||"]"==d?(s=n(r))?(s.closeBracket(d),i(r,l),"bracket"):"error":"{"==d||"["==d?(t(r,s=new(s=o.DEFAULT)),"bracket"):/\d/.test(d)?(e.eatWhile(/[\w.%]/),"atom"):(e.eatWhile(/[\w\-_]/),s=function(e){for(var t=e.cmdState,n=t.length-1;n>=0;n--){var r=t[n];if("DEFAULT"!=r.name)return r}return{styleIdentifier:function(){return null}}}(r),"begin"==s.name&&(s.argument=e.current()),s.styleIdentifier())}function a(e,t,n){if(e.eatSpace())return null;if(n&&e.match(n))return i(t,s),"keyword";if(e.match(/^\\[a-zA-Z@]+/))return"tag";if(e.match(/^[a-zA-Z]+/))return"variableName.special";if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/]/))return"tag";if(e.match(/^[\^_&]/))return"tag";if(e.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(e.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var r=e.next();return"{"==r||"}"==r||"["==r||"]"==r||"("==r||")"==r?"bracket":"%"==r?(e.skipToEnd(),"comment"):"error"}function l(e,t){var r=e.peek();return"{"==r||"["==r?(n(t).openBracket(r),e.eat(r),i(t,s),"bracket"):/[ \t\r]/.test(r)?(e.eat(r),null):(i(t,s),function(e){var t=e.cmdState.pop();t&&t.closeBracket()}(t),s(e,t))}return o.importmodule=r("importmodule","tag",["string","builtin"]),o.documentclass=r("documentclass","tag",["","atom"]),o.usepackage=r("usepackage","tag",["atom"]),o.begin=r("begin","tag",["atom"]),o.end=r("end","tag",["atom"]),o.label=r("label","tag",["atom"]),o.ref=r("ref","tag",["atom"]),o.eqref=r("eqref","tag",["atom"]),o.cite=r("cite","tag",["atom"]),o.bibitem=r("bibitem","tag",["atom"]),o.Bibitem=r("Bibitem","tag",["atom"]),o.RBibitem=r("RBibitem","tag",["atom"]),o.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{name:"stex",startState:function(){return{cmdState:[],f:e?function(e,t){return a(e,t)}:s}},copyState:function(e){return{cmdState:e.cmdState.slice(),f:e.f}},token:function(e,t){return t.f(e,t)},blankLine:function(e){e.f=s,e.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const Id=Dd(!1);Dd(!0);var _d=Object.freeze({__proto__:null,stex:Id});function Rd(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new ur(i-1,s,i,s,new Kt($t.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new un(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=mr(r);if(null==a)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(i,-1)-1);xr(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos);return t(o.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+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 a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?$t.empty:$t.from(o))))return!1;let u=i.pos,h=u+s.nodeSize;return r.step(new ur(u-(a?1:0),h+(l?1:0),u+1,h-1,new Kt((a?$t.empty:$t.from(o.copy($t.empty))).append(l?$t.empty:$t.from(o.copy($t.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}function Bd(e){return String(e||"").toUpperCase()}function Ld(){return function(e){const t=function(e){const t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return K(e,"definition",function(e){const n=Bd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){const n=Bd(e);return t.get(n)}}(e);K(e,function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[J,n];if("imageReference"===e.type||"linkReference"===e.type){const o=t(e.identifier);if(o&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:o.url,title:o.title,alt:e.alt}:{type:"link",url:o.url,title:o.title,children:e.children},[J,n]}})}}function Pd(e,t){if(!(t.childCount>=1&&"hardbreak"===t.lastChild?.type.name))return void e.next(t.content);const n=[];t.content.forEach((e,r,o)=>{o!==t.childCount-1&&n.push(e)}),e.next($t.fromArray(n))}function zd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}var jd=xd("emphasis");zd(jd,{displayName:"Attr<emphasis>",group:"Emphasis"});var Vd=yd("emphasis",e=>({attrs:{marker:{default:e.get(cc).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(jd.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));zd(Vd.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),zd(Vd.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Hd=cd("ToggleEmphasis",e=>()=>Mo(Vd.type(e)));zd(Hd,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var $d=dd(e=>ii(/(?:^|[^*])\*([^*]+)\*$/,Vd.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));zd($d,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var qd=dd(e=>ii(/\b_(?![_\s])(.*?[^_\s])_\b/,Vd.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));zd(qd,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var Fd=wd("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(xc);return()=>t.call(Hd.key)}}});zd(Fd.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),zd(Fd.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var Wd=xd("strong");zd(Wd,{displayName:"Attr<strong>",group:"Strong"});var Ud=yd("strong",e=>({attrs:{marker:{default:e.get(cc).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>["strong",e.get(Wd.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));zd(Ud.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),zd(Ud.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Gd=cd("ToggleStrong",e=>()=>Mo(Ud.type(e)));zd(Gd,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var Kd=dd(e=>ii(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Ud.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));zd(Kd,{displayName:"InputRule<strong>",group:"Strong"});var Jd=wd("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(xc);return()=>t.call(Gd.key)}}});zd(Jd.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),zd(Jd.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Zd=xd("inlineCode");zd(Zd,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Yd=yd("inlineCode",e=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(Zd.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));zd(Yd.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),zd(Yd.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Xd=cd("ToggleInlineCode",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(r.empty)return!1;const{from:i,to:s}=r;return t.doc.rangeHasMark(i,s,Yd.type(e))?(n?.(o.removeMark(i,s,Yd.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==Yd.type.name).map(e=>t.schema.marks[e]).forEach(e=>{o.removeMark(i,s,e)}),n?.(o.addMark(i,s,Yd.type(e).create())),!0)});zd(Xd,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Qd=dd(e=>ii(/(?:`)([^`]+)(?:`)$/,Yd.type(e)));zd(Qd,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var eu=wd("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(xc);return()=>t.call(Xd.key)}}});zd(eu.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),zd(eu.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var tu=xd("link");zd(tu,{displayName:"Attr<link>",group:"Link"});var nu=yd("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(tu.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const r=t.url,o=t.title;e.openMark(n,{href:r,title:o}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));zd(nu.mark,{displayName:"MarkSchema<link>",group:"Link"});var ru=cd("ToggleLink",e=>(t={})=>Mo(nu.type(e),t));zd(ru,{displayName:"Command<toggleLinkCommand>",group:"Link"});var ou=cd("UpdateLink",e=>(t={})=>(n,r)=>{if(!r)return!1;let o,i=-1;const{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(nu.type(e).isInSet(t.marks))return o=t,i=n,!1}),!o)return!1;const c=o.marks.find(({type:t})=>t===nu.type(e));if(!c)return!1;const d=i,u=i+o.nodeSize,{tr:h}=n,p=nu.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(d,u,c).addMark(d,u,p).setSelection(new $r(h.selection.$anchor)).scrollIntoView()),!0)});zd(ou,{displayName:"Command<updateLinkCommand>",group:"Link"});var iu=hd("doc",()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}}));function su(e){return Z(e,e=>"html"===e.type&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;const n=t[t.length-1];if(!n)return;const r=n.children.indexOf(e);-1!==r&&n.children.splice(r,1)},!0)}zd(iu,{displayName:"NodeSchema<doc>",group:"Doc"});var au=kd("remark-preserve-empty-line",()=>()=>su);zd(au.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),zd(au.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var lu=bd("paragraph");zd(lu,{displayName:"Attr<paragraph>",group:"Paragraph"});var cu=vd("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(lu.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(t,n)=>{const r=e.get(Ql).state?.doc.lastChild;t.openNode("paragraph"),n.content&&0!==n.content.size||n===r||!function(e){let t=!1;try{e.get(au.id),t=!0}catch{t=!1}return t}(e)?Pd(t,n):t.addNode("html",void 0,"<br />"),t.closeNode()}}}));zd(cu.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),zd(cu.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var du=cd("TurnIntoText",e=>()=>So(cu.type(e)));zd(du,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var uu=wd("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(xc);return()=>t.call(du.key)}}});zd(uu.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),zd(uu.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var hu=Array(6).fill(0).map((e,t)=>t+1);var pu=gd(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");zd(pu,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var fu=bd("heading");zd(fu,{displayName:"Attr<heading>",group:"Heading"});var mu=vd("heading",e=>{const t=e.get(pu.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:hu.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw St(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(fu.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),Pd(e,t),e.closeNode()}}}});zd(mu.node,{displayName:"NodeSchema<heading>",group:"Heading"}),zd(mu.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var gu=dd(e=>Bo(/^(?<hashes>#+)\s$/,mu.type(e),t=>{const n=t.groups?.hashes?.length||0,{$from:r}=e.get(Ql).state.selection,o=r.node();if("heading"===o.type.name){let e=Number(o.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));zd(gu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var vu=cd("WrapInHeading",e=>t=>(t??=1,t<1?So(cu.type(e)):So(mu.type(e),{level:t})));zd(vu,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var yu=cd("DowngradeHeading",e=>()=>(t,n,r)=>{const{$from:o}=t.selection,i=o.node();if(i.type!==mu.type(e)||!t.selection.empty||0!==o.parentOffset)return!1;const s=i.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...i.attrs,level:s})),!0):So(cu.type(e))(t,n,r)});zd(yu,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var wu=wd("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(xc);return()=>t.call(yu.key)}}});zd(wu.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),zd(wu.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var bu=bd("blockquote");zd(bu,{displayName:"Attr<blockquote>",group:"Blockquote"});var xu=vd("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(bu.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));zd(xu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),zd(xu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var ku=dd(e=>Ro(/^\s*>\s$/,xu.type(e)));zd(ku,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Cu=cd("WrapInBlockquote",e=>()=>Co(xu.type(e)));zd(Cu,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Su=wd("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(xc);return()=>t.call(Cu.key)}}});zd(Su.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),zd(Su.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Mu=bd("codeBlock",()=>({pre:{},code:{}}));zd(Mu,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Nu=vd("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(Mu.key)(t),r=t.attrs.language,o=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...o},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const r=t.lang??"",o=t.value;e.openNode(n,{language:r}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));zd(Nu.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),zd(Nu.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Eu=dd(e=>Bo(/^```(?<language>[a-z]*)?[\s\n]$/,Nu.type(e),e=>({language:e.groups?.language??""})));zd(Eu,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Ou=cd("CreateCodeBlock",e=>(t="")=>So(Nu.type(e),{language:t}));zd(Ou,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),zd(cd("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Tu=wd("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(xc);return()=>t.call(Ou.key)}}});zd(Tu.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),zd(Tu.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Au=bd("image");zd(Au,{displayName:"Attr<image>",group:"Image"});var Du=vd("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(Au.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const r=t.url,o=t.alt,i=t.title;e.addNode(n,{src:r,alt:o,title:i})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));zd(Du.node,{displayName:"NodeSchema<image>",group:"Image"}),zd(Du.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Iu=cd("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:i="",title:s=""}=t,a=Du.type(e).create({src:o,alt:i,title:s});return!a||(r(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});zd(Iu,{displayName:"Command<insertImageCommand>",group:"Image"});var _u=cd("UpdateImage",e=>(t={})=>(n,r)=>{const o=bi(n.selection,Du.type(e));if(!o)return!1;const{node:i,pos:s}=o,a={...i.attrs},{src:l,alt:c,title:d}=t;return void 0!==l&&(a.src=l),void 0!==c&&(a.alt=c),void 0!==d&&(a.title=d),r?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});zd(_u,{displayName:"Command<updateImageCommand>",group:"Image"}),zd(dd(e=>new Io(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,o)=>{const[i,s,a="",l]=n;return i?t.tr.replaceWith(r,o,Du.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Ru=bd("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));zd(Ru,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Bu=vd("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(Ru.key)(t)," "]:["br",e.get(Ru.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{e.addNode(n,{isInline:Boolean(t.data?.isInline)})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}}));zd(Bu.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),zd(Bu.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Lu=cd("InsertHardbreak",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(!(r instanceof $r))return!1;if(r.empty){const e=r.$from.node();if(e.childCount>0&&"hardbreak"===e.lastChild?.type.name)return n?.(o.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(zr.near(o.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(o.setMeta("hardbreak",!0).replaceSelectionWith(Bu.type(e).create()).scrollIntoView()),!0});zd(Lu,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Pu=wd("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(xc);return()=>t.call(Lu.key)}}});zd(Pu.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),zd(Pu.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var zu=bd("hr");zd(zu,{displayName:"Attr<hr>",group:"Hr"});var ju=vd("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(zu.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}}));zd(ju.node,{displayName:"NodeSchema<hr>",group:"Hr"}),zd(ju.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var Vu=dd(e=>new Io(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,o)=>{const{tr:i}=t;return n[0]&&i.replaceWith(r-1,o,ju.type(e).create()),i}));zd(Vu,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var Hu=cd("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;const r=cu.node.type(e).create(),{tr:o,selection:i}=t,{from:s}=i,a=ju.type(e).create();if(!a)return!0;const l=o.replaceSelectionWith(a).insert(s,r),c=zr.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});zd(Hu,{displayName:"Command<insertHrCommand>",group:"Hr"});var $u=bd("bulletList");zd($u,{displayName:"Attr<bulletList>",group:"BulletList"});var qu=vd("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get($u.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));zd(qu.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),zd(qu.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var Fu=dd(e=>Ro(/^\s*([-+*])\s$/,qu.type(e)));zd(Fu,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Wu=cd("WrapInBulletList",e=>()=>Co(qu.type(e)));zd(Wu,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Uu=wd("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(xc);return()=>t.call(Wu.key)}}});zd(Uu.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),zd(Uu.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Gu=bd("orderedList");zd(Gu,{displayName:"Attr<orderedList>",group:"OrderedList"});var Ku=vd("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(Gu.key)(t),...1===t.attrs.order?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}}));zd(Ku.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),zd(Ku.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Ju=dd(e=>Ro(/^\s*(\d+)\.\s$/,Ku.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));zd(Ju,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Zu=cd("WrapInOrderedList",e=>()=>Co(Ku.type(e)));zd(Zu,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Yu=wd("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(xc);return()=>t.call(Zu.key)}}});zd(Yu.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),zd(Yu.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Xu=bd("listItem");zd(Xu,{displayName:"Attr<listItem>",group:"ListItem"});var Qu=vd("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(Xu.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{const r=null!=t.label?`${t.label}.`:"•",o=null!=t.label?"ordered":"bullet",i=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:r,listType:o,spread:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));zd(Qu.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),zd(Qu.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var eh=cd("SinkListItem",e=>()=>{return t=Qu.type(e),function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,e=>e.childCount>0&&e.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,o=$t.from(r?t.create():null),s=new Kt($t.from(t.create(null,$t.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(e.tr.step(new ur(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0};var t});zd(eh,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var th=cd("LiftListItem",e=>()=>Rd(Qu.type(e)));zd(th,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var nh=cd("SplitListItem",e=>()=>{return t=Qu.type(e),function(e,n){let{$from:r,$to:o,node:i}=e.selection;if(i&&i.isBlock||r.depth<2||!r.sameParent(o))return!1;let s=r.node(-1);if(s.type!=t)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=t||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let o=$t.empty,i=r.index(-1)?1:r.index(-2)?2:3;for(let e=r.depth-i;e>=r.depth-3;e--)o=$t.from(r.node(e).copy(o));let s=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;o=o.append($t.from(t.createAndFill()));let a=r.before(r.depth-(i-1)),l=e.tr.replace(a,r.after(-s),new Kt(o,4-i,0)),c=-1;l.doc.nodesBetween(a,l.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)}),c>-1&&l.setSelection(zr.near(l.doc.resolve(c))),n(l.scrollIntoView())}return!0}let a=o.pos==r.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(r.pos,o.pos),c=a?[null,{type:a}]:void 0;return!!br(l.doc,r.pos,2,c)&&(n&&n(l.split(r.pos,2,c).scrollIntoView()),!0)};var t});zd(nh,{displayName:"Command<splitListItemCommand>",group:"ListItem"});var rh=cd("LiftFirstListItem",e=>()=>function(e){return(t,n,r)=>{const{selection:o}=t;if(!(o instanceof $r))return!1;const{empty:i,$from:s}=o;return!(!i||0!==s.parentOffset)&&s.node(-1).type===Qu.type(e)&&co(t,n,r)}}(e));zd(rh,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var oh=wd("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(xc);return()=>t.call(nh.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(xc);return()=>t.call(eh.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(xc);return()=>t.call(th.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(xc);return()=>t.call(rh.key)}}});zd(oh.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),zd(oh.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var ih=hd("text",()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}}));zd(ih,{displayName:"NodeSchema<text>",group:"Text"});var sh=bd("html");zd(sh,{displayName:"Attr<html>",group:"Html"});var ah=vd("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const n=document.createElement("span"),r={...e.get(sh.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>Boolean("html"===e),runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));zd(ah.node,{displayName:"NodeSchema<html>",group:"Html"}),zd(ah.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var lh=[iu,lu,cu,pu,fu,mu,Ru,Bu,bu,xu,Mu,Nu,zu,ju,Au,Du,$u,qu,Gu,Ku,Xu,Qu,jd,Vd,Wd,Ud,Zd,Yd,tu,nu,sh,ah,ih].flat(),ch=[ku,Fu,Ju,Eu,Vu,gu].flat(),dh=[$d,qd,Qd,Kd],uh=cd("IsMarkSelected",()=>e=>t=>{if(!e)return!1;const{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),hh=cd("IsNoteSelected",()=>e=>t=>!!e&&xi(t,e).hasNode),ph=cd("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr;const{$from:r,$to:o}=n.selection,{pos:i}=r,{pos:s}=o,a=i-r.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),fh=cd("SetBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr,{from:s,to:a}=i.selection;try{i.setBlockType(s,a,r,o)}catch{return!1}return n?.(i),!0}),mh=cd("WrapInBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;let i=t.tr;try{const{$from:e,$to:t}=i.selection,n=e.blockRange(t),s=n&&gr(n,r,o);if(!s)return!1;i=i.wrap(n,s)}catch{return!1}return n?.(i),!0}),gh=cd("AddBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr;try{const e=r instanceof pn?r:r.createAndFill(o);if(!e)return!1;i.replaceSelectionWith(e)}catch{return!1}return n?.(i),!0}),vh=cd("SelectTextNearPos",()=>e=>(t,n)=>{const{pos:r}=e??{};if(null==r)return!1;const o=t.tr;try{const e=t.doc.resolve((i=r,s=0,a=t.doc.content.size,Math.min(Math.max(i,s),a)));o.setSelection($r.near(e))}catch{return!1}var i,s,a;return n?.(o.scrollIntoView()),!0}),yh=[du,Cu,vu,yu,Ou,Lu,Hu,Iu,_u,Zu,Wu,eh,nh,th,rh,Hd,Xd,Gd,ru,ou,uh,hh,ph,fh,mh,gh,vh],wh=[Su,Tu,Pu,wu,oh,Yu,Uu,uu,Fd,eu,Jd].flat(),bh=kd("remarkAddOrderInList",()=>()=>e=>{K(e,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});zd(bh.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),zd(bh.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var xh=kd("remarkLineBreak",()=>()=>e=>{const t=/[\t ]*(?:\r?\n|\r)/g;K(e,"text",(e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;const o=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&o.push({type:"text",value:e.value.slice(i,n)}),o.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return o.length>0&&r&&"number"==typeof n?(i<e.value.length&&o.push({type:"text",value:e.value.slice(i)}),r.children.splice(n,1,...o),n+o.length):void 0})});zd(xh.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),zd(xh.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var kh=kd("remarkInlineLink",()=>Ld);zd(kh.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),zd(kh.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var Ch=["root","blockquote","listItem"],Sh=kd("remarkHTMLTransformer",()=>()=>e=>{var t;t=(e,t,n)=>(e=>"html"===e.type)(e)?(n&&Ch.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e],function e(n,r,o){if((e=>!!e.children)(n)){const t=[];for(let r=0,o=n.children.length;r<o;r++){const o=n.children[r];if(o){const i=e(o,r,n);if(i)for(let e=0,n=i.length;e<n;e++){const n=i[e];n&&t.push(n)}}}n.children=t}return t(n,r,o)}(e,0,null)[0]});zd(Sh.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),zd(Sh.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var Mh=kd("remarkMarker",()=>()=>(e,t)=>{K(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)})});zd(Mh.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),zd(Mh.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Nh=pd(()=>{let e=!1;const t=new ro({key:new so("MILKDOWN_INLINE_NODES_CURSOR"),state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!(!(n&&r&&n.isInline&&!n.isText&&r.isInline)||r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e))}}),!0),compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){const e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(t.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),r=vl.widget(t,n,{side:-1}),o=document.createElement("span"),i=vl.widget(t,o);return setTimeout(()=>{n.contentEditable="true",o.contentEditable="true"}),bl.create(e.doc,[r,i])}return bl.empty}}});return t});zd(Nh,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Eh=pd(e=>new ro({key:new so("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;const[o]=t;if(!o)return;const[i]=o.steps;if(o.getMeta("hardbreak")){if(!(i instanceof dr))return;const{from:t}=i;return r.tr.setNodeMarkup(t,Bu.type(e),void 0,[])}if(i instanceof sr){let t=r.tr;const{from:n,to:o}=i;return r.doc.nodesBetween(n,o,(n,r)=>{n.type===Bu.type(e)&&(t=t.setNodeMarkup(r,Bu.type(e),void 0,[]))}),t}}}));zd(Eh,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Oh=gd(["table","code_block"],"hardbreakFilterNodes");zd(Oh,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Th=pd(e=>{const t=e.get(Oh.key);return new ro({key:new so("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const r=e.getMeta("hardbreak"),[o]=e.steps;if(r&&o){const{from:e}=o,r=n.doc.resolve(e);let i=r.depth,s=!0;for(;i>0;)t.includes(r.node(i).type.name)&&(s=!1),i--;return s}return!0}})});zd(Th,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Ah=pd(e=>{const t=new so("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const r=e.get(pu.key),o=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants((n,a)=>{if(n.type===mu.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let l=r(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(i=!0,o.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),i&&n.dispatch(o)};return new ro({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});zd(Ah,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Dh=pd(e=>new ro({key:new so("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;const o=Ku.type(e),i=qu.type(e),s=Qu.type(e),a=(e,t,n=1)=>{let r=!1;const o=`${t+n}.`;return e.label!==o&&(e.label=o,r=!0),r};let l=r.tr,c=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===i){const n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,o,{spread:"true"}),e.descendants((e,t,n,r)=>{if(e.type===s){const n={...e.attrs};a(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===o){const o={...e.attrs};let i=!1;"ordered"!==o.listType&&(o.listType="ordered",i=!0),n?.maybeChild(0)&&(i=a(o,r,n?.attrs.order??1)),i&&(l=l.setNodeMarkup(t,void 0,o),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));zd(Dh,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Ih=[lh,ch,dh,yh,wh,[Eh,Oh,Th,Nh,bh,kh,xh,Sh,Mh,au,Ah,Dh].flat()].flat(),_h=200,Rh=function(){};Rh.prototype.append=function(e){return e.length?(e=Rh.from(e),!this.length&&e||e.length<_h&&this.leafAppend(e)||this.length<_h&&e.leafPrepend(this)||this.appendInner(e)):this},Rh.prototype.prepend=function(e){return e.length?Rh.from(e).append(this):this},Rh.prototype.appendInner=function(e){return new Lh(this,e)},Rh.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Rh.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Rh.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Rh.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Rh.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Rh.from=function(e){return e instanceof Rh?e:e&&e.length?new Bh(e):Rh.empty};var Bh=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=_h)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=_h)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Rh);Rh.empty=new Bh([]);var Lh=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Rh);class Ph{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new zh(e.map));let t,o=e.step.map(n.slice(r));o&&a.maybeStep(o).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new zh(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new Ph(this.items.slice(0,o).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),d=new zh(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?o.pop():s=s.slice(0,s.length-1)),o.push(d),t&&(i++,t=void 0),r||(a=d)}let l=i-n.depth;return l>Vh&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,l),i-=l),new Ph(s.append(o),i)}remapping(e,t){let n=new tr;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Ph(this.items.append(e.map(e=>new zh(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let a=t;this.items.forEach(t=>{let r=o.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(a+1,r));c&&s++,n.push(new zh(l,i,c))}else n.push(new zh(l))},r);let l=[];for(let e=t;e<i;e++)l.push(new zh(o.maps[e]));let c=this.items.slice(0,r).append(l).append(n),d=new Ph(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&o++;let l,c=new zh(s.invert(),e,a),d=r.length-1;(l=r.length&&r[d].merge(c))?r[d]=l:r.push(c)}}else i.map&&n--},this.items.length,0),new Ph(Rh.from(r.reverse()),o)}}Ph.empty=new Ph(Rh.empty,0);class zh{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new zh(t.getMap().invert(),t,this.selection)}}}class jh{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const Vh=20;function Hh(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,o)=>t.push(r,o));return t}function $h(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let qh=!1,Fh=null;function Wh(e){let t=e.plugins;if(Fh!=t){qh=!1,Fh=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){qh=!0;break}}return qh}const Uh=new so("history"),Gh=new so("closeHistory");function Kh(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new ro({key:Uh,state:{init:()=>new jh(Ph.empty,Ph.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(Uh);if(i)return i.historyState;n.getMeta(Gh)&&(e=new jh(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Uh))return s.getMeta(Uh).redo?new jh(e.done.addTransform(n,void 0,r,Wh(t)),e.undone,Hh(n.mapping.maps),e.prevTime,e.prevComposition):new jh(e.done,e.undone.addTransform(n,void 0,r,Wh(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new jh(e.done.rebased(n,o),e.undone.rebased(n,o),$h(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new jh(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),$h(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),a=s?$h(e.prevRanges,n.mapping):Hh(n.mapping.maps);return new jh(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,Wh(t)),Ph.empty,a,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?Zh:"historyRedo"==n?Yh:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Jh(e,t){return(n,r)=>{let o=Uh.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=Wh(t),o=Uh.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),l=new jh(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(Uh,{redo:n,historyState:l})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const Zh=Jh(!1,!0),Yh=Jh(!0,!0);
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{a5 as n,o as r,e as o,f as i,l as s,C as a,c as l,b as c,J as d,a6 as u,a8 as h,X as p,Z as f,_ as m,O as g,K as v,a2 as y,aj as w,z as b,q as x,s as k,n as C,ad as S,y as M,W as N,Y as E,t as O,B as T,af as A,$ as D,R as I,v as _,a9 as R,aa as B,a4 as L,F as P,p as z}from"./light-CK5396YO.js";import{l as j,m as V,i as H,j as $,u as q,F,n as W,A as U,x as G,D as K,S as J,E as Z,v as Y,o as X,w as Q,C as ee}from"./types-DYOIqA8v.js";import te,{useRef as ne,useState as re,useMemo as oe,createContext as ie,useContext as se,useCallback as ae,useLayoutEffect as le,useEffect as ce,useImperativeHandle as de,memo as ue}from"react";import{dd as he,cW as pe,dk as fe,dg as me,aq as ge,b4 as ve,ba as ye,L as we,X as be}from"./index-DoTjNc47.js";import{R as xe,i as ke,l as Ce,t as Se}from"./ViewModuleIcon-B7qvToID.js";import{C as Me,d as Ne,i as Ee}from"./index-DUSXBI7E.js";import{c as Oe}from"./clsx-BeLtu-UY.js";import{p as Te}from"./purify.es-J-_UhghA.js";import{c as Ae,f as De,o as Ie,s as _e,b as Re}from"./floating-ui.dom-D1Wb0QDy.js";import{t as Be,d as Le}from"./throttle-_MCmQvyw.js";import{v as Pe,g as ze,c as je}from"./isSymbol-BuOnvf7n.js";import{c as Ve,i as He}from"./toNumber-DP6YK8S3.js";import{i as $e}from"./viz-BjPw9uNj.js";import{am as qe}from"./mermaid.core-DoQpgFF5.js";import{S as Fe,B as We}from"./contest-hvD3tLnF.js";import{v as Ue}from"./worksheet-BBAH_yZC.js";import{i as Ge,T as Ke}from"./index-Dwi3ag-n.js";import{C as Je}from"./settings-DgLs6IK_.js";import"./enums.js";import"./date-D28INXpp.js";import"motion/react";import"react-dom";import"./time-BHcZPeyw.js";import"swr";import"@ably/spaces";import"@ably/spaces/react";import"ably";import"ably/liveobjects";import"ably/react";import"@ably/spaces/dist/mjs/react";import"./string-CQk_HvWX.js";const Ze={}.hasOwnProperty;function Ye(e,t){let n,r=-1;if(t.extensions)for(;++r<t.extensions.length;)Ye(e,t.extensions[r]);for(n in t)if(Ze.call(t,n))switch(n){case"extensions":break;case"unsafe":case"join":Xe(e[n],t[n]);break;case"handlers":Qe(e[n],t[n]);break;default:e.options[n]=t[n]}return e}function Xe(e,t){t&&e.push(...t)}function Qe(e,t){t&&Object.assign(e,t)}const et=[function(e,t,n,r){if("code"===t.type&&j(t,r)&&("list"===e.type||e.type===t.type&&j(e,r)))return!1;if("spread"in n&&"boolean"==typeof n.spread){if("paragraph"===e.type&&(e.type===t.type||"definition"===t.type||"heading"===t.type&&V(t,r)))return;return n.spread?1:0}}];const tt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],nt=[{character:"\t",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",before:"[\\r\\n]",inConstruct:"phrasing"},{character:"\t",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:"\n",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:tt},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:"(?:[\r\n]|$)"},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:"(?:[ \t\r\n*])"},{character:"*",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"+",after:"(?:[ \t\r\n])"},{atBreak:!0,character:"-",after:"(?:[ \t\r\n-])"},{atBreak:!0,before:"\\d+",character:".",after:"(?:[ \t\r\n]|$)"},{atBreak:!0,character:"<",after:"[!/?A-Za-z]"},{character:"<",after:"[!/?A-Za-z]",inConstruct:"phrasing",notInConstruct:tt},{character:"<",inConstruct:"destinationLiteral"},{atBreak:!0,character:"="},{atBreak:!0,character:">"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:tt},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:tt},{atBreak:!0,character:"~"}];function rt(e){return e.label||!e.identifier?e.label||"":H(e.identifier)}function ot(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function it(e,t,n,r){let o=r.join.length;for(;o--;){const i=r.join[o](e,t,n,r);if(!0===i||1===i)break;if("number"==typeof i)return"\n".repeat(1+i);if(!1===i)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const st=/\r?\n|\r/g;function at(e,t){const n=[];let r,o=0,i=0;for(;r=st.exec(e);)s(e.slice(o,r.index)),n.push(r[0]),o=r.index+r[0].length,i++;return s(e.slice(o)),n.join("");function s(e){n.push(t(e,i,!e))}}function lt(e,t){return e-t}function ct(e,t){const n=/\\(?=[!-/:-@[-`{-~])/g,r=[],o=[],i=e+t;let s,a=-1,l=0;for(;s=n.exec(i);)r.push(s.index);for(;++a<r.length;)l!==r[a]&&o.push(e.slice(l,r[a])),o.push("\\"),l=r[a];return o.push(e.slice(l)),o.join("")}function dt(e){const t=e||{},n=t.now||{};let r=t.lineShift||0,o=n.line||1,i=n.column||1;return{move:function(e){const t=e||"",n=t.split(/\r?\n|\r/g),s=n[n.length-1];return o+=n.length-1,i=1===n.length?i+s.length:1+s.length+r,t},current:function(){return{now:{line:o,column:i},lineShift:r}},shift:function(e){r+=e}}}function ut(e,t){const n={associationId:rt,containerPhrasing:mt,containerFlow:gt,createTracker:dt,compilePattern:ot,enter:function(e){return n.stack.push(e),function(){n.stack.pop()}},handlers:{...W},handle:void 0,indentLines:at,indexStack:[],join:[...et],options:{},safe:vt,stack:[],unsafe:[...nt]};Ye(n,t||{}),n.options.tightDefinitions&&n.join.push(ft),n.handle=F("type",{invalid:ht,unknown:pt,handlers:n.handlers});let r=n.handle(e,void 0,n,{before:"\n",after:"\n",now:{line:1,column:1},lineShift:0});return r&&10!==r.charCodeAt(r.length-1)&&13!==r.charCodeAt(r.length-1)&&(r+="\n"),r}function ht(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function pt(e){throw new Error("Cannot handle unknown node `"+e.type+"`")}function ft(e,t){if("definition"===e.type&&e.type===t.type)return 0}function mt(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=[];let s,a=-1,l=n.before;r.push(-1);let c=t.createTracker(n);for(;++a<o.length;){const d=o[a];let u;if(r[r.length-1]=a,a+1<o.length){let n=t.handle.handlers[o[a+1].type];n&&n.peek&&(n=n.peek),u=n?n(o[a+1],e,t,{before:"",after:"",...c.current()}).charAt(0):""}else u=n.after;i.length>0&&("\r"===l||"\n"===l)&&"html"===d.type&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=t.createTracker(n),c.move(i.join("")));let h=t.handle(d,e,t,{...c.current(),after:u,before:l});s&&s===h.slice(0,1)&&(h=$(s.charCodeAt(0))+h.slice(1));const p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,s=void 0,p&&(i.length>0&&p.before&&l===i[i.length-1].slice(-1)&&(i[i.length-1]=i[i.length-1].slice(0,-1)+$(l.charCodeAt(0))),p.after&&(s=u)),c.move(h),i.push(h),l=h.slice(-1)}return r.pop(),i.join("")}(e,this,t)}function gt(e,t){return function(e,t,n){const r=t.indexStack,o=e.children||[],i=t.createTracker(n),s=[];let a=-1;for(r.push(-1);++a<o.length;){const n=o[a];r[r.length-1]=a,s.push(i.move(t.handle(n,e,t,{before:"\n",after:"\n",...i.current()}))),"list"!==n.type&&(t.bulletLastUsed=void 0),a<o.length-1&&s.push(i.move(it(n,o[a+1],e,t)))}return r.pop(),s.join("")}(e,this,t)}function vt(e,t){return function(e,t,n){const r=(n.before||"")+(t||"")+(n.after||""),o=[],i=[],s={};let a=-1;for(;++a<e.unsafe.length;){const t=e.unsafe[a];if(!q(e.stack,t))continue;const n=e.compilePattern(t);let i;for(;i=n.exec(r);){const e="before"in t||Boolean(t.atBreak),n="after"in t,r=i.index+(e?i[1].length:0);o.includes(r)?(s[r].before&&!e&&(s[r].before=!1),s[r].after&&!n&&(s[r].after=!1)):(o.push(r),s[r]={before:e,after:n})}}o.sort(lt);let l=n.before?n.before.length:0;const c=r.length-(n.after?n.after.length:0);for(a=-1;++a<o.length;){const e=o[a];e<l||e>=c||e+1<c&&o[a+1]===e+1&&s[e].after&&!s[e+1].before&&!s[e+1].after||o[a-1]===e-1&&s[e].before&&!s[e-1].before&&!s[e-1].after||(l!==e&&i.push(ct(r.slice(l,e),"\\")),l=e,!/[!-/:-@[-`{-~]/.test(r.charAt(e))||n.encode&&n.encode.includes(r.charAt(e))?(i.push($(r.charCodeAt(e))),l++):i.push("\\"))}return i.push(ct(r.slice(l,c),n.after)),i.join("")}(this,e,t)}var yt=function(e){return e.docTypeError="docTypeError",e.contextNotFound="contextNotFound",e.timerNotFound="timerNotFound",e.ctxCallOutOfScope="ctxCallOutOfScope",e.createNodeInParserFail="createNodeInParserFail",e.stackOverFlow="stackOverFlow",e.parserMatchError="parserMatchError",e.serializerMatchError="serializerMatchError",e.getAtomFromSchemaFail="getAtomFromSchemaFail",e.expectDomTypeError="expectDomTypeError",e.callCommandBeforeEditorView="callCommandBeforeEditorView",e.missingRootElement="missingRootElement",e.missingNodeInSchema="missingNodeInSchema",e.missingMarkInSchema="missingMarkInSchema",e.ctxNotBind="ctxNotBind",e.missingYjsDoc="missingYjsDoc",e.aiProviderError="aiProviderError",e.aiBuildContextError="aiBuildContextError",e}({}),wt=class extends Error{constructor(e,t,n){super(t,n),this.name="MilkdownError",this.code=e,void 0!==n?.cause&&(this.cause=n.cause)}},bt=(e,t)=>"function"==typeof t?"[Function]":t,xt=e=>JSON.stringify(e,bt);function kt(){return new wt(yt.ctxCallOutOfScope,"Should not call a context out of the plugin.")}function Ct(){return new wt(yt.stackOverFlow,"Stack over flow, cannot pop on an empty stack.")}function St(e){return new wt(yt.expectDomTypeError,`Expect to be a dom, but get: ${xt(e)}.`)}function Mt(){return new wt(yt.callCommandBeforeEditorView,"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized")}function Nt(e){return new wt(yt.missingNodeInSchema,`Missing node in schema, milkdown cannot find "${e}" in schema.`)}function Et(e){try{return xt(e)}catch{return"[Unserializable]"}}var Ot=class{constructor(){this.sliceMap=new Map,this.get=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);if(!t)throw n="string"==typeof e?e:e.name,new wt(yt.contextNotFound,`Context "${n}" not found, do you forget to inject it?`);var n;return t},this.remove=e=>{const t="string"==typeof e?[...this.sliceMap.values()].find(t=>t.type.name===e):this.sliceMap.get(e.id);t&&this.sliceMap.delete(t.type.id)},this.has=e=>"string"==typeof e?[...this.sliceMap.values()].some(t=>t.type.name===e):this.sliceMap.has(e.id)}},Tt=class{#e;#t;#n;constructor(e,t,n){this.#e=[],this.#n=()=>{this.#e.forEach(e=>e(this.#t))},this.set=e=>{this.#t=e,this.#n()},this.get=()=>this.#t,this.update=e=>{this.#t=e(this.#t),this.#n()},this.type=n,this.#t=t,e.set(n.id,this)}on(e){return this.#e.push(e),()=>{this.#e=this.#e.filter(t=>t!==e)}}once(e){const t=this.on(n=>{e(n),t()});return t}off(e){this.#e=this.#e.filter(t=>t!==e)}offAll(){this.#e=[]}},At=class{constructor(e,t){this.id=Symbol(`Context-${t}`),this.name=t,this._defaultValue=e,this._typeInfo=()=>{throw kt()}}create(e,t=this._defaultValue){return new Tt(e,t,this)}},Dt=(e,t)=>new At(e,t),It=class{#r;#o;#i;#s;#a;#l;#c;constructor(e,t,n){this.#s=new Set,this.#a=new Set,this.#l=new Map,this.#c=new Map,this.read=()=>({metadata:this.#r,injectedSlices:[...this.#s].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),consumedSlices:[...this.#a].map(e=>({name:"string"==typeof e?e:e.name,value:this.#d(e)})),recordedTimers:[...this.#l].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)})),waitTimers:[...this.#c].map(([e,{duration:t}])=>({name:e.name,duration:t,status:this.#u(e)}))}),this.onRecord=e=>{this.#l.set(e,{start:Date.now(),duration:0})},this.onClear=e=>{this.#l.delete(e)},this.onDone=e=>{const t=this.#l.get(e);t&&(t.duration=Date.now()-t.start)},this.onWait=(e,t)=>{const n=Date.now();t.finally(()=>{this.#c.set(e,{duration:Date.now()-n})}).catch(console.error)},this.onInject=e=>{this.#s.add(e)},this.onRemove=e=>{this.#s.delete(e)},this.onUse=e=>{this.#a.add(e)},this.#d=e=>this.#o.get(e).get(),this.#u=e=>this.#i.get(e).status,this.#o=e,this.#i=t,this.#r=n}#d;#u},_t=class e{#o;#i;#r;#h;constructor(t,n,r){this.produce=t=>t&&Object.keys(t).length?new e(this.#o,this.#i,{...t}):this,this.inject=(e,t)=>{const n=e.create(this.#o.sliceMap);return null!=t&&n.set(t),this.#h?.onInject(e),this},this.remove=e=>(this.#o.remove(e),this.#h?.onRemove(e),this),this.record=e=>(e.create(this.#i.store),this.#h?.onRecord(e),this),this.clearTimer=e=>(this.#i.remove(e),this.#h?.onClear(e),this),this.isInjected=e=>this.#o.has(e),this.isRecorded=e=>this.#i.has(e),this.use=e=>(this.#h?.onUse(e),this.#o.get(e)),this.get=e=>this.use(e).get(),this.set=(e,t)=>this.use(e).set(t),this.update=(e,t)=>this.use(e).update(t),this.timer=e=>this.#i.get(e),this.done=e=>{this.timer(e).done(),this.#h?.onDone(e)},this.wait=e=>{const t=this.timer(e).start();return this.#h?.onWait(e,t),t},this.waitTimers=async e=>{await Promise.all(this.get(e).map(e=>this.wait(e)))},this.#o=t,this.#i=n,this.#r=r,r&&(this.#h=new It(t,n,r))}get meta(){return this.#r}get inspector(){return this.#h}},Rt=class{constructor(){this.store=new Map,this.get=e=>{const t=this.store.get(e.id);if(!t)throw n=e.name,new wt(yt.timerNotFound,`Timer "${n}" not found, do you forget to record it?`);var n;return t},this.remove=e=>{this.store.delete(e.id)},this.has=e=>this.store.has(e.id)}},Bt=class{#p;#f;#m;#g;constructor(e,t){this.#p=null,this.#f=null,this.#g="pending",this.start=()=>(this.#p??=new Promise((e,t)=>{this.#f=t=>{t instanceof CustomEvent&&t.detail.id===this.#m&&(this.#g="resolved",this.#v(),t.stopImmediatePropagation(),e())},this.#y(()=>{"pending"===this.#g&&(this.#g="rejected"),this.#v(),t(new Error(`Timing ${this.type.name} timeout.`))}),this.#g="pending",addEventListener(this.type.name,this.#f)}),this.#p),this.done=()=>{const e=new CustomEvent(this.type.name,{detail:{id:this.#m}});dispatchEvent(e)},this.#v=()=>{this.#f&&removeEventListener(this.type.name,this.#f)},this.#y=e=>{setTimeout(()=>{e()},this.type.timeout)},this.#m=Symbol(t.name),this.type=t,e.set(t.id,this)}get status(){return this.#g}#v;#y},Lt=class{constructor(e,t=3e3){this.create=e=>new Bt(e,this),this.id=Symbol(`Timer-${e}`),this.name=e,this.timeout=t}},Pt=(e,t=3e3)=>new Lt(e,t);function zt(e){const t=this;t.compiler=function(n){return ut(n,{...t.data("settings"),...e,extensions:t.data("toMarkdownExtensions")||[]})}}function jt(e){this.content=e}function Vt(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),i=t.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let e=0;o.text[e]==i.text[e];e++)n++;return n}if(o.content.size||i.content.size){let e=Vt(o.content,i.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function Ht(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let e=0,t=Math.min(s.text.length,a.text.length);for(;e<t&&s.text[s.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let e=Ht(s.content,a.content,n-1,r-1);if(e)return e}n-=l,r-=l}else n-=l,r-=l}}jt.prototype={constructor:jt,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,o=r.find(e),i=r.content.slice();return-1==o?i.push(n||e,t):(i[o+1]=t,n&&(i[o]=n)),new jt(i)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new jt(n)},addToStart:function(e,t){return new jt([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new jt(n)},addBefore:function(e,t,n){var r=this.remove(t),o=r.content.slice(),i=r.find(e);return o.splice(-1==i?o.length:i,0,t,n),new jt(o)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=jt.from(e)).size?new jt(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=jt.from(e)).size?new jt(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=jt.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},jt.from=function(e){if(e instanceof jt)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new jt(t)};let $t=class e{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let a=this.content[i],l=s+a.nodeSize;if(l>e&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,e-o),Math.min(a.content.size,t-o),n,r+o)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.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<t.content.length;i++)o.push(t.content[i]);return new e(o,this.size+t.size)}cut(t,n=this.size){if(0==t&&n==this.size)return this;let r=[],o=0;if(n>t)for(let e=0,i=0;i<n;e++){let s=this.content[e],a=i+s.nodeSize;a>t&&((i<t||a>n)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,n-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,n-i-1))),r.push(s),o+=s.nodeSize),i=a}return new e(r,o)}cutByIndex(t,n){return t==n?e.empty:0==t&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[t]=n,new e(o,i)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Vt(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Ht(this,e,t,n)}findIndex(e){if(0==e)return Ft(0,e);if(e==this.size)return Ft(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?Ft(t+1,r):Ft(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let o=t[e];r+=o.nodeSize,e&&o.isText&&t[e-1].sameMarkup(o)?(n||(n=t.slice(0,e)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};$t.empty=new $t([],0);const qt={index:0,offset:0};function Ft(e,t){return qt.index=e,qt.offset=t,qt}function Wt(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Wt(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Wt(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class Ut{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Wt(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return Ut.none;if(e instanceof Ut)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}Ut.none=[];class Gt extends Error{}class Kt{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Zt(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new Kt(n,this.openStart,this.openEnd)}removeBetween(e,t){return new Kt(Jt(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Kt.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new Kt($t.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new Kt(e,n,r)}}function Jt(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:a}=e.findIndex(n);if(o==t||i.isText){if(a!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(Jt(i.content,t-o-1,n-o-1)))}function Zt(e,t,n,r,o,i){let{index:s,offset:a}=e.findIndex(t),l=e.maybeChild(s);if(a==t||l.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Zt(l.content,t-a-1,n,0==s?r-1:0,s==e.childCount-1?o-1:0,l);return c&&e.replaceChild(s,l.copy(c))}function Yt(e,t,n){if(n.openStart>e.depth)throw new Gt("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Gt("Inconsistent open depths");return Xt(e,t,n,0)}function Xt(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=Xt(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy($t.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return rn(i,on(e,o,s,t,r))}{let r=e.parent,o=r.content;return rn(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return rn(i,sn(e,t,r))}function Qt(e,t){if(!t.type.compatibleContent(e.type))throw new Gt("Cannot join "+t.type.name+" onto "+e.type.name)}function en(e,t,n){let r=e.node(n);return Qt(r,t.node(n)),r}function tn(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function nn(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(tn(e.nodeAfter,r),i++));for(let e=i;e<s;e++)tn(o.child(e),r);t&&t.depth==n&&t.textOffset&&tn(t.nodeBefore,r)}function rn(e,t){return e.type.checkContent(t),e.copy(t)}function on(e,t,n,r,o){let i=e.depth>o&&en(e,t,o+1),s=r.depth>o&&en(n,r,o+1),a=[];return nn(null,e,o,a),i&&s&&t.index(o)==n.index(o)?(Qt(i,s),tn(rn(i,on(e,t,n,r,o+1)),a)):(i&&tn(rn(i,sn(e,t,o+1)),a),nn(t,n,o,a),s&&tn(rn(s,sn(n,r,o+1)),a)),nn(r,null,o,a),new $t(a)}function sn(e,t,n){let r=[];if(nn(null,e,n,r),e.depth>n){tn(rn(en(e,t,n+1),sn(e,t,n+1)),r)}return nn(t,null,n,r),new $t(r)}Kt.empty=new Kt($t.empty,0,0);class an{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return Ut.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new un(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new an(t,n,o)}static resolveCached(e,t){let n=dn.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else dn.set(e,n=new ln);let r=n.elts[n.i]=an.resolve(e,t);return n.i=(n.i+1)%cn,r}}class ln{constructor(){this.elts=[],this.i=0}}const cn=12,dn=new WeakMap;class un{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}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 hn=Object.create(null);class pn{constructor(e,t,n,r=Ut.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||$t.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Wt(this.attrs,t||e.defaultAttrs||hn)&&Ut.sameSet(this.marks,n||Ut.none)}copy(e=null){return e==this.content?this:new pn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new pn(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Kt.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new Kt(a,r.depth-i,o.depth-i)}replace(e,t,n){return Yt(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return an.resolveCached(this,e)}resolveNoCache(e){return an.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),mn(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=$t.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}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=Ut.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Ut.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=$t.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}}pn.prototype.text=void 0;let fn=class e extends pn{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):mn(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function mn(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class gn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new vn(e,t);if(null==n.next)return gn.empty;let r=yn(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(Sn(e,0));function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);Sn(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new gn(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(Cn);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();o(i(e.expr,s),t),s=t}if(-1==e.max)o(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),o(i(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(e.exprs[r],t);if(r==e.exprs.length-1)return s;o(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function o(i,s){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return $t.from(s.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.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=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}gn.empty=new gn(!0);class vn{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function yn(e){let t=[];do{t.push(wn(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function wn(e){let t=[];do{t.push(bn(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function bn(e){let t=function(e){if(e.eat("(")){let t=yn(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=kn(e,t)}return t}function xn(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function kn(e,t){let n=xn(e),r=n;return e.eat(",")&&(r="}"!=e.next?xn(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function Cn(e,t){return t-e}function Sn(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(Cn)}function Mn(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Nn(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function En(e,t,n,r){for(let r in t)if(!(r in e))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function On(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new An(e,r,t[r]);return n}let Tn=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=On(e,n.attrs),this.defaultAttrs=Mn(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==gn.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:Nn(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pn(this,this.computeAttrs(e),$t.from(t),Ut.setFrom(n))}createChecked(e=null,t,n){return t=$t.from(t),this.checkContent(t),new pn(this,this.computeAttrs(e),t,Ut.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=$t.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore($t.empty,!0);return o?new pn(this,e,t.append(o),Ut.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).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){En(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:Ut.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,o)=>r[t]=new e(t,n,o));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 e in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class An{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Dn{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=On(e,r.attrs),this.excluded=null;let o=Mn(this.attrs);this.instance=o?new Ut(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ut(this,Nn(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new Dn(e,r++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){En(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class In{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=jt.from(e.nodes),t.marks=jt.from(e.marks||{}),this.nodes=Tn.compile(this.spec.nodes,this),this.marks=Dn.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=gn.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?_n(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:_n(this,n.split(" "))}this.nodeFromJSON=e=>pn.fromJSON(this,e),this.markFromJSON=e=>Ut.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof Tn))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new fn(n,n.defaultAttrs,e,Ut.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function _n(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Rn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Vn(this,t,!1);return n.addAll(e,Ut.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Vn(this,t,!0);return n.addAll(e,Ut.none,t.from,t.to),Kt.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Hn(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=$n(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=$n(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Rn(e,Rn.schemaRules(e)))}}const Bn={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},Ln={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pn={ol:!0,ul:!0};function zn(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class jn{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=Ut.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore($t.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=$t.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore($t.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Bn.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Vn{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=zn(null,t.preserveWhitespace,0)|(n?4:0);r=o?new jn(o.type,o.attrs,Ut.none,!0,t.topMatch||o.type.contentMatch,i):new jn(n?null:e.schema.topNodeType,null,Ut.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Pn.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Pn.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Ln.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);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 n,r=this.needsBlock;if(Bn.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=a&&a.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!r||r.length>a.length+i)&&(r=a,o=s,!a.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=Ut.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):qn(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=zn(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=Ut.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):qn(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new jn(e,t,a,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].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 t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function Hn(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function $n(e){let t={};for(let n in e)t[n]=e[n];return t}function qn(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Fn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=Un(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Un(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Jn(Un(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Jn(Un(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:Jn(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Fn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Wn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return Wn(e.marks)}}function Wn(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Un(e){return e.document||window.document}const Gn=new WeakMap;function Kn(e){let t=Gn.get(e);return void 0===t&&Gn.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function Jn(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Kn(r))&&o.indexOf(t)>-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,a=i.indexOf(" ");a>0&&(n=i.slice(0,a),i=i.slice(a+1));let l=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?l.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&l.style?l.style.cssText=c[e]:l.setAttribute(e,c[e])}}for(let o=d;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}if("string"==typeof i)l.appendChild(e.createTextNode(i));else{let{dom:t,contentDOM:o}=Jn(e,i,n,r);if(l.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:l,contentDOM:s}}const Zn=Math.pow(2,16);function Yn(e,t){return e+t*Zn}function Xn(e){return 65535&e}class Qn{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class er{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&er.empty)return er.empty}recover(e){let t=0,n=Xn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/Zn}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>e)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(e<=d){let o=a+r+((l?e==a?-1:e==d?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?a:d)?null:Yn(s/3,e-a),u=e==a?2:e==d?1:4;return(t<0?e!=a:e!=d)&&(u|=8),new Qn(o,u,i)}r+=c-l}return n?e+r:new Qn(e+r,0,null)}touches(e,t){let n=0,r=Xn(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let a=this.ranges[t+o];if(e<=s+a&&t==3*r)return!0;n+=this.ranges[t+i]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+t],c=this.ranges[r+n];e(s,s+l,a,a+c),o+=c-l}}invert(){return new er(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?er.empty:new er(e<0?[0,-e,0]:[0,0,e])}}er.empty=new er([]);class tr{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new tr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new tr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new Qn(e,r,null)}}const nr=Object.create(null);class rr{getMap(){return er.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=nr[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in nr)throw new RangeError("Duplicate use of step JSON ID "+e);return nr[e]=t,t.prototype.jsonID=e,t}}class or{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new or(e,null)}static fail(e){return new or(null,e)}static fromReplace(e,t,n,r){try{return or.ok(e.replace(t,n,r))}catch(e){if(e instanceof Gt)return or.fail(e.message);throw e}}}function ir(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(ir(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return $t.fromArray(r)}class sr extends rr{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new Kt(ir(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return or.fromReplace(e,this.from,this.to,o)}invert(){return new ar(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new sr(t.pos,n.pos,this.mark)}merge(e){return e instanceof sr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new sr(t.from,t.to,e.markFromJSON(t.mark))}}rr.jsonID("addMark",sr);class ar extends rr{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Kt(ir(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return or.fromReplace(e,this.from,this.to,n)}invert(){return new sr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ar(t.pos,n.pos,this.mark)}merge(e){return e instanceof ar&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ar(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ar(t.from,t.to,e.markFromJSON(t.mark))}}rr.jsonID("removeMark",ar);class lr extends rr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return or.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return or.fromReplace(e,this.pos,this.pos+1,new Kt($t.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new lr(this.pos,t.marks[n]);return new lr(this.pos,this.mark)}}return new cr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new lr(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new lr(t.pos,e.markFromJSON(t.mark))}}rr.jsonID("addNodeMark",lr);class cr extends rr{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return or.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return or.fromReplace(e,this.pos,this.pos+1,new Kt($t.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new lr(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new cr(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new cr(t.pos,e.markFromJSON(t.mark))}}rr.jsonID("removeNodeMark",cr);class dr extends rr{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&hr(e,this.from,this.to)?or.fail("Structure replace would overwrite content"):or.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new er([this.from,this.to-this.from,this.slice.size])}invert(e){return new dr(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&dr.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new dr(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof dr)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new dr(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?Kt.empty:new Kt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new dr(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new dr(t.from,t.to,Kt.fromJSON(e,t.slice),!!t.structure)}}dr.MAP_BIAS=1,rr.jsonID("replace",dr);class ur extends rr{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(hr(e,this.from,this.gapFrom)||hr(e,this.gapTo,this.to)))return or.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return or.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?or.fromReplace(e,this.from,this.to,n):or.fail("Content does not fit in gap")}getMap(){return new er([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ur(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new ur(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ur(t.from,t.to,t.gapFrom,t.gapTo,Kt.fromJSON(e,t.slice),t.insert,!!t.structure)}}function hr(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function pr(e,t,n,r=n.contentMatch,o=!0){let i=e.doc.nodeAt(t),s=[],a=t+1;for(let t=0;t<i.childCount;t++){let l=i.child(t),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let t=0;t<l.marks.length;t++)n.allowsMarkType(l.marks[t].type)||e.step(new ar(a,c,l.marks[t]));if(o&&l.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(l.text);)t||(t=new Kt($t.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new dr(a+e.index,a+e.index+e[0].length,t))}}else s.push(new dr(a,c,Kt.empty));a=c}if(!r.validEnd){let t=r.fillBefore($t.empty,!0);e.replace(a,a,new Kt(t,0,0))}for(let t=s.length-1;t>=0;t--)e.step(s[t])}function fr(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function mr(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,a=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,a,t))return n;if(0==n||i.type.spec.isolating||!fr(i,s,a))break;s&&(r=1),a<i.childCount&&(o=1)}return null}function gr(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;a&&e<o;e++)a=a.matchType(n.child(e).type);return a&&a.validEnd?s:null}(r,t);return i?o.map(vr).concat({type:t,attrs:n}).concat(i.map(vr)):null}function vr(e){return{type:e,attrs:null}}function yr(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function wr(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function br(e,t,n=1,r){let o=e.resolve(t),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 e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function xr(e,t){let n=e.resolve(t),r=n.index();return o=n.nodeBefore,i=n.nodeAfter,!(!o||!i||o.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(o,i))&&n.parent.canReplace(r,r+1);var o,i}function kr(e,t,n=t,r=Kt.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Cr(o,i,r)?new dr(t,n,r):new Sr(o,i,r).fit()}function Cr(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}rr.jsonID("replaceAround",ur);class Sr{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=$t.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=$t.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new Kt(o,i,s);return e>-1?new ur(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new dr(n.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Er(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:s,match:a}=this.frontier[e],l=null;if(1==t&&(o?a.matchType(o.type)||(l=a.fillBefore($t.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(2==t&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Er(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new Kt(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Er(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new Kt(Mr(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new Kt(Mr(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-e,l=0,c=[],{match:d,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)c.push(r.child(e));d=d.matchFragment(r)}let h=s.size+e-(i.content.size-i.openEnd);for(;l<s.childCount;){let e=s.child(l),t=d.matchType(e.type);if(!t)break;l++,(l>1||0==a||e.content.size)&&(d=t,c.push(Or(e.mark(u.allowedMarks(e.marks)),1==l?a:0,l==s.childCount?h:-1)))}let p=l==s.childCount;p||(h=-1),this.placed=Nr(this.placed,t,$t.from(c)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=s;e<h;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?0==e?Kt.empty:new Kt(Mr(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Kt(Mr(i.content,e,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Tr(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Tr(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Tr(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Nr(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Nr(this.placed,this.depth,$t.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore($t.empty,!0);e.childCount&&(this.placed=Nr(this.placed,this.frontier.length,e))}}function Mr(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Mr(e.firstChild.content,t-1,n)))}function Nr(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Nr(e.lastChild.content,t-1,n)))}function Er(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Or(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Or(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore($t.empty,!0)))),e.copy(r)}function Tr(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function Ar(e){return e.spec.defining||e.spec.definingForContent}function Dr(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(Dr(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore($t.empty,!0))}return e}function Ir(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class _r extends rr{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return or.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return or.fromReplace(e,this.pos,this.pos+1,new Kt($t.from(r),0,t.isLeaf?0:1))}getMap(){return er.empty}invert(e){return new _r(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new _r(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new _r(t.pos,t.attr,t.value)}}rr.jsonID("attr",_r);class Rr extends rr{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return or.ok(n)}getMap(){return er.empty}invert(e){return new Rr(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Rr(t.attr,t.value)}}rr.jsonID("docAttr",Rr);let Br=class extends Error{};Br=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(Br.prototype=Object.create(Error.prototype)).constructor=Br,Br.prototype.name="TransformError";class Lr{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Br(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,o,i)=>{e=Math.min(e,o),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Kt.empty){let r=kr(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Kt($t.from(n),0,0))}delete(e,t){return this.replace(e,t,Kt.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Cr(o,i,r))return e.step(new dr(t,n,r));let s=Ir(o,i);0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?a=e:o.before(e)==t&&s.splice(1,0,-e)}let l=s.indexOf(a),c=[],d=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=Ar(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let a=(t+d+1)%(r.openStart+1),u=c[a];if(u)for(let t=0;t<s.length;t++){let c=s[(t+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let h=o.node(c-1),p=o.index(c-1);if(h.canReplaceWith(p,p,u.type,u.marks))return e.replace(o.before(c),d?i.after(c):n,new Kt(Dr(r.content,0,r.openStart,a),a,r.openEnd))}}let u=e.steps.length;for(let a=s.length-1;a>=0&&(e.replace(t,n,r),!(e.steps.length>u));a--){let e=s[a];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new Kt($t.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){let i=r.sharedDepth(n),s=!1;for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=o.depth;e>0&&n==o.start(e);e--)n=o.before(e);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let i=Ir(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:i}=t,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=$t.empty,u=0;for(let e=i,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,d=$t.from(r.node(e).copy(d)),u++):l--;let h=$t.empty,p=0;for(let e=i,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,h=$t.from(o.node(e).copy(h)),p++):c++;e.step(new ur(l,c,s,a,new Kt(d.append(h),u,p),d.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let a=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);wr(e,r.node(),r.before(),a)}s.inlineContent&&pr(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let l=e.mapping.slice(a),c=l.map(t-n);if(e.step(new dr(c,l.map(t+n,-1),Kt.empty,!0)),!0===r){let t=e.doc.resolve(c);yr(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=$t.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=$t.from(n[e].type.create(n[e].attrs,r))}let o=t.start,i=t.end;e.step(new ur(o,i,o,i,new Kt(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let s="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,s)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&wr(e,t,n,i),pr(e,e.mapping.slice(i).map(n,1),r,void 0,null===o);let a=e.mapping.slice(i),l=a.map(n,1),c=a.map(n+t.nodeSize,1);return e.step(new ur(l,c,l+1,c-1,new Kt($t.from(r.create(s,null,t.marks)),0,0),1,!0)),!0===o&&yr(e,t,n,i),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let i=e.doc.nodeAt(t);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 e.replaceWith(t,t+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new ur(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new Kt($t.from(s),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new _r(e,t,n)),this}setDocAttribute(e,t){return this.step(new Rr(e,t)),this}addNodeMark(e,t){return this.step(new lr(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof Ut)t.isInSet(n.marks)&&this.step(new cr(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new cr(e,r)),o=r.removeFromSet(o);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),i=$t.empty,s=$t.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){i=$t.from(o.node(e).copy(i));let t=r&&r[a];s=$t.from(t?t.type.create(t.attrs,s):o.node(e).copy(s))}e.step(new dr(t,t,new Kt(i.append(s),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],a=[];e.doc.nodesBetween(t,n,(e,l,c)=>{if(!e.isInline)return;let d=e.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,t),u=Math.min(l+e.nodeSize,n),h=r.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(h)||(o&&o.to==c&&o.mark.eq(d[e])?o.to=u:s.push(o=new ar(c,u,d[e])));i&&i.to==c?i.to=u:a.push(i=new sr(c,u,r))}}),s.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let a=null;if(r instanceof Dn){let t,n=e.marks;for(;t=r.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(a=[r]):a=e.marks;if(a&&a.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,l=a[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&l.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,t),to:r,step:i})}}}),o.forEach(t=>e.step(new ar(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return pr(this,e,t,n),this}}const Pr=Object.create(null);class zr{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new jr(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Kt.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(a.pos),c.map(l.pos),s?Kt.empty:t),0==s&&Jr(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=e.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?e.deleteRange(l,c):(e.replaceRangeWith(l,c,t),Jr(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new $r(e):Kr(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?Kr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Kr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ur(e.node(0))}static atStart(e){return Kr(e,e,0,0,1)||new Ur(e)}static atEnd(e){return Kr(e,e,e.content.size,e.childCount,-1)||new Ur(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Pr[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Pr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Pr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return $r.between(this.$anchor,this.$head).getBookmark()}}zr.prototype.visible=!0;class jr{constructor(e,t){this.$from=e,this.$to=t}}let Vr=!1;function Hr(e){Vr||e.parent.inlineContent||(Vr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class $r extends zr{constructor(e,t=e){Hr(e),Hr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return zr.near(n);let r=e.resolve(t.map(this.anchor));return new $r(r.parent.inlineContent?r:n,n)}replace(e,t=Kt.empty){if(super.replace(e,t),t==Kt.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof $r&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new qr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new $r(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=zr.findFrom(t,n,!0)||zr.findFrom(t,-n,!0);if(!e)return zr.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(zr.findFrom(e,-n,!0)||zr.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new $r(e,t)}}zr.jsonID("text",$r);class qr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new qr(e.map(this.anchor),e.map(this.head))}resolve(e){return $r.between(e.resolve(this.anchor),e.resolve(this.head))}}class Fr extends zr{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?zr.near(o):new Fr(o)}content(){return new Kt($t.from(this.node),0,0)}eq(e){return e instanceof Fr&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Wr(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Fr(e.resolve(t.anchor))}static create(e,t){return new Fr(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}Fr.prototype.visible=!1,zr.jsonID("node",Fr);class Wr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new qr(n,n):new Wr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Fr.isSelectable(n)?new Fr(t):zr.near(t)}}class Ur extends zr{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Kt.empty){if(t==Kt.empty){e.delete(0,e.doc.content.size);let t=zr.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ur(e)}map(e){return new Ur(e)}eq(e){return e instanceof Ur}getBookmark(){return Gr}}zr.jsonID("all",Ur);const Gr={map(){return this},resolve:e=>new Ur(e)};function Kr(e,t,n,r,o,i=!1){if(t.inlineContent)return $r.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&Fr.isSelectable(r))return Fr.create(e,n-(o<0?r.nodeSize:0))}else{let t=Kr(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function Jr(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof dr||i instanceof ur)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==o&&(o=r)}),e.setSelection(zr.near(e.doc.resolve(o),n)))}class Zr extends Lr{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=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return Ut.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ut.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(zr.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Yr(e,t){return t&&e?e.bind(t):e}class Xr{constructor(e,t,n){this.name=e,this.init=Yr(t.init,n),this.apply=Yr(t.apply,n)}}const Qr=[new Xr("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new Xr("selection",{init:(e,t)=>e.selection||zr.atStart(t.doc),apply:e=>e.selection}),new Xr("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new Xr("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class eo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qr.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Xr(e.key,e.spec.state,e))})}}class to{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,c=a<t.length&&s.spec.appendTransaction.call(s,a?t.slice(a):t,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new to(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Zr(this)}static create(e){let t=new eo(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new to(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new eo(this.schema,e.plugins),n=t.fields,r=new to(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new eo(e.schema,e.plugins),o=new to(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=pn.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=zr.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=a.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}}),o}}function no(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=no(o,t,{})),n[r]=o}return n}class ro{constructor(e){this.spec=e,this.props={},e.props&&no(e.props,this,this.props),this.key=e.key?e.key.key:io("plugin")}getState(e){return e[this.key]}}const oo=Object.create(null);function io(e){return e in oo?e+"$"+ ++oo[e]:(oo[e]=0,e+"$")}class so{constructor(e="key"){this.key=io(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ao=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const co=(e,t,n)=>{let r=lo(e,n);if(!r)return!1;let o=fo(r);if(!o){let n=r.blockRange(),o=n&&mr(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(wo(e,o,t,-1))return!0;if(0==r.parent.content.size&&(ho(i,"end")||Fr.isSelectable(i)))for(let n=r.depth;;n--){let s=kr(e.doc,r.before(n),r.after(n),Kt.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(ho(i,"end")?zr.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Fr.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0)},uo=(e,t,n)=>{let r=lo(e,n);if(!r)return!1;let o=fo(r);return!!o&&function(e,t,n){let r=t.nodeBefore,o=r,i=t.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=e}let s=t.nodeAfter,a=s,l=t.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let c=kr(e.doc,i,l,Kt.empty);if(!c||c.from!=i||c instanceof dr&&c.slice.size>=l-i)return!1;if(n){let t=e.tr.step(c);t.setSelection($r.create(t.doc,i)),n(t.scrollIntoView())}return!0}(e,o,t)};function ho(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const po=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=fo(r)}let s=i&&i.nodeBefore;return!(!s||!Fr.isSelectable(s))&&(t&&t(e.tr.setSelection(Fr.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function fo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function mo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}function go(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const vo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=go(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(zr.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0};const yo=(e,t)=>{let{$from:n,$to:r}=e.selection;if(e.selection instanceof Fr&&e.selection.node.isBlock)return!(!n.parentOffset||!br(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0));if(!n.depth)return!1;let o,i,s=[],a=!1,l=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){a=n.end(e)==n.pos+(n.depth-e),l=n.start(e)==n.pos-(n.depth-e),i=go(n.node(e-1).contentMatchAt(n.indexAfter(e-1))),s.unshift(a&&i?{type:i}:null),o=e;break}if(1==e)return!1;s.unshift(null)}let c=e.tr;(e.selection instanceof $r||e.selection instanceof Ur)&&c.deleteSelection();let d=c.mapping.map(n.pos),u=br(c.doc,d,s.length,s);if(u||(s[0]=i?{type:i}:null,u=br(c.doc,d,s.length,s)),!u)return!1;if(c.split(d,s.length,s),!a&&l&&n.node(o).type!=i){let e=c.mapping.map(n.before(o)),t=c.doc.resolve(e);i&&n.node(o-1).canReplaceWith(t.index(),t.index()+1,i)&&c.setNodeMarkup(c.mapping.map(n.before(o)),i)}return t&&t(c.scrollIntoView()),!0};function wo(e,t,n,r){let o,i,s=t.nodeBefore,a=t.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!xr(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let c=!l&&t.parent.canReplace(t.index(),t.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,i=$t.empty;for(let e=o.length-1;e>=0;e--)i=$t.from(o[e].create(null,i));i=$t.from(s.copy(i));let l=e.tr.step(new ur(t.pos-1,r,t.pos,r,new Kt(i,1,0),o.length,!0)),c=l.doc.resolve(r+2*o.length);c.nodeAfter&&c.nodeAfter.type==s.type&&xr(l.doc,c.pos)&&l.join(c.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:zr.findFrom(t,1),u=d&&d.$from.blockRange(d.$to),h=u&&mr(u);if(null!=h&&h>=t.depth)return n&&n(e.tr.lift(u,h).scrollIntoView()),!0;if(c&&ho(a,"start",!0)&&ho(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=$t.empty;for(let e=o.length-1;e>=0;e--)r=$t.from(o[e].copy(r));n(e.tr.step(new ur(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new Kt(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function bo(e){return function(t,n){let r=t.selection,o=e<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(t.tr.setSelection($r.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const xo=bo(-1),ko=bo(1);function Co(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&gr(s,e,t);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}function So(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function Mo(e,t=null,n){return function(n,r){let{empty:o,$cursor:i,ranges:s}=n.selection;if(o&&!i||!function(e,t,n){for(let r=0;r<t.length;r++){let{$from:o,$to:i}=t[r],s=0==o.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(o.pos,i.pos,(e,t)=>{if(s)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}(n.doc,s,e))return!1;if(r)if(i)e.isInSet(n.storedMarks||i.marks())?r(n.tr.removeStoredMark(e)):r(n.tr.addStoredMark(e.create(t)));else{let o,i=n.tr;o=!s.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e));for(let n=0;n<s.length;n++){let{$from:r,$to:a}=s[n];if(o){let n=r.pos,o=a.pos,s=r.nodeAfter,l=a.nodeBefore,c=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+c<o&&(n+=c,o-=d),i.addMark(n,o,e.create(t))}else i.removeMark(r.pos,a.pos,e)}r(i.scrollIntoView())}return!0}}function No(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Eo=No(ao,co,po),Oo=No(ao,(e,t,n)=>{let r=function(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}(e,n);if(!r)return!1;let o=mo(r);if(!o)return!1;let i=o.nodeAfter;if(wo(e,o,t,1))return!0;if(0==r.parent.content.size&&(ho(i,"start")||Fr.isSelectable(i))){let n=kr(e.doc,r.before(),r.after(),Kt.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(ho(i,"start")?zr.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Fr.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=mo(r)}let s=i&&i.nodeAfter;return!(!s||!Fr.isSelectable(s))&&(t&&t(e.tr.setSelection(Fr.create(e.doc,i.pos)).scrollIntoView()),!0)});const To={Enter:No((e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)},(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof Ur||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=go(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection($r.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(br(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&mr(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)},yo),"Mod-Enter":vo,Backspace:Eo,"Mod-Backspace":Eo,"Shift-Backspace":Eo,Delete:Oo,"Mod-Delete":Oo,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new Ur(e.doc))),!0)},Ao={"Ctrl-h":To.Backspace,"Alt-Backspace":To["Mod-Backspace"],"Ctrl-d":To.Delete,"Ctrl-Alt-Backspace":To["Mod-Delete"],"Alt-Delete":To["Mod-Delete"],"Alt-d":To["Mod-Delete"],"Ctrl-a":xo,"Ctrl-e":ko};for(let e in To)Ao[e]=To[e];const Do=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Ao:To;class Io{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,o){let i=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let r=(n+=e)-o;r>0&&(i=t[0].slice(e-r,e)+i,n=o)}return e.tr.insertText(i,n,o)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const _o=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1};function Ro(e,t,n=null,r){return new Io(e,(e,o,i,s)=>{let a=n instanceof Function?n(o):n,l=e.tr.delete(i,s),c=l.doc.resolve(i).blockRange(),d=c&&gr(c,t,a);if(!d)return null;l.wrap(c,d);let u=l.doc.resolve(i-1).nodeBefore;return u&&u.type==t&&xr(l.doc,i-1)&&(!r||r(o,u))&&l.join(i-1),l})}function Bo(e,t,n=null){return new Io(e,(e,r,o,i)=>{let s=e.doc.resolve(o),a=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,a):null})}new Io(/--$/,"—",{inCodeMark:!1}),new Io(/\.\.\.$/,"…",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new Io(/"$/,"”",{inCodeMark:!1}),new Io(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new Io(/'$/,"’",{inCodeMark:!1});const Lo="undefined"!=typeof navigator?navigator:null,Po="undefined"!=typeof document?document:null,zo=Lo&&Lo.userAgent||"",jo=/Edge\/(\d+)/.exec(zo),Vo=/MSIE \d/.exec(zo),Ho=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zo),$o=!!(Vo||Ho||jo),qo=Vo?document.documentMode:Ho?+Ho[1]:jo?+jo[1]:0,Fo=!$o&&/gecko\/(\d+)/i.test(zo),Wo=Fo&&+(/Firefox\/(\d+)/.exec(zo)||[0,0])[1],Uo=!$o&&/Chrome\/(\d+)/.exec(zo),Go=!!Uo,Ko=Uo?+Uo[1]:0,Jo=!$o&&!!Lo&&/Apple Computer/.test(Lo.vendor),Zo=Jo&&(/Mobile\/\w+/.test(zo)||!!Lo&&Lo.maxTouchPoints>2),Yo=Zo||!!Lo&&/Mac/.test(Lo.platform),Xo=/Android \d/.test(zo),Qo=!!Po&&"webkitFontSmoothing"in Po.documentElement.style,ei=Qo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;var ti=Object.freeze({__proto__:null,android:Xo,chrome:Go,chrome_version:Ko,gecko:Fo,gecko_version:Wo,ie:$o,ie_version:qo,ios:Zo,mac:Yo,safari:Jo,webkit:Qo,webkit_version:ei});function ni(e,t,n,r,o,i){if(e.composing)return!1;const s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;const l=a.parent.textBetween(Math.max(0,a.parentOffset-500),a.parentOffset,void 0,"")+r;for(let a of o){const o=a,c=o.match.exec(l),d=c&&c[0]&&o.handler(s,c,t-(c[0].length-r.length),n);if(d)return!1!==o.undoable&&d.setMeta(i,{transform:d,from:t,to:n,text:r}),e.dispatch(d),!0}return!1}const ri=new so("MILKDOWN_CUSTOM_INPUTRULES");function oi({rules:e}){const t=new ro({key:ri,isInputRules:!0,state:{init:()=>null,apply(e,t){const n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>ni(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>(setTimeout(()=>{const{$cursor:r}=n.state.selection;r&&ni(n,r.pos,r.pos,"",e,t)}),!1),keydown:(e,t)=>!(!Xo||!Go||"Enter"!==t.key)&&(!e.composing&&(!!e.someProp("handleKeyDown",n=>n(e,t))&&(t.preventDefault(),!0)))},handleKeyDown(n,r){if("Enter"!==r.key)return!1;const{$cursor:o}=n.state.selection;return!!o&&ni(n,o.pos,o.pos,"\n",e,t)}}});return t}function ii(e,t,n={}){return new Io(e,(e,r,o,i)=>{var s,a,l,c;const{tr:d}=e;let u,h=r[r.length-1],p=r[0],f=[];const m={group:h,fullMatch:p,start:o,end:i},g=null==(s=n.updateCaptured)?void 0:s.call(n,m);if(Object.assign(m,g),({group:h,fullMatch:p,start:o,end:i}=m),null===p)return null;if(""===(null==h?void 0:h.trim()))return null;if(h){const e=p.search(/\S/),s=o+p.indexOf(h),m=s+h.length;f=null!=(a=d.storedMarks)?a:[],m<i&&d.delete(m,i),s>o&&d.delete(o+e,s),u=o+e+h.length;const g=null==(l=n.getAttr)?void 0:l.call(n,r);d.addMark(o,u,t.create(g)),d.setStoredMarks(f),null==(c=n.beforeDispatch)||c.call(n,{match:r,start:o,end:i,tr:d})}return d})}var si=Object.defineProperty,ai=Object.defineProperties,li=Object.getOwnPropertyDescriptors,ci=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable,hi=(e,t,n)=>t in e?si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function pi(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function fi(e,t,n){const r=e.state.doc.content.size,o=pi(t,0,r),i=pi(n,0,r),s=e.coordsAtPos(o),a=e.coordsAtPos(i,-1),l=Math.min(s.top,a.top),c=Math.max(s.bottom,a.bottom),d=Math.min(s.left,a.left),u=Math.max(s.right,a.right),h={top:l,bottom:c,left:d,right:u,width:u-d,height:c-l,x:d,y:l};return p=((e,t)=>{for(var n in t||(t={}))di.call(t,n)&&hi(e,n,t[n]);if(ci)for(var n of ci(t))ui.call(t,n)&&hi(e,n,t[n]);return e})({},h),ai(p,li({toJSON:()=>h}));var p}function mi(e){return Object.assign(Object.create(e),e).setTime(Date.now())}function gi(e){if(1===e.content.childCount){const t=e.content.firstChild;if("text"===(null==t?void 0:t.type.name)&&0===t.marks.length)return t;if("paragraph"===(null==t?void 0:t.type.name)&&1===t.childCount){const e=t.firstChild;if("text"===(null==e?void 0:e.type.name)&&0===e.marks.length)return e}}return!1}function vi(e){return t=>{for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r)){return{from:t.before(n),to:t.after(n),node:r}}}}}function yi(e,t){const n=t.nodes[e];if(!n)throw function(e,t){return new wt(yt.getAtomFromSchemaFail,`Cannot get ${e}: ${t} from schema.`)}("node",e);return n}function wi(e){return t=>{for(let n=t.depth;n>0;n--){const r=t.node(n);if(e(r))return{pos:t.before(n),start:t.start(n),depth:n,node:r}}}}function bi(e,t){if(!(e instanceof Fr))return;const{node:n,$from:r}=e;return function(e,t){return Array.isArray(e)&&e.includes(t.type)||t.type===e}(t,n)?{node:n,pos:r.pos,start:r.start(r.depth),depth:r.depth}:void 0}const xi=(e,t)=>{const{selection:n,doc:r}=e;if(n instanceof Fr)return{hasNode:n.node.type===t,pos:n.from,target:n.node};const{from:o,to:i}=n;let s=!1,a=-1,l=null;return r.nodesBetween(o,i,(e,n)=>!l&&(e.type!==t||(s=!0,a=n,l=e,!1))),{hasNode:s,pos:a,target:l}},ki="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ci="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function Si(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);ki?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function Mi(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function Ni(e){return new ro({props:{handleKeyDown:Ei(e)}})}function Ei(e){let t=function(e){let t=Object.create(null);for(let n in e)t[Si(n)]=e[n];return t}(e);return function(e,o){let i,s=n(o),a=t[Mi(s,o)];if(a&&a(e.state,e.dispatch,e))return!0;if(1==s.length&&" "!=s){if(o.shiftKey){let n=t[Mi(s,o,!1)];if(n&&n(e.state,e.dispatch,e))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Ci&&o.ctrlKey&&o.altKey)&&(i=r[o.keyCode])&&i!=s){let n=t[Mi(i,o)];if(n&&n(e.state,e.dispatch,e))return!0}}return!1}}var Oi=class{},Ti=class{constructor(){this.elements=[],this.size=()=>this.elements.length,this.top=()=>this.elements.at(-1),this.push=e=>{this.top()?.push(e)},this.open=e=>{this.elements.push(e)},this.close=()=>{const e=this.elements.pop();if(!e)throw Ct();return e}}},Ai=class e extends Oi{constructor(e,t,n){super(),this.type=e,this.content=t,this.attrs=n}push(e,...t){this.content.push(e,...t)}pop(){return this.content.pop()}static create(t,n,r){return new e(t,n,r)}},Di=class extends Ti{#w;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(t,e),n.toDoc())}}constructor(e){super(),this.#w=Ut.none,this.#b=e=>e.isText,this.#x=(e,t)=>{if(this.#b(e)&&this.#b(t)&&Ut.sameSet(e.marks,t.marks))return this.schema.text(e.text+t.text,e.marks)},this.#k=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.parseMarkdown.match(e));if(!t)throw function(e){return new wt(yt.parserMatchError,`Cannot match target parser for node: ${xt(e)}.`)}(e);return t},this.#C=e=>{const t=this.#k(e);t.spec.parseMarkdown.runner(this,e,t)},this.injectRoot=(e,t,n)=>(this.openNode(t,n),this.next(e.children),this),this.openNode=(e,t)=>(this.open(Ai.create(e,[],t)),this),this.#S=()=>{this.#w=Ut.none;const e=this.close();return this.#M(e.type,e.attrs,e.content)},this.closeNode=()=>{try{this.#S()}catch(e){console.error(e)}return this},this.#M=(e,t,n)=>{const r=e.createAndFill(t,n,this.#w);if(!r)throw function(e,t,n){const r=`Cannot create node for ${"name"in e?e.name:e}`,o=e=>{if(null==e)return"null";if(Array.isArray(e))return`[${e.map(o).join(", ")}]`;if("object"==typeof e)return"toJSON"in e&&"function"==typeof e.toJSON?JSON.stringify(e.toJSON()):"spec"in e?JSON.stringify(e.spec):JSON.stringify(e);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return JSON.stringify(e);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;try{return String(e)}catch{return"[Unserializable]"}},i=[["[Description]",r],["[Attributes]",t],["[Content]",(n??[]).map(e=>e?"object"==typeof e&&"type"in e?`${e}`:o(e):"null")]].reduce((e,[t,n])=>{const r=`${t}: ${o(n)}.`;return e.concat(r)},[]);return new wt(yt.createNodeInParserFail,i.join("\n"))}(e,t,n);return this.push(r),r},this.addNode=(e,t,n)=>{try{this.#M(e,t,n)}catch(e){console.error(e)}return this},this.openMark=(e,t)=>{const n=e.create(t);return this.#w=n.addToSet(this.#w),this},this.closeMark=e=>(this.#w=e.removeFromSet(this.#w),this),this.addText=e=>{try{const t=this.top();if(!t)throw Ct();const n=t.pop(),r=this.schema.text(e,this.#w);if(!n)return t.push(r),this;const o=this.#x(n,r);return o?(t.push(o),this):(t.push(n,r),this)}catch(e){return console.error(e),this}},this.build=()=>{let e;do{e=this.#S()}while(this.size());return e},this.next=(e=[])=>([e].flat().forEach(e=>this.#C(e)),this),this.toDoc=()=>this.build(),this.run=(e,t)=>{const n=e.runSync(e.parse(t),t);return this.next(n),this},this.schema=e}#b;#x;#k;#C;#S;#M},Ii=class e extends Oi{constructor(e,t,n,r={}){super(),this.type=e,this.children=t,this.value=n,this.props=r,this.push=(e,...t)=>{this.children||(this.children=[]),this.children.push(e,...t)},this.pop=()=>this.children?.pop()}static{this.create=(t,n,r,o={})=>new e(t,n,r,o)}},_i=class extends Ti{#w;static{this.create=(e,t)=>{const n=new this(e);return e=>(n.run(e),n.toString(t))}}constructor(e){super(),this.#w=Ut.none,this.#k=e=>{const t=Object.values({...this.schema.nodes,...this.schema.marks}).find(t=>t.spec.toMarkdown.match(e));if(!t)throw function(e){return new wt(yt.serializerMatchError,`Cannot match target serializer for node: ${xt(e)}.`)}(e.type);return t},this.#N=e=>this.#k(e).spec.toMarkdown.runner(this,e),this.#E=(e,t)=>this.#k(e).spec.toMarkdown.runner(this,e,t),this.#C=e=>{const{marks:t}=e,n=e=>e.type.spec.priority??50;[...t].sort((e,t)=>n(e)-n(t)).every(t=>!this.#E(t,e))&&this.#N(e),t.forEach(e=>this.#O(e))},this.#T=(e,t)=>{if(e.type===t)return e;if(1!==e.children?.length)return e;const n=e=>{if(e.type===t)return null!=e.value?null:e;if(1!==e.children?.length)return null;const[r]=e.children;return r?n(r):null},r=n(e);if(!r)return e;const o=r.children?[...r.children]:void 0,i={...e,children:o};return i.children=o,r.children=[i],r},this.#A=e=>{const{children:t}=e;return t?(e.children=t.reduce((e,t,n)=>{if(0===n)return[t];const r=e.at(-1);if(r&&r.isMark&&t.isMark){t=this.#T(t,r.type);const{children:n,...o}=t,{children:i,...s}=r;if(t.type===r.type&&n&&i&&JSON.stringify(o)===JSON.stringify(s)){const t={...s,children:[...i,...n]};return e.slice(0,-1).concat(this.#A(t))}}return e.concat(t)},[]),e):e},this.#D=e=>{const t={...e.props,type:e.type};return e.children&&(t.children=e.children),e.value&&(t.value=e.value),t},this.openNode=(e,t,n)=>(this.open(Ii.create(e,void 0,t,n)),this),this.#I=(e,t)=>{let n="",r="";const o=e.children;let i=-1,s=-1;if(o){(a=o)&&a.forEach((e,t)=>{"text"===e.type&&e.value&&(i<0&&(i=t),s=t)});const e=o?.[s],t=o?.[i];if(e&&e.value.endsWith(" ")){const t=e.value,n=t.trimEnd();r=t.slice(n.length),e.value=n}if(t&&t.value.startsWith(" ")){const e=t.value,r=e.trimStart();n=e.slice(0,e.length-r.length),t.value=r}}var a;n.length&&this.#M("text",void 0,n);const l=t();return r.length&&this.#M("text",void 0,r),l},this.#S=(e=!1)=>{const t=this.close(),n=()=>this.#M(t.type,t.children,t.value,t.props);return e?this.#I(t,n):n()},this.closeNode=()=>(this.#S(),this),this.#M=(e,t,n,r)=>{const o=Ii.create(e,t,n,r),i=this.#A(this.#D(o));return this.push(i),i},this.addNode=(e,t,n,r)=>(this.#M(e,t,n,r),this),this.#_=(e,t,n,r)=>e.isInSet(this.#w)?this:(this.#w=e.addToSet(this.#w),this.openNode(t,n,{...r,isMark:!0})),this.#O=e=>{e.isInSet(this.#w)&&(this.#w=e.type.removeFromSet(this.#w),this.#S(!0))},this.withMark=(e,t,n,r)=>(this.#_(e,t,n,r),this),this.closeMark=e=>(this.#O(e),this),this.build=()=>{let e=null;do{e=this.#S()}while(this.size());return e},this.next=e=>{return t=e,Object.prototype.hasOwnProperty.call(t,"size")?(e.forEach(e=>{this.#C(e)}),this):(this.#C(e),this);var t},this.toString=e=>e.stringify(this.build()),this.run=e=>(this.next(e),this),this.schema=e}#k;#N;#E;#C;#T;#A;#D;#I;#S;#M;#_;#O};const Ri=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Bi=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Li=null;const Pi=function(e,t,n){let r=Li||(Li=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},zi=function(e,t,n,r){return n&&(Vi(e,t,n,r,-1)||Vi(e,t,n,r,1))},ji=/^(img|br|input|textarea|hr)$/i;function Vi(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:Hi(e))){let n=e.parentNode;if(!n||1!=n.nodeType||$i(e)||ji.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Ri(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?Hi(e):0}}}}function Hi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function $i(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const qi=function(e){return e.focusNode&&zi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Fi(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Wi="undefined"!=typeof navigator?navigator:null,Ui="undefined"!=typeof document?document:null,Gi=Wi&&Wi.userAgent||"",Ki=/Edge\/(\d+)/.exec(Gi),Ji=/MSIE \d/.exec(Gi),Zi=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Gi),Yi=!!(Ji||Zi||Ki),Xi=Ji?document.documentMode:Zi?+Zi[1]:Ki?+Ki[1]:0,Qi=!Yi&&/gecko\/(\d+)/i.test(Gi);Qi&&(/Firefox\/(\d+)/.exec(Gi)||[0,0])[1];const es=!Yi&&/Chrome\/(\d+)/.exec(Gi),ts=!!es,ns=es?+es[1]:0,rs=!Yi&&!!Wi&&/Apple Computer/.test(Wi.vendor),is=rs&&(/Mobile\/\w+/.test(Gi)||!!Wi&&Wi.maxTouchPoints>2),ss=is||!!Wi&&/Mac/.test(Wi.platform),as=!!Wi&&/Win/.test(Wi.platform),ls=/Android \d/.test(Gi),cs=!!Ui&&"webkitFontSmoothing"in Ui.documentElement.style,ds=cs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function us(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function hs(e,t){return"number"==typeof e?e:e[t]}function ps(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function fs(e,t,n){let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Bi(s);continue}let e=s,n=e==i.body,a=n?us(i):ps(e),l=0,c=0;if(t.top<a.top+hs(r,"top")?c=-(a.top-t.top+hs(o,"top")):t.bottom>a.bottom-hs(r,"bottom")&&(c=t.bottom-t.top>a.bottom-a.top?t.top+hs(o,"top")-a.top:t.bottom-a.bottom+hs(o,"bottom")),t.left<a.left+hs(r,"left")?l=-(a.left-t.left+hs(o,"left")):t.right>a.right-hs(r,"right")&&(l=t.right-a.right+hs(o,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),l&&(e.scrollLeft+=l);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Bi(s)}}function ms(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Bi(r));return t}function gs(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let vs=null;function ys(e,t){let n,r,o,i,s=2e8,a=0,l=t.top,c=t.top;for(let d=e.firstChild,u=0;d;d=d.nextSibling,u++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Pi(d).getClientRects()}for(let h=0;h<e.length;h++){let p=e[h];if(p.top<=l&&p.bottom>=c){l=Math.max(p.bottom,l),c=Math.min(p.top,c);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<s){n=d,s=e,r=e&&3==n.nodeType?{left:p.right<t.left?p.right:p.left,top:t.top}:t,1==d.nodeType&&e&&(a=u+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!o&&p.left<=t.left&&p.right>=t.left&&(o=d,i={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=u+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n,r=e.nodeValue.length,o=document.createRange();for(let i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);let r=Cs(o,1);if(r.top!=r.bottom&&ws(t,r)){n={node:e,offset:i+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:a}:ys(n,r)}function ws(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function bs(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(ws(t,o))return bs(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function xs(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(Hi(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(Hi(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=e.dom.getBoundingClientRect();if(!ws(t,n))return null;if(a=bs(e.dom,t,n),!a)return null}if(rs)for(let e=a;n&&e;e=Bi(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(Qi&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;cs&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=ys(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let l=e.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function ks(e){return e.top<e.bottom||e.left<e.right}function Cs(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(ks(e))return e}return Array.prototype.find.call(n,ks)||e.getBoundingClientRect()}const Ss=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ms(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=cs||Qi;if(3==r.nodeType){if(!s||!Ss.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,Ns(Cs(Pi(r,e,t),i),i<0)}{let e=Cs(Pi(r,o,o),n);if(Qi&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Cs(Pi(r,o-1,o-1),-1);if(t.top==e.top){let n=Cs(Pi(r,o,o+1),-1);if(n.top!=e.top)return Ns(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==Hi(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Es(e.getBoundingClientRect(),!1)}if(null==i&&o<Hi(r)){let e=r.childNodes[o];if(1==e.nodeType)return Es(e.getBoundingClientRect(),!0)}return Es(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==Hi(r))){let e=r.childNodes[o-1],t=3==e.nodeType?Pi(e,Hi(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Ns(Cs(t,1),!1)}if(null==i&&o<Hi(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Pi(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Ns(Cs(t,-1),!0)}return Ns(Cs(3==r.nodeType?Pi(r):r,-n),n>=0)}function Ns(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Es(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Os(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Ts=/[\u0590-\u08ac]/;let As=null,Ds=null,Is=!1;function _s(e,t,n){return As==t&&Ds==n?Is:(As=t,Ds=n,Is="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Os(e,t,()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Ms(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Pi(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=e.domSelection();return a?Ts.test(r.parent.textContent)&&a.modify?Os(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:d,focusOffset:u}=e.domSelectionRange(),h=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&o==u;try{a.collapse(i,s),t&&(t!=i||o!=s)&&a.extend&&a.extend(t,o)}catch(e){}return null!=l&&(a.caretBidiLevel=l),h}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class Rs{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].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 t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.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,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Ri(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof Hs){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Bs&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Ri(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Ri(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Ri(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||s==this.children.length-1)){t=a;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Ri(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(o>a&&i<c)return l.setSelection(e-a-l.border,t-a-l.border,n,r);a=c}let s=this.domFromPos(e,e?-1:1),a=t==e?s:this.domFromPos(t,t?-1:1),l=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((Qi||rs)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=a={node:t.parentNode,offset:Ri(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Qi&&c.focusNode&&c.focusNode!=a.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||d&&rs)&&zi(s.node,s.offset,c.anchorNode,c.anchorOffset)&&zi(a.node,a.offset,c.focusNode,c.focusOffset))return;let u=!1;if((l.extend||e==t)&&(!d||!Qi)){l.collapse(s.node,s.offset);try{e!=t&&l.extend(a.node,a.offset),u=!0}catch(e){}}if(!u){if(e>t){let e=s;s=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Bs extends Rs{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||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 Ls extends Rs{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Ps extends Rs{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=Fn.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Ps(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Ps.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=ea(o,t,i,n)),e>0&&(o=ea(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zs extends Rs{constructor(e,t,n,r,o,i,s,a,l){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,a=o.nodeViews[t.type.name],l=a&&a(t,o,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,r),c=l&&l.dom,d=l&&l.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=Fn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Js(c,n,t),l?s=new $s(e,t,n,r,c,d||null,u,l,o,i+1):t.isText?new Vs(e,t,n,r,c,u,o):new zs(e,t,n,r,c,d||null,u,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>$t.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Zs(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new Xs(this,i&&i.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,u,h,p;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(d?(u||(u=[d])).push(e):d=e)}if(d)if(u){u.sort(Qs);for(let e=0;e<u.length;e++)n(u[e],c,!!l)}else n(d,c,!!l);if(l)p=-1,h=l,l=null;else{if(!(c<e.childCount))break;p=c,h=e.child(c++)}for(let e=0;e<a.length;e++)a[e].to<=i&&a.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+h.nodeSize;if(h.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<a.length;t++)a[t].to<e&&(e=a[t].to);e<f&&(l=h.cut(e-i),h=h.cut(0,e-i),f=e,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(h,h.isInline&&!h.isLeaf?a.filter(e=>!e.inline):a.slice(),t.forChild(i,h),p),i=f}}(this.node,this.innerDeco,(t,o,i)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,o):t.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?Ut.none:this.node.child(o).marks,n,e,o),a.placeWidget(t,e,r)},(t,i,l,c)=>{let d;a.syncToMarks(t.marks,n,e,c),a.findNodeMatch(t,i,l,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(d=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(t,i,l,d,e)||a.updateNextNode(t,i,l,e,c,r)||a.addNode(t,i,l,e,r),r+=t.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),qs(this.contentDOM,this.children,e),is&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof $r)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;l+=t.text}if(i>=n){if(i>=r&&l.slice(r-t.length-a,r-a)==t)return r-t.length;let e=a<r?l.lastIndexOf(t,r-a-1):-1;if(e>=0&&e+t.length+a>=n)return a+e;if(n==r&&l.length>=r+t.length-a&&l.slice(r-a,r-a+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Ls(this,o,t,r);e.input.compositionNodes.push(i),this.children=ea(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Zs(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Gs(this.dom,this.nodeDOM,Us(this.outerDeco,this.node,t),Us(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function js(e,t,n,r,o){Js(r,t,e);let i=new zs(void 0,e,t,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Vs extends zs{constructor(e,t,n,r,o,i,s){super(e,t,n,r,o,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new Vs(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Hs extends Rs{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class $s extends zs{constructor(e,t,n,r,o,i,s,a,l,c){super(e,t,n,r,o,i,s,l,c),this.spec=a}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function qs(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],a=s.dom;if(a.parentNode==e){for(;a!=r;)r=Ys(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(a,r);if(s instanceof Ps){let t=r?r.previousSibling:e.lastChild;qs(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Ys(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const Fs=function(e){e&&(this.nodeName=e)};Fs.prototype=Object.create(null);const Ws=[new Fs];function Us(e,t,n){if(0==e.length)return Ws;let r=n?Ws[0]:new Fs,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new Fs(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new Fs(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Gs(e,t,n,r){if(n==Ws&&r==Ws)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Ws[0]),o=t}Ks(o,s||Ws[0],i)}return o}function Ks(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function Js(e,t,n){return Gs(e,e,Ws,Us(t,n,1!=e.nodeType))}function Zs(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Ys(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Xs{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let a;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Ps)){a=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let o=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){o=t;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let r=Ps.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof zs){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let c,d=a.dom,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&3!=a.dirty&&Zs(t,a.outerDeco));if(!u&&a.update(e,t,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(c=this.recreateWrapper(a,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Zs(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=zs.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=zs.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Bs(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ps;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Vs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((rs||ts)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new Hs(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Qs(e,t){return e.type.side-t.type.side}function ea(e,t,n,r,o){let i=[];for(let s=0,a=0;s<e.length;s++){let l=e[s],c=a,d=a+=l.size;c>=n||d<=t?i.push(l):(c<t&&i.push(l.slice(0,t-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function ta(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(qi(n)){for(a=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&Fr.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==Hi(e);r||o;){if(e==n)return!0;let t=Ri(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==Hi(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;l=new Fr(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[a,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else a=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!l){l=da(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return l}function na(e){return e.editable?e.hasFocus():ha(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function ra(e,t=!1){let n=e.state.selection;if(la(e,n),na(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&ts){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&zi(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Ri(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Yi&&Xi<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!oa||n instanceof $r||(n.$from.parent.inlineContent||(r=ia(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=ia(e,n.to))),e.docView.setSelection(i,s,e,t),oa&&(r&&aa(r),o&&aa(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{na(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const oa=rs||ts&&ns<63;function ia(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(rs&&o&&"false"==o.contentEditable)return sa(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return sa(o);if(i)return sa(i)}}function sa(e){return e.contentEditable="true",rs&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function aa(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function la(e,t){if(t instanceof Fr){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ca(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ca(e)}function ca(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function da(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||$r.between(t,n,r)}function ua(e){return!(e.editable&&!e.hasFocus())&&ha(e)}function ha(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function pa(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&zr.findFrom(i,t)}function fa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function ma(e,t,n){let r=e.state.selection;if(!(r instanceof $r)){if(r instanceof Fr&&r.node.isInline)return fa(e,new $r(t>0?r.$to:r.$from));{let n=pa(e.state,t);return!!n&&fa(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return fa(e,new $r(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=pa(e.state,t);return!!(n&&n instanceof Fr)&&fa(e,n)}if(!(ss&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(Fr.isSelectable(i)?fa(e,new Fr(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!cs&&fa(e,new $r(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function ga(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function va(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function ya(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;Qi&&1==n.nodeType&&r<ga(n)&&va(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(va(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(wa(n))break;{let t=n.previousSibling;for(;t&&va(t,-1);)o=n.parentNode,i=Ri(t),t=t.previousSibling;if(t)n=t,r=ga(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?ba(e,n,r):o&&ba(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=ga(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!va(n.childNodes[r],1))break;o=n,i=++r}else{if(wa(n))break;{let t=n.nextSibling;for(;t&&va(t,1);)o=t.parentNode,i=Ri(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=ga(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&ba(e,o,i)}(e)}function wa(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function ba(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!$i(e);)t=Ri(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!$i(e);)t=Ri(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(qi(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&ra(e)},50)}function xa(e,t){let n=e.state.doc.resolve(t);if(!ts&&!as&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ka(e,t,n){let r=e.state.selection;if(r instanceof $r&&!r.empty||n.indexOf("s")>-1)return!1;if(ss&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=pa(e.state,t);if(n&&n instanceof Fr)return fa(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof Ur?zr.near(n,t):zr.findFrom(n,t);return!!s&&fa(e,s)}return!1}function Ca(e,t){if(!(e.state.selection instanceof $r))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function Sa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ma(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||ss&&72==n&&"c"==r)return Ca(e,-1)||ya(e,-1);if(46==n&&!t.shiftKey||ss&&68==n&&"c"==r)return Ca(e,1)||ya(e,1);if(13==n||27==n)return!0;if(37==n||ss&&66==n&&"c"==r){let t=37==n?"ltr"==xa(e,e.state.selection.from)?-1:1:-1;return ma(e,t,r)||ya(e,t)}if(39==n||ss&&70==n&&"c"==r){let t=39==n?"ltr"==xa(e,e.state.selection.from)?1:-1:1;return ma(e,t,r)||ya(e,t)}return 38==n||ss&&80==n&&"c"==r?ka(e,-1,r)||ya(e,-1):40==n||ss&&78==n&&"c"==r?function(e){if(!rs||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Sa(e,n,"true"),setTimeout(()=>Sa(e,n,"false"),20)}return!1}(e)||ka(e,1,r)||ya(e,1):r==(ss?"m":"c")&&(66==n||73==n||89==n||90==n)}function Na(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||Fn.fromSchema(e.state.schema),a=La(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,u=0;for(;d&&1==d.nodeType&&(c=Ra[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=a.createElement(c[e]);for(;l.firstChild;)t.appendChild(l.firstChild);l.appendChild(t),u++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:l,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Ea(e,t,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return s=new Kt($t.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{s=t(s,e,!0)}),s;let n=e.someProp("clipboardTextParser",n=>n(t,o,r,e));if(n)s=n;else{let n=o.marks(),{schema:r}=e.state,s=Fn.fromSchema(r);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=La().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e);(n=o&&Ra[o[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(r.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;Pa||(Pa=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return Pa.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)r=r.querySelector(n[e])||r;return r}(n),cs&&function(e){let t=e.querySelectorAll(ts?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!s){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Rn.fromSchema(e.state.schema);s=t.parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Oa.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)s=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:i,openEnd:s}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=$t.from(t.create(n[e+1],o)),i++,s++}return new Kt(o,i,s)}(_a(s,+d[1],+d[2]),d[4]);else if(s=Kt.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach(e=>{if(!i)return;let t,n=o.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&r.length&&Aa(n,r,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Da(i[i.length-1],r.length));let t=Ta(e,n);i.push(t),o=o.matchType(t.type),r=n}}),i)return $t.from(i)}return e}(s.content,o),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=_a(s,e,t)}return e.someProp("transformPasted",t=>{s=t(s,e,l)}),s}const Oa=/^(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 Ta(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,$t.from(e));return e}function Aa(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let i=Aa(e,t,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append($t.from(Ta(n,e,o+1))))}}function Da(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Da(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore($t.empty,!0);return e.copy(n.append(r))}function Ia(e,t,n,r,o,i){let s=t<0?e.firstChild:e.lastChild,a=s.content;return e.childCount>1&&(i=0),o<r-1&&(a=Ia(a,t,n,r,o+1,i)),o>=n&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore($t.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function _a(e,t,n){return t<e.openStart&&(e=new Kt(Ia(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Kt(Ia(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ra={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 Ba=null;function La(){return Ba||(Ba=document.implementation.createHTMLDocument("title"))}let Pa=null;const za={},ja={},Va={touchstart:!0,touchmove:!0};class Ha{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 $a(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function qa(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Fa(e,t))})}function Fa(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function Wa(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Ua(e){return{left:e.clientX,top:e.clientY}}function Ga(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function Ka(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function Ja(e,t,n,r,o){return Ga(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof Fr&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(Fr.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Ka(e,Fr.create(e.state.doc,r)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&Fr.isSelectable(r))&&(Ka(e,new Fr(n)),!0)}(e,n))}function Za(e,t,n,r){return Ga(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Ya(e,t,n,r){return Ga(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(Ka(e,$r.create(r,0,r.content.size)),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),i=o.before(t);if(n.inlineContent)Ka(e,$r.create(r,i+1,i+1+n.content.size));else{if(!Fr.isSelectable(n))continue;Ka(e,Fr.create(r,i))}return!0}}(e,n,r)}function Xa(e){return sl(e)}ja.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!tl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!ls||!ts||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!is||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Ma(e,n)?n.preventDefault():$a(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},ja.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},ja.keypress=(e,t)=>{let n=t;if(tl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||ss&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof $r&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,o))||e.dispatch(o()),n.preventDefault()}};const Qa=ss?"metaKey":"ctrlKey";za.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Xa(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[Qa]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(Ua(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new el(e,s,n,!!r)):("doubleClick"==i?Za:Ya)(e,s.pos,s.inside,n)?n.preventDefault():$a(e,"pointer"))};class el{constructor(e,t,n,r){let o,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Qa],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?e.docView.nearestDesc(s,!0):null;this.target=a&&1==a.nodeDOM.nodeType?a.nodeDOM:null;let{selection:l}=e.state;0==n.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Fr&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Qi||this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),$a(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ra(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ua(e))),this.updateAllowDefault(e),this.allowDefault||!t?$a(this.view,"pointer"):Ja(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||rs&&this.mightDrag&&!this.mightDrag.node.isAtom||ts&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ka(this.view,zr.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):$a(this.view,"pointer")}move(e){this.updateAllowDefault(e),$a(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function tl(e,t){return!!e.composing||!!(rs&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}za.touchstart=e=>{e.input.lastTouch=Date.now(),Xa(e),$a(e,"pointer")},za.touchmove=e=>{e.input.lastTouch=Date.now(),$a(e,"pointer")},za.contextmenu=e=>Xa(e);const nl=ls?5e3:-1;function rl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>sl(e),t))}function ol(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function il(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Hi(e=e.childNodes[t-1])}else{if(!e.parentNode||$i(e))return null;t=Ri(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||$i(e))return null;t=Ri(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function sl(e,t=!1){if(!(ls&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),ol(e),t||e.docView&&e.docView.dirty){let n=ta(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}ja.compositionstart=ja.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof $r&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||ts&&as&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),sl(e,!0),e.markCursor=null;else if(sl(e,!t.selection.empty),Qi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}rl(e,nl)},ja.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,rl(e,20))};const al=Yi&&Xi<15||is&&ds<604;function ll(e,t,n,r,o){let i=Ea(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,i||Kt.empty)))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),a=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function cl(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}za.copy=ja.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=al?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Na(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},ja.paste=(e,t)=>{let n=t;if(e.composing&&!ls)return;let r=al?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&ll(e,cl(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.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=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ll(e,r.value,null,o,t):ll(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class dl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const ul=ss?"altKey":"ctrlKey";function hl(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[ul]}za.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Ua(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof Fr?i.to-1:i.to));else if(r&&r.mightDrag)o=Fr.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Fr.create(e.state.doc,t.posBefore))}let a=(o||e.state.selection).content(),{dom:l,text:c,slice:d}=Na(e,a);(!n.dataTransfer.files.length||!ts||ns>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(al?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",al||n.dataTransfer.setData("text/plain",c),e.dragging=new dl(d,hl(e,n),o)},za.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ja.dragover=ja.dragenter=(e,t)=>t.preventDefault(),ja.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Ua(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Ea(e,cl(t.dataTransfer),al?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!n||!hl(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||Kt.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let a=i?function(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),a=!1;if(1==e)a=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=e&&s.canReplaceWith(i,i,e[0])}if(a)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}(e.state.doc,o.pos,i):o.pos;null==a&&(a=o.pos);let l=e.state.tr;if(s){let{node:e}=n;e?e.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,u=l.doc;d?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i);if(l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&Fr.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new Fr(h));else{let t=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),l.setSelection(da(e,h,l.doc.resolve(t)))}e.focus(),e.dispatch(l.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},za.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ra(e)},20))},za.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},za.beforeinput=(e,t)=>{if(ts&&ls&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,Fi(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ja)za[e]=ja[e];function pl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class fl{constructor(e,t){this.toDOM=e,this.spec=t||wl,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new vl(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof fl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ml{constructor(e,t){this.attrs=e,this.spec=t||wl}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new vl(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ml&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}static is(e){return e.type instanceof ml}destroy(){}}class gl{constructor(e,t){this.attrs=e,this.spec=t||wl}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new vl(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof gl&&pl(this.attrs,e.attrs)&&pl(this.spec,e.spec)}destroy(){}}class vl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new vl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new vl(e,e,new fl(t,n))}static inline(e,t,n,r){return new vl(e,t,new ml(n,r))}static node(e,t,n,r){return new vl(e,t,new gl(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof ml}get widget(){return this.type instanceof fl}}const yl=[],wl={};class bl{constructor(e,t){this.local=e.length?e:yl,this.children=t.length?t:yl}static create(e,t){return t.length?Nl(t,e,0,wl):xl}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==xl||0==e.maps.length?this:this.mapInner(e,t,0,0,n||wl)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(e,n,r);a&&a.type.valid(t,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let a=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||e>i+t-r)continue;let l=a[o]+t-r;n>=l?a[o+1]=e<=l?-2:-1:e>=t&&s&&(a[o]+=s,a[o+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t<a.length;t+=3)if(a[t+1]<0){if(-2==a[t+1]){l=!0,a[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-o;if(d<0||d>=r.content.size){l=!0;continue}let u=n.map(e[t+1]+i,-1)-o,{index:h,offset:p}=r.content.findIndex(d),f=r.maybeChild(h);if(f&&p==d&&p+f.nodeSize==u){let r=a[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=xl?(a[t]=d,a[t+1]=u,a[t+2]=r):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=function(e,t,n,r,o,i,s){function a(e,t){for(let i=0;i<e.local.length;i++){let a=e.local[i].map(r,o,t);a?n.push(a):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)a(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&a(e[n+2],t[n]+i+1);return n}(a,e,t,n,o,i,s),c=Nl(l,r,0,s);t=c.local;for(let e=0;e<a.length;e+=3)a[e+1]<0&&(a.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<a.length&&a[t]<n;)t+=3;a.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new bl(t.sort(El),a)}(this.children,i||[],e,t,n,r,o):i?new bl(i.sort(El),yl):xl}add(e,t){return t.length?this==xl?bl.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,a=i+n;if(s=Sl(t,e,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,a+1):r.splice(o,0,i,i+e.nodeSize,Nl(s,e,a+1,wl)),o+=3}});let i=Cl(o?Ml(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new bl(i.length?this.local.concat(i).sort(El):this.local,r||this.children)}remove(e){return 0==e.length||this==xl?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=xl?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new bl(r,n):xl}forChild(e,t){if(this==xl)return this;if(t.isLeaf)return bl.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof ml){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new bl(r.sort(El),yl);return n?new kl([e,n]):e}return n||xl}eq(e){if(this==e)return!0;if(!(e instanceof bl)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ol(this.localsInner(e))}localsInner(e){if(this==xl)return yl;if(e.inlineContent||!this.local.some(ml.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof ml||t.push(this.local[e]);return t}forEachSet(e){e(this)}}bl.empty=new bl([],[]),bl.removeOverlap=Ol;const xl=bl.empty;class kl{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,wl));return kl.from(n)}forChild(e,t){if(t.isLeaf)return bl.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=xl&&(o instanceof kl?n=n.concat(o.members):n.push(o))}return kl.from(n)}eq(e){if(!(e instanceof kl)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?Ol(n?t:t.sort(El)):yl}static from(e){switch(e.length){case 0:return xl;case 1:return e[0];default:return new kl(e.every(e=>e instanceof bl)?e:e.reduce((e,t)=>e.concat(t instanceof bl?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Cl(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new vl(o.from+t,o.to+t,o.type))}return n}function Sl(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Ml(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Nl(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let a=Sl(e,t,s+n);if(a){i=!0;let e=Nl(a,t,n+s+1,r);e!=xl&&o.push(s,s+t.nodeSize,e)}});let s=Cl(i?Ml(e):e,-n).sort(El);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new bl(s,o):xl}function El(e,t){return e.from-t.from||e.to-t.to}function Ol(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Tl(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Tl(t,o+1,i.copy(r.to,i.to)))}}return t}function Tl(e,t,n){for(;t<e.length&&El(n,e[t])>0;)t++;e.splice(t,0,n)}function Al(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=xl&&t.push(r)}),e.cursorWrapper&&t.push(bl.create(e.state.doc,[e.cursorWrapper.deco])),kl.from(t)}const Dl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Il=Yi&&Xi<=11;class _l{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 Rl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new _l,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Yi&&Xi<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():rs&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Il&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Dl)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(ua(this.view)){if(this.suppressingSelectionUpdates)return ra(this.view);if(Yi&&Xi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zi(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 t,n=new Set;for(let t=e.focusNode;t;t=Bi(t))n.add(t);for(let r=e.anchorNode;r;r=Bi(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 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 t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ua(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(!a.some(e=>"BR"==e.nodeName)||8!=e.input.lastKeyCode&&46!=e.input.lastKeyCode){if(Qi&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&zl(e,n)==t||r.remove()}}}}else for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}let l=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qi(n)&&(l=ta(e))&&l.eq(zr.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ra(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(Bl.has(e))return;if(Bl.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Qi,Ll)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."),Ll=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if("TR"==(null===(n=i.parentNode)||void 0===n?void 0:n.nodeName)){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(o,i,s,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ra(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(Yi&&Xi<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Ri(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?Ri(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Bl=new WeakMap,Ll=!1;function Pl(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return zi(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function zl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function jl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(rs&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||rs&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Vl=/^(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 Hl(e,t,n,r,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ta(e,t);if(n&&!e.state.selection.eq(n)){if(ts&&ls&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),i&&r.setMeta("composition",i),e.dispatch(r)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(n);t=s.before(a+1),n=e.state.doc.resolve(n).after(a+1);let l,c,d=e.state.selection,u=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:a,to:l}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],qi(c)||r.push({node:c.focusNode,offset:c.focusOffset})),ts&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let u=e.state.doc,h=e.someProp("domParser")||Rn.fromSchema(e.state.schema),p=u.resolve(a),f=null,m=h.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:jl,context:p});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+a,head:t+a}}return{doc:m,sel:f,from:a,to:l}}(e,t,n),h=e.state.doc,p=h.slice(u.from,u.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(l=e.state.selection.to,c="end"):(l=e.state.selection.from,c="start"),e.input.lastKeyCode=null;let f=function(e,t,n,r,o){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:a}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==o){r-=s+Math.max(0,i-Math.min(s,a))-i}if(s<i&&e.size<t.size){let e=r<=i&&r>=s?i-r:0;i-=e,i&&i<t.size&&Fl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),a=i+(a-s),s=i}else if(a<i){let t=r<=i&&r>=a?i-r:0;i-=t,i&&i<e.size&&Fl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(p.content,u.doc.content,u.from,l,c);if(f&&e.input.domChangeCount++,(is&&e.input.lastIOSEnter>Date.now()-225||ls)&&o.some(e=>1==e.nodeType&&!Vl.test(e.nodeName))&&(!f||f.endA>=f.endB)&&e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof $r&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||u.sel&&u.sel.anchor!=u.sel.head){if(u.sel){let t=$l(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&f.start==f.endB&&e.state.selection instanceof $r&&(f.start>e.state.selection.from&&f.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?f.start=e.state.selection.from:f.endA<e.state.selection.to&&f.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(f.endB+=e.state.selection.to-f.endA,f.endA=e.state.selection.to)),Yi&&Xi<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>u.from&&" "==u.doc.textBetween(f.start-u.from-1,f.start-u.from+1)&&(f.start--,f.endA--,f.endB--);let m=u.doc.resolveNoCache(f.start-u.from),g=u.doc.resolveNoCache(f.endB-u.from),v=h.resolve(f.start),y=m.sameParent(g)&&m.parent.inlineContent&&v.end()>=f.endA;if((is&&e.input.lastIOSEnter>Date.now()-225&&(!y||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!y&&m.pos<u.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(u.doc.textBetween(m.pos,g.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,Fi(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>f.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||ql(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(ql(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||ql(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(h,f.start,f.endA,m,g)&&e.someProp("handleKeyDown",t=>t(e,Fi(8,"Backspace"))))return void(ls&&ts&&e.domObserver.suppressSelectionUpdates());ts&&f.endB==f.start&&(e.input.lastChromeDelete=Date.now()),ls&&!y&&m.start()!=g.start()&&0==g.parentOffset&&m.depth==g.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==f.endA&&(f.endB-=2,g=u.doc.resolveNoCache(f.endB-u.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,Fi(13,"Enter"))})},20));let w,b=f.start,x=f.endA,k=t=>{let n=t||e.state.tr.replace(b,x,u.doc.slice(f.start-u.from,f.endB-u.from));if(u.sel){let t=$l(e,n.doc,u.sel);t&&!(ts&&e.composing&&t.empty&&(f.start!=f.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1)||Yi&&t.empty&&t.head==b)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(y)if(m.pos==g.pos){Yi&&Xi<=11&&0==m.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>ra(e),20));let t=k(e.state.tr.delete(b,x)),n=h.resolve(f.start).marksAcross(h.resolve(f.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(f.endA==f.endB&&(w=function(e,t){let n,r,o,i=e.firstChild.marks,s=t.firstChild.marks,a=i,l=s;for(let e=0;e<s.length;e++)a=s[e].removeFromSet(a);for(let e=0;e<i.length;e++)l=i[e].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let c=[];for(let e=0;e<t.childCount;e++)c.push(o(t.child(e)));if($t.from(c).eq(e))return{mark:r,type:n}}(m.parent.content.cut(m.parentOffset,g.parentOffset),v.parent.content.cut(v.parentOffset,f.endA-v.start())))){let t=k(e.state.tr);"add"==w.type?t.addMark(b,x,w.mark):t.removeMark(b,x,w.mark),e.dispatch(t)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let t=m.parent.textBetween(m.parentOffset,g.parentOffset),n=()=>k(e.state.tr.insertText(t,b,x));e.someProp("handleTextInput",r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(k());else e.dispatch(k())}function $l(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:da(e,t.resolve(n.anchor),t.resolve(n.head))}function ql(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}function Fl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class Wl{constructor(e,t){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 Ha,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Zl),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Kl(this),Gl(this),this.nodeViews=Jl(this),this.docView=js(this.state.doc,Ul(this),Al(this),this.dom,this),this.domObserver=new Rl(this,(e,t,n,r)=>Hl(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in za){let n=za[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!Wa(e,t)||Fa(e,t)||!e.editable&&t.type in ja||n(e,t)},Va[t]?{passive:!0}:void 0)}rs&&e.dom.addEventListener("input",()=>null),qa(e)}(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 t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&qa(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Zl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(ol(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Jl(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&qa(this),this.editable=Kl(this),Gl(this);let a=Al(this),l=Ul(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,l,a);!d&&e.selection.eq(r.selection)||(i=!0);let u="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){t=r,n=a.top;break}}return{refDOM:t,refTop:n,stack:ms(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(Yi||ts)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(d){let n=ts?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=il(this)),!o&&this.docView.update(e.doc,l,a,this)||(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=js(e.doc,l,a,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return zi(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?ra(this,t):(la(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():u&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;gs(n,0==r?0:r-t)}(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof Fr){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&fs(this,t.getBoundingClientRect(),e)}else fs(this,this.coordsAtPos(this.state.selection.head,1),e);else;}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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new dl(e.slice,e.move,r<0?void 0:Fr.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(Yi){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(vs)return e.focus(vs);let t=ms(e);e.focus(null==vs?{get preventScroll(){return vs={preventScroll:!0},!0}}:void 0),vs||(vs=!1,gs(t,0))}(this.dom),ra(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return xs(this,e)}coordsAtPos(e,t=1){return Ms(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return _s(this,t||this.state,e)}pasteHTML(e,t){return ll(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ll(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Na(this,e)}destroy(){this.docView&&(!function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Al(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Li=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Fa(e,t)||!za[t.type]||!e.editable&&t.type in ja||za[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?rs&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Pl(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Pl(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ul(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[vl.node(0,e.state.doc.content.size,t)]}function Gl(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:vl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Kl(e){return!e.someProp("editable",t=>!1===t(e.state))}function Jl(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Zl(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}function Yl(e,t){return e.meta={package:"@milkdown/core",group:"System",...t},e}Wl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};var Xl={text:(e,t,n,r)=>{const o=e.value;return/^[^*_\\]*\s+$/.test(o)?o:n.safe(o,{...r,encode:[]})},strong:(e,t,n,r)=>{const o=e.marker||n.options.strong||"*",i=n.enter("strong"),s=n.createTracker(r);let a=s.move(o+o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o+o),i(),a},emphasis:(e,t,n,r)=>{const o=e.marker||n.options.emphasis||"*",i=n.enter("emphasis"),s=n.createTracker(r);let a=s.move(o);return a+=s.move(n.containerPhrasing(e,{before:a,after:o,...s.current()})),a+=s.move(o),i(),a}},Ql=Dt({},"editorView"),ec=Dt({},"editorState"),tc=Dt([],"initTimer"),nc=Dt({},"editor"),rc=Dt([],"inputRules"),oc=Dt([],"prosePlugins"),ic=Dt([],"remarkPlugins"),sc=Dt([],"nodeView"),ac=Dt([],"markView"),lc=Dt(U().use(G).use(zt),"remark"),cc=Dt({handlers:Xl,encode:[]},"remarkStringifyOptions"),dc=Pt("ConfigReady");var uc=Pt("InitReady");function hc(e){const t=t=>(t.inject(nc,e).inject(oc,[]).inject(ic,[]).inject(rc,[]).inject(sc,[]).inject(ac,[]).inject(cc,{handlers:Xl,encode:[]}).inject(lc,U().use(G).use(zt)).inject(tc,[dc]).record(uc),async()=>{await t.waitTimers(tc);const e=t.get(cc);return t.set(lc,U().use(G).use(zt,e)),t.done(uc),()=>{t.remove(nc).remove(oc).remove(ic).remove(rc).remove(sc).remove(ac).remove(cc).remove(lc).remove(tc).clearTimer(uc)}});return Yl(t,{displayName:"Init"}),t}var pc=Pt("SchemaReady"),fc=Dt([],"schemaTimer"),mc=Dt({},"schema"),gc=Dt([],"nodes"),vc=Dt([],"marks");function yc(e){return{...e,parseDOM:e.parseDOM?.map(t=>({priority:e.priority,...t}))}}var wc=e=>(e.inject(mc,{}).inject(gc,[]).inject(vc,[]).inject(fc,[uc]).record(pc),async()=>{await e.waitTimers(fc);const t=e.get(lc),n=e.get(ic).reduce((e,t)=>e.use(t.plugin,t.options),t);e.set(lc,n);const r=new In({nodes:Object.fromEntries(e.get(gc).map(([e,t])=>[e,yc(t)])),marks:Object.fromEntries(e.get(vc).map(([e,t])=>[e,yc(t)]))});return e.set(mc,r),e.done(pc),()=>{e.remove(mc).remove(gc).remove(vc).remove(fc).clearTimer(pc)}});Yl(wc,{displayName:"Schema"});var bc=class{constructor(){this.#o=new Ot,this.#R=null,this.setCtx=e=>{this.#R=e},this.chain=()=>{if(null==this.#R)throw Mt();const e=this.#R,t=[],n=this.get.bind(this),r={run:()=>{const n=No(...t),r=e.get(Ql);return n(r.state,r.dispatch,r)},inline:e=>(t.push(e),r),pipe:function(e,o){const i=n(e);return t.push(i(o)),r}.bind(this)};return r}}#o;#R;get ctx(){return this.#R}create(e,t){const n=e.create(this.#o.sliceMap);return n.set(t),n}get(e){return this.#o.get(e).get()}remove(e){return this.#o.remove(e)}call(e,t){if(null==this.#R)throw Mt();const n=this.get(e)(t),r=this.#R.get(Ql);return n(r.state,r.dispatch,r)}inline(e){if(null==this.#R)throw Mt();const t=this.#R.get(Ql);return e(t.state,t.dispatch,t)}};var xc=Dt(new bc,"commands"),kc=Dt([pc],"commandsTimer"),Cc=Pt("CommandsReady"),Sc=e=>{const t=new bc;return t.setCtx(e),e.inject(xc,t).inject(kc,[pc]).record(Cc),async()=>(await e.waitTimers(kc),e.done(Cc),()=>{e.remove(xc).remove(kc).clearTimer(Cc)})};Yl(Sc,{displayName:"Commands"});var Mc=class{constructor(){this.#R=null,this.#B=[],this.setCtx=e=>{this.#R=e},this.add=e=>(this.#B.push(e),()=>{this.#B=this.#B.filter(t=>t!==e)}),this.addObjectKeymap=e=>{const t=[];return Object.entries(e).forEach(([e,n])=>{if("function"==typeof n){const r={key:e,onRun:()=>n};this.#B.push(r),t.push(()=>{this.#B=this.#B.filter(e=>e!==r)})}else this.#B.push(n),t.push(()=>{this.#B=this.#B.filter(e=>e!==n)})}),()=>{t.forEach(e=>e())}},this.addBaseKeymap=()=>{const e=function(e){return e.Backspace=No(_o,ao,uo,po),e}(Do);return this.addObjectKeymap(e)},this.build=()=>{const e={};return this.#B.forEach(t=>{e[t.key]=[...e[t.key]||[],t]}),Object.fromEntries(Object.entries(e).map(([e,t])=>{const n=t.sort((e,t)=>(t.priority??50)-(e.priority??50));return[e,(e,t,r)=>{const o=this.#R;if(null==o)throw kt();return No(...n.map(e=>e.onRun(o)))(e,t,r)}]}))}}#R;#B;get ctx(){return this.#R}},Nc=Dt(new Mc,"keymap"),Ec=Dt([pc],"keymapTimer"),Oc=Pt("KeymapReady"),Tc=e=>{const t=new Mc;return t.setCtx(e),e.inject(Nc,t).inject(Ec,[pc]).record(Oc),async()=>(await e.waitTimers(Ec),e.done(Oc),()=>{e.remove(Nc).remove(Ec).clearTimer(Oc)})},Ac=Pt("ParserReady"),Dc=()=>{throw kt()},Ic=Dt(Dc,"parser"),_c=Dt([],"parserTimer"),Rc=e=>(e.inject(Ic,Dc).inject(_c,[pc]).record(Ac),async()=>{await e.waitTimers(_c);const t=e.get(lc),n=e.get(mc);return e.set(Ic,Di.create(n,t)),e.done(Ac),()=>{e.remove(Ic).remove(_c).clearTimer(Ac)}});Yl(Rc,{displayName:"Parser"});var Bc=Pt("SerializerReady"),Lc=Dt([],"serializerTimer"),Pc=()=>{throw kt()},zc=Dt(Pc,"serializer"),jc=e=>(e.inject(zc,Pc).inject(Lc,[pc]).record(Bc),async()=>{await e.waitTimers(Lc);const t=e.get(lc),n=e.get(mc);return e.set(zc,_i.create(n,t)),e.done(Bc),()=>{e.remove(zc).remove(Lc).clearTimer(Bc)}});Yl(jc,{displayName:"Serializer"});var Vc=Dt("","defaultValue"),Hc=Dt(e=>e,"stateOptions"),$c=Dt([],"editorStateTimer"),qc=Pt("EditorStateReady");function Fc(e,t,n){if("string"==typeof e)return t(e);if("html"===e.type)return Rn.fromSchema(n).parse(e.dom);if("json"===e.type)return pn.fromJSON(n,e.value);throw r=e,new wt(yt.docTypeError,`Doc type error, unsupported type: ${xt(r)}`);var r}var Wc=new so("MILKDOWN_STATE_TRACKER"),Uc=e=>(e.inject(Vc,"").inject(ec,{}).inject(Hc,e=>e).inject($c,[Ac,Bc,Cc,Oc]).record(qc),async()=>{await e.waitTimers($c);const t=e.get(mc),n=e.get(Ic),r=e.get(rc),o=e.get(Hc),i=e.get(oc),s=Fc(e.get(Vc),n,t),a=e.get(Nc),l=a.addBaseKeymap(),c=[...i,new ro({key:Wc,state:{init:()=>{},apply:(t,n,r,o)=>{e.set(ec,o)}}}),oi({rules:r}),Ni(a.build())];e.set(oc,c);const d=o({schema:t,doc:s,plugins:c}),u=to.create(d);return e.set(ec,u),e.done(qc),()=>{l(),e.remove(Vc).remove(ec).remove(Hc).remove($c).clearTimer(qc)}});Yl(Uc,{displayName:"EditorState"});var Gc=Dt([],"pasteRule"),Kc=Dt([pc],"pasteRuleTimer"),Jc=Pt("PasteRuleReady"),Zc=e=>(e.inject(Gc,[]).inject(Kc,[pc]).record(Jc),async()=>(await e.waitTimers(Kc),e.done(Jc),()=>{e.remove(Gc).remove(Kc).clearTimer(Jc)}));Yl(Zc,{displayName:"PasteRule"});var Yc=Pt("EditorViewReady"),Xc=Dt([],"editorViewTimer"),Qc=Dt({},"editorViewOptions"),ed=Dt(null,"root"),td=Dt(null,"rootDOM"),nd=Dt({},"rootAttrs");var rd=new so("MILKDOWN_VIEW_CLEAR"),od=e=>(e.inject(ed,document.body).inject(Ql,{}).inject(Qc,{}).inject(td,null).inject(nd,{}).inject(Xc,[qc,Jc]).record(Yc),async()=>{await e.wait(uc);const t=e.get(ed)||document.body,n="string"==typeof t?document.querySelector(t):t;e.update(oc,t=>[new ro({key:rd,view:t=>{const r=n?function(e,t){const n=document.createElement("div");n.className="milkdown",e.appendChild(n),t.set(td,n);const r=t.get(nd);return Object.entries(r).forEach(([e,t])=>n.setAttribute(e,t)),n}(n,e):void 0;return(()=>{if(r&&n){const e=t.dom;n.replaceChild(r,e),r.appendChild(e)}})(),{destroy:()=>{r?.parentNode&&r?.parentNode.replaceChild(t.dom,r),r?.remove()}}}}),...t]),await e.waitTimers(Xc);const r=e.get(ec),o=e.get(Qc),i=new Wl(n,{state:r,nodeViews:Object.fromEntries(e.get(sc)),markViews:Object.fromEntries(e.get(ac)),transformPasted:(t,n,r)=>(e.get(Gc).sort((e,t)=>(t.priority??50)-(e.priority??50)).map(e=>e.run).forEach(e=>{t=e(t,n,r)}),t),...o});var s;return(s=i.dom).classList.add("editor"),s.setAttribute("role","textbox"),e.set(Ql,i),e.done(Yc),()=>{i?.destroy(),e.remove(ed).remove(Ql).remove(Qc).remove(td).remove(nd).remove(Xc).clearTimer(Yc)}});Yl(od,{displayName:"EditorView"});var id=function(e){return e.Idle="Idle",e.OnCreate="OnCreate",e.Created="Created",e.OnDestroy="OnDestroy",e.Destroyed="Destroyed",e}({}),sd=class e{constructor(){this.#L=!1,this.#g=id.Idle,this.#P=[],this.#z=()=>{},this.#o=new Ot,this.#i=new Rt,this.#j=new Map,this.#V=new Map,this.#R=new _t(this.#o,this.#i),this.#H=()=>{const e=function(e){const t=t=>(t.record(dc),async()=>(await e(t),t.done(dc),()=>{t.clearTimer(dc)}));return Yl(t,{displayName:"Config"}),t}(async e=>{await Promise.all(this.#P.map(t=>Promise.resolve(t(e))))}),t=[wc,Rc,jc,Sc,Tc,Zc,Uc,od,hc(this),e];this.#$(t,this.#V)},this.#$=(e,t)=>{e.forEach(e=>{const n=this.#R.produce(this.#L?e.meta:void 0),r=e(n);t.set(e,{ctx:n,handler:r,cleanup:void 0})})},this.#q=(e,t=!1)=>Promise.all([e].flat().map(async e=>{const n=this.#j.get(e)?.cleanup;return t?this.#j.delete(e):this.#j.set(e,{ctx:void 0,handler:void 0,cleanup:void 0}),"function"==typeof n?n():n})),this.#F=async()=>{await Promise.all([...this.#V.entries()].map(async([e,{cleanup:t}])=>"function"==typeof t?t():t)),this.#V.clear()},this.#W=e=>{this.#g=e,this.#z(e)},this.#U=e=>[...e.entries()].map(async([t,n])=>{const{ctx:r,handler:o}=n;if(!o)return;const i=await o();e.set(t,{ctx:r,handler:o,cleanup:i})}),this.enableInspector=(e=!0)=>(this.#L=e,this),this.onStatusChange=e=>(this.#z=e,this),this.config=e=>(this.#P.push(e),this),this.removeConfig=e=>(this.#P=this.#P.filter(t=>t!==e),this),this.use=e=>{const t=[e].flat();return t.flat().forEach(e=>{this.#j.set(e,{ctx:void 0,handler:void 0,cleanup:void 0})}),this.#g===id.Created&&this.#$(t,this.#j),this},this.remove=async e=>this.#g===id.OnCreate?(console.warn("[Milkdown]: You are trying to remove plugins when the editor is creating, this is not recommended, please check your code."),new Promise(t=>{setTimeout(()=>{t(this.remove(e))},50)})):(await this.#q([e].flat(),!0),this),this.create=async()=>(this.#g===id.OnCreate||(this.#g===id.Created&&await this.destroy(),this.#W(id.OnCreate),this.#H(),this.#$([...this.#j.keys()],this.#j),await Promise.all([this.#U(this.#V),this.#U(this.#j)].flat()),this.#W(id.Created)),this),this.destroy=async(e=!1)=>this.#g===id.Destroyed||this.#g===id.OnDestroy?this:this.#g===id.OnCreate?new Promise(t=>{setTimeout(()=>{t(this.destroy(e))},50)}):(e&&(this.#P=[]),this.#W(id.OnDestroy),await this.#q([...this.#j.keys()],e),await this.#F(),this.#W(id.Destroyed),this),this.action=e=>e(this.#R),this.inspect=()=>this.#L?[...this.#V.values(),...this.#j.values()].map(({ctx:e})=>e?.inspector?.read()).filter(e=>Boolean(e)):(console.warn("[Milkdown]: You are trying to collect inspection when inspector is disabled, please enable inspector by `editor.enableInspector()` first."),[])}static make(){return new e}#L;#g;#P;#z;#o;#i;#j;#V;#R;#H;#$;#q;#F;#W;#U;get ctx(){return this.#R}get status(){return this.#g}};let ad=e=>crypto.getRandomValues(new Uint8Array(e)),ld=(e,t=21)=>((e,t,n)=>{let r=256-256%e.length;if(256===r){let r=e.length-1;return(o=t)=>{if(!o)return"";let i="";for(;;){let t=n(o),s=o;for(;s--;)if(i+=e[t[s]&r],i.length>=o)return i}}}let o=Math.ceil(409.6*t/r);return(i=t)=>{if(!i)return"";let s="";for(;;){let t=n(o),a=o;for(;a--;)if(t[a]<r&&(s+=e[t[a]%e.length],s.length>=i))return s}}})(e,0|t,ad);function cd(e,t){const n=function(e="cmdKey"){return Dt(()=>()=>!1,e)}(e),r=o=>async()=>{r.key=n,await o.wait(Cc);const i=t(o);return o.get(xc).create(n,i),r.run=t=>o.get(xc).call(e,t),()=>{o.get(xc).remove(n)}};return r}function dd(e){const t=n=>async()=>{await n.wait(pc);const r=e(n);return n.update(rc,e=>[...e,r]),t.inputRule=r,()=>{n.update(rc,e=>e.filter(e=>e!==r))}};return t}function ud(e,t){const n=r=>async()=>{const o=t(r);return r.update(vc,t=>[...t.filter(t=>t[0]!==e),[e,o]]),n.id=e,n.schema=o,()=>{r.update(vc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(mc).marks[e];if(!n)throw r=e,new wt(yt.missingMarkInSchema,`Missing mark in schema, milkdown cannot find "${r}" in schema.`);var r;return n},n}function hd(e,t){const n=r=>async()=>{const o=t(r);return r.update(gc,t=>[...t.filter(t=>t[0]!==e),[e,o]]),n.id=e,n.schema=o,()=>{r.update(gc,t=>t.filter(([t])=>t!==e))}};return n.type=t=>{const n=t.get(mc).nodes[e];if(!n)throw Nt(e);return n},n}function pd(e){let t;const n=n=>async()=>(await n.wait(pc),t=e(n),n.update(oc,e=>[...e,t]),()=>{n.update(oc,e=>e.filter(e=>e!==t))});return n.plugin=()=>t,n.key=()=>t.spec.key,n}function fd(e){const t=n=>async()=>{await n.wait(Oc);const r=n.get(Nc),o=e(n),i=r.addObjectKeymap(o);return t.keymap=o,()=>{i()}};return t}function md(e,t){const n=r=>async()=>{await r.wait(pc);const o=t(r);return e.type(r)instanceof Tn?r.update(sc,t=>[...t,[e.id,o]]):r.update(ac,t=>[...t,[e.id,o]]),n.view=o,n.type=e,()=>{e.type(r)instanceof Tn?r.update(sc,t=>t.filter(t=>t[0]!==e.id)):r.update(ac,t=>t.filter(t=>t[0]!==e.id))}};return n}function gd(e,t){const n=Dt(e,t),r=e=>(e.inject(n),()=>()=>{e.remove(n)});return r.key=n,r}function vd(e,t){const n=gd(t,e),r=hd(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.node=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>vd(e,n(t)),o}function yd(e,t){const n=gd(t,e),r=ud(e,e=>e.get(n.key)(e)),o=[n,r];return o.id=r.id,o.mark=r,o.type=e=>r.type(e),o.ctx=n,o.key=n.key,o.extendSchema=n=>yd(e,n(t)),o}function wd(e,t){const n=gd(Object.fromEntries(Object.entries(t).map(([e,{shortcuts:t,priority:n}])=>[e,{shortcuts:t,priority:n}])),`${e}Keymap`),r=fd(e=>{const r=e.get(n.key),o=Object.entries(t).flatMap(([e,{command:t}])=>{const n=r[e],o=[n.shortcuts].flat(),i=n.priority;return o.map(e=>[e,{key:e,onRun:t,priority:i}])});return Object.fromEntries(o)}),o=[n,r];return o.ctx=n,o.shortcuts=r,o.key=n.key,o.keymap=r.keymap,o}ld("abcedfghicklmn",10);var bd=(e,t=()=>({}))=>gd(t,`${e}Attr`),xd=(e,t=()=>({}))=>gd(t,`${e}Attr`);function kd(e,t,n){const r=gd({},e),o=e=>async()=>{await e.wait(uc);const n={plugin:t(e),options:e.get(r.key)};return e.update(ic,e=>[...e,n]),()=>{e.update(ic,e=>e.filter(e=>e!==n))}},i=[r,o];return i.id=e,i.plugin=o,i.options=r,i}function Cd(e){return e=>{const t=e.get(Ql);e.get(mc);return e.get(zc)(t.state.doc)}}var Sd=ie({});var Md=()=>{const e=function(){const{dom:e,editor:t,setLoading:n,editorFactory:r}=se(Sd),o=ne(null);return ce(()=>{const i=o.current;if(!r)return;if(!i)return;e.current=i;const s=r(i);return s?(n(!0),s.create().then(e=>{t.current=e}).finally(()=>{n(!1)}).catch(console.error),()=>{s.destroy().catch(console.error)}):void 0},[e,t,r,n]),o}();return te.createElement("div",{"data-milkdown-root":!0,ref:e})},Nd=({children:e})=>{const t=ne(void 0),[n,r]=re(void 0),o=ne(void 0),[i,s]=re(!0),a=oe(()=>({loading:i,dom:t,editor:o,setLoading:s,editorFactory:n,setEditorFactory:r}),[i,n]);return te.createElement(Sd.Provider,{value:a},e)};function Ed(){const e=se(Sd),t=ae(()=>e.editor.current,[e.editor]);return[e.loading,t]}function Od(e){return new i(s.define(e))}function Td(e){return import("./index-wgkxcuUd.js").then(t=>t.sql({dialect:t[e]}))}const Ad=[o.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-mPuca8dy.js").then(e=>e.cpp())}),o.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-mPuca8dy.js").then(e=>e.cpp())}),o.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Td("Cassandra")}),o.of({name:"CSS",extensions:["css"],load:()=>import("./index-CQTsT8Zj.js").then(e=>e.css())}),o.of({name:"Go",extensions:["go"],load:()=>import("./index-XKEYn2Wr.js").then(e=>e.go())}),o.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-Ci0TIrsP.js").then(e=>e.html())}),o.of({name:"Java",extensions:["java"],load:()=>import("./index-CYal7RVq.js").then(e=>e.java())}),o.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript())}),o.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-DQ_RDg2x.js").then(e=>e.jinja())}),o.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-4xl-oI83.js").then(e=>e.json())}),o.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript({jsx:!0}))}),o.of({name:"LESS",extensions:["less"],load:()=>import("./index-uScqGt-h.js").then(e=>e.less())}),o.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index-DPqNWk5z.js").then(e=>e.liquid())}),o.of({name:"MariaDB SQL",load:()=>Td("MariaSQL")}),o.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-CWWVtFL-.js").then(e=>e.markdown())}),o.of({name:"MS SQL",load:()=>Td("MSSQL")}),o.of({name:"MySQL",load:()=>Td("MySQL")}),o.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-3RT03X12.js").then(e=>e.php())}),o.of({name:"PLSQL",extensions:["pls"],load:()=>Td("PLSQL")}),o.of({name:"PostgreSQL",load:()=>Td("PostgreSQL")}),o.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-C_iDYl6D.js").then(e=>e.python())}),o.of({name:"Rust",extensions:["rs"],load:()=>import("./index-BozcvZKO.js").then(e=>e.rust())}),o.of({name:"Sass",extensions:["sass"],load:()=>import("./index-D2MvgUx2.js").then(e=>e.sass({indented:!0}))}),o.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-D2MvgUx2.js").then(e=>e.sass())}),o.of({name:"SQL",extensions:["sql"],load:()=>Td("StandardSQL")}),o.of({name:"SQLite",load:()=>Td("SQLite")}),o.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}),o.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-DklIqAi8.js").then(e=>e.javascript({typescript:!0}))}),o.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-CU5b90xS.js").then(e=>e.wast())}),o.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-DI4w9v5q.js").then(e=>e.xml())}),o.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-CZHb8PSE.js").then(e=>e.yaml())}),o.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-CXdQSnD-.js").then(e=>Od(e.apl))}),o.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D5V0T9Cu.js").then(e=>Od(e.asciiArmor))}),o.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DWPaVWf6.js").then(e=>Od(e.asn1({})))}),o.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-B46aRdXb.js").then(e=>Od(e.asterisk))}),o.of({name:"Brainfuck",extensions:["b","bf"],load:()=>import("./brainfuck-CtZaYBKt.js").then(e=>Od(e.brainfuck))}),o.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-stawOqaz.js").then(e=>Od(e.cobol))}),o.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.csharp))}),o.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Od(e.clojure))}),o.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Od(e.clojure))}),o.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-C4GSMmGA.js").then(e=>Od(e.gss))}),o.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DXn5xaP-.js").then(e=>Od(e.cmake))}),o.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-BTDxI-eT.js").then(e=>Od(e.coffeeScript))}),o.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-vq6DHwts.js").then(e=>Od(e.commonLisp))}),o.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-gJDei3ni.js").then(e=>Od(e.cypher))}),o.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-On6Xi21R.js").then(e=>Od(e.cython))}),o.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-CRzZ78HM.js").then(e=>Od(e.crystal))}),o.of({name:"D",extensions:["d"],load:()=>import("./d-BShv7fp-.js").then(e=>Od(e.d))}),o.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.dart))}),o.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-UJJ5BM9S.js").then(e=>Od(e.diff))}),o.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DVQ9Q8O9.js").then(e=>Od(e.dockerFile))}),o.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-DI9Herc-.js").then(e=>Od(e.dtd))}),o.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-DkEP81N9.js").then(e=>Od(e.dylan))}),o.of({name:"EBNF",load:()=>import("./ebnf-B-Df8AvO.js").then(e=>Od(e.ebnf))}),o.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-DPFc0Uaf.js").then(e=>Od(e.ecl))}),o.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-DiuoqK-z.js").then(e=>Od(e.clojure))}),o.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-DR5c0IrL.js").then(e=>Od(e.eiffel))}),o.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DompmV0j.js").then(e=>Od(e.elm))}),o.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-BuqgqA5h.js").then(e=>Od(e.erlang))}),o.of({name:"Esper",load:()=>import("./sql-ByLYq2fX.js").then(e=>Od(e.esper))}),o.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-Bk9_H-XT.js").then(e=>Od(e.factor))}),o.of({name:"FCL",load:()=>import("./fcl-CVaBTCzQ.js").then(e=>Od(e.fcl))}),o.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-POgR1ypr.js").then(e=>Od(e.forth))}),o.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-DL7KluxX.js").then(e=>Od(e.fortran))}),o.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Od(e.fSharp))}),o.of({name:"Gas",extensions:["s"],load:()=>import("./gas-8mz5Q3qN.js").then(e=>Od(e.gas))}),o.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-B6X1vGSW.js").then(e=>Od(e.gherkin))}),o.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-DnIzCrpZ.js").then(e=>Od(e.groovy))}),o.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-CLQs6EAM.js").then(e=>Od(e.haskell))}),o.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Od(e.haxe))}),o.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-D25e-2l-.js").then(e=>Od(e.hxml))}),o.of({name:"HTTP",load:()=>import("./http-BKJkqRj4.js").then(e=>Od(e.http))}),o.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-pcmmZuaN.js").then(e=>Od(e.idl))}),o.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BVaBnk3P.js").then(e=>Od(e.jsonld))}),o.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-DjdwvFuI.js").then(e=>Od(e.julia))}),o.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.kotlin))}),o.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-HO6ttBFx.js").then(e=>Od(e.liveScript))}),o.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-BvgfYBhq.js").then(e=>Od(e.lua))}),o.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DkvFAiy5.js").then(e=>Od(e.mirc))}),o.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-IIbmv7SK.js").then(e=>Od(e.mathematica))}),o.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-DSrSSXCg.js").then(e=>Od(e.modelica))}),o.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-zvxmGV4l.js").then(e=>Od(e.mumps))}),o.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-z_N2Mo3d.js").then(e=>Od(e.mbox))}),o.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-B4hAVlXN.js").then(e=>Od(e.nginx))}),o.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-Cx8FAvMN.js").then(e=>Od(e.nsis))}),o.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-BSwWqoLa.js").then(e=>Od(e.ntriples))}),o.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.objectiveC))}),o.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.objectiveCpp))}),o.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Od(e.oCaml))}),o.of({name:"Octave",extensions:["m"],load:()=>import("./octave-C4hdQ5Hf.js").then(e=>Od(e.octave))}),o.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-qQq7irPq.js").then(e=>Od(e.oz))}),o.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-CafrKXZF.js").then(e=>Od(e.pascal))}),o.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-tdMlh9QA.js").then(e=>Od(e.perl))}),o.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CwGJVRC4.js").then(e=>Od(e.pig))}),o.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D1ly3AHC.js").then(e=>Od(e.powerShell))}),o.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-_nPj978X.js").then(e=>Od(e.properties))}),o.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-B4y9do6W.js").then(e=>Od(e.protobuf))}),o.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Dlfivyh-.js").then(e=>Od(e.pug))}),o.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-Bc-yJKzi.js").then(e=>Od(e.puppet))}),o.of({name:"Q",extensions:["q"],load:()=>import("./q-mUfi2b_o.js").then(e=>Od(e.q))}),o.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-BA4EbLKE.js").then(e=>Od(e.r))}),o.of({name:"RPM Changes",load:()=>import("./rpm-DI_rRufH.js").then(e=>Od(e.rpmChanges))}),o.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-DI_rRufH.js").then(e=>Od(e.rpmSpec))}),o.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-CR-u2WLS.js").then(e=>Od(e.ruby))}),o.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-Bqaci40L.js").then(e=>Od(e.sas))}),o.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.scala))}),o.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-qjP0V5Ag.js").then(e=>Od(e.scheme))}),o.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BLav31RL.js").then(e=>Od(e.shell))}),o.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-r025o_jW.js").then(e=>Od(e.sieve))}),o.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-C7J3IyEP.js").then(e=>Od(e.smalltalk))}),o.of({name:"Solr",load:()=>import("./solr-78MBEUkU.js").then(e=>Od(e.solr))}),o.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-3c2dg9RT.js").then(e=>Od(e.sml))}),o.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-BRLJFz69.js").then(e=>Od(e.sparql))}),o.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CGlWr0eM.js").then(e=>Od(e.spreadsheet))}),o.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-D9ynMLA9.js").then(e=>Od(e.squirrel))}),o.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Bdo_Aemu.js").then(e=>Od(e.stylus))}),o.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-B_XXVlXX.js").then(e=>Od(e.swift))}),o.of({name:"sTeX",load:()=>Promise.resolve().then(function(){return _d}).then(e=>Od(e.stex))}),o.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>Promise.resolve().then(function(){return _d}).then(e=>Od(e.stex))}),o.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Od(e.verilog))}),o.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-B2fODqDH.js").then(e=>Od(e.tcl))}),o.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BuVhTOzU.js").then(e=>Od(e.textile))}),o.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-BgR6AEZu.js").then(e=>Od(e.tiddlyWiki))}),o.of({name:"Tiki wiki",load:()=>import("./tiki-CI-ztowC.js").then(e=>Od(e.tiki))}),o.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BVJm5Fzd.js").then(e=>Od(e.toml))}),o.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Ce85hlLp.js").then(e=>Od(e.troff))}),o.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-BxnYHtq8.js").then(e=>Od(e.ttcn))}),o.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-CKJxb-l2.js").then(e=>Od(e.ttcnCfg))}),o.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-BkSuIpt-.js").then(e=>Od(e.turtle))}),o.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-CGwyPRYs.js").then(e=>Od(e.webIDL))}),o.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-BHgjm0DN.js").then(e=>Od(e.vb))}),o.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VzWlGt02.js").then(e=>Od(e.vbScript))}),o.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BdD_26Jv.js").then(e=>Od(e.velocity))}),o.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-C8nH2N0M.js").then(e=>Od(e.verilog))}),o.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-CWWH2SUo.js").then(e=>Od(e.vhdl))}),o.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-CVDBqZPY.js").then(e=>Od(e.xQuery))}),o.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-I8QjZlxf.js").then(e=>Od(e.yacas))}),o.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-DMVFMNEx.js").then(e=>Od(e.z80))}),o.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Od(e.mscgen))}),o.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Od(e.xu))}),o.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-B2igx18G.js").then(e=>Od(e.msgenny))}),o.of({name:"Vue",extensions:["vue"],load:()=>import("./index-C7UTkWm2.js").then(e=>e.vue())}),o.of({name:"Angular Template",load:()=>import("./index-B8r5j97Z.js").then(e=>e.angular())})];function Dd(e){function t(e,t){e.cmdState.push(t)}function n(e){return e.cmdState.length>0?e.cmdState[e.cmdState.length-1]:null}function r(e,t,n){return function(){this.name=e,this.bracketNo=0,this.style=t,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var o={};function i(e,t){e.f=t}function s(e,r){var s;if(e.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var c=e.current().slice(1);return t(r,s=new(s=o.hasOwnProperty(c)?o[c]:o.DEFAULT)),i(r,l),s.style}if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/\\]/))return"tag";if(e.match("\\["))return i(r,function(e,t){return a(e,t,"\\]")}),"keyword";if(e.match("\\("))return i(r,function(e,t){return a(e,t,"\\)")}),"keyword";if(e.match("$$"))return i(r,function(e,t){return a(e,t,"$$")}),"keyword";if(e.match("$"))return i(r,function(e,t){return a(e,t,"$")}),"keyword";var d=e.next();return"%"==d?(e.skipToEnd(),"comment"):"}"==d||"]"==d?(s=n(r))?(s.closeBracket(d),i(r,l),"bracket"):"error":"{"==d||"["==d?(t(r,s=new(s=o.DEFAULT)),"bracket"):/\d/.test(d)?(e.eatWhile(/[\w.%]/),"atom"):(e.eatWhile(/[\w\-_]/),s=function(e){for(var t=e.cmdState,n=t.length-1;n>=0;n--){var r=t[n];if("DEFAULT"!=r.name)return r}return{styleIdentifier:function(){return null}}}(r),"begin"==s.name&&(s.argument=e.current()),s.styleIdentifier())}function a(e,t,n){if(e.eatSpace())return null;if(n&&e.match(n))return i(t,s),"keyword";if(e.match(/^\\[a-zA-Z@]+/))return"tag";if(e.match(/^[a-zA-Z]+/))return"variableName.special";if(e.match(/^\\[$&%#{}_]/))return"tag";if(e.match(/^\\[,;!\/]/))return"tag";if(e.match(/^[\^_&]/))return"tag";if(e.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(e.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var r=e.next();return"{"==r||"}"==r||"["==r||"]"==r||"("==r||")"==r?"bracket":"%"==r?(e.skipToEnd(),"comment"):"error"}function l(e,t){var r=e.peek();return"{"==r||"["==r?(n(t).openBracket(r),e.eat(r),i(t,s),"bracket"):/[ \t\r]/.test(r)?(e.eat(r),null):(i(t,s),function(e){var t=e.cmdState.pop();t&&t.closeBracket()}(t),s(e,t))}return o.importmodule=r("importmodule","tag",["string","builtin"]),o.documentclass=r("documentclass","tag",["","atom"]),o.usepackage=r("usepackage","tag",["atom"]),o.begin=r("begin","tag",["atom"]),o.end=r("end","tag",["atom"]),o.label=r("label","tag",["atom"]),o.ref=r("ref","tag",["atom"]),o.eqref=r("eqref","tag",["atom"]),o.cite=r("cite","tag",["atom"]),o.bibitem=r("bibitem","tag",["atom"]),o.Bibitem=r("Bibitem","tag",["atom"]),o.RBibitem=r("RBibitem","tag",["atom"]),o.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{name:"stex",startState:function(){return{cmdState:[],f:e?function(e,t){return a(e,t)}:s}},copyState:function(e){return{cmdState:e.cmdState.slice(),f:e.f}},token:function(e,t){return t.f(e,t)},blankLine:function(e){e.f=s,e.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const Id=Dd(!1);Dd(!0);var _d=Object.freeze({__proto__:null,stex:Id});function Rd(e){return function(t,n){let{$from:r,$to:o}=t.selection,i=r.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);return!!i&&(!n||(r.node(i.depth-1).type==e?function(e,t,n,r){let o=e.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new ur(i-1,s,i,s,new Kt($t.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new un(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=mr(r);if(null==a)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(i,-1)-1);xr(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos);return t(o.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+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 a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?$t.empty:$t.from(o))))return!1;let u=i.pos,h=u+s.nodeSize;return r.step(new ur(u-(a?1:0),h+(l?1:0),u+1,h-1,new Kt((a?$t.empty:$t.from(o.copy($t.empty))).append(l?$t.empty:$t.from(o.copy($t.empty))),a?0:1,l?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,i)))}}function Bd(e){return String(e||"").toUpperCase()}function Ld(){return function(e){const t=function(e){const t=new Map;if(!e||!e.type)throw new Error("mdast-util-definitions expected node");return K(e,"definition",function(e){const n=Bd(e.identifier);n&&!t.get(n)&&t.set(n,e)}),function(e){const n=Bd(e);return t.get(n)}}(e);K(e,function(e,n,r){if("definition"===e.type&&void 0!==r&&"number"==typeof n)return r.children.splice(n,1),[J,n];if("imageReference"===e.type||"linkReference"===e.type){const o=t(e.identifier);if(o&&r&&"number"==typeof n)return r.children[n]="imageReference"===e.type?{type:"image",url:o.url,title:o.title,alt:e.alt}:{type:"link",url:o.url,title:o.title,children:e.children},[J,n]}})}}function Pd(e,t){if(!(t.childCount>=1&&"hardbreak"===t.lastChild?.type.name))return void e.next(t.content);const n=[];t.content.forEach((e,r,o)=>{o!==t.childCount-1&&n.push(e)}),e.next($t.fromArray(n))}function zd(e,t){return Object.assign(e,{meta:{package:"@milkdown/preset-commonmark",...t}}),e}var jd=xd("emphasis");zd(jd,{displayName:"Attr<emphasis>",group:"Emphasis"});var Vd=yd("emphasis",e=>({attrs:{marker:{default:e.get(cc).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>"italic"===e}],toDOM:t=>["em",e.get(jd.key)(t)],parseMarkdown:{match:e=>"emphasis"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"emphasis"===e.type.name,runner:(e,t)=>{e.withMark(t,"emphasis",void 0,{marker:t.attrs.marker})}}}));zd(Vd.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"}),zd(Vd.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});var Hd=cd("ToggleEmphasis",e=>()=>Mo(Vd.type(e)));zd(Hd,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});var $d=dd(e=>ii(/(?:^|[^*])\*([^*]+)\*$/,Vd.type(e),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:t+1}}));zd($d,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});var qd=dd(e=>ii(/\b_(?![_\s])(.*?[^_\s])_\b/,Vd.type(e),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:t})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:t+1}}));zd(qd,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});var Fd=wd("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:e=>{const t=e.get(xc);return()=>t.call(Hd.key)}}});zd(Fd.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"}),zd(Fd.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});var Wd=xd("strong");zd(Wd,{displayName:"Attr<strong>",group:"Strong"});var Ud=yd("strong",e=>({attrs:{marker:{default:e.get(cc).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>"bold"===e},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:t=>["strong",e.get(Wd.key)(t)],parseMarkdown:{match:e=>"strong"===e.type,runner:(e,t,n)=>{e.openMark(n,{marker:t.marker}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"strong"===e.type.name,runner:(e,t)=>{e.withMark(t,"strong",void 0,{marker:t.attrs.marker})}}}));zd(Ud.mark,{displayName:"MarkSchema<strong>",group:"Strong"}),zd(Ud.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});var Gd=cd("ToggleStrong",e=>()=>Mo(Ud.type(e)));zd(Gd,{displayName:"Command<toggleStrongCommand>",group:"Strong"});var Kd=dd(e=>ii(/(?<![\w:/])(?:\*\*|__)([^*_]+?)(?:\*\*|__)(?![\w/])$/,Ud.type(e),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));zd(Kd,{displayName:"InputRule<strong>",group:"Strong"});var Jd=wd("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:e=>{const t=e.get(xc);return()=>t.call(Gd.key)}}});zd(Jd.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"}),zd(Jd.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});var Zd=xd("inlineCode");zd(Zd,{displayName:"Attr<inlineCode>",group:"InlineCode"});var Yd=yd("inlineCode",e=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:t=>["code",e.get(Zd.key)(t)],parseMarkdown:{match:e=>"inlineCode"===e.type,runner:(e,t,n)=>{e.openMark(n),e.addText(t.value),e.closeMark(n)}},toMarkdown:{match:e=>"inlineCode"===e.type.name,runner:(e,t,n)=>(e.withMark(t,"inlineCode",n.text||""),!0)}}));zd(Yd.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"}),zd(Yd.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});var Xd=cd("ToggleInlineCode",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(r.empty)return!1;const{from:i,to:s}=r;return t.doc.rangeHasMark(i,s,Yd.type(e))?(n?.(o.removeMark(i,s,Yd.type(e))),!0):(Object.keys(t.schema.marks).filter(e=>e!==Yd.type.name).map(e=>t.schema.marks[e]).forEach(e=>{o.removeMark(i,s,e)}),n?.(o.addMark(i,s,Yd.type(e).create())),!0)});zd(Xd,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});var Qd=dd(e=>ii(/(?:`)([^`]+)(?:`)$/,Yd.type(e)));zd(Qd,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});var eu=wd("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:e=>{const t=e.get(xc);return()=>t.call(Xd.key)}}});zd(eu.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"}),zd(eu.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});var tu=xd("link");zd(tu,{displayName:"Attr<link>",group:"Link"});var nu=yd("link",e=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:t=>["a",{...e.get(tu.key)(t),...t.attrs}],parseMarkdown:{match:e=>"link"===e.type,runner:(e,t,n)=>{const r=t.url,o=t.title;e.openMark(n,{href:r,title:o}),e.next(t.children),e.closeMark(n)}},toMarkdown:{match:e=>"link"===e.type.name,runner:(e,t)=>{e.withMark(t,"link",void 0,{title:t.attrs.title,url:t.attrs.href})}}}));zd(nu.mark,{displayName:"MarkSchema<link>",group:"Link"});var ru=cd("ToggleLink",e=>(t={})=>Mo(nu.type(e),t));zd(ru,{displayName:"Command<toggleLinkCommand>",group:"Link"});var ou=cd("UpdateLink",e=>(t={})=>(n,r)=>{if(!r)return!1;let o,i=-1;const{selection:s}=n,{from:a,to:l}=s;if(n.doc.nodesBetween(a,a===l?l+1:l,(t,n)=>{if(nu.type(e).isInSet(t.marks))return o=t,i=n,!1}),!o)return!1;const c=o.marks.find(({type:t})=>t===nu.type(e));if(!c)return!1;const d=i,u=i+o.nodeSize,{tr:h}=n,p=nu.type(e).create({...c.attrs,...t});return!!p&&(r(h.removeMark(d,u,c).addMark(d,u,p).setSelection(new $r(h.selection.$anchor)).scrollIntoView()),!0)});zd(ou,{displayName:"Command<updateLinkCommand>",group:"Link"});var iu=hd("doc",()=>({content:"block+",parseMarkdown:{match:({type:e})=>"root"===e,runner:(e,t,n)=>{e.injectRoot(t,n)}},toMarkdown:{match:e=>"doc"===e.type.name,runner:(e,t)=>{e.openNode("root"),e.next(t.content)}}}));function su(e){return Z(e,e=>"html"===e.type&&["<br />","<br>","<br >","<br/>"].includes(e.value?.trim()),(e,t)=>{if(!t.length)return;const n=t[t.length-1];if(!n)return;const r=n.children.indexOf(e);-1!==r&&n.children.splice(r,1)},!0)}zd(iu,{displayName:"NodeSchema<doc>",group:"Doc"});var au=kd("remark-preserve-empty-line",()=>()=>su);zd(au.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"}),zd(au.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});var lu=bd("paragraph");zd(lu,{displayName:"Attr<paragraph>",group:"Paragraph"});var cu=vd("paragraph",e=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:t=>["p",e.get(lu.key)(t),0],parseMarkdown:{match:e=>"paragraph"===e.type,runner:(e,t,n)=>{e.openNode(n),t.children?e.next(t.children):e.addText(t.value||""),e.closeNode()}},toMarkdown:{match:e=>"paragraph"===e.type.name,runner:(t,n)=>{const r=e.get(Ql).state?.doc.lastChild;t.openNode("paragraph"),n.content&&0!==n.content.size||n===r||!function(e){let t=!1;try{e.get(au.id),t=!0}catch{t=!1}return t}(e)?Pd(t,n):t.addNode("html",void 0,"<br />"),t.closeNode()}}}));zd(cu.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"}),zd(cu.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});var du=cd("TurnIntoText",e=>()=>So(cu.type(e)));zd(du,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});var uu=wd("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:e=>{const t=e.get(xc);return()=>t.call(du.key)}}});zd(uu.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"}),zd(uu.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});var hu=Array(6).fill(0).map((e,t)=>t+1);var pu=gd(function(e){return e.textContent.toLowerCase().trim().replace(/\s+/g,"-")},"headingIdGenerator");zd(pu,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});var fu=bd("heading");zd(fu,{displayName:"Attr<heading>",group:"Heading"});var mu=vd("heading",e=>{const t=e.get(pu.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:hu.map(e=>({tag:`h${e}`,getAttrs:t=>{if(!(t instanceof HTMLElement))throw St(t);return{level:e,id:t.id}}})),toDOM:n=>[`h${n.attrs.level}`,{...e.get(fu.key)(n),id:n.attrs.id||t(n)},0],parseMarkdown:{match:({type:e})=>"heading"===e,runner:(e,t,n)=>{const r=t.depth;e.openNode(n,{level:r}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"heading"===e.type.name,runner:(e,t)=>{e.openNode("heading",void 0,{depth:t.attrs.level}),Pd(e,t),e.closeNode()}}}});zd(mu.node,{displayName:"NodeSchema<heading>",group:"Heading"}),zd(mu.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});var gu=dd(e=>Bo(/^(?<hashes>#+)\s$/,mu.type(e),t=>{const n=t.groups?.hashes?.length||0,{$from:r}=e.get(Ql).state.selection,o=r.node();if("heading"===o.type.name){let e=Number(o.attrs.level)+Number(n);return e>6&&(e=6),{level:e}}return{level:n}}));zd(gu,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});var vu=cd("WrapInHeading",e=>t=>(t??=1,t<1?So(cu.type(e)):So(mu.type(e),{level:t})));zd(vu,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});var yu=cd("DowngradeHeading",e=>()=>(t,n,r)=>{const{$from:o}=t.selection,i=o.node();if(i.type!==mu.type(e)||!t.selection.empty||0!==o.parentOffset)return!1;const s=i.attrs.level-1;return s?(n?.(t.tr.setNodeMarkup(t.selection.$from.before(),void 0,{...i.attrs,level:s})),!0):So(cu.type(e))(t,n,r)});zd(yu,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});var wu=wd("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:e=>{const t=e.get(xc);return()=>t.call(vu.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:e=>{const t=e.get(xc);return()=>t.call(yu.key)}}});zd(wu.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"}),zd(wu.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});var bu=bd("blockquote");zd(bu,{displayName:"Attr<blockquote>",group:"Blockquote"});var xu=vd("blockquote",e=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:t=>["blockquote",e.get(bu.key)(t),0],parseMarkdown:{match:({type:e})=>"blockquote"===e,runner:(e,t,n)=>{e.openNode(n).next(t.children).closeNode()}},toMarkdown:{match:e=>"blockquote"===e.type.name,runner:(e,t)=>{e.openNode("blockquote").next(t.content).closeNode()}}}));zd(xu.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"}),zd(xu.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});var ku=dd(e=>Ro(/^\s*>\s$/,xu.type(e)));zd(ku,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});var Cu=cd("WrapInBlockquote",e=>()=>Co(xu.type(e)));zd(Cu,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});var Su=wd("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:e=>{const t=e.get(xc);return()=>t.call(Cu.key)}}});zd(Su.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"}),zd(Su.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});var Mu=bd("codeBlock",()=>({pre:{},code:{}}));zd(Mu,{displayName:"Attr<codeBlock>",group:"CodeBlock"});var Nu=vd("code_block",e=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{language:e.dataset.language}}}],toDOM:t=>{const n=e.get(Mu.key)(t),r=t.attrs.language,o=r&&r.length>0?{"data-language":r}:void 0;return["pre",{...n.pre,...o},["code",n.code,0]]},parseMarkdown:{match:({type:e})=>"code"===e,runner:(e,t,n)=>{const r=t.lang??"",o=t.value;e.openNode(n,{language:r}),o&&e.addText(o),e.closeNode()}},toMarkdown:{match:e=>"code_block"===e.type.name,runner:(e,t)=>{e.addNode("code",void 0,t.content.firstChild?.text||"",{lang:t.attrs.language})}}}));zd(Nu.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"}),zd(Nu.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});var Eu=dd(e=>Bo(/^```(?<language>[a-z]*)?[\s\n]$/,Nu.type(e),e=>({language:e.groups?.language??""})));zd(Eu,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});var Ou=cd("CreateCodeBlock",e=>(t="")=>So(Nu.type(e),{language:t}));zd(Ou,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"}),zd(cd("UpdateCodeBlockLanguage",()=>({pos:e,language:t}={pos:-1,language:""})=>(n,r)=>e>=0&&(r?.(n.tr.setNodeAttribute(e,"language",t)),!0)),{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});var Tu=wd("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:e=>{const t=e.get(xc);return()=>t.call(Ou.key)}}});zd(Tu.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"}),zd(Tu.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});var Au=bd("image");zd(Au,{displayName:"Attr<image>",group:"Image"});var Du=vd("image",e=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:t=>["img",{...e.get(Au.key)(t),...t.attrs}],parseMarkdown:{match:({type:e})=>"image"===e,runner:(e,t,n)=>{const r=t.url,o=t.alt,i=t.title;e.addNode(n,{src:r,alt:o,title:i})}},toMarkdown:{match:e=>"image"===e.type.name,runner:(e,t)=>{e.addNode("image",void 0,void 0,{title:t.attrs.title,url:t.attrs.src,alt:t.attrs.alt})}}}));zd(Du.node,{displayName:"NodeSchema<image>",group:"Image"}),zd(Du.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});var Iu=cd("InsertImage",e=>(t={})=>(n,r)=>{if(!r)return!0;const{src:o="",alt:i="",title:s=""}=t,a=Du.type(e).create({src:o,alt:i,title:s});return!a||(r(n.tr.replaceSelectionWith(a).scrollIntoView()),!0)});zd(Iu,{displayName:"Command<insertImageCommand>",group:"Image"});var _u=cd("UpdateImage",e=>(t={})=>(n,r)=>{const o=bi(n.selection,Du.type(e));if(!o)return!1;const{node:i,pos:s}=o,a={...i.attrs},{src:l,alt:c,title:d}=t;return void 0!==l&&(a.src=l),void 0!==c&&(a.alt=c),void 0!==d&&(a.title=d),r?.(n.tr.setNodeMarkup(s,void 0,a).scrollIntoView()),!0});zd(_u,{displayName:"Command<updateImageCommand>",group:"Image"}),zd(dd(e=>new Io(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(t,n,r,o)=>{const[i,s,a="",l]=n;return i?t.tr.replaceWith(r,o,Du.type(e).create({src:a,alt:s,title:l})):null})),{displayName:"InputRule<insertImageInputRule>",group:"Image"});var Ru=bd("hardbreak",e=>({"data-type":"hardbreak","data-is-inline":e.attrs.isInline}));zd(Ru,{displayName:"Attr<hardbreak>",group:"Hardbreak"});var Bu=vd("hardbreak",e=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:t=>t.attrs.isInline?["span",e.get(Ru.key)(t)," "]:["br",e.get(Ru.key)(t)],parseMarkdown:{match:({type:e})=>"break"===e,runner:(e,t,n)=>{e.addNode(n,{isInline:Boolean(t.data?.isInline)})}},leafText:()=>"\n",toMarkdown:{match:e=>"hardbreak"===e.type.name,runner:(e,t)=>{t.attrs.isInline?e.addNode("text",void 0,"\n"):e.addNode("break")}}}));zd(Bu.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"}),zd(Bu.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});var Lu=cd("InsertHardbreak",e=>()=>(t,n)=>{const{selection:r,tr:o}=t;if(!(r instanceof $r))return!1;if(r.empty){const e=r.$from.node();if(e.childCount>0&&"hardbreak"===e.lastChild?.type.name)return n?.(o.replaceRangeWith(r.to-1,r.to,t.schema.node("paragraph")).setSelection(zr.near(o.doc.resolve(r.to))).scrollIntoView()),!0}return n?.(o.setMeta("hardbreak",!0).replaceSelectionWith(Bu.type(e).create()).scrollIntoView()),!0});zd(Lu,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});var Pu=wd("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:e=>{const t=e.get(xc);return()=>t.call(Lu.key)}}});zd(Pu.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"}),zd(Pu.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});var zu=bd("hr");zd(zu,{displayName:"Attr<hr>",group:"Hr"});var ju=vd("hr",e=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:t=>["hr",e.get(zu.key)(t)],parseMarkdown:{match:({type:e})=>"thematicBreak"===e,runner:(e,t,n)=>{e.addNode(n)}},toMarkdown:{match:e=>"hr"===e.type.name,runner:e=>{e.addNode("thematicBreak")}}}));zd(ju.node,{displayName:"NodeSchema<hr>",group:"Hr"}),zd(ju.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});var Vu=dd(e=>new Io(/^(?:---|___\s|\*\*\*\s)$/,(t,n,r,o)=>{const{tr:i}=t;return n[0]&&i.replaceWith(r-1,o,ju.type(e).create()),i}));zd(Vu,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});var Hu=cd("InsertHr",e=>()=>(t,n)=>{if(!n)return!0;const r=cu.node.type(e).create(),{tr:o,selection:i}=t,{from:s}=i,a=ju.type(e).create();if(!a)return!0;const l=o.replaceSelectionWith(a).insert(s,r),c=zr.findFrom(l.doc.resolve(s),1,!0);return!c||(n(l.setSelection(c).scrollIntoView()),!0)});zd(Hu,{displayName:"Command<insertHrCommand>",group:"Hr"});var $u=bd("bulletList");zd($u,{displayName:"Attr<bulletList>",group:"BulletList"});var qu=vd("bullet_list",e=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{spread:"true"===e.dataset.spread}}}],toDOM:t=>["ul",{...e.get($u.key)(t),"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"false";e.openNode(n,{spread:r}).next(t.children).closeNode()}},toMarkdown:{match:e=>"bullet_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!1,spread:t.attrs.spread}).next(t.content).closeNode()}}}));zd(qu.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"}),zd(qu.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});var Fu=dd(e=>Ro(/^\s*([-+*])\s$/,qu.type(e)));zd(Fu,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});var Wu=cd("WrapInBulletList",e=>()=>Co(qu.type(e)));zd(Wu,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});var Uu=wd("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:e=>{const t=e.get(xc);return()=>t.call(Wu.key)}}});zd(Uu.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"}),zd(Uu.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});var Gu=bd("orderedList");zd(Gu,{displayName:"Attr<orderedList>",group:"OrderedList"});var Ku=vd("ordered_list",e=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:t=>["ol",{...e.get(Gu.key)(t),...1===t.attrs.order?{}:{start:t.attrs.order},"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:t})=>"list"===e&&!!t,runner:(e,t,n)=>{const r=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{spread:r,order:t.start??1}).next(t.children).closeNode()}},toMarkdown:{match:e=>"ordered_list"===e.type.name,runner:(e,t)=>{e.openNode("list",void 0,{ordered:!0,start:t.attrs.order??1,spread:"true"===t.attrs.spread}),e.next(t.content),e.closeNode()}}}));zd(Ku.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"}),zd(Ku.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});var Ju=dd(e=>Ro(/^\s*(\d+)\.\s$/,Ku.type(e),e=>({order:Number(e[1])}),(e,t)=>t.childCount+t.attrs.order===Number(e[1])));zd(Ju,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});var Zu=cd("WrapInOrderedList",e=>()=>Co(Ku.type(e)));zd(Zu,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});var Yu=wd("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:e=>{const t=e.get(xc);return()=>t.call(Zu.key)}}});zd(Yu.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"}),zd(Yu.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});var Xu=bd("listItem");zd(Xu,{displayName:"Attr<listItem>",group:"ListItem"});var Qu=vd("list_item",e=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw St(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:"true"===e.dataset.spread}}}],toDOM:t=>["li",{...e.get(Xu.key)(t),"data-label":t.attrs.label,"data-list-type":t.attrs.listType,"data-spread":t.attrs.spread},0],parseMarkdown:{match:({type:e})=>"listItem"===e,runner:(e,t,n)=>{const r=null!=t.label?`${t.label}.`:"•",o=null!=t.label?"ordered":"bullet",i=null!=t.spread?`${t.spread}`:"true";e.openNode(n,{label:r,listType:o,spread:i}),e.next(t.children),e.closeNode()}},toMarkdown:{match:e=>"list_item"===e.type.name,runner:(e,t)=>{e.openNode("listItem",void 0,{spread:t.attrs.spread}),e.next(t.content),e.closeNode()}}}));zd(Qu.node,{displayName:"NodeSchema<listItem>",group:"ListItem"}),zd(Qu.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});var eh=cd("SinkListItem",e=>()=>{return t=Qu.type(e),function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,e=>e.childCount>0&&e.firstChild.type==t);if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,o=$t.from(r?t.create():null),s=new Kt($t.from(t.create(null,$t.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(e.tr.step(new ur(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0};var t});zd(eh,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});var th=cd("LiftListItem",e=>()=>Rd(Qu.type(e)));zd(th,{displayName:"Command<liftListItemCommand>",group:"ListItem"});var nh=cd("SplitListItem",e=>()=>{return t=Qu.type(e),function(e,n){let{$from:r,$to:o,node:i}=e.selection;if(i&&i.isBlock||r.depth<2||!r.sameParent(o))return!1;let s=r.node(-1);if(s.type!=t)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=t||r.index(-2)!=r.node(-2).childCount-1)return!1;if(n){let o=$t.empty,i=r.index(-1)?1:r.index(-2)?2:3;for(let e=r.depth-i;e>=r.depth-3;e--)o=$t.from(r.node(e).copy(o));let s=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;o=o.append($t.from(t.createAndFill()));let a=r.before(r.depth-(i-1)),l=e.tr.replace(a,r.after(-s),new Kt(o,4-i,0)),c=-1;l.doc.nodesBetween(a,l.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&0==e.content.size&&(c=t+1)}),c>-1&&l.setSelection(zr.near(l.doc.resolve(c))),n(l.scrollIntoView())}return!0}let a=o.pos==r.end()?s.contentMatchAt(0).defaultType:null,l=e.tr.delete(r.pos,o.pos),c=a?[null,{type:a}]:void 0;return!!br(l.doc,r.pos,2,c)&&(n&&n(l.split(r.pos,2,c).scrollIntoView()),!0)};var t});zd(nh,{displayName:"Command<splitListItemCommand>",group:"ListItem"});var rh=cd("LiftFirstListItem",e=>()=>function(e){return(t,n,r)=>{const{selection:o}=t;if(!(o instanceof $r))return!1;const{empty:i,$from:s}=o;return!(!i||0!==s.parentOffset)&&s.node(-1).type===Qu.type(e)&&co(t,n,r)}}(e));zd(rh,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});var oh=wd("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:e=>{const t=e.get(xc);return()=>t.call(nh.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:e=>{const t=e.get(xc);return()=>t.call(eh.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:e=>{const t=e.get(xc);return()=>t.call(th.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:e=>{const t=e.get(xc);return()=>t.call(rh.key)}}});zd(oh.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"}),zd(oh.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});var ih=hd("text",()=>({group:"inline",parseMarkdown:{match:({type:e})=>"text"===e,runner:(e,t)=>{e.addText(t.value)}},toMarkdown:{match:e=>"text"===e.type.name,runner:(e,t)=>{e.addNode("text",void 0,t.text)}}}));zd(ih,{displayName:"NodeSchema<text>",group:"Text"});var sh=bd("html");zd(sh,{displayName:"Attr<html>",group:"Html"});var ah=vd("html",e=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:t=>{const n=document.createElement("span"),r={...e.get(sh.key)(t),"data-value":t.attrs.value,"data-type":"html"};return n.textContent=t.attrs.value,["span",r,t.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>Boolean("html"===e),runner:(e,t,n)=>{e.addNode(n,{value:t.value})}},toMarkdown:{match:e=>"html"===e.type.name,runner:(e,t)=>{e.addNode("html",void 0,t.attrs.value)}}}));zd(ah.node,{displayName:"NodeSchema<html>",group:"Html"}),zd(ah.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});var lh=[iu,lu,cu,pu,fu,mu,Ru,Bu,bu,xu,Mu,Nu,zu,ju,Au,Du,$u,qu,Gu,Ku,Xu,Qu,jd,Vd,Wd,Ud,Zd,Yd,tu,nu,sh,ah,ih].flat(),ch=[ku,Fu,Ju,Eu,Vu,gu].flat(),dh=[$d,qd,Qd,Kd],uh=cd("IsMarkSelected",()=>e=>t=>{if(!e)return!1;const{doc:n,selection:r}=t;return n.rangeHasMark(r.from,r.to,e)}),hh=cd("IsNoteSelected",()=>e=>t=>!!e&&xi(t,e).hasNode),ph=cd("ClearTextInCurrentBlock",()=>()=>(e,t)=>{let n=e.tr;const{$from:r,$to:o}=n.selection,{pos:i}=r,{pos:s}=o,a=i-r.node().content.size;return!(a<0)&&(n=n.deleteRange(a,s),t?.(n),!0)}),fh=cd("SetBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr,{from:s,to:a}=i.selection;try{i.setBlockType(s,a,r,o)}catch{return!1}return n?.(i),!0}),mh=cd("WrapInBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;let i=t.tr;try{const{$from:e,$to:t}=i.selection,n=e.blockRange(t),s=n&&gr(n,r,o);if(!s)return!1;i=i.wrap(n,s)}catch{return!1}return n?.(i),!0}),gh=cd("AddBlockType",()=>e=>(t,n)=>{const{nodeType:r,attrs:o=null}=e??{};if(!r)return!1;const i=t.tr;try{const e=r instanceof pn?r:r.createAndFill(o);if(!e)return!1;i.replaceSelectionWith(e)}catch{return!1}return n?.(i),!0}),vh=cd("SelectTextNearPos",()=>e=>(t,n)=>{const{pos:r}=e??{};if(null==r)return!1;const o=t.tr;try{const e=t.doc.resolve((i=r,s=0,a=t.doc.content.size,Math.min(Math.max(i,s),a)));o.setSelection($r.near(e))}catch{return!1}var i,s,a;return n?.(o.scrollIntoView()),!0}),yh=[du,Cu,vu,yu,Ou,Lu,Hu,Iu,_u,Zu,Wu,eh,nh,th,rh,Hd,Xd,Gd,ru,ou,uh,hh,ph,fh,mh,gh,vh],wh=[Su,Tu,Pu,wu,oh,Yu,Uu,uu,Fd,eu,Jd].flat(),bh=kd("remarkAddOrderInList",()=>()=>e=>{K(e,"list",e=>{if(e.ordered){const t=e.start??1;e.children.forEach((e,n)=>{e.label=n+t})}})});zd(bh.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"}),zd(bh.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});var xh=kd("remarkLineBreak",()=>()=>e=>{const t=/[\t ]*(?:\r?\n|\r)/g;K(e,"text",(e,n,r)=>{if(!e.value||"string"!=typeof e.value)return;const o=[];let i=0;t.lastIndex=0;let s=t.exec(e.value);for(;s;){const n=s.index;i!==n&&o.push({type:"text",value:e.value.slice(i,n)}),o.push({type:"break",data:{isInline:!0}}),i=n+s[0].length,s=t.exec(e.value)}return o.length>0&&r&&"number"==typeof n?(i<e.value.length&&o.push({type:"text",value:e.value.slice(i)}),r.children.splice(n,1,...o),n+o.length):void 0})});zd(xh.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"}),zd(xh.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});var kh=kd("remarkInlineLink",()=>Ld);zd(kh.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"}),zd(kh.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});var Ch=["root","blockquote","listItem"],Sh=kd("remarkHTMLTransformer",()=>()=>e=>{var t;t=(e,t,n)=>(e=>"html"===e.type)(e)?(n&&Ch.includes(n.type)&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e],function e(n,r,o){if((e=>!!e.children)(n)){const t=[];for(let r=0,o=n.children.length;r<o;r++){const o=n.children[r];if(o){const i=e(o,r,n);if(i)for(let e=0,n=i.length;e<n;e++){const n=i[e];n&&t.push(n)}}}n.children=t}return t(n,r,o)}(e,0,null)[0]});zd(Sh.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"}),zd(Sh.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});var Mh=kd("remarkMarker",()=>()=>(e,t)=>{K(e,e=>["strong","emphasis"].includes(e.type),e=>{e.marker=(e=>t.value.charAt(e.position.start.offset))(e)})});zd(Mh.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"}),zd(Mh.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});var Nh=pd(()=>{let e=!1;const t=new ro({key:new so("MILKDOWN_INLINE_NODES_CURSOR"),state:{init:()=>!1,apply(e){if(!e.selection.empty)return!1;const t=e.selection.$from,n=t.nodeBefore,r=t.nodeAfter;return!(!(n&&r&&n.isInline&&!n.isText&&r.isInline)||r.isText)}},props:{handleDOMEvents:{compositionend:(n,r)=>!!e&&(e=!1,requestAnimationFrame(()=>{if(t.getState(n.state)){const e=n.state.selection.from;r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e))}}),!0),compositionstart:n=>(t.getState(n.state)&&(e=!0),!1),beforeinput:(n,r)=>{if(t.getState(n.state)&&r instanceof InputEvent&&r.data&&!e){const e=n.state.selection.from;return r.preventDefault(),n.dispatch(n.state.tr.insertText(r.data||"",e)),!0}return!1}},decorations(e){if(t.getState(e)){const t=e.selection.$from.pos,n=document.createElement("span"),r=vl.widget(t,n,{side:-1}),o=document.createElement("span"),i=vl.widget(t,o);return setTimeout(()=>{n.contentEditable="true",o.contentEditable="true"}),bl.create(e.doc,[r,i])}return bl.empty}}});return t});zd(Nh,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});var Eh=pd(e=>new ro({key:new so("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(t,n,r)=>{if(!t.length)return;const[o]=t;if(!o)return;const[i]=o.steps;if(o.getMeta("hardbreak")){if(!(i instanceof dr))return;const{from:t}=i;return r.tr.setNodeMarkup(t,Bu.type(e),void 0,[])}if(i instanceof sr){let t=r.tr;const{from:n,to:o}=i;return r.doc.nodesBetween(n,o,(n,r)=>{n.type===Bu.type(e)&&(t=t.setNodeMarkup(r,Bu.type(e),void 0,[]))}),t}}}));zd(Eh,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});var Oh=gd(["table","code_block"],"hardbreakFilterNodes");zd(Oh,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});var Th=pd(e=>{const t=e.get(Oh.key);return new ro({key:new so("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(e,n)=>{const r=e.getMeta("hardbreak"),[o]=e.steps;if(r&&o){const{from:e}=o,r=n.doc.resolve(e);let i=r.depth,s=!0;for(;i>0;)t.includes(r.node(i).type.name)&&(s=!1),i--;return s}return!0}})});zd(Th,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});var Ah=pd(e=>{const t=new so("MILKDOWN_HEADING_ID"),n=n=>{if(n.composing)return;const r=e.get(pu.key),o=n.state.tr.setMeta("addToHistory",!1);let i=!1;const s={};n.state.doc.descendants((n,a)=>{if(n.type===mu.type(e)){if(0===n.textContent.trim().length)return;const e=n.attrs;let l=r(n);s[l]?(s[l]+=1,l+=`-#${s[l]}`):s[l]=1,e.id!==l&&(i=!0,o.setMeta(t,!0).setNodeMarkup(a,void 0,{...e,id:l}))}}),i&&n.dispatch(o)};return new ro({key:t,view:e=>(n(e),{update:(e,t)=>{e.state.doc.eq(t.doc)||n(e)}})})});zd(Ah,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});var Dh=pd(e=>new ro({key:new so("MILKDOWN_KEEP_LIST_ORDER"),appendTransaction:(t,n,r)=>{if(!r.selection||t.some(e=>!1===e.getMeta("addToHistory")||!e.isGeneric))return null;const o=Ku.type(e),i=qu.type(e),s=Qu.type(e),a=(e,t,n=1)=>{let r=!1;const o=`${t+n}.`;return e.label!==o&&(e.label=o,r=!0),r};let l=r.tr,c=!1;return r.doc.descendants((e,t,n,r)=>{if(e.type===i){const n=e.maybeChild(0);n?.type===s&&"ordered"===n.attrs.listType&&(c=!0,l.setNodeMarkup(t,o,{spread:"true"}),e.descendants((e,t,n,r)=>{if(e.type===s){const n={...e.attrs};a(n,r)&&(l=l.setNodeMarkup(t,void 0,n))}return!1}))}else if(e.type===s&&n?.type===o){const o={...e.attrs};let i=!1;"ordered"!==o.listType&&(o.listType="ordered",i=!0),n?.maybeChild(0)&&(i=a(o,r,n?.attrs.order??1)),i&&(l=l.setNodeMarkup(t,void 0,o),c=!0)}}),c?l.setMeta("addToHistory",!1):null}}));zd(Dh,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});var Ih=[lh,ch,dh,yh,wh,[Eh,Oh,Th,Nh,bh,kh,xh,Sh,Mh,au,Ah,Dh].flat()].flat(),_h=200,Rh=function(){};Rh.prototype.append=function(e){return e.length?(e=Rh.from(e),!this.length&&e||e.length<_h&&this.leafAppend(e)||this.length<_h&&e.leafPrepend(this)||this.appendInner(e)):this},Rh.prototype.prepend=function(e){return e.length?Rh.from(e).append(this):this},Rh.prototype.appendInner=function(e){return new Lh(this,e)},Rh.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Rh.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Rh.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Rh.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Rh.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Rh.from=function(e){return e instanceof Rh?e:e&&e.length?new Bh(e):Rh.empty};var Bh=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=_h)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=_h)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Rh);Rh.empty=new Bh([]);var Lh=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Rh);class Ph{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,a=e.tr,l=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new zh(e.map));let t,o=e.step.map(n.slice(r));o&&a.maybeStep(o).doc&&(t=a.mapping.maps[a.mapping.maps.length-1],l.push(new zh(t,void 0,void 0,l.length+c.length))),r--,t&&n.appendMap(t,r)}else a.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new Ph(this.items.slice(0,o).append(c.reverse().concat(l)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:a,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,a=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let l,c=e.steps[n].invert(e.docs[n]),d=new zh(e.mapping.maps[n],c,t);(l=a&&a.merge(d))&&(d=l,n?o.pop():s=s.slice(0,s.length-1)),o.push(d),t&&(i++,t=void 0),r||(a=d)}let l=i-n.depth;return l>Vh&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,l),i-=l),new Ph(s.append(o),i)}remapping(e,t){let n=new tr;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Ph(this.items.append(e.map(e=>new zh(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let a=t;this.items.forEach(t=>{let r=o.getMirror(--a);if(null==r)return;i=Math.min(i,r);let l=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(a+1,r));c&&s++,n.push(new zh(l,i,c))}else n.push(new zh(l))},r);let l=[];for(let e=t;e<i;e++)l.push(new zh(o.maps[e]));let c=this.items.slice(0,r).append(l).append(n),d=new Ph(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=i.selection&&i.selection.map(t.slice(n));a&&o++;let l,c=new zh(s.invert(),e,a),d=r.length-1;(l=r.length&&r[d].merge(c))?r[d]=l:r.push(c)}}else i.map&&n--},this.items.length,0),new Ph(Rh.from(r.reverse()),o)}}Ph.empty=new Ph(Rh.empty,0);class zh{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new zh(t.getMap().invert(),t,this.selection)}}}class jh{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const Vh=20;function Hh(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,o)=>t.push(r,o));return t}function $h(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let qh=!1,Fh=null;function Wh(e){let t=e.plugins;if(Fh!=t){qh=!1,Fh=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){qh=!0;break}}return qh}const Uh=new so("history"),Gh=new so("closeHistory");function Kh(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new ro({key:Uh,state:{init:()=>new jh(Ph.empty,Ph.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(Uh);if(i)return i.historyState;n.getMeta(Gh)&&(e=new jh(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Uh))return s.getMeta(Uh).redo?new jh(e.done.addTransform(n,void 0,r,Wh(t)),e.undone,Hh(n.mapping.maps),e.prevTime,e.prevComposition):new jh(e.done,e.undone.addTransform(n,void 0,r,Wh(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new jh(e.done.rebased(n,o),e.undone.rebased(n,o),$h(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new jh(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),$h(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),a=s?$h(e.prevRanges,n.mapping):Hh(n.mapping.maps);return new jh(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,Wh(t)),Ph.empty,a,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?Zh:"historyRedo"==n?Yh:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Jh(e,t){return(n,r)=>{let o=Uh.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=Wh(t),o=Uh.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),a=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),l=new jh(n?a:i.remaining,n?i.remaining:a,null,0,-1);return i.transform.setSelection(s).setMeta(Uh,{redo:n,historyState:l})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const Zh=Jh(!1,!0),Yh=Jh(!0,!0);
|
|
2
2
|
/**
|
|
3
3
|
* @vue/shared v3.5.35
|
|
4
4
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|