zs_library 0.4.2 → 0.4.4
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/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C,fe){typeof exports=="object"&&typeof module<"u"?fe(exports,require("i18next"),require("react-i18next"),require("react/jsx-runtime"),require("@emotion/css"),require("react"),require("react-slick"),require("react-sortablejs"),require("framer-motion"),require("ahooks"),require("uuid"),require("rc-tooltip"),require("@remixicon/react"),require("rc-dialog"),require("react-json-view"),require("@mdxeditor/editor"),require("react-markdown"),require("remark-gfm"),require("remark-emoji"),require("rehype-raw"),require("react-syntax-highlighter"),require("rc-image"),require("clsx"),require("tailwind-merge"),require("novel"),require("use-debounce"),require("tiptap-markdown"),require("class-variance-authority"),require("lowlight"),require("@tiptap/core"),require("@radix-ui/react-popover"),require("@radix-ui/react-slot"),require("lucide-react"),require("@radix-ui/react-separator"),require("@ai-sdk/react"),require("sonner"),require("@radix-ui/react-scroll-area"),require("cmdk"),require("@radix-ui/react-dialog"),require("highlight.js"),require("rc-dropdown"),require("rc-menu"),require("@tiptap/html")):typeof define=="function"&&define.amd?define(["exports","i18next","react-i18next","react/jsx-runtime","@emotion/css","react","react-slick","react-sortablejs","framer-motion","ahooks","uuid","rc-tooltip","@remixicon/react","rc-dialog","react-json-view","@mdxeditor/editor","react-markdown","remark-gfm","remark-emoji","rehype-raw","react-syntax-highlighter","rc-image","clsx","tailwind-merge","novel","use-debounce","tiptap-markdown","class-variance-authority","lowlight","@tiptap/core","@radix-ui/react-popover","@radix-ui/react-slot","lucide-react","@radix-ui/react-separator","@ai-sdk/react","sonner","@radix-ui/react-scroll-area","cmdk","@radix-ui/react-dialog","highlight.js","rc-dropdown","rc-menu","@tiptap/html"],fe):(C=typeof globalThis<"u"?globalThis:C||self,fe(C.zs_library={},C.i18n,C.reactI18next,C.jsxRuntime,C.css,C.React,C.Slider,C.reactSortablejs,C.framerMotion,C.ahooks,C.uuid,C.RcTooltip,C.react,C.Dialog,C.ReactJson,C.MDXEditor,C.Markdown,C.remarkGfm,C.emoji,C.rehypeRaw,C.reactSyntaxHighlighter,C.Image$1,C.clsx,C.tailwindMerge,C.novel,C.useDebounce,C.tiptapMarkdown,C.classVarianceAuthority,C.lowlight,C.core,C.PopoverPrimitive,C.reactSlot,C.lucideReact,C.SeparatorPrimitive,C.react$1,C.sonner,C.ScrollAreaPrimitive,C.cmdk,C.DialogPrimitive,C.hljs,C.RcDropdown,C.RcMenu,C.html))})(this,function(C,fe,it,h,b,
|
|
1
|
+
(function(C,fe){typeof exports=="object"&&typeof module<"u"?fe(exports,require("i18next"),require("react-i18next"),require("react/jsx-runtime"),require("@emotion/css"),require("react"),require("react-slick"),require("react-sortablejs"),require("framer-motion"),require("ahooks"),require("uuid"),require("rc-tooltip"),require("@remixicon/react"),require("rc-dialog"),require("react-json-view"),require("@mdxeditor/editor"),require("react-markdown"),require("remark-gfm"),require("remark-emoji"),require("rehype-raw"),require("react-syntax-highlighter"),require("rc-image"),require("clsx"),require("tailwind-merge"),require("novel"),require("use-debounce"),require("tiptap-markdown"),require("class-variance-authority"),require("lowlight"),require("@tiptap/core"),require("@radix-ui/react-popover"),require("@radix-ui/react-slot"),require("lucide-react"),require("@radix-ui/react-separator"),require("@ai-sdk/react"),require("sonner"),require("@radix-ui/react-scroll-area"),require("cmdk"),require("@radix-ui/react-dialog"),require("highlight.js"),require("rc-dropdown"),require("rc-menu"),require("@tiptap/html")):typeof define=="function"&&define.amd?define(["exports","i18next","react-i18next","react/jsx-runtime","@emotion/css","react","react-slick","react-sortablejs","framer-motion","ahooks","uuid","rc-tooltip","@remixicon/react","rc-dialog","react-json-view","@mdxeditor/editor","react-markdown","remark-gfm","remark-emoji","rehype-raw","react-syntax-highlighter","rc-image","clsx","tailwind-merge","novel","use-debounce","tiptap-markdown","class-variance-authority","lowlight","@tiptap/core","@radix-ui/react-popover","@radix-ui/react-slot","lucide-react","@radix-ui/react-separator","@ai-sdk/react","sonner","@radix-ui/react-scroll-area","cmdk","@radix-ui/react-dialog","highlight.js","rc-dropdown","rc-menu","@tiptap/html"],fe):(C=typeof globalThis<"u"?globalThis:C||self,fe(C.zs_library={},C.i18n,C.reactI18next,C.jsxRuntime,C.css,C.React,C.Slider,C.reactSortablejs,C.framerMotion,C.ahooks,C.uuid,C.RcTooltip,C.react,C.Dialog,C.ReactJson,C.MDXEditor,C.Markdown,C.remarkGfm,C.emoji,C.rehypeRaw,C.reactSyntaxHighlighter,C.Image$1,C.clsx,C.tailwindMerge,C.novel,C.useDebounce,C.tiptapMarkdown,C.classVarianceAuthority,C.lowlight,C.core,C.PopoverPrimitive,C.reactSlot,C.lucideReact,C.SeparatorPrimitive,C.react$1,C.sonner,C.ScrollAreaPrimitive,C.cmdk,C.DialogPrimitive,C.hljs,C.RcDropdown,C.RcMenu,C.html))})(this,function(C,fe,it,h,b,w,bs,on,v,_n,Zn,Qn,D,Rn,xs,B,er,ks,Ss,Cs,Ns,ws,Ds,Ts,N,Os,Ms,le,tr,vs,Ft,Is,te,Es,As,bt,Ps,he,zs,Bs,Ls,Vt,Fs){"use strict";var Za=Object.defineProperty;var Qa=(C,fe,it)=>fe in C?Za(C,fe,{enumerable:!0,configurable:!0,writable:!0,value:it}):C[fe]=it;var Yn=(C,fe,it)=>Qa(C,typeof fe!="symbol"?fe+"":fe,it);require("./zs_library.css");function xt(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const ne=xt(w),kt=xt(Ft),nr=xt(Es),Xe=xt(Ps),we=xt(zs),Vs={common:{ok:"确定",cancel:"取消",confirm:"确认",loading:"加载中...",noData:"暂无数据",edit:"编辑",delete:"删除",save:"保存"},desktop:{maximize:"最大化",minimize:"最小化",restore:"还原",close:"关闭"},editor:{placeholder:"请输入内容...",bold:"加粗",italic:"斜体",code:"代码",link:"链接",image:"图片"}},$s={common:{ok:"OK",cancel:"Cancel",confirm:"Confirm",loading:"Loading...",noData:"No Data",edit:"Edit",delete:"Delete",save:"Save"},desktop:{maximize:"Maximize",minimize:"Minimize",restore:"Restore",close:"Close"},editor:{placeholder:"Please enter content...",bold:"Bold",italic:"Italic",code:"Code",link:"Link",image:"Image"}};fe.use(it.initReactI18next).init({resources:{"zh-CN":Vs,"en-US":$s},lng:"zh-CN",fallbackLng:"zh-CN",defaultNS:"common",interpolation:{escapeValue:!1}});const rr={token:{itemNameColor:"#1a1a1a",itemIconBackgroundColor:"white",itemIconShadowColor:"rgba(0, 0, 0, 0.1)",groupItemIconBackgroundColor:"rgba(255, 255, 255, 0.1)",groupItemIconShadowColor:"rgba(0, 0, 0, 0.1)",groupItemModalBackgroundColor:"rgba(255, 255, 255, 0.8)",contextMenuTextColor:"black",contextMenuActiveColor:"#f3f4f6",contextMenuBackgroundColor:"white",contextMenuShadowColor:"rgba(0, 0, 0, 0.1)"}},or={token:{itemNameColor:"white",itemIconBackgroundColor:"#1f2937",itemIconShadowColor:"rgba(0, 0, 0, 0.1)",groupItemIconBackgroundColor:"rgba(0, 0, 0, 0.1)",groupItemIconShadowColor:"rgba(0, 0, 0, 0.1)",groupItemModalBackgroundColor:"rgba(0, 0, 0, 0.1)",contextMenuTextColor:"white",contextMenuActiveColor:"#1a1a1a",contextMenuBackgroundColor:"#1a1a1a",contextMenuShadowColor:"rgba(255, 255, 255, 0.1)"}},sr=w.createContext({}),qs=n=>{const{children:e,theme:t,...r}=n,o=w.useMemo(()=>t==="light"?rr:t==="dark"?or:t,[t]);return h.jsx(sr.Provider,{value:{theme:o,...r},children:e})},Ye=()=>w.useContext(sr),ir={maxRow:2,maxCol:2},Hs={...ir},lr={app:ir,group:Hs};class Ce{}Yn(Ce,"uniqueArray",e=>e.reduce((t,r)=>t.find(s=>s.id===r.id)?t:t.concat([r]),[])),Yn(Ce,"getTheme",e=>{const t=rr.token,r=or.token,o={...t,...e==null?void 0:e.token},s={...r,...e==null?void 0:e.token};return{light:o,dark:s}});const ar=w.createContext({list:[],setList:()=>{},contextMenu:null,setContextMenu:()=>{},listStatus:null,setListStatus:()=>{},contextMenuFuns:()=>{},hideContextMenu:()=>{},showInfoItemData:null,setShowInfoItemData:()=>{},openGroupItemData:null,setOpenGroupItemData:()=>{},longPressTriggered:!1,updateItem:()=>{},updateItemConfig:()=>{},removeItem:()=>{},addItem:()=>{},moveItemId:null,setMoveItemId:()=>{},moveTargetId:null,setMoveTargetId:()=>{}}),Ws=n=>{const{children:e,list:t=[],onChange:r,storageKey:o="ZS_LIBRARY_DESKTOP_SORTABLE_CONFIG",enableCaching:s=!0}=n,[i,l]=w.useState(),[a,c]=w.useState(),[d,u]=w.useState(null),f=w.useRef(d),[m,p]=w.useState(null),[y,g]=w.useState([]),[x,S]=w.useState(null),[E,k]=w.useState(null),[P,I]=w.useState(!1),[A,M]=w.useState(null),[T,Q]=w.useState(null),[X,Me]=w.useState(!1),[Le,F]=_n.useLocalStorageState(o,{defaultValue:[],listenStorageChange:!0}),Y=()=>{p(null),clearTimeout(i),l(void 0),f.current=null},W=(V,ie)=>{p({...V,pageX:V.pageX,pageY:V.pageY,data:ie}),clearTimeout(i)},ge=(V,ie=!0)=>{const{config:Z={}}=V;return Z.allowContextMenu===!1?{}:{onMouseDown:K=>{l(setTimeout(()=>{ie&&f.current===null&&W(K,V)},800)),I(!1),c(setTimeout(()=>{I(!0)},800))},onMouseUp:()=>{clearTimeout(a),c(void 0),clearTimeout(i),l(void 0)},onContextMenu:K=>{ie&&(K.preventDefault(),W(K,V))}}},ve=w.useCallback((V,ie)=>{const Z=[...ie||[]];if(Z.length>0)g(K=>{const q=[...K],J=$=>{var gs,ys;const j=Z.shift(),ee=$.find(Fe=>Fe.id===j),Ie=$.findIndex(Fe=>Fe.id===j);if(Z.length&&ee){if(((gs=ee.children)==null?void 0:gs.filter(Fe=>!V.some(_a=>_a.id===Fe.id)).length)===1&&V.length===1){const Fe={...V[0]};return $.splice(Ie,1,Fe),r==null||r($),$}return ee.children=J(ee.children||[]),$.splice(Ie,1,ee),r==null||r($),$}if(ee){if(!((ys=ee.children)!=null&&ys.length)&&V.length){const Fe={...ee};return ee.data={name:"文件夹"},ee.type="group",ee.children=[Fe,...V],ee.id=Zn.v4(),$.splice(Ie,1,ee),r==null||r($),$}return ee.children=Ce.uniqueArray(V),$.splice(Ie,1,ee),r==null||r($),$}return Ce.uniqueArray(V)};return Ce.uniqueArray(J(q))});else{const K=Ce.uniqueArray(V);r==null||r(K),g(K)}},[r]),Xn=(V,ie)=>{g(Z=>{const K=[...Z],q=J=>{var $;for(let j=0;j<J.length;j++)if(J[j].id===V){J[j].config=ie;break}else(($=J[j].children)==null?void 0:$.length)!==void 0&&q(J[j].children)};return q(K),r==null||r(K),K})},nn=(V,ie)=>{g(Z=>{const K=[...Z],q=J=>{var $;for(let j=0;j<J.length;j++)if(J[j].id===V){J[j].data=ie;break}else(($=J[j].children)==null?void 0:$.length)!==void 0&&q(J[j].children)};return q(K),r==null||r(K),K})},rn=V=>{g(ie=>{const Z=[...ie],K=q=>{var J;for(let $=0;$<q.length;$++)if(q[$].id===V){q.splice($,1);break}else((J=q[$].children)==null?void 0:J.length)!==void 0&&K(q[$].children)};return K(Z),r==null||r(Z),Z})},je=(V,ie)=>{const Z=[...y],K=(q,J)=>{const $=J.shift(),j=q.find(Ie=>Ie.id===$),ee=q.findIndex(Ie=>Ie.id===$);if(j){if(J.length)j.children=K(j.children||[],J);else{const Ie=(V==null?void 0:V.type)??"app";j.children=[...j.children??[],{...V,id:Zn.v4(),config:(V==null?void 0:V.config)??lr[Ie]}]}return q.splice(ee,1,j),q}else return q};g(K(Z,ie))};return w.useEffect(()=>{(t==null?void 0:t.length)>0&&(y.length===0||JSON.stringify(y)!==JSON.stringify(t))&&ve(t)},[ve,y,t]),w.useEffect(()=>{f.current=d,d!==null&&Y()},[d]),w.useEffect(()=>{s&&Le!=null&&Le.length&&!X&&(ve(Le),Me(!0))},[Le,X,s]),_n.useDebounceEffect(()=>{s&&F(y)},[y,s],{wait:1e3}),h.jsx(ar.Provider,{value:{list:y,setList:ve,contextMenu:m,setContextMenu:p,listStatus:d,setListStatus:u,contextMenuFuns:ge,hideContextMenu:Y,showInfoItemData:x,setShowInfoItemData:S,openGroupItemData:E,setOpenGroupItemData:k,longPressTriggered:P,updateItemConfig:Xn,updateItem:nn,removeItem:rn,addItem:je,moveItemId:A,setMoveItemId:M,moveTargetId:T,setMoveTargetId:Q},children:e})},lt=()=>w.useContext(ar),Js={menuShow:{opacity:1,y:0,transition:{type:"spring",stiffness:300,damping:24}},menuHide:{opacity:0,y:20,transition:{duration:.2}}},sn=n=>{const{icon:e,title:t,onClick:r}=n,{theme:o}=Ye(),{light:s,dark:i}=Ce.getTheme(o);return h.jsx(v.motion.div,{className:b.css`
|
|
2
2
|
&:hover {
|
|
3
3
|
background-color: ${s.contextMenuActiveColor};
|
|
4
4
|
@media (prefers-color-scheme: dark) {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
background-color: white;
|
|
38
38
|
padding: 0.25rem;
|
|
39
39
|
margin: 0;
|
|
40
|
-
`,children:[{label:"修改大小",key:"size",icon:h.jsx(
|
|
40
|
+
`,children:[{label:"修改大小",key:"size",icon:h.jsx(D.RiPencilRuler2Line,{size:14}),items:E().map(k=>({label:k,key:k,onClick:()=>{const[P,I]=k.split("x").map(Number);m(a.data.id,{row:P,col:I})}}))}].map(k=>h.jsxs(v.motion.li,{className:b.css`
|
|
41
41
|
padding-top: 0.5rem;
|
|
42
42
|
padding-bottom: 0.5rem;
|
|
43
43
|
padding-left: 0.75rem;
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
border-radius: 0.5rem;
|
|
95
95
|
overflow: hidden;
|
|
96
96
|
padding: 0.25rem;
|
|
97
|
-
`),children:[r&&h.jsx(sn,{icon:h.jsx(
|
|
97
|
+
`),children:[r&&h.jsx(sn,{icon:h.jsx(D.RiShareLine,{size:20}),title:"分享",onClick:()=>{if(i){i(a.data);return}}}),e&&h.jsx(sn,{icon:h.jsx(D.RiInformationLine,{size:20}),title:"信息",onClick:()=>{if(s){s(a.data);return}u({...a.data,pageX:a.pageX,pageY:a.pageY}),d()}}),t&&h.jsx(sn,{icon:h.jsx(D.RiCloseCircleLine,{size:20}),title:"移除",onClick:()=>{if(l){l(a.data,f);return}c(null),f(a.data.id)}})]})]})})},Us=n=>{const{data:e,noLetters:t=!1}=n,{contextMenuFuns:r}=lt(),{itemIconBuilder:o,theme:s,contextMenu:i}=Ye(),{light:l,dark:a}=Ce.getTheme(s),{data:c={}}=e,{name:d}=c;return h.jsxs(h.Fragment,{children:[h.jsx(v.motion.div,{className:b.css`
|
|
98
98
|
width: 4rem;
|
|
99
99
|
height: 4rem;
|
|
100
100
|
background-color: ${l.itemIconBackgroundColor};
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
padding: 0;
|
|
135
135
|
border: none;
|
|
136
136
|
}
|
|
137
|
-
`,overlay:h.jsx(Ks,{...u}),visible:(c==null?void 0:c.data.id)===e.id,onVisibleChange:f=>{f||d(null)},destroyTooltipOnHide:!0,children:h.jsx(v.motion.div,{"data-id":e.id,"data-index":r,"data-parent-ids":l==null?void 0:l.join(","),"data-children-length":a,onClick:()=>o==null?void 0:o(e),className:b.cx(s&&"drag-disabled",t),children:i??h.jsx(Us,{...n})})})},js=n=>{const{data:e,className:t,parentIds:r,itemIndex:o,onClick:s,noLetters:i=!1}=n,{contextMenuFuns:l,setList:a,setOpenGroupItemData:c,longPressTriggered:d,moveItemId:u,moveTargetId:f,setMoveTargetId:m,listStatus:p}=lt(),{itemIconBuilder:y,theme:g,contextMenu:x}=Ye(),{light:S,dark:E}=Ce.getTheme(g),{children:k,data:P,config:I}=e,{row:A=1,col:M=1}=I??{},T={visible:{opacity:1,scale:1},hidden:{opacity:0,scale:.95}},Q=((k==null?void 0:k.length)??0)===0,X=Q?[e]:[...k??[]].slice(0,9),Me=
|
|
137
|
+
`,overlay:h.jsx(Ks,{...u}),visible:(c==null?void 0:c.data.id)===e.id,onVisibleChange:f=>{f||d(null)},destroyTooltipOnHide:!0,children:h.jsx(v.motion.div,{"data-id":e.id,"data-index":r,"data-parent-ids":l==null?void 0:l.join(","),"data-children-length":a,onClick:()=>o==null?void 0:o(e),className:b.cx(s&&"drag-disabled",t),children:i??h.jsx(Us,{...n})})})},js=n=>{const{data:e,className:t,parentIds:r,itemIndex:o,onClick:s,noLetters:i=!1}=n,{contextMenuFuns:l,setList:a,setOpenGroupItemData:c,longPressTriggered:d,moveItemId:u,moveTargetId:f,setMoveTargetId:m,listStatus:p}=lt(),{itemIconBuilder:y,theme:g,contextMenu:x}=Ye(),{light:S,dark:E}=Ce.getTheme(g),{children:k,data:P,config:I}=e,{row:A=1,col:M=1}=I??{},T={visible:{opacity:1,scale:1},hidden:{opacity:0,scale:.95}},Q=((k==null?void 0:k.length)??0)===0,X=Q?[e]:[...k??[]].slice(0,9),Me=w.useMemo(()=>u===e.id.toString(),[e.id,u]),Le=w.useMemo(()=>f===e.id,[e.id,f]),F=b.css`
|
|
138
138
|
overflow: hidden;
|
|
139
139
|
cursor: pointer;
|
|
140
140
|
background-color: ${S.itemIconBackgroundColor};
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
border-radius: 0.375rem;
|
|
191
191
|
grid-column: span 2 / span 2;
|
|
192
192
|
grid-row: span 2 / span 2;
|
|
193
|
-
`),onClick:
|
|
193
|
+
`),onClick:ve=>{ge>2||(ve.stopPropagation(),s==null||s(W))},children:y==null?void 0:y(W)},W.id))});if(A===2&&M===1)return h.jsx(v.motion.div,{className:b.css`
|
|
194
194
|
display: grid;
|
|
195
195
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
196
196
|
grid-template-rows: repeat(10, minmax(0, 1fr));
|
|
@@ -210,10 +210,10 @@
|
|
|
210
210
|
height: 1.5rem;
|
|
211
211
|
grid-column: span 2 / span 2;
|
|
212
212
|
grid-row: span 2 / span 2;
|
|
213
|
-
`),onClick:
|
|
213
|
+
`),onClick:ve=>{ge>2||(ve.stopPropagation(),s==null||s(W))},children:y==null?void 0:y(W)},W.id))})};return h.jsxs(ln,{data:e,itemIndex:o,parentIds:r,childrenLength:k==null?void 0:k.length,className:b.cx(b.css`
|
|
214
214
|
grid-row: span ${A};
|
|
215
215
|
grid-column: span ${M};
|
|
216
|
-
`,t),children:[h.jsx(v.motion.div,{whileTap:{scale:.9},className:b.cx(
|
|
216
|
+
`,t),children:[h.jsx(v.motion.div,{whileTap:{scale:.9},className:b.cx(Le?"!scale-110":"",b.css`
|
|
217
217
|
cursor: pointer;
|
|
218
218
|
position: relative;
|
|
219
219
|
border-radius: 0.75rem;
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
transition: all 0.2s;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
`,Xs=n=>{const{data:e,onClose:t,onItemClick:r}=n,{list:o,setList:s,setListStatus:i,setMoveItemId:l,setMoveTargetId:a,updateItem:c}=lt(),{theme:d}=Ye(),{light:u,dark:f}=Ce.getTheme(d),[m,p]=
|
|
272
|
+
`,Xs=n=>{const{data:e,onClose:t,onItemClick:r}=n,{list:o,setList:s,setListStatus:i,setMoveItemId:l,setMoveTargetId:a,updateItem:c}=lt(),{theme:d}=Ye(),{light:u,dark:f}=Ce.getTheme(d),[m,p]=w.useState("文件夹"),y=[...(e==null?void 0:e.children)??[]];return w.useEffect(()=>{var g;e&&p((g=e.data)==null?void 0:g.name)},[e]),h.jsx(Rn,{visible:!!e,onClose:()=>{t()},animation:"zoom",maskAnimation:"fade",mousePosition:e!=null&&e.pageX&&(e!=null&&e.pageY)?{x:e==null?void 0:e.pageX,y:e==null?void 0:e.pageY}:null,title:h.jsx("input",{className:b.css`
|
|
273
273
|
background-color: transparent;
|
|
274
274
|
border-style: none;
|
|
275
275
|
text-align: center;
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
grid-template-columns: repeat(auto-fill, 96px);
|
|
317
317
|
grid-auto-flow: dense;
|
|
318
318
|
grid-auto-rows: 96px;
|
|
319
|
-
`,group:{name:"nested",pull:!0,put:!1},animation:150,fallbackOnBody:!0,list:(e==null?void 0:e.children)??[],setList:g=>{var E,k;const x=g.map(P=>P.id),S=(k=(E=o.find(P=>P.id===(e==null?void 0:e.id)))==null?void 0:E.children)==null?void 0:k.map(P=>P.id);x.length===(S==null?void 0:S.length)&&x.every((P,I)=>P===S[I])||x.length<((S==null?void 0:S.length)??0)||s(g,[...(e==null?void 0:e.parentIds)??[],e==null?void 0:e.id])},onMove:()=>(a(null),i("onMove"),!0),onStart:g=>{const x=g.item.dataset;x!=null&&x.id&&l(x.id),i("onMove")},onEnd:()=>{l(null),a(null),i(null)},ghostClass:cr,children:y.map((g,x)=>h.jsx(ln,{data:g,itemIndex:x,onClick:r},g.id))})})})},Ys=n=>{var r;const{data:e,onClose:t}=n;return h.jsx(Rn,{visible:!!e,onClose:()=>{t()},animation:"zoom",maskAnimation:"fade",mousePosition:e!=null&&e.pageX&&(e!=null&&e.pageY)?{x:e==null?void 0:e.pageX,y:e==null?void 0:e.pageY}:null,footer:null,title:((r=e==null?void 0:e.data)==null?void 0:r.name)??"信息",children:e&&h.jsxs("div",{children:[h.jsx("div",{className:"mb-2",children:"开发者信息"}),h.jsx("div",{className:"p-2 rounded-md bg-[#272822]",children:h.jsx(xs,{src:e,theme:"monokai"})})]})})},Gs=n=>{const{pagination:e={position:"bottom"},className:t,sliderProps:r,sliderRef:o,onItemClick:s}=n,i=
|
|
319
|
+
`,group:{name:"nested",pull:!0,put:!1},animation:150,fallbackOnBody:!0,list:(e==null?void 0:e.children)??[],setList:g=>{var E,k;const x=g.map(P=>P.id),S=(k=(E=o.find(P=>P.id===(e==null?void 0:e.id)))==null?void 0:E.children)==null?void 0:k.map(P=>P.id);x.length===(S==null?void 0:S.length)&&x.every((P,I)=>P===S[I])||x.length<((S==null?void 0:S.length)??0)||s(g,[...(e==null?void 0:e.parentIds)??[],e==null?void 0:e.id])},onMove:()=>(a(null),i("onMove"),!0),onStart:g=>{const x=g.item.dataset;x!=null&&x.id&&l(x.id),i("onMove")},onEnd:()=>{l(null),a(null),i(null)},ghostClass:cr,children:y.map((g,x)=>h.jsx(ln,{data:g,itemIndex:x,onClick:r},g.id))})})})},Ys=n=>{var r;const{data:e,onClose:t}=n;return h.jsx(Rn,{visible:!!e,onClose:()=>{t()},animation:"zoom",maskAnimation:"fade",mousePosition:e!=null&&e.pageX&&(e!=null&&e.pageY)?{x:e==null?void 0:e.pageX,y:e==null?void 0:e.pageY}:null,footer:null,title:((r=e==null?void 0:e.data)==null?void 0:r.name)??"信息",children:e&&h.jsxs("div",{children:[h.jsx("div",{className:"mb-2",children:"开发者信息"}),h.jsx("div",{className:"p-2 rounded-md bg-[#272822]",children:h.jsx(xs,{src:e,theme:"monokai"})})]})})},Gs=n=>{const{pagination:e={position:"bottom"},className:t,sliderProps:r,sliderRef:o,onItemClick:s}=n,i=w.useRef(null),l=w.useRef(null),{list:a,setList:c,setListStatus:d,showInfoItemData:u,setShowInfoItemData:f,openGroupItemData:m,setOpenGroupItemData:p,setMoveItemId:y,setMoveTargetId:g,addItem:x}=lt();console.log("🚀 ~ list:",a);const{pagingDotBuilder:S,pagingDotsBuilder:E,itemBuilder:k}=Ye(),P=w.useMemo(()=>e===!1?{}:{top:b.css`
|
|
320
320
|
display: flex;
|
|
321
321
|
flex-direction: column;
|
|
322
322
|
.slick-list {
|
|
@@ -402,7 +402,7 @@
|
|
|
402
402
|
place-items: center;
|
|
403
403
|
justify-content: center;
|
|
404
404
|
align-items: center;
|
|
405
|
-
`),animation:150,fallbackOnBody:!0,swapThreshold:.65,group:"nested",list:I.children??[],setList:A=>c(A,[I.id]),filter:".drag-disabled",onMove:A=>{d("onMove");const{dragged:M,related:T}=A,Q=M.dataset,X=T.dataset;return g(null),!((Object.keys(X).length===0||X.parentIds)&&Number(Q.childrenLength)>0&&T.classList.contains("sortable-group-item"))},onStart:A=>{const M=A.item.dataset;M!=null&&M.id&&y(M.id),d("onMove")},onEnd:()=>{y(null),g(null),d(null)},ghostClass:cr,children:(I.children??[]).map((A,M)=>{let T;if(k)return k(A);switch(A.type){case"group":case"app":T=h.jsx(js,{data:A,itemIndex:M,parentIds:[I.id,A.id],onClick:s},A.id);break;default:T=h.jsx(ln,{data:A,itemIndex:M,onClick:s},A.id);break}return T})})},I.id))}),h.jsx(Ys,{data:u,onClose:()=>{f(null)}}),h.jsx(Xs,{data:m,onClose:()=>{p(null)},onItemClick:s})]})},_s=n=>{const{
|
|
405
|
+
`),animation:150,fallbackOnBody:!0,swapThreshold:.65,group:"nested",list:I.children??[],setList:A=>c(A,[I.id]),filter:".drag-disabled",onMove:A=>{d("onMove");const{dragged:M,related:T}=A,Q=M.dataset,X=T.dataset;return g(null),!((Object.keys(X).length===0||X.parentIds)&&Number(Q.childrenLength)>0&&T.classList.contains("sortable-group-item"))},onStart:A=>{const M=A.item.dataset;M!=null&&M.id&&y(M.id),d("onMove")},onEnd:()=>{y(null),g(null),d(null)},ghostClass:cr,children:(I.children??[]).map((A,M)=>{let T;if(k)return k(A);switch(A.type){case"group":case"app":T=h.jsx(js,{data:A,itemIndex:M,parentIds:[I.id,A.id],onClick:s},A.id);break;default:T=h.jsx(ln,{data:A,itemIndex:M,onClick:s},A.id);break}return T})})},I.id))}),h.jsx(Ys,{data:u,onClose:()=>{f(null)}}),h.jsx(Xs,{data:m,onClose:()=>{p(null)},onItemClick:s})]})},_s=n=>{const{list:e,onChange:t,storageKey:r,enableCaching:o,theme:s,noLetters:i,contextMenu:l,contextMenuBuilder:a,itemBuilder:c,itemIconBuilder:d,pagingDotBuilder:u,pagingDotsBuilder:f,...m}=n,p={list:e,onChange:t,storageKey:r,enableCaching:o},y={theme:s,noLetters:i,contextMenu:l,pagingDotsBuilder:f,pagingDotBuilder:u,itemBuilder:c,itemIconBuilder:d,contextMenuBuilder:a};return h.jsx(Ws,{...p,children:h.jsx(qs,{...y,children:h.jsx(Gs,{...m})})})},Zs={frontmatterEditor:{title:"编辑前置元数据",key:"键",value:"值",addEntry:"添加项目"},dialogControls:{save:"保存",cancel:"取消"},uploadImage:{uploadInstructions:"从您的设备中上传图片:",addViaUrlInstructions:"或从网址新增图片:",autoCompletePlaceholder:"选择或粘贴图片",alt:"替代文本:",title:"标题:"},imageEditor:{editImage:"编辑图片"},createLink:{url:"网址",urlPlaceholder:"选择或粘贴网址",title:"标题",saveTooltip:"设置网址",cancelTooltip:"取消更改"},linkPreview:{open:"在新窗口中打开 {{url}}",edit:"编辑链接网址",copyToClipboard:"复制到剪贴板",copied:"已复制!",remove:"移除链接"},table:{deleteTable:"删除表格",columnMenu:"列菜单",textAlignment:"文字对齐",alignLeft:"左对齐",alignCenter:"居中对齐",alignRight:"右对齐",insertColumnLeft:"在当前列左侧插入一列",insertColumnRight:"在当前列右侧插入一列",deleteColumn:"删除此列",rowMenu:"行菜单",insertRowAbove:"在当前行上方插入一行",insertRowBelow:"在当前行下方插入一行",deleteRow:"删除此行"},toolbar:{blockTypes:{paragraph:"段落",quote:"引用",heading:"标题 {{level}}"},blockTypeSelect:{selectBlockTypeTooltip:"选择块类型",placeholder:"块类型"},toggleGroup:"切换组",removeBold:"移除粗体",bold:"粗体",removeItalic:"移除斜体",italic:"斜体",underline:"移除下划线",removeUnderline:"下划线",removeInlineCode:"移除内联代码样式",inlineCode:"内联代码样式",link:"创建链接",richText:"富文本",diffMode:"差异模式",source:"源码模式",admonition:"插入注释区块",codeBlock:"插入代码块",editFrontmatter:"编辑前置元数据",insertFrontmatter:"插入前置元数据",image:"插入图片",insertSandpack:"插入 Sandpack",table:"插入表格",thematicBreak:"插入主题换行",bulletedList:"无序列表",numberedList:"有序列表",checkList:"任务列表",deleteSandpack:"删除 Sandpack",undo:"撤销 {{shortcut}}",redo:"重做 {{shortcut}}",superscript:"上标",subscript:"下标",strikethrough:"删除线",removeSubscript:"移除下标",removeSuperscript:"移除上标",removeStrikethrough:"移除删除线"},admonitions:{note:"注意",tip:"提示",danger:"危险",info:"信息",caution:"警告",changeType:"选择注释区块类型",placeholder:"注释区块类型"},codeBlock:{language:"代码块语言",selectLanguage:"选择代码块语言",inlineLanguage:"代码块语言"},codeblock:{delete:"删除代码块"},contentArea:{editableMarkdown:"可编辑的 Markdown"},image:{delete:"删除图片"}},Qs=(n,e,t)=>{const o=n.split(".").reduce((s,i)=>typeof s=="string"?s:s[i],Zs);return typeof o!="string"?e:t?o.replace(/{{(.*?)}}/g,(s,i)=>t[i]):o},Rs=b.css`
|
|
406
406
|
--accentBase: var(--tomato-1);
|
|
407
407
|
--accentBgSubtle: var(--tomato-2);
|
|
408
408
|
--accentBg: var(--tomato-3);
|
|
@@ -656,21 +656,21 @@
|
|
|
656
656
|
--color-prettylights-syntax-meta-diff-range: #d2a8ff;
|
|
657
657
|
--color-prettylights-syntax-sublimelinter-gutter-mark: #3d444d;
|
|
658
658
|
}
|
|
659
|
-
`,an=n=>{var e,t;return n==="dark"?!0:n==="light"?!1:(e=document.documentElement.getAttribute("style"))!=null&&e.includes("color-scheme: dark;")?!0:(t=document.documentElement.getAttribute("style"))!=null&&t.includes("color-scheme: light;")?!1:window.matchMedia("(prefers-color-scheme: dark)").matches},ti=n=>{const{value:e,onChange:t,translation:r,pluginConfig:o,className:s,theme:i="auto",...l}=n,a=D.useRef(null),{image:c,diffSource:d={viewMode:"rich-text"},headings:u,link:f,codeBlock:m,codeMirror:p={codeBlockLanguages:{js:"JavaScript",css:"CSS",txt:"Plain Text",tsx:"TypeScript","":"Unspecified"}},directives:y={directiveDescriptors:[B.AdmonitionDirectiveDescriptor]}}=o??{},[g,x]=D.useState("");return D.useEffect(()=>{var S;e!==void 0&&a.current&&((S=a.current)==null||S.setMarkdown(e),x(e))},[e,a]),h.jsx(B.MDXEditor,{ref:a,className:b.cx(ei,an(i)?Rs:"",an(i)?ur:hr,s),contentEditableClassName:dr,markdown:g,onChange:S=>{!e&&!t&&x(S),t&&t(S)},translation:r??Qs,plugins:[B.toolbarPlugin({toolbarContents:()=>h.jsxs(B.DiffSourceToggleWrapper,{options:["rich-text","source"],children:[h.jsx(B.UndoRedo,{}),h.jsx(B.Separator,{}),h.jsx(B.BoldItalicUnderlineToggles,{}),h.jsx(B.CodeToggle,{}),h.jsx(B.Separator,{}),h.jsx(B.StrikeThroughSupSubToggles,{}),h.jsx(B.Separator,{}),h.jsx(B.ListsToggle,{}),h.jsx(B.Separator,{}),h.jsx(B.CreateLink,{}),h.jsx(B.InsertImage,{}),h.jsx(B.Separator,{}),h.jsx(B.InsertTable,{}),h.jsx(B.InsertThematicBreak,{}),h.jsx(B.Separator,{}),h.jsx(B.InsertCodeBlock,{}),h.jsx(B.Separator,{}),h.jsx(B.InsertFrontmatter,{})]})}),B.diffSourcePlugin(d),B.listsPlugin(),B.quotePlugin(),B.headingsPlugin(u),B.linkPlugin(f),B.linkDialogPlugin(),B.imagePlugin(c),B.tablePlugin(),B.thematicBreakPlugin(),B.frontmatterPlugin(),B.codeBlockPlugin(m),B.codeMirrorPlugin(p),B.markdownShortcutPlugin(),B.directivesPlugin(y)],...l})},ni={'code[class*="language-"]':{background:"hsl(230, 1%, 98%)",color:"hsl(230, 8%, 24%)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(230, 1%, 98%)",color:"hsl(230, 8%, 24%)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"] *::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"]::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"] *::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'pre[class*="language-"] *::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},prolog:{color:"hsl(230, 4%, 64%)"},cdata:{color:"hsl(230, 4%, 64%)"},doctype:{color:"hsl(230, 8%, 24%)"},punctuation:{color:"hsl(230, 8%, 24%)"},entity:{color:"hsl(230, 8%, 24%)",cursor:"help"},"attr-name":{color:"hsl(35, 99%, 36%)"},"class-name":{color:"hsl(35, 99%, 36%)"},boolean:{color:"hsl(35, 99%, 36%)"},constant:{color:"hsl(35, 99%, 36%)"},number:{color:"hsl(35, 99%, 36%)"},atrule:{color:"hsl(35, 99%, 36%)"},keyword:{color:"hsl(301, 63%, 40%)"},property:{color:"hsl(5, 74%, 59%)"},tag:{color:"hsl(5, 74%, 59%)"},symbol:{color:"hsl(5, 74%, 59%)"},deleted:{color:"hsl(5, 74%, 59%)"},important:{color:"hsl(5, 74%, 59%)"},selector:{color:"hsl(119, 34%, 47%)"},string:{color:"hsl(119, 34%, 47%)"},char:{color:"hsl(119, 34%, 47%)"},builtin:{color:"hsl(119, 34%, 47%)"},inserted:{color:"hsl(119, 34%, 47%)"},regex:{color:"hsl(119, 34%, 47%)"},"attr-value":{color:"hsl(119, 34%, 47%)"},"attr-value > .token.punctuation":{color:"hsl(119, 34%, 47%)"},variable:{color:"hsl(221, 87%, 60%)"},operator:{color:"hsl(221, 87%, 60%)"},function:{color:"hsl(221, 87%, 60%)"},url:{color:"hsl(198, 99%, 37%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(230, 8%, 24%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(230, 8%, 24%)"},".language-css .token.selector":{color:"hsl(5, 74%, 59%)"},".language-css .token.property":{color:"hsl(230, 8%, 24%)"},".language-css .token.function":{color:"hsl(198, 99%, 37%)"},".language-css .token.url > .token.function":{color:"hsl(198, 99%, 37%)"},".language-css .token.url > .token.string.url":{color:"hsl(119, 34%, 47%)"},".language-css .token.important":{color:"hsl(301, 63%, 40%)"},".language-css .token.atrule .token.rule":{color:"hsl(301, 63%, 40%)"},".language-javascript .token.operator":{color:"hsl(301, 63%, 40%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(344, 84%, 43%)"},".language-json .token.operator":{color:"hsl(230, 8%, 24%)"},".language-json .token.null.keyword":{color:"hsl(35, 99%, 36%)"},".language-markdown .token.url":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url > .token.operator":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url > .token.content":{color:"hsl(221, 87%, 60%)"},".language-markdown .token.url > .token.url":{color:"hsl(198, 99%, 37%)"},".language-markdown .token.url-reference.url":{color:"hsl(198, 99%, 37%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(119, 34%, 47%)"},".language-markdown .token.bold .token.content":{color:"hsl(35, 99%, 36%)"},".language-markdown .token.italic .token.content":{color:"hsl(301, 63%, 40%)"},".language-markdown .token.strike .token.content":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.list.punctuation":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(5, 74%, 59%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.cr:before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.lf:before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.space:before":{color:"hsla(230, 8%, 24%, 0.2)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},".line-highlight.line-highlight":{background:"hsla(230, 8%, 24%, 0.05)"},".line-highlight.line-highlight:before":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 8%, 24%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 8%, 24%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(230, 8%, 24%, 0.05)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(230, 8%, 24%, 0.2)"},".command-line .command-line-prompt":{borderRightColor:"hsla(230, 8%, 24%, 0.2)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(230, 1%, 62%)"},".command-line .command-line-prompt > span:before":{color:"hsl(230, 1%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(301, 63%, 40%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(301, 63%, 40%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(301, 63%, 40%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(0, 0, 95%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(0, 0, 95%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(0, 0, 95%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(0, 0, 95%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(0, 0%, 100%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(0, 0%, 100%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(0, 0%, 100%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(230, 8%, 24%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(230, 8%, 24%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(230, 8%, 24%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(230, 8%, 24%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(230, 8%, 24%)"}},fr=n=>{const{children:e="",className:t,theme:r="auto",imageProps:o}=n;return h.jsx("div",{className:an(r)?ur:hr,children:h.jsx(er,{className:b.cx(dr,t),remarkPlugins:[ks,Ss],rehypePlugins:[Cs],components:{code(s){const{children:i,className:l,node:a,ref:c,...d}=s,u=/language-(\w+)/.exec(l||"");return u?h.jsx(Ns.Prism,{...d,PreTag:"div",children:String(i).replace(/\n$/,""),language:u[1],style:ni}):h.jsx("code",{...d,className:l,children:i})},img(s){const{preview:i,...l}=o??{};return h.jsx(ws,{...s,preview:i instanceof Boolean?i:{icons:{rotateLeft:h.jsx(w.RiAnticlockwise2Line,{}),rotateRight:h.jsx(w.RiClockwise2Line,{}),zoomIn:h.jsx(w.RiZoomInLine,{}),zoomOut:h.jsx(w.RiZoomOutLine,{}),close:h.jsx(w.RiCloseLine,{}),left:h.jsx(w.RiArrowLeftLine,{}),right:h.jsx(w.RiArrowRightLine,{}),flipX:h.jsx(w.RiArrowLeftRightLine,{}),flipY:h.jsx(w.RiArrowUpDownLine,{})},zIndex:9999,mask:" ",...i},className:b.css`
|
|
659
|
+
`,an=n=>{var e,t;return n==="dark"?!0:n==="light"?!1:(e=document.documentElement.getAttribute("style"))!=null&&e.includes("color-scheme: dark;")?!0:(t=document.documentElement.getAttribute("style"))!=null&&t.includes("color-scheme: light;")?!1:window.matchMedia("(prefers-color-scheme: dark)").matches},ti=n=>{const{value:e,onChange:t,translation:r,pluginConfig:o,className:s,theme:i="auto",...l}=n,a=w.useRef(null),{image:c,diffSource:d={viewMode:"rich-text"},headings:u,link:f,codeBlock:m,codeMirror:p={codeBlockLanguages:{js:"JavaScript",css:"CSS",txt:"Plain Text",tsx:"TypeScript","":"Unspecified"}},directives:y={directiveDescriptors:[B.AdmonitionDirectiveDescriptor]}}=o??{},[g,x]=w.useState("");return w.useEffect(()=>{var S;e!==void 0&&a.current&&((S=a.current)==null||S.setMarkdown(e),x(e))},[e,a]),h.jsx(B.MDXEditor,{ref:a,className:b.cx(ei,an(i)?Rs:"",an(i)?ur:hr,s),contentEditableClassName:dr,markdown:g,onChange:S=>{!e&&!t&&x(S),t&&t(S)},translation:r??Qs,plugins:[B.toolbarPlugin({toolbarContents:()=>h.jsxs(B.DiffSourceToggleWrapper,{options:["rich-text","source"],children:[h.jsx(B.UndoRedo,{}),h.jsx(B.Separator,{}),h.jsx(B.BoldItalicUnderlineToggles,{}),h.jsx(B.CodeToggle,{}),h.jsx(B.Separator,{}),h.jsx(B.StrikeThroughSupSubToggles,{}),h.jsx(B.Separator,{}),h.jsx(B.ListsToggle,{}),h.jsx(B.Separator,{}),h.jsx(B.CreateLink,{}),h.jsx(B.InsertImage,{}),h.jsx(B.Separator,{}),h.jsx(B.InsertTable,{}),h.jsx(B.InsertThematicBreak,{}),h.jsx(B.Separator,{}),h.jsx(B.InsertCodeBlock,{}),h.jsx(B.Separator,{}),h.jsx(B.InsertFrontmatter,{})]})}),B.diffSourcePlugin(d),B.listsPlugin(),B.quotePlugin(),B.headingsPlugin(u),B.linkPlugin(f),B.linkDialogPlugin(),B.imagePlugin(c),B.tablePlugin(),B.thematicBreakPlugin(),B.frontmatterPlugin(),B.codeBlockPlugin(m),B.codeMirrorPlugin(p),B.markdownShortcutPlugin(),B.directivesPlugin(y)],...l})},ni={'code[class*="language-"]':{background:"hsl(230, 1%, 98%)",color:"hsl(230, 8%, 24%)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(230, 1%, 98%)",color:"hsl(230, 8%, 24%)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"] *::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"]::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'code[class*="language-"] *::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},'pre[class*="language-"] *::selection':{background:"hsl(230, 1%, 90%)",color:"inherit"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},prolog:{color:"hsl(230, 4%, 64%)"},cdata:{color:"hsl(230, 4%, 64%)"},doctype:{color:"hsl(230, 8%, 24%)"},punctuation:{color:"hsl(230, 8%, 24%)"},entity:{color:"hsl(230, 8%, 24%)",cursor:"help"},"attr-name":{color:"hsl(35, 99%, 36%)"},"class-name":{color:"hsl(35, 99%, 36%)"},boolean:{color:"hsl(35, 99%, 36%)"},constant:{color:"hsl(35, 99%, 36%)"},number:{color:"hsl(35, 99%, 36%)"},atrule:{color:"hsl(35, 99%, 36%)"},keyword:{color:"hsl(301, 63%, 40%)"},property:{color:"hsl(5, 74%, 59%)"},tag:{color:"hsl(5, 74%, 59%)"},symbol:{color:"hsl(5, 74%, 59%)"},deleted:{color:"hsl(5, 74%, 59%)"},important:{color:"hsl(5, 74%, 59%)"},selector:{color:"hsl(119, 34%, 47%)"},string:{color:"hsl(119, 34%, 47%)"},char:{color:"hsl(119, 34%, 47%)"},builtin:{color:"hsl(119, 34%, 47%)"},inserted:{color:"hsl(119, 34%, 47%)"},regex:{color:"hsl(119, 34%, 47%)"},"attr-value":{color:"hsl(119, 34%, 47%)"},"attr-value > .token.punctuation":{color:"hsl(119, 34%, 47%)"},variable:{color:"hsl(221, 87%, 60%)"},operator:{color:"hsl(221, 87%, 60%)"},function:{color:"hsl(221, 87%, 60%)"},url:{color:"hsl(198, 99%, 37%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(230, 8%, 24%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(230, 8%, 24%)"},".language-css .token.selector":{color:"hsl(5, 74%, 59%)"},".language-css .token.property":{color:"hsl(230, 8%, 24%)"},".language-css .token.function":{color:"hsl(198, 99%, 37%)"},".language-css .token.url > .token.function":{color:"hsl(198, 99%, 37%)"},".language-css .token.url > .token.string.url":{color:"hsl(119, 34%, 47%)"},".language-css .token.important":{color:"hsl(301, 63%, 40%)"},".language-css .token.atrule .token.rule":{color:"hsl(301, 63%, 40%)"},".language-javascript .token.operator":{color:"hsl(301, 63%, 40%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(344, 84%, 43%)"},".language-json .token.operator":{color:"hsl(230, 8%, 24%)"},".language-json .token.null.keyword":{color:"hsl(35, 99%, 36%)"},".language-markdown .token.url":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url > .token.operator":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(230, 8%, 24%)"},".language-markdown .token.url > .token.content":{color:"hsl(221, 87%, 60%)"},".language-markdown .token.url > .token.url":{color:"hsl(198, 99%, 37%)"},".language-markdown .token.url-reference.url":{color:"hsl(198, 99%, 37%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(230, 4%, 64%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(119, 34%, 47%)"},".language-markdown .token.bold .token.content":{color:"hsl(35, 99%, 36%)"},".language-markdown .token.italic .token.content":{color:"hsl(301, 63%, 40%)"},".language-markdown .token.strike .token.content":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.list.punctuation":{color:"hsl(5, 74%, 59%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(5, 74%, 59%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.cr:before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.lf:before":{color:"hsla(230, 8%, 24%, 0.2)"},"token.space:before":{color:"hsla(230, 8%, 24%, 0.2)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 6%, 44%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(230, 1%, 78%)",color:"hsl(230, 8%, 24%)"},".line-highlight.line-highlight":{background:"hsla(230, 8%, 24%, 0.05)"},".line-highlight.line-highlight:before":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 8%, 24%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(230, 1%, 90%)",color:"hsl(230, 8%, 24%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(230, 8%, 24%, 0.05)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(230, 8%, 24%, 0.2)"},".command-line .command-line-prompt":{borderRightColor:"hsla(230, 8%, 24%, 0.2)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(230, 1%, 62%)"},".command-line .command-line-prompt > span:before":{color:"hsl(230, 1%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(5, 74%, 59%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(119, 34%, 47%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(221, 87%, 60%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(301, 63%, 40%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(301, 63%, 40%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(301, 63%, 40%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(0, 0, 95%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(0, 0, 95%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(0, 0, 95%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(0, 0, 95%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(0, 0%, 100%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(0, 0%, 100%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(0, 0%, 100%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(230, 8%, 24%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(230, 8%, 24%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(230, 8%, 24%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(230, 8%, 24%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(230, 8%, 24%)"}},fr=n=>{const{children:e="",className:t,theme:r="auto",imageProps:o}=n;return h.jsx("div",{className:an(r)?ur:hr,children:h.jsx(er,{className:b.cx(dr,t),remarkPlugins:[ks,Ss],rehypePlugins:[Cs],components:{code(s){const{children:i,className:l,node:a,ref:c,...d}=s,u=/language-(\w+)/.exec(l||"");return u?h.jsx(Ns.Prism,{...d,PreTag:"div",children:String(i).replace(/\n$/,""),language:u[1],style:ni}):h.jsx("code",{...d,className:l,children:i})},img(s){const{preview:i,...l}=o??{};return h.jsx(ws,{...s,preview:i instanceof Boolean?i:{icons:{rotateLeft:h.jsx(D.RiAnticlockwise2Line,{}),rotateRight:h.jsx(D.RiClockwise2Line,{}),zoomIn:h.jsx(D.RiZoomInLine,{}),zoomOut:h.jsx(D.RiZoomOutLine,{}),close:h.jsx(D.RiCloseLine,{}),left:h.jsx(D.RiArrowLeftLine,{}),right:h.jsx(D.RiArrowRightLine,{}),flipX:h.jsx(D.RiArrowLeftRightLine,{}),flipY:h.jsx(D.RiArrowUpDownLine,{})},zIndex:9999,mask:" ",...i},className:b.css`
|
|
660
660
|
cursor: zoom-in;
|
|
661
|
-
`,...l})}},children:e})})},pr=ti;pr.Preview=fr;function mr(...n){return Ts.twMerge(Ds.clsx(n))}const ri=n=>{const{mouseX:e,title:t,icon:r,href:o}=n,s=D.useRef(null),i=v.useTransform(e,x=>{var E;const S=((E=s.current)==null?void 0:E.getBoundingClientRect())??{x:0,width:0};return x-S.x-S.width/2}),l=v.useTransform(i,[-150,0,150],[40,80,40]),a=v.useTransform(i,[-150,0,150],[40,80,40]),c=v.useTransform(i,[-150,0,150],[20,40,20]),d=v.useTransform(i,[-150,0,150],[20,40,20]),u=v.useSpring(l,{mass:.1,stiffness:150,damping:12}),f=v.useSpring(a,{mass:.1,stiffness:150,damping:12}),m=v.useSpring(c,{mass:.1,stiffness:150,damping:12}),p=v.useSpring(d,{mass:.1,stiffness:150,damping:12}),[y,g]=D.useState(!1);return h.jsx("a",{href:o,children:h.jsxs(v.motion.div,{ref:s,style:{width:u,height:f},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"aspect-square rounded-full bg-gray-200 dark:bg-neutral-800 flex items-center justify-center relative",children:[h.jsx(v.AnimatePresence,{children:y&&h.jsx(v.motion.div,{initial:{opacity:0,y:10,x:"-50%"},animate:{opacity:1,y:0,x:"-50%"},exit:{opacity:0,y:2,x:"-50%"},className:"px-2 py-0.5 whitespace-pre rounded-md bg-gray-100 border dark:bg-neutral-800 dark:border-neutral-900 dark:text-white border-gray-200 text-neutral-700 absolute left-1/2 -translate-x-1/2 -top-8 w-fit text-xs",children:t})}),h.jsx(v.motion.div,{style:{width:m,height:p},className:"flex items-center justify-center",children:r})]})})},gr=n=>{const{items:e,className:t}=n,r=v.useMotionValue(1/0);return h.jsx(v.motion.div,{onMouseMove:o=>r.set(o.pageX),onMouseLeave:()=>r.set(1/0),className:mr("mx-auto hidden md:flex h-16 gap-4 items-end rounded-2xl bg-gray-50 dark:bg-neutral-900 px-4 pb-3",t),children:e.map(o=>h.jsx(ri,{mouseX:r,...o},o.title))})},yr=n=>{const{items:e,className:t,collapseIcon:r,autoHidden:o=!1}=n,[s,i]=D.useState(!1),l=()=>{i(!s)};return h.jsxs("div",{className:mr("relative block",o?"md:hidden":"",t),children:[h.jsx(v.AnimatePresence,{children:s&&h.jsx(v.motion.div,{layoutId:"nav",className:"absolute bottom-full mb-2 inset-x-0 flex flex-col gap-2",children:e.map((a,c)=>h.jsx(v.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10,transition:{delay:c*.05}},transition:{delay:(e.length-1-c)*.05},children:h.jsx("a",{href:a.href,className:"h-10 w-10 rounded-full bg-gray-50 dark:bg-neutral-900 flex items-center justify-center",children:h.jsx("div",{className:"h-4 w-4",children:a.icon})},a.title)},a.title))})}),h.jsx("button",{onClick:l,className:"h-10 w-10 rounded-full bg-gray-50 dark:bg-neutral-800 flex items-center justify-center",children:r||h.jsx(w.RiMoreLine,{className:"h-5 w-5 text-neutral-500 dark:text-neutral-400"})})]})},cn=n=>{const{items:e,desktopClassName:t,mobileClassName:r,...o}=n;return h.jsxs(h.Fragment,{children:[h.jsx(gr,{items:e,className:t,...o}),h.jsx(yr,{items:e,className:r,autoHidden:!0,...o})]})};cn.Desktop=gr,cn.Mobile=yr;function br(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=br(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function xr(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=xr(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class z{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new z(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new z(r,o)}cutByIndex(e,t){return e==t?z.empty:e==0&&t==this.content.length?this:new z(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new z(o,s)}addToStart(e){return new z([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new z(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return br(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return xr(this,e,t,r)}findIndex(e,t=-1){if(e==0)return $t(0,e);if(e==this.size)return $t(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?$t(r+1,i):$t(r,o);o=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return z.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new z(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return z.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new z(t||e,r)}static from(e){if(!e)return z.empty;if(e instanceof z)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new z([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}z.empty=new z([],0);const dn={index:0,offset:0};function $t(n,e){return dn.index=n,dn.offset=e,dn}function hn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!hn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!hn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class pe{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return pe.none;if(e instanceof pe)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}pe.none=[];class oi extends Error{}class L{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Sr(this.content,e+this.openStart,t);return r&&new L(r,this.openStart,this.openEnd)}removeBetween(e,t){return new L(kr(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 L.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new L(z.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new L(e,r,o)}}L.empty=new L(z.empty,0,0);function kr(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(kr(s.content,e-o-1,t-o-1)))}function Sr(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Sr(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function si(n){return n.tag!=null}function ii(n){return n.style!=null}let Cr=class Gn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(si(o))this.tags.push(o);else if(ii(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Tr(this,t,!1);return r.addAll(e,pe.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Tr(this,t,!0);return r.addAll(e,pe.none,t.from,t.to),L.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(ci(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Or(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Or(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Gn(e,Gn.schemaRules(e)))}};const Nr={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},li={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wr={ol:!0,ul:!0},St=1,un=2,qt=4;function Dr(n,e,t){return e!=null?(e?St:0)|(e==="full"?un:0):n&&n.whitespace=="pre"?St|un:t&-5}class Ht{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=pe.none,this.match=s||(i&qt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&St)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(z.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&&!Nr.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Tr{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=Dr(null,t.preserveWhitespace,0)|(r?qt:0);o?s=new Ht(o.type,o.attrs,pe.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Ht(null,null,pe.none,!0,null,i):s=new Ht(e.schema.topNodeType,null,pe.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&un?"full":this.localPreserveWS||(o.options&St)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
661
|
+
`,...l})}},children:e})})},pr=ti;pr.Preview=fr;function mr(...n){return Ts.twMerge(Ds.clsx(n))}const ri=n=>{const{mouseX:e,title:t,icon:r,href:o}=n,s=w.useRef(null),i=v.useTransform(e,x=>{var E;const S=((E=s.current)==null?void 0:E.getBoundingClientRect())??{x:0,width:0};return x-S.x-S.width/2}),l=v.useTransform(i,[-150,0,150],[40,80,40]),a=v.useTransform(i,[-150,0,150],[40,80,40]),c=v.useTransform(i,[-150,0,150],[20,40,20]),d=v.useTransform(i,[-150,0,150],[20,40,20]),u=v.useSpring(l,{mass:.1,stiffness:150,damping:12}),f=v.useSpring(a,{mass:.1,stiffness:150,damping:12}),m=v.useSpring(c,{mass:.1,stiffness:150,damping:12}),p=v.useSpring(d,{mass:.1,stiffness:150,damping:12}),[y,g]=w.useState(!1);return h.jsx("a",{href:o,children:h.jsxs(v.motion.div,{ref:s,style:{width:u,height:f},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"aspect-square rounded-full bg-gray-200 dark:bg-neutral-800 flex items-center justify-center relative",children:[h.jsx(v.AnimatePresence,{children:y&&h.jsx(v.motion.div,{initial:{opacity:0,y:10,x:"-50%"},animate:{opacity:1,y:0,x:"-50%"},exit:{opacity:0,y:2,x:"-50%"},className:"px-2 py-0.5 whitespace-pre rounded-md bg-gray-100 border dark:bg-neutral-800 dark:border-neutral-900 dark:text-white border-gray-200 text-neutral-700 absolute left-1/2 -translate-x-1/2 -top-8 w-fit text-xs",children:t})}),h.jsx(v.motion.div,{style:{width:m,height:p},className:"flex items-center justify-center",children:r})]})})},gr=n=>{const{items:e,className:t}=n,r=v.useMotionValue(1/0);return h.jsx(v.motion.div,{onMouseMove:o=>r.set(o.pageX),onMouseLeave:()=>r.set(1/0),className:mr("mx-auto hidden md:flex h-16 gap-4 items-end rounded-2xl bg-gray-50 dark:bg-neutral-900 px-4 pb-3",t),children:e.map(o=>h.jsx(ri,{mouseX:r,...o},o.title))})},yr=n=>{const{items:e,className:t,collapseIcon:r,autoHidden:o=!1}=n,[s,i]=w.useState(!1),l=()=>{i(!s)};return h.jsxs("div",{className:mr("relative block",o?"md:hidden":"",t),children:[h.jsx(v.AnimatePresence,{children:s&&h.jsx(v.motion.div,{layoutId:"nav",className:"absolute bottom-full mb-2 inset-x-0 flex flex-col gap-2",children:e.map((a,c)=>h.jsx(v.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10,transition:{delay:c*.05}},transition:{delay:(e.length-1-c)*.05},children:h.jsx("a",{href:a.href,className:"h-10 w-10 rounded-full bg-gray-50 dark:bg-neutral-900 flex items-center justify-center",children:h.jsx("div",{className:"h-4 w-4",children:a.icon})},a.title)},a.title))})}),h.jsx("button",{onClick:l,className:"h-10 w-10 rounded-full bg-gray-50 dark:bg-neutral-800 flex items-center justify-center",children:r||h.jsx(D.RiMoreLine,{className:"h-5 w-5 text-neutral-500 dark:text-neutral-400"})})]})},cn=n=>{const{items:e,desktopClassName:t,mobileClassName:r,...o}=n;return h.jsxs(h.Fragment,{children:[h.jsx(gr,{items:e,className:t,...o}),h.jsx(yr,{items:e,className:r,autoHidden:!0,...o})]})};cn.Desktop=gr,cn.Mobile=yr;function br(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=br(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function xr(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,d=Math.min(i.text.length,l.text.length);for(;c<d&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=xr(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class z{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new z(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new z(r,o)}cutByIndex(e,t){return e==t?z.empty:e==0&&t==this.content.length?this:new z(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new z(o,s)}addToStart(e){return new z([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new z(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return br(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return xr(this,e,t,r)}findIndex(e,t=-1){if(e==0)return $t(0,e);if(e==this.size)return $t(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?$t(r+1,i):$t(r,o);o=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return z.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new z(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return z.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new z(t||e,r)}static from(e){if(!e)return z.empty;if(e instanceof z)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new z([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}z.empty=new z([],0);const dn={index:0,offset:0};function $t(n,e){return dn.index=n,dn.offset=e,dn}function hn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!hn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!hn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class pe{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return pe.none;if(e instanceof pe)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}pe.none=[];class oi extends Error{}class L{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Sr(this.content,e+this.openStart,t);return r&&new L(r,this.openStart,this.openEnd)}removeBetween(e,t){return new L(kr(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 L.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new L(z.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new L(e,r,o)}}L.empty=new L(z.empty,0,0);function kr(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(kr(s.content,e-o-1,t-o-1)))}function Sr(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Sr(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function si(n){return n.tag!=null}function ii(n){return n.style!=null}let Cr=class Gn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(si(o))this.tags.push(o);else if(ii(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Tr(this,t,!1);return r.addAll(e,pe.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Tr(this,t,!0);return r.addAll(e,pe.none,t.from,t.to),L.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(ci(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Or(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Or(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Gn(e,Gn.schemaRules(e)))}};const Nr={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},li={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wr={ol:!0,ul:!0},St=1,un=2,qt=4;function Dr(n,e,t){return e!=null?(e?St:0)|(e==="full"?un:0):n&&n.whitespace=="pre"?St|un:t&-5}class Ht{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=pe.none,this.match=s||(i&qt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&St)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(z.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&&!Nr.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Tr{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=Dr(null,t.preserveWhitespace,0)|(r?qt:0);o?s=new Ht(o.type,o.attrs,pe.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Ht(null,null,pe.none,!0,null,i):s=new Ht(e.schema.topNodeType,null,pe.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&un?"full":this.localPreserveWS||(o.options&St)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
662
662
|
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let i=o.content[o.content.length-1],l=e.previousSibling;(!i||l&&l.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;wr.hasOwnProperty(i)&&this.parser.normalizeLists&&ai(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:li.hasOwnProperty(i))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 c,d=this.needsBlock;if(Nr.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
663
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t){let r,o;for(let s=this.open;s>=0;s--){let i=this.nodes[s],l=i.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,o=i,!l.length)||i.solid)break}if(!r)return null;this.sync(o);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=pe.none;for(let i of r.concat(e.marks))(o.type?o.type.allowsMarkType(i.type):Mr(i.type,e.type))&&(s=i.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Dr(e,s,i.options);i.options&qt&&i.content.length==0&&(l|=qt);let a=pe.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Mr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ht(e,t,a,o,null,l)),this.open++,r}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|=St)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}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 r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function ai(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&wr.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ci(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Or(n){let e={};for(let t in n)e[t]=n[t];return e}function Mr(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||s.indexOf(d)<0&&i(d))return!0}};if(i(o.contentMatch))return!0}}class at{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=fn(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(s.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Wt(fn(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Wt(fn(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return Wt(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new at(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=vr(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return vr(e.marks)}}function vr(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function fn(n){return n.document||window.document}const Ir=new WeakMap;function di(n){let e=Ir.get(n);return e===void 0&&Ir.set(n,e=hi(n)),e}function hi(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Wt(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=di(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:m,contentDOM:p}=Wt(n,f,t,r);if(a.appendChild(m),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Er=65535,Ar=Math.pow(2,16);function ui(n,e){return n+e*Ar}function Pr(n){return n&Er}function fi(n){return(n-(n&Er))/Ar}const zr=1,Br=2,Jt=4,Lr=8;class Fr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Lr)>0}get deletedBefore(){return(this.delInfo&(zr|Jt))>0}get deletedAfter(){return(this.delInfo&(Br|Jt))>0}get deletedAcross(){return(this.delInfo&Jt)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,r=Pr(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+fi(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],d=this.ranges[l+i],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,m=a+o+(f<0?0:d);if(r)return m;let p=e==(t<0?a:u)?null:ui(l/3,e-a),y=e==a?Br:e==u?zr:Jt;return(t<0?e!=a:e!=u)&&(y|=Lr),new Fr(m,y,p)}o+=d-c}return r?e+o:new Fr(e+o,0,null)}touches(e,t){let r=0,o=Pr(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],d=this.ranges[o+r];e(l,l+c,a,a+d),s+=d-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);const pn=Object.create(null);class re{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=pn[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in pn)throw new RangeError("Duplicate use of step JSON ID "+e);return pn[e]=t,t.prototype.jsonID=e,t}}class G{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new G(e,null)}static fail(e){return new G(null,e)}static fromReplace(e,t,r,o){try{return G.ok(e.replace(t,r,o))}catch(s){if(s instanceof oi)return G.fail(s.message);throw s}}}function mn(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(mn(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return z.fromArray(r)}class Ge extends re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new L(mn(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return G.fromReplace(e,this.from,this.to,s)}invert(){return new _e(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ge(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ge(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ge(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("addMark",Ge);class _e extends re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new L(mn(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return G.fromReplace(e,this.from,this.to,r)}invert(){return new Ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new _e(t.pos,r.pos,this.mark)}merge(e){return e instanceof _e&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _e(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new _e(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("removeMark",_e);class Ze extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return G.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return G.fromReplace(e,this.pos,this.pos+1,new L(z.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new Ze(this.pos,t.marks[o]);return new Ze(this.pos,this.mark)}}return new Ct(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ze(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ze(t.pos,e.markFromJSON(t.mark))}}re.jsonID("addNodeMark",Ze);class Ct extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return G.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return G.fromReplace(e,this.pos,this.pos+1,new L(z.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ze(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ct(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ct(t.pos,e.markFromJSON(t.mark))}}re.jsonID("removeNodeMark",Ct);class Ie extends re{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&gn(e,this.from,this.to)?G.fail("Structure replace would overwrite content"):G.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ie(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Ie(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Ie)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?L.empty:new L(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ie(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?L.empty:new L(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ie(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ie(t.from,t.to,L.fromJSON(e,t.slice),!!t.structure)}}re.jsonID("replace",Ie);class ct extends re{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(gn(e,this.from,this.gapFrom)||gn(e,this.gapTo,this.to)))return G.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return G.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?G.fromReplace(e,this.from,this.to,r):G.fail("Content does not fit in gap")}getMap(){return new me([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 ct(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ct(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ct(t.from,t.to,t.gapFrom,t.gapTo,L.fromJSON(e,t.slice),t.insert,!!t.structure)}}re.jsonID("replaceAround",ct);function gn(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function pi(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),d=!1;if(s==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}class Nt extends re{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return G.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return G.fromReplace(e,this.pos,this.pos+1,new L(z.from(o),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new Nt(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 Nt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Nt(t.pos,t.attr,t.value)}}re.jsonID("attr",Nt);class Kt extends re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return G.ok(r)}getMap(){return me.empty}invert(e){return new Kt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Kt(t.attr,t.value)}}re.jsonID("docAttr",Kt);let wt=class extends Error{};wt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},wt.prototype=Object.create(Error.prototype),wt.prototype.constructor=wt,wt.prototype.name="TransformError";const yn=Object.create(null);class U{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new mi(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=L.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(c.pos),l?L.empty:t),l==0&&qr(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),d=a.map(l.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),qr(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new H(e):dt(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?dt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):dt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new De(e.node(0))}static atStart(e){return dt(e,e,0,0,1)||new De(e)}static atEnd(e){return dt(e,e,e.content.size,e.childCount,-1)||new De(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=yn[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yn)throw new RangeError("Duplicate use of selection JSON ID "+e);return yn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}}U.prototype.visible=!0;class mi{constructor(e,t){this.$from=e,this.$to=t}}let Vr=!1;function $r(n){!Vr&&!n.parent.inlineContent&&(Vr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class H extends U{constructor(e,t=e){$r(e),$r(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return U.near(r);let o=e.resolve(t.map(this.anchor));return new H(o.parent.inlineContent?o:r,r)}replace(e,t=L.empty){if(super.replace(e,t),t==L.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof H&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ut(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new H(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=U.findFrom(t,r,!0)||U.findFrom(t,-r,!0);if(s)t=s.$head;else return U.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(U.findFrom(e,-r,!0)||U.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new H(e,t)}}U.jsonID("text",H);class Ut{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ut(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}}class O extends U{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?U.near(s):new O(s)}content(){return new L(z.from(this.node),0,0)}eq(e){return e instanceof O&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bn(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new O(e.resolve(t.anchor))}static create(e,t){return new O(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}O.prototype.visible=!1,U.jsonID("node",O);class bn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Ut(r,r):new bn(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&O.isSelectable(r)?new O(t):U.near(t)}}class De extends U{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=L.empty){if(t==L.empty){e.delete(0,e.doc.content.size);let r=U.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new De(e)}map(e){return new De(e)}eq(e){return e instanceof De}getBookmark(){return gi}}U.jsonID("all",De);const gi={map(){return this},resolve(n){return new De(n)}};function dt(n,e,t,r,o,s=!1){if(e.inlineContent)return H.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(n,t-(o<0?l.nodeSize:0))}else{let a=dt(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function qr(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof Ie||o instanceof ct))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(U.near(n.doc.resolve(i),t))}function Hr(n,e){return!e||!n?n:n.bind(e)}class jt{constructor(e,t,r){this.name=e,this.init=Hr(t.init,r),this.apply=Hr(t.apply,r)}}new jt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new jt("selection",{init(n,e){return n.selection||U.atStart(e.doc)},apply(n){return n.selection}}),new jt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new jt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Wr(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Wr(o,e,{})),t[r]=o}return t}class yi{constructor(e){this.spec=e,this.props={},e.props&&Wr(e.props,this,this.props),this.key=e.key?e.key.key:Jr("plugin")}getState(e){return e[this.key]}}const xn=Object.create(null);function Jr(n){return n in xn?n+"$"+ ++xn[n]:(xn[n]=0,n+"$")}class bi{constructor(e="key"){this.key=Jr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const R=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Dt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let kn=null;const Ee=function(n,e,t){let r=kn||(kn=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},xi=function(){kn=null},Qe=function(n,e,t,r){return t&&(Kr(n,e,t,r,-1)||Kr(n,e,t,r,1))},ki=/^(img|br|input|textarea|hr)$/i;function Kr(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:ye(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Tt(n)||ki.test(n.nodeName)||n.contentEditable=="false")return!1;e=R(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?ye(n):0}else return!1}}function ye(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Si(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ye(n)}else if(n.parentNode&&!Tt(n))e=R(n),n=n.parentNode;else return null}}function Ci(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Tt(n))e=R(n)+1,n=n.parentNode;else return null}}function Ni(n,e,t){for(let r=e==0,o=e==ye(n);r||o;){if(n==t)return!0;let s=R(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==ye(n)}}function Tt(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Xt=function(n){return n.focusNode&&Qe(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Re(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function wi(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Di(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ye(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ye(r.startContainer),r.startOffset)}}}const Te=typeof navigator<"u"?navigator:null,Ur=typeof document<"u"?document:null,Ve=Te&&Te.userAgent||"",Sn=/Edge\/(\d+)/.exec(Ve),jr=/MSIE \d/.exec(Ve),Cn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ve),ue=!!(jr||Cn||Sn),$e=jr?document.documentMode:Cn?+Cn[1]:Sn?+Sn[1]:0,Ne=!ue&&/gecko\/(\d+)/i.test(Ve);Ne&&+(/Firefox\/(\d+)/.exec(Ve)||[0,0])[1];const Nn=!ue&&/Chrome\/(\d+)/.exec(Ve),oe=!!Nn,Xr=Nn?+Nn[1]:0,ae=!ue&&!!Te&&/Apple Computer/.test(Te.vendor),ht=ae&&(/Mobile\/\w+/.test(Ve)||!!Te&&Te.maxTouchPoints>2),be=ht||(Te?/Mac/.test(Te.platform):!1),Ti=Te?/Win/.test(Te.platform):!1,Ae=/Android \d/.test(Ve),Ot=!!Ur&&"webkitFontSmoothing"in Ur.documentElement.style,Oi=Ot?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Mi(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Pe(n,e){return typeof n=="number"?n:n[e]}function vi(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Yr(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=Dt(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?Mi(s):vi(l),d=0,u=0;if(e.top<c.top+Pe(r,"top")?u=-(c.top-e.top+Pe(o,"top")):e.bottom>c.bottom-Pe(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Pe(o,"top")-c.top:e.bottom-c.bottom+Pe(o,"bottom")),e.left<c.left+Pe(r,"left")?d=-(c.left-e.left+Pe(o,"left")):e.right>c.right-Pe(r,"right")&&(d=e.right-c.right+Pe(o,"right")),d||u)if(a)s.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,m=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,y=l.scrollTop-m;e={left:e.left-p,top:e.top-y,right:e.right-p,bottom:e.bottom-y}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function Ii(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Gr(n.dom)}}function Gr(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Dt(r));return e}function Ei({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;_r(t,r==0?0:r-e)}function _r(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ut=null;function Ai(n){if(n.setActive)return n.setActive();if(ut)return n.focus(ut);let e=Gr(n);n.focus(ut==null?{get preventScroll(){return ut={preventScroll:!0},!0}}:void 0),ut||(ut=!1,_r(e,0))}function Zr(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Ee(d).getClientRects();else continue;for(let m=0;m<f.length;m++){let p=f[m];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){t=d,r=y,o=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&y&&(s=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=u+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?Pi(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Zr(t,o)}function Pi(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=qe(r,1);if(s.top!=s.bottom&&wn(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function wn(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function zi(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Bi(n,e,t){let{node:r,offset:o}=Zr(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function Li(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Qr(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(wn(e,c))return Qr(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function Fi(n,e){let t=n.dom.ownerDocument,r,o=0,s=Di(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!wn(e,c)||(i=Qr(n.dom,e,c),!i))return null}if(ae)for(let c=i;r&&c;c=Dt(c))c.draggable&&(r=void 0);if(i=zi(i,e),r){if(Ne&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Ot&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=Li(n,r,o,e))}l==null&&(l=Bi(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Rr(n){return n.top<n.bottom||n.left<n.right}function qe(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Rr(r))return r}return Array.prototype.find.call(t,Rr)||n.getBoundingClientRect()}const Vi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function eo(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Ot||Ne;if(r.nodeType==3)if(i&&(Vi.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=qe(Ee(r,o,o),t);if(Ne&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=qe(Ee(r,o-1,o-1),-1);if(c.top==a.top){let d=qe(Ee(r,o,o+1),-1);if(d.top!=a.top)return Mt(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==r.nodeValue.length?(a--,d=1):t<0?a--:c++,Mt(qe(Ee(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==ye(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Dn(a.getBoundingClientRect(),!1)}if(s==null&&o<ye(r)){let a=r.childNodes[o];if(a.nodeType==1)return Dn(a.getBoundingClientRect(),!0)}return Dn(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==ye(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ee(a,ye(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Mt(qe(c,1),!1)}if(s==null&&o<ye(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ee(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Mt(qe(c,-1),!0)}return Mt(qe(r.nodeType==3?Ee(r):r,-t),t>=0)}function Mt(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Dn(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function to(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function $i(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return to(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=eo(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ee(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const qi=/[\u0590-\u08ac]/;function Hi(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!qi.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:to(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let m=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),g=p&&!m.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==y;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let no=null,ro=null,oo=!1;function Wi(n,e,t){return no==e&&ro==t?oo:(no=e,ro=t,oo=t=="up"||t=="down"?$i(n,e,t):Hi(n,e,t))}const xe=0,so=1,et=2,Oe=3;class vt{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>R(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)for(let i=0;i<o.children.length;i++){let l=o.children[i];if(l.size){o=l;break}}return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof ao){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof io&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?R(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?R(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=R(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=R(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let m=0,p=0;m<this.children.length;m++){let y=this.children[m],g=p+y.size;if(s>p&&i<g)return y.setSelection(e-p-y.border,t-p-y.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Ne||ae)&&e==t){let{node:m,offset:p}=l;if(m.nodeType==3){if(u=!!(p&&m.nodeValue[p-1]==`
|
|
664
|
-
`),u&&p==m.nodeValue.length)for(let y=m,g;y;y=y.parentNode){if(g=y.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:R(g)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=m.childNodes[p-1];u=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Ne&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(o=!0)}if(!(o||u&&ae)&&Qe(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Qe(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let m=document.createRange();m.setEnd(a.node,a.offset),m.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?et:so,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Oe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?et:Oe}r=i}this.dirty=et}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?et:so;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class io extends vt{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Ji extends vt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}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 e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class tt extends vt{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=at.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new tt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Oe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=xe}}slice(e,t,r){let o=tt.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=On(s,t,i,r)),e>0&&(s=On(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class He extends vt{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=at.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=uo(d,r,t),c?a=new Ki(e,t,r,o,d,u||null,f,c,s,i+1):t.isText?new Yt(e,t,r,o,d,f,s):new He(e,t,r,o,d,u||null,f,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>z.empty)}return e}matchesNode(e,t,r){return this.dirty==xe&&e.eq(this.node)&&Gt(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new ji(this,i&&i.node,e);Gi(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?pe.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let m;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,d,u,m,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==et)&&(i&&this.protectLocalComposition(e,i),co(this.contentDOM,this.children,e),ht&&_i(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof H)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=Zi(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Ji(this,s,t,o);e.input.compositionNodes.push(i),this.children=On(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==Oe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=xe}updateOuterDeco(e){if(Gt(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ho(this.dom,this.nodeDOM,Tn(this.outerDeco,this.node,t),Tn(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function lo(n,e,t,r,o){uo(r,e,n);let s=new He(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class Yt extends He{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==Oe||this.dirty!=xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=xe,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new Yt(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Oe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ao extends vt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ki extends He{constructor(e,t,r,o,s,i,l,a,c,d){super(e,t,r,o,s,i,l,c,d),this.spec=a}update(e,t,r,o){if(this.dirty==Oe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function co(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=fo(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof tt){let a=r?r.previousSibling:n.lastChild;co(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=fo(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const It=function(n){n&&(this.nodeName=n)};It.prototype=Object.create(null);const nt=[new It];function Tn(n,e,t){if(n.length==0)return nt;let r=t?nt[0]:new It,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new It(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new It(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function ho(n,e,t,r){if(t==nt&&r==nt)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=nt[0]),o=a}Ui(o,l||nt[0],i)}return o}function Ui(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function uo(n,e,t){return ho(n,n,nt,Tn(e,t,n.nodeType!=1))}function Gt(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function fo(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ji{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Xi(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=tt.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==Oe&&i.dom==i.contentDOM&&(i.dirty=et),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof He){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Oe&&Gt(t,a.outerDeco));if(!f&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=et,u.updateChildren(o,i+1),u.dirty=xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Gt(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=He.create(this.top,t,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,s){let i=He.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new io(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof tt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Yt)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||oe)&&e&&e.dom.contentEditable=="false"&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new ao(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Xi(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof tt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function Yi(n,e){return n.type.side-e.type.side}function Gi(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,e.forChild(s,d),c),s+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Yi);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,m;if(a)m=-1,f=a,a=null;else if(c<n.childCount)m=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let p=s+f.nodeSize;if(f.isText){let g=p;i<o.length&&o[i].from<g&&(g=o[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,m=-1)}else for(;i<o.length&&o[i].to<p;)i++;let y=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,y,e.forChild(s,f),m),s=p}}function _i(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Zi(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function On(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),d>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Mn(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Xt(t)){for(a=i;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&O.isSelectable(u)&&o.parent&&!(u.isInline&&Ni(t.focusNode,t.focusOffset,o.dom))){let f=o.posBefore;c=new O(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,f=i;for(let m=0;m<t.rangeCount;m++){let p=t.getRangeAt(m);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,i]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=In(n,d,l,u)}return c}function po(n){return n.editable?n.hasFocus():So(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ze(n,e=!1){let t=n.state.selection;if(bo(n,t),!!po(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&oe){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Qe(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ri(n);else{let{anchor:r,head:o}=t,s,i;mo&&!(t instanceof H)&&(t.$from.parent.inlineContent||(s=go(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=go(n,t.to))),n.docView.setSelection(r,o,n,e),mo&&(s&&yo(s),i&&yo(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qi(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const mo=ae||oe&&Xr<63;function go(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ae&&o&&o.contentEditable=="false")return vn(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return vn(o);if(s)return vn(s)}}function vn(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function yo(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Qi(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!po(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ri(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,R(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ue&&$e<=11&&(r.disabled=!0,r.disabled=!1)}function bo(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(xo(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else xo(n)}function xo(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function In(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||H.between(e,t,r)}function ko(n){return n.editable&&!n.hasFocus()?!1:So(n)}function So(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function el(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function En(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&U.findFrom(s,e)}function We(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Co(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return We(n,new H(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=En(n.state,e);return o&&o instanceof O?We(n,o):!1}else if(!(be&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?O.isSelectable(s)?We(n,new O(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Ot?We(n,new H(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return We(n,new H(e>0?r.$to:r.$from));{let o=En(n.state,e);return o?We(n,o):!1}}}function _t(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Et(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ft(n,e){return e<0?tl(n):nl(n)}function tl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ne&&t.nodeType==1&&r<_t(t)&&Et(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Et(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(No(t))break;{let l=t.previousSibling;for(;l&&Et(l,-1);)o=t.parentNode,s=R(l),l=l.previousSibling;if(l)t=l,r=_t(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?An(n,t,r):o&&An(n,o,s)}function nl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=_t(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Et(l,1))s=t,i=++r;else break}else{if(No(t))break;{let l=t.nextSibling;for(;l&&Et(l,1);)s=l.parentNode,i=R(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=_t(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&An(n,s,i)}function No(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function rl(n,e){for(;n&&e==n.childNodes.length&&!Tt(n);)e=R(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ol(n,e){for(;n&&!e&&!Tt(n);)e=R(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function An(n,e,t){if(e.nodeType!=3){let s,i;(i=rl(e,t))?(e=i,t=0):(s=ol(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Xt(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&ze(n)},50)}function wo(n,e){let t=n.state.doc.resolve(e);if(!(oe||Ti)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Do(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||be&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=En(n.state,e);if(i&&i instanceof O)return We(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof De?U.near(i,e):U.findFrom(i,e);return l?We(n,l):!1}return!1}function To(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function Oo(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function sl(n){if(!ae||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Oo(n,r,"true"),setTimeout(()=>Oo(n,r,"false"),20)}return!1}function il(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ll(n,e){let t=e.keyCode,r=il(e);if(t==8||be&&t==72&&r=="c")return To(n,-1)||ft(n,-1);if(t==46&&!e.shiftKey||be&&t==68&&r=="c")return To(n,1)||ft(n,1);if(t==13||t==27)return!0;if(t==37||be&&t==66&&r=="c"){let o=t==37?wo(n,n.state.selection.from)=="ltr"?-1:1:-1;return Co(n,o,r)||ft(n,o)}else if(t==39||be&&t==70&&r=="c"){let o=t==39?wo(n,n.state.selection.from)=="ltr"?1:-1:1;return Co(n,o,r)||ft(n,o)}else{if(t==38||be&&t==80&&r=="c")return Do(n,-1,r)||ft(n,-1);if(t==40||be&&t==78&&r=="c")return sl(n)||Do(n,1,r)||ft(n,1);if(r==(be?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Pn(n,e){n.someProp("transformCopied",m=>{e=m(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let m=r.firstChild;t.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let i=n.someProp("clipboardSerializer")||at.fromSchema(n.state.schema),l=zo(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Ao[c.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let p=l.createElement(d[m]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",m=>m(e,n))||e.content.textBetween(0,e.content.size,`
|
|
663
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t){let r,o;for(let s=this.open;s>=0;s--){let i=this.nodes[s],l=i.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,o=i,!l.length)||i.solid)break}if(!r)return null;this.sync(o);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=pe.none;for(let i of r.concat(e.marks))(o.type?o.type.allowsMarkType(i.type):Mr(i.type,e.type))&&(s=i.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Dr(e,s,i.options);i.options&qt&&i.content.length==0&&(l|=qt);let a=pe.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Mr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ht(e,t,a,o,null,l)),this.open++,r}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|=St)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}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 r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function ai(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&wr.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ci(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Or(n){let e={};for(let t in n)e[t]=n[t];return e}function Mr(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||s.indexOf(d)<0&&i(d))return!0}};if(i(o.contentMatch))return!0}}class at{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=fn(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],d=this.serializeMark(c,i.isInline,t);d&&(s.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Wt(fn(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Wt(fn(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return Wt(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new at(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=vr(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return vr(e.marks)}}function vr(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function fn(n){return n.document||window.document}const Ir=new WeakMap;function di(n){let e=Ir.get(n);return e===void 0&&Ir.set(n,e=hi(n)),e}function hi(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Wt(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=di(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:m,contentDOM:p}=Wt(n,f,t,r);if(a.appendChild(m),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Er=65535,Ar=Math.pow(2,16);function ui(n,e){return n+e*Ar}function Pr(n){return n&Er}function fi(n){return(n-(n&Er))/Ar}const zr=1,Br=2,Jt=4,Lr=8;class Fr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Lr)>0}get deletedBefore(){return(this.delInfo&(zr|Jt))>0}get deletedAfter(){return(this.delInfo&(Br|Jt))>0}get deletedAcross(){return(this.delInfo&Jt)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,r=Pr(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+fi(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],d=this.ranges[l+i],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,m=a+o+(f<0?0:d);if(r)return m;let p=e==(t<0?a:u)?null:ui(l/3,e-a),y=e==a?Br:e==u?zr:Jt;return(t<0?e!=a:e!=u)&&(y|=Lr),new Fr(m,y,p)}o+=d-c}return r?e+o:new Fr(e+o,0,null)}touches(e,t){let r=0,o=Pr(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],d=this.ranges[o+r];e(l,l+c,a,a+d),s+=d-c}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);const pn=Object.create(null);class re{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=pn[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in pn)throw new RangeError("Duplicate use of step JSON ID "+e);return pn[e]=t,t.prototype.jsonID=e,t}}class G{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new G(e,null)}static fail(e){return new G(null,e)}static fromReplace(e,t,r,o){try{return G.ok(e.replace(t,r,o))}catch(s){if(s instanceof oi)return G.fail(s.message);throw s}}}function mn(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(mn(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return z.fromArray(r)}class Ge extends re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new L(mn(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return G.fromReplace(e,this.from,this.to,s)}invert(){return new _e(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ge(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ge(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ge(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("addMark",Ge);class _e extends re{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new L(mn(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return G.fromReplace(e,this.from,this.to,r)}invert(){return new Ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new _e(t.pos,r.pos,this.mark)}merge(e){return e instanceof _e&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _e(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new _e(t.from,t.to,e.markFromJSON(t.mark))}}re.jsonID("removeMark",_e);class Ze extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return G.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return G.fromReplace(e,this.pos,this.pos+1,new L(z.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new Ze(this.pos,t.marks[o]);return new Ze(this.pos,this.mark)}}return new Ct(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ze(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ze(t.pos,e.markFromJSON(t.mark))}}re.jsonID("addNodeMark",Ze);class Ct extends re{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return G.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return G.fromReplace(e,this.pos,this.pos+1,new L(z.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ze(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ct(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ct(t.pos,e.markFromJSON(t.mark))}}re.jsonID("removeNodeMark",Ct);class Ee extends re{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&gn(e,this.from,this.to)?G.fail("Structure replace would overwrite content"):G.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ee(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Ee(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Ee)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?L.empty:new L(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ee(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?L.empty:new L(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ee(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ee(t.from,t.to,L.fromJSON(e,t.slice),!!t.structure)}}re.jsonID("replace",Ee);class ct extends re{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(gn(e,this.from,this.gapFrom)||gn(e,this.gapTo,this.to)))return G.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return G.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?G.fromReplace(e,this.from,this.to,r):G.fail("Content does not fit in gap")}getMap(){return new me([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 ct(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ct(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ct(t.from,t.to,t.gapFrom,t.gapTo,L.fromJSON(e,t.slice),t.insert,!!t.structure)}}re.jsonID("replaceAround",ct);function gn(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function pi(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),d=!1;if(s==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}class Nt extends re{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return G.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return G.fromReplace(e,this.pos,this.pos+1,new L(z.from(o),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new Nt(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 Nt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Nt(t.pos,t.attr,t.value)}}re.jsonID("attr",Nt);class Kt extends re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return G.ok(r)}getMap(){return me.empty}invert(e){return new Kt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Kt(t.attr,t.value)}}re.jsonID("docAttr",Kt);let wt=class extends Error{};wt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},wt.prototype=Object.create(Error.prototype),wt.prototype.constructor=wt,wt.prototype.name="TransformError";const yn=Object.create(null);class U{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new mi(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=L.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],d=e.mapping.slice(s);e.replaceRange(d.map(a.pos),d.map(c.pos),l?L.empty:t),l==0&&qr(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),d=a.map(l.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),qr(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new H(e):dt(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?dt(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):dt(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new De(e.node(0))}static atStart(e){return dt(e,e,0,0,1)||new De(e)}static atEnd(e){return dt(e,e,e.content.size,e.childCount,-1)||new De(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=yn[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yn)throw new RangeError("Duplicate use of selection JSON ID "+e);return yn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}}U.prototype.visible=!0;class mi{constructor(e,t){this.$from=e,this.$to=t}}let Vr=!1;function $r(n){!Vr&&!n.parent.inlineContent&&(Vr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class H extends U{constructor(e,t=e){$r(e),$r(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return U.near(r);let o=e.resolve(t.map(this.anchor));return new H(o.parent.inlineContent?o:r,r)}replace(e,t=L.empty){if(super.replace(e,t),t==L.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof H&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ut(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new H(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=U.findFrom(t,r,!0)||U.findFrom(t,-r,!0);if(s)t=s.$head;else return U.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(U.findFrom(e,-r,!0)||U.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new H(e,t)}}U.jsonID("text",H);class Ut{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ut(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}}class O extends U{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?U.near(s):new O(s)}content(){return new L(z.from(this.node),0,0)}eq(e){return e instanceof O&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bn(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new O(e.resolve(t.anchor))}static create(e,t){return new O(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}O.prototype.visible=!1,U.jsonID("node",O);class bn{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Ut(r,r):new bn(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&O.isSelectable(r)?new O(t):U.near(t)}}class De extends U{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=L.empty){if(t==L.empty){e.delete(0,e.doc.content.size);let r=U.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new De(e)}map(e){return new De(e)}eq(e){return e instanceof De}getBookmark(){return gi}}U.jsonID("all",De);const gi={map(){return this},resolve(n){return new De(n)}};function dt(n,e,t,r,o,s=!1){if(e.inlineContent)return H.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(n,t-(o<0?l.nodeSize:0))}else{let a=dt(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function qr(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof Ee||o instanceof ct))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,d)=>{i==null&&(i=d)}),n.setSelection(U.near(n.doc.resolve(i),t))}function Hr(n,e){return!e||!n?n:n.bind(e)}class jt{constructor(e,t,r){this.name=e,this.init=Hr(t.init,r),this.apply=Hr(t.apply,r)}}new jt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new jt("selection",{init(n,e){return n.selection||U.atStart(e.doc)},apply(n){return n.selection}}),new jt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new jt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Wr(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Wr(o,e,{})),t[r]=o}return t}class yi{constructor(e){this.spec=e,this.props={},e.props&&Wr(e.props,this,this.props),this.key=e.key?e.key.key:Jr("plugin")}getState(e){return e[this.key]}}const xn=Object.create(null);function Jr(n){return n in xn?n+"$"+ ++xn[n]:(xn[n]=0,n+"$")}class bi{constructor(e="key"){this.key=Jr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const R=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Dt=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let kn=null;const Ae=function(n,e,t){let r=kn||(kn=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},xi=function(){kn=null},Qe=function(n,e,t,r){return t&&(Kr(n,e,t,r,-1)||Kr(n,e,t,r,1))},ki=/^(img|br|input|textarea|hr)$/i;function Kr(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:ye(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Tt(n)||ki.test(n.nodeName)||n.contentEditable=="false")return!1;e=R(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?ye(n):0}else return!1}}function ye(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Si(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ye(n)}else if(n.parentNode&&!Tt(n))e=R(n),n=n.parentNode;else return null}}function Ci(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Tt(n))e=R(n)+1,n=n.parentNode;else return null}}function Ni(n,e,t){for(let r=e==0,o=e==ye(n);r||o;){if(n==t)return!0;let s=R(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==ye(n)}}function Tt(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Xt=function(n){return n.focusNode&&Qe(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Re(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function wi(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Di(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ye(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ye(r.startContainer),r.startOffset)}}}const Te=typeof navigator<"u"?navigator:null,Ur=typeof document<"u"?document:null,Ve=Te&&Te.userAgent||"",Sn=/Edge\/(\d+)/.exec(Ve),jr=/MSIE \d/.exec(Ve),Cn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ve),ue=!!(jr||Cn||Sn),$e=jr?document.documentMode:Cn?+Cn[1]:Sn?+Sn[1]:0,Ne=!ue&&/gecko\/(\d+)/i.test(Ve);Ne&&+(/Firefox\/(\d+)/.exec(Ve)||[0,0])[1];const Nn=!ue&&/Chrome\/(\d+)/.exec(Ve),oe=!!Nn,Xr=Nn?+Nn[1]:0,ae=!ue&&!!Te&&/Apple Computer/.test(Te.vendor),ht=ae&&(/Mobile\/\w+/.test(Ve)||!!Te&&Te.maxTouchPoints>2),be=ht||(Te?/Mac/.test(Te.platform):!1),Ti=Te?/Win/.test(Te.platform):!1,Pe=/Android \d/.test(Ve),Ot=!!Ur&&"webkitFontSmoothing"in Ur.documentElement.style,Oi=Ot?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Mi(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function ze(n,e){return typeof n=="number"?n:n[e]}function vi(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Yr(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=Dt(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?Mi(s):vi(l),d=0,u=0;if(e.top<c.top+ze(r,"top")?u=-(c.top-e.top+ze(o,"top")):e.bottom>c.bottom-ze(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+ze(o,"top")-c.top:e.bottom-c.bottom+ze(o,"bottom")),e.left<c.left+ze(r,"left")?d=-(c.left-e.left+ze(o,"left")):e.right>c.right-ze(r,"right")&&(d=e.right-c.right+ze(o,"right")),d||u)if(a)s.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,m=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-f,y=l.scrollTop-m;e={left:e.left-p,top:e.top-y,right:e.right-p,bottom:e.bottom-y}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function Ii(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Gr(n.dom)}}function Gr(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Dt(r));return e}function Ei({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;_r(t,r==0?0:r-e)}function _r(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ut=null;function Ai(n){if(n.setActive)return n.setActive();if(ut)return n.focus(ut);let e=Gr(n);n.focus(ut==null?{get preventScroll(){return ut={preventScroll:!0},!0}}:void 0),ut||(ut=!1,_r(e,0))}function Zr(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Ae(d).getClientRects();else continue;for(let m=0;m<f.length;m++){let p=f[m];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){t=d,r=y,o=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&y&&(s=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=u+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?Pi(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Zr(t,o)}function Pi(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=qe(r,1);if(s.top!=s.bottom&&wn(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function wn(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function zi(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Bi(n,e,t){let{node:r,offset:o}=Zr(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function Li(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Qr(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(wn(e,c))return Qr(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function Fi(n,e){let t=n.dom.ownerDocument,r,o=0,s=Di(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!wn(e,c)||(i=Qr(n.dom,e,c),!i))return null}if(ae)for(let c=i;r&&c;c=Dt(c))c.draggable&&(r=void 0);if(i=zi(i,e),r){if(Ne&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Ot&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=Li(n,r,o,e))}l==null&&(l=Bi(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Rr(n){return n.top<n.bottom||n.left<n.right}function qe(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Rr(r))return r}return Array.prototype.find.call(t,Rr)||n.getBoundingClientRect()}const Vi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function eo(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Ot||Ne;if(r.nodeType==3)if(i&&(Vi.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=qe(Ae(r,o,o),t);if(Ne&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=qe(Ae(r,o-1,o-1),-1);if(c.top==a.top){let d=qe(Ae(r,o,o+1),-1);if(d.top!=a.top)return Mt(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==r.nodeValue.length?(a--,d=1):t<0?a--:c++,Mt(qe(Ae(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==ye(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Dn(a.getBoundingClientRect(),!1)}if(s==null&&o<ye(r)){let a=r.childNodes[o];if(a.nodeType==1)return Dn(a.getBoundingClientRect(),!0)}return Dn(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==ye(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ae(a,ye(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Mt(qe(c,1),!1)}if(s==null&&o<ye(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ae(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Mt(qe(c,-1),!0)}return Mt(qe(r.nodeType==3?Ae(r):r,-t),t>=0)}function Mt(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Dn(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function to(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function $i(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return to(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=eo(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ae(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?i.top-d.top>(d.bottom-i.top)*2:d.bottom-i.bottom>(i.bottom-d.top)*2))return!1}}return!0})}const qi=/[\u0590-\u08ac]/;function Hi(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!qi.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:to(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let m=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),g=p&&!m.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==y;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let no=null,ro=null,oo=!1;function Wi(n,e,t){return no==e&&ro==t?oo:(no=e,ro=t,oo=t=="up"||t=="down"?$i(n,e,t):Hi(n,e,t))}const xe=0,so=1,et=2,Oe=3;class vt{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=xe,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){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,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>R(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)for(let i=0;i<o.children.length;i++){let l=o.children[i];if(l.size){o=l;break}}return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof ao){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof io&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?R(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?R(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let d=i+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=i;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=R(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=R(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let m=0,p=0;m<this.children.length;m++){let y=this.children[m],g=p+y.size;if(s>p&&i<g)return y.setSelection(e-p-y.border,t-p-y.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Ne||ae)&&e==t){let{node:m,offset:p}=l;if(m.nodeType==3){if(u=!!(p&&m.nodeValue[p-1]==`
|
|
664
|
+
`),u&&p==m.nodeValue.length)for(let y=m,g;y;y=y.parentNode){if(g=y.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:R(g)+1});break}let x=y.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let y=m.childNodes[p-1];u=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Ne&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(o=!0)}if(!(o||u&&ae)&&Qe(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Qe(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let m=document.createRange();m.setEnd(a.node,a.offset),m.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?et:so,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Oe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?et:Oe}r=i}this.dirty=et}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?et:so;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class io extends vt{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==xe&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Ji extends vt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}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 e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class tt extends vt{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=at.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new tt(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Oe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Oe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=xe){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=xe}}slice(e,t,r){let o=tt.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=On(s,t,i,r)),e>0&&(s=On(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class He extends vt{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=at.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=uo(d,r,t),c?a=new Ki(e,t,r,o,d,u||null,f,c,s,i+1):t.isText?new Yt(e,t,r,o,d,f,s):new He(e,t,r,o,d,u||null,f,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>z.empty)}return e}matchesNode(e,t,r){return this.dirty==xe&&e.eq(this.node)&&Gt(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new ji(this,i&&i.node,e);Gi(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?pe.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let m;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(m=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,d,u,m,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==et)&&(i&&this.protectLocalComposition(e,i),co(this.contentDOM,this.children,e),ht&&_i(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof H)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=Zi(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Ji(this,s,t,o);e.input.compositionNodes.push(i),this.children=On(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==Oe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=xe}updateOuterDeco(e){if(Gt(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ho(this.dom,this.nodeDOM,Tn(this.outerDeco,this.node,t),Tn(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function lo(n,e,t,r,o){uo(r,e,n);let s=new He(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class Yt extends He{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==Oe||this.dirty!=xe&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=xe||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=xe,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new Yt(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Oe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ao extends vt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==xe&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Ki extends He{constructor(e,t,r,o,s,i,l,a,c,d){super(e,t,r,o,s,i,l,c,d),this.spec=a}update(e,t,r,o){if(this.dirty==Oe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function co(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=fo(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof tt){let a=r?r.previousSibling:n.lastChild;co(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=fo(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const It=function(n){n&&(this.nodeName=n)};It.prototype=Object.create(null);const nt=[new It];function Tn(n,e,t){if(n.length==0)return nt;let r=t?nt[0]:new It,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new It(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new It(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function ho(n,e,t,r){if(t==nt&&r==nt)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=nt[0]),o=a}Ui(o,l||nt[0],i)}return o}function Ui(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function uo(n,e,t){return ho(n,n,nt,Tn(e,t,n.nodeType!=1))}function Gt(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function fo(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class ji{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Xi(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=xe,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=tt.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==Oe&&i.dom==i.contentDOM&&(i.dirty=et),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof He){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Oe&&Gt(t,a.outerDeco));if(!f&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=et,u.updateChildren(o,i+1),u.dirty=xe),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Gt(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=He.create(this.top,t,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,s){let i=He.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new io(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof tt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Yt)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ae||oe)&&e&&e.dom.contentEditable=="false"&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new ao(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Xi(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof tt)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function Yi(n,e){return n.type.side-e.type.side}function Gi(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,e.forChild(s,d),c),s+=d.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let d,u;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Yi);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let f,m;if(a)m=-1,f=a,a=null;else if(c<n.childCount)m=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let p=s+f.nodeSize;if(f.isText){let g=p;i<o.length&&o[i].from<g&&(g=o[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<p&&(a=f.cut(g-s),f=f.cut(0,g-s),p=g,m=-1)}else for(;i<o.length&&o[i].to<p;)i++;let y=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,y,e.forChild(s,f),m),s=p}}function _i(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Zi(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function On(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,d=l+=a.size;c>=t||d<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),d>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Mn(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Xt(t)){for(a=i;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&O.isSelectable(u)&&o.parent&&!(u.isInline&&Ni(t.focusNode,t.focusOffset,o.dom))){let f=o.posBefore;c=new O(i==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=i,f=i;for(let m=0;m<t.rangeCount;m++){let p=t.getRangeAt(m);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,i]=f==n.state.selection.anchor?[f,u]:[u,f],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=In(n,d,l,u)}return c}function po(n){return n.editable?n.hasFocus():So(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Be(n,e=!1){let t=n.state.selection;if(bo(n,t),!!po(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&oe){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Qe(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ri(n);else{let{anchor:r,head:o}=t,s,i;mo&&!(t instanceof H)&&(t.$from.parent.inlineContent||(s=go(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=go(n,t.to))),n.docView.setSelection(r,o,n,e),mo&&(s&&yo(s),i&&yo(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qi(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const mo=ae||oe&&Xr<63;function go(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ae&&o&&o.contentEditable=="false")return vn(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return vn(o);if(s)return vn(s)}}function vn(n){return n.contentEditable="true",ae&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function yo(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Qi(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!po(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ri(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,R(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ue&&$e<=11&&(r.disabled=!0,r.disabled=!1)}function bo(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(xo(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else xo(n)}function xo(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function In(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||H.between(e,t,r)}function ko(n){return n.editable&&!n.hasFocus()?!1:So(n)}function So(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function el(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qe(e.node,e.offset,t.anchorNode,t.anchorOffset)}function En(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&U.findFrom(s,e)}function We(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Co(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return We(n,new H(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=En(n.state,e);return o&&o instanceof O?We(n,o):!1}else if(!(be&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?O.isSelectable(s)?We(n,new O(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Ot?We(n,new H(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return We(n,new H(e>0?r.$to:r.$from));{let o=En(n.state,e);return o?We(n,o):!1}}}function _t(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Et(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function ft(n,e){return e<0?tl(n):nl(n)}function tl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ne&&t.nodeType==1&&r<_t(t)&&Et(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Et(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(No(t))break;{let l=t.previousSibling;for(;l&&Et(l,-1);)o=t.parentNode,s=R(l),l=l.previousSibling;if(l)t=l,r=_t(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?An(n,t,r):o&&An(n,o,s)}function nl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=_t(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Et(l,1))s=t,i=++r;else break}else{if(No(t))break;{let l=t.nextSibling;for(;l&&Et(l,1);)s=l.parentNode,i=R(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=_t(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&An(n,s,i)}function No(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function rl(n,e){for(;n&&e==n.childNodes.length&&!Tt(n);)e=R(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ol(n,e){for(;n&&!e&&!Tt(n);)e=R(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function An(n,e,t){if(e.nodeType!=3){let s,i;(i=rl(e,t))?(e=i,t=0):(s=ol(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Xt(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Be(n)},50)}function wo(n,e){let t=n.state.doc.resolve(e);if(!(oe||Ti)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Do(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||be&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=En(n.state,e);if(i&&i instanceof O)return We(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof De?U.near(i,e):U.findFrom(i,e);return l?We(n,l):!1}return!1}function To(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function Oo(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function sl(n){if(!ae||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Oo(n,r,"true"),setTimeout(()=>Oo(n,r,"false"),20)}return!1}function il(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ll(n,e){let t=e.keyCode,r=il(e);if(t==8||be&&t==72&&r=="c")return To(n,-1)||ft(n,-1);if(t==46&&!e.shiftKey||be&&t==68&&r=="c")return To(n,1)||ft(n,1);if(t==13||t==27)return!0;if(t==37||be&&t==66&&r=="c"){let o=t==37?wo(n,n.state.selection.from)=="ltr"?-1:1:-1;return Co(n,o,r)||ft(n,o)}else if(t==39||be&&t==70&&r=="c"){let o=t==39?wo(n,n.state.selection.from)=="ltr"?1:-1:1;return Co(n,o,r)||ft(n,o)}else{if(t==38||be&&t==80&&r=="c")return Do(n,-1,r)||ft(n,-1);if(t==40||be&&t==78&&r=="c")return sl(n)||Do(n,1,r)||ft(n,1);if(r==(be?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Pn(n,e){n.someProp("transformCopied",m=>{e=m(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let m=r.firstChild;t.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let i=n.someProp("clipboardSerializer")||at.fromSchema(n.state.schema),l=zo(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Ao[c.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let p=l.createElement(d[m]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",m=>m(e,n))||e.content.textBetween(0,e.content.size,`
|
|
665
665
|
|
|
666
666
|
`);return{dom:a,text:f,slice:e}}function zn(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return e?new L(z.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
667
|
-
`))),0,0):L.empty;let u=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(u)l=u;else{let f=o.marks(),{schema:m}=n.state,p=at.fromSchema(m);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=i.appendChild(document.createElement("p"));y&&g.appendChild(p.serializeNode(m.text(y,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=hl(t),Ot&&ul(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 u=+d[3];u>0;u--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Cr.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!al.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=fl(Eo(l,+d[1],+d[2]),d[4]);else if(l=L.maxOpen(cl(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let m=l.content.firstChild;u<l.openStart&&!m.type.spec.isolating;u++,m=m.firstChild);for(let m=l.content.lastChild;f<l.openEnd&&!m.type.spec.isolating;f++,m=m.lastChild);l=Eo(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const al=/^(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 cl(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&vo(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Io(i[i.length-1],s.length));let d=Mo(l,a);i.push(d),o=o.matchType(d.type),s=a}}),i)return z.from(i)}return n}function Mo(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,z.from(n));return n}function vo(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=vo(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(z.from(Mo(t,n,o+1))))}}function Io(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Io(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(z.empty,!0);return n.copy(t.append(r))}function Bn(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=Bn(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(z.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Eo(n,e,t){return e<n.openStart&&(n=new L(Bn(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new L(Bn(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ao={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 Po=null;function zo(){return Po||(Po=document.implementation.createHTMLDocument("title"))}let Ln=null;function dl(n){let e=window.trustedTypes;return e?(Ln||(Ln=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ln.createHTML(n)):n}function hl(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=zo().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&Ao[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=dl(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function ul(n){let e=n.querySelectorAll(oe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function fl(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=z.from(a.create(r[l+1],o)),s++,i++}return new L(o,s,i)}const ce={},de={},pl={touchstart:!0,touchmove:!0};class ml{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function gl(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{bl(n,r)&&!Vn(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},pl[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),Fn(n)}function Je(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function yl(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Fn(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Vn(n,r))})}function Vn(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function bl(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function xl(n,e){!Vn(n,e)&&ce[e.type]&&(n.editable||!(e.type in de))&&ce[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Lo(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ae&&oe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ht&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Re(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ll(n,t)?t.preventDefault():Je(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Lo(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||be&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Zt(n){return{left:n.clientX,top:n.clientY}}function kl(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function $n(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function pt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Sl(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(pt(n,new O(t)),!0):!1}function Cl(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(O.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(pt(n,O.create(n.state.doc,o)),!0):!1}function Nl(n,e,t,r,o){return $n(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Cl(n,t):Sl(n,t))}function wl(n,e,t,r){return $n(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Dl(n,e,t,r){return $n(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Tl(n,t,r)}function Tl(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(pt(n,H.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)pt(n,H.create(r,l+1,l+1+i.content.size));else if(O.isSelectable(i))pt(n,O.create(r,l));else continue;return!0}}function qn(n){return At(n)}const Bo=be?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=qn(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&kl(t,n.input.lastClick)&&!t[Bo]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Zt(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ol(n,i,t,!!r)):(s=="doubleClick"?wl:Dl)(n,i.pos,i.inside,t)?t.preventDefault():Je(n,"pointer"))};class Ol{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Bo],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,i=d.depth?d.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ne&&!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)),Je(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(()=>ze(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(Zt(e))),this.updateAllowDefault(e),this.allowDefault||!t?Je(this.view,"pointer"):Nl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||oe&&!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)?(pt(this.view,U.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Je(this.view,"pointer")}move(e){this.updateAllowDefault(e),Je(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ce.touchstart=n=>{n.input.lastTouch=Date.now(),qn(n),Je(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),Je(n,"pointer")},ce.contextmenu=n=>qn(n);function Lo(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ml=Ae?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),At(n,!0),n.markCursor=null;else if(At(n,!e.selection.empty),Ne&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Fo(n,Ml)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Fo(n,20))};function Fo(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>At(n),e))}function Vo(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Il());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function vl(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Si(e.focusNode,e.focusOffset),r=Ci(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function Il(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function At(n,e=!1){if(!(Ae&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Vo(n),e||n.docView&&n.docView.dirty){let t=Mn(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function El(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Pt=ue&&$e<15||ht&&Oi<604;ce.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Pt?null:t.clipboardData,i=r.content(),{dom:l,text:a}=Pn(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):El(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Al(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Pl(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?zt(n,r.value,null,o,e):zt(n,r.textContent,r.innerHTML,o,e)},50)}function zt(n,e,t,r,o){let s=zn(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||L.empty)))return!0;if(!s)return!1;let i=Al(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $o(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Ae)return;let r=Pt?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&zt(n,$o(r),r.getData("text/html"),o,t)?t.preventDefault():Pl(n,t)};class qo{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Ho=be?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Zt(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)i=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=O.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=Pn(n,l);(!t.dataTransfer.files.length||!oe||Xr>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Pt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Pt||t.dataTransfer.setData("text/plain",c),n.dragging=new qo(d,!t[Ho],i)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Zt(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=zn(n,$o(t.dataTransfer),Pt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Ho]);if(n.someProp("handleDrop",p=>p(n,t,i||L.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?pi(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(f))return;let m=c.doc.resolve(d);if(u&&O.isSelectable(i.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new O(m));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((y,g,x,S)=>p=S),c.setSelection(In(n,m,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ce.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ze(n)},20))},ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ce.beforeinput=(n,e)=>{if(oe&&Ae&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Re(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)ce[n]=de[n];function Bt(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Qt{constructor(e,t){this.toDOM=e,this.spec=t||rt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new ke(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Qt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ke{constructor(e,t){this.attrs=e,this.spec=t||rt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new ke(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ke&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}static is(e){return e.type instanceof Ke}destroy(){}}class Hn{constructor(e,t){this.attrs=e,this.spec=t||rt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new ke(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Hn&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}destroy(){}}class ke{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ke(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ke(e,e,new Qt(t,r))}static inline(e,t,r,o){return new ke(e,t,new Ke(r,o))}static node(e,t,r,o){return new ke(e,t,new Hn(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ke}get widget(){return this.type instanceof Qt}}const mt=[],rt={};class _{constructor(e,t){this.local=e.length?e:mt,this.children=t.length?t:mt}static create(e,t){return t.length?Rt(t,e,0,rt):se}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||rt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?zl(this.children,i||[],e,t,r,o,s):i?new _(i.sort(ot),mt):se}add(e,t){return t.length?this==se?_.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Jo(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,d,c+1):o.splice(s,0,a,a+l.nodeSize,Rt(d,l,c+1,rt)),s+=3}});let i=Wo(s?Ko(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new _(i.length?this.local.concat(i).sort(ot):this.local,o||this.children)}remove(e){return e.length==0||this==se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=se?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new _(o,r):se}forChild(e,t){if(this==se)return this;if(t.isLeaf)return _.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof Ke){let c=Math.max(s,a.from)-s,d=Math.min(i,a.to)-s;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new _(o.sort(ot),mt);return r?new Ue([l,r]):l}return r||se}eq(e){if(this==e)return!0;if(!(e instanceof _)||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 Wn(this.localsInner(e))}localsInner(e){if(this==se)return mt;if(e.inlineContent||!this.local.some(Ke.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ke||t.push(this.local[r]);return t}forEachSet(e){e(this)}}_.empty=new _([],[]),_.removeOverlap=Wn;const se=_.empty;class Ue{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,rt));return Ue.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=se&&(s instanceof Ue?r=r.concat(s.members):r.push(s))}return Ue.from(r)}eq(e){if(!(e instanceof Ue)||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,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Wn(r?t:t.sort(ot)):mt}static from(e){switch(e.length){case 0:return se;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function zl(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,m,p,y)=>{let g=y-p-(m-f);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||f>S+d-u)continue;let E=l[x]+d-u;m>=E?l[x+1]=f<=E?-2:-1:f>=d&&g&&(l[x]+=g,l[x+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+s),u=d-o;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),m=f-o,{index:p,offset:y}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&y==u&&y+g.nodeSize==m){let x=l[c+2].mapInner(t,g,d+1,n[c]+s+1,i);x!=se?(l[c]=u,l[c+1]=m,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Bl(l,n,e,t,o,s,i),d=Rt(c,r,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let m=d.children[u];for(;f<l.length&&l[f]<m;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new _(e.sort(ot),l)}function Wo(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ke(o.from+e,o.to+e,o.type))}return t}function Bl(n,e,t,r,o,s,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,o,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Jo(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Ko(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Rt(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Jo(n,l,a+t);if(c){s=!0;let d=Rt(c,l,t+a+1,r);d!=se&&o.push(a,a+l.nodeSize,d)}});let i=Wo(s?Ko(n):n,-t).sort(ot);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new _(i,o):se}function ot(n,e){return n.from-e.from||n.to-e.to}function Wn(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Uo(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Uo(e,o,r.copy(s.from,r.to)));break}}}return e}function Uo(n,e,t){for(;e<n.length&&ot(t,n[e])>0;)e++;n.splice(e,0,t)}function Jn(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=se&&e.push(r)}),n.cursorWrapper&&e.push(_.create(n.state.doc,[n.cursorWrapper.deco])),Ue.from(e)}const Ll={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fl=ue&&$e<=11;class Vl{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 $l{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Vl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ue&&$e<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Fl&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ll)),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(ko(this.view)){if(this.suppressingSelectionUpdates)return ze(this.view);if(ue&&$e<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qe(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=new Set,r;for(let s=e.focusNode;s;s=Dt(s))t.add(s);for(let s=e.anchorNode;s;s=Dt(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ko(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(s=s<0?u.from:Math.min(u.from,s),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(Ne&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let m=f.parentNode;m&&m.nodeName=="LI"&&(!u||Wl(e,u)!=m)&&f.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Xt(r)&&(c=Mn(e))&&c.eq(U.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ze(e),this.currentSelection.set(r)):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),ql(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ze(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ue&&$e<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let i=o&&o.parentNode==e.target?R(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?R(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let jo=new WeakMap,Xo=!1;function ql(n){if(!jo.has(n)&&(jo.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ne,Xo)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."),Xo=!0}}function Yo(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Qe(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function Hl(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Yo(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Yo(n,t):null}function Wl(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Jl(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Xt(a)||c.push({node:a.focusNode,offset:a.focusOffset})),oe&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let x=r.childNodes[g-1],S=x.pmViewDesc;if(x.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||Cr.fromSchema(n.state.schema),m=u.resolve(i),p=null,y=f.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Kl,context:m});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),p={anchor:g+i,head:x+i}}return{doc:y,sel:p,from:i,to:l}}function Kl(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ae&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ae&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ul=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function jl(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,Q=Mn(n,T);if(Q&&!n.state.selection.eq(Q)){if(oe&&Ae&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Me=>Me(n,Re(13,"Enter"))))return;let X=n.state.tr.setSelection(Q);T=="pointer"?X.setMeta("pointer",!0):T=="key"&&X.scrollIntoView(),s&&X.setMeta("composition",s),n.dispatch(X)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Jl(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,m;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,m="end"):(f=n.state.selection.from,m="start"),n.input.lastKeyCode=null;let p=Gl(u.content,c.doc.content,c.from,f,m);if(p&&n.input.domChangeCount++,(ht&&n.input.lastIOSEnter>Date.now()-225||Ae)&&o.some(T=>T.nodeType==1&&!Ul.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Re(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof H&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Go(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let Q=n.state.tr.setSelection(T);s&&Q.setMeta("composition",s),n.dispatch(Q)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof H&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ue&&$e<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let y=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),x=d.resolve(p.start),S=y.sameParent(g)&&y.parent.inlineContent&&x.end()>=p.endA,E;if((ht&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!S&&y.pos<c.doc.content.size&&!y.sameParent(g)&&(E=U.findFrom(c.doc.resolve(y.pos+1),1,!0))&&E.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Re(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Yl(d,p.start,p.endA,y,g)&&n.someProp("handleKeyDown",T=>T(n,Re(8,"Backspace")))){Ae&&oe&&n.domObserver.suppressSelectionUpdates();return}oe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Ae&&!S&&y.start()!=g.start()&&g.parentOffset==0&&y.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Re(13,"Enter"))})},20));let k=p.start,P=p.endA,I,A,M;if(S){if(y.pos==g.pos)ue&&$e<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>ze(n),20)),I=n.state.tr.delete(k,P),A=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(M=Xl(y.parent.content.cut(y.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start()))))I=n.state.tr,M.type=="add"?I.addMark(k,P,M.mark):I.removeMark(k,P,M.mark);else if(y.parent.child(y.index()).isText&&y.index()==g.index()-(g.textOffset?0:1)){let T=y.parent.textBetween(y.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",Q=>Q(n,k,P,T)))return;I=n.state.tr.insertText(T,k,P)}}if(I||(I=n.state.tr.replace(k,P,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=Go(n,I.doc,c.sel);T&&!(oe&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(T.head==k||T.head==I.mapping.map(P)-1)||ue&&T.empty&&T.head==k)&&I.setSelection(T)}A&&I.ensureMarks(A),s&&I.setMeta("composition",s),n.dispatch(I.scrollIntoView())}function Go(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:In(n,e.resolve(t.anchor),e.resolve(t.head))}function Xl(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(z.from(c).eq(n))return{mark:l,type:i}}function Yl(n,e,t,r,o){if(t-e<=o.pos-r.pos||Kn(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(Kn(s,!0,!0));return!i.parent.isTextblock||i.pos>t||Kn(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Kn(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Gl(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&_o(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&_o(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function _o(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}const _l=zn,Zl=At;class Ql{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 ml,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ts),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ro(this),Qo(this),this.nodeViews=es(this),this.docView=lo(this.state.doc,Zo(this),Jn(this),this.dom,this),this.domObserver=new $l(this,(r,o,s,i)=>jl(this,r,o,s,i)),this.domObserver.start(),gl(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&&Fn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ts),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Vo(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let m=es(this);ea(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fn(this),this.editable=Ro(this),Qo(this);let a=Jn(this),c=Zo(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(i=!0);let f=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Ii(this);if(i){this.domObserver.stop();let m=u&&(ue||oe)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Rl(o.selection,e.selection);if(u){let p=oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vl(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=lo(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&el(this))?ze(this,m):(bo(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Ei(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Yr(this,t.getBoundingClientRect(),e)}else Yr(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new qo(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ue){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Ai(this.dom),ze(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Fi(this,e)}coordsAtPos(e,t=1){return eo(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Wi(this,t||this.state,e)}pasteHTML(e,t){return zt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return zt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Pn(this,e)}destroy(){this.docView&&(yl(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Jn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,xi())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xl(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ae&&this.root.nodeType===11&&wi(this.dom.ownerDocument)==this.dom&&Hl(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Zo(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ke.node(0,n.state.doc.content.size,e)]}function Qo(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ke.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ro(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Rl(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function es(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ea(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function ts(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const ta=Object.freeze(Object.defineProperty({__proto__:null,Decoration:ke,DecorationSet:_,EditorView:Ql,__endComposition:Zl,__parseFromClipboard:_l},Symbol.toStringTag,{value:"Module"}));function na(){try{return ta}catch{return null}}function ra(n,e){if(n&&typeof n.serializeForClipboard=="function")return n.serializeForClipboard(e);const t=na();if(t&&typeof(t==null?void 0:t.__serializeForClipboard)=="function")return t.__serializeForClipboard(n,e);throw new Error("No supported clipboard serialization method found.")}function oa(n){const e=n.getBoundingClientRect(),t=n.closest('[role="dialog"]'),r=n.closest(".ProseMirror"),o=r==null?void 0:r.getBoundingClientRect(),s=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;if(t&&window.getComputedStyle(t).transform!=="none"){const l=t.getBoundingClientRect();return{top:e.top-l.top+i,left:e.left-l.left+s,width:e.width}}return{top:o?e.top-o.top:e.top+i,left:o?e.left-o.left:e.left+s,width:e.width}}function ns(n,e){const t=["li","p:not(:first-child)","pre","blockquote","h1","h2","h3","h4","h5","h6",...e.customNodes.map(r=>`[data-type=${r}]`)].join(", ");return document.elementsFromPoint(n.x,n.y).find(r=>{var o,s;return((s=(o=r.parentElement)==null?void 0:o.matches)==null?void 0:s.call(o,".ProseMirror"))||r.matches(t)})}function rs(n,e,t){var o;const r=n.getBoundingClientRect();return(o=e.posAtCoords({left:r.left+50+t.dragHandleWidth,top:r.top+1}))==null?void 0:o.inside}function en(n,e){const t=e.state.doc.resolve(n);return t.depth>1?t.before(t.depth):n}function sa(n){let e="",t=!1;function r(d,u){if(u.focus(),!d.dataTransfer)return;const f=ns({x:d.clientX+50+n.dragHandleWidth,y:d.clientY},n);if(!(f instanceof Element))return;let m=rs(f,u,n);if(m==null||m<0)return;m=en(m,u);const{from:p,to:y}=u.state.selection,g=p-y,x=en(p,u);let S=!1;const E=u.state.doc.resolve(x);if(E.node().type.name==="doc")S=!0;else{const M=O.create(u.state.doc,E.before());S=!(m+1>=M.$from.pos&&m<=M.$to.pos)}let k=u.state.selection;if(!S&&g!==0&&!(u.state.selection instanceof O)){const M=O.create(u.state.doc,y-1);k=H.create(u.state.doc,m,M.$to.pos)}else if(k=O.create(u.state.doc,m),k.node.type.isInline||k.node.type.name==="tableRow"){const M=u.state.doc.resolve(k.from);k=O.create(u.state.doc,M.before())}u.dispatch(u.state.tr.setSelection(k)),u.state.selection instanceof O&&u.state.selection.node.type.name==="listItem"&&(e=f.parentElement.tagName);const P=u.state.selection.content(),{dom:I,text:A}=ra(u,P);d.dataTransfer.clearData(),d.dataTransfer.setData("text/html",I.innerHTML),d.dataTransfer.setData("text/plain",A),d.dataTransfer.effectAllowed="copyMove",d.dataTransfer.setDragImage(f,0,0),u.dragging={slice:P,move:d.ctrlKey}}let o=null;function s(){o&&o.classList.add("hide")}function i(){o&&o.classList.remove("hide")}function l(d,u){const f=en(u,d),m=O.create(d.state.doc,f);d.dispatch(d.state.tr.setSelection(m)),d.focus(),t=!0}function a(d){if(t=d.state.selection instanceof O,t&&(o!=null&&o.dataset.nodePos)){const f=parseInt(o.dataset.nodePos,10);try{const m=d.state.doc.resolve(f);m&&m.parent&&m.parent.type.name!=="doc"||(t=!1,s())}catch{t=!1,s()}}t&&o&&!o.classList.contains("hide")?i():t||s()}function c(d){if(!(d.target instanceof Element))return;const u=d.relatedTarget;if(!u){t||s();return}const f=u.closest(".drag-handle")||u.classList.contains("drag-handle"),m=u.closest(".tiptap")||u.classList.contains("tiptap");!f&&!m&&!t&&s()}return new yi({key:new bi(n.pluginKey),view:d=>{var y,g,x,S;const u=n.dragHandleSelector?document.querySelector(n.dragHandleSelector):null;o=u??document.createElement("div"),o.draggable=!0,o.dataset.dragHandle="",o.classList.add("drag-handle");function f(E){r(E,d)}o.addEventListener("dragstart",f);function m(E){u||(E.preventDefault(),E.stopPropagation());const k=o==null?void 0:o.dataset.nodePos;k&&l(d,parseInt(k,10))}o.addEventListener("click",m);function p(E){s();const k=window.scrollY;E.clientY<n.scrollTreshold?window.scrollTo({top:k-30,behavior:"smooth"}):window.innerHeight-E.clientY<n.scrollTreshold&&window.scrollTo({top:k+30,behavior:"smooth"})}return o.addEventListener("drag",p),s(),u||(g=(y=d==null?void 0:d.dom)==null?void 0:y.parentElement)==null||g.appendChild(o),(S=(x=d==null?void 0:d.dom)==null?void 0:x.parentElement)==null||S.addEventListener("mouseout",c),{destroy:()=>{var E,k,P;u||(E=o==null?void 0:o.remove)==null||E.call(o),o==null||o.removeEventListener("drag",p),o==null||o.removeEventListener("dragstart",f),o==null||o.removeEventListener("click",m),o=null,(P=(k=d==null?void 0:d.dom)==null?void 0:k.parentElement)==null||P.removeEventListener("mouseout",c)}}},props:{handleDOMEvents:{mousemove:(d,u)=>{if(!d.editable)return;const f=ns({x:u.clientX+50+n.dragHandleWidth,y:u.clientY},n),m=f==null?void 0:f.closest(".not-draggable"),p=n.excludedTags.concat(["ol","ul"]).join(", ");if(!(f instanceof Element)||f.matches(p)||m){t||s();return}const y=rs(f,d,n);y!=null&&y>=0&&(o.dataset.nodePos=String(en(y,d)));const g=window.getComputedStyle(f),x=parseInt(g.lineHeight,10),S=isNaN(x)?parseInt(g.fontSize)*1.2:x,E=parseInt(g.paddingTop,10),k=oa(f);k.top+=(S-24)/2,k.top+=E,f.matches("ul:not([data-type=taskList]) li, ol li")&&(k.left-=n.dragHandleWidth-28),k.width=n.dragHandleWidth,o&&(o.style.position="absolute",o.style.left=`${k.left-k.width}px`,o.style.top=`${k.top}px`,i())},keydown:()=>{t||s()},mousewheel:()=>{t||s()},selectionChange:d=>{a(d)},dragstart:d=>{d.dom.classList.add("dragging")},drop:(d,u)=>{var g;d.dom.classList.remove("dragging"),s();let f=null;const m=d.posAtCoords({left:u.clientX,top:u.clientY});if(!m||(d.state.selection instanceof O&&(f=d.state.selection.node),!f))return;const y=d.state.doc.resolve(m.pos).parent.type.name==="listItem";if(d.state.selection instanceof O&&d.state.selection.node.type.name==="listItem"&&!y&&e=="OL"){const x=(g=d.state.schema.nodes.orderedList)==null?void 0:g.createAndFill(null,f),S=new L(z.from(x),0,0);d.dragging={slice:S,move:u.ctrlKey}}},dragend:d=>{d.dom.classList.remove("dragging")}}},state:{init(){return{}},apply(d,u,f,m){if(d.docChanged&&o&&o.dataset.nodePos){const p=parseInt(o.dataset.nodePos,10);try{const y=m.doc.resolve(p);(!y||y.parent.type.name==="doc")&&(t=!1,s())}catch{t=!1,s()}}return u}}})}const ia=vs.Extension.create({name:"globalDragHandle",addOptions(){return{dragHandleWidth:20,scrollTreshold:100,excludedTags:[],customNodes:[]}},addProseMirrorPlugins(){return[sa({pluginKey:"globalDragHandle",dragHandleWidth:this.options.dragHandleWidth,scrollTreshold:this.options.scrollTreshold,dragHandleSelector:this.options.dragHandleSelector,excludedTags:this.options.excludedTags,customNodes:this.options.customNodes})]}}),la=N.AIHighlight,aa=N.Placeholder.configure({placeholder:"撰写任何内容,或者按“/”输入命令..."}),ca=N.TiptapLink.configure({HTMLAttributes:{class:le.cx("text-muted-foreground underline underline-offset-[3px] hover:text-primary transition-colors cursor-pointer")}}),da=N.TiptapImage.extend({addProseMirrorPlugins(){return[N.UploadImagesPlugin({imageClass:le.cx("opacity-40 rounded-lg border border-stone-200")})]}}).configure({allowBase64:!0,HTMLAttributes:{class:le.cx("rounded-lg border border-muted")}}),ha=N.UpdatedImage.configure({HTMLAttributes:{class:le.cx("rounded-lg border border-muted")}}),ua=N.TaskList.configure({HTMLAttributes:{class:le.cx("not-prose pl-2 ")}}),fa=N.TaskItem.configure({HTMLAttributes:{class:le.cx("flex gap-2 items-start my-4")},nested:!0}),pa=N.HorizontalRule.configure({HTMLAttributes:{class:le.cx("mt-4 mb-6 border-t border-muted-foreground")}}),ma=N.StarterKit.configure({bulletList:{HTMLAttributes:{class:le.cx("list-disc list-outside leading-3 -mt-2")}},orderedList:{HTMLAttributes:{class:le.cx("list-decimal list-outside leading-3 -mt-2")}},listItem:{HTMLAttributes:{class:le.cx("leading-normal -mb-2")}},blockquote:{HTMLAttributes:{class:le.cx("border-l-4 border-primary")}},codeBlock:{HTMLAttributes:{class:le.cx("rounded-md bg-muted text-muted-foreground border p-5 font-mono font-medium")}},code:{HTMLAttributes:{class:le.cx("rounded-md bg-muted px-1.5 py-1 font-mono font-medium"),spellcheck:"false"}},horizontalRule:!1,dropcursor:{color:"#DBEAFE",width:4},gapcursor:!1}),ga=N.CodeBlockLowlight.configure({lowlight:tr.createLowlight(tr.common)}),ya=N.Mathematics.configure({HTMLAttributes:{class:le.cx("text-foreground rounded p-1 hover:bg-accent cursor-pointer")},katexOptions:{throwOnError:!1}}),ba=N.CharacterCount.configure(),xa=Ms.Markdown.configure({html:!0,tightLists:!0,tightListClass:"tight",bulletListMarker:"-",linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}),ka=ia.configure({dragHandleWidth:56,dragHandleSelector:".custom-drag-handle"}),os=[ma,aa,ca,da,ha,ua,fa,pa,la,ga,ya,ba,N.TiptapUnderline,xa,N.HighlightExtension,N.TextStyle,N.Color,N.CustomKeymap,ka],Sa=kt.Root,ss=kt.Trigger,tn=ne.forwardRef(({className:n,align:e="center",sideOffset:t=4,...r},o)=>h.jsx(kt.Portal,{children:h.jsx(kt.Content,{ref:o,align:e,sideOffset:t,className:b.cx("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...r})}));tn.displayName=kt.Content.displayName;const Ca=le.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-7 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Se=ne.forwardRef(({className:n,variant:e,size:t,asChild:r=!1,...o},s)=>{const i=r?Is.Slot:"button";return h.jsx(i,{className:b.cx(Ca({variant:e,size:t,className:n})),ref:s,...o})});Se.displayName="Button";const is=[{name:"默认",color:"var(--novel-black)"},{name:"紫色",color:"#9333EA"},{name:"红色",color:"#E00000"},{name:"黄色",color:"#EAB308"},{name:"蓝色",color:"#2563EB"},{name:"绿色",color:"#008A00"},{name:"橙色",color:"#FFA500"},{name:"粉色",color:"#BA4081"},{name:"灰色",color:"#A8A29E"}],ls=[{name:"默认背景",color:"var(--novel-highlight-default)"},{name:"紫色背景",color:"var(--novel-highlight-purple)"},{name:"红色背景",color:"var(--novel-highlight-red)"},{name:"黄色背景",color:"var(--novel-highlight-yellow)"},{name:"蓝色背景",color:"var(--novel-highlight-blue)"},{name:"绿色背景",color:"var(--novel-highlight-green)"},{name:"橙色背景",color:"var(--novel-highlight-orange)"},{name:"粉色背景",color:"var(--novel-highlight-pink)"},{name:"灰色背景",color:"var(--novel-highlight-gray)"}],st=n=>h.jsx(Qn,{classNames:{root:b.css`
|
|
667
|
+
`))),0,0):L.empty;let u=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(u)l=u;else{let f=o.marks(),{schema:m}=n.state,p=at.fromSchema(m);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=i.appendChild(document.createElement("p"));y&&g.appendChild(p.serializeNode(m.text(y,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),i=hl(t),Ot&&ul(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 u=+d[3];u>0;u--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Cr.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!al.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=fl(Eo(l,+d[1],+d[2]),d[4]);else if(l=L.maxOpen(cl(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let m=l.content.firstChild;u<l.openStart&&!m.type.spec.isolating;u++,m=m.firstChild);for(let m=l.content.lastChild;f<l.openEnd&&!m.type.spec.isolating;f++,m=m.lastChild);l=Eo(l,u,f)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const al=/^(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 cl(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&vo(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Io(i[i.length-1],s.length));let d=Mo(l,a);i.push(d),o=o.matchType(d.type),s=a}}),i)return z.from(i)}return n}function Mo(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,z.from(n));return n}function vo(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=vo(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(z.from(Mo(t,n,o+1))))}}function Io(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Io(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(z.empty,!0);return n.copy(t.append(r))}function Bn(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=Bn(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(z.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Eo(n,e,t){return e<n.openStart&&(n=new L(Bn(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new L(Bn(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ao={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 Po=null;function zo(){return Po||(Po=document.implementation.createHTMLDocument("title"))}let Ln=null;function dl(n){let e=window.trustedTypes;return e?(Ln||(Ln=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ln.createHTML(n)):n}function hl(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=zo().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&Ao[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=dl(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function ul(n){let e=n.querySelectorAll(oe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function fl(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=z.from(a.create(r[l+1],o)),s++,i++}return new L(o,s,i)}const ce={},de={},pl={touchstart:!0,touchmove:!0};class ml{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function gl(n){for(let e in ce){let t=ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{bl(n,r)&&!Vn(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},pl[e]?{passive:!0}:void 0)}ae&&n.dom.addEventListener("input",()=>null),Fn(n)}function Je(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function yl(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Fn(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Vn(n,r))})}function Vn(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function bl(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function xl(n,e){!Vn(n,e)&&ce[e.type]&&(n.editable||!(e.type in de))&&ce[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Lo(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Pe&&oe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ht&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Re(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ll(n,t)?t.preventDefault():Je(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Lo(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||be&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Zt(n){return{left:n.clientX,top:n.clientY}}function kl(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function $n(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function pt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Sl(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(pt(n,new O(t)),!0):!1}function Cl(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(O.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(pt(n,O.create(n.state.doc,o)),!0):!1}function Nl(n,e,t,r,o){return $n(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Cl(n,t):Sl(n,t))}function wl(n,e,t,r){return $n(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Dl(n,e,t,r){return $n(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Tl(n,t,r)}function Tl(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(pt(n,H.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)pt(n,H.create(r,l+1,l+1+i.content.size));else if(O.isSelectable(i))pt(n,O.create(r,l));else continue;return!0}}function qn(n){return At(n)}const Bo=be?"metaKey":"ctrlKey";ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=qn(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&kl(t,n.input.lastClick)&&!t[Bo]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Zt(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ol(n,i,t,!!r)):(s=="doubleClick"?wl:Dl)(n,i.pos,i.inside,t)?t.preventDefault():Je(n,"pointer"))};class Ol{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Bo],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,i=d.depth?d.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ne&&!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)),Je(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(()=>Be(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(Zt(e))),this.updateAllowDefault(e),this.allowDefault||!t?Je(this.view,"pointer"):Nl(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ae&&this.mightDrag&&!this.mightDrag.node.isAtom||oe&&!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)?(pt(this.view,U.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Je(this.view,"pointer")}move(e){this.updateAllowDefault(e),Je(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ce.touchstart=n=>{n.input.lastTouch=Date.now(),qn(n),Je(n,"pointer")},ce.touchmove=n=>{n.input.lastTouch=Date.now(),Je(n,"pointer")},ce.contextmenu=n=>qn(n);function Lo(n,e){return n.composing?!0:ae&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ml=Pe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),At(n,!0),n.markCursor=null;else if(At(n,!e.selection.empty),Ne&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Fo(n,Ml)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Fo(n,20))};function Fo(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>At(n),e))}function Vo(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Il());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function vl(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Si(e.focusNode,e.focusOffset),r=Ci(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function Il(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function At(n,e=!1){if(!(Pe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Vo(n),e||n.docView&&n.docView.dirty){let t=Mn(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function El(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Pt=ue&&$e<15||ht&&Oi<604;ce.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Pt?null:t.clipboardData,i=r.content(),{dom:l,text:a}=Pn(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):El(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Al(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Pl(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?zt(n,r.value,null,o,e):zt(n,r.textContent,r.innerHTML,o,e)},50)}function zt(n,e,t,r,o){let s=zn(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||L.empty)))return!0;if(!s)return!1;let i=Al(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function $o(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Pe)return;let r=Pt?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&zt(n,$o(r),r.getData("text/html"),o,t)?t.preventDefault():Pl(n,t)};class qo{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Ho=be?"altKey":"ctrlKey";ce.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Zt(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)i=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(i=O.create(n.state.doc,u.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:d}=Pn(n,l);(!t.dataTransfer.files.length||!oe||Xr>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Pt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Pt||t.dataTransfer.setData("text/plain",c),n.dragging=new qo(d,!t[Ho],i)},ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Zt(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=zn(n,$o(t.dataTransfer),Pt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Ho]);if(n.someProp("handleDrop",p=>p(n,t,i||L.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?pi(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,i.content.firstChild):c.replaceRange(d,d,i),c.doc.eq(f))return;let m=c.doc.resolve(d);if(u&&O.isSelectable(i.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new O(m));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((y,g,x,S)=>p=S),c.setSelection(In(n,m,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},ce.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Be(n)},20))},ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},ce.beforeinput=(n,e)=>{if(oe&&Pe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Re(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)ce[n]=de[n];function Bt(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Qt{constructor(e,t){this.toDOM=e,this.spec=t||rt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new ke(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Qt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ke{constructor(e,t){this.attrs=e,this.spec=t||rt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new ke(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ke&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}static is(e){return e.type instanceof Ke}destroy(){}}class Hn{constructor(e,t){this.attrs=e,this.spec=t||rt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new ke(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Hn&&Bt(this.attrs,e.attrs)&&Bt(this.spec,e.spec)}destroy(){}}class ke{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ke(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ke(e,e,new Qt(t,r))}static inline(e,t,r,o){return new ke(e,t,new Ke(r,o))}static node(e,t,r,o){return new ke(e,t,new Hn(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ke}get widget(){return this.type instanceof Qt}}const mt=[],rt={};class _{constructor(e,t){this.local=e.length?e:mt,this.children=t.length?t:mt}static create(e,t){return t.length?Rt(t,e,0,rt):se}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||rt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?zl(this.children,i||[],e,t,r,o,s):i?new _(i.sort(ot),mt):se}add(e,t){return t.length?this==se?_.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Jo(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,d,c+1):o.splice(s,0,a,a+l.nodeSize,Rt(d,l,c+1,rt)),s+=3}});let i=Wo(s?Ko(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new _(i.length?this.local.concat(i).sort(ot):this.local,o||this.children)}remove(e){return e.length==0||this==se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(i||(i=[])).push(u));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=se?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new _(o,r):se}forChild(e,t){if(this==se)return this;if(t.isLeaf)return _.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof Ke){let c=Math.max(s,a.from)-s,d=Math.min(i,a.to)-s;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new _(o.sort(ot),mt);return r?new Ue([l,r]):l}return r||se}eq(e){if(this==e)return!0;if(!(e instanceof _)||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 Wn(this.localsInner(e))}localsInner(e){if(this==se)return mt;if(e.inlineContent||!this.local.some(Ke.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ke||t.push(this.local[r]);return t}forEachSet(e){e(this)}}_.empty=new _([],[]),_.removeOverlap=Wn;const se=_.empty;class Ue{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,rt));return Ue.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=se&&(s instanceof Ue?r=r.concat(s.members):r.push(s))}return Ue.from(r)}eq(e){if(!(e instanceof Ue)||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,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Wn(r?t:t.sort(ot)):mt}static from(e){switch(e.length){case 0:return se;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function zl(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,m,p,y)=>{let g=y-p-(m-f);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||f>S+d-u)continue;let E=l[x]+d-u;m>=E?l[x+1]=f<=E?-2:-1:f>=d&&g&&(l[x]+=g,l[x+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+s),u=d-o;if(u<0||u>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),m=f-o,{index:p,offset:y}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&y==u&&y+g.nodeSize==m){let x=l[c+2].mapInner(t,g,d+1,n[c]+s+1,i);x!=se?(l[c]=u,l[c+1]=m,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Bl(l,n,e,t,o,s,i),d=Rt(c,r,0,i);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let m=d.children[u];for(;f<l.length&&l[f]<m;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new _(e.sort(ot),l)}function Wo(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ke(o.from+e,o.to+e,o.type))}return t}function Bl(n,e,t,r,o,s,i){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,o,c);u?t.push(u):i.onRemove&&i.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Jo(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Ko(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Rt(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Jo(n,l,a+t);if(c){s=!0;let d=Rt(c,l,t+a+1,r);d!=se&&o.push(a,a+l.nodeSize,d)}});let i=Wo(s?Ko(n):n,-t).sort(ot);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new _(i,o):se}function ot(n,e){return n.from-e.from||n.to-e.to}function Wn(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Uo(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Uo(e,o,r.copy(s.from,r.to)));break}}}return e}function Uo(n,e,t){for(;e<n.length&&ot(t,n[e])>0;)e++;n.splice(e,0,t)}function Jn(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=se&&e.push(r)}),n.cursorWrapper&&e.push(_.create(n.state.doc,[n.cursorWrapper.deco])),Ue.from(e)}const Ll={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fl=ue&&$e<=11;class Vl{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 $l{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Vl,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ue&&$e<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Fl&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ll)),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(ko(this.view)){if(this.suppressingSelectionUpdates)return Be(this.view);if(ue&&$e<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qe(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=new Set,r;for(let s=e.focusNode;s;s=Dt(s))t.add(s);for(let s=e.anchorNode;s;s=Dt(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ko(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(s=s<0?u.from:Math.min(u.from,s),i=i<0?u.to:Math.max(u.to,i),u.typeOver&&(l=!0))}if(Ne&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let m=f.parentNode;m&&m.nodeName=="LI"&&(!u||Wl(e,u)!=m)&&f.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Xt(r)&&(c=Mn(e))&&c.eq(U.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Be(e),this.currentSelection.set(r)):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),ql(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Be(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ue&&$e<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let i=o&&o.parentNode==e.target?R(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?R(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let jo=new WeakMap,Xo=!1;function ql(n){if(!jo.has(n)&&(jo.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ne,Xo)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."),Xo=!0}}function Yo(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Qe(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function Hl(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Yo(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Yo(n,t):null}function Wl(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Jl(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],Xt(a)||c.push({node:a.focusNode,offset:a.focusOffset})),oe&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let x=r.childNodes[g-1],S=x.pmViewDesc;if(x.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||Cr.fromSchema(n.state.schema),m=u.resolve(i),p=null,y=f.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:o,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Kl,context:m});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),p={anchor:g+i,head:x+i}}return{doc:y,sel:p,from:i,to:l}}function Kl(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ae&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ae&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ul=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function jl(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,Q=Mn(n,T);if(Q&&!n.state.selection.eq(Q)){if(oe&&Pe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Me=>Me(n,Re(13,"Enter"))))return;let X=n.state.tr.setSelection(Q);T=="pointer"?X.setMeta("pointer",!0):T=="key"&&X.scrollIntoView(),s&&X.setMeta("composition",s),n.dispatch(X)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Jl(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,m;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,m="end"):(f=n.state.selection.from,m="start"),n.input.lastKeyCode=null;let p=Gl(u.content,c.doc.content,c.from,f,m);if(p&&n.input.domChangeCount++,(ht&&n.input.lastIOSEnter>Date.now()-225||Pe)&&o.some(T=>T.nodeType==1&&!Ul.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Re(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof H&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Go(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let Q=n.state.tr.setSelection(T);s&&Q.setMeta("composition",s),n.dispatch(Q)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof H&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ue&&$e<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let y=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),x=d.resolve(p.start),S=y.sameParent(g)&&y.parent.inlineContent&&x.end()>=p.endA,E;if((ht&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!S&&y.pos<c.doc.content.size&&!y.sameParent(g)&&(E=U.findFrom(c.doc.resolve(y.pos+1),1,!0))&&E.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Re(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Yl(d,p.start,p.endA,y,g)&&n.someProp("handleKeyDown",T=>T(n,Re(8,"Backspace")))){Pe&&oe&&n.domObserver.suppressSelectionUpdates();return}oe&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Pe&&!S&&y.start()!=g.start()&&g.parentOffset==0&&y.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Re(13,"Enter"))})},20));let k=p.start,P=p.endA,I,A,M;if(S){if(y.pos==g.pos)ue&&$e<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Be(n),20)),I=n.state.tr.delete(k,P),A=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(M=Xl(y.parent.content.cut(y.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,p.endA-x.start()))))I=n.state.tr,M.type=="add"?I.addMark(k,P,M.mark):I.removeMark(k,P,M.mark);else if(y.parent.child(y.index()).isText&&y.index()==g.index()-(g.textOffset?0:1)){let T=y.parent.textBetween(y.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",Q=>Q(n,k,P,T)))return;I=n.state.tr.insertText(T,k,P)}}if(I||(I=n.state.tr.replace(k,P,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=Go(n,I.doc,c.sel);T&&!(oe&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(T.head==k||T.head==I.mapping.map(P)-1)||ue&&T.empty&&T.head==k)&&I.setSelection(T)}A&&I.ensureMarks(A),s&&I.setMeta("composition",s),n.dispatch(I.scrollIntoView())}function Go(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:In(n,e.resolve(t.anchor),e.resolve(t.head))}function Xl(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(z.from(c).eq(n))return{mark:l,type:i}}function Yl(n,e,t,r,o){if(t-e<=o.pos-r.pos||Kn(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(Kn(s,!0,!0));return!i.parent.isTextblock||i.pos>t||Kn(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Kn(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Gl(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&_o(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&_o(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function _o(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}const _l=zn,Zl=At;class Ql{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 ml,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ts),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Ro(this),Qo(this),this.nodeViews=es(this),this.docView=lo(this.state.doc,Zo(this),Jn(this),this.dom,this),this.domObserver=new $l(this,(r,o,s,i)=>jl(this,r,o,s,i)),this.domObserver.start(),gl(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&&Fn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ts),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Vo(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let m=es(this);ea(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fn(this),this.editable=Ro(this),Qo(this);let a=Jn(this),c=Zo(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(i=!0);let f=d=="preserve"&&i&&this.dom.style.overflowAnchor==null&&Ii(this);if(i){this.domObserver.stop();let m=u&&(ue||oe)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Rl(o.selection,e.selection);if(u){let p=oe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vl(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=lo(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&el(this))?Be(this,m):(bo(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Ei(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Yr(this,t.getBoundingClientRect(),e)}else Yr(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new qo(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ue){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Ai(this.dom),Be(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Fi(this,e)}coordsAtPos(e,t=1){return eo(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Wi(this,t||this.state,e)}pasteHTML(e,t){return zt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return zt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Pn(this,e)}destroy(){this.docView&&(yl(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Jn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,xi())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xl(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ae&&this.root.nodeType===11&&wi(this.dom.ownerDocument)==this.dom&&Hl(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Zo(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ke.node(0,n.state.doc.content.size,e)]}function Qo(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ke.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ro(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Rl(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function es(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ea(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function ts(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}const ta=Object.freeze(Object.defineProperty({__proto__:null,Decoration:ke,DecorationSet:_,EditorView:Ql,__endComposition:Zl,__parseFromClipboard:_l},Symbol.toStringTag,{value:"Module"}));function na(){try{return ta}catch{return null}}function ra(n,e){if(n&&typeof n.serializeForClipboard=="function")return n.serializeForClipboard(e);const t=na();if(t&&typeof(t==null?void 0:t.__serializeForClipboard)=="function")return t.__serializeForClipboard(n,e);throw new Error("No supported clipboard serialization method found.")}function oa(n){const e=n.getBoundingClientRect(),t=n.closest('[role="dialog"]'),r=n.closest(".ProseMirror"),o=r==null?void 0:r.getBoundingClientRect(),s=window.pageXOffset||document.documentElement.scrollLeft,i=window.pageYOffset||document.documentElement.scrollTop;if(t&&window.getComputedStyle(t).transform!=="none"){const l=t.getBoundingClientRect();return{top:e.top-l.top+i,left:e.left-l.left+s,width:e.width}}return{top:o?e.top-o.top:e.top+i,left:o?e.left-o.left:e.left+s,width:e.width}}function ns(n,e){const t=["li","p:not(:first-child)","pre","blockquote","h1","h2","h3","h4","h5","h6",...e.customNodes.map(r=>`[data-type=${r}]`)].join(", ");return document.elementsFromPoint(n.x,n.y).find(r=>{var o,s;return((s=(o=r.parentElement)==null?void 0:o.matches)==null?void 0:s.call(o,".ProseMirror"))||r.matches(t)})}function rs(n,e,t){var o;const r=n.getBoundingClientRect();return(o=e.posAtCoords({left:r.left+50+t.dragHandleWidth,top:r.top+1}))==null?void 0:o.inside}function en(n,e){const t=e.state.doc.resolve(n);return t.depth>1?t.before(t.depth):n}function sa(n){let e="",t=!1;function r(d,u){if(u.focus(),!d.dataTransfer)return;const f=ns({x:d.clientX+50+n.dragHandleWidth,y:d.clientY},n);if(!(f instanceof Element))return;let m=rs(f,u,n);if(m==null||m<0)return;m=en(m,u);const{from:p,to:y}=u.state.selection,g=p-y,x=en(p,u);let S=!1;const E=u.state.doc.resolve(x);if(E.node().type.name==="doc")S=!0;else{const M=O.create(u.state.doc,E.before());S=!(m+1>=M.$from.pos&&m<=M.$to.pos)}let k=u.state.selection;if(!S&&g!==0&&!(u.state.selection instanceof O)){const M=O.create(u.state.doc,y-1);k=H.create(u.state.doc,m,M.$to.pos)}else if(k=O.create(u.state.doc,m),k.node.type.isInline||k.node.type.name==="tableRow"){const M=u.state.doc.resolve(k.from);k=O.create(u.state.doc,M.before())}u.dispatch(u.state.tr.setSelection(k)),u.state.selection instanceof O&&u.state.selection.node.type.name==="listItem"&&(e=f.parentElement.tagName);const P=u.state.selection.content(),{dom:I,text:A}=ra(u,P);d.dataTransfer.clearData(),d.dataTransfer.setData("text/html",I.innerHTML),d.dataTransfer.setData("text/plain",A),d.dataTransfer.effectAllowed="copyMove",d.dataTransfer.setDragImage(f,0,0),u.dragging={slice:P,move:d.ctrlKey}}let o=null;function s(){o&&o.classList.add("hide")}function i(){o&&o.classList.remove("hide")}function l(d,u){const f=en(u,d),m=O.create(d.state.doc,f);d.dispatch(d.state.tr.setSelection(m)),d.focus(),t=!0}function a(d){if(t=d.state.selection instanceof O,t&&(o!=null&&o.dataset.nodePos)){const f=parseInt(o.dataset.nodePos,10);try{const m=d.state.doc.resolve(f);m&&m.parent&&m.parent.type.name!=="doc"||(t=!1,s())}catch{t=!1,s()}}t&&o&&!o.classList.contains("hide")?i():t||s()}function c(d){if(!(d.target instanceof Element))return;const u=d.relatedTarget;if(!u){t||s();return}const f=u.closest(".drag-handle")||u.classList.contains("drag-handle"),m=u.closest(".tiptap")||u.classList.contains("tiptap");!f&&!m&&!t&&s()}return new yi({key:new bi(n.pluginKey),view:d=>{var y,g,x,S;const u=n.dragHandleSelector?document.querySelector(n.dragHandleSelector):null;o=u??document.createElement("div"),o.draggable=!0,o.dataset.dragHandle="",o.classList.add("drag-handle");function f(E){r(E,d)}o.addEventListener("dragstart",f);function m(E){u||(E.preventDefault(),E.stopPropagation());const k=o==null?void 0:o.dataset.nodePos;k&&l(d,parseInt(k,10))}o.addEventListener("click",m);function p(E){s();const k=window.scrollY;E.clientY<n.scrollTreshold?window.scrollTo({top:k-30,behavior:"smooth"}):window.innerHeight-E.clientY<n.scrollTreshold&&window.scrollTo({top:k+30,behavior:"smooth"})}return o.addEventListener("drag",p),s(),u||(g=(y=d==null?void 0:d.dom)==null?void 0:y.parentElement)==null||g.appendChild(o),(S=(x=d==null?void 0:d.dom)==null?void 0:x.parentElement)==null||S.addEventListener("mouseout",c),{destroy:()=>{var E,k,P;u||(E=o==null?void 0:o.remove)==null||E.call(o),o==null||o.removeEventListener("drag",p),o==null||o.removeEventListener("dragstart",f),o==null||o.removeEventListener("click",m),o=null,(P=(k=d==null?void 0:d.dom)==null?void 0:k.parentElement)==null||P.removeEventListener("mouseout",c)}}},props:{handleDOMEvents:{mousemove:(d,u)=>{if(!d.editable)return;const f=ns({x:u.clientX+50+n.dragHandleWidth,y:u.clientY},n),m=f==null?void 0:f.closest(".not-draggable"),p=n.excludedTags.concat(["ol","ul"]).join(", ");if(!(f instanceof Element)||f.matches(p)||m){t||s();return}const y=rs(f,d,n);y!=null&&y>=0&&(o.dataset.nodePos=String(en(y,d)));const g=window.getComputedStyle(f),x=parseInt(g.lineHeight,10),S=isNaN(x)?parseInt(g.fontSize)*1.2:x,E=parseInt(g.paddingTop,10),k=oa(f);k.top+=(S-24)/2,k.top+=E,f.matches("ul:not([data-type=taskList]) li, ol li")&&(k.left-=n.dragHandleWidth-28),k.width=n.dragHandleWidth,o&&(o.style.position="absolute",o.style.left=`${k.left-k.width}px`,o.style.top=`${k.top}px`,i())},keydown:()=>{t||s()},mousewheel:()=>{t||s()},selectionChange:d=>{a(d)},dragstart:d=>{d.dom.classList.add("dragging")},drop:(d,u)=>{var g;d.dom.classList.remove("dragging"),s();let f=null;const m=d.posAtCoords({left:u.clientX,top:u.clientY});if(!m||(d.state.selection instanceof O&&(f=d.state.selection.node),!f))return;const y=d.state.doc.resolve(m.pos).parent.type.name==="listItem";if(d.state.selection instanceof O&&d.state.selection.node.type.name==="listItem"&&!y&&e=="OL"){const x=(g=d.state.schema.nodes.orderedList)==null?void 0:g.createAndFill(null,f),S=new L(z.from(x),0,0);d.dragging={slice:S,move:u.ctrlKey}}},dragend:d=>{d.dom.classList.remove("dragging")}}},state:{init(){return{}},apply(d,u,f,m){if(d.docChanged&&o&&o.dataset.nodePos){const p=parseInt(o.dataset.nodePos,10);try{const y=m.doc.resolve(p);(!y||y.parent.type.name==="doc")&&(t=!1,s())}catch{t=!1,s()}}return u}}})}const ia=vs.Extension.create({name:"globalDragHandle",addOptions(){return{dragHandleWidth:20,scrollTreshold:100,excludedTags:[],customNodes:[]}},addProseMirrorPlugins(){return[sa({pluginKey:"globalDragHandle",dragHandleWidth:this.options.dragHandleWidth,scrollTreshold:this.options.scrollTreshold,dragHandleSelector:this.options.dragHandleSelector,excludedTags:this.options.excludedTags,customNodes:this.options.customNodes})]}}),la=N.AIHighlight,aa=N.Placeholder.configure({placeholder:"撰写任何内容,或者按“/”输入命令..."}),ca=N.TiptapLink.configure({HTMLAttributes:{class:le.cx("text-muted-foreground underline underline-offset-[3px] hover:text-primary transition-colors cursor-pointer")}}),da=N.TiptapImage.extend({addProseMirrorPlugins(){return[N.UploadImagesPlugin({imageClass:le.cx("opacity-40 rounded-lg border border-stone-200")})]}}).configure({allowBase64:!0,HTMLAttributes:{class:le.cx("rounded-lg border border-muted")}}),ha=N.UpdatedImage.configure({HTMLAttributes:{class:le.cx("rounded-lg border border-muted")}}),ua=N.TaskList.configure({HTMLAttributes:{class:le.cx("not-prose pl-2 ")}}),fa=N.TaskItem.configure({HTMLAttributes:{class:le.cx("flex gap-2 items-start my-4")},nested:!0}),pa=N.HorizontalRule.configure({HTMLAttributes:{class:le.cx("mt-4 mb-6 border-t border-muted-foreground")}}),ma=N.StarterKit.configure({bulletList:{HTMLAttributes:{class:le.cx("list-disc list-outside leading-3 -mt-2")}},orderedList:{HTMLAttributes:{class:le.cx("list-decimal list-outside leading-3 -mt-2")}},listItem:{HTMLAttributes:{class:le.cx("leading-normal -mb-2")}},blockquote:{HTMLAttributes:{class:le.cx("border-l-4 border-primary")}},codeBlock:{HTMLAttributes:{class:le.cx("rounded-md bg-muted text-muted-foreground border p-5 font-mono font-medium")}},code:{HTMLAttributes:{class:le.cx("rounded-md bg-muted px-1.5 py-1 font-mono font-medium"),spellcheck:"false"}},horizontalRule:!1,dropcursor:{color:"#DBEAFE",width:4},gapcursor:!1}),ga=N.CodeBlockLowlight.configure({lowlight:tr.createLowlight(tr.common)}),ya=N.Mathematics.configure({HTMLAttributes:{class:le.cx("text-foreground rounded p-1 hover:bg-accent cursor-pointer")},katexOptions:{throwOnError:!1}}),ba=N.CharacterCount.configure(),xa=Ms.Markdown.configure({html:!0,tightLists:!0,tightListClass:"tight",bulletListMarker:"-",linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}),ka=ia.configure({dragHandleWidth:56,dragHandleSelector:".custom-drag-handle"}),os=[ma,aa,ca,da,ha,ua,fa,pa,la,ga,ya,ba,N.TiptapUnderline,xa,N.HighlightExtension,N.TextStyle,N.Color,N.CustomKeymap,ka],Sa=kt.Root,ss=kt.Trigger,tn=ne.forwardRef(({className:n,align:e="center",sideOffset:t=4,...r},o)=>h.jsx(kt.Portal,{children:h.jsx(kt.Content,{ref:o,align:e,sideOffset:t,className:b.cx("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...r})}));tn.displayName=kt.Content.displayName;const Ca=le.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-7 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Se=ne.forwardRef(({className:n,variant:e,size:t,asChild:r=!1,...o},s)=>{const i=r?Is.Slot:"button";return h.jsx(i,{className:b.cx(Ca({variant:e,size:t,className:n})),ref:s,...o})});Se.displayName="Button";const is=[{name:"默认",color:"var(--novel-black)"},{name:"紫色",color:"#9333EA"},{name:"红色",color:"#E00000"},{name:"黄色",color:"#EAB308"},{name:"蓝色",color:"#2563EB"},{name:"绿色",color:"#008A00"},{name:"橙色",color:"#FFA500"},{name:"粉色",color:"#BA4081"},{name:"灰色",color:"#A8A29E"}],ls=[{name:"默认背景",color:"var(--novel-highlight-default)"},{name:"紫色背景",color:"var(--novel-highlight-purple)"},{name:"红色背景",color:"var(--novel-highlight-red)"},{name:"黄色背景",color:"var(--novel-highlight-yellow)"},{name:"蓝色背景",color:"var(--novel-highlight-blue)"},{name:"绿色背景",color:"var(--novel-highlight-green)"},{name:"橙色背景",color:"var(--novel-highlight-orange)"},{name:"粉色背景",color:"var(--novel-highlight-pink)"},{name:"灰色背景",color:"var(--novel-highlight-gray)"}],st=n=>h.jsx(Qn,{classNames:{root:b.css`
|
|
668
668
|
background-color: transparent;
|
|
669
669
|
padding: 0;
|
|
670
670
|
.rc-tooltip-content {
|
|
671
671
|
border: none;
|
|
672
672
|
}
|
|
673
|
-
`,body:"!p-2 !rounded-md !bg-background !border !border-muted !text-secondary-foreground"},showArrow:!1,...n}),Na=({open:n,onOpenChange:e})=>{const{editor:t}=N.useEditor();if(!t)return null;const r=is.find(({color:s})=>t.isActive("textStyle",{color:s})),o=ls.find(({color:s})=>t.isActive("highlight",{color:s}));return h.jsxs(Sa,{modal:!0,open:n,onOpenChange:e,children:[h.jsx(st,{overlay:"文本颜色",placement:"top",children:h.jsx(ss,{asChild:!0,children:h.jsxs(Se,{size:"sm",className:"gap-1 rounded-md pr-0",variant:"ghost",children:[h.jsx("span",{className:"rounded-sm px-1",style:{color:r==null?void 0:r.color,backgroundColor:o==null?void 0:o.color},children:"A"}),h.jsx(w.RiArrowDropDownLine,{})]})})}),h.jsxs(tn,{sideOffset:5,className:"my-1 flex max-h-80 w-48 flex-col overflow-hidden overflow-y-auto rounded border p-1 shadow-xl ",align:"start",children:[h.jsxs("div",{className:"flex flex-col",children:[h.jsx("div",{className:"my-1 px-2 text-sm font-semibold text-muted-foreground",children:"颜色"}),is.map(({name:s,color:i})=>h.jsxs(N.EditorBubbleItem,{onSelect:()=>{t.commands.unsetColor(),s!=="Default"&&t.chain().focus().setColor(i||"").run(),e(!1)},className:"flex cursor-pointer items-center justify-between px-2 py-1 text-sm hover:bg-accent",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"rounded-sm border px-2 py-px font-medium",style:{color:i},children:"A"}),h.jsx("span",{children:s})]}),t.isActive("textStyle",{color:i})&&h.jsx(w.RiCheckLine,{size:14})]},s))]}),h.jsxs("div",{children:[h.jsx("div",{className:"my-1 px-2 text-sm font-semibold text-muted-foreground",children:"背景 "}),ls.map(({name:s,color:i})=>h.jsxs(N.EditorBubbleItem,{onSelect:()=>{t.commands.unsetHighlight(),s!=="Default"&&t.chain().focus().setHighlight({color:i}).run(),e(!1)},className:"flex cursor-pointer items-center justify-between px-2 py-1 text-sm hover:bg-accent",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"rounded-sm border px-2 py-px font-medium",style:{backgroundColor:i},children:"A"}),h.jsx("span",{children:s})]}),t.isActive("highlight",{color:i})&&h.jsx(w.RiCheckLine,{size:14})]},s))]})]})]})};function wa(n){try{return new URL(n),!0}catch{return!1}}function Da(n){if(wa(n))return n;try{if(n.includes(".")&&!n.includes(" "))return new URL(`https://${n}`).toString()}catch{return null}}const Ta=({open:n,onOpenChange:e})=>{const t=D.useRef(null),{editor:r}=N.useEditor();return D.useEffect(()=>{var o;(o=t.current)==null||o.focus()}),r?h.jsxs(Ft.Popover,{modal:!0,open:n,onOpenChange:e,children:[h.jsx(st,{overlay:"添加链接",placement:"top",children:h.jsx(Ft.PopoverTrigger,{asChild:!0,children:h.jsxs(Se,{size:"sm",variant:"ghost",className:"gap-2 rounded-md border-none",children:[h.jsx("p",{className:"text-base",children:h.jsx(w.RiLink,{size:16})}),h.jsx("p",{className:b.cx("underline decoration-stone-400 underline-offset-4",{"text-blue-500":r.isActive("link")}),children:"链接 "})]})})}),h.jsx(tn,{align:"start",className:"w-60 p-0",sideOffset:10,children:h.jsxs("form",{onSubmit:o=>{const s=o.currentTarget;o.preventDefault();const i=s[0],l=Da(i.value);l&&(r.chain().focus().setLink({href:l}).run(),e(!1))},className:"flex p-1 ",children:[h.jsx("input",{ref:t,type:"text",placeholder:"粘贴链接",className:"flex-1 bg-background p-1 text-sm outline-none",defaultValue:r.getAttributes("link").href||""}),r.getAttributes("link").href?h.jsx(Se,{size:"icon",variant:"outline",type:"button",className:"flex h-8 items-center rounded-sm p-1 text-red-600 transition-all hover:bg-red-100 dark:hover:bg-red-800",onClick:()=>{r.chain().focus().unsetLink().run(),t.current.value="",e(!1)},children:h.jsx(w.RiDeleteBinLine,{className:"h-4 w-4"})}):h.jsx(Se,{size:"icon",className:"h-8",children:h.jsx(w.RiCheckLine,{className:"h-4 w-4"})})]})})]}):null},Oa=()=>{const{editor:n}=N.useEditor();return n?h.jsx(st,{overlay:"标记为公式",placement:"top",children:h.jsx(Se,{variant:"ghost",size:"sm",className:"rounded-md w-12",onClick:()=>{if(n.isActive("math"))n.chain().focus().unsetLatex().run();else{const{from:e,to:t}=n.state.selection,r=n.state.doc.textBetween(e,t);if(!r)return;n.chain().focus().setLatex({latex:r}).run()}},children:h.jsx(te.SigmaIcon,{className:b.cx("size-4",{"text-blue-500":n.isActive("math")}),strokeWidth:2.3})})}):null},Un=[{name:"正文",icon:w.RiText,command:n=>n.chain().focus().clearNodes().run(),isActive:n=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"标题 1",icon:w.RiH1,command:n=>n.chain().focus().clearNodes().toggleHeading({level:1}).run(),isActive:n=>n.isActive("heading",{level:1})},{name:"标题 2",icon:w.RiH2,command:n=>n.chain().focus().clearNodes().toggleHeading({level:2}).run(),isActive:n=>n.isActive("heading",{level:2})},{name:"标题 3",icon:w.RiH3,command:n=>n.chain().focus().clearNodes().toggleHeading({level:3}).run(),isActive:n=>n.isActive("heading",{level:3})},{name:"待办列表",icon:w.RiListCheck,command:n=>n.chain().focus().clearNodes().toggleTaskList().run(),isActive:n=>n.isActive("taskItem")},{name:"无序列表",icon:w.RiListUnordered,command:n=>n.chain().focus().clearNodes().toggleBulletList().run(),isActive:n=>n.isActive("bulletList")},{name:"有序列表",icon:w.RiListOrdered,command:n=>n.chain().focus().clearNodes().toggleOrderedList().run(),isActive:n=>n.isActive("orderedList")},{name:"引用",icon:w.RiQuoteText,command:n=>n.chain().focus().clearNodes().toggleBlockquote().run(),isActive:n=>n.isActive("blockquote")},{name:"代码块",icon:w.RiCodeLine,command:n=>n.chain().focus().clearNodes().toggleCodeBlock().run(),isActive:n=>n.isActive("codeBlock")}],Ma=({open:n,onOpenChange:e})=>{const{editor:t}=N.useEditor();if(!t)return null;const r=Un.filter(o=>o.isActive(t)).pop()??{name:"多个选中"};return h.jsxs(Ft.Popover,{modal:!0,open:n,onOpenChange:e,children:[h.jsx(st,{overlay:"转换成",placement:"top",children:h.jsx(ss,{asChild:!0,className:"rounded-md border-none hover:bg-accent focus:ring-0 pr-0",children:h.jsxs(Se,{size:"sm",variant:"ghost",children:[h.jsx("span",{className:"whitespace-nowrap text-sm",children:r.name}),h.jsx(w.RiArrowDropDownLine,{})]})})}),h.jsxs(tn,{sideOffset:5,align:"start",className:"w-48 p-1",children:[h.jsx("p",{className:"mb-2 text-sm text-secondary-foreground",children:"转换成"})," ",Un.map(o=>h.jsxs(N.EditorBubbleItem,{onSelect:s=>{o.command(s),e(!1)},className:"flex cursor-pointer items-center justify-between rounded-sm px-2 py-1 text-sm hover:bg-accent",children:[h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsx("div",{className:"rounded-sm border p-1",children:h.jsx(o.icon,{className:"h-3 w-3"})}),h.jsx("span",{children:o.name})]}),r.name===o.name&&h.jsx(w.RiCheckLine,{size:14})]},o.name))]})]})},gt=ne.forwardRef(({className:n,orientation:e="horizontal",decorative:t=!0,...r},o)=>h.jsx(nr.Root,{ref:o,decorative:t,orientation:e,className:b.cx("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":" w-[1px]",n),...r}));gt.displayName=nr.Root.displayName;const va=()=>h.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[h.jsx("div",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-purple-500 [animation-delay:-0.3s]"}),h.jsx("div",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-purple-500 [animation-delay:-0.15s]"}),h.jsx("div",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-purple-500"})]}),as=ne.forwardRef(({className:n,children:e,...t},r)=>h.jsxs(Xe.Root,{ref:r,className:b.cx("relative overflow-hidden",n),...t,children:[h.jsx(Xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:e}),h.jsx(cs,{}),h.jsx(Xe.Corner,{})]}));as.displayName=Xe.Root.displayName;const cs=ne.forwardRef(({className:n,orientation:e="vertical",...t},r)=>h.jsx(Xe.ScrollAreaScrollbar,{ref:r,orientation:e,className:b.cx("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...t,children:h.jsx(Xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));cs.displayName=Xe.ScrollAreaScrollbar.displayName;const Ia=we.Portal,ds=ne.forwardRef(({className:n,...e},t)=>h.jsx(we.Overlay,{ref:t,className:b.cx("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));ds.displayName=we.Overlay.displayName;const Ea=ne.forwardRef(({className:n,children:e,...t},r)=>h.jsxs(Ia,{children:[h.jsx(ds,{}),h.jsxs(we.Content,{ref:r,className:b.cx("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...t,children:[e,h.jsxs(we.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(te.X,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ea.displayName=we.Content.displayName;const Aa=ne.forwardRef(({className:n,...e},t)=>h.jsx(we.Title,{ref:t,className:b.cx("text-lg font-semibold leading-none tracking-tight",n),...e}));Aa.displayName=we.Title.displayName;const Pa=ne.forwardRef(({className:n,...e},t)=>h.jsx(we.Description,{ref:t,className:b.cx("text-sm text-muted-foreground",n),...e}));Pa.displayName=we.Description.displayName;const hs=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command,{ref:t,className:b.cx("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",n),...e}));hs.displayName=he.Command.displayName;const us=ne.forwardRef(({className:n,...e},t)=>h.jsxs("div",{className:"flex items-center border-b px-4","cmdk-input-wrapper":"",children:[h.jsx(w.RiSparklingFill,{size:14,className:"mr-2 shrink-0 text-purple-500 "}),h.jsx(he.Command.Input,{ref:t,className:b.cx("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",n),...e})]}));us.displayName=he.Command.Input.displayName;const za=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.List,{ref:t,className:b.cx("max-h-[300px] overflow-y-auto overflow-x-hidden",n),...e}));za.displayName=he.Command.List.displayName;const Ba=ne.forwardRef((n,e)=>h.jsx(he.Command.Empty,{ref:e,className:"py-6 text-center text-sm",...n}));Ba.displayName=he.Command.Empty.displayName;const Lt=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.Group,{ref:t,className:b.cx("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",n),...e}));Lt.displayName=he.Command.Group.displayName;const jn=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.Separator,{ref:t,className:b.cx("-mx-1 h-px bg-border",n),...e}));jn.displayName=he.Command.Separator.displayName;const yt=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.Item,{ref:t,className:b.cx("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled='true']:pointer-events-none data-[disabled='true']:opacity-50",n),...e}));yt.displayName=he.Command.Item.displayName;const La=({completion:n,onDiscard:e})=>{const{editor:t}=N.useEditor();return h.jsxs(h.Fragment,{children:[h.jsxs(Lt,{children:[h.jsxs(yt,{className:"gap-2 px-4",value:"replace",onSelect:()=>{const r=t.view.state.selection;t.chain().focus().insertContentAt({from:r.from,to:r.to},n).run()},children:[h.jsx(te.Check,{className:"h-4 w-4 text-muted-foreground"}),"替换选择"]}),h.jsxs(yt,{className:"gap-2 px-4",value:"insert",onSelect:()=>{const r=t.view.state.selection;t.chain().focus().insertContentAt(r.to+1,n).run()},children:[h.jsx(te.TextQuote,{className:"h-4 w-4 text-muted-foreground"}),"在下面插入"]})]}),h.jsx(jn,{}),h.jsx(Lt,{children:h.jsxs(yt,{onSelect:e,value:"thrash",className:"gap-2 px-4",children:[h.jsx(te.TrashIcon,{className:"h-4 w-4 text-muted-foreground"}),"丢弃"]})})]})},Fa=[{value:"improve",label:"改进写作",icon:te.RefreshCcwDot},{value:"fix",label:"修正语法",icon:te.CheckCheck},{value:"shorter",label:"缩短文本",icon:te.ArrowDownWideNarrow},{value:"longer",label:"扩展文本",icon:te.WrapText}],Va=({onSelect:n})=>{const{editor:e}=N.useEditor();return h.jsxs(h.Fragment,{children:[h.jsxs(Lt,{heading:"编辑或校对选中文本",children:[" ",Fa.map(t=>h.jsxs(yt,{onSelect:r=>{const o=e.state.selection.content(),s=e.storage.markdown.serializer.serialize(o.content);n(s,r)},className:"flex gap-2 px-4",value:t.value,children:[h.jsx(t.icon,{className:"h-4 w-4 text-purple-500"}),t.label]},t.value))]}),h.jsx(jn,{}),h.jsxs(Lt,{heading:"使用 AI 完成更多",children:[" ",h.jsxs(yt,{onSelect:()=>{const t=e.state.selection.from,r=N.getPrevText(e,t);n(r,"continue")},value:"continue",className:"gap-2 px-4",children:[h.jsx(te.StepForward,{className:"h-4 w-4 text-purple-500"}),"继续写作"]})]})]})};function $a({onOpenChange:n,options:e}){const{editor:t}=N.useEditor(),[r,o]=D.useState(""),{completion:s,complete:i,isLoading:l}=As.useCompletion({api:"/api/generate",onResponse:c=>{if(c.status===429){bt.toast.error("You have reached your request limit for the day.");return}},onError:c=>{bt.toast.error(c.message)},...e}),a=s.length>0;return h.jsxs(hs,{className:"w-[350px]",children:[a&&h.jsx("div",{className:"flex max-h-[400px]",children:h.jsx(as,{children:h.jsx("div",{className:"prose p-2 px-4 prose-sm",children:h.jsx(er,{children:s})})})}),l&&h.jsxs("div",{className:"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-purple-500",children:[h.jsx(w.RiSparklingFill,{size:14,className:"mr-2 shrink-0"}),"AI正在思考",h.jsx("div",{className:"ml-2 mt-1",children:h.jsx(va,{})})]}),!l&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"relative",children:[h.jsx(us,{value:r,onValueChange:o,autoFocus:!0,placeholder:a?"告诉AI下一步该怎么做":"要求AI编辑或生成……",onFocus:()=>N.addAIHighlight(t)}),h.jsx(Se,{size:"icon",className:"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-purple-500 hover:bg-purple-900",onClick:()=>{if(s)return i(s,{body:{option:"zap",command:r}}).then(()=>o(""));const c=t.state.selection.content(),d=t.storage.markdown.serializer.serialize(c.content);i(d,{body:{option:"zap",command:r}}).then(()=>o(""))},children:h.jsx(te.ArrowUp,{className:"h-4 w-4"})})]}),a?h.jsx(La,{onDiscard:()=>{t.chain().unsetHighlight().focus().run(),n(!1)},completion:s}):h.jsx(Va,{onSelect:(c,d)=>i(c,{body:{option:d}})})]})]})}const qa=({children:n,open:e,onOpenChange:t,enableAI:r=!1,aiOptions:o})=>{const{editor:s}=N.useEditor();return D.useEffect(()=>{e||N.removeAIHighlight(s)},[e]),h.jsxs(N.EditorBubble,{tippyOptions:{placement:e?"bottom-start":"top",onHidden:()=>{t(!1),s.chain().unsetHighlight().run()}},className:"flex w-fit max-w-[90vw] overflow-hidden rounded-lg border border-muted bg-background shadow-xl p-1 gap-1",children:[e&&r&&h.jsx($a,{open:e,onOpenChange:t,options:o}),!e&&h.jsxs(D.Fragment,{children:[r&&h.jsxs(Se,{className:"gap-1 text-purple-500",variant:"ghost",onClick:()=>t(!0),size:"sm",children:[h.jsx(w.RiSparklingFill,{size:14}),"询问AI"]}),n]})]})},Ha=n=>{const e=fetch("/api/upload",{method:"POST",headers:{"content-type":(n==null?void 0:n.type)||"application/octet-stream","x-vercel-filename":(n==null?void 0:n.name)||"image.png"},body:n});return new Promise((t,r)=>{bt.toast.promise(e.then(async o=>{if(o.status===200){const{url:s}=await o.json(),i=new Image;i.src=s,i.onload=()=>{t(s)}}else throw o.status===401?(t(n),new Error("`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead.")):new Error("Error uploading image. Please try again.")}),{loading:"Uploading image...",success:"Image uploaded successfully.",error:o=>(r(o),o.message)})})},Wa=N.createImageUpload({onUpload:Ha,validateFn:n=>n.type.includes("image/")?n.size/1024/1024>20?(bt.toast.error("File size too big (max 20MB)."),!1):!0:(bt.toast.error("File type not supported."),!1)}),Ja=()=>{const{editor:n}=N.useEditor();if(!n)return null;const e=[{name:"粗体",isActive:t=>t.isActive("bold"),command:t=>t.chain().focus().toggleBold().run(),icon:te.BoldIcon},{name:"斜体",isActive:t=>t.isActive("italic"),command:t=>t.chain().focus().toggleItalic().run(),icon:te.ItalicIcon},{name:"下划线",isActive:t=>t.isActive("underline"),command:t=>t.chain().focus().toggleUnderline().run(),icon:te.UnderlineIcon},{name:"删除线",isActive:t=>t.isActive("strike"),command:t=>t.chain().focus().toggleStrike().run(),icon:te.StrikethroughIcon},{name:"代码",isActive:t=>t.isActive("code"),command:t=>t.chain().focus().toggleCode().run(),icon:te.CodeIcon}];return h.jsx("div",{className:"flex",children:e.map(t=>h.jsx(N.EditorBubbleItem,{onSelect:r=>{t.command(r)},children:h.jsx(st,{overlay:t.name,placement:"top",children:h.jsx(Se,{size:"sm",className:"rounded-md",variant:"ghost",type:"button",children:h.jsx(t.icon,{className:b.cx("h-4 w-4",{"text-blue-500":t.isActive(n)})})})})},t.name))})},fs=({uploadFn:n})=>N.createSuggestionItems([{title:"文本",description:"从纯文本开始编写。",searchTerms:["p","paragraph"],icon:h.jsx(w.RiText,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"标题1",description:"大标题。",searchTerms:["title","big","large"],icon:h.jsx(w.RiH1,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"标题2",description:"中标题。",searchTerms:["subtitle","medium"],icon:h.jsx(w.RiH2,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"标题3",description:"小标题。",searchTerms:["subtitle","small"],icon:h.jsx(w.RiH3,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"待办清单",description:"使用待办清单追踪任务。",searchTerms:["todo","task","list","check","checkbox"],icon:h.jsx(w.RiListCheck,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"项目符号列表",description:"创建一个简单的项目符号列表。",searchTerms:["unordered","point"],icon:h.jsx(w.RiListUnordered,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"有序列表",description:"创建一个带有序号的列表。",searchTerms:["ordered"],icon:h.jsx(w.RiListOrdered,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"引用",description:"摘取引用。",searchTerms:["blockquote"],icon:h.jsx(w.RiQuoteText,{size:18}),command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"代码",description:"捕获代码段。",searchTerms:["codeblock"],icon:h.jsx(w.RiCodeLine,{size:18}),command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"图片",description:"从您的计算机上传图像。",searchTerms:["photo","picture","media"],icon:h.jsx(w.RiImageLine,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var o;if((o=r.files)!=null&&o.length){const s=r.files[0],i=e.view.state.selection.from;n(s,e.view,i)}},r.click()}}]),Ka=n=>N.Command.configure({suggestion:{items:()=>fs(n),render:N.renderItems}}),Ua={type:"doc",content:[]},ps=D.forwardRef(({children:n,items:e,...t},r)=>{const o=i=>h.jsxs(Vt.Item,{onClick:i.onClick,className:b.cx("gap-2 !p-1.5 text-sm hover:bg-accent focus:ring-0 rounded-md cursor-pointer",i.className),itemIcon:i.isActive?h.jsx(w.RiCheckLine,{size:16}):void 0,children:[i.icon,i.label,h.jsx("div",{className:"flex-1"})]},i.key),s=i=>{var l;return h.jsx(Vt.SubMenu,{expandIcon:h.jsx(w.RiArrowRightSLine,{size:16}),popupClassName:b.cx("!rounded-lg border border-muted bg-background shadow-xl !p-2 min-w-48 !m-0 z-[1080]",b.css`
|
|
673
|
+
`,body:"!p-2 !rounded-md !bg-background !border !border-muted !text-secondary-foreground"},showArrow:!1,...n}),Na=({open:n,onOpenChange:e})=>{const{editor:t}=N.useEditor();if(!t)return null;const r=is.find(({color:s})=>t.isActive("textStyle",{color:s})),o=ls.find(({color:s})=>t.isActive("highlight",{color:s}));return h.jsxs(Sa,{modal:!0,open:n,onOpenChange:e,children:[h.jsx(st,{overlay:"文本颜色",placement:"top",children:h.jsx(ss,{asChild:!0,children:h.jsxs(Se,{size:"sm",className:"gap-1 rounded-md pr-0",variant:"ghost",children:[h.jsx("span",{className:"rounded-sm px-1",style:{color:r==null?void 0:r.color,backgroundColor:o==null?void 0:o.color},children:"A"}),h.jsx(D.RiArrowDropDownLine,{})]})})}),h.jsxs(tn,{sideOffset:5,className:"my-1 flex max-h-80 w-48 flex-col overflow-hidden overflow-y-auto rounded border p-1 shadow-xl ",align:"start",children:[h.jsxs("div",{className:"flex flex-col",children:[h.jsx("div",{className:"my-1 px-2 text-sm font-semibold text-muted-foreground",children:"颜色"}),is.map(({name:s,color:i})=>h.jsxs(N.EditorBubbleItem,{onSelect:()=>{t.commands.unsetColor(),s!=="Default"&&t.chain().focus().setColor(i||"").run(),e(!1)},className:"flex cursor-pointer items-center justify-between px-2 py-1 text-sm hover:bg-accent",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"rounded-sm border px-2 py-px font-medium",style:{color:i},children:"A"}),h.jsx("span",{children:s})]}),t.isActive("textStyle",{color:i})&&h.jsx(D.RiCheckLine,{size:14})]},s))]}),h.jsxs("div",{children:[h.jsx("div",{className:"my-1 px-2 text-sm font-semibold text-muted-foreground",children:"背景 "}),ls.map(({name:s,color:i})=>h.jsxs(N.EditorBubbleItem,{onSelect:()=>{t.commands.unsetHighlight(),s!=="Default"&&t.chain().focus().setHighlight({color:i}).run(),e(!1)},className:"flex cursor-pointer items-center justify-between px-2 py-1 text-sm hover:bg-accent",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:"rounded-sm border px-2 py-px font-medium",style:{backgroundColor:i},children:"A"}),h.jsx("span",{children:s})]}),t.isActive("highlight",{color:i})&&h.jsx(D.RiCheckLine,{size:14})]},s))]})]})]})};function wa(n){try{return new URL(n),!0}catch{return!1}}function Da(n){if(wa(n))return n;try{if(n.includes(".")&&!n.includes(" "))return new URL(`https://${n}`).toString()}catch{return null}}const Ta=({open:n,onOpenChange:e})=>{const t=w.useRef(null),{editor:r}=N.useEditor();return w.useEffect(()=>{var o;(o=t.current)==null||o.focus()}),r?h.jsxs(Ft.Popover,{modal:!0,open:n,onOpenChange:e,children:[h.jsx(st,{overlay:"添加链接",placement:"top",children:h.jsx(Ft.PopoverTrigger,{asChild:!0,children:h.jsxs(Se,{size:"sm",variant:"ghost",className:"gap-2 rounded-md border-none",children:[h.jsx("p",{className:"text-base",children:h.jsx(D.RiLink,{size:16})}),h.jsx("p",{className:b.cx("underline decoration-stone-400 underline-offset-4",{"text-blue-500":r.isActive("link")}),children:"链接 "})]})})}),h.jsx(tn,{align:"start",className:"w-60 p-0",sideOffset:10,children:h.jsxs("form",{onSubmit:o=>{const s=o.currentTarget;o.preventDefault();const i=s[0],l=Da(i.value);l&&(r.chain().focus().setLink({href:l}).run(),e(!1))},className:"flex p-1 ",children:[h.jsx("input",{ref:t,type:"text",placeholder:"粘贴链接",className:"flex-1 bg-background p-1 text-sm outline-none",defaultValue:r.getAttributes("link").href||""}),r.getAttributes("link").href?h.jsx(Se,{size:"icon",variant:"outline",type:"button",className:"flex h-8 items-center rounded-sm p-1 text-red-600 transition-all hover:bg-red-100 dark:hover:bg-red-800",onClick:()=>{r.chain().focus().unsetLink().run(),t.current.value="",e(!1)},children:h.jsx(D.RiDeleteBinLine,{className:"h-4 w-4"})}):h.jsx(Se,{size:"icon",className:"h-8",children:h.jsx(D.RiCheckLine,{className:"h-4 w-4"})})]})})]}):null},Oa=()=>{const{editor:n}=N.useEditor();return n?h.jsx(st,{overlay:"标记为公式",placement:"top",children:h.jsx(Se,{variant:"ghost",size:"sm",className:"rounded-md w-12",onClick:()=>{if(n.isActive("math"))n.chain().focus().unsetLatex().run();else{const{from:e,to:t}=n.state.selection,r=n.state.doc.textBetween(e,t);if(!r)return;n.chain().focus().setLatex({latex:r}).run()}},children:h.jsx(te.SigmaIcon,{className:b.cx("size-4",{"text-blue-500":n.isActive("math")}),strokeWidth:2.3})})}):null},Un=[{name:"正文",icon:D.RiText,command:n=>n.chain().focus().clearNodes().run(),isActive:n=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"标题 1",icon:D.RiH1,command:n=>n.chain().focus().clearNodes().toggleHeading({level:1}).run(),isActive:n=>n.isActive("heading",{level:1})},{name:"标题 2",icon:D.RiH2,command:n=>n.chain().focus().clearNodes().toggleHeading({level:2}).run(),isActive:n=>n.isActive("heading",{level:2})},{name:"标题 3",icon:D.RiH3,command:n=>n.chain().focus().clearNodes().toggleHeading({level:3}).run(),isActive:n=>n.isActive("heading",{level:3})},{name:"待办列表",icon:D.RiListCheck,command:n=>n.chain().focus().clearNodes().toggleTaskList().run(),isActive:n=>n.isActive("taskItem")},{name:"无序列表",icon:D.RiListUnordered,command:n=>n.chain().focus().clearNodes().toggleBulletList().run(),isActive:n=>n.isActive("bulletList")},{name:"有序列表",icon:D.RiListOrdered,command:n=>n.chain().focus().clearNodes().toggleOrderedList().run(),isActive:n=>n.isActive("orderedList")},{name:"引用",icon:D.RiQuoteText,command:n=>n.chain().focus().clearNodes().toggleBlockquote().run(),isActive:n=>n.isActive("blockquote")},{name:"代码块",icon:D.RiCodeLine,command:n=>n.chain().focus().clearNodes().toggleCodeBlock().run(),isActive:n=>n.isActive("codeBlock")}],Ma=({open:n,onOpenChange:e})=>{const{editor:t}=N.useEditor();if(!t)return null;const r=Un.filter(o=>o.isActive(t)).pop()??{name:"多个选中"};return h.jsxs(Ft.Popover,{modal:!0,open:n,onOpenChange:e,children:[h.jsx(st,{overlay:"转换成",placement:"top",children:h.jsx(ss,{asChild:!0,className:"rounded-md border-none hover:bg-accent focus:ring-0 pr-0",children:h.jsxs(Se,{size:"sm",variant:"ghost",children:[h.jsx("span",{className:"whitespace-nowrap text-sm",children:r.name}),h.jsx(D.RiArrowDropDownLine,{})]})})}),h.jsxs(tn,{sideOffset:5,align:"start",className:"w-48 p-1",children:[h.jsx("p",{className:"mb-2 text-sm text-secondary-foreground",children:"转换成"})," ",Un.map(o=>h.jsxs(N.EditorBubbleItem,{onSelect:s=>{o.command(s),e(!1)},className:"flex cursor-pointer items-center justify-between rounded-sm px-2 py-1 text-sm hover:bg-accent",children:[h.jsxs("div",{className:"flex items-center space-x-2",children:[h.jsx("div",{className:"rounded-sm border p-1",children:h.jsx(o.icon,{className:"h-3 w-3"})}),h.jsx("span",{children:o.name})]}),r.name===o.name&&h.jsx(D.RiCheckLine,{size:14})]},o.name))]})]})},gt=ne.forwardRef(({className:n,orientation:e="horizontal",decorative:t=!0,...r},o)=>h.jsx(nr.Root,{ref:o,decorative:t,orientation:e,className:b.cx("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":" w-[1px]",n),...r}));gt.displayName=nr.Root.displayName;const va=()=>h.jsxs("div",{className:"flex items-center justify-center gap-0.5",children:[h.jsx("div",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-purple-500 [animation-delay:-0.3s]"}),h.jsx("div",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-purple-500 [animation-delay:-0.15s]"}),h.jsx("div",{className:"h-1.5 w-1.5 animate-bounce rounded-full bg-purple-500"})]}),as=ne.forwardRef(({className:n,children:e,...t},r)=>h.jsxs(Xe.Root,{ref:r,className:b.cx("relative overflow-hidden",n),...t,children:[h.jsx(Xe.Viewport,{className:"h-full w-full rounded-[inherit]",children:e}),h.jsx(cs,{}),h.jsx(Xe.Corner,{})]}));as.displayName=Xe.Root.displayName;const cs=ne.forwardRef(({className:n,orientation:e="vertical",...t},r)=>h.jsx(Xe.ScrollAreaScrollbar,{ref:r,orientation:e,className:b.cx("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...t,children:h.jsx(Xe.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));cs.displayName=Xe.ScrollAreaScrollbar.displayName;const Ia=we.Portal,ds=ne.forwardRef(({className:n,...e},t)=>h.jsx(we.Overlay,{ref:t,className:b.cx("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));ds.displayName=we.Overlay.displayName;const Ea=ne.forwardRef(({className:n,children:e,...t},r)=>h.jsxs(Ia,{children:[h.jsx(ds,{}),h.jsxs(we.Content,{ref:r,className:b.cx("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...t,children:[e,h.jsxs(we.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(te.X,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ea.displayName=we.Content.displayName;const Aa=ne.forwardRef(({className:n,...e},t)=>h.jsx(we.Title,{ref:t,className:b.cx("text-lg font-semibold leading-none tracking-tight",n),...e}));Aa.displayName=we.Title.displayName;const Pa=ne.forwardRef(({className:n,...e},t)=>h.jsx(we.Description,{ref:t,className:b.cx("text-sm text-muted-foreground",n),...e}));Pa.displayName=we.Description.displayName;const hs=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command,{ref:t,className:b.cx("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",n),...e}));hs.displayName=he.Command.displayName;const us=ne.forwardRef(({className:n,...e},t)=>h.jsxs("div",{className:"flex items-center border-b px-4","cmdk-input-wrapper":"",children:[h.jsx(D.RiSparklingFill,{size:14,className:"mr-2 shrink-0 text-purple-500 "}),h.jsx(he.Command.Input,{ref:t,className:b.cx("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",n),...e})]}));us.displayName=he.Command.Input.displayName;const za=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.List,{ref:t,className:b.cx("max-h-[300px] overflow-y-auto overflow-x-hidden",n),...e}));za.displayName=he.Command.List.displayName;const Ba=ne.forwardRef((n,e)=>h.jsx(he.Command.Empty,{ref:e,className:"py-6 text-center text-sm",...n}));Ba.displayName=he.Command.Empty.displayName;const Lt=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.Group,{ref:t,className:b.cx("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",n),...e}));Lt.displayName=he.Command.Group.displayName;const jn=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.Separator,{ref:t,className:b.cx("-mx-1 h-px bg-border",n),...e}));jn.displayName=he.Command.Separator.displayName;const yt=ne.forwardRef(({className:n,...e},t)=>h.jsx(he.Command.Item,{ref:t,className:b.cx("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled='true']:pointer-events-none data-[disabled='true']:opacity-50",n),...e}));yt.displayName=he.Command.Item.displayName;const La=({completion:n,onDiscard:e})=>{const{editor:t}=N.useEditor();return h.jsxs(h.Fragment,{children:[h.jsxs(Lt,{children:[h.jsxs(yt,{className:"gap-2 px-4",value:"replace",onSelect:()=>{const r=t.view.state.selection;t.chain().focus().insertContentAt({from:r.from,to:r.to},n).run()},children:[h.jsx(te.Check,{className:"h-4 w-4 text-muted-foreground"}),"替换选择"]}),h.jsxs(yt,{className:"gap-2 px-4",value:"insert",onSelect:()=>{const r=t.view.state.selection;t.chain().focus().insertContentAt(r.to+1,n).run()},children:[h.jsx(te.TextQuote,{className:"h-4 w-4 text-muted-foreground"}),"在下面插入"]})]}),h.jsx(jn,{}),h.jsx(Lt,{children:h.jsxs(yt,{onSelect:e,value:"thrash",className:"gap-2 px-4",children:[h.jsx(te.TrashIcon,{className:"h-4 w-4 text-muted-foreground"}),"丢弃"]})})]})},Fa=[{value:"improve",label:"改进写作",icon:te.RefreshCcwDot},{value:"fix",label:"修正语法",icon:te.CheckCheck},{value:"shorter",label:"缩短文本",icon:te.ArrowDownWideNarrow},{value:"longer",label:"扩展文本",icon:te.WrapText}],Va=({onSelect:n})=>{const{editor:e}=N.useEditor();return h.jsxs(h.Fragment,{children:[h.jsxs(Lt,{heading:"编辑或校对选中文本",children:[" ",Fa.map(t=>h.jsxs(yt,{onSelect:r=>{const o=e.state.selection.content(),s=e.storage.markdown.serializer.serialize(o.content);n(s,r)},className:"flex gap-2 px-4",value:t.value,children:[h.jsx(t.icon,{className:"h-4 w-4 text-purple-500"}),t.label]},t.value))]}),h.jsx(jn,{}),h.jsxs(Lt,{heading:"使用 AI 完成更多",children:[" ",h.jsxs(yt,{onSelect:()=>{const t=e.state.selection.from,r=N.getPrevText(e,t);n(r,"continue")},value:"continue",className:"gap-2 px-4",children:[h.jsx(te.StepForward,{className:"h-4 w-4 text-purple-500"}),"继续写作"]})]})]})};function $a({onOpenChange:n,options:e}){const{editor:t}=N.useEditor(),[r,o]=w.useState(""),{completion:s,complete:i,isLoading:l}=As.useCompletion({api:"/api/generate",onResponse:c=>{if(c.status===429){bt.toast.error("You have reached your request limit for the day.");return}},onError:c=>{bt.toast.error(c.message)},...e}),a=s.length>0;return h.jsxs(hs,{className:"w-[350px]",children:[a&&h.jsx("div",{className:"flex max-h-[400px]",children:h.jsx(as,{children:h.jsx("div",{className:"prose p-2 px-4 prose-sm",children:h.jsx(er,{children:s})})})}),l&&h.jsxs("div",{className:"flex h-12 w-full items-center px-4 text-sm font-medium text-muted-foreground text-purple-500",children:[h.jsx(D.RiSparklingFill,{size:14,className:"mr-2 shrink-0"}),"AI正在思考",h.jsx("div",{className:"ml-2 mt-1",children:h.jsx(va,{})})]}),!l&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"relative",children:[h.jsx(us,{value:r,onValueChange:o,autoFocus:!0,placeholder:a?"告诉AI下一步该怎么做":"要求AI编辑或生成……",onFocus:()=>N.addAIHighlight(t)}),h.jsx(Se,{size:"icon",className:"absolute right-2 top-1/2 h-6 w-6 -translate-y-1/2 rounded-full bg-purple-500 hover:bg-purple-900",onClick:()=>{if(s)return i(s,{body:{option:"zap",command:r}}).then(()=>o(""));const c=t.state.selection.content(),d=t.storage.markdown.serializer.serialize(c.content);i(d,{body:{option:"zap",command:r}}).then(()=>o(""))},children:h.jsx(te.ArrowUp,{className:"h-4 w-4"})})]}),a?h.jsx(La,{onDiscard:()=>{t.chain().unsetHighlight().focus().run(),n(!1)},completion:s}):h.jsx(Va,{onSelect:(c,d)=>i(c,{body:{option:d}})})]})]})}const qa=({children:n,open:e,onOpenChange:t,enableAI:r=!1,aiOptions:o})=>{const{editor:s}=N.useEditor();return w.useEffect(()=>{e||N.removeAIHighlight(s)},[e]),h.jsxs(N.EditorBubble,{tippyOptions:{placement:e?"bottom-start":"top",onHidden:()=>{t(!1),s.chain().unsetHighlight().run()}},className:"flex w-fit max-w-[90vw] overflow-hidden rounded-lg border border-muted bg-background shadow-xl p-1 gap-1",children:[e&&r&&h.jsx($a,{open:e,onOpenChange:t,options:o}),!e&&h.jsxs(w.Fragment,{children:[r&&h.jsxs(Se,{className:"gap-1 text-purple-500",variant:"ghost",onClick:()=>t(!0),size:"sm",children:[h.jsx(D.RiSparklingFill,{size:14}),"询问AI"]}),n]})]})},Ha=n=>{const e=fetch("/api/upload",{method:"POST",headers:{"content-type":(n==null?void 0:n.type)||"application/octet-stream","x-vercel-filename":(n==null?void 0:n.name)||"image.png"},body:n});return new Promise((t,r)=>{bt.toast.promise(e.then(async o=>{if(o.status===200){const{url:s}=await o.json(),i=new Image;i.src=s,i.onload=()=>{t(s)}}else throw o.status===401?(t(n),new Error("`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead.")):new Error("Error uploading image. Please try again.")}),{loading:"Uploading image...",success:"Image uploaded successfully.",error:o=>(r(o),o.message)})})},Wa=N.createImageUpload({onUpload:Ha,validateFn:n=>n.type.includes("image/")?n.size/1024/1024>20?(bt.toast.error("File size too big (max 20MB)."),!1):!0:(bt.toast.error("File type not supported."),!1)}),Ja=()=>{const{editor:n}=N.useEditor();if(!n)return null;const e=[{name:"粗体",isActive:t=>t.isActive("bold"),command:t=>t.chain().focus().toggleBold().run(),icon:te.BoldIcon},{name:"斜体",isActive:t=>t.isActive("italic"),command:t=>t.chain().focus().toggleItalic().run(),icon:te.ItalicIcon},{name:"下划线",isActive:t=>t.isActive("underline"),command:t=>t.chain().focus().toggleUnderline().run(),icon:te.UnderlineIcon},{name:"删除线",isActive:t=>t.isActive("strike"),command:t=>t.chain().focus().toggleStrike().run(),icon:te.StrikethroughIcon},{name:"代码",isActive:t=>t.isActive("code"),command:t=>t.chain().focus().toggleCode().run(),icon:te.CodeIcon}];return h.jsx("div",{className:"flex",children:e.map(t=>h.jsx(N.EditorBubbleItem,{onSelect:r=>{t.command(r)},children:h.jsx(st,{overlay:t.name,placement:"top",children:h.jsx(Se,{size:"sm",className:"rounded-md",variant:"ghost",type:"button",children:h.jsx(t.icon,{className:b.cx("h-4 w-4",{"text-blue-500":t.isActive(n)})})})})},t.name))})},fs=({uploadFn:n})=>N.createSuggestionItems([{title:"文本",description:"从纯文本开始编写。",searchTerms:["p","paragraph"],icon:h.jsx(D.RiText,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"标题1",description:"大标题。",searchTerms:["title","big","large"],icon:h.jsx(D.RiH1,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"标题2",description:"中标题。",searchTerms:["subtitle","medium"],icon:h.jsx(D.RiH2,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"标题3",description:"小标题。",searchTerms:["subtitle","small"],icon:h.jsx(D.RiH3,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"待办清单",description:"使用待办清单追踪任务。",searchTerms:["todo","task","list","check","checkbox"],icon:h.jsx(D.RiListCheck,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"项目符号列表",description:"创建一个简单的项目符号列表。",searchTerms:["unordered","point"],icon:h.jsx(D.RiListUnordered,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"有序列表",description:"创建一个带有序号的列表。",searchTerms:["ordered"],icon:h.jsx(D.RiListOrdered,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"引用",description:"摘取引用。",searchTerms:["blockquote"],icon:h.jsx(D.RiQuoteText,{size:18}),command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"代码",description:"捕获代码段。",searchTerms:["codeblock"],icon:h.jsx(D.RiCodeLine,{size:18}),command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"图片",description:"从您的计算机上传图像。",searchTerms:["photo","picture","media"],icon:h.jsx(D.RiImageLine,{size:18}),command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var o;if((o=r.files)!=null&&o.length){const s=r.files[0],i=e.view.state.selection.from;n(s,e.view,i)}},r.click()}}]),Ka=n=>N.Command.configure({suggestion:{items:()=>fs(n),render:N.renderItems}}),Ua={type:"doc",content:[]},ps=w.forwardRef(({children:n,items:e,...t},r)=>{const o=i=>h.jsxs(Vt.Item,{onClick:i.onClick,className:b.cx("gap-2 !p-1.5 text-sm hover:bg-accent focus:ring-0 rounded-md cursor-pointer",i.className),itemIcon:i.isActive?h.jsx(D.RiCheckLine,{size:16}):void 0,children:[i.icon,i.label,h.jsx("div",{className:"flex-1"})]},i.key),s=i=>{var l;return h.jsx(Vt.SubMenu,{expandIcon:h.jsx(D.RiArrowRightSLine,{size:16}),popupClassName:b.cx("!rounded-lg border border-muted bg-background shadow-xl !p-2 min-w-48 !m-0 z-[1080]",b.css`
|
|
674
674
|
.rc-menu {
|
|
675
675
|
border: none !important;
|
|
676
676
|
box-shadow: none !important;
|
|
@@ -693,9 +693,9 @@
|
|
|
693
693
|
background-color: hsl(var(--accent)) !important;
|
|
694
694
|
}
|
|
695
695
|
}
|
|
696
|
-
`),...t,children:e.map(i=>i.type==="divider"?h.jsx(Vt.Divider,{className:"!my-1"},i.key):i.type==="submenu"?s(i):o(i))}),...t,children:n})});ps.displayName="DropdownMenu";const ja=({children:n,...e})=>{const{editor:t}=N.useEditor(),r=()=>{t&&t.state.selection instanceof O&&(t.commands.deleteSelection(),t.commands.focus())},o=()=>{if(t&&t.state.selection instanceof O){const l=t.state.selection.node,a=t.state.selection.to;t.chain().insertContentAt(a,{type:l.type.name,attrs:{...l.attrs},content:l.content.toJSON()}).focus().run()}},s=Un.map(l=>({key:`transform-${l.name}`,icon:h.jsx(l.icon,{size:16}),label:l.name,onClick:()=>{t&&t.state.selection instanceof O&&l.command(t)},isActive:l.isActive(t)})),i=[{key:"transform",type:"submenu",icon:h.jsx(
|
|
696
|
+
`),...t,children:e.map(i=>i.type==="divider"?h.jsx(Vt.Divider,{className:"!my-1"},i.key):i.type==="submenu"?s(i):o(i))}),...t,children:n})});ps.displayName="DropdownMenu";const ja=({children:n,...e})=>{const{editor:t}=N.useEditor(),r=()=>{t&&t.state.selection instanceof O&&(t.commands.deleteSelection(),t.commands.focus())},o=()=>{if(t&&t.state.selection instanceof O){const l=t.state.selection.node,a=t.state.selection.to;t.chain().insertContentAt(a,{type:l.type.name,attrs:{...l.attrs},content:l.content.toJSON()}).focus().run()}},s=Un.map(l=>({key:`transform-${l.name}`,icon:h.jsx(l.icon,{size:16}),label:l.name,onClick:()=>{t&&t.state.selection instanceof O&&l.command(t)},isActive:l.isActive(t)})),i=[{key:"transform",type:"submenu",icon:h.jsx(D.RiRepeatLine,{size:16}),label:"转换成",children:s},{key:"duplicate",icon:h.jsx(D.RiFileCopyLine,{size:16}),label:"创建副本",onClick:o},{key:"divider",type:"divider"},{key:"delete",icon:h.jsx(D.RiDeleteBinLine,{size:16}),label:"删除",className:"text-red-500",onClick:r}];return h.jsx(ps,{items:i,...e,children:n})},Xa=()=>{const{editor:n}=N.useEditor(),e=t=>{if(!n)return;const r=t.target.closest(".custom-drag-handle");if(!r)return;const o=r.dataset.nodePos,s=o!==void 0?parseInt(r.dataset.nodePos||"0",10):o;s!==void 0&&(n.commands.focus(),n.commands.setNodeSelection(s),n.commands.createParagraphNear()?n.commands.insertContent("/"):n.chain().insertContentAt(s,{type:"paragraph",content:[{type:"text",text:"/"}]}).run())};return h.jsxs("div",{className:b.cx("custom-drag-handle",b.css`
|
|
697
697
|
width: auto;
|
|
698
698
|
background: none;
|
|
699
699
|
display: flex;
|
|
700
700
|
align-items: center;
|
|
701
|
-
`),children:[h.jsx(st,{placement:"bottom",overlay:h.jsxs("div",{children:["点击",h.jsx("span",{className:"text-muted-foreground",children:"以在下方添加快"})]}),children:h.jsx(Se,{size:"icon",variant:"ghost",className:"w-auto h-auto p-0.5",onClick:e,children:h.jsx(
|
|
701
|
+
`),children:[h.jsx(st,{placement:"bottom",overlay:h.jsxs("div",{children:["点击",h.jsx("span",{className:"text-muted-foreground",children:"以在下方添加快"})]}),children:h.jsx(Se,{size:"icon",variant:"ghost",className:"w-auto h-auto p-0.5",onClick:e,children:h.jsx(D.RiAddLine,{className:"cursor-pointer",size:22})})}),h.jsx(ja,{children:h.jsx(st,{placement:"bottom",overlay:h.jsx("div",{children:h.jsxs("div",{children:["拖动",h.jsx("span",{className:"text-muted-foreground",children:"以移动"})]})}),children:h.jsx(Se,{size:"icon",variant:"ghost",className:"w-auto h-auto p-0.5",children:h.jsx(D.RiDraggable,{size:22})})})})]})},Ya=n=>{const{className:e,initialContent:t={},onChange:r,cacheKey:o="novel-content",enableCache:s=!1,showSaveStatus:i=!0,showWordCount:l=!0,uploadImageProps:a,editorRef:c,enableAI:d=!1,aiOptions:u}=n,[f,m]=w.useState(t),[p,y]=w.useState("Saved"),[g,x]=w.useState(),[S,E]=w.useState(!1),[k,P]=w.useState(!1),[I,A]=w.useState(!1),[M,T]=w.useState(!1),Q=F=>{const Y=new DOMParser().parseFromString(F,"text/html");return Y.querySelectorAll("pre code").forEach(W=>{Bs.highlightElement(W)}),new XMLSerializer().serializeToString(Y)},X=Os.useDebouncedCallback(async F=>{const Y=F.getJSON();x(F.storage.characterCount.words()),r==null||r(Y),s&&(window.localStorage.setItem("html-content",Q(F.getHTML())),window.localStorage.setItem(o,JSON.stringify(Y)),window.localStorage.setItem("markdown",F.storage.markdown.getMarkdown()),y("Saved"))},500),Me=w.useMemo(()=>{if(!a)return Wa;const{beforeUpload:F,maxSize:Y,action:W,headers:ge,method:ve,name:Xn,onSuccess:nn,onError:rn}=a;return N.createImageUpload({onUpload:je=>{const V=new FormData;V.append(Xn||"file",je);const ie=fetch(W,{method:ve||"POST",headers:{...ge},body:V});return new Promise((Z,K)=>{ie.then(async q=>{if(nn){const J=await q.json();Z(nn(J));return}if(q.status===200){const{url:J}=await q.json(),$=new Image;$.src=J,$.onload=()=>{Z(J)}}else throw q.status===401?(Z(je),new Error("`BLOB_READ_WRITE_TOKEN` environment variable not found, reading image locally instead.")):new Error("Error uploading image. Please try again.")}).catch(q=>{rn&&rn(q),K(q)})})},validateFn:je=>F?F(je):je.type.includes("image/")?Y&&je.size>Y?(console.error("File size too big (max 20MB)."),!1):!0:(console.error("File type not supported."),!1)})},[a]);if(w.useEffect(()=>{if(!s)return;const F=window.localStorage.getItem(o);m(F?JSON.parse(F):Ua)},[o,s]),!f)return null;const Le=[...os,Ka({uploadFn:Me})];return h.jsxs("div",{className:b.cx("relative w-full max-w-screen-lg",e),children:[(s&&i||l)&&h.jsxs("div",{className:"flex absolute right-5 top-5 z-10 mb-5 gap-2",children:[s&&i&&h.jsx("div",{className:"rounded-lg bg-accent px-2 py-1 text-sm text-muted-foreground",children:p}),l&&h.jsxs("div",{className:g?"rounded-lg bg-accent px-2 py-1 text-sm text-muted-foreground":"hidden",children:[g," Words"]})]}),h.jsx(N.EditorRoot,{children:h.jsxs(N.EditorContent,{onCreate:({editor:F})=>{c&&(c.current=F)},initialContent:f,extensions:Le,className:"relative min-h-[500px] w-full max-w-screen-lg border-muted bg-background sm:mb-[calc(20vh)] sm:rounded-lg sm:border sm:shadow-lg editor-content",editorProps:{handleDOMEvents:{keydown:(F,Y)=>N.handleCommandNavigation(Y)},handlePaste:(F,Y)=>N.handleImagePaste(F,Y,Me),handleDrop:(F,Y,W,ge)=>N.handleImageDrop(F,Y,ge,Me),attributes:{class:"prose prose-lg dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full"}},onUpdate:({editor:F})=>{X(F),y("Unsaved")},slotAfter:h.jsx(N.ImageResizer,{}),children:[h.jsxs(N.EditorCommand,{className:"z-50 h-auto max-h-[330px] overflow-y-auto rounded-md border border-muted bg-background px-1 py-2 shadow-md transition-all",children:[h.jsx(N.EditorCommandEmpty,{className:"px-2 text-muted-foreground",children:"没有结果"}),h.jsx(N.EditorCommandList,{children:fs({uploadFn:Me}).map(F=>h.jsxs(N.EditorCommandItem,{value:F.title,onCommand:Y=>F.command(Y),className:"flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm hover:bg-accent aria-selected:bg-accent",children:[h.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-muted bg-background",children:F.icon}),h.jsxs("div",{children:[h.jsx("p",{className:"font-medium",children:F.title}),h.jsx("p",{className:"text-xs text-muted-foreground",children:F.description})]})]},F.title))})]}),h.jsxs(qa,{open:M,onOpenChange:T,enableAI:d,aiOptions:u,children:[d&&h.jsx(gt,{orientation:"vertical"}),h.jsx(Ma,{open:S,onOpenChange:E}),h.jsx(gt,{orientation:"vertical"}),h.jsx(Ta,{open:I,onOpenChange:A}),h.jsx(gt,{orientation:"vertical"}),h.jsx(Oa,{}),h.jsx(gt,{orientation:"vertical"}),h.jsx(Ja,{}),h.jsx(gt,{orientation:"vertical"}),h.jsx(Na,{open:k,onOpenChange:P})]}),h.jsx(Xa,{})]})})]})},Ga=({json:n})=>{const e=w.useMemo(()=>Fs.generateHTML(n??{},os),[n]);return h.jsx("div",{className:"tiptap ProseMirror prose prose-lg dark:prose-invert prose-headings:font-title font-default focus:outline-none max-w-full",children:h.jsx("div",{dangerouslySetInnerHTML:{__html:e}})})},ms=Ya;ms.Preview=Ga,C.Desktop=_s,C.Dock=cn,C.Editor=ms,C.Markdown=fr,C.MdEditor=pr,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});
|