@plandesk/api 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -78,25 +78,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
78
78
|
`,`
|
|
79
79
|
+`).split(`
|
|
80
80
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,V.useEffect)(()=>{let n=t?.target??My,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&f_(e))return!1;let n=Fy(e.code,s);if(a.current.add(e[n]),Py(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Fy(e.code,s);Py(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Py(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Fy(e,t){return t.includes(e)?`code`:`key`}var Iy=()=>{let e=oy();return(0,V.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=$g(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Jg(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Yg(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Ly(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Ry(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Ry(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function zy(e,t){return Ly(e,t)}function By(e,t){return Ly(e,t)}function Vy(e,t){return{id:e,type:`select`,selected:t}}function Hy(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Vy(a.id,e)))}return r}function Uy({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Wy(e){return{id:e.id,type:`remove`}}var Gy=Kg(`React Flow`,`https://reactflow.dev/`);function Ky(e,t,n={}){return T_(e,t,{...n,onError:n.onError??Gy})}var qy=e=>xg(e),Jy=e=>bg(e);function Yy(e){return(0,V.forwardRef)(e)}var Xy=typeof window<`u`?V.useLayoutEffect:V.useEffect;function Zy(e){let[t,n]=(0,V.useState)(BigInt(0)),[r]=(0,V.useState)(()=>Qy(()=>n(e=>e+BigInt(1))));return Xy(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Qy(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var $y=(0,V.createContext)(null);function eb({children:e}){let t=oy(),n=Zy((0,V.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Uy({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=Zy((0,V.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Uy({items:s,lookup:o}))},[])),i=(0,V.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,H.jsx)($y.Provider,{value:i,children:e})}function tb(){let e=(0,V.useContext)($y);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var nb=e=>!!e.panZoom;function rb(){let e=Iy(),t=oy(),n=tb(),r=ay(nb),i=(0,V.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=qy(e)?e:n.get(e.id),a=i.parentId?i_(i.position,i.measured,i.parentId,n,r):i.position;return Bg({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&qy(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Jy(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await jg({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Wy);o?.(f),c(e)}if(m){let e=d.map(Wy);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Wg(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=Bg(s?r:a),l=Ug(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Wg(e)?e:a(e);if(!r)return!1;let i=Ug(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return wg(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??o_();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,V.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var ib=e=>e.selected,ab=typeof window<`u`?window:void 0;function ob({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=oy(),{deleteElements:r}=rb(),i=Ny(e,{actInsideInputWithModifier:!1}),a=Ny(t,{target:ab});(0,V.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(ib),edges:e.filter(ib)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,V.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function sb(e){let t=oy();(0,V.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=l_(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,cg.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var cb={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},lb=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function ub({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=pg.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=oy(),S=(0,V.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=ay(lb,ty),E=Ny(f),D=(0,V.useRef)();sb(S);let O=(0,V.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,V.useEffect)(()=>{if(S.current){D.current=Pv({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,V.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,H.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:cb,children:m})}var db=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function fb(){let{userSelectionActive:e,userSelectionRect:t}=ay(db,ty);return e&&t?(0,H.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var pb=(e,t)=>n=>{n.target===t.current&&e?.(n)},mb=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function hb({isSelecting:e,selectionKeyPressed:t,selectionMode:n=mg.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,V.useRef)(0),_=oy(),{userSelectionActive:v,elementsSelectable:y,dragging:b,connectionInProgress:x,panBy:S,autoPanSpeed:C}=ay(mb,ty),w=y&&(e||v),T=(0,V.useRef)(null),E=(0,V.useRef)(),D=(0,V.useRef)(new Set),O=(0,V.useRef)(new Set),k=(0,V.useRef)(!1),A=(0,V.useRef)({x:0,y:0}),j=(0,V.useRef)(!1),M=e=>{if(k.current||x){k.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},ee=d?e=>d(e):void 0,te=e=>{k.current&&=(e.stopPropagation(),!1)},P=n=>{let{domNode:r,transform:i}=_.getState();if(E.current=r?.getBoundingClientRect(),!E.current)return;let a=n.target===T.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=m_(n.nativeEvent,E.current),l=Jg({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function F(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Yg(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=D.current,g=O.current;D.current=new Set(Eg(a,m,i,n===mg.Partial,!0).map(e=>e.id)),O.current=new Set;let v=u?.selectable??!0;for(let e of D.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&O.current.add(e)}}a_(h,D.current)||c(Hy(a,D.current,!0)),a_(g,O.current)||l(Hy(o,O.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function ne(){if(!i||!E.current)return;let[e,t]=Ig(A.current,E.current,C);S({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(ne);return}let{x:t,y:n}=A.current;F(t,n),g.current=requestAnimationFrame(ne)})}let re=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};return(0,V.useEffect)(()=>()=>re(),[]),(0,H.jsxs)(`div`,{className:Cu([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:b,selection:e}]),onClick:w?void 0:pb(M,T),onContextMenu:pb(N,T),onWheel:pb(ee,T),onPointerEnter:w?void 0:f,onPointerMove:w?e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!E.current||!n)return;let{x:o,y:c}=m_(e.nativeEvent,E.current);A.current={x:o,y:c};let l=Yg({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(ne(),!0),F(o,c)}:p,onPointerUp:w?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===T.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:D.current.size>0})),re())}:void 0,onPointerCancel:w?e=>{e.target?.releasePointerCapture?.(e.pointerId),re()}:void 0,onPointerDownCapture:w?P:void 0,onClickCapture:w?te:void 0,onPointerLeave:m,ref:T,style:cb,children:[h,(0,H.jsx)(fb,{})]})}function gb({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,cg.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function _b({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=oy(),[c,l]=(0,V.useState)(!1),u=(0,V.useRef)();return(0,V.useEffect)(()=>{u.current=lv({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{gb({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,V.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var vb=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function yb(){let e=oy();return(0,V.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=vb(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=qg(t,i));let{position:a,positionAbsolute:s}=Ag({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var bb=(0,V.createContext)(null),xb=bb.Provider;bb.Consumer;var Sb=()=>(0,V.useContext)(bb),Cb=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),wb=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===fg.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Tb({type:e=`source`,position:t=q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=oy(),_=Sb(),{connectOnClick:v,noPanClassName:y,rfId:b}=ay(Cb,ty),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=ay(wb(_,m,e),ty);_||g.getState().onError?.(`010`,cg.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Ky(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=p_(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();yv.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,H.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Cu([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=u_(t.target),h=n||c,{connection:v,isValid:y}=yv.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var Eb=(0,V.memo)(Yy(Tb));function Db({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return(0,H.jsxs)(H.Fragment,{children:[e?.label,(0,H.jsx)(Eb,{type:`source`,position:n,isConnectable:t})]})}function Ob({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:r=q.Bottom}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Eb,{type:`target`,position:n,isConnectable:t}),e?.label,(0,H.jsx)(Eb,{type:`source`,position:r,isConnectable:t})]})}function kb(){return null}function Ab({data:e,isConnectable:t,targetPosition:n=q.Top}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Eb,{type:`target`,position:n,isConnectable:t}),e?.label]})}var jb={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Mb={input:Db,default:Ob,output:Ab,group:kb};function Nb(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Pb=e=>{let{width:t,height:n,x:r,y:i}=Tg(e.nodeLookup,{filter:e=>!!e.selected});return{width:Gg(t)?t:null,height:Gg(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Fb({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=oy(),{width:i,height:a,transformString:o,userSelectionActive:s}=ay(Pb,ty),c=yb(),l=(0,V.useRef)(null);(0,V.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(_b({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,H.jsx)(`div`,{className:Cu([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,H.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(jb,e.key)&&(e.preventDefault(),c({direction:jb[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Ib=typeof window<`u`?window:void 0,Lb=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Rb({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:ee,onViewportChange:te,isControlledViewport:P}){let{nodesSelectionActive:F,userSelectionActive:ne}=ay(Lb,ty),re=Ny(l,{target:Ib}),I=Ny(h,{target:Ib}),L=I||w,R=I||b,z=u&&L!==!0,ie=re||ne||z;return ob({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,H.jsx)(ub,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:R,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!re&&L,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:te,isControlledViewport:P,paneClickDistance:s,selectionOnDrag:z,children:(0,H.jsxs)(hb,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:L,autoPanOnSelection:T,isSelecting:!!ie,selectionMode:d,selectionKeyPressed:re,paneClickDistance:s,selectionOnDrag:z,children:[e,F&&(0,H.jsx)(Fb,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:ee})]})})}Rb.displayName=`FlowRenderer`;var zb=(0,V.memo)(Rb),Bb=e=>t=>e?Eg(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Vb(e){return ay((0,V.useCallback)(Bb(e),[e]),ty)}var Hb=e=>e.updateNodeInternals;function Ub(){let e=ay(Hb),[t]=(0,V.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,V.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Wb({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=oy(),a=(0,V.useRef)(null),o=(0,V.useRef)(null),s=(0,V.useRef)(e.sourcePosition),c=(0,V.useRef)(e.targetPosition),l=(0,V.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,V.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,V.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,V.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Gb({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=ay(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},ty),S=y.type||`default`,C=g?.[S]||Mb[S];C===void 0&&(v?.(`003`,cg.error003(S)),S=`default`,C=g?.default||Mb.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=oy(),k=r_(y),A=Wb({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=_b({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=yb();if(y.hidden)return null;let N=n_(y),ee=Nb(y),te=T||w||t||n||r||i,P=n?e=>n(e,{...b.userNode}):void 0,F=r?e=>r(e,{...b.userNode}):void 0,ne=i?e=>i(e,{...b.userNode}):void 0,re=a?e=>a(e,{...b.userNode}):void 0,I=o?e=>o(e,{...b.userNode}):void 0,L=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&gb({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},R=t=>{if(!(f_(t.nativeEvent)||m)){if(ug.includes(t.key)&&T)gb({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(jb,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:jb[t.key],factor:t.shiftKey?4:1})}}},z=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(Eg(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,H.jsx)(`div`,{className:Cu([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:te?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...ee},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:P,onMouseMove:F,onMouseLeave:ne,onContextMenu:re,onClick:L,onDoubleClick:I,onKeyDown:D?R:void 0,tabIndex:D?0:void 0,onFocus:D?z:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${ly}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,H.jsx)(xb,{value:e,children:(0,H.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var Kb=(0,V.memo)(Gb),qb=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Jb(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=ay(qb,ty),o=Vb(e.onlyRenderVisibleElements),s=Ub();return(0,H.jsx)(`div`,{className:`react-flow__nodes`,style:cb,children:o.map(o=>(0,H.jsx)(Kb,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}Jb.displayName=`NodeRenderer`;var Yb=(0,V.memo)(Jb);function Xb(e){return ay((0,V.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&S_({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),ty)}var Zb=({color:e=`none`,strokeWidth:t=1})=>(0,H.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),Qb=({color:e=`none`,strokeWidth:t=1})=>(0,H.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),$b={[_g.Arrow]:Zb,[_g.ArrowClosed]:Qb};function ex(e){let t=oy();return(0,V.useMemo)(()=>Object.prototype.hasOwnProperty.call($b,e)?$b[e]:(t.getState().onError?.(`009`,cg.error009(e)),null),[e])}var tx=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=ex(t);return c?(0,H.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,H.jsx)(c,{color:n,strokeWidth:o})}):null},nx=({defaultColor:e,rfId:t})=>{let n=ay(e=>e.edges),r=ay(e=>e.defaultEdgeOptions),i=(0,V.useMemo)(()=>z_(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,H.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,H.jsx)(`defs`,{children:i.map(e=>(0,H.jsx)(tx,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};nx.displayName=`MarkerDefinitions`;var rx=(0,V.memo)(nx);function ix({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,V.useState)({x:1,y:0,width:0,height:0}),p=Cu([`react-flow__edge-textwrapper`,l]),m=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,H.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,H.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,H.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}ix.displayName=`EdgeText`;var ax=(0,V.memo)(ix);function ox({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{...u,d:e,fill:`none`,className:Cu([`react-flow__edge-path`,u.className])}),l?(0,H.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Gg(t)&&Gg(n)?(0,H.jsx)(ax,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function sx({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===q.Left||e===q.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function cx({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:i,targetPosition:a=q.Top}){let[o,s]=sx({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=sx({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=g_({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function lx(e){return(0,V.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=cx({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,H.jsx)(ox,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var ux=lx({isInternal:!1}),dx=lx({isInternal:!0});ux.displayName=`SimpleBezierEdge`,dx.displayName=`SimpleBezierEdgeInternal`;function fx(e){return(0,V.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=q.Bottom,targetPosition:m=q.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=M_({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,H.jsx)(ox,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var px=fx({isInternal:!1}),mx=fx({isInternal:!0});px.displayName=`SmoothStepEdge`,mx.displayName=`SmoothStepEdgeInternal`;function hx(e){return(0,V.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,H.jsx)(px,{...n,id:r,pathOptions:(0,V.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var gx=hx({isInternal:!1}),_x=hx({isInternal:!0});gx.displayName=`StepEdge`,_x.displayName=`StepEdgeInternal`;function vx(e){return(0,V.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=E_({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,H.jsx)(ox,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var yx=vx({isInternal:!1}),bx=vx({isInternal:!0});yx.displayName=`StraightEdge`,bx.displayName=`StraightEdgeInternal`;function xx(e){return(0,V.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=q.Bottom,targetPosition:s=q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=y_({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,H.jsx)(ox,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var Sx=xx({isInternal:!1}),Cx=xx({isInternal:!0});Sx.displayName=`BezierEdge`,Cx.displayName=`BezierEdgeInternal`;var wx={default:Cx,straight:bx,step:_x,smoothstep:mx,simplebezier:dx},Tx={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Ex=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,Dx=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,Ox=`react-flow__edgeupdater`;function kx({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,H.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Cu([Ox,`${Ox}-${s}`]),cx:Ex(t,r,e),cy:Dx(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Ax({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=oy(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;yv.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,H.jsxs)(H.Fragment,{children:[(e===!0||e===`source`)&&(0,H.jsx)(kx,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,H.jsx)(kx,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function jx({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=ay(t=>t.edgeLookup.get(e)),b=ay(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||wx[x];S===void 0&&(_?.(`011`,cg.error011(x)),x=`default`,S=h?.default||wx.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,V.useRef)(null),[D,O]=(0,V.useState)(!1),[k,A]=(0,V.useState)(!1),j=oy(),{zIndex:M,sourceX:N,sourceY:ee,targetX:te,targetY:P,sourcePosition:F,targetPosition:ne}=ay((0,V.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...Tx};let i=P_({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:x_({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||Tx}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),ty),re=(0,V.useMemo)(()=>y.markerStart?`url('#${R_(y.markerStart,m)}')`:void 0,[y.markerStart,m]),I=(0,V.useMemo)(()=>y.markerEnd?`url('#${R_(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||ee===null||te===null||P===null)return null;let L=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},R=a?e=>{a(e,{...y})}:void 0,z=o?e=>{o(e,{...y})}:void 0,ie=s?e=>{s(e,{...y})}:void 0,B=c?e=>{c(e,{...y})}:void 0,ae=l?e=>{l(e,{...y})}:void 0;return(0,H.jsx)(`svg`,{style:{zIndex:M},children:(0,H.jsxs)(`g`,{className:Cu([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:L,onDoubleClick:R,onContextMenu:z,onMouseEnter:ie,onMouseMove:B,onMouseLeave:ae,onKeyDown:C?t=>{if(!v&&ug.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${uy}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,H.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:ee,targetX:te,targetY:P,sourcePosition:F,targetPosition:ne,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:re,markerEnd:I,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,H.jsx)(Ax,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:ee,targetX:te,targetY:P,sourcePosition:F,targetPosition:ne,setUpdateHover:O,setReconnecting:A})]})})}var Mx=(0,V.memo)(jx),Nx=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Px({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=ay(Nx,ty),b=Xb(t);return(0,H.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,H.jsx)(rx,{defaultColor:e,rfId:n}),b.map(e=>(0,H.jsx)(Mx,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Px.displayName=`EdgeRenderer`;var Fx=(0,V.memo)(Px),Ix=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Lx({children:e}){return(0,H.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:ay(Ix)},children:e})}function Rx(e){let t=rb(),n=(0,V.useRef)(!1);(0,V.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var zx=e=>e.panZoom?.syncViewport;function Bx(e){let t=ay(zx),n=oy();return(0,V.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Vx(e){return e.connection.inProgress?{...e.connection,to:Jg(e.connection.to,e.transform)}:{...e.connection}}function Hx(e){return e?t=>e(Vx(t)):Vx}function Ux(e){return ay(Hx(e),ty)}var Wx=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Gx({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=ay(Wx,ty);return a&&i&&c?(0,H.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,H.jsx)(`g`,{className:Cu([`react-flow__connection`,yg(s)]),children:(0,H.jsx)(Kx,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Kx=({style:e,type:t=gg.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Ux();if(!i)return;if(n)return(0,H.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:yg(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case gg.Bezier:[m]=y_(h);break;case gg.SimpleBezier:[m]=cx(h);break;case gg.Step:[m]=M_({...h,borderRadius:0});break;case gg.SmoothStep:[m]=M_(h);break;default:[m]=E_(h)}return(0,H.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Kx.displayName=`ConnectionLine`;var qx={};function Jx(e=qx){(0,V.useRef)(e),oy(),(0,V.useEffect)(()=>{},[e])}function Yx(){oy(),(0,V.useRef)(!1),(0,V.useEffect)(()=>{},[])}function Xx({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:ee,panOnScroll:te,panOnScrollSpeed:P,panOnScrollMode:F,zoomOnDoubleClick:ne,panOnDrag:re,autoPanOnSelection:I,onPaneClick:L,onPaneMouseEnter:R,onPaneMouseMove:z,onPaneMouseLeave:ie,onPaneScroll:B,onPaneContextMenu:ae,paneClickDistance:oe,nodeClickDistance:se,onEdgeContextMenu:ce,onEdgeMouseEnter:le,onEdgeMouseMove:ue,onEdgeMouseLeave:de,reconnectRadius:fe,onReconnect:pe,onReconnectStart:me,onReconnectEnd:he,noDragClassName:ge,noWheelClassName:_e,noPanClassName:ve,disableKeyboardA11y:ye,nodeExtent:be,rfId:xe,viewport:Se,onViewportChange:Ce}){return Jx(e),Jx(t),Yx(),Rx(n),Bx(Se),(0,H.jsx)(zb,{onPaneClick:L,onPaneMouseEnter:R,onPaneMouseMove:z,onPaneMouseLeave:ie,onPaneContextMenu:ae,onPaneScroll:B,paneClickDistance:oe,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:ee,zoomOnDoubleClick:ne,panOnScroll:te,panOnScrollSpeed:P,panOnScrollMode:F,panOnDrag:re,autoPanOnSelection:I,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:ge,noWheelClassName:_e,noPanClassName:ve,disableKeyboardA11y:ye,onViewportChange:Ce,isControlledViewport:!!Se,children:(0,H.jsxs)(Lx,{children:[(0,H.jsx)(Fx,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:pe,onReconnectStart:me,onReconnectEnd:he,onlyRenderVisibleElements:T,onEdgeContextMenu:ce,onEdgeMouseEnter:le,onEdgeMouseMove:ue,onEdgeMouseLeave:de,reconnectRadius:fe,defaultMarkerColor:M,noPanClassName:ve,disableKeyboardA11y:ye,rfId:xe}),(0,H.jsx)(Gx,{style:h,type:m,component:g,containerStyle:_}),(0,H.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,H.jsx)(Yb,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:se,onlyRenderVisibleElements:T,noPanClassName:ve,noDragClassName:ge,disableKeyboardA11y:ye,nodeExtent:be,rfId:xe}),(0,H.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Xx.displayName=`GraphView`;var Zx=(0,V.memo)(Xx),Qx=Kg(`React Flow`,`https://reactflow.dev/`),$x=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??lg;rv(h,g,_);let{nodesInitialized:x}=J_(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=$g(Tg(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:lg,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:fg.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...hg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Qx,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:dg,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},eS=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>ey((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await kg({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...$x({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=J_(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();rv(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=ev(e,n,r,i,a,o,l);d&&(G_(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=I_(e,o.fromHandle,q.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=$_(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(zy(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(By(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Vy(e,!0)));return}i(Hy(r,new Set([...e]),!0)),a(Hy(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Vy(e,!0)));return}a(Hy(n,new Set([...e]))),i(Hy(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Vy(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Vy(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Vy(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Vy(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(J_(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return tv({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...hg}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...$x()})}},Object.is);function tS({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,V.useState)(()=>eS({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,H.jsx)(ry,{value:m,children:(0,H.jsx)(eb,{children:p})})}function nS({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,V.useContext)(ny)?(0,H.jsx)(H.Fragment,{children:e}):(0,H.jsx)(tS,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var rS={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function iS({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:ee,onSelectionEnd:te,onBeforeDelete:P,connectionMode:F,connectionLineType:ne=gg.Bezier,connectionLineStyle:re,connectionLineComponent:I,connectionLineContainerStyle:L,deleteKeyCode:R=`Backspace`,selectionKeyCode:z=`Shift`,selectionOnDrag:ie=!1,selectionMode:B=mg.Full,panActivationKeyCode:ae=`Space`,multiSelectionKeyCode:oe=e_()?`Meta`:`Control`,zoomActivationKeyCode:se=e_()?`Meta`:`Control`,snapToGrid:ce,snapGrid:le,onlyRenderVisibleElements:ue=!1,selectNodesOnDrag:de,nodesDraggable:fe,autoPanOnNodeFocus:pe,nodesConnectable:me,nodesFocusable:he,nodeOrigin:ge=wy,edgesFocusable:_e,edgesReconnectable:ve,elementsSelectable:ye=!0,defaultViewport:be=Ty,minZoom:xe=.5,maxZoom:Se=2,translateExtent:Ce=lg,preventScrolling:we=!0,nodeExtent:Te,defaultMarkerColor:Ee=`#b1b1b7`,zoomOnScroll:De=!0,zoomOnPinch:Oe=!0,panOnScroll:ke=!1,panOnScrollSpeed:Ae=.5,panOnScrollMode:je=pg.Free,zoomOnDoubleClick:Me=!0,panOnDrag:Ne=!0,onPaneClick:Pe,onPaneMouseEnter:Fe,onPaneMouseMove:Ie,onPaneMouseLeave:Le,onPaneScroll:Re,onPaneContextMenu:ze,paneClickDistance:Be=1,nodeClickDistance:Ve=0,children:U,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:ot,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanOnSelection:pt=!0,autoPanSpeed:mt,connectionRadius:ht,isValidConnection:gt,onError:_t,style:vt,id:yt,nodeDragThreshold:bt,connectionDragThreshold:xt,viewport:St,onViewportChange:Ct,width:wt,height:Tt,colorMode:Et=`light`,debug:Dt,onScroll:Ot,ariaLabelConfig:kt,zIndexMode:At=`basic`,...jt},Mt){let Nt=yt||`1`,Pt=jy(Et),Ft=(0,V.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Ot?.(e)},[Ot]);return(0,H.jsx)(`div`,{"data-testid":`rf__wrapper`,...jt,onScroll:Ft,style:{...vt,...rS},ref:Mt,className:Cu([`react-flow`,i,Pt]),id:yt,role:`application`,children:(0,H.jsxs)(nS,{nodes:e,edges:t,width:wt,height:Tt,fitView:nt,fitViewOptions:rt,minZoom:xe,maxZoom:Se,nodeOrigin:ge,nodeExtent:Te,zIndexMode:At,children:[(0,H.jsx)(ky,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:fe,autoPanOnNodeFocus:pe,nodesConnectable:me,nodesFocusable:he,edgesFocusable:_e,edgesReconnectable:ve,elementsSelectable:ye,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:xe,maxZoom:Se,nodeExtent:Te,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:ce,snapGrid:le,connectionMode:F,translateExtent:Ce,connectOnClick:it,defaultEdgeOptions:st,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:ge,rfId:Nt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:mt,onError:_t,connectionRadius:ht,isValidConnection:gt,selectNodesOnDrag:de,nodeDragThreshold:bt,connectionDragThreshold:xt,onBeforeDelete:P,debug:Dt,ariaLabelConfig:kt,zIndexMode:At}),(0,H.jsx)(Zx,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:ne,connectionLineStyle:re,connectionLineComponent:I,connectionLineContainerStyle:L,selectionKeyCode:z,selectionOnDrag:ie,selectionMode:B,deleteKeyCode:R,multiSelectionKeyCode:oe,panActivationKeyCode:ae,zoomActivationKeyCode:se,onlyRenderVisibleElements:ue,defaultViewport:be,translateExtent:Ce,minZoom:xe,maxZoom:Se,preventScrolling:we,zoomOnScroll:De,zoomOnPinch:Oe,zoomOnDoubleClick:Me,panOnScroll:ke,panOnScrollSpeed:Ae,panOnScrollMode:je,panOnDrag:Ne,autoPanOnSelection:pt,onPaneClick:Pe,onPaneMouseEnter:Fe,onPaneMouseMove:Ie,onPaneMouseLeave:Le,onPaneScroll:Re,onPaneContextMenu:ze,paneClickDistance:Be,nodeClickDistance:Ve,onSelectionContextMenu:N,onSelectionStart:ee,onSelectionEnd:te,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:Ee,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:Nt,disableKeyboardA11y:ut,nodeExtent:Te,viewport:St,onViewportChange:Ct}),(0,H.jsx)(Cy,{onSelectionChange:k}),U,(0,H.jsx)(_y,{proOptions:ot,position:at}),(0,H.jsx)(hy,{rfId:Nt,disableKeyboardA11y:ut})]})})}var aS=Yy(iS),oS=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function sS({children:e}){let t=ay(oS);return t?(0,ki.createPortal)(e,t):null}function cS(e){let[t,n]=(0,V.useState)(e);return[t,n,(0,V.useCallback)(e=>n(t=>zy(e,t)),[])]}function lS(e){let[t,n]=(0,V.useState)(e);return[t,n,(0,V.useCallback)(e=>n(t=>By(e,t)),[])]}cg.error014();function uS({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,H.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Cu([`react-flow__background-pattern`,n,r])})}function dS({radius:e,className:t}){return(0,H.jsx)(`circle`,{cx:e,cy:e,r:e,className:Cu([`react-flow__background-pattern`,`dots`,t])})}var fS;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(fS||={});var pS={[fS.Dots]:1,[fS.Lines]:1,[fS.Cross]:6},mS=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hS({id:e,variant:t=fS.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,V.useRef)(null),{transform:f,patternId:p}=ay(mS,ty),m=r||pS[t],h=t===fS.Dots,g=t===fS.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,H.jsxs)(`svg`,{className:Cu([`react-flow__background`,l]),style:{...c,...cb,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,H.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,H.jsx)(dS,{radius:y/2,className:u}):(0,H.jsx)(uS,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,H.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}hS.displayName=`Background`;var gS=(0,V.memo)(hS);function _S(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,H.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function vS(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,H.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function yS(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,H.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function bS(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,H.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function xS(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,H.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function SS({children:e,className:t,...n}){return(0,H.jsx)(`button`,{type:`button`,className:Cu([`react-flow__controls-button`,t]),...n,children:e})}var CS=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function wS({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=oy(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=ay(CS,ty),{zoomIn:y,zoomOut:b,fitView:x}=rb();return(0,H.jsxs)(gy,{className:Cu([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(SS,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,H.jsx)(_S,{})}),(0,H.jsx)(SS,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,H.jsx)(vS,{})})]}),n&&(0,H.jsx)(SS,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,H.jsx)(yS,{})}),r&&(0,H.jsx)(SS,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,H.jsx)(xS,{}):(0,H.jsx)(bS,{})}),u]})}wS.displayName=`Controls`;var TS=(0,V.memo)(wS);function ES({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,H.jsx)(`rect`,{className:Cu([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var DS=(0,V.memo)(ES),OS=e=>e.nodes.map(e=>e.id),kS=e=>e instanceof Function?e:()=>e;function AS({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=DS,onClick:o}){let s=ay(OS,ty),c=kS(t),l=kS(e),u=kS(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,H.jsx)(H.Fragment,{children:s.map(e=>(0,H.jsx)(MS,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function jS({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=ay(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=n_(r);return{node:r,x:i,y:a,width:o,height:s}},ty);return!l||l.hidden||!r_(l)?null:(0,H.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var MS=(0,V.memo)(jS),NS=(0,V.memo)(AS),PS=200,FS=150,IS=e=>!e.hidden,LS=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Hg(Tg(e.nodeLookup,{filter:IS}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},RS=`react-flow__minimap-desc`;function zS({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=oy(),S=(0,V.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=ay(LS,ty),j=e?.width??PS,M=e?.height??FS,N=C.width/j,ee=C.height/M,te=Math.max(N,ee),P=te*j,F=te*M,ne=b*te,re=C.x-(P-C.width)/2-ne,I=C.y-(F-C.height)/2-ne,L=P+ne*2,R=F+ne*2,z=`${RS}-${T}`,ie=(0,V.useRef)(0),B=(0,V.useRef)();ie.current=te,(0,V.useEffect)(()=>{if(S.current&&E)return B.current=bv({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ie.current}),()=>{B.current?.destroy()}},[E]),(0,V.useEffect)(()=>{B.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ae=p?e=>{let[t,n]=B.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,oe=m?(0,V.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,se=_??A[`minimap.ariaLabel`];return(0,H.jsx)(gy,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*te:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Cu([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,H.jsxs)(`svg`,{width:j,height:M,viewBox:`${re} ${I} ${L} ${R}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":z,ref:S,onClick:ae,children:[se&&(0,H.jsx)(`title`,{id:z,children:se}),(0,H.jsx)(NS,{onClick:oe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,H.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${re-ne},${I-ne}h${L+ne*2}v${R+ne*2}h${-L-ne*2}z
|
|
81
|
-
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}zS.displayName=`MiniMap`,(0,V.memo)(zS);var BS=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,VS={[Fv.Line]:`right`,[Fv.Handle]:`bottom-right`};function HS({nodeId:e,position:t,variant:n=Fv.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Sb(),y=typeof e==`string`?e:v,b=oy(),x=(0,V.useRef)(null),S=n===Fv.Handle,C=ay((0,V.useCallback)(BS(S&&p),[S,p]),ty),w=(0,V.useRef)(null),T=t??VS[n];return(0,V.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Kv({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$_([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...i_({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,H.jsx)(`div`,{className:Cu([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,V.memo)(HS);var US=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function WS(e){let t=new Map;function n(e){for(let r of e)r.linked_task_id!==null&&t.set(r.linked_task_id,r.id),n(r.children)}return n(e),t}function GS(e,t={}){return e.map(e=>({id:e.id,type:`taskCard`,position:{x:e.x,y:e.y},data:{label:e.label,status:e.status,projectId:e.project_id,documentId:t.taskDocumentMap?.get(e.id),description:e.description,assignee:e.assignee,dueDate:e.due_date}}))}function KS(e){return e.map(e=>({id:e.id,type:`labeled`,source:e.from_task_id,target:e.to_task_id,data:{label:e.label??`depends_on`}}))}function qS(e,t){return{nodes:e.map(e=>({id:e.id,x:e.position.x,y:e.position.y})),edges:t.map(e=>{let t={from_task_id:e.source,to_task_id:e.target,label:e.data?.label??`depends_on`};return US.test(e.id)&&(t.id=e.id),t})}}function JS({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,data:s}){let[c,l,u]=y_({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ox,{id:e,path:c}),(0,H.jsx)(sS,{children:(0,H.jsx)(`div`,{className:`nodrag nopan`,style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${String(l)}px,${String(u)}px)`,fontSize:`0.7rem`,fontWeight:600,padding:`0.125rem 0.375rem`,borderRadius:4,background:`#f3f4f6`,color:`#374151`,border:`1px solid #d1d5db`,pointerEvents:`all`},children:s?.label??`depends_on`})})]})}function YS({taskId:e,data:t,onPatch:n,onDelete:r,onClose:i,isSaving:a=!1}){let[o,s]=(0,V.useState)(t.label),[c,l]=(0,V.useState)(t.description??``),[u,d]=(0,V.useState)(t.assignee??``),[f,p]=(0,V.useState)(t.dueDate===null?``:t.dueDate.slice(0,10));return(0,V.useEffect)(()=>{s(t.label),l(t.description??``),d(t.assignee??``),p(t.dueDate===null?``:t.dueDate.slice(0,10))},[e,t.label,t.description,t.assignee,t.dueDate]),(0,H.jsxs)(`aside`,{"aria-label":`Task details`,style:{position:`absolute`,top:8,right:8,zIndex:10,width:280,background:`#fff`,border:`1px solid #e5e7eb`,borderRadius:8,padding:`1rem`,boxShadow:`0 4px 12px rgba(0,0,0,0.08)`},children:[(0,H.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.75rem`},children:[(0,H.jsx)(`h3`,{style:{margin:0,fontSize:`0.875rem`,color:`#374151`},children:`Task details`}),i===void 0?null:(0,H.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Close task details`,style:{border:`none`,background:`none`,color:`#9ca3af`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1,padding:0},children:`×`})]}),(0,H.jsx)(`label`,{htmlFor:`task-label-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Label`}),(0,H.jsx)(`input`,{id:`task-label-${e}`,type:`text`,value:o,onChange:e=>{s(e.target.value)},style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,fontWeight:600,boxSizing:`border-box`}}),(0,H.jsx)(`label`,{htmlFor:`task-desc-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Description`}),(0,H.jsx)(`textarea`,{id:`task-desc-${e}`,value:c,onChange:e=>{l(e.target.value)},rows:3,style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,resize:`vertical`,boxSizing:`border-box`}}),(0,H.jsx)(`label`,{htmlFor:`task-assignee-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Assignee`}),(0,H.jsx)(`input`,{id:`task-assignee-${e}`,type:`text`,value:u,onChange:e=>{d(e.target.value)},placeholder:`Unassigned`,style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,boxSizing:`border-box`}}),(0,H.jsx)(`label`,{htmlFor:`task-due-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Due date`}),(0,H.jsx)(`input`,{id:`task-due-${e}`,type:`date`,value:f,onChange:e=>{p(e.target.value)},style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,boxSizing:`border-box`}}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,marginTop:`0.5rem`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{let e=o.trim();n({...e!==``&&e!==t.label?{label:e}:{},description:c.trim()===``?null:c,assignee:u.trim()===``?null:u.trim(),due_date:f===``?null:`${f}T00:00:00.000Z`})},disabled:a,style:{flex:1,padding:`0.5rem`,borderRadius:6,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,fontSize:`0.875rem`,cursor:a?`wait`:`pointer`},children:a?`Saving…`:`Save details`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Delete this task? Connected edges will be removed.`)&&r()},"aria-label":`Delete task`,style:{padding:`0.5rem 0.75rem`,borderRadius:6,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontWeight:600,fontSize:`0.875rem`,cursor:`pointer`},children:`Delete`})]})]})}function XS({projectId:e,documentId:t}){return(0,H.jsx)(Vi,{to:`/projects/$id/documents/$docId`,params:{id:e,docId:t},style:{fontSize:`0.75rem`,fontWeight:600,color:`#1d4ed8`,textDecoration:`none`},onClick:e=>{e.stopPropagation()},children:`Open doc →`})}var ZS={scope:{bg:`#ede9fe`,color:`#5b21b6`},todo:{bg:`#dbeafe`,color:`#1d4ed8`},in_progress:{bg:`#fef3c7`,color:`#b45309`},done:{bg:`#dcfce7`,color:`#15803d`},backlog:{bg:`#f3f4f6`,color:`#4b5563`}},QS=null;function $S(e){QS=e}function eC({id:e,data:t}){let n=ZS[t.status],[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(t.label);(0,V.useEffect)(()=>{o(t.label)},[t.label]);let s=()=>{let n=a.trim();if(n===``||n===t.label){o(t.label),i(!1);return}QS?.onPatchLabel(e,n),i(!1)};return(0,H.jsxs)(`div`,{className:`nodrag`,style:{minWidth:160,padding:`0.75rem 1rem`,borderRadius:8,border:`1px solid #d1d5db`,background:`#fff`,boxShadow:`0 1px 3px rgba(0,0,0,0.08)`},children:[(0,H.jsx)(Eb,{type:`target`,position:q.Top}),(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`0.25rem`,marginBottom:`0.5rem`},children:[r?(0,H.jsx)(`input`,{type:`text`,value:a,autoFocus:!0,onChange:e=>{o(e.target.value)},onBlur:s,onKeyDown:e=>{e.key===`Enter`&&s(),e.key===`Escape`&&(o(t.label),i(!1))},"aria-label":`Task label`,style:{flex:1,fontWeight:600,fontSize:`0.875rem`,border:`1px solid #93c5fd`,borderRadius:4,padding:`0.125rem 0.375rem`}}):(0,H.jsx)(`button`,{type:`button`,onClick:()=>{i(!0)},style:{flex:1,textAlign:`left`,fontWeight:600,lineHeight:1.3,background:`none`,border:`none`,padding:0,cursor:`text`,fontSize:`inherit`,color:`inherit`},children:t.label}),(0,H.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),confirm(`Delete this task? Connected edges will be removed.`)&&QS?.onDelete(e)},"aria-label":`Delete task`,title:`Delete task`,style:{border:`none`,background:`none`,color:`#9ca3af`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1,padding:`0 0.125rem`},children:`×`})]}),(0,H.jsx)(`select`,{value:t.status,onChange:t=>{QS?.onPatchStatus(e,t.target.value)},"aria-label":`Task status`,style:{fontSize:`0.75rem`,fontWeight:600,padding:`0.125rem 0.375rem`,borderRadius:999,background:n.bg,color:n.color,border:`none`,cursor:`pointer`},children:pa.map(e=>(0,H.jsx)(`option`,{value:e,children:e.replace(`_`,` `)},e))}),t.documentId===void 0?null:(0,H.jsx)(`div`,{style:{marginTop:`0.5rem`},children:(0,H.jsx)(XS,{projectId:t.projectId,documentId:t.documentId})}),(0,H.jsx)(Eb,{type:`source`,position:q.Bottom})]})}var tC=400;function nC(e){let t=eo(e),n=(0,V.useRef)([]),r=(0,V.useRef)([]),i=(0,V.useRef)(void 0),a=(0,V.useCallback)(()=>{t.mutate(qS(n.current,r.current))},[t]),o=(0,V.useCallback)(()=>{clearTimeout(i.current),i.current=setTimeout(()=>{a()},tC)},[a]);return(0,V.useEffect)(()=>()=>{clearTimeout(i.current)},[]),{bindFlowState:(0,V.useCallback)((e,t)=>{n.current=e,r.current=t},[]),onNodeDragStop:(0,V.useCallback)(()=>{o()},[o]),saveWithState:(0,V.useCallback)((e,t)=>{n.current=e,r.current=t,clearTimeout(i.current),a()},[a]),isSaving:t.isPending,saveError:t.error}}var rC={taskCard:eC},iC={labeled:JS},aC=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function oC({projectId:e}){let{screenToFlowPosition:t}=rb(),n=Ja(e),[r,i]=(0,V.useState)(``);return(0,H.jsx)(gy,{position:`top-left`,children:(0,H.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let a=r.trim();if(a===``)return;let o=t({x:window.innerWidth/2,y:window.innerHeight/2});n.mutate({label:a,status:`todo`,x:o.x,y:o.y},{onSuccess:()=>{i(``)}})},style:{display:`flex`,gap:`0.375rem`,background:`#fff`,padding:`0.5rem`,borderRadius:6,border:`1px solid #e5e7eb`,boxShadow:`0 1px 3px rgba(0,0,0,0.08)`},children:[(0,H.jsx)(`input`,{type:`text`,value:r,onChange:e=>{i(e.target.value)},placeholder:`New task name`,"aria-label":`New task name`,style:{width:160,padding:`0.375rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,fontSize:`0.875rem`}}),(0,H.jsx)(`button`,{type:`submit`,disabled:n.isPending||r.trim()===``,style:{padding:`0.375rem 0.75rem`,borderRadius:4,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,fontSize:`0.875rem`,cursor:n.isPending?`wait`:`pointer`,whiteSpace:`nowrap`},children:n.isPending?`Adding…`:`+ Add task`})]})})}function sC({projectId:e}){let{data:t,isLoading:n,error:r}=$a(e),{data:i}=to(e),[a,o,s]=cS([]),[c,l,u]=lS([]),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),{bindFlowState:h,onNodeDragStop:g,saveWithState:_,isSaving:v,saveError:y}=nC(e),b=Ya(),x=Xa(),S=lo(e);(0,V.useEffect)(()=>{if(t===void 0)return;let e=i===void 0?void 0:WS(i);o(GS(t.nodes,{taskDocumentMap:e})),l(KS(t.edges))},[t,i,o,l]),(0,V.useEffect)(()=>{h(a,c)},[a,c,h]),(0,V.useEffect)(()=>($S({onPatchLabel:(e,t)=>{b.mutate({id:e,input:{label:t}}),o(n=>n.map(n=>n.id===e?{...n,data:{...n.data,label:t}}:n))},onPatchStatus:(e,t)=>{b.mutate({id:e,input:{status:t}}),o(n=>n.map(n=>n.id===e?{...n,data:{...n.data,status:t}}:n))},onDelete:t=>{x.mutate({id:t,projectId:e},{onSuccess:()=>{f(null)}})}}),()=>{$S(null)}),[b,x,e,o]);let C=(0,V.useCallback)(e=>{l(t=>{let n=Ky({...e,type:`labeled`,data:{label:ma}},t);return _(a,n),n})},[l,a,_]),w=(0,V.useCallback)(()=>{g()},[g]),T=(0,V.useCallback)(e=>{f(e.nodes[0]?.id??null),m(e.edges.map(e=>e.id))},[]),E=(0,V.useCallback)(e=>{l(t=>{let n=t.filter(t=>t.id!==e);return _(a,n),n})},[l,a,_]),D=(0,V.useCallback)(()=>{if(p.length!==0&&confirm(`Delete ${String(p.length)} selected edge(s)?`)){for(let e of p)aC.test(e)?S.mutate(e,{onSuccess:()=>{E(e)}}):E(e);m([])}},[p,S,E]),O=(0,V.useCallback)(e=>{if(e.key===`Delete`||e.key===`Backspace`){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)return;p.length>0&&(e.preventDefault(),D())}},[p,D]),k=d===null?void 0:a.find(e=>e.id===d);return n?(0,H.jsx)(`p`,{children:`Loading canvas…`}):r===null?t===void 0?(0,H.jsx)(`p`,{children:`Canvas not found.`}):(0,H.jsxs)(`div`,{style:{position:`relative`},onKeyDown:O,tabIndex:0,children:[v?(0,H.jsx)(`span`,{style:{position:`absolute`,top:8,left:`50%`,transform:`translateX(-50%)`,zIndex:10,fontSize:`0.75rem`,color:`#6b7280`,background:`#fff`,padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #e5e7eb`},children:`Saving…`}):null,y===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{color:`#b91c1c`,marginBottom:`0.5rem`},children:[`Save failed: `,y.message]}),p.length>0?(0,H.jsx)(gy,{position:`top-center`,children:(0,H.jsx)(`button`,{type:`button`,onClick:D,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontWeight:600,fontSize:`0.875rem`,cursor:`pointer`},children:`Delete edge`})}):null,k===void 0?null:(0,H.jsx)(YS,{taskId:k.id,data:k.data,isSaving:b.isPending,onPatch:e=>{b.mutate({id:k.id,input:e})},onDelete:()=>{x.mutate({id:k.id,projectId:e},{onSuccess:()=>{f(null)}})}}),(0,H.jsx)(`div`,{style:{width:`100%`,height:`calc(100vh - 12rem)`,border:`1px solid #e5e7eb`},children:(0,H.jsxs)(aS,{nodes:a,edges:c,onNodesChange:s,onEdgesChange:u,onConnect:C,onNodeDragStop:w,onSelectionChange:T,nodeTypes:rC,edgeTypes:iC,fitView:!0,children:[(0,H.jsx)(gS,{}),(0,H.jsx)(TS,{}),(0,H.jsx)(oC,{projectId:e})]})})]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load canvas: `,r.message]})}function cC(e){let t=e.status;return typeof t==`string`&&pa.includes(t)?{status:t}:{}}function lC(){let{id:e}=uC.useParams(),{status:t}=uC.useSearch(),{data:n,isLoading:r,error:i}=Ga(e);return r?(0,H.jsx)(`p`,{children:`Loading project…`}):i?(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load project: `,i.message]}):n===void 0?(0,H.jsx)(`p`,{children:`Project not found.`}):(0,H.jsxs)(`section`,{children:[(0,H.jsxs)(`nav`,{style:{display:`flex`,gap:`1rem`,marginBottom:`1.5rem`},children:[(0,H.jsx)(Vi,{to:`/projects/$id/overview`,params:{id:e},style:{color:`#555`},children:`Overview`}),(0,H.jsx)(Vi,{to:`/projects/$id/flow`,params:{id:e},style:{fontWeight:600,color:`#1a56db`},children:`Flow`}),(0,H.jsx)(Vi,{to:`/projects/$id/board`,params:{id:e},style:{color:`#555`},children:`Board`})]}),(0,H.jsxs)(`h1`,{style:{marginTop:0},children:[n.name,` — Flow`]}),t===void 0?null:(0,H.jsxs)(`p`,{style:{color:`#666`,marginTop:0},children:[`Filter: `,t]}),(0,H.jsxs)(`div`,{style:{position:`relative`},children:[(0,H.jsx)(Su,{projectId:e}),(0,H.jsx)(sC,{projectId:e})]})]})}var uC=qi(`/projects/$id/flow`)({validateSearch:cC,component:lC}),dC=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function fC(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function pC(e){return`nodeType`in e}function mC(e){return e?fC(e)?e:pC(e)?e.ownerDocument?.defaultView??window:window:window}function hC(e){let{Document:t}=mC(e);return e instanceof t}function gC(e){return fC(e)?!1:e instanceof mC(e).HTMLElement}function _C(e){return e instanceof mC(e).SVGElement}function vC(e){return e?fC(e)?e.document:pC(e)?hC(e)?e:gC(e)||_C(e)?e.ownerDocument:document:document:document}var yC=dC?V.useLayoutEffect:V.useEffect;function bC(e){let t=(0,V.useRef)(e);return yC(()=>{t.current=e}),(0,V.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function xC(){let e=(0,V.useRef)(null);return[(0,V.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,V.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function SC(e,t){t===void 0&&(t=[e]);let n=(0,V.useRef)(e);return yC(()=>{n.current!==e&&(n.current=e)},t),n}function CC(e,t){let n=(0,V.useRef)();return(0,V.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function wC(e){let t=bC(e),n=(0,V.useRef)(null);return[n,(0,V.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function TC(e){let t=(0,V.useRef)();return(0,V.useEffect)(()=>{t.current=e},[e]),t.current}var EC={};function DC(e,t){return(0,V.useMemo)(()=>{if(t)return t;let n=EC[e]==null?0:EC[e]+1;return EC[e]=n,e+`-`+n},[e,t])}function OC(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var kC=OC(1),AC=OC(-1);function jC(e){return`clientX`in e&&`clientY`in e}function MC(e){if(!e)return!1;let{KeyboardEvent:t}=mC(e.target);return t&&e instanceof t}function NC(e){if(!e)return!1;let{TouchEvent:t}=mC(e.target);return t&&e instanceof t}function PC(e){if(NC(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return jC(e)?{x:e.clientX,y:e.clientY}:null}var FC=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[FC.Translate.toString(e),FC.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),IC=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function LC(e){return e.matches(IC)?e:e.querySelector(IC)}var RC={display:`none`};function zC(e){let{id:t,value:n}=e;return V.createElement(`div`,{id:t,style:RC},n)}function BC(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return V.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function VC(){let[e,t]=(0,V.useState)(``);return{announce:(0,V.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var HC=(0,V.createContext)(null);function UC(e){let t=(0,V.useContext)(HC);(0,V.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function WC(){let[e]=(0,V.useState)(()=>new Set),t=(0,V.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,V.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var GC={draggable:`
|
|
81
|
+
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}zS.displayName=`MiniMap`,(0,V.memo)(zS);var BS=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,VS={[Fv.Line]:`right`,[Fv.Handle]:`bottom-right`};function HS({nodeId:e,position:t,variant:n=Fv.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=Sb(),y=typeof e==`string`?e:v,b=oy(),x=(0,V.useRef)(null),S=n===Fv.Handle,C=ay((0,V.useCallback)(BS(S&&p),[S,p]),ty),w=(0,V.useRef)(null),T=t??VS[n];return(0,V.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Kv({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=$_([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...i_({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,H.jsx)(`div`,{className:Cu([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,V.memo)(HS);var US=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function WS(e){let t=new Map;function n(e){for(let r of e)r.linked_task_id!==null&&t.set(r.linked_task_id,r.id),n(r.children)}return n(e),t}function GS(e,t={}){return e.map(e=>({id:e.id,type:`taskCard`,position:{x:e.x,y:e.y},data:{label:e.label,status:e.status,projectId:e.project_id,documentId:t.taskDocumentMap?.get(e.id),description:e.description,assignee:e.assignee,dueDate:e.due_date}}))}function KS(e){return e.map(e=>({id:e.id,type:`labeled`,source:e.from_task_id,target:e.to_task_id,data:{label:e.label??`depends_on`}}))}function qS(e,t){return{nodes:e.map(e=>({id:e.id,x:e.position.x,y:e.position.y})),edges:t.map(e=>{let t={from_task_id:e.source,to_task_id:e.target,label:e.data?.label??`depends_on`};return US.test(e.id)&&(t.id=e.id),t})}}function JS({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,data:s}){let[c,l,u]=y_({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ox,{id:e,path:c}),(0,H.jsx)(sS,{children:(0,H.jsx)(`div`,{className:`nodrag nopan`,style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${String(l)}px,${String(u)}px)`,fontSize:`0.7rem`,fontWeight:600,padding:`0.125rem 0.375rem`,borderRadius:4,background:`#f3f4f6`,color:`#374151`,border:`1px solid #d1d5db`,pointerEvents:`all`},children:s?.label??`depends_on`})})]})}var YS=Object.defineProperty,XS=(e,t,n)=>t in e?YS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ZS=(e,t)=>{for(var n in t)YS(e,n,{get:t[n],enumerable:!0})},QS=(e,t,n)=>XS(e,typeof t==`symbol`?t:t+``,n),$S={};ZS($S,{Graph:()=>nC,alg:()=>mC,json:()=>lC,version:()=>cC});var eC=Object.defineProperty,tC=(e,t)=>{for(var n in t)eC(e,n,{get:t[n],enumerable:!0})},nC=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e?e.multigraph:!1,this._isCompound=`compound`in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e==`function`?this._defaultNodeLabelFn=e:this._defaultNodeLabelFn=()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let t of this.successors(e))n.add(t);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return typeof e==`function`?this._defaultEdgeLabelFn=e:this._defaultEdgeLabelFn=()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=aC(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=oC(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,rC(this._preds[a],i),rC(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?sC(this._isDirected,e):aC(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r==`object`?r:{label:r}}hasEdge(e,t,n){return(arguments.length===1?sC(this._isDirected,e):aC(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?sC(this._isDirected,e):aC(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],iC(this._preds[t],e),iC(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function rC(e,t){e[t]?e[t]++:e[t]=1}function iC(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function aC(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function oC(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function sC(e,t){return aC(e,t.v,t.w,t.name)}var cC=`4.0.1`,lC={};tC(lC,{read:()=>pC,write:()=>uC});function uC(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:dC(e),edges:fC(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function dC(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function fC(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function pC(e){let t=new nC(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var mC={};tC(mC,{CycleException:()=>kC,bellmanFord:()=>gC,components:()=>vC,dijkstra:()=>xC,dijkstraAll:()=>CC,findCycles:()=>TC,floydWarshall:()=>DC,isAcyclic:()=>jC,postorder:()=>FC,preorder:()=>IC,prim:()=>LC,shortestPaths:()=>RC,tarjan:()=>wC,topsort:()=>AC});var hC=()=>1;function gC(e,t,n,r){return _C(e,String(t),n||hC,r||function(t){return e.outEdges(t)})}function _C(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=n(e);i[e.v].distance+t<i[e.w].distance&&(i[e.w]={distance:i[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w;c({v:n,w:n===t.v?t.w:t.v})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function vC(e){let t={},n=[],r;function i(n){n in t||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var yC=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},bC=()=>1;function xC(e,t,n,r){return SC(e,String(t),n||bC,r||function(t){return e.outEdges(t)})}function SC(e,t,n,r){let i={},a=new yC,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t],c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0&&(o=a.removeMin(),s=i[o],s.distance!==1/0);)r(o).forEach(c);return i}function CC(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=xC(e,i,t,n),r},{})}function wC(e){let t=0,n=[],r={},i=[];function a(o){let s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){e in r?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){let e=[],t;do t=n.pop(),r[t].onStack=!1,e.push(t);while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function TC(e){return wC(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var EC=()=>1;function DC(e,t,n){return OC(e,t||EC,n||function(t){return e.outEdges(t)})}function OC(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){let t=r[e];i.forEach(function(n){let a=r[n];i.forEach(function(n){let r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}var kC=class extends Error{constructor(...e){super(...e)}};function AC(e){let t={},n={},r=[];function i(a){if(a in n)throw new kC;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new kC;return r}function jC(e){try{AC(e)}catch(e){if(e instanceof kC)return!1;throw e}return!0}function MC(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=NC(e,t,n===`post`,o,a,r,i)}),i}function NC(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=NC(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function PC(e,t,n){return MC(e,t,n,function(e,t){return e.push(t),e},[])}function FC(e,t){return PC(e,t,`post`)}function IC(e,t){return PC(e,t,`pre`)}function LC(e,t){let n=new nC,r={},i=new yC,a;function o(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(o!==void 0){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){i.add(e,1/0),n.setNode(e)}),i.decrease(e.nodes()[0],0);let s=!1;for(;i.size()>0;){if(a=i.removeMin(),a in r)n.setEdge(a,r[a]);else{if(s)throw Error(`Input graph is not connected: `+e);s=!0}e.nodeEdges(a).forEach(o)}return n}function RC(e,t,n,r){return zC(e,t,n,r??(t=>e.outEdges(t)??[]))}function zC(e,t,n,r){if(n===void 0)return xC(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=r(a[o]);for(let e=0;e<s.length;e++){let t=s[e],r=t.v===a[o]?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return gC(e,t,n,r)}return xC(e,t,n,r)}function BC(e,t,n,r){let i=r;for(;e.hasNode(i);)i=nw(r);return n.dummy=t,e.setNode(i,n),i}function VC(e){let t=new nC().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function HC(e){let t=new nC({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function UC(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function WC(e){let t=rw(ZC(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function GC(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=XC(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function KC(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=XC(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function qC(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),BC(e,`border`,i,t)}function JC(e,t=YC){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var YC=65535;function XC(e,t){return t.length>YC?e(...JC(t).map(t=>e(...t))):e(...t)}function ZC(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return XC(Math.max,t)}function QC(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function $C(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function ew(e,t){return t()}var tw=0;function nw(e){return e+(``+ ++tw)}function rw(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function iw(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function aw(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function ow(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var sw=`\0`,cw=`3.0.0`,lw=class{constructor(){QS(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return uw(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&uw(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,dw)),n=n._prev;return`[`+e.join(`, `)+`]`}};function uw(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function dw(e,t){if(e!==`_next`&&e!==`_prev`)return t}var fw=lw,pw=()=>1;function mw(e,t){if(e.nodeCount()<=1)return[];let n=_w(e,t||pw);return hw(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function hw(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)gw(e,t,n,o);for(;o=i.dequeue();)gw(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(gw(e,t,n,o,!0)||[]);break}}}return r}function gw(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,vw(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,vw(t,n,o)}),e.removeNode(r.v),o}function _w(e,t){let n=new nC,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=yw(i+r+3).map(()=>new fw),o=r+1;return n.nodes().forEach(e=>{vw(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function vw(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function yw(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function bw(e){(e.graph().acyclicer===`greedy`?mw(e,t(e)):xw(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,nw(`rev`))});function t(e){return t=>e.edge(t).weight}}function xw(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function Sw(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Cw(e){e.graph().dummyChains=[],e.edges().forEach(t=>ww(e,t))}function ww(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d;for(d=0,++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=BC(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Tw(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Ew(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=XC(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function Dw(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ow=kw;function kw(e){let t=new nC({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;Aw(t,e)<i&&(a=jw(t,e),a);)o=t.hasNode(a.v)?Dw(e,a):-Dw(e,a),Mw(t,e,o);return t}function Aw(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!Dw(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function jw(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=Dw(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function Mw(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Nw,postorder:Pw}=mC,Fw=Iw;Iw.initLowLimValues=Bw,Iw.initCutValues=Lw,Iw.calcCutValue=zw,Iw.leaveEdge=Hw,Iw.enterEdge=Uw,Iw.exchangeEdges=Ww;function Iw(e){e=VC(e),Ew(e);let t=Ow(e);Bw(t),Lw(t,e);let n,r;for(;n=Hw(t);)r=Uw(t,e,n),Ww(t,e,n,r)}function Lw(e,t){let n=Pw(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Rw(e,t,n))}function Rw(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=zw(e,t,n)}function zw(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,Kw(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Bw(e,t){arguments.length<2&&(t=e.nodes()[0]),Vw(e,{},1,t)}function Vw(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=Vw(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function Hw(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Uw(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===qw(e,e.node(t.v),s)&&c!==qw(e,e.node(t.w),s)).reduce((e,n)=>Dw(t,n)<Dw(t,e)?n:e)}function Ww(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Bw(e),Lw(e,t),Gw(e,t)}function Gw(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Nw(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function Kw(e,t,n){return e.hasEdge(t,n)}function qw(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Jw=Yw;function Yw(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Qw(e);break;case`tight-tree`:Zw(e);break;case`longest-path`:Xw(e);break;case`none`:break;default:Qw(e)}}var Xw=Ew;function Zw(e){Ew(e),Ow(e)}function Qw(e){Fw(e)}var $w=eT;function eT(e){let t=nT(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=tT(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function tT(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function nT(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(sw).forEach(r),t}function rT(e){let t=BC(e,`root`,{},`_root`),n=aT(e),r=Object.values(n),i=XC(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=oT(e)+1;e.children(sw).forEach(r=>iT(e,t,a,o,i,n,r)),e.graph().nodeRankFactor=a}function iT(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=qC(e,`_bt`),l=qC(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{iT(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function aT(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(sw).forEach(e=>n(e,1)),t}function oT(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function sT(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var cT=lT;function lT(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)uT(e,`borderLeft`,`_bl`,n,i,t),uT(e,`borderRight`,`_br`,n,i,t)}}e.children(sw).forEach(t)}function uT(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=BC(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function dT(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&pT(e)}function fT(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&hT(e),(t===`lr`||t===`rl`)&&(_T(e),pT(e))}function pT(e){e.nodes().forEach(t=>mT(e.node(t))),e.edges().forEach(t=>mT(e.edge(t)))}function mT(e){let t=e.width;e.width=e.height,e.height=t}function hT(e){e.nodes().forEach(t=>gT(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(gT),Object.hasOwn(r,`y`)&&gT(r)})}function gT(e){e.y=-e.y}function _T(e){e.nodes().forEach(t=>vT(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(vT),Object.hasOwn(r,`x`)&&vT(r)})}function vT(e){let t=e.x;e.x=e.y,e.y=t}function yT(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),r=n.map(t=>e.node(t).rank),i=rw(XC(Math.max,r)+1).map(()=>[]);function a(n){if(t[n])return;t[n]=!0,i[e.node(n).rank].push(n);let r=e.successors(n);r&&r.forEach(a)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(a),i}function bT(e,t){let n=0;for(let r=1;r<t.length;++r)n+=xT(e,t[r-1],t[r]);return n}function xT(e,t,n){let r=ow(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function ST(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function CT(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),wT(Object.values(n).filter(e=>!e.indegree))}function wT(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&TT(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>iw(e,[`vs`,`i`,`barycenter`,`weight`]))}function TT(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function ET(e,t){let n=QC(e,e=>Object.hasOwn(e,`barycenter`)),r=n.lhs,i=n.rhs.sort((e,t)=>t.i-e.i),a=[],o=0,s=0,c=0;r.sort(OT(!!t)),c=DT(a,i,c),r.forEach(e=>{c+=e.vs.length,a.push(e.vs),o+=e.barycenter*e.weight,s+=e.weight,c=DT(a,i,c)});let l={vs:a.flat(1)};return s&&(l.barycenter=o/s,l.weight=s),l}function DT(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function OT(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function kT(e,t,n,r){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=i.filter(e=>e!==o&&e!==s));let l=ST(e,i);l.forEach(t=>{if(e.children(t.v).length){let i=kT(e,t.v,n,r);c[t.v]=i,Object.hasOwn(i,`barycenter`)&&jT(t,i)}});let u=CT(l,n);AT(u,c);let d=ET(u,r);if(o&&s){d.vs=[o,d.vs,s].flat(1);let t=e.predecessors(o);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(s),i=e.node(r[0]);Object.hasOwn(d,`barycenter`)||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+n.order+i.order)/(d.weight+2),d.weight+=2}}return d}function AT(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function jT(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function MT(e,t,n,r){r||=e.nodes();let i=NT(e),a=new nC({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function NT(e){let t;for(;e.hasNode(t=nw(`_root`)););return t}function PT(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function FT(e,t={}){if(typeof t.customOrder==`function`){t.customOrder(e,FT);return}let n=ZC(e),r=IT(e,rw(1,n+1),`inEdges`),i=IT(e,rw(n-1,-1,-1),`outEdges`),a=yT(e);if(RT(e,a),t.disableOptimalOrderHeuristic)return;let o=1/0,s,c=t.constraints||[];for(let t=0,n=0;n<4;++t,++n){LT(t%2?r:i,t%4>=2,c),a=WC(e);let l=bT(e,a);l<o?(n=0,s=Object.assign({},a),o=l):l===o&&(s=structuredClone(a))}RT(e,s)}function IT(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return MT(e,t,n,r.get(t)||[])})}function LT(e,t,n){let r=new nC;e.forEach(function(e){n.forEach(e=>r.setEdge(e.left,e.right));let i=e.graph().root,a=kT(e,i,r,t);a.vs.forEach((t,n)=>e.node(t).order=n),PT(e,r,a.vs)})}function RT(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function zT(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=VT(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&HT(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function BT(e,t){let n={};function r(t,r,i,a,o){rw(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&HT(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function VT(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function HT(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function UT(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function WT(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s&&s.length){let r=s.sort((e,t)=>{let n=o[e],r=o[t];return(n===void 0?0:n)-(r===void 0?0:r)}),c=(r.length-1)/2;for(let s=Math.floor(c),l=Math.ceil(c);s<=l;++s){let c=r[s];if(c===void 0)continue;let l=o[c];if(l!==void 0&&a[e]===e&&t<l&&!UT(n,e,c)){let n=i[c];n!==void 0&&(a[c]=e,a[e]=i[e]=n,t=l)}}}})}),{root:i,align:a}}function GT(e,t,n,r,i=!1){let a={},o=KT(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function KT(e,t,n,r){let i=new nC,a=e.graph(),o=ZT(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function qT(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=QT(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function JT(e,t){let n=Object.values(t),r=XC(Math.min,n),i=XC(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-XC(Math.min,c);a!==`l`&&(l=i-XC(Math.max,c)),l&&(e[o]=aw(s,e=>e+l))})})}function YT(e,t=void 0){let n=e.ul;return n?aw(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function XT(e){let t=WC(e),n=Object.assign(zT(e,t),BT(e,t)),r={},i;return[`u`,`d`].forEach(a=>{i=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(i=i.map(e=>Object.values(e).reverse()));let o=WT(e,i,n,t=>(a===`u`?e.predecessors(t):e.successors(t))||[]),s=GT(e,i,o.root,o.align,t===`r`);t===`r`&&(s=aw(s,e=>-e)),r[a+t]=s})}),JT(r,qT(e,r)),YT(r,e.graph().align)}function ZT(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),c}}function QT(e,t){return e.node(t).width}function $T(e){e=HC(e),eE(e),Object.entries(XT(e)).forEach(([t,n])=>e.node(t).x=n)}function eE(e){let t=WC(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);i===`top`?r.y=a+r.height/2:i===`bottom`?r.y=a+n-r.height/2:r.y=a+n/2}),a+=n+r})}function tE(e,t={}){let n=t.debugTiming?$C:ew;return n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>fE(e));return n(` runLayout`,()=>nE(r,n,t)),n(` updateInputGraph`,()=>rE(e,r)),r})}function nE(e,t,n){t(` makeSpaceForEdgeLabels`,()=>pE(e)),t(` removeSelfEdges`,()=>SE(e)),t(` acyclic`,()=>bw(e)),t(` nestingGraph.run`,()=>rT(e)),t(` rank`,()=>Jw(HC(e))),t(` injectEdgeLabelProxies`,()=>mE(e)),t(` removeEmptyRanks`,()=>KC(e)),t(` nestingGraph.cleanup`,()=>sT(e)),t(` normalizeRanks`,()=>GC(e)),t(` assignRankMinMax`,()=>hE(e)),t(` removeEdgeLabelProxies`,()=>gE(e)),t(` normalize.run`,()=>Cw(e)),t(` parentDummyChains`,()=>$w(e)),t(` addBorderSegments`,()=>cT(e)),t(` order`,()=>FT(e,n)),t(` insertSelfEdges`,()=>CE(e)),t(` adjustCoordinateSystem`,()=>dT(e)),t(` position`,()=>$T(e)),t(` positionSelfEdges`,()=>wE(e)),t(` removeBorderNodes`,()=>xE(e)),t(` normalize.undo`,()=>Tw(e)),t(` fixupEdgeLabelCoords`,()=>yE(e)),t(` undoCoordinateSystem`,()=>fT(e)),t(` translateGraph`,()=>_E(e)),t(` assignNodeIntersects`,()=>vE(e)),t(` reversePoints`,()=>bE(e)),t(` acyclic.undo`,()=>Sw(e))}function rE(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var iE=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],aE={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},oE=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],sE=[`width`,`height`,`rank`],cE={width:0,height:0},lE=[`minlen`,`weight`,`width`,`height`,`labeloffset`],uE={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},dE=[`labelpos`];function fE(e){let t=new nC({multigraph:!0,compound:!0}),n=EE(e.graph());return t.setGraph(Object.assign({},aE,TE(n,iE),iw(n,oE))),e.nodes().forEach(n=>{let r=TE(EE(e.node(n)),sE);Object.keys(cE).forEach(e=>{r[e]===void 0&&(r[e]=cE[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=EE(e.edge(n));t.setEdge(n,Object.assign({},uE,TE(r,lE),iw(r,dE)))}),t}function pE(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function mE(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);BC(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function hE(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function gE(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function _E(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function vE(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(UC(r,a)),n.points.push(UC(i,o))})}function yE(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function bE(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function xE(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function SE(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function CE(e){WC(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{BC(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function wE(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`selfedge`){let r=n,i=e.node(r.e.v),a=i.x+i.width/2,o=i.y,s=n.x-a,c=i.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*s/3,y:o-c},{x:a+5*s/6,y:o-c},{x:a+s,y:o},{x:a+5*s/6,y:o+c},{x:a+2*s/3,y:o+c}],r.label.x=n.x,r.label.y=n.y}})}function TE(e,t){return aw(iw(e,t),Number)}function EE(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function DE(e){let t=WC(e),n=new nC({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var OE={graphlib:$S,version:cw,layout:tE,debug:DE,util:{time:$C,notime:ew}},kE=200,AE=120;function jE(e,t){let n=new OE.graphlib.Graph().setDefaultEdgeLabel(()=>({}));n.setGraph({rankdir:`TB`,nodesep:60,ranksep:80});for(let t of e)n.setNode(t.id,{width:t.measured?.width??kE,height:t.measured?.height??AE});for(let e of t)n.setEdge(e.source,e.target);return OE.layout(n),e.map(e=>{let t=n.node(e.id),r=e.measured?.width??kE,i=e.measured?.height??AE;return{...e,position:{x:t.x-r/2,y:t.y-i/2}}})}function ME({taskId:e,data:t,onPatch:n,onDelete:r,onClose:i,isSaving:a=!1}){let[o,s]=(0,V.useState)(t.label),[c,l]=(0,V.useState)(t.description??``),[u,d]=(0,V.useState)(t.assignee??``),[f,p]=(0,V.useState)(t.dueDate===null?``:t.dueDate.slice(0,10));return(0,V.useEffect)(()=>{s(t.label),l(t.description??``),d(t.assignee??``),p(t.dueDate===null?``:t.dueDate.slice(0,10))},[e,t.label,t.description,t.assignee,t.dueDate]),(0,H.jsxs)(`aside`,{"aria-label":`Task details`,style:{position:`absolute`,top:8,right:8,zIndex:10,width:280,background:`#fff`,border:`1px solid #e5e7eb`,borderRadius:8,padding:`1rem`,boxShadow:`0 4px 12px rgba(0,0,0,0.08)`},children:[(0,H.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.75rem`},children:[(0,H.jsx)(`h3`,{style:{margin:0,fontSize:`0.875rem`,color:`#374151`},children:`Task details`}),i===void 0?null:(0,H.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Close task details`,style:{border:`none`,background:`none`,color:`#9ca3af`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1,padding:0},children:`×`})]}),(0,H.jsx)(`label`,{htmlFor:`task-label-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Label`}),(0,H.jsx)(`input`,{id:`task-label-${e}`,type:`text`,value:o,onChange:e=>{s(e.target.value)},style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,fontWeight:600,boxSizing:`border-box`}}),(0,H.jsx)(`label`,{htmlFor:`task-desc-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Description`}),(0,H.jsx)(`textarea`,{id:`task-desc-${e}`,value:c,onChange:e=>{l(e.target.value)},rows:3,style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,resize:`vertical`,boxSizing:`border-box`}}),(0,H.jsx)(`label`,{htmlFor:`task-assignee-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Assignee`}),(0,H.jsx)(`input`,{id:`task-assignee-${e}`,type:`text`,value:u,onChange:e=>{d(e.target.value)},placeholder:`Unassigned`,style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,boxSizing:`border-box`}}),(0,H.jsx)(`label`,{htmlFor:`task-due-${e}`,style:{display:`block`,fontSize:`0.75rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Due date`}),(0,H.jsx)(`input`,{id:`task-due-${e}`,type:`date`,value:f,onChange:e=>{p(e.target.value)},style:{width:`100%`,marginBottom:`0.75rem`,padding:`0.5rem`,borderRadius:6,border:`1px solid #d1d5db`,fontSize:`0.875rem`,boxSizing:`border-box`}}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,marginTop:`0.5rem`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{let e=o.trim();n({...e!==``&&e!==t.label?{label:e}:{},description:c.trim()===``?null:c,assignee:u.trim()===``?null:u.trim(),due_date:f===``?null:`${f}T00:00:00.000Z`})},disabled:a,style:{flex:1,padding:`0.5rem`,borderRadius:6,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,fontSize:`0.875rem`,cursor:a?`wait`:`pointer`},children:a?`Saving…`:`Save details`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Delete this task? Connected edges will be removed.`)&&r()},"aria-label":`Delete task`,style:{padding:`0.5rem 0.75rem`,borderRadius:6,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontWeight:600,fontSize:`0.875rem`,cursor:`pointer`},children:`Delete`})]})]})}function NE({projectId:e,documentId:t}){return(0,H.jsx)(Vi,{to:`/projects/$id/documents/$docId`,params:{id:e,docId:t},style:{fontSize:`0.75rem`,fontWeight:600,color:`#1d4ed8`,textDecoration:`none`},onClick:e=>{e.stopPropagation()},children:`Open doc →`})}var PE={scope:{bg:`#ede9fe`,color:`#5b21b6`},todo:{bg:`#dbeafe`,color:`#1d4ed8`},in_progress:{bg:`#fef3c7`,color:`#b45309`},done:{bg:`#dcfce7`,color:`#15803d`},backlog:{bg:`#f3f4f6`,color:`#4b5563`}},FE=null;function IE(e){FE=e}function LE({id:e,data:t}){let n=PE[t.status],[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(t.label);(0,V.useEffect)(()=>{o(t.label)},[t.label]);let s=()=>{let n=a.trim();if(n===``||n===t.label){o(t.label),i(!1);return}FE?.onPatchLabel(e,n),i(!1)};return(0,H.jsxs)(`div`,{style:{minWidth:160,padding:`0.75rem 1rem`,borderRadius:8,border:`1px solid #d1d5db`,background:`#fff`,boxShadow:`0 1px 3px rgba(0,0,0,0.08)`,cursor:`grab`},children:[(0,H.jsx)(Eb,{type:`target`,position:q.Top}),(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`0.25rem`,marginBottom:`0.5rem`},children:[r?(0,H.jsx)(`input`,{className:`nodrag`,type:`text`,value:a,autoFocus:!0,onChange:e=>{o(e.target.value)},onBlur:s,onKeyDown:e=>{e.key===`Enter`&&s(),e.key===`Escape`&&(o(t.label),i(!1))},"aria-label":`Task label`,style:{flex:1,fontWeight:600,fontSize:`0.875rem`,border:`1px solid #93c5fd`,borderRadius:4,padding:`0.125rem 0.375rem`}}):(0,H.jsx)(`button`,{className:`nodrag`,type:`button`,onClick:()=>{i(!0)},style:{flex:1,textAlign:`left`,fontWeight:600,lineHeight:1.3,background:`none`,border:`none`,padding:0,cursor:`text`,fontSize:`inherit`,color:`inherit`},children:t.label}),(0,H.jsx)(`button`,{className:`nodrag`,type:`button`,onClick:t=>{t.stopPropagation(),confirm(`Delete this task? Connected edges will be removed.`)&&FE?.onDelete(e)},"aria-label":`Delete task`,title:`Delete task`,style:{border:`none`,background:`none`,color:`#9ca3af`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1,padding:`0 0.125rem`},children:`×`})]}),(0,H.jsx)(`select`,{className:`nodrag`,value:t.status,onChange:t=>{FE?.onPatchStatus(e,t.target.value)},"aria-label":`Task status`,style:{fontSize:`0.75rem`,fontWeight:600,padding:`0.125rem 0.375rem`,borderRadius:999,background:n.bg,color:n.color,border:`none`,cursor:`pointer`},children:pa.map(e=>(0,H.jsx)(`option`,{value:e,children:e.replace(`_`,` `)},e))}),t.documentId===void 0?null:(0,H.jsx)(`div`,{className:`nodrag`,style:{marginTop:`0.5rem`},children:(0,H.jsx)(NE,{projectId:t.projectId,documentId:t.documentId})}),(0,H.jsx)(Eb,{type:`source`,position:q.Bottom})]})}var RE=400;function zE(e){let t=eo(e),n=(0,V.useRef)([]),r=(0,V.useRef)([]),i=(0,V.useRef)(void 0),a=(0,V.useCallback)(()=>{t.mutate(qS(n.current,r.current))},[t]),o=(0,V.useCallback)(()=>{clearTimeout(i.current),i.current=setTimeout(()=>{a()},RE)},[a]);return(0,V.useEffect)(()=>()=>{clearTimeout(i.current)},[]),{bindFlowState:(0,V.useCallback)((e,t)=>{n.current=e,r.current=t},[]),onNodeDragStop:(0,V.useCallback)(()=>{o()},[o]),saveWithState:(0,V.useCallback)((e,t)=>{n.current=e,r.current=t,clearTimeout(i.current),a()},[a]),isSaving:t.isPending,saveError:t.error}}var BE={taskCard:LE},VE={labeled:JS},HE=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function UE({projectId:e}){let{screenToFlowPosition:t}=rb(),n=Ja(e),[r,i]=(0,V.useState)(``);return(0,H.jsx)(gy,{position:`top-left`,children:(0,H.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let a=r.trim();if(a===``)return;let o=t({x:window.innerWidth/2,y:window.innerHeight/2});n.mutate({label:a,status:`todo`,x:o.x,y:o.y},{onSuccess:()=>{i(``)}})},style:{display:`flex`,gap:`0.375rem`,background:`#fff`,padding:`0.5rem`,borderRadius:6,border:`1px solid #e5e7eb`,boxShadow:`0 1px 3px rgba(0,0,0,0.08)`},children:[(0,H.jsx)(`input`,{type:`text`,value:r,onChange:e=>{i(e.target.value)},placeholder:`New task name`,"aria-label":`New task name`,style:{width:160,padding:`0.375rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,fontSize:`0.875rem`}}),(0,H.jsx)(`button`,{type:`submit`,disabled:n.isPending||r.trim()===``,style:{padding:`0.375rem 0.75rem`,borderRadius:4,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,fontSize:`0.875rem`,cursor:n.isPending?`wait`:`pointer`,whiteSpace:`nowrap`},children:n.isPending?`Adding…`:`+ Add task`})]})})}function WE({onArrange:e}){let{fitView:t}=rb();return(0,H.jsx)(gy,{position:`top-right`,children:(0,H.jsx)(`button`,{type:`button`,onClick:()=>{e(),t({padding:.2,duration:300})},style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:`#fff`,fontWeight:600,fontSize:`0.875rem`,cursor:`pointer`,boxShadow:`0 1px 3px rgba(0,0,0,0.08)`},children:`Auto-arrange`})})}function GE({projectId:e}){let{data:t,isLoading:n,error:r}=$a(e),{data:i}=to(e),[a,o,s]=cS([]),[c,l,u]=lS([]),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)([]),{bindFlowState:h,onNodeDragStop:g,saveWithState:_,isSaving:v,saveError:y}=zE(e),b=Ya(),x=Xa(),S=lo(e);(0,V.useEffect)(()=>{if(t===void 0)return;let e=i===void 0?void 0:WS(i);o(GS(t.nodes,{taskDocumentMap:e})),l(KS(t.edges))},[t,i,o,l]),(0,V.useEffect)(()=>{h(a,c)},[a,c,h]),(0,V.useEffect)(()=>(IE({onPatchLabel:(e,t)=>{b.mutate({id:e,input:{label:t}}),o(n=>n.map(n=>n.id===e?{...n,data:{...n.data,label:t}}:n))},onPatchStatus:(e,t)=>{b.mutate({id:e,input:{status:t}}),o(n=>n.map(n=>n.id===e?{...n,data:{...n.data,status:t}}:n))},onDelete:t=>{x.mutate({id:t,projectId:e},{onSuccess:()=>{f(null)}})}}),()=>{IE(null)}),[b,x,e,o]);let C=(0,V.useCallback)(e=>{l(t=>{let n=Ky({...e,type:`labeled`,data:{label:ma}},t);return _(a,n),n})},[l,a,_]),w=(0,V.useCallback)(()=>{g()},[g]),T=(0,V.useCallback)(()=>{o(e=>{let t=jE(e,c);return _(t,c),t})},[o,c,_]),E=(0,V.useCallback)(e=>{f(e.nodes[0]?.id??null),m(e.edges.map(e=>e.id))},[]),D=(0,V.useCallback)(e=>{l(t=>{let n=t.filter(t=>t.id!==e);return _(a,n),n})},[l,a,_]),O=(0,V.useCallback)(()=>{if(p.length!==0&&confirm(`Delete ${String(p.length)} selected edge(s)?`)){for(let e of p)HE.test(e)?S.mutate(e,{onSuccess:()=>{D(e)}}):D(e);m([])}},[p,S,D]),k=(0,V.useCallback)(e=>{if(e.key===`Delete`||e.key===`Backspace`){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)return;p.length>0&&(e.preventDefault(),O())}},[p,O]),A=d===null?void 0:a.find(e=>e.id===d);return n?(0,H.jsx)(`p`,{children:`Loading canvas…`}):r===null?t===void 0?(0,H.jsx)(`p`,{children:`Canvas not found.`}):(0,H.jsxs)(`div`,{style:{position:`relative`},onKeyDown:k,tabIndex:0,children:[v?(0,H.jsx)(`span`,{style:{position:`absolute`,top:8,left:`50%`,transform:`translateX(-50%)`,zIndex:10,fontSize:`0.75rem`,color:`#6b7280`,background:`#fff`,padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #e5e7eb`},children:`Saving…`}):null,y===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{color:`#b91c1c`,marginBottom:`0.5rem`},children:[`Save failed: `,y.message]}),p.length>0?(0,H.jsx)(gy,{position:`top-center`,children:(0,H.jsx)(`button`,{type:`button`,onClick:O,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontWeight:600,fontSize:`0.875rem`,cursor:`pointer`},children:`Delete edge`})}):null,A===void 0?null:(0,H.jsx)(ME,{taskId:A.id,data:A.data,isSaving:b.isPending,onPatch:e=>{b.mutate({id:A.id,input:e})},onDelete:()=>{x.mutate({id:A.id,projectId:e},{onSuccess:()=>{f(null)}})}}),(0,H.jsx)(`div`,{style:{width:`100%`,height:`calc(100vh - 12rem)`,border:`1px solid #e5e7eb`},children:(0,H.jsxs)(aS,{nodes:a,edges:c,onNodesChange:s,onEdgesChange:u,onConnect:C,onNodeDragStop:w,onSelectionChange:E,nodeTypes:BE,edgeTypes:VE,fitView:!0,children:[(0,H.jsx)(gS,{}),(0,H.jsx)(TS,{}),(0,H.jsx)(UE,{projectId:e}),(0,H.jsx)(WE,{onArrange:T})]})})]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load canvas: `,r.message]})}function KE(e){let t=e.status;return typeof t==`string`&&pa.includes(t)?{status:t}:{}}function qE(){let{id:e}=JE.useParams(),{status:t}=JE.useSearch(),{data:n,isLoading:r,error:i}=Ga(e);return r?(0,H.jsx)(`p`,{children:`Loading project…`}):i?(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load project: `,i.message]}):n===void 0?(0,H.jsx)(`p`,{children:`Project not found.`}):(0,H.jsxs)(`section`,{children:[(0,H.jsxs)(`nav`,{style:{display:`flex`,gap:`1rem`,marginBottom:`1.5rem`},children:[(0,H.jsx)(Vi,{to:`/projects/$id/overview`,params:{id:e},style:{color:`#555`},children:`Overview`}),(0,H.jsx)(Vi,{to:`/projects/$id/flow`,params:{id:e},style:{fontWeight:600,color:`#1a56db`},children:`Flow`}),(0,H.jsx)(Vi,{to:`/projects/$id/board`,params:{id:e},style:{color:`#555`},children:`Board`})]}),(0,H.jsxs)(`h1`,{style:{marginTop:0},children:[n.name,` — Flow`]}),t===void 0?null:(0,H.jsxs)(`p`,{style:{color:`#666`,marginTop:0},children:[`Filter: `,t]}),(0,H.jsxs)(`div`,{style:{position:`relative`},children:[(0,H.jsx)(Su,{projectId:e}),(0,H.jsx)(GE,{projectId:e})]})]})}var JE=qi(`/projects/$id/flow`)({validateSearch:KE,component:qE}),YE=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function XE(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function ZE(e){return`nodeType`in e}function QE(e){return e?XE(e)?e:ZE(e)?e.ownerDocument?.defaultView??window:window:window}function $E(e){let{Document:t}=QE(e);return e instanceof t}function eD(e){return XE(e)?!1:e instanceof QE(e).HTMLElement}function tD(e){return e instanceof QE(e).SVGElement}function nD(e){return e?XE(e)?e.document:ZE(e)?$E(e)?e:eD(e)||tD(e)?e.ownerDocument:document:document:document}var rD=YE?V.useLayoutEffect:V.useEffect;function iD(e){let t=(0,V.useRef)(e);return rD(()=>{t.current=e}),(0,V.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function aD(){let e=(0,V.useRef)(null);return[(0,V.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,V.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function oD(e,t){t===void 0&&(t=[e]);let n=(0,V.useRef)(e);return rD(()=>{n.current!==e&&(n.current=e)},t),n}function sD(e,t){let n=(0,V.useRef)();return(0,V.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function cD(e){let t=iD(e),n=(0,V.useRef)(null);return[n,(0,V.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function lD(e){let t=(0,V.useRef)();return(0,V.useEffect)(()=>{t.current=e},[e]),t.current}var uD={};function dD(e,t){return(0,V.useMemo)(()=>{if(t)return t;let n=uD[e]==null?0:uD[e]+1;return uD[e]=n,e+`-`+n},[e,t])}function fD(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var pD=fD(1),mD=fD(-1);function hD(e){return`clientX`in e&&`clientY`in e}function gD(e){if(!e)return!1;let{KeyboardEvent:t}=QE(e.target);return t&&e instanceof t}function _D(e){if(!e)return!1;let{TouchEvent:t}=QE(e.target);return t&&e instanceof t}function vD(e){if(_D(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return hD(e)?{x:e.clientX,y:e.clientY}:null}var yD=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[yD.Translate.toString(e),yD.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),bD=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function xD(e){return e.matches(bD)?e:e.querySelector(bD)}var SD={display:`none`};function CD(e){let{id:t,value:n}=e;return V.createElement(`div`,{id:t,style:SD},n)}function wD(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return V.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function TD(){let[e,t]=(0,V.useState)(``);return{announce:(0,V.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var ED=(0,V.createContext)(null);function DD(e){let t=(0,V.useContext)(ED);(0,V.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function OD(){let[e]=(0,V.useState)(()=>new Set),t=(0,V.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,V.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var kD={draggable:`
|
|
82
82
|
To pick up a draggable item, press the space bar.
|
|
83
83
|
While dragging, use the arrow keys to move the item.
|
|
84
84
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
85
|
-
`},KC={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function qC(e){let{announcements:t=KC,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=GC}=e,{announce:a,announcement:o}=VC(),s=DC(`DndLiveRegion`),[c,l]=(0,V.useState)(!1);if((0,V.useEffect)(()=>{l(!0)},[]),UC((0,V.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=V.createElement(V.Fragment,null,V.createElement(zC,{id:r,value:i.draggable}),V.createElement(BC,{id:s,announcement:o}));return n?(0,ki.createPortal)(u,n):u}var JC;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(JC||={});function YC(){}function XC(e,t){return(0,V.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function ZC(){var e=[...arguments];return(0,V.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var QC=Object.freeze({x:0,y:0});function $C(e,t){let n=PC(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function ew(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function tw(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function nw(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var rw=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=nw(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(ew)};function iw(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function aw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:QC}function ow(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var sw=ow(1);function cw(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function lw(e,t,n){let r=cw(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var uw={ignoreTransform:!1};function dw(e,t){t===void 0&&(t=uw);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=mC(e).getComputedStyle(e);t&&(n=lw(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function fw(e){return dw(e,{ignoreTransform:!0})}function pw(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mw(e,t){return t===void 0&&(t=mC(e).getComputedStyle(e)),t.position===`fixed`}function hw(e,t){t===void 0&&(t=mC(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function gw(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(hC(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!gC(i)||_C(i)||n.includes(i))return n;let a=mC(e).getComputedStyle(i);return i!==e&&hw(i,a)&&n.push(i),mw(i,a)?n:r(i.parentNode)}return e?r(e):n}function _w(e){let[t]=gw(e,1);return t??null}function vw(e){return!dC||!e?null:fC(e)?e:pC(e)?hC(e)||e===vC(e).scrollingElement?window:gC(e)?e:null:null}function yw(e){return fC(e)?e.scrollX:e.scrollLeft}function bw(e){return fC(e)?e.scrollY:e.scrollTop}function xw(e){return{x:yw(e),y:bw(e)}}var Sw;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Sw||={});function Cw(e){return!dC||!e?!1:e===document.scrollingElement}function ww(e){let t={x:0,y:0},n=Cw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Tw={x:.2,y:.2};function Ew(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Tw);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=ww(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Sw.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Sw.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Sw.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Sw.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Dw(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Ow(e){return e.reduce((e,t)=>kC(e,xw(t)),QC)}function kw(e){return e.reduce((e,t)=>e+yw(t),0)}function Aw(e){return e.reduce((e,t)=>e+bw(t),0)}function jw(e,t){if(t===void 0&&(t=dw),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);_w(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Mw=[[`x`,[`left`,`right`],kw],[`y`,[`top`,`bottom`],Aw]],Nw=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=gw(t),r=Ow(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Mw)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Pw=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Fw(e){let{EventTarget:t}=mC(e);return e instanceof t?e:vC(e)}function Iw(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Lw;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Lw||={});function Rw(e){e.preventDefault()}function zw(e){e.stopPropagation()}var Bw;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Bw||={});var Vw={start:[Bw.Space,Bw.Enter],cancel:[Bw.Esc],end:[Bw.Space,Bw.Enter,Bw.Tab]},Hw=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Bw.Right:return{...n,x:n.x+25};case Bw.Left:return{...n,x:n.x-25};case Bw.Down:return{...n,y:n.y+25};case Bw.Up:return{...n,y:n.y-25}}},Uw=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Pw(vC(t)),this.windowListeners=new Pw(mC(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Lw.Resize,this.handleCancel),this.windowListeners.add(Lw.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Lw.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&jw(n),t(QC)}handleKeyDown(e){if(MC(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Vw,coordinateGetter:a=Hw,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:QC;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=AC(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=ww(n),p=Dw(n),m={x:Math.min(i===Bw.Right?p.right-p.width/2:p.right,Math.max(i===Bw.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Bw.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Bw.Down?p.top:p.top+p.height/2,u.y))},h=i===Bw.Right&&!s||i===Bw.Left&&!c,g=i===Bw.Down&&!l||i===Bw.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Bw.Right&&e<=d.x||i===Bw.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Bw.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Bw.Down&&e<=d.y||i===Bw.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Bw.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,kC(AC(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Uw.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Vw,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Ww(e){return!!(e&&`distance`in e)}function Gw(e){return!!(e&&`delay`in e)}var Kw=class{constructor(e,t,n){n===void 0&&(n=Fw(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=vC(i),this.documentListeners=new Pw(this.document),this.listeners=new Pw(n),this.windowListeners=new Pw(mC(i)),this.initialCoordinates=PC(r)??QC,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Lw.Resize,this.handleCancel),this.windowListeners.add(Lw.DragStart,Rw),this.windowListeners.add(Lw.VisibilityChange,this.handleCancel),this.windowListeners.add(Lw.ContextMenu,Rw),this.documentListeners.add(Lw.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Gw(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Ww(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Lw.Click,zw,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Lw.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=PC(e)??QC,s=AC(n,o);if(!t&&a){if(Ww(a)){if(a.tolerance!=null&&Iw(s,a.tolerance))return this.handleCancel();if(Iw(s,a.distance))return this.handleStart()}if(Gw(a)&&Iw(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Bw.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},qw={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Jw=class extends Kw{constructor(e){let{event:t}=e,n=vC(t.target);super(e,qw,n)}};Jw.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Yw={move:{name:`mousemove`},end:{name:`mouseup`}},Xw;(function(e){e[e.RightClick=2]=`RightClick`})(Xw||={});var Zw=class extends Kw{constructor(e){super(e,Yw,vC(e.event.target))}};Zw.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Xw.RightClick?!1:(r?.({event:n}),!0)}}];var Qw={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},$w=class extends Kw{constructor(e){super(e,Qw)}static setup(){return window.addEventListener(Qw.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Qw.move.name,e)};function e(){}}};$w.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var eT;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(eT||={});var tT;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(tT||={});function nT(e){let{acceleration:t,activator:n=eT.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=tT.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=iT({delta:d,disabled:!a}),[m,h]=xC(),g=(0,V.useRef)({x:0,y:0}),_=(0,V.useRef)({x:0,y:0}),v=(0,V.useMemo)(()=>{switch(n){case eT.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case eT.DraggableRect:return i}},[n,i,c]),y=(0,V.useRef)(null),b=(0,V.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,V.useMemo)(()=>s===tT.TreeOrder?[...l].reverse():l,[s,l]);(0,V.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Ew(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var rT={x:{[Sw.Backward]:!1,[Sw.Forward]:!1},y:{[Sw.Backward]:!1,[Sw.Forward]:!1}};function iT(e){let{delta:t,disabled:n}=e,r=TC(t);return CC(e=>{if(n||!r||!e)return rT;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Sw.Backward]:e.x[Sw.Backward]||i.x===-1,[Sw.Forward]:e.x[Sw.Forward]||i.x===1},y:{[Sw.Backward]:e.y[Sw.Backward]||i.y===-1,[Sw.Forward]:e.y[Sw.Forward]||i.y===1}}},[n,t,r])}function aT(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return CC(e=>t==null?null:r??e??null,[r,t])}function oT(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var sT;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(sT||={});var cT;(function(e){e.Optimized=`optimized`})(cT||={});var lT=new Map;function uT(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,V.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,V.useRef)(e),d=g(),f=SC(d),p=(0,V.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,V.useRef)(null),h=CC(t=>{if(d&&!n)return lT;if(!t||t===lT||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Nw(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,V.useEffect)(()=>{u.current=e},[e]),(0,V.useEffect)(()=>{d||p()},[n,d]),(0,V.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,V.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case sT.Always:return!1;case sT.BeforeDragging:return n;default:return!n}}}function dT(e,t){return CC(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function fT(e,t){return dT(e,t)}function pT(e){let{callback:t,disabled:n}=e,r=bC(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function mT(e){let{callback:t,disabled:n}=e,r=bC(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function hT(e){return new Nw(dw(e),e)}function gT(e,t,n){t===void 0&&(t=hT);let[r,i]=(0,V.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=pT({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=mT({callback:a});return yC(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function _T(e){return aw(e,dT(e))}var vT=[];function yT(e){let t=(0,V.useRef)(e),n=CC(n=>e?n&&n!==vT&&e&&t.current&&e.parentNode===t.current.parentNode?n:gw(e):vT,[e]);return(0,V.useEffect)(()=>{t.current=e},[e]),n}function bT(e){let[t,n]=(0,V.useState)(null),r=(0,V.useRef)(e),i=(0,V.useCallback)(e=>{let t=vw(e.target);t&&n(e=>e?(e.set(t,xw(t)),new Map(e)):null)},[]);return(0,V.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=vw(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,xw(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{vw(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,V.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>kC(e,t),QC):Ow(e):QC,[e,t])}function xT(e,t){t===void 0&&(t=[]);let n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{n.current=null},t),(0,V.useEffect)(()=>{let t=e!==QC;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?AC(e,n.current):QC}function ST(e){(0,V.useEffect)(()=>{if(!dC)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function CT(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function wT(e){return(0,V.useMemo)(()=>e?pw(e):null,[e])}var TT=[];function ET(e,t){t===void 0&&(t=dw);let[n]=e,r=wT(n?mC(n):null),[i,a]=(0,V.useState)(TT);function o(){a(()=>e.length?e.map(e=>Cw(e)?r:new Nw(t(e),e)):TT)}let s=mT({callback:o});return yC(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function DT(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return gC(t)?t:e}function OT(e){let{measure:t}=e,[n,r]=(0,V.useState)(null),i=mT({callback:(0,V.useCallback)(e=>{for(let{target:n}of e)if(gC(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=wC((0,V.useCallback)(e=>{let n=DT(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,V.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var kT=[{sensor:Jw,options:{}},{sensor:Uw,options:{}}],AT={current:{}},jT={draggable:{measure:fw},droppable:{measure:fw,strategy:sT.WhileDragging,frequency:cT.Optimized},dragOverlay:{measure:dw}},MT=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},NT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new MT,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:YC},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jT,measureDroppableContainers:YC,windowRect:null,measuringScheduled:!1},PT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:YC,draggableNodes:new Map,over:null,measureDroppableContainers:YC},FT=(0,V.createContext)(PT),IT=(0,V.createContext)(NT);function LT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new MT}}}function RT(e,t){switch(t.type){case JC.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case JC.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case JC.DragEnd:case JC.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case JC.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new MT(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case JC.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new MT(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case JC.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new MT(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function zT(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,V.useContext)(FT),a=TC(r),o=TC(n?.id);return(0,V.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!MC(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=LC(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function BT(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function VT(e){return(0,V.useMemo)(()=>({draggable:{...jT.draggable,...e?.draggable},droppable:{...jT.droppable,...e?.droppable},dragOverlay:{...jT.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function HT(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,V.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;yC(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=aw(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=_w(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var UT=(0,V.createContext)({...QC,scaleX:1,scaleY:1}),WT;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(WT||={});var GT=(0,V.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=kT,collisionDetection:o=rw,measuring:s,modifiers:c,...l}=e,[u,d]=(0,V.useReducer)(RT,void 0,LT),[f,p]=WC(),[m,h]=(0,V.useState)(WT.Uninitialized),g=m===WT.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,V.useRef)({initial:null,translated:null}),C=(0,V.useMemo)(()=>_==null?null:{id:_,data:x?.data??AT,rect:S},[_,x]),w=(0,V.useRef)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),k=SC(l,Object.values(l)),A=DC(`DndDescribedBy`,t),j=(0,V.useMemo)(()=>b.getEnabled(),[b]),M=VT(s),{droppableRects:N,measureDroppableContainers:ee,measuringScheduled:te}=uT(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),P=aT(v,_),F=(0,V.useMemo)(()=>D?PC(D):null,[D]),ne=Oe(),re=fT(P,M.draggable.measure);HT({activeNode:_==null?null:v.get(_),config:ne.layoutShiftCompensation,initialRect:re,measure:M.draggable.measure});let I=gT(P,M.draggable.measure,re),L=gT(P?P.parentElement:null),R=(0,V.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),z=b.getNodeFor(R.current.over?.id),ie=OT({measure:M.dragOverlay.measure}),B=ie.nodeRef.current??P,ae=g?ie.rect??I:null,oe=!!(ie.nodeRef.current&&ie.rect),se=_T(oe?null:I),ce=wT(B?mC(B):null),le=yT(g?z??P:null),ue=ET(le),de=BT(c,{transform:{x:y.x-se.x,y:y.y-se.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:I,containerNodeRect:L,draggingNodeRect:ae,over:R.current.over,overlayNodeRect:ie.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),fe=F?kC(F,y):null,pe=bT(le),me=xT(pe),he=xT(pe,[I]),ge=kC(de,me),_e=ae?sw(ae,de):null,ve=C&&_e?o({active:C,collisionRect:_e,droppableRects:N,droppableContainers:j,pointerCoordinates:fe}):null,ye=tw(ve,`id`),[be,xe]=(0,V.useState)(null),Se=iw(oe?de:kC(de,he),be?.rect??null,I),Ce=(0,V.useRef)(null),we=(0,V.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;Ce.current=new n({active:w.current,activeNode:i,event:a,options:r,context:R,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ki.unstable_batchedUpdates)(()=>{r?.(i),h(WT.Initializing),d({type:JC.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),O(a)})},onMove(e){d({type:JC.DragMove,coordinates:e})},onEnd:o(JC.DragEnd),onCancel:o(JC.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=R.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===JC.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=JC.DragCancel)}w.current=null,(0,ki.unstable_batchedUpdates)(()=>{d({type:e}),h(WT.Uninitialized),xe(null),E(null),O(null),Ce.current=null;let t=e===JC.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=oT(a,(0,V.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,we(n,t))},[v,we]));ST(a),yC(()=>{I&&m===WT.Initializing&&h(WT.Initialized)},[I,m]),(0,V.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=R.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,ki.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,V.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=R.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ye),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ki.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),yC(()=>{R.current={activatorEvent:D,active:C,activeNode:P,collisionRect:_e,collisions:ve,droppableRects:N,draggableNodes:v,draggingNode:B,draggingNodeRect:ae,droppableContainers:b,over:be,scrollableAncestors:le,scrollAdjustedTranslate:ge},S.current={initial:ae,translated:_e}},[C,P,ve,_e,v,B,ae,N,b,be,le,ge]),nT({...ne,delta:y,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:le,scrollableAncestorRects:ue});let Ee=(0,V.useMemo)(()=>({active:C,activeNode:P,activeNodeRect:I,activatorEvent:D,collisions:ve,containerNodeRect:L,dragOverlay:ie,draggableNodes:v,droppableContainers:b,droppableRects:N,over:be,measureDroppableContainers:ee,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:M,measuringScheduled:te,windowRect:ce}),[C,P,I,D,ve,L,ie,v,b,N,be,ee,le,ue,M,te,ce]),De=(0,V.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:I,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:be,measureDroppableContainers:ee}),[D,Te,C,I,d,A,v,be,ee]);return V.createElement(HC.Provider,{value:p},V.createElement(FT.Provider,{value:De},V.createElement(IT.Provider,{value:Ee},V.createElement(UT.Provider,{value:Se},i)),V.createElement(zT,{disabled:n?.restoreFocus===!1})),V.createElement(qC,{...n,hiddenTextDescribedById:A}));function Oe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),KT=(0,V.createContext)(null),qT=`button`,JT=`Draggable`;function YT(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=DC(JT),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,V.useContext)(FT),{role:p=qT,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,V.useContext)(g?UT:KT),[v,y]=wC(),[b,x]=wC(),S=CT(o,t),C=SC(n);return yC(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,V.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===qT?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function XT(){return(0,V.useContext)(IT)}var ZT=`Droppable`,QT={timeout:25};function $T(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=DC(ZT),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,V.useContext)(FT),u=(0,V.useRef)({disabled:n}),d=(0,V.useRef)(!1),f=(0,V.useRef)(null),p=(0,V.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...QT,...i},_=SC(h??r),v=mT({callback:(0,V.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=wC((0,V.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=SC(t);return(0,V.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,V.useEffect)(()=>(s({type:JC.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:JC.UnregisterDroppable,key:a,id:r})),[r]),(0,V.useEffect)(()=>{n!==u.current.disabled&&(s({type:JC.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function eE(e){let{animation:t,children:n}=e,[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),s=TC(n);return!n&&!r&&s&&i(s),yC(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),V.createElement(V.Fragment,null,n,r?(0,V.cloneElement)(r,{ref:o}):null)}var tE={x:0,y:0,scaleX:1,scaleY:1};function nE(e){let{children:t}=e;return V.createElement(FT.Provider,{value:PT},V.createElement(UT.Provider,{value:tE},t))}var rE={position:`fixed`,touchAction:`none`},iE=e=>MC(e)?`transform 250ms ease`:void 0,aE=(0,V.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=iE}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...rE,width:s.width,height:s.height,top:s.top,left:s.left,transform:FC.Transform.toString(d),transformOrigin:i&&r?$C(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return V.createElement(n,{className:o,style:f,ref:t},a)}),oE={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:FC.Transform.toString(t)},{transform:FC.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function sE(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return bC((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=DT(a);if(!c)return;let{transform:l}=mC(a).getComputedStyle(a),u=cw(l);if(!u)return;let d=typeof t==`function`?t:cE(t);return jw(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function cE(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...oE,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var lE=0;function uE(e){return(0,V.useMemo)(()=>{if(e!=null)return lE++,lE},[e])}var dE=V.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=XT(),S=(0,V.useContext)(UT),C=uE(d?.id),w=BT(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=dT(f),E=sE({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return V.createElement(nE,null,V.createElement(eE,{animation:E},d&&C?V.createElement(aE,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),fE=5;function pE({task:e,isDragging:t=!1,onOpen:n,onDelete:r}){let{attributes:i,listeners:a,setNodeRef:o,transform:s}=YT({id:e.id,data:{status:e.status}}),c=(0,V.useRef)(null),l=t=>{t.stopPropagation(),confirm(`Delete this task?`)&&r(e.id)},u=t=>{let r=c.current;r!==null&&(Math.abs(t.clientX-r.x)>fE||Math.abs(t.clientY-r.y)>fE)||n(e.id)},d={transform:FC.Translate.toString(s),padding:`0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:`#fff`,boxShadow:t?`0 4px 12px rgba(0,0,0,0.12)`:`0 1px 2px rgba(0,0,0,0.06)`,cursor:t?`grabbing`:`pointer`,opacity:t?.5:1,touchAction:`none`};return(0,H.jsxs)(`div`,{ref:o,"data-task-id":e.id,"data-task-status":e.status,style:d,...i,...a,onPointerDown:e=>{c.current={x:e.clientX,y:e.clientY},a?.onPointerDown?.(e)},onClick:u,children:[(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`0.25rem`},children:[(0,H.jsx)(`div`,{style:{flex:1,fontWeight:600,lineHeight:1.3},children:e.label}),(0,H.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`Delete task`,style:{border:`none`,background:`none`,color:`#9ca3af`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1,padding:`0 0.125rem`},children:`×`})]}),e.assignee===null?null:(0,H.jsx)(`div`,{style:{fontSize:`0.75rem`,color:`#6b7280`,marginTop:`0.25rem`},children:e.assignee})]})}function mE({status:e,tasks:t,activeTaskId:n,onAddTask:r,onOpenTask:i,onDeleteTask:a,isAdding:o=!1}){let{setNodeRef:s,isOver:c}=$T({id:e}),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{ref:s,"data-board-column":e,style:{flex:`1 1 0`,minWidth:180,display:`flex`,flexDirection:`column`,background:c?`#eff6ff`:`#f9fafb`,borderRadius:8,border:c?`2px solid #3b82f6`:`1px solid #e5e7eb`,transition:`background 0.15s, border 0.15s`},children:[(0,H.jsxs)(`header`,{style:{padding:`0.75rem`,fontWeight:600,fontSize:`0.875rem`,borderBottom:`1px solid #e5e7eb`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,H.jsx)(`span`,{children:Jl[e]}),(0,H.jsx)(`span`,{style:{fontSize:`0.75rem`,fontWeight:500,color:`#6b7280`,background:`#e5e7eb`,borderRadius:999,padding:`0.125rem 0.5rem`},children:t.length})]}),(0,H.jsxs)(`div`,{style:{padding:`0.5rem`,display:`flex`,flexDirection:`column`,gap:`0.5rem`,flex:1,minHeight:120},children:[t.map(e=>(0,H.jsx)(pE,{task:e,isDragging:n===e.id,onOpen:i,onDelete:a},e.id)),d?(0,H.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=l.trim();n!==``&&(r(e,n),u(``),f(!1))},style:{display:`flex`,flexDirection:`column`,gap:`0.375rem`},children:[(0,H.jsx)(`input`,{type:`text`,value:l,autoFocus:!0,onChange:e=>{u(e.target.value)},placeholder:`Task name`,"aria-label":`New task in ${Jl[e]}`,style:{padding:`0.375rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,fontSize:`0.875rem`}}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.25rem`},children:[(0,H.jsx)(`button`,{type:`submit`,disabled:o||l.trim()===``,style:{flex:1,padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontSize:`0.75rem`,fontWeight:600,cursor:o?`wait`:`pointer`},children:o?`Adding…`:`Add`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(``)},style:{padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.75rem`,cursor:`pointer`},children:`Cancel`})]})]}):(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!0)},style:{padding:`0.375rem`,borderRadius:4,border:`1px dashed #d1d5db`,background:`transparent`,color:`#6b7280`,fontSize:`0.75rem`,cursor:`pointer`},children:`+ Add task`})]})]})}function hE({projectId:e,tasks:t}){let n=U(),r=Ya(),i=(0,V.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);return{handleDragEnd:(0,V.useCallback)(t=>{let{active:a,over:o}=t;if(o===null)return;let s=String(a.id),c=i.get(s);if(c===void 0)return;let l=Xl(o.id,i);if(l===void 0||l===c.status)return;let u=n.getQueryData(W.tasks(e));n.setQueryData(W.tasks(e),e=>e?.map(e=>e.id===s?{...e,status:l}:e)),n.setQueryData(W.canvas(e),e=>{if(e===void 0||typeof e!=`object`||!e)return e;let t=e;return{...t,nodes:t.nodes.map(e=>e.id===s?{...e,status:l}:e)}}),r.mutate({id:s,input:{status:l}},{onError:()=>{u!==void 0&&n.setQueryData(W.tasks(e),u),n.invalidateQueries({queryKey:W.canvas(e)})}})},[r,e,n,i]),isUpdating:r.isPending,updateError:r.error}}function gE({projectId:e,tasks:t}){let n=(0,V.useMemo)(()=>Yl(t),[t]),{handleDragEnd:r,isUpdating:i,updateError:a}=hE({projectId:e,tasks:t}),o=Ja(e),s=Ya(),c=Xa(),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),p=ZC(XC(Jw,{activationConstraint:{distance:6}})),m=l===null?void 0:t.find(e=>e.id===l),h=d===null?void 0:t.find(e=>e.id===d),g=e=>{u(String(e.active.id))},_=e=>{r(e),u(null)},v=(e,t)=>{o.mutate({label:t,status:e})},y=t=>{d===t&&f(null),c.mutate({id:t,projectId:e})};return(0,H.jsxs)(`div`,{style:{position:`relative`},children:[i?(0,H.jsx)(`p`,{style:{fontSize:`0.875rem`,color:`#6b7280`,marginTop:0},children:`Updating task…`}):null,a===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{color:`#b91c1c`,marginTop:0},children:[`Failed to update task: `,a.message]}),(0,H.jsxs)(GT,{sensors:p,onDragStart:g,onDragEnd:_,children:[(0,H.jsx)(`div`,{style:{display:`flex`,gap:`0.75rem`,alignItems:`flex-start`,overflowX:`auto`},children:ql.map(e=>(0,H.jsx)(mE,{status:e,tasks:n[e],activeTaskId:l,onAddTask:v,onOpenTask:f,onDeleteTask:y,isAdding:o.isPending},e))}),(0,H.jsx)(dE,{children:m===void 0?null:(0,H.jsx)(pE,{task:m,isDragging:!0,onOpen:()=>void 0,onDelete:y})})]}),h===void 0?null:(0,H.jsx)(YS,{taskId:h.id,data:{label:h.label,status:h.status,projectId:e,description:h.description,assignee:h.assignee,dueDate:h.due_date},isSaving:s.isPending,onPatch:e=>{s.mutate({id:h.id,input:e})},onDelete:()=>{c.mutate({id:h.id,projectId:e},{onSuccess:()=>{f(null)}})},onClose:()=>{f(null)}})]})}function _E(){let{id:e}=vE.useParams(),{status:t}=vE.useSearch(),{data:n,isLoading:r,error:i}=Ga(e),{data:a,isLoading:o,error:s}=Ka(e,t===void 0?{}:{status:t});return r||o?(0,H.jsx)(`p`,{children:`Loading board…`}):i===null?s===null?n===void 0?(0,H.jsx)(`p`,{children:`Project not found.`}):(0,H.jsxs)(`section`,{children:[(0,H.jsxs)(`nav`,{style:{display:`flex`,gap:`1rem`,marginBottom:`1.5rem`},children:[(0,H.jsx)(Vi,{to:`/projects/$id/overview`,params:{id:e},style:{color:`#555`},children:`Overview`}),(0,H.jsx)(Vi,{to:`/projects/$id/flow`,params:{id:e},style:{color:`#555`},children:`Flow`}),(0,H.jsx)(Vi,{to:`/projects/$id/board`,params:{id:e},style:{fontWeight:600,color:`#1a56db`},children:`Board`})]}),(0,H.jsxs)(`h1`,{style:{marginTop:0},children:[n.name,` — Board`]}),t===void 0?null:(0,H.jsxs)(`p`,{style:{color:`#666`,marginTop:0},children:[`Filter: `,t]}),(0,H.jsx)(gE,{projectId:e,tasks:a??[]})]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load tasks: `,s.message]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load project: `,i.message]})}var vE=qi(`/projects/$id/board`)({validateSearch:cC,component:_E});function yE(e){return new Date(e).toLocaleString()}function bE(){let e=window.getSelection()?.toString().trim()??``;return e===``?null:e}function xE({comment:e,onResolve:t,onDelete:n,isResolving:r,isDeleting:i}){return(0,H.jsxs)(`li`,{style:{padding:`0.75rem`,border:`1px solid #e5e7eb`,borderRadius:8,background:e.resolved?`#f9fafb`:`#fff`},children:[e.passage===null?null:(0,H.jsxs)(`p`,{style:{margin:`0 0 0.5rem`,fontSize:`0.8125rem`,color:`#6b7280`,fontStyle:`italic`},children:[`“`,e.passage,`”`]}),(0,H.jsx)(`p`,{style:{margin:`0 0 0.5rem`,lineHeight:1.5},children:e.body}),(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`0.5rem`,flexWrap:`wrap`},children:[(0,H.jsxs)(`span`,{style:{fontSize:`0.75rem`,color:`#9ca3af`},children:[yE(e.created_at),e.resolved?` · Resolved`:``]}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.375rem`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:t,disabled:r||i,style:{padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.8125rem`,cursor:r?`wait`:`pointer`},children:r?`…`:e.resolved?`Reopen`:`Resolve`}),(0,H.jsx)(`button`,{type:`button`,onClick:n,disabled:r||i,style:{padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontSize:`0.8125rem`,cursor:i?`wait`:`pointer`},children:i?`…`:`Delete`})]})]})]})}function SE({documentId:e}){let{data:t,isLoading:n,error:r}=oo(e),i=so(e),a=G(e),o=co(e),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),h=t??[],g=h.filter(e=>!e.resolved),_=h.filter(e=>e.resolved),v=()=>{let e=bE();e!==null&&u(e)},y=()=>{let e=s.trim();if(e===``)return;let t=l??bE();i.mutate(t===null?{body:e}:{body:e,passage:t},{onSuccess:()=>{c(``),u(null)}})},b=e=>{m(e.id),a.mutate({id:e.id,input:{resolved:!e.resolved}},{onSettled:()=>{m(null)}})},x=e=>{confirm(`Delete this comment?`)&&(m(e.id),o.mutate(e.id,{onSettled:()=>{m(null)}}))};return(0,H.jsxs)(`aside`,{style:{width:320,flexShrink:0,borderLeft:`1px solid #e5e7eb`,paddingLeft:`1rem`,display:`flex`,flexDirection:`column`,gap:`1rem`},children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{style:{margin:`0 0 0.25rem`,fontSize:`1.125rem`},children:`Comments`}),(0,H.jsxs)(`p`,{style:{margin:0,fontSize:`0.875rem`,color:`#6b7280`},children:[g.length,` open`]})]}),(0,H.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`,padding:`0.75rem`,border:`1px solid #e5e7eb`,borderRadius:8,background:`#fafafa`},children:[l===null?null:(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`0.5rem`,padding:`0.5rem`,background:`#fff`,border:`1px solid #e5e7eb`,borderRadius:6},children:[(0,H.jsxs)(`p`,{style:{margin:0,flex:1,fontSize:`0.8125rem`,color:`#6b7280`,fontStyle:`italic`},children:[`“`,l,`”`]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{u(null)},"aria-label":`Clear attached selection`,style:{padding:`0.125rem 0.375rem`,borderRadius:4,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.75rem`,cursor:`pointer`},children:`Clear`})]}),(0,H.jsx)(`textarea`,{value:s,onChange:e=>{c(e.target.value)},placeholder:`Leave feedback for teammates or an agent…`,rows:3,style:{width:`100%`,padding:`0.5rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,resize:`vertical`,fontFamily:`inherit`,fontSize:`0.875rem`}}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,flexWrap:`wrap`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:v,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.8125rem`,cursor:`pointer`},children:`Attach selection`}),(0,H.jsx)(`button`,{type:`button`,onClick:y,disabled:s.trim()===``||i.isPending,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,fontSize:`0.8125rem`,cursor:i.isPending?`wait`:`pointer`},children:i.isPending?`Adding…`:`Add comment`})]}),i.error===null?null:(0,H.jsx)(`p`,{role:`alert`,style:{margin:0,fontSize:`0.8125rem`,color:`#b91c1c`},children:i.error.message})]}),n?(0,H.jsx)(`p`,{style:{margin:0,color:`#6b7280`},children:`Loading comments…`}):null,r===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{margin:0,color:`#b91c1c`},children:[`Failed to load comments: `,r.message]}),!n&&r===null&&h.length===0?(0,H.jsx)(`p`,{style:{margin:0,color:`#6b7280`,fontSize:`0.875rem`},children:`No comments yet — add one to leave feedback for teammates or an agent.`}):null,!n&&r===null&&g.length>0?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{style:{margin:`0 0 0.5rem`,fontSize:`0.875rem`,color:`#374151`},children:`Open`}),(0,H.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:g.map(e=>(0,H.jsx)(xE,{comment:e,onResolve:()=>{b(e)},onDelete:()=>{x(e)},isResolving:a.isPending&&p===e.id,isDeleting:o.isPending&&p===e.id},e.id))})]}):null,!n&&r===null&&_.length>0?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(e=>!e)},style:{padding:`0.25rem 0`,border:`none`,background:`transparent`,color:`#1d4ed8`,fontSize:`0.875rem`,cursor:`pointer`,marginBottom:d?`0.5rem`:0},children:d?`Hide resolved`:`Show resolved (${String(_.length)})`}),d?(0,H.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:_.map(e=>(0,H.jsx)(xE,{comment:e,onResolve:()=>{b(e)},onDelete:()=>{x(e)},isResolving:a.isPending&&p===e.id,isDeleting:o.isPending&&p===e.id},e.id))}):null]}):null]})}function CE(e){this.content=e}CE.prototype={constructor:CE,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new CE(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new CE(n)},addToStart:function(e,t){return new CE([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new CE(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new CE(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=CE.from(e),e.size?new CE(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=CE.from(e),e.size?new CE(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=CE.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},CE.from=function(e){if(e instanceof CE)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new CE(t)};function wE(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=wE(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function TE(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=TE(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var J=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return wE(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return TE(this,e,t,n)}findIndex(e){if(e==0)return DE(0,e);if(e==this.size)return DE(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?DE(t+1,i):DE(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};J.empty=new J([],0);var EE={index:0,offset:0};function DE(e,t){return EE.index=e,EE.offset=t,EE}function OE(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!OE(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!OE(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var kE=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&OE(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 RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};kE.none=[];var AE=class extends Error{},Y=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=ME(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(jE(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(J.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Y.empty=new Y(J.empty,0,0);function jE(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(jE(a.content,t-i-1,n-i-1)))}function ME(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=ME(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function NE(e,t,n){if(n.openStart>e.depth)throw new AE(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new AE(`Inconsistent open depths`);return PE(e,t,n,0)}function PE(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=PE(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return zE(a,VE(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return zE(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=HE(n,e);return zE(a,BE(e,i,o,t,r))}}function FE(e,t){if(!t.type.compatibleContent(e.type))throw new AE(`Cannot join `+t.type.name+` onto `+e.type.name)}function IE(e,t,n){let r=e.node(n);return FE(r,t.node(n)),r}function LE(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function RE(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(LE(e.nodeAfter,r),a++));for(let e=a;e<o;e++)LE(i.child(e),r);t&&t.depth==n&&t.textOffset&&LE(t.nodeBefore,r)}function zE(e,t){return e.type.checkContent(t),e.copy(t)}function BE(e,t,n,r,i){let a=e.depth>i&&IE(e,t,i+1),o=r.depth>i&&IE(n,r,i+1),s=[];return RE(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(FE(a,o),LE(zE(a,BE(e,t,n,r,i+1)),s)):(a&&LE(zE(a,VE(e,t,i+1)),s),RE(t,n,i,s),o&&LE(zE(o,VE(n,r,i+1)),s)),RE(r,null,i,s),new J(s)}function VE(e,t,n){let r=[];return RE(null,e,n,r),e.depth>n&&LE(zE(IE(e,t,n+1),VE(e,t,n+1)),r),RE(t,null,n,r),new J(r)}function HE(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(J.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var UE=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return kE.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new qE(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=KE.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else KE.set(t,r=new WE);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%GE,i}},WE=class{constructor(){this.elts=[],this.i=0}},GE=12,KE=new WeakMap,qE=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},JE=Object.create(null),YE=class e{constructor(e,t,n,r=kE.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||J.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&OE(this.attrs,t||e.defaultAttrs||JE)&&kE.sameSet(this.marks,n||kE.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Y.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Y(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return NE(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return UE.resolveCached(this,e)}resolveNoCache(e){return UE.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),ZE(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=J.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=kE.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!kE.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=J.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};YE.prototype.text=void 0;var XE=class e extends YE{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ZE(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function ZE(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var QE=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new $E(t,n);if(r.next==null)return e.empty;let i=eD(r);r.next&&r.err(`Unexpected trailing text`);let a=uD(sD(i));return dD(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return J.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
86
|
-
`)}};QE.empty=new QE(!0);var $E=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function eD(e){let t=[];do t.push(tD(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function tD(e){let t=[];do t.push(nD(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function nD(e){let t=oD(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=iD(e,t);else break;return t}function rD(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function iD(e,t){let n=rD(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:rD(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function aD(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function oD(e){if(e.eat(`(`)){let t=eD(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=aD(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function sD(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function cD(e,t){return t-e}function lD(e,t){let n=[];return r(t),n.sort(cD);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function uD(e){let t=Object.create(null);return n(lD(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);lD(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new QE(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(cD);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function dD(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function fD(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function pD(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function mD(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function hD(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new vD(e,r,t[r]);return n}var gD=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=hD(e,n.attrs),this.defaultAttrs=fD(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==QE.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:pD(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new YE(this,this.computeAttrs(e),J.from(t),kE.setFrom(n))}createChecked(e=null,t,n){return t=J.from(t),this.checkContent(t),new YE(this,this.computeAttrs(e),t,kE.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=J.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(J.empty,!0);return i?new YE(this,e,t.append(i),kE.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){mD(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:kE.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function _D(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var vD=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?_D(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},yD=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=hD(e,r.attrs),this.excluded=null;let i=fD(this.attrs);this.instance=i?new kE(this,i):null}create(e=null){return!e&&this.instance?this.instance:new kE(this,pD(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){mD(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},bD=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=CE.from(e.nodes),t.marks=CE.from(e.marks||{}),this.nodes=gD.compile(this.spec.nodes,this),this.marks=yD.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=QE.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?xD(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:xD(this,n.split(` `))}this.nodeFromJSON=e=>YE.fromJSON(this,e),this.markFromJSON=e=>kE.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof gD))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new XE(n,n.defaultAttrs,e,kE.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function xD(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function SD(e){return e.tag!=null}function CD(e){return e.style!=null}var wD=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(SD(e))this.tags.push(e);else if(CD(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new ND(this,t,!1);return n.addAll(e,kE.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new ND(this,t,!0);return n.addAll(e,kE.none,t.from,t.to),Y.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(FD(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ID(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ID(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},TD={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},ED={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},DD={ol:!0,ul:!0},OD=1,kD=2,AD=4;function jD(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?OD:0)|(t===`full`?kD:0)}var MD=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=kE.none,this.match=i||(a&AD?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(J.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&OD)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=J.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(J.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&&!TD.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},ND=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=jD(null,t.preserveWhitespace,0)|(n?AD:0);i=r?new MD(r.type,r.attrs,kE.none,!0,t.topMatch||r.type.contentMatch,a):n?new MD(null,null,kE.none,!0,null,a):new MD(e.schema.topNodeType,null,kE.none,!0,null,a),this.nodes=[i],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 n=e.nodeValue,r=this.top,i=r.options&kD?`full`:this.localPreserveWS||(r.options&OD)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
87
|
-
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;
|
|
88
|
-
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=kE.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):LD(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=jD(e,i,a.options);a.options&AD&&a.content.length==0&&(o|=AD);let s=kE.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):LD(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new MD(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=OD);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function PD(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&DD.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function FD(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ID(e){let t={};for(let n in e)t[n]=e[n];return t}function LD(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var RD=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=BD(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return BD(t).createTextNode(e.text);let{dom:n,contentDOM:r}=WD(BD(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&WD(BD(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:WD(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=zD(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return zD(e.marks)}};function zD(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function BD(e){return e.document||window.document}var VD=new WeakMap;function HD(e){let t=VD.get(e);return t===void 0&&VD.set(e,t=UD(e)),t}function UD(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function WD(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=HD(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=WD(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var GD=65535,KD=2**16;function qD(e,t){return e+t*KD}function JD(e){return e&GD}function YD(e){return(e-(e&GD))/KD}var XD=1,ZD=2,QD=4,$D=8,eO=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&$D)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&QD)>0}},tO=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=JD(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+YD(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:qD(o/3,e-s),f=e==s?ZD:e==u?XD:QD;return(t<0?e!=s:e!=u)&&(f|=$D),new eO(a,f,d)}r+=l-c}return n?e+r:new eO(e+r,0,null)}touches(e,t){let n=0,r=JD(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};tO.empty=new tO([]);var nO=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new eO(e,r,null)}},rO=Object.create(null),iO=class{getMap(){return tO.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=rO[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rO)throw RangeError(`Duplicate use of step JSON ID `+e);return rO[e]=t,t.prototype.jsonID=e,t}},aO=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof AE)return e.fail(t.message);throw t}}};function oO(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(oO(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return J.fromArray(r)}var sO=class e extends iO{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Y(oO(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return aO.fromReplace(e,this.from,this.to,i)}invert(){return new cO(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};iO.jsonID(`addMark`,sO);var cO=class e extends iO{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Y(oO(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return aO.fromReplace(e,this.from,this.to,n)}invert(){return new sO(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};iO.jsonID(`removeMark`,cO);var lO=class e extends iO{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return aO.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return aO.fromReplace(e,this.pos,this.pos+1,new Y(J.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new uO(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};iO.jsonID(`addNodeMark`,lO);var uO=class e extends iO{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return aO.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return aO.fromReplace(e,this.pos,this.pos+1,new Y(J.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new lO(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};iO.jsonID(`removeNodeMark`,uO);var dO=class e extends iO{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&pO(e,this.from,this.to)?aO.fail(`Structure replace would overwrite content`):aO.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new tO([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Y.empty:new Y(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Y.empty:new Y(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Y.fromJSON(t,n.slice),!!n.structure)}};dO.MAP_BIAS=1,iO.jsonID(`replace`,dO);var fO=class e extends iO{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(pO(e,this.from,this.gapFrom)||pO(e,this.gapTo,this.to)))return aO.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return aO.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?aO.fromReplace(e,this.from,this.to,n):aO.fail(`Content does not fit in gap`)}getMap(){return new tO([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Y.fromJSON(t,n.slice),n.insert,!!n.structure)}};iO.jsonID(`replaceAround`,fO);function pO(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function mO(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new cO(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new sO(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function hO(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof yD){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new cO(t.from,t.to,t.style)))}function gO(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new dO(s,l,Y.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new cO(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Y(J.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new dO(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(J.empty,!0);e.replace(s,s,new Y(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function _O(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function vO(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!_O(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function yO(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=J.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=J.from(r.node(e).copy(u)),d++):c--;let f=J.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=J.from(i.node(e).copy(f)),p++):l++;e.step(new fO(c,l,o,s,new Y(u.append(f),d,p),u.size-d,!0))}function bO(e,t,n=null,r=e){let i=SO(e,t),a=i&&CO(r,t);return a?i.map(xO).concat({type:t,attrs:n}).concat(a.map(xO)):null}function xO(e){return{type:e,attrs:null}}function SO(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function CO(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function wO(e,t,n){let r=J.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=J.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new fO(i,a,i,a,new Y(r,0,0),n.length,!0))}function TO(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&OO(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&DO(e,t,n,a),gO(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new fO(c,l,c+1,l-1,new Y(J.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&EO(e,t,n,a),!1}})}function EO(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function DO(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
89
|
-
`))}})}function OO(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function kO(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new fO(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new Y(J.from(o),0,0),1,!0))}function AO(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function jO(e,t,n=1,r){let i=e.doc.resolve(t),a=J.empty,o=J.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=J.from(i.node(e).copy(a));let t=r&&r[s];o=J.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new dO(t,t,new Y(a.append(o),n,n),!0))}function MO(e,t){let n=e.resolve(t),r=n.index();return PO(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function NO(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function PO(e,t){return!!(e&&t&&!e.isLeaf&&NO(e,t))}function FO(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&PO(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function IO(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);DO(e,r.node(),r.before(),s)}o.inlineContent&&gO(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new dO(l,c.map(t+n,-1),Y.empty,!0)),r===!0){let t=e.doc.resolve(l);EO(e,t.node(),t.before(),e.steps.length)}return e}function LO(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function RO(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function zO(e,t,n=t,r=Y.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return BO(i,a,r)?new dO(t,n,r):new VO(i,a,r).fit()}function BO(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var VO=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=J.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=J.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new Y(i,a,o);return e>-1?new fO(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new dO(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=WO(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(J.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=WO(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new Y(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=WO(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Y(HO(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Y(HO(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(GO(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=UO(this.placed,t,J.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?Y.empty:new Y(HO(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new Y(HO(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!KO(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=KO(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=KO(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=UO(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=UO(this.placed,this.depth,J.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(J.empty,!0);e.childCount&&(this.placed=UO(this.placed,this.frontier.length,e))}};function HO(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(HO(e.firstChild.content,t-1,n)))}function UO(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(UO(e.lastChild.content,t-1,n)))}function WO(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function GO(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,GO(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(J.empty,!0)))),e.copy(r)}function KO(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!qO(n,a.content,o)?s:null}function qO(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function JO(e){return e.spec.defining||e.spec.definingForContent}function YO(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(BO(i,a,r))return e.step(new dO(t,n,r));let o=$O(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=JO(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new Y(XO(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function XO(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(XO(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(J.empty,!0))}return e}function ZO(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=LO(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new Y(J.from(r),0,0))}function QO(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=$O(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function $O(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var ek=class e extends iO{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return aO.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return aO.fromReplace(e,this.pos,this.pos+1,new Y(J.from(r),0,+!t.isLeaf))}getMap(){return tO.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};iO.jsonID(`attr`,ek);var tk=class e extends iO{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return aO.ok(n)}getMap(){return tO.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};iO.jsonID(`docAttr`,tk);var nk=class extends Error{};nk=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},nk.prototype=Object.create(Error.prototype),nk.prototype.constructor=nk,nk.prototype.name=`TransformError`;var rk=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new nO}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new nk(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Y.empty){let r=zO(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Y(J.from(n),0,0))}delete(e,t){return this.replace(e,t,Y.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return YO(this,e,t,n),this}replaceRangeWith(e,t,n){return ZO(this,e,t,n),this}deleteRange(e,t){return QO(this,e,t),this}lift(e,t){return yO(this,e,t),this}join(e,t=1){return IO(this,e,t),this}wrap(e,t){return wO(this,e,t),this}setBlockType(e,t=e,n,r=null){return TO(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return kO(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new ek(e,t,n)),this}setDocAttribute(e,t){return this.step(new tk(e,t)),this}addNodeMark(e,t){return this.step(new lO(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof kE)t.isInSet(n.marks)&&this.step(new uO(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new uO(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return jO(this,e,t,n),this}addMark(e,t,n){return mO(this,e,t,n),this}removeMark(e,t,n){return hO(this,e,t,n),this}clearIncompatible(e,t,n){return gO(this,e,t,n),this}},ik=Object.create(null),ak=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new ok(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=Y.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?Y.empty:t),o==0&&mk(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),mk(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new X(e):pk(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?pk(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):pk(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new dk(e.node(0))}static atStart(e){return pk(e,e,0,0,1)||new dk(e)}static atEnd(e){return pk(e,e,e.content.size,e.childCount,-1)||new dk(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=ik[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ik)throw RangeError(`Duplicate use of selection JSON ID `+e);return ik[e]=t,t.prototype.jsonID=e,t}getBookmark(){return X.between(this.$anchor,this.$head).getBookmark()}};ak.prototype.visible=!0;var ok=class{constructor(e,t){this.$from=e,this.$to=t}},sk=!1;function ck(e){!sk&&!e.parent.inlineContent&&(sk=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var X=class e extends ak{constructor(e,t=e){ck(e),ck(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return ak.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=Y.empty){if(super.replace(e,t),t==Y.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new lk(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=ak.findFrom(n,r,!0)||ak.findFrom(n,-r,!0);if(e)n=e.$head;else return ak.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(ak.findFrom(t,-r,!0)||ak.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};ak.jsonID(`text`,X);var lk=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return X.between(e.resolve(this.anchor),e.resolve(this.head))}},Z=class e extends ak{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?ak.near(a):new e(a)}content(){return new Y(J.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new uk(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Z.prototype.visible=!1,ak.jsonID(`node`,Z);var uk=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new lk(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Z.isSelectable(n)?new Z(t):ak.near(t)}},dk=class e extends ak{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Y.empty){if(t==Y.empty){e.delete(0,e.doc.content.size);let t=ak.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return fk}};ak.jsonID(`all`,dk);var fk={map(){return this},resolve(e){return new dk(e)}};function pk(e,t,n,r,i,a=!1){if(t.inlineContent)return X.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=pk(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Z.isSelectable(r))return Z.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function mk(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof dO||i instanceof fO))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(ak.near(e.doc.resolve(o),n))}var hk=1,gk=2,_k=4,vk=class extends rk{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|hk)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&hk)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=gk,this}ensureMarks(e){return kE.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&gk)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||kE.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(ak.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=_k,this}get scrolledIntoView(){return(this.updated&_k)>0}};function yk(e,t){return!t||!e?e:e.bind(t)}var bk=class{constructor(e,t,n){this.name=e,this.init=yk(t.init,n),this.apply=yk(t.apply,n)}},xk=[new bk(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new bk(`selection`,{init(e,t){return e.selection||ak.atStart(t.doc)},apply(e){return e.selection}}),new bk(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new bk(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Sk=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xk.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new bk(e.key,e.spec.state,e))})}},Ck=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new vk(this)}static create(t){let n=new Sk(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new Sk(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Sk(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=YE.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=ak.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function wk(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=wk(i,t,{})),n[r]=i}return n}var Tk=class{constructor(e){this.spec=e,this.props={},e.props&&wk(e.props,this,this.props),this.key=e.key?e.key.key:Dk(`plugin`)}getState(e){return e[this.key]}},Ek=Object.create(null);function Dk(e){return e in Ek?e+`$`+ ++Ek[e]:(Ek[e]=0,e+`$`)}var Ok=class{constructor(e=`key`){this.key=Dk(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},kk=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ak(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var jk=(e,t,n)=>{let r=Ak(e,n);if(!r)return!1;let i=Lk(r);if(!i){let n=r.blockRange(),i=n&&vO(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(tA(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Fk(a,`end`)||Z.isSelectable(a)))for(let n=r.depth;;n--){let o=zO(e.doc,r.before(n),r.after(n),Y.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(Fk(a,`end`)?ak.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Z.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Mk=(e,t,n)=>{let r=Ak(e,n);if(!r)return!1;let i=Lk(r);return i?Pk(e,i,t):!1},Nk=(e,t,n)=>{let r=Rk(e,n);if(!r)return!1;let i=Vk(r);return i?Pk(e,i,t):!1};function Pk(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=zO(e.doc,i,o,Y.empty);if(!s||s.from!=i||s instanceof dO&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(X.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Fk(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Ik=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Lk(r)}let o=a&&a.nodeBefore;return!o||!Z.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Z.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Lk(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Rk(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var zk=(e,t,n)=>{let r=Rk(e,n);if(!r)return!1;let i=Vk(r);if(!i)return!1;let a=i.nodeAfter;if(tA(e,i,t,1))return!0;if(r.parent.content.size==0&&(Fk(a,`start`)||Z.isSelectable(a))){let n=zO(e.doc,r.before(),r.after(),Y.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Fk(a,`start`)?ak.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Z.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},Bk=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=Vk(r)}let o=a&&a.nodeAfter;return!o||!Z.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Z.create(e.doc,a.pos)).scrollIntoView()),!0)};function Vk(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Hk=(e,t)=>{let n=e.selection,r=n instanceof Z,i;if(r){if(n.node.isTextblock||!MO(e.doc,n.from))return!1;i=n.from}else if(i=FO(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Z.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},Uk=(e,t)=>{let n=e.selection,r;if(n instanceof Z){if(n.node.isTextblock||!MO(e.doc,n.to))return!1;r=n.to}else if(r=FO(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Wk=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&vO(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},Gk=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
90
|
-
`).scrollIntoView()),!0)};function Kk(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var qk=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=Kk(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(ak.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Jk=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof dk||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Kk(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(X.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},Yk=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(AO(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&vO(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Xk(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Z&&t.selection.node.isBlock)return!r.parentOffset||!AO(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=Kk(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof X||t.selection instanceof dk)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=AO(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,AO(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var Zk=Xk(),Qk=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Z.create(e.doc,i))),!0)},$k=(e,t)=>(t&&t(e.tr.setSelection(new dk(e.doc))),!0);function eA(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||MO(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function tA(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&eA(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=J.empty;for(let e=o.length-1;e>=0;e--)s=J.from(o[e].create(null,s));s=J.from(i.copy(s));let c=e.tr.step(new fO(t.pos-1,r,t.pos,r,new Y(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&MO(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:ak.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&vO(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Fk(a,`start`,!0)&&Fk(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=J.empty;for(let e=o.length-1;e>=0;e--)r=J.from(o[e].copy(r));n(e.tr.step(new fO(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new Y(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function nA(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(X.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var rA=nA(-1),iA=nA(1);function aA(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&bO(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function oA(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function sA(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var cA=sA(kk,jk,Ik),lA=sA(kk,zk,Bk),uA={Enter:sA(Gk,Jk,Yk,Zk),"Mod-Enter":qk,Backspace:cA,"Mod-Backspace":cA,"Shift-Backspace":cA,Delete:lA,"Mod-Delete":lA,"Mod-a":$k},dA={"Ctrl-h":uA.Backspace,"Alt-Backspace":uA[`Mod-Backspace`],"Ctrl-d":uA.Delete,"Ctrl-Alt-Backspace":uA[`Mod-Delete`],"Alt-Delete":uA[`Mod-Delete`],"Alt-d":uA[`Mod-Delete`],"Ctrl-a":rA,"Ctrl-e":iA};for(let e in uA)dA[e]=uA[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function fA(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return pA(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function pA(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new qE(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new qE(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=bO(a,n,r,t);return s?(e&&mA(e,t,s,i,n),!0):!1}function mA(e,t,n,r,i){let a=J.empty;for(let e=n.length-1;e>=0;e--)a=J.from(n[e].type.create(n[e].attrs,a));e.step(new fO(t.start-(r?2:0),t.end,t.start,t.end,new Y(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&AO(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function hA(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?gA(t,n,e,a):_A(t,n,a):!0:!1}}function gA(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new fO(a-1,o,a,o,new Y(J.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new qE(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=vO(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return MO(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function _A(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?J.empty:J.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new fO(d-+!!s,f+ +!!c,d+1,f-1,new Y((s?J.empty:J.from(i.copy(J.empty))).append(c?J.empty:J.from(i.copy(J.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function vA(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=J.from(r?e.create():null),o=new Y(J.from(e.create(null,J.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new fO(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var yA=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},bA=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},xA=null,SA=function(e,t,n){let r=xA||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},CA=function(){xA=null},wA=function(e,t,n,r){return n&&(EA(e,t,n,r,-1)||EA(e,t,n,r,1))},TA=/^(img|br|input|textarea|hr)$/i;function EA(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:DA(e))){let n=e.parentNode;if(!n||n.nodeType!=1||jA(e)||TA.test(e.nodeName)||e.contentEditable==`false`)return!1;t=yA(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?DA(e):0}else return!1}}function DA(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function OA(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=DA(e)}else if(e.parentNode&&!jA(e))t=yA(e),e=e.parentNode;else return null}}function kA(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!jA(e))t=yA(e)+1,e=e.parentNode;else return null}}function AA(e,t,n){for(let r=t==0,i=t==DA(e);r||i;){if(e==n)return!0;let t=yA(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==DA(e)}}function jA(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var MA=function(e){return e.focusNode&&wA(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function NA(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function PA(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function FA(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(DA(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(DA(r.startContainer),r.startOffset)}}}var IA=typeof navigator<`u`?navigator:null,LA=typeof document<`u`?document:null,RA=IA&&IA.userAgent||``,zA=/Edge\/(\d+)/.exec(RA),BA=/MSIE \d/.exec(RA),VA=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(RA),HA=!!(BA||VA||zA),UA=BA?document.documentMode:VA?+VA[1]:zA?+zA[1]:0,WA=!HA&&/gecko\/(\d+)/i.test(RA);WA&&+(/Firefox\/(\d+)/.exec(RA)||[0,0])[1];var GA=!HA&&/Chrome\/(\d+)/.exec(RA),KA=!!GA,qA=GA?+GA[1]:0,JA=!HA&&!!IA&&/Apple Computer/.test(IA.vendor),YA=JA&&(/Mobile\/\w+/.test(RA)||!!IA&&IA.maxTouchPoints>2),XA=YA||(IA?/Mac/.test(IA.platform):!1),ZA=IA?/Win/.test(IA.platform):!1,QA=/Android \d/.test(RA),$A=!!LA&&`webkitFontSmoothing`in LA.documentElement.style,ej=$A?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function tj(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function nj(e,t){return typeof e==`number`?e:e[t]}function rj(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function ij(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=bA(o);continue}let e=o,n=e==a.body,s=n?tj(a):rj(e),c=0,l=0;if(t.top<s.top+nj(r,`top`)?l=-(s.top-t.top+nj(i,`top`)):t.bottom>s.bottom-nj(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+nj(i,`top`)-s.top:t.bottom-s.bottom+nj(i,`bottom`)),t.left<s.left+nj(r,`left`)?c=-(s.left-t.left+nj(i,`left`)):t.right>s.right-nj(r,`right`)&&(c=t.right-s.right+nj(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:bA(o)}}function aj(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:oj(e.dom)}}function oj(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=bA(r));return t}function sj({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;cj(n,r==0?0:r-t)}function cj(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var lj=null;function uj(e){if(e.setActive)return e.setActive();if(lj)return e.focus(lj);let t=oj(e);e.focus(lj==null?{get preventScroll(){return lj={preventScroll:!0},!0}}:void 0),lj||(lj=!1,cj(t,0))}function dj(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=SA(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?fj(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:dj(n,i)}function fj(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=bj(r,1);if(n.top!=n.bottom&&pj(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function pj(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function mj(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function hj(e,t,n){let{node:r,offset:i}=dj(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function gj(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function _j(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(pj(t,i))return _j(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function vj(e,t){let n=e.dom.ownerDocument,r,i=0,a=FA(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!pj(t,n)||(o=_j(e.dom,t,n),!o))return null}if(JA)for(let e=o;r&&e;e=bA(e))e.draggable&&(r=void 0);if(o=mj(o,t),r){if(WA&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;$A&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=gj(e,r,i,t))}s??=hj(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function yj(e){return e.top<e.bottom||e.left<e.right}function bj(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(yj(e))return e}return Array.prototype.find.call(n,yj)||e.getBoundingClientRect()}var xj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Sj(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=$A||WA;if(r.nodeType==3)if(o&&(xj.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=bj(SA(r,i,i),n);if(WA&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=bj(SA(r,i-1,i-1),-1);if(t.top==e.top){let n=bj(SA(r,i,i+1),-1);if(n.top!=e.top)return Cj(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Cj(bj(SA(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==DA(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return wj(e.getBoundingClientRect(),!1)}if(a==null&&i<DA(r)){let e=r.childNodes[i];if(e.nodeType==1)return wj(e.getBoundingClientRect(),!0)}return wj(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==DA(r))){let e=r.childNodes[i-1],t=e.nodeType==3?SA(e,DA(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Cj(bj(t,1),!1)}if(a==null&&i<DA(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?SA(e,0,+!o):e.nodeType==1?e:null:null;if(t)return Cj(bj(t,-1),!0)}return Cj(bj(r.nodeType==3?SA(r):r,-n),n>=0)}function Cj(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function wj(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Tj(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Ej(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Tj(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Sj(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=SA(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Dj=/[\u0590-\u08ac]/;function Oj(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Dj.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Tj(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var kj=null,Aj=null,jj=!1;function Mj(e,t,n){return kj==t&&Aj==n?jj:(kj=t,Aj=n,jj=n==`up`||n==`down`?Ej(e,t,n):Oj(e,t,n))}var Nj=0,Pj=1,Fj=2,Ij=3,Lj=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Nj,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>yA(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof Wj){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Rj&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?yA(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?yA(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=yA(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=yA(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}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:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((WA||JA)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
|
|
91
|
-
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:yA(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(WA&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&JA)&&wA(o.node,o.offset,l.anchorNode,l.anchorOffset)&&wA(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&WA)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}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 n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Fj:Pj,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ij:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Fj:Ij}n=a}this.dirty=Fj}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Fj:Pj;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Rj=class extends Lj{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Nj&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},zj=class extends Lj{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Bj=class e extends Lj{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=RD.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ij||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ij&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Nj){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Nj}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=sM(a,n,o,r)),t>0&&(a=sM(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Vj=class e extends Lj{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=RD.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Qj(u,r,n),l?c=new Gj(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Uj(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+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 n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>J.empty)}return e}matchesNode(e,t,n){return this.dirty==Nj&&e.eq(this.node)&&$j(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new tM(this,a&&a.node,e);iM(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?kE.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Fj)&&(a&&this.protectLocalComposition(e,a),Kj(this.contentDOM,this.children,e),YA&&aM(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof X)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=oM(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new zj(this,i,t,r);e.input.compositionNodes.push(a),this.children=sM(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Ij||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Nj}updateOuterDeco(e){if($j(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Xj(this.dom,this.nodeDOM,Yj(this.outerDeco,this.node,t),Yj(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Hj(e,t,n,r,i){Qj(r,t,e);let a=new Vj(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Uj=class e extends Vj{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Ij||this.dirty!=Nj&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Nj||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Nj,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ij)}get domAtom(){return!1}isText(e){return this.node.text==e}},Wj=class extends Lj{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Nj&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Gj=class extends Vj{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Ij)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Kj(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=eM(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Bj){let t=r?r.previousSibling:e.lastChild;Kj(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=eM(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var qj=function(e){e&&(this.nodeName=e)};qj.prototype=Object.create(null);var Jj=[new qj];function Yj(e,t,n){if(e.length==0)return Jj;let r=n?Jj[0]:new qj,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new qj(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new qj(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function Xj(e,t,n,r){if(n==Jj&&r==Jj)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=Jj[0],i=t)}Zj(i,o||Jj[0],a)}return i}function Zj(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function Qj(e,t,n){return Xj(e,e,Jj,Yj(t,n,e.nodeType!=1))}function $j(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function eM(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var tM=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=nM(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Nj,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Bj.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Ij&&a.dom==a.contentDOM&&(a.dirty=Fj),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Vj){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Ij&&$j(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Fj,u.updateChildren(r,a+1),u.dirty=Nj),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!$j(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Vj.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Vj.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Rj(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Bj;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Uj)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((JA||KA)&&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 n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Wj(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function nM(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Bj)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function rM(e,t){return e.type.side-t.type.side}function iM(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(rM);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function aM(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function oM(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function sM(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function cM(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(MA(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Z.isSelectable(e)&&i.parent&&!(e.isInline&&AA(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Z(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=yM(e,u,s,n)}return l}function lM(e){return e.editable?e.hasFocus():xM(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function uM(e,t=!1){let n=e.state.selection;if(_M(e,n),lM(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&KA){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&wA(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)gM(e);else{let{anchor:r,head:i}=n,a,o;dM&&!(n instanceof X)&&(n.$from.parent.inlineContent||(a=fM(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=fM(e,n.to))),e.docView.setSelection(r,i,e,t),dM&&(a&&mM(a),o&&mM(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&hM(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var dM=JA||KA&&qA<63;function fM(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(JA&&i&&i.contentEditable==`false`)return pM(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return pM(i);if(a)return pM(a)}}function pM(e){return e.contentEditable=`true`,JA&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function mM(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function hM(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!lM(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function gM(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,yA(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&HA&&UA<=11&&(n.disabled=!0,n.disabled=!1)}function _M(e,t){if(t instanceof Z){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(vM(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else vM(e)}function vM(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function yM(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||X.between(t,n,r)}function bM(e){return e.editable&&!e.hasFocus()?!1:xM(e)}function xM(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function SM(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return wA(t.node,t.offset,n.anchorNode,n.anchorOffset)}function CM(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&ak.findFrom(a,t)}function wM(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function TM(e,t,n){let r=e.state.selection;if(r instanceof X){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return wM(e,new X(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=CM(e.state,t);return n&&n instanceof Z?wM(e,n):!1}else if(!(XA&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Z.isSelectable(i)?wM(e,new Z(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):$A?wM(e,new X(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Z&&r.node.isInline)return wM(e,new X(t>0?r.$to:r.$from));else{let n=CM(e.state,t);return n?wM(e,n):!1}}function EM(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function DM(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function OM(e,t){return t<0?kM(e):AM(e)}function kM(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(WA&&n.nodeType==1&&r<EM(n)&&DM(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(DM(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(jM(n))break;else{let t=n.previousSibling;for(;t&&DM(t,-1);)i=n.parentNode,a=yA(t),t=t.previousSibling;if(t)n=t,r=EM(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?PM(e,n,r):i&&PM(e,i,a)}function AM(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=EM(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(DM(e,1))a=n,o=++r;else break}else if(jM(n))break;else{let t=n.nextSibling;for(;t&&DM(t,1);)a=t.parentNode,o=yA(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=EM(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&PM(e,a,o)}function jM(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function MM(e,t){for(;e&&t==e.childNodes.length&&!jA(e);)t=yA(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function NM(e,t){for(;e&&!t&&!jA(e);)t=yA(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function PM(e,t,n){if(t.nodeType!=3){let e,r;(r=MM(t,n))?(t=r,n=0):(e=NM(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(MA(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&uM(e)},50)}function FM(e,t){let n=e.state.doc.resolve(t);if(!(KA||ZA)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function IM(e,t,n){let r=e.state.selection;if(r instanceof X&&!r.empty||n.indexOf(`s`)>-1||XA&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=CM(e.state,t);if(n&&n instanceof Z)return wM(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof dk?ak.near(n,t):ak.findFrom(n,t);return o?wM(e,o):!1}return!1}function LM(e,t){if(!(e.state.selection instanceof X))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function RM(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function zM(e){if(!JA||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;RM(e,n,`true`),setTimeout(()=>RM(e,n,`false`),20)}return!1}function BM(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function VM(e,t){let n=t.keyCode,r=BM(t);if(n==8||XA&&n==72&&r==`c`)return LM(e,-1)||OM(e,-1);if(n==46&&!t.shiftKey||XA&&n==68&&r==`c`)return LM(e,1)||OM(e,1);if(n==13||n==27)return!0;if(n==37||XA&&n==66&&r==`c`){let t=n==37?FM(e,e.state.selection.from)==`ltr`?-1:1:-1;return TM(e,t,r)||OM(e,t)}else if(n==39||XA&&n==70&&r==`c`){let t=n==39?FM(e,e.state.selection.from)==`ltr`?1:-1:1;return TM(e,t,r)||OM(e,t)}else if(n==38||XA&&n==80&&r==`c`)return IM(e,-1,r)||OM(e,-1);else if(n==40||XA&&n==78&&r==`c`)return zM(e)||IM(e,1,r)||OM(e,1);else if(r==(XA?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function HM(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||RD.fromSchema(e.state.schema),s=$M(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=ZM[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
85
|
+
`},AD={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function jD(e){let{announcements:t=AD,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=kD}=e,{announce:a,announcement:o}=TD(),s=dD(`DndLiveRegion`),[c,l]=(0,V.useState)(!1);if((0,V.useEffect)(()=>{l(!0)},[]),DD((0,V.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=V.createElement(V.Fragment,null,V.createElement(CD,{id:r,value:i.draggable}),V.createElement(wD,{id:s,announcement:o}));return n?(0,ki.createPortal)(u,n):u}var MD;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(MD||={});function ND(){}function PD(e,t){return(0,V.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function FD(){var e=[...arguments];return(0,V.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var ID=Object.freeze({x:0,y:0});function LD(e,t){let n=vD(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function RD(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function zD(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function BD(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var VD=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=BD(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(RD)};function HD(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function UD(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ID}function WD(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var GD=WD(1);function KD(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function qD(e,t,n){let r=KD(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var JD={ignoreTransform:!1};function YD(e,t){t===void 0&&(t=JD);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=QE(e).getComputedStyle(e);t&&(n=qD(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function XD(e){return YD(e,{ignoreTransform:!0})}function ZD(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function QD(e,t){return t===void 0&&(t=QE(e).getComputedStyle(e)),t.position===`fixed`}function $D(e,t){t===void 0&&(t=QE(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function eO(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if($E(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!eD(i)||tD(i)||n.includes(i))return n;let a=QE(e).getComputedStyle(i);return i!==e&&$D(i,a)&&n.push(i),QD(i,a)?n:r(i.parentNode)}return e?r(e):n}function tO(e){let[t]=eO(e,1);return t??null}function nO(e){return!YE||!e?null:XE(e)?e:ZE(e)?$E(e)||e===nD(e).scrollingElement?window:eD(e)?e:null:null}function rO(e){return XE(e)?e.scrollX:e.scrollLeft}function iO(e){return XE(e)?e.scrollY:e.scrollTop}function aO(e){return{x:rO(e),y:iO(e)}}var oO;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(oO||={});function sO(e){return!YE||!e?!1:e===document.scrollingElement}function cO(e){let t={x:0,y:0},n=sO(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var lO={x:.2,y:.2};function uO(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=lO);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=cO(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=oO.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=oO.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=oO.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=oO.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function dO(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function fO(e){return e.reduce((e,t)=>pD(e,aO(t)),ID)}function pO(e){return e.reduce((e,t)=>e+rO(t),0)}function mO(e){return e.reduce((e,t)=>e+iO(t),0)}function hO(e,t){if(t===void 0&&(t=YD),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);tO(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var gO=[[`x`,[`left`,`right`],pO],[`y`,[`top`,`bottom`],mO]],_O=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=eO(t),r=fO(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of gO)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},vO=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function yO(e){let{EventTarget:t}=QE(e);return e instanceof t?e:nD(e)}function bO(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var xO;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(xO||={});function SO(e){e.preventDefault()}function CO(e){e.stopPropagation()}var wO;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(wO||={});var TO={start:[wO.Space,wO.Enter],cancel:[wO.Esc],end:[wO.Space,wO.Enter,wO.Tab]},EO=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case wO.Right:return{...n,x:n.x+25};case wO.Left:return{...n,x:n.x-25};case wO.Down:return{...n,y:n.y+25};case wO.Up:return{...n,y:n.y-25}}},DO=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new vO(nD(t)),this.windowListeners=new vO(QE(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(xO.Resize,this.handleCancel),this.windowListeners.add(xO.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(xO.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&hO(n),t(ID)}handleKeyDown(e){if(gD(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=TO,coordinateGetter:a=EO,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:ID;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=mD(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=cO(n),p=dO(n),m={x:Math.min(i===wO.Right?p.right-p.width/2:p.right,Math.max(i===wO.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===wO.Down?p.bottom-p.height/2:p.bottom,Math.max(i===wO.Down?p.top:p.top+p.height/2,u.y))},h=i===wO.Right&&!s||i===wO.Left&&!c,g=i===wO.Down&&!l||i===wO.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===wO.Right&&e<=d.x||i===wO.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===wO.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===wO.Down&&e<=d.y||i===wO.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===wO.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,pD(mD(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};DO.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=TO,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function OO(e){return!!(e&&`distance`in e)}function kO(e){return!!(e&&`delay`in e)}var AO=class{constructor(e,t,n){n===void 0&&(n=yO(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=nD(i),this.documentListeners=new vO(this.document),this.listeners=new vO(n),this.windowListeners=new vO(QE(i)),this.initialCoordinates=vD(r)??ID,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(xO.Resize,this.handleCancel),this.windowListeners.add(xO.DragStart,SO),this.windowListeners.add(xO.VisibilityChange,this.handleCancel),this.windowListeners.add(xO.ContextMenu,SO),this.documentListeners.add(xO.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(kO(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(OO(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(xO.Click,CO,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(xO.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=vD(e)??ID,s=mD(n,o);if(!t&&a){if(OO(a)){if(a.tolerance!=null&&bO(s,a.tolerance))return this.handleCancel();if(bO(s,a.distance))return this.handleStart()}if(kO(a)&&bO(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===wO.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},jO={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},MO=class extends AO{constructor(e){let{event:t}=e,n=nD(t.target);super(e,jO,n)}};MO.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var NO={move:{name:`mousemove`},end:{name:`mouseup`}},PO;(function(e){e[e.RightClick=2]=`RightClick`})(PO||={});var FO=class extends AO{constructor(e){super(e,NO,nD(e.event.target))}};FO.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===PO.RightClick?!1:(r?.({event:n}),!0)}}];var IO={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},LO=class extends AO{constructor(e){super(e,IO)}static setup(){return window.addEventListener(IO.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(IO.move.name,e)};function e(){}}};LO.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var RO;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(RO||={});var zO;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(zO||={});function BO(e){let{acceleration:t,activator:n=RO.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=zO.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=HO({delta:d,disabled:!a}),[m,h]=aD(),g=(0,V.useRef)({x:0,y:0}),_=(0,V.useRef)({x:0,y:0}),v=(0,V.useMemo)(()=>{switch(n){case RO.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case RO.DraggableRect:return i}},[n,i,c]),y=(0,V.useRef)(null),b=(0,V.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,V.useMemo)(()=>s===zO.TreeOrder?[...l].reverse():l,[s,l]);(0,V.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=uO(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var VO={x:{[oO.Backward]:!1,[oO.Forward]:!1},y:{[oO.Backward]:!1,[oO.Forward]:!1}};function HO(e){let{delta:t,disabled:n}=e,r=lD(t);return sD(e=>{if(n||!r||!e)return VO;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[oO.Backward]:e.x[oO.Backward]||i.x===-1,[oO.Forward]:e.x[oO.Forward]||i.x===1},y:{[oO.Backward]:e.y[oO.Backward]||i.y===-1,[oO.Forward]:e.y[oO.Forward]||i.y===1}}},[n,t,r])}function UO(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return sD(e=>t==null?null:r??e??null,[r,t])}function WO(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var GO;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(GO||={});var KO;(function(e){e.Optimized=`optimized`})(KO||={});var qO=new Map;function JO(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,V.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,V.useRef)(e),d=g(),f=oD(d),p=(0,V.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,V.useRef)(null),h=sD(t=>{if(d&&!n)return qO;if(!t||t===qO||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new _O(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,V.useEffect)(()=>{u.current=e},[e]),(0,V.useEffect)(()=>{d||p()},[n,d]),(0,V.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,V.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case GO.Always:return!1;case GO.BeforeDragging:return n;default:return!n}}}function YO(e,t){return sD(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function XO(e,t){return YO(e,t)}function ZO(e){let{callback:t,disabled:n}=e,r=iD(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function QO(e){let{callback:t,disabled:n}=e,r=iD(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function $O(e){return new _O(YD(e),e)}function ek(e,t,n){t===void 0&&(t=$O);let[r,i]=(0,V.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=ZO({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=QO({callback:a});return rD(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function tk(e){return UD(e,YO(e))}var nk=[];function rk(e){let t=(0,V.useRef)(e),n=sD(n=>e?n&&n!==nk&&e&&t.current&&e.parentNode===t.current.parentNode?n:eO(e):nk,[e]);return(0,V.useEffect)(()=>{t.current=e},[e]),n}function ik(e){let[t,n]=(0,V.useState)(null),r=(0,V.useRef)(e),i=(0,V.useCallback)(e=>{let t=nO(e.target);t&&n(e=>e?(e.set(t,aO(t)),new Map(e)):null)},[]);return(0,V.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=nO(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,aO(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{nO(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,V.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>pD(e,t),ID):fO(e):ID,[e,t])}function ak(e,t){t===void 0&&(t=[]);let n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{n.current=null},t),(0,V.useEffect)(()=>{let t=e!==ID;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?mD(e,n.current):ID}function ok(e){(0,V.useEffect)(()=>{if(!YE)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function sk(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function ck(e){return(0,V.useMemo)(()=>e?ZD(e):null,[e])}var lk=[];function uk(e,t){t===void 0&&(t=YD);let[n]=e,r=ck(n?QE(n):null),[i,a]=(0,V.useState)(lk);function o(){a(()=>e.length?e.map(e=>sO(e)?r:new _O(t(e),e)):lk)}let s=QO({callback:o});return rD(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function dk(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return eD(t)?t:e}function fk(e){let{measure:t}=e,[n,r]=(0,V.useState)(null),i=QO({callback:(0,V.useCallback)(e=>{for(let{target:n}of e)if(eD(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=cD((0,V.useCallback)(e=>{let n=dk(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,V.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var pk=[{sensor:MO,options:{}},{sensor:DO,options:{}}],mk={current:{}},hk={draggable:{measure:XD},droppable:{measure:XD,strategy:GO.WhileDragging,frequency:KO.Optimized},dragOverlay:{measure:YD}},gk=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},_k={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new gk,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ND},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:hk,measureDroppableContainers:ND,windowRect:null,measuringScheduled:!1},vk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:ND,draggableNodes:new Map,over:null,measureDroppableContainers:ND},yk=(0,V.createContext)(vk),bk=(0,V.createContext)(_k);function xk(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new gk}}}function Sk(e,t){switch(t.type){case MD.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case MD.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case MD.DragEnd:case MD.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case MD.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new gk(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case MD.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new gk(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case MD.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new gk(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Ck(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,V.useContext)(yk),a=lD(r),o=lD(n?.id);return(0,V.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!gD(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=xD(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function wk(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Tk(e){return(0,V.useMemo)(()=>({draggable:{...hk.draggable,...e?.draggable},droppable:{...hk.droppable,...e?.droppable},dragOverlay:{...hk.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ek(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,V.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;rD(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=UD(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=tO(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Dk=(0,V.createContext)({...ID,scaleX:1,scaleY:1}),Ok;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Ok||={});var kk=(0,V.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=pk,collisionDetection:o=VD,measuring:s,modifiers:c,...l}=e,[u,d]=(0,V.useReducer)(Sk,void 0,xk),[f,p]=OD(),[m,h]=(0,V.useState)(Ok.Uninitialized),g=m===Ok.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,V.useRef)({initial:null,translated:null}),C=(0,V.useMemo)(()=>_==null?null:{id:_,data:x?.data??mk,rect:S},[_,x]),w=(0,V.useRef)(null),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),k=oD(l,Object.values(l)),A=dD(`DndDescribedBy`,t),j=(0,V.useMemo)(()=>b.getEnabled(),[b]),M=Tk(s),{droppableRects:N,measureDroppableContainers:ee,measuringScheduled:te}=JO(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),P=UO(v,_),F=(0,V.useMemo)(()=>D?vD(D):null,[D]),ne=Oe(),re=XO(P,M.draggable.measure);Ek({activeNode:_==null?null:v.get(_),config:ne.layoutShiftCompensation,initialRect:re,measure:M.draggable.measure});let I=ek(P,M.draggable.measure,re),L=ek(P?P.parentElement:null),R=(0,V.useRef)({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),z=b.getNodeFor(R.current.over?.id),ie=fk({measure:M.dragOverlay.measure}),B=ie.nodeRef.current??P,ae=g?ie.rect??I:null,oe=!!(ie.nodeRef.current&&ie.rect),se=tk(oe?null:I),ce=ck(B?QE(B):null),le=rk(g?z??P:null),ue=uk(le),de=wk(c,{transform:{x:y.x-se.x,y:y.y-se.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:I,containerNodeRect:L,draggingNodeRect:ae,over:R.current.over,overlayNodeRect:ie.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),fe=F?pD(F,y):null,pe=ik(le),me=ak(pe),he=ak(pe,[I]),ge=pD(de,me),_e=ae?GD(ae,de):null,ve=C&&_e?o({active:C,collisionRect:_e,droppableRects:N,droppableContainers:j,pointerCoordinates:fe}):null,ye=zD(ve,`id`),[be,xe]=(0,V.useState)(null),Se=HD(oe?de:pD(de,he),be?.rect??null,I),Ce=(0,V.useRef)(null),we=(0,V.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;Ce.current=new n({active:w.current,activeNode:i,event:a,options:r,context:R,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ki.unstable_batchedUpdates)(()=>{r?.(i),h(Ok.Initializing),d({type:MD.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),O(a)})},onMove(e){d({type:MD.DragMove,coordinates:e})},onEnd:o(MD.DragEnd),onCancel:o(MD.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=R.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===MD.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=MD.DragCancel)}w.current=null,(0,ki.unstable_batchedUpdates)(()=>{d({type:e}),h(Ok.Uninitialized),xe(null),E(null),O(null),Ce.current=null;let t=e===MD.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=WO(a,(0,V.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,we(n,t))},[v,we]));ok(a),rD(()=>{I&&m===Ok.Initializing&&h(Ok.Initialized)},[I,m]),(0,V.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=R.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,ki.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,V.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=R.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ye),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ki.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),rD(()=>{R.current={activatorEvent:D,active:C,activeNode:P,collisionRect:_e,collisions:ve,droppableRects:N,draggableNodes:v,draggingNode:B,draggingNodeRect:ae,droppableContainers:b,over:be,scrollableAncestors:le,scrollAdjustedTranslate:ge},S.current={initial:ae,translated:_e}},[C,P,ve,_e,v,B,ae,N,b,be,le,ge]),BO({...ne,delta:y,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:le,scrollableAncestorRects:ue});let Ee=(0,V.useMemo)(()=>({active:C,activeNode:P,activeNodeRect:I,activatorEvent:D,collisions:ve,containerNodeRect:L,dragOverlay:ie,draggableNodes:v,droppableContainers:b,droppableRects:N,over:be,measureDroppableContainers:ee,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:M,measuringScheduled:te,windowRect:ce}),[C,P,I,D,ve,L,ie,v,b,N,be,ee,le,ue,M,te,ce]),De=(0,V.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:I,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:be,measureDroppableContainers:ee}),[D,Te,C,I,d,A,v,be,ee]);return V.createElement(ED.Provider,{value:p},V.createElement(yk.Provider,{value:De},V.createElement(bk.Provider,{value:Ee},V.createElement(Dk.Provider,{value:Se},i)),V.createElement(Ck,{disabled:n?.restoreFocus===!1})),V.createElement(jD,{...n,hiddenTextDescribedById:A}));function Oe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Ak=(0,V.createContext)(null),jk=`button`,Mk=`Draggable`;function Nk(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=dD(Mk),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,V.useContext)(yk),{role:p=jk,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,V.useContext)(g?Dk:Ak),[v,y]=cD(),[b,x]=cD(),S=sk(o,t),C=oD(n);return rD(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,V.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===jk?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Pk(){return(0,V.useContext)(bk)}var Fk=`Droppable`,Ik={timeout:25};function Lk(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=dD(Fk),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,V.useContext)(yk),u=(0,V.useRef)({disabled:n}),d=(0,V.useRef)(!1),f=(0,V.useRef)(null),p=(0,V.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Ik,...i},_=oD(h??r),v=QO({callback:(0,V.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=cD((0,V.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=oD(t);return(0,V.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,V.useEffect)(()=>(s({type:MD.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:MD.UnregisterDroppable,key:a,id:r})),[r]),(0,V.useEffect)(()=>{n!==u.current.disabled&&(s({type:MD.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Rk(e){let{animation:t,children:n}=e,[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(null),s=lD(n);return!n&&!r&&s&&i(s),rD(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),V.createElement(V.Fragment,null,n,r?(0,V.cloneElement)(r,{ref:o}):null)}var zk={x:0,y:0,scaleX:1,scaleY:1};function Bk(e){let{children:t}=e;return V.createElement(yk.Provider,{value:vk},V.createElement(Dk.Provider,{value:zk},t))}var Vk={position:`fixed`,touchAction:`none`},Hk=e=>gD(e)?`transform 250ms ease`:void 0,Uk=(0,V.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Hk}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Vk,width:s.width,height:s.height,top:s.top,left:s.left,transform:yD.Transform.toString(d),transformOrigin:i&&r?LD(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return V.createElement(n,{className:o,style:f,ref:t},a)}),Wk={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:yD.Transform.toString(t)},{transform:yD.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function Gk(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return iD((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=dk(a);if(!c)return;let{transform:l}=QE(a).getComputedStyle(a),u=KD(l);if(!u)return;let d=typeof t==`function`?t:Kk(t);return hO(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Kk(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Wk,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var qk=0;function Jk(e){return(0,V.useMemo)(()=>{if(e!=null)return qk++,qk},[e])}var Yk=V.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=Pk(),S=(0,V.useContext)(Dk),C=Jk(d?.id),w=wk(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=YO(f),E=Gk({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return V.createElement(Bk,null,V.createElement(Rk,{animation:E},d&&C?V.createElement(Uk,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),Xk=5;function Zk({task:e,isDragging:t=!1,onOpen:n,onDelete:r}){let{attributes:i,listeners:a,setNodeRef:o,transform:s}=Nk({id:e.id,data:{status:e.status}}),c=(0,V.useRef)(null),l=t=>{t.stopPropagation(),confirm(`Delete this task?`)&&r(e.id)},u=t=>{let r=c.current;r!==null&&(Math.abs(t.clientX-r.x)>Xk||Math.abs(t.clientY-r.y)>Xk)||n(e.id)},d={transform:yD.Translate.toString(s),padding:`0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:`#fff`,boxShadow:t?`0 4px 12px rgba(0,0,0,0.12)`:`0 1px 2px rgba(0,0,0,0.06)`,cursor:t?`grabbing`:`pointer`,opacity:t?.5:1,touchAction:`none`};return(0,H.jsxs)(`div`,{ref:o,"data-task-id":e.id,"data-task-status":e.status,style:d,...i,...a,onPointerDown:e=>{c.current={x:e.clientX,y:e.clientY},a?.onPointerDown?.(e)},onClick:u,children:[(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`0.25rem`},children:[(0,H.jsx)(`div`,{style:{flex:1,fontWeight:600,lineHeight:1.3},children:e.label}),(0,H.jsx)(`button`,{type:`button`,onClick:l,"aria-label":`Delete task`,style:{border:`none`,background:`none`,color:`#9ca3af`,cursor:`pointer`,fontSize:`1rem`,lineHeight:1,padding:`0 0.125rem`},children:`×`})]}),e.assignee===null?null:(0,H.jsx)(`div`,{style:{fontSize:`0.75rem`,color:`#6b7280`,marginTop:`0.25rem`},children:e.assignee})]})}function Qk({status:e,tasks:t,activeTaskId:n,onAddTask:r,onOpenTask:i,onDeleteTask:a,isAdding:o=!1}){let{setNodeRef:s,isOver:c}=Lk({id:e}),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{ref:s,"data-board-column":e,style:{flex:`1 1 0`,minWidth:180,display:`flex`,flexDirection:`column`,background:c?`#eff6ff`:`#f9fafb`,borderRadius:8,border:c?`2px solid #3b82f6`:`1px solid #e5e7eb`,transition:`background 0.15s, border 0.15s`},children:[(0,H.jsxs)(`header`,{style:{padding:`0.75rem`,fontWeight:600,fontSize:`0.875rem`,borderBottom:`1px solid #e5e7eb`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,H.jsx)(`span`,{children:Jl[e]}),(0,H.jsx)(`span`,{style:{fontSize:`0.75rem`,fontWeight:500,color:`#6b7280`,background:`#e5e7eb`,borderRadius:999,padding:`0.125rem 0.5rem`},children:t.length})]}),(0,H.jsxs)(`div`,{style:{padding:`0.5rem`,display:`flex`,flexDirection:`column`,gap:`0.5rem`,flex:1,minHeight:120},children:[t.map(e=>(0,H.jsx)(Zk,{task:e,isDragging:n===e.id,onOpen:i,onDelete:a},e.id)),d?(0,H.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n=l.trim();n!==``&&(r(e,n),u(``),f(!1))},style:{display:`flex`,flexDirection:`column`,gap:`0.375rem`},children:[(0,H.jsx)(`input`,{type:`text`,value:l,autoFocus:!0,onChange:e=>{u(e.target.value)},placeholder:`Task name`,"aria-label":`New task in ${Jl[e]}`,style:{padding:`0.375rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,fontSize:`0.875rem`}}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.25rem`},children:[(0,H.jsx)(`button`,{type:`submit`,disabled:o||l.trim()===``,style:{flex:1,padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontSize:`0.75rem`,fontWeight:600,cursor:o?`wait`:`pointer`},children:o?`Adding…`:`Add`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),u(``)},style:{padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.75rem`,cursor:`pointer`},children:`Cancel`})]})]}):(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(!0)},style:{padding:`0.375rem`,borderRadius:4,border:`1px dashed #d1d5db`,background:`transparent`,color:`#6b7280`,fontSize:`0.75rem`,cursor:`pointer`},children:`+ Add task`})]})]})}function $k({projectId:e,tasks:t}){let n=U(),r=Ya(),i=(0,V.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);return{handleDragEnd:(0,V.useCallback)(t=>{let{active:a,over:o}=t;if(o===null)return;let s=String(a.id),c=i.get(s);if(c===void 0)return;let l=Xl(o.id,i);if(l===void 0||l===c.status)return;let u=n.getQueryData(W.tasks(e));n.setQueryData(W.tasks(e),e=>e?.map(e=>e.id===s?{...e,status:l}:e)),n.setQueryData(W.canvas(e),e=>{if(e===void 0||typeof e!=`object`||!e)return e;let t=e;return{...t,nodes:t.nodes.map(e=>e.id===s?{...e,status:l}:e)}}),r.mutate({id:s,input:{status:l}},{onError:()=>{u!==void 0&&n.setQueryData(W.tasks(e),u),n.invalidateQueries({queryKey:W.canvas(e)})}})},[r,e,n,i]),isUpdating:r.isPending,updateError:r.error}}function eA({projectId:e,tasks:t}){let n=(0,V.useMemo)(()=>Yl(t),[t]),{handleDragEnd:r,isUpdating:i,updateError:a}=$k({projectId:e,tasks:t}),o=Ja(e),s=Ya(),c=Xa(),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),p=FD(PD(MO,{activationConstraint:{distance:6}})),m=l===null?void 0:t.find(e=>e.id===l),h=d===null?void 0:t.find(e=>e.id===d),g=e=>{u(String(e.active.id))},_=e=>{r(e),u(null)},v=(e,t)=>{o.mutate({label:t,status:e})},y=t=>{d===t&&f(null),c.mutate({id:t,projectId:e})};return(0,H.jsxs)(`div`,{style:{position:`relative`},children:[i?(0,H.jsx)(`p`,{style:{fontSize:`0.875rem`,color:`#6b7280`,marginTop:0},children:`Updating task…`}):null,a===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{color:`#b91c1c`,marginTop:0},children:[`Failed to update task: `,a.message]}),(0,H.jsxs)(kk,{sensors:p,onDragStart:g,onDragEnd:_,children:[(0,H.jsx)(`div`,{style:{display:`flex`,gap:`0.75rem`,alignItems:`flex-start`,overflowX:`auto`},children:ql.map(e=>(0,H.jsx)(Qk,{status:e,tasks:n[e],activeTaskId:l,onAddTask:v,onOpenTask:f,onDeleteTask:y,isAdding:o.isPending},e))}),(0,H.jsx)(Yk,{children:m===void 0?null:(0,H.jsx)(Zk,{task:m,isDragging:!0,onOpen:()=>void 0,onDelete:y})})]}),h===void 0?null:(0,H.jsx)(ME,{taskId:h.id,data:{label:h.label,status:h.status,projectId:e,description:h.description,assignee:h.assignee,dueDate:h.due_date},isSaving:s.isPending,onPatch:e=>{s.mutate({id:h.id,input:e})},onDelete:()=>{c.mutate({id:h.id,projectId:e},{onSuccess:()=>{f(null)}})},onClose:()=>{f(null)}})]})}function tA(){let{id:e}=nA.useParams(),{status:t}=nA.useSearch(),{data:n,isLoading:r,error:i}=Ga(e),{data:a,isLoading:o,error:s}=Ka(e,t===void 0?{}:{status:t});return r||o?(0,H.jsx)(`p`,{children:`Loading board…`}):i===null?s===null?n===void 0?(0,H.jsx)(`p`,{children:`Project not found.`}):(0,H.jsxs)(`section`,{children:[(0,H.jsxs)(`nav`,{style:{display:`flex`,gap:`1rem`,marginBottom:`1.5rem`},children:[(0,H.jsx)(Vi,{to:`/projects/$id/overview`,params:{id:e},style:{color:`#555`},children:`Overview`}),(0,H.jsx)(Vi,{to:`/projects/$id/flow`,params:{id:e},style:{color:`#555`},children:`Flow`}),(0,H.jsx)(Vi,{to:`/projects/$id/board`,params:{id:e},style:{fontWeight:600,color:`#1a56db`},children:`Board`})]}),(0,H.jsxs)(`h1`,{style:{marginTop:0},children:[n.name,` — Board`]}),t===void 0?null:(0,H.jsxs)(`p`,{style:{color:`#666`,marginTop:0},children:[`Filter: `,t]}),(0,H.jsx)(eA,{projectId:e,tasks:a??[]})]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load tasks: `,s.message]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load project: `,i.message]})}var nA=qi(`/projects/$id/board`)({validateSearch:KE,component:tA});function rA(e){return new Date(e).toLocaleString()}function iA(){let e=window.getSelection()?.toString().trim()??``;return e===``?null:e}function aA({comment:e,onResolve:t,onDelete:n,isResolving:r,isDeleting:i}){return(0,H.jsxs)(`li`,{style:{padding:`0.75rem`,border:`1px solid #e5e7eb`,borderRadius:8,background:e.resolved?`#f9fafb`:`#fff`},children:[e.passage===null?null:(0,H.jsxs)(`p`,{style:{margin:`0 0 0.5rem`,fontSize:`0.8125rem`,color:`#6b7280`,fontStyle:`italic`},children:[`“`,e.passage,`”`]}),(0,H.jsx)(`p`,{style:{margin:`0 0 0.5rem`,lineHeight:1.5},children:e.body}),(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`0.5rem`,flexWrap:`wrap`},children:[(0,H.jsxs)(`span`,{style:{fontSize:`0.75rem`,color:`#9ca3af`},children:[rA(e.created_at),e.resolved?` · Resolved`:``]}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.375rem`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:t,disabled:r||i,style:{padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.8125rem`,cursor:r?`wait`:`pointer`},children:r?`…`:e.resolved?`Reopen`:`Resolve`}),(0,H.jsx)(`button`,{type:`button`,onClick:n,disabled:r||i,style:{padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontSize:`0.8125rem`,cursor:i?`wait`:`pointer`},children:i?`…`:`Delete`})]})]})]})}function oA({documentId:e}){let{data:t,isLoading:n,error:r}=oo(e),i=so(e),a=G(e),o=co(e),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(null),h=t??[],g=h.filter(e=>!e.resolved),_=h.filter(e=>e.resolved),v=()=>{let e=iA();e!==null&&u(e)},y=()=>{let e=s.trim();if(e===``)return;let t=l??iA();i.mutate(t===null?{body:e}:{body:e,passage:t},{onSuccess:()=>{c(``),u(null)}})},b=e=>{m(e.id),a.mutate({id:e.id,input:{resolved:!e.resolved}},{onSettled:()=>{m(null)}})},x=e=>{confirm(`Delete this comment?`)&&(m(e.id),o.mutate(e.id,{onSettled:()=>{m(null)}}))};return(0,H.jsxs)(`aside`,{style:{width:320,flexShrink:0,borderLeft:`1px solid #e5e7eb`,paddingLeft:`1rem`,display:`flex`,flexDirection:`column`,gap:`1rem`},children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{style:{margin:`0 0 0.25rem`,fontSize:`1.125rem`},children:`Comments`}),(0,H.jsxs)(`p`,{style:{margin:0,fontSize:`0.875rem`,color:`#6b7280`},children:[g.length,` open`]})]}),(0,H.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`,padding:`0.75rem`,border:`1px solid #e5e7eb`,borderRadius:8,background:`#fafafa`},children:[l===null?null:(0,H.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`0.5rem`,padding:`0.5rem`,background:`#fff`,border:`1px solid #e5e7eb`,borderRadius:6},children:[(0,H.jsxs)(`p`,{style:{margin:0,flex:1,fontSize:`0.8125rem`,color:`#6b7280`,fontStyle:`italic`},children:[`“`,l,`”`]}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{u(null)},"aria-label":`Clear attached selection`,style:{padding:`0.125rem 0.375rem`,borderRadius:4,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.75rem`,cursor:`pointer`},children:`Clear`})]}),(0,H.jsx)(`textarea`,{value:s,onChange:e=>{c(e.target.value)},placeholder:`Leave feedback for teammates or an agent…`,rows:3,style:{width:`100%`,padding:`0.5rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,resize:`vertical`,fontFamily:`inherit`,fontSize:`0.875rem`}}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,flexWrap:`wrap`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:v,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:`#fff`,fontSize:`0.8125rem`,cursor:`pointer`},children:`Attach selection`}),(0,H.jsx)(`button`,{type:`button`,onClick:y,disabled:s.trim()===``||i.isPending,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,fontSize:`0.8125rem`,cursor:i.isPending?`wait`:`pointer`},children:i.isPending?`Adding…`:`Add comment`})]}),i.error===null?null:(0,H.jsx)(`p`,{role:`alert`,style:{margin:0,fontSize:`0.8125rem`,color:`#b91c1c`},children:i.error.message})]}),n?(0,H.jsx)(`p`,{style:{margin:0,color:`#6b7280`},children:`Loading comments…`}):null,r===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{margin:0,color:`#b91c1c`},children:[`Failed to load comments: `,r.message]}),!n&&r===null&&h.length===0?(0,H.jsx)(`p`,{style:{margin:0,color:`#6b7280`,fontSize:`0.875rem`},children:`No comments yet — add one to leave feedback for teammates or an agent.`}):null,!n&&r===null&&g.length>0?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{style:{margin:`0 0 0.5rem`,fontSize:`0.875rem`,color:`#374151`},children:`Open`}),(0,H.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:g.map(e=>(0,H.jsx)(aA,{comment:e,onResolve:()=>{b(e)},onDelete:()=>{x(e)},isResolving:a.isPending&&p===e.id,isDeleting:o.isPending&&p===e.id},e.id))})]}):null,!n&&r===null&&_.length>0?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(e=>!e)},style:{padding:`0.25rem 0`,border:`none`,background:`transparent`,color:`#1d4ed8`,fontSize:`0.875rem`,cursor:`pointer`,marginBottom:d?`0.5rem`:0},children:d?`Hide resolved`:`Show resolved (${String(_.length)})`}),d?(0,H.jsx)(`ul`,{style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:_.map(e=>(0,H.jsx)(aA,{comment:e,onResolve:()=>{b(e)},onDelete:()=>{x(e)},isResolving:a.isPending&&p===e.id,isDeleting:o.isPending&&p===e.id},e.id))}):null]}):null]})}function sA(e){this.content=e}sA.prototype={constructor:sA,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new sA(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new sA(n)},addToStart:function(e,t){return new sA([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new sA(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new sA(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=sA.from(e),e.size?new sA(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=sA.from(e),e.size?new sA(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=sA.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},sA.from=function(e){if(e instanceof sA)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new sA(t)};function cA(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=cA(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function lA(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=lA(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var J=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return cA(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return lA(this,e,t,n)}findIndex(e){if(e==0)return dA(0,e);if(e==this.size)return dA(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?dA(t+1,i):dA(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};J.empty=new J([],0);var uA={index:0,offset:0};function dA(e,t){return uA.index=e,uA.offset=t,uA}function fA(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!fA(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!fA(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var pA=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&fA(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 RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};pA.none=[];var mA=class extends Error{},Y=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=gA(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(hA(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(J.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Y.empty=new Y(J.empty,0,0);function hA(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(hA(a.content,t-i-1,n-i-1)))}function gA(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=gA(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function _A(e,t,n){if(n.openStart>e.depth)throw new mA(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new mA(`Inconsistent open depths`);return vA(e,t,n,0)}function vA(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=vA(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return CA(a,TA(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return CA(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=EA(n,e);return CA(a,wA(e,i,o,t,r))}}function yA(e,t){if(!t.type.compatibleContent(e.type))throw new mA(`Cannot join `+t.type.name+` onto `+e.type.name)}function bA(e,t,n){let r=e.node(n);return yA(r,t.node(n)),r}function xA(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function SA(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(xA(e.nodeAfter,r),a++));for(let e=a;e<o;e++)xA(i.child(e),r);t&&t.depth==n&&t.textOffset&&xA(t.nodeBefore,r)}function CA(e,t){return e.type.checkContent(t),e.copy(t)}function wA(e,t,n,r,i){let a=e.depth>i&&bA(e,t,i+1),o=r.depth>i&&bA(n,r,i+1),s=[];return SA(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(yA(a,o),xA(CA(a,wA(e,t,n,r,i+1)),s)):(a&&xA(CA(a,TA(e,t,i+1)),s),SA(t,n,i,s),o&&xA(CA(o,TA(n,r,i+1)),s)),SA(r,null,i,s),new J(s)}function TA(e,t,n){let r=[];return SA(null,e,n,r),e.depth>n&&xA(CA(bA(e,t,n+1),TA(e,t,n+1)),r),SA(t,null,n,r),new J(r)}function EA(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(J.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var DA=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return pA.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new jA(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=AA.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else AA.set(t,r=new OA);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%kA,i}},OA=class{constructor(){this.elts=[],this.i=0}},kA=12,AA=new WeakMap,jA=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},MA=Object.create(null),NA=class e{constructor(e,t,n,r=pA.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||J.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&fA(this.attrs,t||e.defaultAttrs||MA)&&pA.sameSet(this.marks,n||pA.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Y.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Y(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return _A(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return DA.resolveCached(this,e)}resolveNoCache(e){return DA.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),FA(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=J.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=pA.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!pA.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=J.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};NA.prototype.text=void 0;var PA=class e extends NA{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):FA(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function FA(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var IA=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new LA(t,n);if(r.next==null)return e.empty;let i=RA(r);r.next&&r.err(`Unexpected trailing text`);let a=JA(GA(i));return YA(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return J.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
86
|
+
`)}};IA.empty=new IA(!0);var LA=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function RA(e){let t=[];do t.push(zA(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function zA(e){let t=[];do t.push(BA(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function BA(e){let t=WA(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=HA(e,t);else break;return t}function VA(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function HA(e,t){let n=VA(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:VA(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function UA(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function WA(e){if(e.eat(`(`)){let t=RA(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=UA(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function GA(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function KA(e,t){return t-e}function qA(e,t){let n=[];return r(t),n.sort(KA);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function JA(e){let t=Object.create(null);return n(qA(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);qA(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new IA(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(KA);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function YA(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function XA(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function ZA(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function QA(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function $A(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new nj(e,r,t[r]);return n}var ej=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=$A(e,n.attrs),this.defaultAttrs=XA(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==IA.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ZA(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new NA(this,this.computeAttrs(e),J.from(t),pA.setFrom(n))}createChecked(e=null,t,n){return t=J.from(t),this.checkContent(t),new NA(this,this.computeAttrs(e),t,pA.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=J.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(J.empty,!0);return i?new NA(this,e,t.append(i),pA.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){QA(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:pA.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function tj(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var nj=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?tj(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},rj=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=$A(e,r.attrs),this.excluded=null;let i=XA(this.attrs);this.instance=i?new pA(this,i):null}create(e=null){return!e&&this.instance?this.instance:new pA(this,ZA(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){QA(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},ij=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=sA.from(e.nodes),t.marks=sA.from(e.marks||{}),this.nodes=ej.compile(this.spec.nodes,this),this.marks=rj.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=IA.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?aj(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:aj(this,n.split(` `))}this.nodeFromJSON=e=>NA.fromJSON(this,e),this.markFromJSON=e=>pA.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof ej))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new PA(n,n.defaultAttrs,e,pA.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function aj(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function oj(e){return e.tag!=null}function sj(e){return e.style!=null}var cj=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(oj(e))this.tags.push(e);else if(sj(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new _j(this,t,!1);return n.addAll(e,pA.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new _j(this,t,!0);return n.addAll(e,pA.none,t.from,t.to),Y.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(yj(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=bj(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=bj(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},lj={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},uj={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dj={ol:!0,ul:!0},fj=1,pj=2,mj=4;function hj(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?fj:0)|(t===`full`?pj:0)}var gj=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=pA.none,this.match=i||(a&mj?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(J.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&fj)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=J.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(J.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&&!lj.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},_j=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=hj(null,t.preserveWhitespace,0)|(n?mj:0);i=r?new gj(r.type,r.attrs,pA.none,!0,t.topMatch||r.type.contentMatch,a):n?new gj(null,null,pA.none,!0,null,a):new gj(e.schema.topNodeType,null,pA.none,!0,null,a),this.nodes=[i],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 n=e.nodeValue,r=this.top,i=r.options&pj?`full`:this.localPreserveWS||(r.options&fj)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
87
|
+
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;dj.hasOwnProperty(a)&&this.parser.normalizeLists&&vj(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:uj.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(lj.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
88
|
+
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=pA.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):xj(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=hj(e,i,a.options);a.options&mj&&a.content.length==0&&(o|=mj);let s=pA.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):xj(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new gj(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=fj);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function vj(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&dj.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function yj(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function bj(e){let t={};for(let n in e)t[n]=e[n];return t}function xj(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Sj=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=wj(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return wj(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Oj(wj(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Oj(wj(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Oj(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Cj(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Cj(e.marks)}};function Cj(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function wj(e){return e.document||window.document}var Tj=new WeakMap;function Ej(e){let t=Tj.get(e);return t===void 0&&Tj.set(e,t=Dj(e)),t}function Dj(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Oj(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Ej(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Oj(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var kj=65535,Aj=2**16;function jj(e,t){return e+t*Aj}function Mj(e){return e&kj}function Nj(e){return(e-(e&kj))/Aj}var Pj=1,Fj=2,Ij=4,Lj=8,Rj=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Lj)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Ij)>0}},zj=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Mj(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Nj(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:jj(o/3,e-s),f=e==s?Fj:e==u?Pj:Ij;return(t<0?e!=s:e!=u)&&(f|=Lj),new Rj(a,f,d)}r+=l-c}return n?e+r:new Rj(e+r,0,null)}touches(e,t){let n=0,r=Mj(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};zj.empty=new zj([]);var Bj=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Rj(e,r,null)}},Vj=Object.create(null),Hj=class{getMap(){return zj.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Vj[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Vj)throw RangeError(`Duplicate use of step JSON ID `+e);return Vj[e]=t,t.prototype.jsonID=e,t}},Uj=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof mA)return e.fail(t.message);throw t}}};function Wj(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Wj(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return J.fromArray(r)}var Gj=class e extends Hj{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Y(Wj(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Uj.fromReplace(e,this.from,this.to,i)}invert(){return new Kj(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Hj.jsonID(`addMark`,Gj);var Kj=class e extends Hj{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Y(Wj(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Uj.fromReplace(e,this.from,this.to,n)}invert(){return new Gj(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};Hj.jsonID(`removeMark`,Kj);var qj=class e extends Hj{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Uj.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Uj.fromReplace(e,this.pos,this.pos+1,new Y(J.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Jj(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Hj.jsonID(`addNodeMark`,qj);var Jj=class e extends Hj{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Uj.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Uj.fromReplace(e,this.pos,this.pos+1,new Y(J.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new qj(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};Hj.jsonID(`removeNodeMark`,Jj);var Yj=class e extends Hj{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Zj(e,this.from,this.to)?Uj.fail(`Structure replace would overwrite content`):Uj.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new zj([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Y.empty:new Y(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Y.empty:new Y(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Y.fromJSON(t,n.slice),!!n.structure)}};Yj.MAP_BIAS=1,Hj.jsonID(`replace`,Yj);var Xj=class e extends Hj{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Zj(e,this.from,this.gapFrom)||Zj(e,this.gapTo,this.to)))return Uj.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Uj.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Uj.fromReplace(e,this.from,this.to,n):Uj.fail(`Content does not fit in gap`)}getMap(){return new zj([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Y.fromJSON(t,n.slice),n.insert,!!n.structure)}};Hj.jsonID(`replaceAround`,Xj);function Zj(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Qj(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Kj(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Gj(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function $j(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof rj){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Kj(t.from,t.to,t.style)))}function eM(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Yj(s,l,Y.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Kj(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Y(J.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Yj(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(J.empty,!0);e.replace(s,s,new Y(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function tM(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function nM(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!tM(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function rM(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=J.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=J.from(r.node(e).copy(u)),d++):c--;let f=J.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=J.from(i.node(e).copy(f)),p++):l++;e.step(new Xj(c,l,o,s,new Y(u.append(f),d,p),u.size-d,!0))}function iM(e,t,n=null,r=e){let i=oM(e,t),a=i&&sM(r,t);return a?i.map(aM).concat({type:t,attrs:n}).concat(a.map(aM)):null}function aM(e){return{type:e,attrs:null}}function oM(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function sM(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function cM(e,t,n){let r=J.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=J.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Xj(i,a,i,a,new Y(r,0,0),n.length,!0))}function lM(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&fM(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&dM(e,t,n,a),eM(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Xj(c,l,c+1,l-1,new Y(J.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&uM(e,t,n,a),!1}})}function uM(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function dM(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
89
|
+
`))}})}function fM(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function pM(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Xj(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new Y(J.from(o),0,0),1,!0))}function mM(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function hM(e,t,n=1,r){let i=e.doc.resolve(t),a=J.empty,o=J.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=J.from(i.node(e).copy(a));let t=r&&r[s];o=J.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Yj(t,t,new Y(a.append(o),n,n),!0))}function gM(e,t){let n=e.resolve(t),r=n.index();return vM(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function _M(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function vM(e,t){return!!(e&&t&&!e.isLeaf&&_M(e,t))}function yM(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&vM(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function bM(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);dM(e,r.node(),r.before(),s)}o.inlineContent&&eM(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Yj(l,c.map(t+n,-1),Y.empty,!0)),r===!0){let t=e.doc.resolve(l);uM(e,t.node(),t.before(),e.steps.length)}return e}function xM(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function SM(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function CM(e,t,n=t,r=Y.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return wM(i,a,r)?new Yj(t,n,r):new TM(i,a,r).fit()}function wM(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var TM=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=J.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=J.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new Y(i,a,o);return e>-1?new Xj(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Yj(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=OM(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(J.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=OM(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new Y(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=OM(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new Y(EM(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new Y(EM(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(kM(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=DM(this.placed,t,J.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?Y.empty:new Y(EM(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new Y(EM(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!AM(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=AM(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=AM(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=DM(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=DM(this.placed,this.depth,J.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(J.empty,!0);e.childCount&&(this.placed=DM(this.placed,this.frontier.length,e))}};function EM(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(EM(e.firstChild.content,t-1,n)))}function DM(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(DM(e.lastChild.content,t-1,n)))}function OM(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function kM(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,kM(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(J.empty,!0)))),e.copy(r)}function AM(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!jM(n,a.content,o)?s:null}function jM(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function MM(e){return e.spec.defining||e.spec.definingForContent}function NM(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(wM(i,a,r))return e.step(new Yj(t,n,r));let o=LM(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=MM(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new Y(PM(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function PM(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(PM(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(J.empty,!0))}return e}function FM(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=xM(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new Y(J.from(r),0,0))}function IM(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=LM(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function LM(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var RM=class e extends Hj{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return Uj.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return Uj.fromReplace(e,this.pos,this.pos+1,new Y(J.from(r),0,+!t.isLeaf))}getMap(){return zj.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};Hj.jsonID(`attr`,RM);var zM=class e extends Hj{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return Uj.ok(n)}getMap(){return zj.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};Hj.jsonID(`docAttr`,zM);var BM=class extends Error{};BM=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},BM.prototype=Object.create(Error.prototype),BM.prototype.constructor=BM,BM.prototype.name=`TransformError`;var VM=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Bj}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new BM(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=Y.empty){let r=CM(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new Y(J.from(n),0,0))}delete(e,t){return this.replace(e,t,Y.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return NM(this,e,t,n),this}replaceRangeWith(e,t,n){return FM(this,e,t,n),this}deleteRange(e,t){return IM(this,e,t),this}lift(e,t){return rM(this,e,t),this}join(e,t=1){return bM(this,e,t),this}wrap(e,t){return cM(this,e,t),this}setBlockType(e,t=e,n,r=null){return lM(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return pM(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new RM(e,t,n)),this}setDocAttribute(e,t){return this.step(new zM(e,t)),this}addNodeMark(e,t){return this.step(new qj(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof pA)t.isInSet(n.marks)&&this.step(new Jj(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new Jj(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return hM(this,e,t,n),this}addMark(e,t,n){return Qj(this,e,t,n),this}removeMark(e,t,n){return $j(this,e,t,n),this}clearIncompatible(e,t,n){return eM(this,e,t,n),this}},HM=Object.create(null),UM=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new WM(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=Y.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?Y.empty:t),o==0&&QM(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),QM(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new X(e):ZM(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?ZM(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):ZM(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new YM(e.node(0))}static atStart(e){return ZM(e,e,0,0,1)||new YM(e)}static atEnd(e){return ZM(e,e,e.content.size,e.childCount,-1)||new YM(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=HM[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in HM)throw RangeError(`Duplicate use of selection JSON ID `+e);return HM[e]=t,t.prototype.jsonID=e,t}getBookmark(){return X.between(this.$anchor,this.$head).getBookmark()}};UM.prototype.visible=!0;var WM=class{constructor(e,t){this.$from=e,this.$to=t}},GM=!1;function KM(e){!GM&&!e.parent.inlineContent&&(GM=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var X=class e extends UM{constructor(e,t=e){KM(e),KM(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return UM.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=Y.empty){if(super.replace(e,t),t==Y.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new qM(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=UM.findFrom(n,r,!0)||UM.findFrom(n,-r,!0);if(e)n=e.$head;else return UM.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(UM.findFrom(t,-r,!0)||UM.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};UM.jsonID(`text`,X);var qM=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return X.between(e.resolve(this.anchor),e.resolve(this.head))}},Z=class e extends UM{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?UM.near(a):new e(a)}content(){return new Y(J.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new JM(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Z.prototype.visible=!1,UM.jsonID(`node`,Z);var JM=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new qM(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&Z.isSelectable(n)?new Z(t):UM.near(t)}},YM=class e extends UM{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Y.empty){if(t==Y.empty){e.delete(0,e.doc.content.size);let t=UM.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return XM}};UM.jsonID(`all`,YM);var XM={map(){return this},resolve(e){return new YM(e)}};function ZM(e,t,n,r,i,a=!1){if(t.inlineContent)return X.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=ZM(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Z.isSelectable(r))return Z.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function QM(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Yj||i instanceof Xj))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(UM.near(e.doc.resolve(o),n))}var $M=1,eN=2,tN=4,nN=class extends VM{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|$M)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&$M)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=eN,this}ensureMarks(e){return pA.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&eN)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||pA.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(UM.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=tN,this}get scrolledIntoView(){return(this.updated&tN)>0}};function rN(e,t){return!t||!e?e:e.bind(t)}var iN=class{constructor(e,t,n){this.name=e,this.init=rN(t.init,n),this.apply=rN(t.apply,n)}},aN=[new iN(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new iN(`selection`,{init(e,t){return e.selection||UM.atStart(t.doc)},apply(e){return e.selection}}),new iN(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new iN(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],oN=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=aN.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new iN(e.key,e.spec.state,e))})}},sN=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new nN(this)}static create(t){let n=new oN(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new oN(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new oN(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=NA.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=UM.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function cN(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=cN(i,t,{})),n[r]=i}return n}var lN=class{constructor(e){this.spec=e,this.props={},e.props&&cN(e.props,this,this.props),this.key=e.key?e.key.key:dN(`plugin`)}getState(e){return e[this.key]}},uN=Object.create(null);function dN(e){return e in uN?e+`$`+ ++uN[e]:(uN[e]=0,e+`$`)}var fN=class{constructor(e=`key`){this.key=dN(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},pN=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function mN(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var hN=(e,t,n)=>{let r=mN(e,n);if(!r)return!1;let i=xN(r);if(!i){let n=r.blockRange(),i=n&&nM(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(zN(e,i,t,-1))return!0;if(r.parent.content.size==0&&(yN(a,`end`)||Z.isSelectable(a)))for(let n=r.depth;;n--){let o=CM(e.doc,r.before(n),r.after(n),Y.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(yN(a,`end`)?UM.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):Z.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},gN=(e,t,n)=>{let r=mN(e,n);if(!r)return!1;let i=xN(r);return i?vN(e,i,t):!1},_N=(e,t,n)=>{let r=SN(e,n);if(!r)return!1;let i=TN(r);return i?vN(e,i,t):!1};function vN(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=CM(e.doc,i,o,Y.empty);if(!s||s.from!=i||s instanceof Yj&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(X.create(t.doc,i)),n(t.scrollIntoView())}return!0}function yN(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var bN=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=xN(r)}let o=a&&a.nodeBefore;return!o||!Z.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Z.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function xN(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function SN(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var CN=(e,t,n)=>{let r=SN(e,n);if(!r)return!1;let i=TN(r);if(!i)return!1;let a=i.nodeAfter;if(zN(e,i,t,1))return!0;if(r.parent.content.size==0&&(yN(a,`start`)||Z.isSelectable(a))){let n=CM(e.doc,r.before(),r.after(),Y.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(yN(a,`start`)?UM.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):Z.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},wN=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=TN(r)}let o=a&&a.nodeAfter;return!o||!Z.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Z.create(e.doc,a.pos)).scrollIntoView()),!0)};function TN(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var EN=(e,t)=>{let n=e.selection,r=n instanceof Z,i;if(r){if(n.node.isTextblock||!gM(e.doc,n.from))return!1;i=n.from}else if(i=yM(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Z.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},DN=(e,t)=>{let n=e.selection,r;if(n instanceof Z){if(n.node.isTextblock||!gM(e.doc,n.to))return!1;r=n.to}else if(r=yM(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},ON=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&nM(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},kN=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
90
|
+
`).scrollIntoView()),!0)};function AN(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var jN=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=AN(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(UM.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},MN=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof YM||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=AN(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(X.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},NN=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(mM(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&nM(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function PN(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Z&&t.selection.node.isBlock)return!r.parentOffset||!mM(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=AN(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof X||t.selection instanceof YM)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=mM(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,mM(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var FN=PN(),IN=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Z.create(e.doc,i))),!0)},LN=(e,t)=>(t&&t(e.tr.setSelection(new YM(e.doc))),!0);function RN(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||gM(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function zN(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&RN(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=J.empty;for(let e=o.length-1;e>=0;e--)s=J.from(o[e].create(null,s));s=J.from(i.copy(s));let c=e.tr.step(new Xj(t.pos-1,r,t.pos,r,new Y(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&gM(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:UM.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&nM(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&yN(a,`start`,!0)&&yN(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=J.empty;for(let e=o.length-1;e>=0;e--)r=J.from(o[e].copy(r));n(e.tr.step(new Xj(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new Y(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function BN(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(X.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var VN=BN(-1),HN=BN(1);function UN(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&iM(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function WN(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function GN(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var KN=GN(pN,hN,bN),qN=GN(pN,CN,wN),JN={Enter:GN(kN,MN,NN,FN),"Mod-Enter":jN,Backspace:KN,"Mod-Backspace":KN,"Shift-Backspace":KN,Delete:qN,"Mod-Delete":qN,"Mod-a":LN},YN={"Ctrl-h":JN.Backspace,"Alt-Backspace":JN[`Mod-Backspace`],"Ctrl-d":JN.Delete,"Ctrl-Alt-Backspace":JN[`Mod-Delete`],"Alt-Delete":JN[`Mod-Delete`],"Alt-d":JN[`Mod-Delete`],"Ctrl-a":VN,"Ctrl-e":HN};for(let e in JN)YN[e]=JN[e];typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform();function XN(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return ZN(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function ZN(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new jA(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new jA(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=iM(a,n,r,t);return s?(e&&QN(e,t,s,i,n),!0):!1}function QN(e,t,n,r,i){let a=J.empty;for(let e=n.length-1;e>=0;e--)a=J.from(n[e].type.create(n[e].attrs,a));e.step(new Xj(t.start-(r?2:0),t.end,t.start,t.end,new Y(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&mM(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function $N(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?eP(t,n,e,a):tP(t,n,a):!0:!1}}function eP(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new Xj(a-1,o,a,o,new Y(J.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new jA(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=nM(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return gM(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function tP(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?J.empty:J.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new Xj(d-+!!s,f+ +!!c,d+1,f-1,new Y((s?J.empty:J.from(i.copy(J.empty))).append(c?J.empty:J.from(i.copy(J.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function nP(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=J.from(r?e.create():null),o=new Y(J.from(e.create(null,J.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new Xj(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var rP=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},iP=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},aP=null,oP=function(e,t,n){let r=aP||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},sP=function(){aP=null},cP=function(e,t,n,r){return n&&(uP(e,t,n,r,-1)||uP(e,t,n,r,1))},lP=/^(img|br|input|textarea|hr)$/i;function uP(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:dP(e))){let n=e.parentNode;if(!n||n.nodeType!=1||hP(e)||lP.test(e.nodeName)||e.contentEditable==`false`)return!1;t=rP(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?dP(e):0}else return!1}}function dP(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function fP(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=dP(e)}else if(e.parentNode&&!hP(e))t=rP(e),e=e.parentNode;else return null}}function pP(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!hP(e))t=rP(e)+1,e=e.parentNode;else return null}}function mP(e,t,n){for(let r=t==0,i=t==dP(e);r||i;){if(e==n)return!0;let t=rP(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==dP(e)}}function hP(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var gP=function(e){return e.focusNode&&cP(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function _P(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function vP(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function yP(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(dP(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(dP(r.startContainer),r.startOffset)}}}var bP=typeof navigator<`u`?navigator:null,xP=typeof document<`u`?document:null,SP=bP&&bP.userAgent||``,CP=/Edge\/(\d+)/.exec(SP),wP=/MSIE \d/.exec(SP),TP=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(SP),EP=!!(wP||TP||CP),DP=wP?document.documentMode:TP?+TP[1]:CP?+CP[1]:0,OP=!EP&&/gecko\/(\d+)/i.test(SP);OP&&+(/Firefox\/(\d+)/.exec(SP)||[0,0])[1];var kP=!EP&&/Chrome\/(\d+)/.exec(SP),AP=!!kP,jP=kP?+kP[1]:0,MP=!EP&&!!bP&&/Apple Computer/.test(bP.vendor),NP=MP&&(/Mobile\/\w+/.test(SP)||!!bP&&bP.maxTouchPoints>2),PP=NP||(bP?/Mac/.test(bP.platform):!1),FP=bP?/Win/.test(bP.platform):!1,IP=/Android \d/.test(SP),LP=!!xP&&`webkitFontSmoothing`in xP.documentElement.style,RP=LP?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function zP(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function BP(e,t){return typeof e==`number`?e:e[t]}function VP(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function HP(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=iP(o);continue}let e=o,n=e==a.body,s=n?zP(a):VP(e),c=0,l=0;if(t.top<s.top+BP(r,`top`)?l=-(s.top-t.top+BP(i,`top`)):t.bottom>s.bottom-BP(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+BP(i,`top`)-s.top:t.bottom-s.bottom+BP(i,`bottom`)),t.left<s.left+BP(r,`left`)?c=-(s.left-t.left+BP(i,`left`)):t.right>s.right-BP(r,`right`)&&(c=t.right-s.right+BP(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:iP(o)}}function UP(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:WP(e.dom)}}function WP(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=iP(r));return t}function GP({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;KP(n,r==0?0:r-t)}function KP(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var qP=null;function JP(e){if(e.setActive)return e.setActive();if(qP)return e.focus(qP);let t=WP(e);e.focus(qP==null?{get preventScroll(){return qP={preventScroll:!0},!0}}:void 0),qP||(qP=!1,KP(t,0))}function YP(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=oP(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?XP(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:YP(n,i)}function XP(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=iF(r,1);if(n.top!=n.bottom&&ZP(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function ZP(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function QP(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function $P(e,t,n){let{node:r,offset:i}=YP(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function eF(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function tF(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(ZP(t,i))return tF(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function nF(e,t){let n=e.dom.ownerDocument,r,i=0,a=yP(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!ZP(t,n)||(o=tF(e.dom,t,n),!o))return null}if(MP)for(let e=o;r&&e;e=iP(e))e.draggable&&(r=void 0);if(o=QP(o,t),r){if(OP&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;LP&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=eF(e,r,i,t))}s??=$P(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function rF(e){return e.top<e.bottom||e.left<e.right}function iF(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(rF(e))return e}return Array.prototype.find.call(n,rF)||e.getBoundingClientRect()}var aF=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function oF(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=LP||OP;if(r.nodeType==3)if(o&&(aF.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=iF(oP(r,i,i),n);if(OP&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=iF(oP(r,i-1,i-1),-1);if(t.top==e.top){let n=iF(oP(r,i,i+1),-1);if(n.top!=e.top)return sF(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,sF(iF(oP(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==dP(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return cF(e.getBoundingClientRect(),!1)}if(a==null&&i<dP(r)){let e=r.childNodes[i];if(e.nodeType==1)return cF(e.getBoundingClientRect(),!0)}return cF(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==dP(r))){let e=r.childNodes[i-1],t=e.nodeType==3?oP(e,dP(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return sF(iF(t,1),!1)}if(a==null&&i<dP(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?oP(e,0,+!o):e.nodeType==1?e:null:null;if(t)return sF(iF(t,-1),!0)}return sF(iF(r.nodeType==3?oP(r):r,-n),n>=0)}function sF(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function cF(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function lF(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function uF(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return lF(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=oF(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=oP(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var dF=/[\u0590-\u08ac]/;function fF(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!dF.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:lF(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var pF=null,mF=null,hF=!1;function gF(e,t,n){return pF==t&&mF==n?hF:(pF=t,mF=n,hF=n==`up`||n==`down`?uF(e,t,n):fF(e,t,n))}var _F=0,vF=1,yF=2,bF=3,xF=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=_F,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>rP(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof OF){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof SF&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?rP(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?rP(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=rP(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=rP(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}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:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((OP||MP)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
|
|
91
|
+
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:rP(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(OP&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&MP)&&cP(o.node,o.offset,l.anchorNode,l.anchorOffset)&&cP(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&OP)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}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 n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?yF:vF,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=bF:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?yF:bF}n=a}this.dirty=yF}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?yF:vF;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},SF=class extends xF{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==_F&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},CF=class extends xF{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},wF=class e extends xF{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=Sj.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&bF||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=bF&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=_F){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=_F}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=GF(a,n,o,r)),t>0&&(a=GF(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},TF=class e extends xF{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Sj.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=IF(u,r,n),l?c=new kF(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new DF(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+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 n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>J.empty)}return e}matchesNode(e,t,n){return this.dirty==_F&&e.eq(this.node)&&LF(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new zF(this,a&&a.node,e);HF(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?pA.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==yF)&&(a&&this.protectLocalComposition(e,a),AF(this.contentDOM,this.children,e),NP&&UF(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof X)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=WF(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new CF(this,i,t,r);e.input.compositionNodes.push(a),this.children=GF(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==bF||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=_F}updateOuterDeco(e){if(LF(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=PF(this.dom,this.nodeDOM,NF(this.outerDeco,this.node,t),NF(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function EF(e,t,n,r,i){IF(r,t,e);let a=new TF(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var DF=class e extends TF{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==bF||this.dirty!=_F&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=_F||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=_F,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=bF)}get domAtom(){return!1}isText(e){return this.node.text==e}},OF=class extends xF{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==_F&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},kF=class extends TF{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==bF)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function AF(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=RF(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof wF){let t=r?r.previousSibling:e.lastChild;AF(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=RF(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var jF=function(e){e&&(this.nodeName=e)};jF.prototype=Object.create(null);var MF=[new jF];function NF(e,t,n){if(e.length==0)return MF;let r=n?MF[0]:new jF,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new jF(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new jF(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function PF(e,t,n,r){if(n==MF&&r==MF)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=MF[0],i=t)}FF(i,o||MF[0],a)}return i}function FF(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function IF(e,t,n){return PF(e,e,MF,NF(t,n,e.nodeType!=1))}function LF(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function RF(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var zF=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=BF(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=_F,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=wF.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==bF&&a.dom==a.contentDOM&&(a.dirty=yF),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof TF){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=bF&&LF(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=yF,u.updateChildren(r,a+1),u.dirty=_F),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!LF(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=TF.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=TF.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new SF(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof wF;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof DF)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((MP||AP)&&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 n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new OF(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function BF(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof wF)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function VF(e,t){return e.type.side-t.type.side}function HF(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(VF);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function UF(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function WF(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function GF(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function KF(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(gP(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Z.isSelectable(e)&&i.parent&&!(e.isInline&&mP(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Z(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=rI(e,u,s,n)}return l}function qF(e){return e.editable?e.hasFocus():aI(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function JF(e,t=!1){let n=e.state.selection;if(tI(e,n),qF(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&AP){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&cP(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)eI(e);else{let{anchor:r,head:i}=n,a,o;YF&&!(n instanceof X)&&(n.$from.parent.inlineContent||(a=XF(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=XF(e,n.to))),e.docView.setSelection(r,i,e,t),YF&&(a&&QF(a),o&&QF(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&$F(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var YF=MP||AP&&jP<63;function XF(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(MP&&i&&i.contentEditable==`false`)return ZF(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return ZF(i);if(a)return ZF(a)}}function ZF(e){return e.contentEditable=`true`,MP&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function QF(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function $F(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!qF(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function eI(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,rP(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&EP&&DP<=11&&(n.disabled=!0,n.disabled=!1)}function tI(e,t){if(t instanceof Z){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(nI(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else nI(e)}function nI(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function rI(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||X.between(t,n,r)}function iI(e){return e.editable&&!e.hasFocus()?!1:aI(e)}function aI(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function oI(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return cP(t.node,t.offset,n.anchorNode,n.anchorOffset)}function sI(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&UM.findFrom(a,t)}function cI(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function lI(e,t,n){let r=e.state.selection;if(r instanceof X){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return cI(e,new X(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=sI(e.state,t);return n&&n instanceof Z?cI(e,n):!1}else if(!(PP&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Z.isSelectable(i)?cI(e,new Z(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):LP?cI(e,new X(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Z&&r.node.isInline)return cI(e,new X(t>0?r.$to:r.$from));else{let n=sI(e.state,t);return n?cI(e,n):!1}}function uI(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function dI(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function fI(e,t){return t<0?pI(e):mI(e)}function pI(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(OP&&n.nodeType==1&&r<uI(n)&&dI(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(dI(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(hI(n))break;else{let t=n.previousSibling;for(;t&&dI(t,-1);)i=n.parentNode,a=rP(t),t=t.previousSibling;if(t)n=t,r=uI(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?vI(e,n,r):i&&vI(e,i,a)}function mI(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=uI(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(dI(e,1))a=n,o=++r;else break}else if(hI(n))break;else{let t=n.nextSibling;for(;t&&dI(t,1);)a=t.parentNode,o=rP(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=uI(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&vI(e,a,o)}function hI(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function gI(e,t){for(;e&&t==e.childNodes.length&&!hP(e);)t=rP(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function _I(e,t){for(;e&&!t&&!hP(e);)t=rP(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function vI(e,t,n){if(t.nodeType!=3){let e,r;(r=gI(t,n))?(t=r,n=0):(e=_I(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(gP(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&JF(e)},50)}function yI(e,t){let n=e.state.doc.resolve(t);if(!(AP||FP)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function bI(e,t,n){let r=e.state.selection;if(r instanceof X&&!r.empty||n.indexOf(`s`)>-1||PP&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=sI(e.state,t);if(n&&n instanceof Z)return cI(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof YM?UM.near(n,t):UM.findFrom(n,t);return o?cI(e,o):!1}return!1}function xI(e,t){if(!(e.state.selection instanceof X))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function SI(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function CI(e){if(!MP||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;SI(e,n,`true`),setTimeout(()=>SI(e,n,`false`),20)}return!1}function wI(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function TI(e,t){let n=t.keyCode,r=wI(t);if(n==8||PP&&n==72&&r==`c`)return xI(e,-1)||fI(e,-1);if(n==46&&!t.shiftKey||PP&&n==68&&r==`c`)return xI(e,1)||fI(e,1);if(n==13||n==27)return!0;if(n==37||PP&&n==66&&r==`c`){let t=n==37?yI(e,e.state.selection.from)==`ltr`?-1:1:-1;return lI(e,t,r)||fI(e,t)}else if(n==39||PP&&n==70&&r==`c`){let t=n==39?yI(e,e.state.selection.from)==`ltr`?1:-1:1;return lI(e,t,r)||fI(e,t)}else if(n==38||PP&&n==80&&r==`c`)return bI(e,-1,r)||fI(e,-1);else if(n==40||PP&&n==78&&r==`c`)return CI(e)||bI(e,1,r)||fI(e,1);else if(r==(PP?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function EI(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Sj.fromSchema(e.state.schema),s=LI(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=FI[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
|
|
92
92
|
|
|
93
|
-
`),slice:t}}function
|
|
94
|
-
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=RD.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=nN(n),$A&&rN(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||wD.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!WM.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=iN(XM(s,+u[1],+u[2]),u[4]);else if(s=Y.maxOpen(GM(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=XM(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var WM=/^(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 GM(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&qM(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=JM(a[a.length-1],i.length));let n=KM(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return J.from(a)}return e}function KM(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,J.from(e));return e}function qM(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=qM(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(J.from(KM(n,e,i+1))))}}function JM(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,JM(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(J.empty,!0);return e.copy(n.append(r))}function YM(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=YM(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(J.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function XM(e,t,n){return t<e.openStart&&(e=new Y(YM(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Y(YM(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var ZM={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},QM=null;function $M(){return QM||=document.implementation.createHTMLDocument(`title`)}var eN=null;function tN(e){let t=window.trustedTypes;return t?(eN||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),eN.createHTML(e)):e}function nN(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=$M().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&ZM[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=tN(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function rN(e){let t=e.querySelectorAll(KA?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function iN(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=J.from(t.create(r[e+1],i)),a++,o++}return new Y(i,a,o)}var aN={},oN={},sN={touchstart:!0,touchmove:!0},cN=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function lN(e){for(let t in aN){let n=aN[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{mN(e,t)&&!pN(e,t)&&(e.editable||!(t.type in oN))&&n(e,t)},sN[t]?{passive:!0}:void 0)}JA&&e.dom.addEventListener(`input`,()=>null),fN(e)}function uN(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function dN(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function fN(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>pN(e,t))})}function pN(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function mN(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function hN(e,t){!pN(e,t)&&aN[t.type]&&(e.editable||!(t.type in oN))&&aN[t.type](e,t)}oN.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!kN(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(QA&&KA&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),YA&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,NA(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||VM(e,n)?n.preventDefault():uN(e,`key`)},oN.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},oN.keypress=(e,t)=>{let n=t;if(kN(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||XA&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof X)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function gN(e){return{left:e.clientX,top:e.clientY}}function _N(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function vN(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function yN(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function bN(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Z.isSelectable(r)?(yN(e,new Z(n),`pointer`),!0):!1}function xN(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Z&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Z.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(yN(e,Z.create(e.state.doc,i),`pointer`),!0)}function SN(e,t,n,r,i){return vN(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?xN(e,n):bN(e,n))}function CN(e,t,n,r){return vN(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function wN(e,t,n,r){return vN(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||TN(e,n,r)}function TN(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(yN(e,X.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)yN(e,X.create(r,a+1,a+1+n.content.size),`pointer`);else if(Z.isSelectable(n))yN(e,Z.create(r,a),`pointer`);else continue;return!0}}function EN(e){return IN(e)}var DN=XA?`metaKey`:`ctrlKey`;aN.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=EN(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&_N(n,e.input.lastClick)&&!n[DN]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(gN(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ON(e,o,n,!!r)):(a==`doubleClick`?CN:wN)(e,o.pos,o.inside,n)?n.preventDefault():uN(e,`pointer`))};var ON=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[DN],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Z&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&WA&&!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)),uN(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(()=>uM(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(gN(e))),this.updateAllowDefault(e),this.allowDefault||!t?uN(this.view,`pointer`):SN(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||JA&&this.mightDrag&&!this.mightDrag.node.isAtom||KA&&!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)?(yN(this.view,ak.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):uN(this.view,`pointer`)}move(e){this.updateAllowDefault(e),uN(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)}};aN.touchstart=e=>{e.input.lastTouch=Date.now(),EN(e),uN(e,`pointer`)},aN.touchmove=e=>{e.input.lastTouch=Date.now(),uN(e,`pointer`)},aN.contextmenu=e=>EN(e);function kN(e,t){return e.composing?!0:JA&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var AN=QA?5e3:-1;oN.compositionstart=oN.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof X&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||KA&&ZA&&jN(e)))e.markCursor=e.state.storedMarks||n.marks(),IN(e,!0),e.markCursor=null;else if(IN(e,!t.selection.empty),WA&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}MN(e,AN)};function jN(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}oN.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,MN(e,20))};function MN(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>IN(e),t))}function NN(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=FN());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function PN(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=OA(t.focusNode,t.focusOffset),r=kA(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function FN(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function IN(e,t=!1){if(!(QA&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),NN(e),t||e.docView&&e.docView.dirty){let n=cM(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function LN(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var RN=HA&&UA<15||YA&&ej<604;aN.copy=oN.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=RN?null:n.clipboardData,{dom:o,text:s}=HM(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):LN(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function zN(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function BN(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?VN(e,r.value,null,i,t):VN(e,r.textContent,r.innerHTML,i,t)},50)}function VN(e,t,n,r,i){let a=UM(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||Y.empty)))return!0;if(!a)return!1;let o=zN(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function HN(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}oN.paste=(e,t)=>{let n=t;if(e.composing&&!QA)return;let r=RN?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&VN(e,HN(r),r.getData(`text/html`),i,n)?n.preventDefault():BN(e,n)};var UN=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},WN=XA?`altKey`:`ctrlKey`;function GN(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[WN]:!n}aN.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(gN(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Z?i.to-1:i.to))){if(r&&r.mightDrag)o=Z.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Z.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=HM(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!KA||qA>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(RN?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,RN||n.dataTransfer.setData(`text/plain`,c),e.dragging=new UN(l,GN(e,n),o)},aN.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},oN.dragover=oN.dragenter=(e,t)=>t.preventDefault(),oN.drop=(e,t)=>{try{KN(e,t,e.dragging)}finally{e.dragging=null}};function KN(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(gN(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=UM(e,HN(t.dataTransfer),RN?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&GN(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||Y.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?RO(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Z.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Z(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(yM(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}aN.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&uM(e)},20))},aN.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},aN.beforeinput=(e,t)=>{if(KA&&QA&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,NA(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in oN)aN[e]=oN[e];function qN(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var JN=class e{constructor(e,t){this.toDOM=e,this.spec=t||$N,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new ZN(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&qN(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},YN=class e{constructor(e,t){this.attrs=e,this.spec=t||$N}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new ZN(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&qN(this.attrs,t.attrs)&&qN(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},XN=class e{constructor(e,t){this.attrs=e,this.spec=t||$N}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new ZN(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&qN(this.attrs,t.attrs)&&qN(this.spec,t.spec)}destroy(){}},ZN=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new JN(n,r))}static inline(t,n,r,i){return new e(t,n,new YN(r,i))}static node(t,n,r,i){return new e(t,n,new XN(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof YN}get widget(){return this.type instanceof JN}},QN=[],$N={},eP=class e{constructor(e,t){this.local=e.length?e:QN,this.children=t.length?t:QN}static create(e,t){return t.length?cP(t,e,0,$N):tP}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==tP||e.maps.length==0?this:this.mapInner(e,t,0,0,n||$N)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?rP(this.children,o||[],t,n,r,i,a):o?new e(o.sort(lP),QN):tP}add(t,n){return n.length?this==tP?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=oP(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,cP(s,e,o+1,$N)),a+=3}});let o=iP(a?sP(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(lP):this.local,i||this.children)}remove(e){return e.length==0||this==tP?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==tP?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):tP}forChild(t,n){if(this==tP)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof YN){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(lP),QN);return r?new nP([t,r]):t}return r||tP}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return uP(this.localsInner(e))}localsInner(e){if(this==tP)return QN;if(e.inlineContent||!this.local.some(YN.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof YN||t.push(this.local[e]);return t}forEachSet(e){e(this)}};eP.empty=new eP([],[]),eP.removeOverlap=uP;var tP=eP.empty,nP=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,$N));return e.from(r)}forChild(t,n){if(n.isLeaf)return eP.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=tP&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?uP(n?t:t.sort(lP)):QN}static from(t){switch(t.length){case 0:return tP;case 1:return t[0];default:return new e(t.every(e=>e instanceof eP)?t:t.reduce((e,t)=>e.concat(t instanceof eP?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function rP(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==tP?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=cP(aP(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new eP(t.sort(lP),s)}function iP(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new ZN(i.from+t,i.to+t,i.type))}return n}function aP(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function oP(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function sP(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function cP(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=oP(e,t,o+n);if(s){a=!0;let e=cP(s,t,n+o+1,r);e!=tP&&i.push(o,o+t.nodeSize,e)}});let o=iP(a?sP(e):e,-n).sort(lP);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new eP(o,i):tP}function lP(e,t){return e.from-t.from||e.to-t.to}function uP(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),dP(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),dP(t,i,r.copy(a.from,r.to)));break}}}return t}function dP(e,t,n){for(;t<e.length&&lP(n,e[t])>0;)t++;e.splice(t,0,n)}function fP(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=tP&&t.push(r)}),e.cursorWrapper&&t.push(eP.create(e.state.doc,[e.cursorWrapper.deco])),nP.from(t)}var pP={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mP=HA&&UA<=11,hP=class{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}},gP=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new hP,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);HA&&UA<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():JA&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),mP&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,pP)),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(bM(this.view)){if(this.suppressingSelectionUpdates)return uM(this.view);if(HA&&UA<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&wA(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,n;for(let n=e.focusNode;n;n=bA(n))t.add(n);for(let r=e.anchorNode;r;r=bA(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))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 n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&bM(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(WA&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||SP(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&MA(n)&&(c=cM(e))&&c.eq(ak.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,uM(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),yP(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,CP(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||uM(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(HA&&UA<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?yA(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?yA(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},_P=new WeakMap,vP=!1;function yP(e){if(!_P.has(e)&&(_P.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=WA,vP)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.`),vP=!0}}function bP(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return wA(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function xP(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return bP(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?bP(e,n):null}function SP(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function CP(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function wP(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],MA(c)||l.push({node:c.focusNode,offset:c.focusOffset})),KA&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||wD.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:TP,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function TP(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(JA&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||JA&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var EP=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function DP(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=cM(e,t);if(n&&!e.state.selection.eq(n)){if(KA&&QA&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,NA(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=wP(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=MP(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(YA&&e.input.lastIOSEnter>Date.now()-225||QA)&&i.some(e=>e.nodeType==1&&!EP.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,NA(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof X&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=OP(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof X&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),HA&&UA<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((YA&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,NA(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&AP(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,NA(8,`Backspace`)))){QA&&KA&&e.domObserver.suppressSelectionUpdates();return}KA&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),QA&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,NA(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=OP(e,n.doc,l.sel);t&&!(KA&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||HA&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){HA&&UA<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>uM(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=kP(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function OP(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:yM(e,t.resolve(n.anchor),t.resolve(n.head))}function kP(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(J.from(l).eq(e))return{mark:s,type:o}}function AP(e,t,n,r,i){if(n-t<=i.pos-r.pos||jP(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(jP(a,!0,!0));return!o.parent.isTextblock||o.pos>n||jP(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function jP(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function MP(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&NP(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&NP(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function NP(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var PP=class{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 cN,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(VP),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=LP(this),IP(this),this.nodeViews=zP(this),this.docView=Hj(this.state.doc,FP(this),fP(this),this.dom,this),this.domObserver=new gP(this,(e,t,n,r)=>DP(this,e,t,n,r)),this.domObserver.start(),lN(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(VP),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(NN(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=zP(this);BP(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&fN(this),this.editable=LP(this),IP(this);let o=fP(this),s=FP(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&aj(this);if(i){this.domObserver.stop();let t=l&&(HA||KA)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&RP(n.selection,e.selection);if(l){let n=KA?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=PN(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Hj(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&SM(this))?uM(this,t):(_M(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&sj(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Z){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&ij(this,t.getBoundingClientRect(),e)}else ij(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new UN(e.slice,e.move,r<0?void 0:Z.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(HA){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&&uj(this.dom),uM(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return vj(this,e)}coordsAtPos(e,t=1){return Sj(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Mj(this,t||this.state,e)}pasteHTML(e,t){return VN(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return VN(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return HM(this,e)}destroy(){this.docView&&(dN(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],fP(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,CA())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return hN(this,e)}domSelectionRange(){let e=this.domSelection();return e?JA&&this.root.nodeType===11&&PA(this.dom.ownerDocument)==this.dom&&xP(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};PP.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function FP(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[ZN.node(0,e.state.doc.content.size,t)]}function IP(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:ZN.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function LP(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function RP(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function zP(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function BP(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function VP(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var HP={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},UP={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},WP=typeof navigator<`u`&&/Mac/.test(navigator.platform),GP=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),KP=0;KP<10;KP++)HP[48+KP]=HP[96+KP]=String(KP);for(var KP=1;KP<=24;KP++)HP[KP+111]=`F`+KP;for(var KP=65;KP<=90;KP++)HP[KP]=String.fromCharCode(KP+32),UP[KP]=String.fromCharCode(KP);for(var qP in HP)UP.hasOwnProperty(qP)||(UP[qP]=HP[qP]);function JP(e){var t=!(WP&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||GP&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?UP:HP)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var YP=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),XP=typeof navigator<`u`&&/Win/.test(navigator.platform);function ZP(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))YP?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function QP(e){let t=Object.create(null);for(let n in e)t[ZP(n)]=e[n];return t}function $P(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function eF(e){return new Tk({props:{handleKeyDown:tF(e)}})}function tF(e){let t=QP(e);return function(e,n){let r=JP(n),i,a=t[$P(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[$P(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(XP&&n.ctrlKey&&n.altKey)&&(i=HP[n.keyCode])&&i!=r){let r=t[$P(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var nF=Object.defineProperty,rF=(e,t)=>{for(var n in t)nF(e,n,{get:t[n],enumerable:!0})};function iF(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var aF=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:iF({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},oF={};rF(oF,{blur:()=>sF,clearContent:()=>cF,clearNodes:()=>lF,command:()=>uF,createParagraphNear:()=>dF,cut:()=>fF,deleteCurrentNode:()=>pF,deleteNode:()=>hF,deleteRange:()=>gF,deleteSelection:()=>bF,enter:()=>xF,exitCode:()=>SF,extendMarkRange:()=>kF,first:()=>AF,focus:()=>LF,forEach:()=>RF,insertContent:()=>zF,insertContentAt:()=>GF,joinBackward:()=>JF,joinDown:()=>qF,joinForward:()=>YF,joinItemBackward:()=>XF,joinItemForward:()=>ZF,joinTextblockBackward:()=>QF,joinTextblockForward:()=>$F,joinUp:()=>KF,keyboardShortcut:()=>nI,lift:()=>iI,liftEmptyBlock:()=>aI,liftListItem:()=>oI,newlineInCode:()=>sI,resetAttributes:()=>uI,scrollIntoView:()=>dI,selectAll:()=>fI,selectNodeBackward:()=>pI,selectNodeForward:()=>mI,selectParentNode:()=>hI,selectTextblockEnd:()=>gI,selectTextblockStart:()=>_I,setContent:()=>yI,setMark:()=>gL,setMeta:()=>_L,setNode:()=>vL,setNodeSelection:()=>yL,setTextDirection:()=>bL,setTextSelection:()=>xL,sinkListItem:()=>SL,splitBlock:()=>wL,splitListItem:()=>TL,toggleList:()=>kL,toggleMark:()=>AL,toggleNode:()=>jL,toggleWrap:()=>ML,undoInputRule:()=>NL,unsetAllMarks:()=>PL,unsetMark:()=>FL,unsetTextDirection:()=>IL,updateAttributes:()=>LL,wrapIn:()=>RL,wrapInList:()=>zL});var sF=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),cF=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),lF=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=vO(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},uF=e=>t=>e(t),dF=()=>({state:e,dispatch:t})=>Jk(e,t),fF=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new X(r.doc.resolve(Math.max(o-1,0)))),!0},pF=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function mF(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var hF=e=>({tr:t,state:n,dispatch:r})=>{let i=mF(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},gF=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},_F=e=>e.content?/^text(\*|\+)/.test(e.content):!1,vF=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return _F(r)?n===`left`?e.start()-1:e.end()+1:e.pos},yF=(e,t,n)=>({from:vF(e,n,`left`),to:vF(t,n,`right`)}),bF=()=>({state:e,dispatch:t})=>{let{$from:n,$to:r}=e.selection;if(e.selection.empty)return!1;let{from:i,to:a}=yF(n,r,e.schema);return t&&(e.tr.deleteRange(i,a).scrollIntoView(),t(e.tr)),!0},xF=()=>({commands:e})=>e.keyboardShortcut(`Enter`),SF=()=>({state:e,dispatch:t})=>qk(e,t);function CF(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function wF(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:CF(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function TF(e,t,n={}){return e.find(e=>e.type===t&&wF(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function EF(e,t,n={}){return!!TF(e,t,n)}function DF(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!TF([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&EF([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&EF([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function OF(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var kF=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=OF(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=DF(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=X.create(o,e.from,e.to);n.setSelection(t)}}return!0},AF=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function jF(e){return e instanceof X}function MF(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function NF(e,t=null){if(!t)return null;let n=ak.atStart(e),r=ak.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?X.create(e,MF(0,i,a),MF(e.content.size,i,a)):X.create(e,MF(t,i,a),MF(t,i,a))}function PF(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function FF(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function IF(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var LF=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(FF()||PF())&&r.dom.focus(),IF()&&!FF()&&!PF()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!jF(n.state.selection))return o(),!0;let s=NF(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},RF=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),zF=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),BF=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&BF(r)}return e};function VF(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return BF(n)}function HF(e,t,n){if(e instanceof YE||e instanceof J)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return J.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),HF(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new bD({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?wD.fromSchema(a).parseSlice(VF(e),n.parseOptions):wD.fromSchema(a).parse(VF(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=wD.fromSchema(t);return n.slice?r.parseSlice(VF(e),n.parseOptions).content:r.parse(VF(e),n.parseOptions)}return HF(``,t,n)}function UF(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof dO||i instanceof fO))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(ak.near(e.doc.resolve(o),n))}var WF=e=>!(`type`in e),GF=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{HF(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=HF(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((WF(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof J){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else{f=i;let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,a=t.isText||t.isTextblock,o=t.content.size>0;n&&a&&o&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&UF(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},KF=()=>({state:e,dispatch:t})=>Hk(e,t),qF=()=>({state:e,dispatch:t})=>Uk(e,t),JF=()=>({state:e,dispatch:t})=>jk(e,t),YF=()=>({state:e,dispatch:t})=>zk(e,t),XF=()=>({state:e,dispatch:t,tr:n})=>{try{let r=FO(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},ZF=()=>({state:e,dispatch:t,tr:n})=>{try{let r=FO(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},QF=()=>({state:e,dispatch:t})=>Mk(e,t),$F=()=>({state:e,dispatch:t})=>Nk(e,t);function eI(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function tI(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))FF()||eI()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var nI=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=tI(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function rI(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?mF(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>wF(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var iI=(e,t={})=>({state:n,dispatch:r})=>rI(n,mF(e,n.schema),t)?Wk(n,r):!1,aI=()=>({state:e,dispatch:t})=>Yk(e,t),oI=e=>({state:t,dispatch:n})=>hA(mF(e,t.schema))(t,n),sI=()=>({state:e,dispatch:t})=>Gk(e,t);function cI(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function lI(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var uI=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=cI(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=mF(e,r.schema)),s===`mark`&&(o=OF(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,lI(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(lI(a.attrs,t))))})})}),c},dI=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),fI=()=>({tr:e,dispatch:t})=>{if(t){let t=new dk(e.doc);e.setSelection(t)}return!0},pI=()=>({state:e,dispatch:t})=>Ik(e,t),mI=()=>({state:e,dispatch:t})=>Bk(e,t),hI=()=>({state:e,dispatch:t})=>Qk(e,t),gI=()=>({state:e,dispatch:t})=>iA(e,t),_I=()=>({state:e,dispatch:t})=>rA(e,t);function vI(e,t,n={},r={}){return HF(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var yI=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=vI(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!n),!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function bI(e,t){let n=OF(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function xI(e,t){let n=new rk(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function SI(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function CI(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function wI(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function TI(e){return t=>wI(t.$from,e)}function Q(e,t,n){return e.config[t]===void 0&&e.parent?Q(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?Q(e.parent,t,n):null}):e.config[t]}function EI(e){return e.map(e=>{let t=Q(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...EI(t())]:e}).flat(10)}function DI(e,t){let n=RD.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function OI(e){return typeof e==`function`}function kI(e,t=void 0,...n){return OI(e)?t?e.bind(t)(...n):e(...n):e}function AI(e={}){return Object.keys(e).length===0&&e.constructor===Object}function jI(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function MI(e){let t=[],{nodeExtensions:n,markExtensions:r}=jI(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=Q(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=Q(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function NI(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s<o;s+=1){let o=e[s];if(o===`'`&&!i){r=!r,n+=o;continue}if(o===`"`&&!r){i=!i,n+=o;continue}if(!r&&!i){if(o===`(`){a+=1,n+=o;continue}if(o===`)`&&a>0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}return n&&t.push(n),t}function PI(e){let t=[],n=NI(e||``),r=n.length;for(let e=0;e<r;e+=1){let r=n[e],i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();a&&o&&t.push([a,o])}return t}function FI(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...PI(n[e]),...PI(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function II(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>FI(e,t),{})}function LI(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function RI(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):LI(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function zI(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&AI(t)?!1:t!=null))}function BI(e){let t={};return!e?.attribute?.isRequired&&`default`in(e?.attribute||{})&&(t.default=e.attribute.default),e?.attribute?.validate!==void 0&&(t.validate=e.attribute.validate),[e.name,t]}function VI(e,t){let n=MI(e),{nodeExtensions:r,markExtensions:i}=jI(e);return new bD({topNode:r.find(e=>Q(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=zI({...e.reduce((e,t)=>{let n=Q(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:kI(Q(r,`content`,a)),marks:kI(Q(r,`marks`,a)),group:kI(Q(r,`group`,a)),inline:kI(Q(r,`inline`,a)),atom:kI(Q(r,`atom`,a)),selectable:kI(Q(r,`selectable`,a)),draggable:kI(Q(r,`draggable`,a)),code:kI(Q(r,`code`,a)),whitespace:kI(Q(r,`whitespace`,a)),linebreakReplacement:kI(Q(r,`linebreakReplacement`,a)),defining:kI(Q(r,`defining`,a)),isolating:kI(Q(r,`isolating`,a)),attrs:Object.fromEntries(i.map(BI))}),s=kI(Q(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>RI(e,i)));let c=Q(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:II(e,i)}));let l=Q(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=zI({...e.reduce((e,t)=>{let n=Q(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:kI(Q(r,`inclusive`,a)),excludes:kI(Q(r,`excludes`,a)),group:kI(Q(r,`group`,a)),spanning:kI(Q(r,`spanning`,a)),code:kI(Q(r,`code`,a)),attrs:Object.fromEntries(i.map(BI))}),s=kI(Q(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>RI(e,i)));let c=Q(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:II(e,i)})),[r.name,o]}))})}function HI(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function UI(e){return e.sort((e,t)=>{let n=Q(e,`priority`)||100,r=Q(t,`priority`)||100;return n>r?-1:+(n<r)})}function WI(e){let t=UI(EI(e)),n=HI(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function GI(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
|
|
93
|
+
`),slice:t}}function DI(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new Y(J.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
94
|
+
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=Sj.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=BI(n),LP&&VI(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||cj.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!OI.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=HI(PI(s,+u[1],+u[2]),u[4]);else if(s=Y.maxOpen(kI(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=PI(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var OI=/^(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 kI(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&jI(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=MI(a[a.length-1],i.length));let n=AI(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return J.from(a)}return e}function AI(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,J.from(e));return e}function jI(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=jI(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(J.from(AI(n,e,i+1))))}}function MI(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,MI(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(J.empty,!0);return e.copy(n.append(r))}function NI(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=NI(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(J.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function PI(e,t,n){return t<e.openStart&&(e=new Y(NI(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new Y(NI(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var FI={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},II=null;function LI(){return II||=document.implementation.createHTMLDocument(`title`)}var RI=null;function zI(e){let t=window.trustedTypes;return t?(RI||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),RI.createHTML(e)):e}function BI(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=LI().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&FI[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=zI(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function VI(e){let t=e.querySelectorAll(AP?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function HI(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=J.from(t.create(r[e+1],i)),a++,o++}return new Y(i,a,o)}var UI={},WI={},GI={touchstart:!0,touchmove:!0},KI=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function qI(e){for(let t in UI){let n=UI[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{QI(e,t)&&!ZI(e,t)&&(e.editable||!(t.type in WI))&&n(e,t)},GI[t]?{passive:!0}:void 0)}MP&&e.dom.addEventListener(`input`,()=>null),XI(e)}function JI(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function YI(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function XI(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ZI(e,t))})}function ZI(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function QI(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function $I(e,t){!ZI(e,t)&&UI[t.type]&&(e.editable||!(t.type in WI))&&UI[t.type](e,t)}WI.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!pL(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(IP&&AP&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),NP&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,_P(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||TI(e,n)?n.preventDefault():JI(e,`key`)},WI.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},WI.keypress=(e,t)=>{let n=t;if(pL(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||PP&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof X)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function eL(e){return{left:e.clientX,top:e.clientY}}function tL(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function nL(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function rL(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function iL(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Z.isSelectable(r)?(rL(e,new Z(n),`pointer`),!0):!1}function aL(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Z&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Z.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(rL(e,Z.create(e.state.doc,i),`pointer`),!0)}function oL(e,t,n,r,i){return nL(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?aL(e,n):iL(e,n))}function sL(e,t,n,r){return nL(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function cL(e,t,n,r){return nL(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||lL(e,n,r)}function lL(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(rL(e,X.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)rL(e,X.create(r,a+1,a+1+n.content.size),`pointer`);else if(Z.isSelectable(n))rL(e,Z.create(r,a),`pointer`);else continue;return!0}}function uL(e){return bL(e)}var dL=PP?`metaKey`:`ctrlKey`;UI.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=uL(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&tL(n,e.input.lastClick)&&!n[dL]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(eL(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new fL(e,o,n,!!r)):(a==`doubleClick`?sL:cL)(e,o.pos,o.inside,n)?n.preventDefault():JI(e,`pointer`))};var fL=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[dL],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Z&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&OP&&!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)),JI(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(()=>JF(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(eL(e))),this.updateAllowDefault(e),this.allowDefault||!t?JI(this.view,`pointer`):oL(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||MP&&this.mightDrag&&!this.mightDrag.node.isAtom||AP&&!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)?(rL(this.view,UM.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):JI(this.view,`pointer`)}move(e){this.updateAllowDefault(e),JI(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)}};UI.touchstart=e=>{e.input.lastTouch=Date.now(),uL(e),JI(e,`pointer`)},UI.touchmove=e=>{e.input.lastTouch=Date.now(),JI(e,`pointer`)},UI.contextmenu=e=>uL(e);function pL(e,t){return e.composing?!0:MP&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var mL=IP?5e3:-1;WI.compositionstart=WI.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof X&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||AP&&FP&&hL(e)))e.markCursor=e.state.storedMarks||n.marks(),bL(e,!0),e.markCursor=null;else if(bL(e,!t.selection.empty),OP&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}gL(e,mL)};function hL(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}WI.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,gL(e,20))};function gL(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>bL(e),t))}function _L(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=yL());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function vL(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=fP(t.focusNode,t.focusOffset),r=pP(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function yL(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function bL(e,t=!1){if(!(IP&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),_L(e),t||e.docView&&e.docView.dirty){let n=KF(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function xL(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var SL=EP&&DP<15||NP&&RP<604;UI.copy=WI.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=SL?null:n.clipboardData,{dom:o,text:s}=EI(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):xL(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function CL(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function wL(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?TL(e,r.value,null,i,t):TL(e,r.textContent,r.innerHTML,i,t)},50)}function TL(e,t,n,r,i){let a=DI(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||Y.empty)))return!0;if(!a)return!1;let o=CL(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function EL(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}WI.paste=(e,t)=>{let n=t;if(e.composing&&!IP)return;let r=SL?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&TL(e,EL(r),r.getData(`text/html`),i,n)?n.preventDefault():wL(e,n)};var DL=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},OL=PP?`altKey`:`ctrlKey`;function kL(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[OL]:!n}UI.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(eL(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Z?i.to-1:i.to))){if(r&&r.mightDrag)o=Z.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Z.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=EI(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!AP||jP>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(SL?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,SL||n.dataTransfer.setData(`text/plain`,c),e.dragging=new DL(l,kL(e,n),o)},UI.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},WI.dragover=WI.dragenter=(e,t)=>t.preventDefault(),WI.drop=(e,t)=>{try{AL(e,t,e.dragging)}finally{e.dragging=null}};function AL(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(eL(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=DI(e,EL(t.dataTransfer),SL?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&kL(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||Y.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?SM(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Z.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Z(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(rI(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}UI.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&JF(e)},20))},UI.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},UI.beforeinput=(e,t)=>{if(AP&&IP&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,_P(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in WI)UI[e]=WI[e];function jL(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ML=class e{constructor(e,t){this.toDOM=e,this.spec=t||LL,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new FL(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&jL(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},NL=class e{constructor(e,t){this.attrs=e,this.spec=t||LL}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new FL(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&jL(this.attrs,t.attrs)&&jL(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},PL=class e{constructor(e,t){this.attrs=e,this.spec=t||LL}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new FL(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&jL(this.attrs,t.attrs)&&jL(this.spec,t.spec)}destroy(){}},FL=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new ML(n,r))}static inline(t,n,r,i){return new e(t,n,new NL(r,i))}static node(t,n,r,i){return new e(t,n,new PL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof NL}get widget(){return this.type instanceof ML}},IL=[],LL={},RL=class e{constructor(e,t){this.local=e.length?e:IL,this.children=t.length?t:IL}static create(e,t){return t.length?KL(t,e,0,LL):zL}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==zL||e.maps.length==0?this:this.mapInner(e,t,0,0,n||LL)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?VL(this.children,o||[],t,n,r,i,a):o?new e(o.sort(qL),IL):zL}add(t,n){return n.length?this==zL?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=WL(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,KL(s,e,o+1,LL)),a+=3}});let o=HL(a?GL(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(qL):this.local,i||this.children)}remove(e){return e.length==0||this==zL?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==zL?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):zL}forChild(t,n){if(this==zL)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof NL){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(qL),IL);return r?new BL([t,r]):t}return r||zL}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return JL(this.localsInner(e))}localsInner(e){if(this==zL)return IL;if(e.inlineContent||!this.local.some(NL.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof NL||t.push(this.local[e]);return t}forEachSet(e){e(this)}};RL.empty=new RL([],[]),RL.removeOverlap=JL;var zL=RL.empty,BL=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,LL));return e.from(r)}forChild(t,n){if(n.isLeaf)return RL.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=zL&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?JL(n?t:t.sort(qL)):IL}static from(t){switch(t.length){case 0:return zL;case 1:return t[0];default:return new e(t.every(e=>e instanceof RL)?t:t.reduce((e,t)=>e.concat(t instanceof RL?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function VL(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==zL?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=KL(UL(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new RL(t.sort(qL),s)}function HL(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new FL(i.from+t,i.to+t,i.type))}return n}function UL(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function WL(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function GL(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function KL(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=WL(e,t,o+n);if(s){a=!0;let e=KL(s,t,n+o+1,r);e!=zL&&i.push(o,o+t.nodeSize,e)}});let o=HL(a?GL(e):e,-n).sort(qL);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new RL(o,i):zL}function qL(e,t){return e.from-t.from||e.to-t.to}function JL(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),YL(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),YL(t,i,r.copy(a.from,r.to)));break}}}return t}function YL(e,t,n){for(;t<e.length&&qL(n,e[t])>0;)t++;e.splice(t,0,n)}function XL(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=zL&&t.push(r)}),e.cursorWrapper&&t.push(RL.create(e.state.doc,[e.cursorWrapper.deco])),BL.from(t)}var ZL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},QL=EP&&DP<=11,$L=class{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}},eR=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $L,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);EP&&DP<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():MP&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),QL&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ZL)),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(iI(this.view)){if(this.suppressingSelectionUpdates)return JF(this.view);if(EP&&DP<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&cP(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,n;for(let n=e.focusNode;n;n=iP(n))t.add(n);for(let r=e.anchorNode;r;r=iP(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))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 n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&iI(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(OP&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||oR(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&gP(n)&&(c=KF(e))&&c.eq(UM.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,JF(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),rR(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,sR(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||JF(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(EP&&DP<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?rP(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?rP(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},tR=new WeakMap,nR=!1;function rR(e){if(!tR.has(e)&&(tR.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=OP,nR)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.`),nR=!0}}function iR(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return cP(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function aR(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return iR(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?iR(e,n):null}function oR(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function sR(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function cR(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],gP(c)||l.push({node:c.focusNode,offset:c.focusOffset})),AP&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||cj.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:lR,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function lR(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(MP&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||MP&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var uR=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function dR(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=KF(e,t);if(n&&!e.state.selection.eq(n)){if(AP&&IP&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,_P(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=cR(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=gR(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(NP&&e.input.lastIOSEnter>Date.now()-225||IP)&&i.some(e=>e.nodeType==1&&!uR.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,_P(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof X&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=fR(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof X&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),EP&&DP<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((NP&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,_P(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&mR(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,_P(8,`Backspace`)))){IP&&AP&&e.domObserver.suppressSelectionUpdates();return}AP&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),IP&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,_P(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=fR(e,n.doc,l.sel);t&&!(AP&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||EP&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v)if(h.pos==g.pos){EP&&DP<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>JF(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=pR(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function fR(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:rI(e,t.resolve(n.anchor),t.resolve(n.head))}function pR(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(J.from(l).eq(e))return{mark:s,type:o}}function mR(e,t,n,r,i){if(n-t<=i.pos-r.pos||hR(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(hR(a,!0,!0));return!o.parent.isTextblock||o.pos>n||hR(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function hR(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function gR(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&_R(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&_R(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function _R(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var vR=class{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 KI,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(TR),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=xR(this),bR(this),this.nodeViews=CR(this),this.docView=EF(this.state.doc,yR(this),XL(this),this.dom,this),this.domObserver=new eR(this,(e,t,n,r)=>dR(this,e,t,n,r)),this.domObserver.start(),qI(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&&XI(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(TR),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(_L(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=CR(this);wR(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&XI(this),this.editable=xR(this),bR(this);let o=XL(this),s=yR(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&UP(this);if(i){this.domObserver.stop();let t=l&&(EP||AP)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&SR(n.selection,e.selection);if(l){let n=AP?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=vL(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=EF(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&oI(this))?JF(this,t):(tI(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&GP(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Z){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&HP(this,t.getBoundingClientRect(),e)}else HP(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 e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new DL(e.slice,e.move,r<0?void 0:Z.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(EP){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&&JP(this.dom),JF(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return nF(this,e)}coordsAtPos(e,t=1){return oF(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return gF(this,t||this.state,e)}pasteHTML(e,t){return TL(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return TL(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return EI(this,e)}destroy(){this.docView&&(YI(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],XL(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,sP())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $I(this,e)}domSelectionRange(){let e=this.domSelection();return e?MP&&this.root.nodeType===11&&vP(this.dom.ownerDocument)==this.dom&&aR(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};vR.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function yR(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[FL.node(0,e.state.doc.content.size,t)]}function bR(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:FL.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function xR(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function SR(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function CR(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function wR(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function TR(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var ER={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},DR={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},OR=typeof navigator<`u`&&/Mac/.test(navigator.platform),kR=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),AR=0;AR<10;AR++)ER[48+AR]=ER[96+AR]=String(AR);for(var AR=1;AR<=24;AR++)ER[AR+111]=`F`+AR;for(var AR=65;AR<=90;AR++)ER[AR]=String.fromCharCode(AR+32),DR[AR]=String.fromCharCode(AR);for(var jR in ER)DR.hasOwnProperty(jR)||(DR[jR]=ER[jR]);function MR(e){var t=!(OR&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||kR&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?DR:ER)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var NR=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),PR=typeof navigator<`u`&&/Win/.test(navigator.platform);function FR(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))NR?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function IR(e){let t=Object.create(null);for(let n in e)t[FR(n)]=e[n];return t}function LR(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function RR(e){return new lN({props:{handleKeyDown:zR(e)}})}function zR(e){let t=IR(e);return function(e,n){let r=MR(n),i,a=t[LR(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[LR(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(PR&&n.ctrlKey&&n.altKey)&&(i=ER[n.keyCode])&&i!=r){let r=t[LR(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var BR=Object.defineProperty,VR=(e,t)=>{for(var n in t)BR(e,n,{get:t[n],enumerable:!0})};function HR(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var UR=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:HR({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},WR={};VR(WR,{blur:()=>GR,clearContent:()=>KR,clearNodes:()=>qR,command:()=>JR,createParagraphNear:()=>YR,cut:()=>XR,deleteCurrentNode:()=>ZR,deleteNode:()=>$R,deleteRange:()=>ez,deleteSelection:()=>iz,enter:()=>az,exitCode:()=>oz,extendMarkRange:()=>pz,first:()=>mz,focus:()=>xz,forEach:()=>Sz,insertContent:()=>Cz,insertContentAt:()=>kz,joinBackward:()=>Mz,joinDown:()=>jz,joinForward:()=>Nz,joinItemBackward:()=>Pz,joinItemForward:()=>Fz,joinTextblockBackward:()=>Iz,joinTextblockForward:()=>Lz,joinUp:()=>Az,keyboardShortcut:()=>Bz,lift:()=>Hz,liftEmptyBlock:()=>Uz,liftListItem:()=>Wz,newlineInCode:()=>Gz,resetAttributes:()=>Jz,scrollIntoView:()=>Yz,selectAll:()=>Xz,selectNodeBackward:()=>Zz,selectNodeForward:()=>Qz,selectParentNode:()=>$z,selectTextblockEnd:()=>eB,selectTextblockStart:()=>tB,setContent:()=>rB,setMark:()=>eV,setMeta:()=>tV,setNode:()=>nV,setNodeSelection:()=>rV,setTextDirection:()=>iV,setTextSelection:()=>aV,sinkListItem:()=>oV,splitBlock:()=>cV,splitListItem:()=>lV,toggleList:()=>pV,toggleMark:()=>mV,toggleNode:()=>hV,toggleWrap:()=>gV,undoInputRule:()=>_V,unsetAllMarks:()=>vV,unsetMark:()=>yV,unsetTextDirection:()=>bV,updateAttributes:()=>xV,wrapIn:()=>SV,wrapInList:()=>CV});var GR=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),KR=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),qR=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=nM(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},JR=e=>t=>e(t),YR=()=>({state:e,dispatch:t})=>MN(e,t),XR=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new X(r.doc.resolve(Math.max(o-1,0)))),!0},ZR=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function QR(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var $R=e=>({tr:t,state:n,dispatch:r})=>{let i=QR(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},ez=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},tz=e=>e.content?/^text(\*|\+)/.test(e.content):!1,nz=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos<e.end())return e.pos;let r=t.nodes[e.parent.type.name].spec;return tz(r)?n===`left`?e.start()-1:e.end()+1:e.pos},rz=(e,t,n)=>({from:nz(e,n,`left`),to:nz(t,n,`right`)}),iz=()=>({state:e,dispatch:t})=>{let{$from:n,$to:r}=e.selection;if(e.selection.empty)return!1;let{from:i,to:a}=rz(n,r,e.schema);return t&&(e.tr.deleteRange(i,a).scrollIntoView(),t(e.tr)),!0},az=()=>({commands:e})=>e.keyboardShortcut(`Enter`),oz=()=>({state:e,dispatch:t})=>jN(e,t);function sz(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function cz(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:sz(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function lz(e,t,n={}){return e.find(e=>e.type===t&&cz(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function uz(e,t,n={}){return!!lz(e,t,n)}function dz(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!lz([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&uz([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o<e.parent.childCount&&uz([...e.parent.child(o).marks],t,n);)s+=e.parent.child(o).nodeSize,o+=1;return{from:a,to:s}}function fz(e,t){if(typeof e==`string`){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}var pz=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=fz(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=dz(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=X.create(o,e.from,e.to);n.setSelection(t)}}return!0},mz=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e<n.length;e+=1)if(n[e](t))return!0;return!1};function hz(e){return e instanceof X}function gz(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function _z(e,t=null){if(!t)return null;let n=UM.atStart(e),r=UM.atEnd(e);if(t===`start`||t===!0)return n;if(t===`end`)return r;let i=n.from,a=r.to;return t===`all`?X.create(e,gz(0,i,a),gz(e.content.size,i,a)):X.create(e,gz(t,i,a),gz(t,i,a))}function vz(){return navigator.platform===`Android`||/android/i.test(navigator.userAgent)}function yz(){return[`iPad Simulator`,`iPhone Simulator`,`iPod Simulator`,`iPad`,`iPhone`,`iPod`].includes(navigator.platform)||navigator.userAgent.includes(`Mac`)&&`ontouchend`in document}function bz(){return typeof navigator<`u`?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var xz=(e=null,t={})=>({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(yz()||vz())&&r.dom.focus(),bz()&&!yz()&&!vz()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!hz(n.state.selection))return o(),!0;let s=_z(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Sz=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),Cz=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),wz=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&wz(r)}return e};function Tz(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return wz(n)}function Ez(e,t,n){if(e instanceof NA||e instanceof J)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return J.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),Ez(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new ij({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?cj.fromSchema(a).parseSlice(Tz(e),n.parseOptions):cj.fromSchema(a).parse(Tz(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=cj.fromSchema(t);return n.slice?r.parseSlice(Tz(e),n.parseOptions).content:r.parse(Tz(e),n.parseOptions)}return Ez(``,t,n)}function Dz(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof Yj||i instanceof Xj))return;let a=e.mapping.maps[r],o=0;a.forEach((e,t,n,r)=>{o===0&&(o=r)}),e.setSelection(UM.near(e.doc.resolve(o),n))}var Oz=e=>!(`type`in e),kz=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Ez(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=Ez(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((Oz(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof J){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else{f=i;let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,a=t.isText||t.isTextblock,o=t.content.size>0;n&&a&&o&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&Dz(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},Az=()=>({state:e,dispatch:t})=>EN(e,t),jz=()=>({state:e,dispatch:t})=>DN(e,t),Mz=()=>({state:e,dispatch:t})=>hN(e,t),Nz=()=>({state:e,dispatch:t})=>CN(e,t),Pz=()=>({state:e,dispatch:t,tr:n})=>{try{let r=yM(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Fz=()=>({state:e,dispatch:t,tr:n})=>{try{let r=yM(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Iz=()=>({state:e,dispatch:t})=>gN(e,t),Lz=()=>({state:e,dispatch:t})=>_N(e,t);function Rz(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function zz(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e+=1){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))yz()||Rz()?o=!0:i=!0;else throw Error(`Unrecognized modifier name: ${n}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var Bz=e=>({editor:t,view:n,tr:r,dispatch:i})=>{let a=zz(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Vz(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?QR(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>cz(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Hz=(e,t={})=>({state:n,dispatch:r})=>Vz(n,QR(e,n.schema),t)?ON(n,r):!1,Uz=()=>({state:e,dispatch:t})=>NN(e,t),Wz=e=>({state:t,dispatch:n})=>$N(QR(e,t.schema))(t,n),Gz=()=>({state:e,dispatch:t})=>kN(e,t);function Kz(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function qz(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Jz=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Kz(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=QR(e,r.schema)),s===`mark`&&(o=fz(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,qz(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(qz(a.attrs,t))))})})}),c},Yz=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Xz=()=>({tr:e,dispatch:t})=>{if(t){let t=new YM(e.doc);e.setSelection(t)}return!0},Zz=()=>({state:e,dispatch:t})=>bN(e,t),Qz=()=>({state:e,dispatch:t})=>wN(e,t),$z=()=>({state:e,dispatch:t})=>IN(e,t),eB=()=>({state:e,dispatch:t})=>HN(e,t),tB=()=>({state:e,dispatch:t})=>VN(e,t);function nB(e,t,n={},r={}){return Ez(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var rB=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=nB(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!n),!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function iB(e,t){let n=fz(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function aB(e,t){let n=new VM(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function oB(e){for(let t=0;t<e.edgeCount;t+=1){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function sB(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function cB(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function lB(e){return t=>cB(t.$from,e)}function Q(e,t,n){return e.config[t]===void 0&&e.parent?Q(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?Q(e.parent,t,n):null}):e.config[t]}function uB(e){return e.map(e=>{let t=Q(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...uB(t())]:e}).flat(10)}function dB(e,t){let n=Sj.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function fB(e){return typeof e==`function`}function pB(e,t=void 0,...n){return fB(e)?t?e.bind(t)(...n):e(...n):e}function mB(e={}){return Object.keys(e).length===0&&e.constructor===Object}function hB(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function gB(e){let t=[],{nodeExtensions:n,markExtensions:r}=hB(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=Q(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=Q(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function _B(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s<o;s+=1){let o=e[s];if(o===`'`&&!i){r=!r,n+=o;continue}if(o===`"`&&!r){i=!i,n+=o;continue}if(!r&&!i){if(o===`(`){a+=1,n+=o;continue}if(o===`)`&&a>0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}return n&&t.push(n),t}function vB(e){let t=[],n=_B(e||``),r=n.length;for(let e=0;e<r;e+=1){let r=n[e],i=r.indexOf(`:`);if(i===-1)continue;let a=r.slice(0,i).trim(),o=r.slice(i+1).trim();a&&o&&t.push([a,o])}return t}function yB(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...vB(n[e]),...vB(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function bB(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>yB(e,t),{})}function xB(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function SB(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):xB(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function CB(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&mB(t)?!1:t!=null))}function wB(e){let t={};return!e?.attribute?.isRequired&&`default`in(e?.attribute||{})&&(t.default=e.attribute.default),e?.attribute?.validate!==void 0&&(t.validate=e.attribute.validate),[e.name,t]}function TB(e,t){let n=gB(e),{nodeExtensions:r,markExtensions:i}=hB(e);return new ij({topNode:r.find(e=>Q(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=CB({...e.reduce((e,t)=>{let n=Q(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:pB(Q(r,`content`,a)),marks:pB(Q(r,`marks`,a)),group:pB(Q(r,`group`,a)),inline:pB(Q(r,`inline`,a)),atom:pB(Q(r,`atom`,a)),selectable:pB(Q(r,`selectable`,a)),draggable:pB(Q(r,`draggable`,a)),code:pB(Q(r,`code`,a)),whitespace:pB(Q(r,`whitespace`,a)),linebreakReplacement:pB(Q(r,`linebreakReplacement`,a)),defining:pB(Q(r,`defining`,a)),isolating:pB(Q(r,`isolating`,a)),attrs:Object.fromEntries(i.map(wB))}),s=pB(Q(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>SB(e,i)));let c=Q(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:bB(e,i)}));let l=Q(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=CB({...e.reduce((e,t)=>{let n=Q(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:pB(Q(r,`inclusive`,a)),excludes:pB(Q(r,`excludes`,a)),group:pB(Q(r,`group`,a)),spanning:pB(Q(r,`spanning`,a)),code:pB(Q(r,`code`,a)),attrs:Object.fromEntries(i.map(wB))}),s=pB(Q(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>SB(e,i)));let c=Q(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:bB(e,i)})),[r.name,o]}))})}function EB(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function DB(e){return e.sort((e,t)=>{let n=Q(e,`priority`)||100,r=Q(t,`priority`)||100;return n>r?-1:+(n<r)})}function OB(e){let t=DB(uB(e)),n=EB(t.map(e=>e.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function kB(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=`
|
|
95
95
|
|
|
96
|
-
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function KI(e,t){return GI(e,{from:0,to:e.content.size},t)}function qI(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function JI(e,t){let n=mF(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function YI(e,t){let n=cI(typeof t==`string`?t:t.name,e.schema);return n===`node`?JI(e,t):n===`mark`?bI(e,t):{}}function XI(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function ZI(e){let t=XI(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function QI(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),ZI(r)}function $I(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=DF(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var eL=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]};function tL(e,t){return t.nodes[e]||t.marks[e]||null}function nL(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var rL=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function iL(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?OF(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>wF(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>wF(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function aL(e,t,n={}){if(!t)return rI(e,null,n)||iL(e,null,n);let r=cI(t,e.schema);return r===`node`?rI(e,t,n):r===`mark`?iL(e,t,n):!1}var oL=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=TI(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},sL=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function cL(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function lL(e,t){let{nodeExtensions:n}=jI(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=kI(Q(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function uL(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(uL(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function dL(e){return e instanceof Z}var fL=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function pL(e,t){let n=t.mapping.mapResult(e.position);return{position:new fL(n.pos),mapResult:n}}function mL(e){return new fL(e)}function hL(e,t,n){let{selection:r}=t,i=null;if(jF(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var gL=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=OF(e,r.schema);if(i)if(o){let e=bI(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return hL(r,n,c)},_L=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),vL=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=mF(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>oA(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>oA(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},yL=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=MF(e,0,n.content.size),i=Z.create(n,r);t.setSelection(i)}return!0},bL=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},xL=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=X.atStart(n).from,o=X.atEnd(n).to,s=MF(r,a,o),c=MF(i,a,o),l=X.create(n,s,c);t.setSelection(l)}return!0},SL=e=>({state:t,dispatch:n})=>vA(mF(e,t.schema))(t,n);function CL(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var wL=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=nL(l,s.node().type.name,s.node().attrs);if(a instanceof Z&&a.node.isBlock)return!s.parentOffset||!AO(o,s.pos)?!1:(r&&(e&&CL(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:SI(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=AO(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&AO(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof X&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&CL(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},TL=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=mF(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=J.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=J.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...nL(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(J.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new Y(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(X.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...nL(d,u.type.name,u.attrs),...t},m={...nL(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!AO(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},EL=(e,t)=>{let n=TI(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&MO(e.doc,n.pos)&&e.join(n.pos),!0},DL=(e,t)=>{let n=TI(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&MO(e.doc,r)&&e.join(r),!0};function OL(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return X.between(r,i)}var kL=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=mF(e,o.schema),m=mF(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=TI(e=>lL(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&lL(w.type.name,d)?{node:w,pos:0,depth:0}:null,E=x??T,D=!!x&&y.depth>=1&&y.depth-x.depth<=1,O=!!T;if((D||O)&&E){if(E.node.type===p)return S&&O?c().command(({tr:e,dispatch:t})=>{let n=OL(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(lL(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>EL(a,p)).command(()=>DL(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>EL(a,p)).command(()=>DL(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>EL(a,p)).command(()=>DL(a,p)).run()},AL=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=OF(e,r.schema);return iL(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},jL=(e,t,n={})=>({state:r,commands:i})=>{let a=mF(e,r.schema),o=mF(t,r.schema),s=rI(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},ML=(e,t={})=>({state:n,commands:r})=>{let i=mF(e,n.schema);return rI(n,i,t)?r.lift(i):r.wrapIn(i,t)},NL=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},PL=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},FL=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=OF(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=DF(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},IL=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},LL=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=cI(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=mF(e,r.schema)),s===`mark`&&(o=OF(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r<s&&a&&a===e.type&&(c=!0,f=Math.max(r,s),p=Math.min(r+e.nodeSize,l),u=r,d=e),r>=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},RL=(e,t={})=>({state:n,dispatch:r})=>aA(mF(e,n.schema),t)(n,r),zL=(e,t={})=>({state:n,dispatch:r})=>fA(mF(e,n.schema),t)(n,r),BL=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},VL=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},HL=(e,t)=>{if(CF(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function UL(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=rL(c)+i;return a.forEach(e=>{if(l)return;let a=HL(u,e.find);if(!a)return;let c=s.state.tr,d=iF({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new aF({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(e.undoable&&c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function WL(e){let{editor:t,rules:n}=e,r=new Tk({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:DI(J.from(e),a.schema);let{from:i}=s;UL({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return UL({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&UL({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?UL({editor:t,from:a.pos,to:a.pos,text:`
|
|
97
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function
|
|
96
|
+
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function AB(e,t){return kB(e,{from:0,to:e.content.size},t)}function jB(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function MB(e,t){let n=QR(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function NB(e,t){let n=Kz(typeof t==`string`?t:t.name,e.schema);return n===`node`?MB(e,t):n===`mark`?iB(e,t):{}}function PB(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function FB(e){let t=PB(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function IB(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),FB(r)}function LB(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=dz(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var RB=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]};function zB(e,t){return t.nodes[e]||t.marks[e]||null}function BB(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var VB=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function HB(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?fz(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>cz(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>cz(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function UB(e,t,n={}){if(!t)return Vz(e,null,n)||HB(e,null,n);let r=Kz(t,e.schema);return r===`node`?Vz(e,t,n):r===`mark`?HB(e,t,n):!1}var WB=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=lB(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},GB=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function KB(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function qB(e,t){let{nodeExtensions:n}=hB(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=pB(Q(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function JB(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(JB(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function YB(e){return e instanceof Z}var XB=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function ZB(e,t){let n=t.mapping.mapResult(e.position);return{position:new XB(n.pos),mapResult:n}}function QB(e){return new XB(e)}function $B(e,t,n){let{selection:r}=t,i=null;if(hz(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var eV=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=fz(e,r.schema);if(i)if(o){let e=iB(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return $B(r,n,c)},tV=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),nV=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=QR(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>WN(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>WN(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},rV=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=gz(e,0,n.content.size),i=Z.create(n,r);t.setSelection(i)}return!0},iV=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},aV=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=X.atStart(n).from,o=X.atEnd(n).to,s=gz(r,a,o),c=gz(i,a,o),l=X.create(n,s,c);t.setSelection(l)}return!0},oV=e=>({state:t,dispatch:n})=>nP(QR(e,t.schema))(t,n);function sV(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var cV=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=BB(l,s.node().type.name,s.node().attrs);if(a instanceof Z&&a.node.isBlock)return!s.parentOffset||!mM(o,s.pos)?!1:(r&&(e&&sV(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:oB(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=mM(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&mM(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof X&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&sV(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},lV=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=QR(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=J.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=J.from(s.node(t).copy(e));let i=s.indexAfter(-1)<s.node(-2).childCount?1:s.indexAfter(-2)<s.node(-3).childCount?2:3,a={...BB(d,s.node().type.name,s.node().attrs),...t},c=o.contentMatch.defaultType?.createAndFill(a)||void 0;e=e.append(J.from(o.createAndFill(null,c)||void 0));let l=s.before(s.depth-(r-1));n.replace(l,s.after(-i),new Y(e,4-r,0));let u=-1;n.doc.nodesBetween(l,n.doc.content.size,(e,t)=>{if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(X.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...BB(d,u.type.name,u.attrs),...t},m={...BB(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!mM(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},uV=(e,t)=>{let n=lB(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&gM(e.doc,n.pos)&&e.join(n.pos),!0},dV=(e,t)=>{let n=lB(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&gM(e.doc,r)&&e.join(r),!0};function fV(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return X.between(r,i)}var pV=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=QR(e,o.schema),m=QR(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=lB(e=>qB(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&qB(w.type.name,d)?{node:w,pos:0,depth:0}:null,E=x??T,D=!!x&&y.depth>=1&&y.depth-x.depth<=1,O=!!T;if((D||O)&&E){if(E.node.type===p)return S&&O?c().command(({tr:e,dispatch:t})=>{let n=fV(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(qB(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>uV(a,p)).command(()=>dV(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>uV(a,p)).command(()=>dV(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>uV(a,p)).command(()=>dV(a,p)).run()},mV=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=fz(e,r.schema);return HB(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},hV=(e,t,n={})=>({state:r,commands:i})=>{let a=QR(e,r.schema),o=QR(t,r.schema),s=Vz(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},gV=(e,t={})=>({state:n,commands:r})=>{let i=QR(e,n.schema);return Vz(n,i,t)?r.lift(i):r.wrapIn(i,t)},_V=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r<n.length;r+=1){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let t=e.tr,n=a.transform;for(let e=n.steps.length-1;e>=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},vV=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},yV=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=fz(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=dz(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},bV=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},xV=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Kz(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=QR(e,r.schema)),s===`mark`&&(o=fz(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r<s&&a&&a===e.type&&(c=!0,f=Math.max(r,s),p=Math.min(r+e.nodeSize,l),u=r,d=e),r>=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},SV=(e,t={})=>({state:n,dispatch:r})=>UN(QR(e,n.schema),t)(n,r),CV=(e,t={})=>({state:n,dispatch:r})=>XN(QR(e,n.schema),t)(n,r),wV=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},TV=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},EV=(e,t)=>{if(sz(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function DV(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=VB(c)+i;return a.forEach(e=>{if(l)return;let a=EV(u,e.find);if(!a)return;let c=s.state.tr,d=HR({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new UR({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(e.undoable&&c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function OV(e){let{editor:t,rules:n}=e,r=new lN({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:dB(J.from(e),a.schema);let{from:i}=s;DV({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return DV({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&DV({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?DV({editor:t,from:a.pos,to:a.pos,text:`
|
|
97
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function kV(e){return Object.prototype.toString.call(e).slice(8,-1)}function AV(e){return kV(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function jV(e,t){let n={...e};return AV(e)&&AV(t)&&Object.keys(t).forEach(r=>{AV(t[r])&&AV(e[r])?n[r]=jV(e[r],t[r]):n[r]=t[r]}),n}var MV=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...pB(Q(this,`addOptions`,{name:this.name}))}}get storage(){return{...pB(Q(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>jV(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},NV=class e extends MV{constructor(){super(...arguments),this.type=`mark`}static create(t={}){return new e(typeof t==`function`?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function PV(e){return typeof e==`number`}var FV=class{constructor(e){this.find=e.find,this.handler=e.handler}},IV=(e,t,n)=>{if(sz(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function LV(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new UR({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(e.type?.spec?.code||!(e.isText||e.isTextblock||e.isInline))return;let f=e.content?.size??e.nodeSize??0,p=Math.max(r,t),m=Math.min(i,t+f);p>=m||IV(e.isText?e.text||``:e.textBetween(p-t,m-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=p+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var RV=null,zV=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function BV(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!LV({editor:t,state:HR({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new lN({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(RV=t)},i=()=>{RV&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=RV;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:dB(J.from(t),r.schema);let{from:n}=d,i=n+t.length,a=zV(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!PV(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var VV=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=OB(e),this.schema=TB(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=Q(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:zB(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this;return DB([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:zB(t.name,this.schema)},r=[],i=Q(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&Q(t,`exitable`,n)&&(a.ArrowRight=()=>NV.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=RR(a);r.push(o);let s=Q(t,`addInputRules`,n);if(KB(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=OV({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=Q(t,`addPasteRules`,n);if(KB(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=BV({editor:e,rules:t});r.push(...n)}}let l=Q(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r})}get attributes(){return gB(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=hB(this.extensions);return Object.fromEntries(t.filter(e=>!!Q(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=Q(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:QR(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:bB(r,n)})]:[]}))}dispatchTransaction(e){let{editor:t}=this;return DB([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:zB(n.name,this.schema)},i=Q(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return DB([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:zB(n.name,this.schema)},i=Q(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=hB(this.extensions);return Object.fromEntries(t.filter(e=>!!Q(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=Q(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:fz(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=bB(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{bH(i,e,t)}})}]:[]}))}destroy(){this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:zB(e.name,this.schema)};e.type===`mark`&&((pB(Q(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(pB(Q(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=Q(e,`onBeforeCreate`,t),r=Q(e,`onCreate`,t),i=Q(e,`onUpdate`,t),a=Q(e,`onSelectionUpdate`,t),o=Q(e,`onTransaction`,t),s=Q(e,`onFocus`,t),c=Q(e,`onBlur`,t),l=Q(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};VV.resolve=OB,VV.sort=DB,VV.flatten=uB,VR({},{ClipboardTextSerializer:()=>UV,Commands:()=>WV,Delete:()=>GV,Drop:()=>KV,Editable:()=>qV,FocusEvents:()=>YV,Keymap:()=>XV,Paste:()=>ZV,Tabindex:()=>QV,TextDirection:()=>$V,focusEventsPluginKey:()=>JV});var HV=class e extends MV{constructor(){super(...arguments),this.type=`extension`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},UV=HV.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new lN({key:new fN(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=jB(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>kB(r,{from:e.pos,to:t.pos},s)).join(o??`
|
|
98
98
|
|
|
99
|
-
`)}}})]}}),
|
|
99
|
+
`)}}})]}}),WV=HV.create({name:`commands`,addCommands(){return{...WR}}}),GV=HV.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){let n=()=>{var n;if(((n=this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(n,e)??e.getMeta(`y-sync$`))return;let r=aB(e.before,[e,...t]);IB(r).forEach(t=>{r.mapping.mapResult(t.oldRange.from).deletedAfter&&r.mapping.mapResult(t.oldRange.to).deletedBefore&&r.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,i)=>{let a=i+n.nodeSize-2,o=t.oldRange.from<=i&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:i,to:a,newFrom:r.mapping.map(i),newTo:r.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:r})})});let i=r.mapping;r.steps.forEach((t,n)=>{if(t instanceof Kj){let a=i.slice(n).map(t.from,-1),o=i.slice(n).map(t.to),s=i.invert().map(a,-1),c=i.invert().map(o),l=a>0?r.doc.nodeAt(a-1)?.marks.some(e=>e.eq(t.mark)):!1,u=r.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:a,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:r})}})};this.editor.options.coreExtensionOptions?.delete?.async??!0?setTimeout(n,0):n()}}),KV=HV.create({name:`drop`,addProseMirrorPlugins(){return[new lN({key:new fN(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),qV=HV.create({name:`editable`,addProseMirrorPlugins(){return[new lN({key:new fN(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),JV=new fN(`focusEvents`),YV=HV.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new lN({key:JV,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),XV=HV.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:UM.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return yz()||Rz()?i:r},addProseMirrorPlugins(){return[new lN({key:new fN(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=UM.atStart(t.doc).from,l=UM.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!JB(n.doc))return;let u=n.tr,d=HR({state:n,transaction:u}),{commands:f}=new UR({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),ZV=HV.create({name:`paste`,addProseMirrorPlugins(){return[new lN({key:new fN(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),QV=HV.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new lN({key:new fN(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),$V=HV.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=hB(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new lN({key:new fN(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),eH=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r<n.length;r+=1){let i=n[r];if(e[i]!==t[i])break}}else n=r;r=r.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let r=[];if(!this.children||this.children.length===0)return r;let i=Object.keys(t);return this.children.forEach(a=>{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},tH=`.ProseMirror {
|
|
100
100
|
position: relative;
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -166,38 +166,38 @@ img.ProseMirror-separator {
|
|
|
166
166
|
|
|
167
167
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
168
168
|
display: block;
|
|
169
|
-
}`;function
|
|
169
|
+
}`;function nH(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var rH=class extends wV{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:ZB,createMappablePosition:QB},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc(),n=_z(t,this.options.autofocus);this.editorState=sN.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=nH(tH,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=fB(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[qV,UV.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),WV,YV,XV,QV.configure({value:this.options.coreExtensionOptions?.tabindex?.value}),KV,ZV,GV,$V.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new VV(e,this)}createCommandManager(){this.commandManager=new UR({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=nB(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=nB(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new vR(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return NB(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return UB(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return dB(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=`
|
|
170
170
|
|
|
171
|
-
`,textSerializers:n={}}=e||{};return KI(this.state.doc,{blockSeparator:t,textSerializers:{...qI(this.schema),...n}})}get isEmpty(){return uL(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText?t.nodeAfter:null;return new gR(t,this,!1,n)}get $doc(){return this.$pos(0)}};function bR(e){return new VL({find:e.find,handler:({state:t,range:n,match:r})=>{let i=kI(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if($I(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function xR(e){return new VL({find:e.find,handler:({state:t,range:n,match:r})=>{let i=kI(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function SR(e){return new VL({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=kI(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function CR(e){return new VL({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=kI(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&bO(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&MO(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var wR=e=>`touches`in e,TR=class{constructor(e){this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e?.options?.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type?(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0):!1}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,wR(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return r<this.minSize.width&&(r=this.minSize.width,i=r/this.aspectRatio),i<this.minSize.height&&(i=this.minSize.height,r=i*this.aspectRatio),this.maxSize?.width&&r>this.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};function ER(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Z){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}rF({},{createAtomBlockMarkdownSpec:()=>kR,createBlockMarkdownSpec:()=>AR,createInlineMarkdownSpec:()=>NR,parseAttributes:()=>DR,parseIndentedBlocks:()=>PR,renderNestedMarkdownContent:()=>FR,serializeAttributes:()=>OR});function DR(e){if(!e?.trim())return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(` `));let a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{let i=n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1]||`0`,10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,``).replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,``).replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,``).trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function OR(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e===`class`||e===`id`||(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function kR(e){let{nodeName:t,name:n,parseAttributes:r=DR,serializeAttributes:i=OR,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:s}=e,c=n||t,l=e=>{if(!s)return e;let t={};return s.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let r={...a,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${c}(?:\\s|$)`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,i){let a=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),s=e.match(a);if(!s)return;let l=r(s[1]||``);if(!o.find(e=>!(e in l)))return{type:t,raw:s[0],attributes:l}}},renderMarkdown:e=>{let t=i(l(e.attrs||{}));return`:::${c}${t?` {${t}}`:``} :::`}}}function AR(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=DR,serializeAttributes:a=OR,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m)if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m);return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=a(u(e.attrs||{}));return`:::${l}${n?` {${n}}`:``}
|
|
171
|
+
`,textSerializers:n={}}=e||{};return AB(this.state.doc,{blockSeparator:t,textSerializers:{...jB(this.schema),...n}})}get isEmpty(){return JB(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText?t.nodeAfter:null;return new eH(t,this,!1,n)}get $doc(){return this.$pos(0)}};function iH(e){return new TV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=pB(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(LB(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function aH(e){return new TV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=pB(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function oH(e){return new TV({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=pB(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function sH(e){return new TV({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=pB(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&iM(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&gM(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var cH=e=>`touches`in e,lH=class{constructor(e){this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e?.options?.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type?(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0):!1}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,cH(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return r<this.minSize.width&&(r=this.minSize.width,i=r/this.aspectRatio),i<this.minSize.height&&(i=this.minSize.height,r=i*this.aspectRatio),this.maxSize?.width&&r>this.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};function uH(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Z){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}VR({},{createAtomBlockMarkdownSpec:()=>pH,createBlockMarkdownSpec:()=>mH,createInlineMarkdownSpec:()=>_H,parseAttributes:()=>dH,parseIndentedBlocks:()=>vH,renderNestedMarkdownContent:()=>yH,serializeAttributes:()=>fH});function dH(e){if(!e?.trim())return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(` `));let a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{let i=n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1]||`0`,10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,``).replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,``).replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,``).trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function fH(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e===`class`||e===`id`||(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function pH(e){let{nodeName:t,name:n,parseAttributes:r=dH,serializeAttributes:i=fH,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:s}=e,c=n||t,l=e=>{if(!s)return e;let t={};return s.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let r={...a,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${c}(?:\\s|$)`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,i){let a=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),s=e.match(a);if(!s)return;let l=r(s[1]||``);if(!o.find(e=>!(e in l)))return{type:t,raw:s[0],attributes:l}}},renderMarkdown:e=>{let t=i(l(e.attrs||{}));return`:::${c}${t?` {${t}}`:``} :::`}}}function mH(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=dH,serializeAttributes:a=fH,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m)if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m);return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=a(u(e.attrs||{}));return`:::${l}${n?` {${n}}`:``}
|
|
172
172
|
|
|
173
173
|
${t.renderChildren(e.content||[],`
|
|
174
174
|
|
|
175
175
|
`)}
|
|
176
176
|
|
|
177
|
-
:::`}}}function
|
|
177
|
+
:::`}}}function hH(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i]=a||o,r=n.exec(e)}return t}function gH(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function _H(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=hH,serializeAttributes:a=gH,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=a(u(e.attrs||{})),i=n?` ${n}`:``;return s?`[${l}${i}]`:`[${l}${i}]${t}[/${l}]`}}}function vH(e,t,n){let r=e.split(`
|
|
178
178
|
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],c=e.match(t.itemPattern);if(!c){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}
|
|
179
179
|
`;continue}else return}let l=t.extractItemData(c),{indentLevel:u,mainContent:d}=l;a=`${a}${e}
|
|
180
180
|
`;let f=[d];for(o+=1;o<r.length;){let e=r[o];if(e.trim()===``){let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((r[o+1+t].match(/^(\s*)/)?.[1]?.length||0)>u){f.push(e),a=`${a}${e}
|
|
181
181
|
`,o+=1;continue}else break}if((e.match(/^(\s*)/)?.[1]?.length||0)>u)f.push(e),a=`${a}${e}
|
|
182
182
|
`,o+=1;else break}let p,m=f.slice(1);if(m.length>0){let e=m.map(e=>e.slice(u+s)).join(`
|
|
183
|
-
`);e.trim()&&(p=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let h=t.createToken(l,p);i.push(h)}if(i.length!==0)return{items:i,raw:a}}function
|
|
183
|
+
`);e.trim()&&(p=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let h=t.createToken(l,p);i.push(h)}if(i.length!==0)return{items:i,raw:a}}function yH(e,t,n,r){if(!e||!Array.isArray(e.content))return``;let i=typeof n==`function`?n(r):n,[a,...o]=e.content,s=`${i}${t.renderChildren([a])}`;return o&&o.length>0&&o.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=r.split(`
|
|
184
184
|
`).map(e=>e?t.indent(e):t.indent(``)).join(`
|
|
185
185
|
`);s+=e.type===`paragraph`?`
|
|
186
186
|
|
|
187
187
|
${n}`:`
|
|
188
|
-
${n}`}}),s}function IR(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var LR=class e extends JL{constructor(){super(...arguments),this.type=`node`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function RR(e){return new ZL({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=kI(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if($I(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var zR=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,BR=LR.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,FI(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);c.draggable=!1;let l=FI(this.options.HTMLAttributes,o);Object.entries(l).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),l.src!==null&&(c.src=l.src);let u=new TR({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility=`hidden`,d.style.pointerEvents=`none`,c.onload=()=>{d.style.visibility=``,d.style.pointerEvents=``},u}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[xR({find:zR,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),VR=gi(),{getOwnPropertyNames:HR,getOwnPropertySymbols:UR}=Object,{hasOwnProperty:WR}=Object.prototype;function GR(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function KR(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function qR(e){return e?.[Symbol.toStringTag]}function JR(e){return HR(e).concat(UR(e))}var YR=Object.hasOwn||((e,t)=>WR.call(e,t));function XR(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var ZR=`__v`,QR=`__o`,$R=`_owner`,{getOwnPropertyDescriptor:ez,keys:tz}=Object;function nz(e,t){return e.byteLength===t.byteLength&&hz(new Uint8Array(e),new Uint8Array(t))}function rz(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function iz(e,t){return e.byteLength===t.byteLength&&hz(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function az(e,t){return XR(e.getTime(),t.getTime())}function oz(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function sz(e,t){return e===t}function cz(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var lz=XR;function uz(e,t,n){let r=tz(e),i=r.length;if(tz(t).length!==i)return!1;for(;i-- >0;)if(!_z(e,t,n,r[i]))return!1;return!0}function dz(e,t,n){let r=JR(e),i=r.length;if(JR(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!_z(e,t,n,a)||(o=ez(e,a),s=ez(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function fz(e,t){return XR(e.valueOf(),t.valueOf())}function pz(e,t){return e.source===t.source&&e.flags===t.flags}function mz(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function hz(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function gz(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function _z(e,t,n,r){return(r===$R||r===QR||r===ZR)&&(e.$$typeof||t.$$typeof)?!0:YR(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var vz=`[object ArrayBuffer]`,yz=`[object Arguments]`,bz=`[object Boolean]`,xz=`[object DataView]`,Sz=`[object Date]`,Cz=`[object Error]`,wz=`[object Map]`,Tz=`[object Number]`,Ez=`[object Object]`,Dz=`[object RegExp]`,Oz=`[object Set]`,kz=`[object String]`,Az={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},jz=`[object URL]`,Mz=Object.prototype.toString;function Nz({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=Mz.call(h);if(b===Sz)return r(h,g,_);if(b===Dz)return u(h,g,_);if(b===wz)return o(h,g,_);if(b===Oz)return d(h,g,_);if(b===Ez)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===jz)return p(h,g,_);if(b===Cz)return i(h,g,_);if(b===yz)return c(h,g,_);if(Az[b])return f(h,g,_);if(b===vz)return e(h,g,_);if(b===xz)return n(h,g,_);if(b===bz||b===Tz||b===kz)return l(h,g,_);if(m){let e=m[b];if(!e){let t=qR(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function Pz({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:nz,areArraysEqual:n?dz:rz,areDataViewsEqual:iz,areDatesEqual:az,areErrorsEqual:oz,areFunctionsEqual:sz,areMapsEqual:n?GR(cz,dz):cz,areNumbersEqual:lz,areObjectsEqual:n?dz:uz,arePrimitiveWrappersEqual:fz,areRegExpsEqual:pz,areSetsEqual:n?GR(mz,dz):mz,areTypedArraysEqual:n?GR(hz,dz):hz,areUrlsEqual:gz,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=KR(r.areArraysEqual),t=KR(r.areMapsEqual),n=KR(r.areObjectsEqual),i=KR(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function Fz(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function Iz({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var Lz=Rz();Rz({strict:!0}),Rz({circular:!0}),Rz({circular:!0,strict:!0}),Rz({createInternalComparator:()=>XR}),Rz({strict:!0,createInternalComparator:()=>XR}),Rz({circular:!0,createInternalComparator:()=>XR}),Rz({circular:!0,createInternalComparator:()=>XR,strict:!0});function Rz(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=Nz(Pz(e));return Iz({circular:t,comparator:a,createState:r,equals:n?n(a):Fz(a),strict:i})}var zz=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},Bz=({contentComponent:e})=>{let t=(0,VR.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,H.jsx)(H.Fragment,{children:Object.values(t)})};function Vz(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:ki.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var Hz=class extends V.Component{constructor(e){super(e),this.editorContentRef=V.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=Vz(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:zz(t,this.editorContentRef),...n}),e?.contentComponent&&(0,H.jsx)(Bz,{contentComponent:e.contentComponent})]})}},Uz=(0,V.forwardRef)((e,t)=>{let n=V.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return V.createElement(Hz,{key:n,innerRef:t,...e})}),Wz=V.memo(Uz),Gz=typeof window<`u`?V.useLayoutEffect:V.useEffect,Kz=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function qz(e){let[t]=(0,V.useState)(()=>new Kz(e.editor)),n=(0,vi.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??Lz);return Gz(()=>t.watch(e.editor),[e.editor,t]),(0,V.useDebugValue)(n),n}var Jz=!1,Yz=typeof window>`u`,Xz=Yz||!!(typeof window<`u`&&window.next),Zz=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=e??!0;return Yz?(t&&Jz&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),t=!1):Xz&&e===void 0&&(t=!1,Jz&&console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.")),t?this.createEditor():null}createEditor(){return new yR({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length?e.extensions.every((e,n)=>e===t.extensions?.[n]):!1:e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Qz(e={},t=[]){let n=(0,V.useRef)(e);n.current=e;let[r]=(0,V.useState)(()=>new Zz(n)),i=(0,VR.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,V.useDebugValue)(i),(0,V.useEffect)(r.onRender(t)),qz({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var $z=(0,V.createContext)({editor:null});$z.Consumer;var eB=(0,V.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),tB=()=>(0,V.useContext)(eB);V.forwardRef((e,t)=>{let{onDragStart:n}=tB();return(0,H.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),V.createContext({markViewContentRef:()=>{}});var nB=(0,V.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});nB.displayName=`TiptapContext`;var rB=()=>(0,V.useContext)(nB);function iB({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,V.useMemo)(()=>({editor:r}),[r]),a=(0,V.useMemo)(()=>({editor:r}),[r]);return(0,H.jsx)($z.Provider,{value:a,children:(0,H.jsx)(nB.Provider,{value:i,children:n})})}iB.displayName=`Tiptap`;function aB({...e}){let{editor:t}=rB();return(0,H.jsx)(Wz,{editor:t,...e})}aB.displayName=`Tiptap.Content`,Object.assign(iB,{Content:aB});var oB=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]};function sB(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=sB(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function cB(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=cB(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var lB=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return sB(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return cB(this,e,t,n)}findIndex(e){if(e==0)return dB(0,e);if(e==this.size)return dB(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?dB(t+1,i):dB(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};lB.empty=new lB([],0);var uB={index:0,offset:0};function dB(e,t){return uB.index=e,uB.offset=t,uB}function fB(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!fB(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!fB(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var pB=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&fB(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 RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};pB.none=[];var mB=class extends Error{},hB=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=_B(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(gB(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(lB.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};hB.empty=new hB(lB.empty,0,0);function gB(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(gB(a.content,t-i-1,n-i-1)))}function _B(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=_B(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function vB(e,t,n){if(n.openStart>e.depth)throw new mB(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new mB(`Inconsistent open depths`);return yB(e,t,n,0)}function yB(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=yB(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return wB(a,EB(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return wB(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=DB(n,e);return wB(a,TB(e,i,o,t,r))}}function bB(e,t){if(!t.type.compatibleContent(e.type))throw new mB(`Cannot join `+t.type.name+` onto `+e.type.name)}function xB(e,t,n){let r=e.node(n);return bB(r,t.node(n)),r}function SB(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function CB(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(SB(e.nodeAfter,r),a++));for(let e=a;e<o;e++)SB(i.child(e),r);t&&t.depth==n&&t.textOffset&&SB(t.nodeBefore,r)}function wB(e,t){return e.type.checkContent(t),e.copy(t)}function TB(e,t,n,r,i){let a=e.depth>i&&xB(e,t,i+1),o=r.depth>i&&xB(n,r,i+1),s=[];return CB(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(bB(a,o),SB(wB(a,TB(e,t,n,r,i+1)),s)):(a&&SB(wB(a,EB(e,t,i+1)),s),CB(t,n,i,s),o&&SB(wB(o,EB(n,r,i+1)),s)),CB(r,null,i,s),new lB(s)}function EB(e,t,n){let r=[];return CB(null,e,n,r),e.depth>n&&SB(wB(xB(e,t,n+1),EB(e,t,n+1)),r),CB(t,null,n,r),new lB(r)}function DB(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(lB.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var OB=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return pB.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new MB(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=jB.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else jB.set(t,r=new kB);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%AB,i}},kB=class{constructor(){this.elts=[],this.i=0}},AB=12,jB=new WeakMap,MB=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},NB=Object.create(null),PB=class e{constructor(e,t,n,r=pB.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||lB.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&fB(this.attrs,t||e.defaultAttrs||NB)&&pB.sameSet(this.marks,n||pB.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return hB.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new hB(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return vB(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return OB.resolveCached(this,e)}resolveNoCache(e){return OB.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),FB(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=lB.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=pB.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!pB.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=lB.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};PB.prototype.text=void 0;function FB(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var IB=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new LB(t,n);if(r.next==null)return e.empty;let i=RB(r);r.next&&r.err(`Unexpected trailing text`);let a=JB(GB(i));return YB(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return lB.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
189
|
-
`)}};IB.empty=new IB(!0);var LB=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function RB(e){let t=[];do t.push(zB(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function zB(e){let t=[];do t.push(BB(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function BB(e){let t=WB(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=HB(e,t);else break;return t}function VB(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function HB(e,t){let n=VB(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:VB(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function UB(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function WB(e){if(e.eat(`(`)){let t=RB(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=UB(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function GB(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function KB(e,t){return t-e}function qB(e,t){let n=[];return r(t),n.sort(KB);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function JB(e){let t=Object.create(null);return n(qB(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);qB(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new IB(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(KB);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function YB(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}var XB=65535,ZB=2**16;function QB(e,t){return e+t*ZB}function $B(e){return e&XB}function eV(e){return(e-(e&XB))/ZB}var tV=1,nV=2,rV=4,iV=8,aV=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&iV)>0}get deletedBefore(){return(this.delInfo&(tV|rV))>0}get deletedAfter(){return(this.delInfo&(nV|rV))>0}get deletedAcross(){return(this.delInfo&rV)>0}},oV=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=$B(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+eV(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:QB(o/3,e-s),f=e==s?nV:e==u?tV:rV;return(t<0?e!=s:e!=u)&&(f|=iV),new aV(a,f,d)}r+=l-c}return n?e+r:new aV(e+r,0,null)}touches(e,t){let n=0,r=$B(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};oV.empty=new oV([]);var sV=Object.create(null),cV=class{getMap(){return oV.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=sV[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in sV)throw RangeError(`Duplicate use of step JSON ID `+e);return sV[e]=t,t.prototype.jsonID=e,t}},lV=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof mB)return e.fail(t.message);throw t}}};function uV(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(uV(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return lB.fromArray(r)}var dV=class e extends cV{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new hB(uV(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return lV.fromReplace(e,this.from,this.to,i)}invert(){return new fV(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};cV.jsonID(`addMark`,dV);var fV=class e extends cV{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new hB(uV(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return lV.fromReplace(e,this.from,this.to,n)}invert(){return new dV(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};cV.jsonID(`removeMark`,fV);var pV=class e extends cV{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return lV.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return lV.fromReplace(e,this.pos,this.pos+1,new hB(lB.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new mV(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};cV.jsonID(`addNodeMark`,pV);var mV=class e extends cV{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return lV.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return lV.fromReplace(e,this.pos,this.pos+1,new hB(lB.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new pV(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};cV.jsonID(`removeNodeMark`,mV);var hV=class e extends cV{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&_V(e,this.from,this.to)?lV.fail(`Structure replace would overwrite content`):lV.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new oV([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?hB.empty:new hB(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?hB.empty:new hB(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,hB.fromJSON(t,n.slice),!!n.structure)}};hV.MAP_BIAS=1,cV.jsonID(`replace`,hV);var gV=class e extends cV{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(_V(e,this.from,this.gapFrom)||_V(e,this.gapTo,this.to)))return lV.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return lV.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?lV.fromReplace(e,this.from,this.to,n):lV.fail(`Content does not fit in gap`)}getMap(){return new oV([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,hB.fromJSON(t,n.slice),n.insert,!!n.structure)}};cV.jsonID(`replaceAround`,gV);function _V(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}var vV=class e extends cV{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return lV.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return lV.fromReplace(e,this.pos,this.pos+1,new hB(lB.from(r),0,+!t.isLeaf))}getMap(){return oV.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};cV.jsonID(`attr`,vV);var yV=class e extends cV{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return lV.ok(n)}getMap(){return oV.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};cV.jsonID(`docAttr`,yV);var bV=class extends Error{};bV=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},bV.prototype=Object.create(Error.prototype),bV.prototype.constructor=bV,bV.prototype.name=`TransformError`;var xV=Object.create(null),SV=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new CV(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=hB.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?hB.empty:t),o==0&&NV(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),NV(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new EV(e):MV(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?MV(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):MV(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new AV(e.node(0))}static atStart(e){return MV(e,e,0,0,1)||new AV(e)}static atEnd(e){return MV(e,e,e.content.size,e.childCount,-1)||new AV(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=xV[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in xV)throw RangeError(`Duplicate use of selection JSON ID `+e);return xV[e]=t,t.prototype.jsonID=e,t}getBookmark(){return EV.between(this.$anchor,this.$head).getBookmark()}};SV.prototype.visible=!0;var CV=class{constructor(e,t){this.$from=e,this.$to=t}},wV=!1;function TV(e){!wV&&!e.parent.inlineContent&&(wV=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var EV=class e extends SV{constructor(e,t=e){TV(e),TV(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return SV.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=hB.empty){if(super.replace(e,t),t==hB.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new DV(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=SV.findFrom(n,r,!0)||SV.findFrom(n,-r,!0);if(e)n=e.$head;else return SV.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(SV.findFrom(t,-r,!0)||SV.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};SV.jsonID(`text`,EV);var DV=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return EV.between(e.resolve(this.anchor),e.resolve(this.head))}},OV=class e extends SV{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?SV.near(a):new e(a)}content(){return new hB(lB.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new kV(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};OV.prototype.visible=!1,SV.jsonID(`node`,OV);var kV=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new DV(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&OV.isSelectable(n)?new OV(t):SV.near(t)}},AV=class e extends SV{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=hB.empty){if(t==hB.empty){e.delete(0,e.doc.content.size);let t=SV.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return jV}};SV.jsonID(`all`,AV);var jV={map(){return this},resolve(e){return new AV(e)}};function MV(e,t,n,r,i,a=!1){if(t.inlineContent)return EV.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=MV(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&OV.isSelectable(r))return OV.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function NV(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof hV||i instanceof gV))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(SV.near(e.doc.resolve(o),n))}function PV(e,t){return!t||!e?e:e.bind(t)}var FV=class{constructor(e,t,n){this.name=e,this.init=PV(t.init,n),this.apply=PV(t.apply,n)}};new FV(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new FV(`selection`,{init(e,t){return e.selection||SV.atStart(t.doc)},apply(e){return e.selection}}),new FV(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new FV(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});var IV=(e,t)=>{let{state:n,view:r}=e,{selection:i}=n;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0)return!1;let o=a.depth-1,s=a.node(o),c=a.index(o);if(c===0)return!1;if(s.type===t)return e.commands.lift(t.name);let l=s.child(c-1);if(l.type!==t||!l.lastChild?.isTextblock)return!1;let u=a.before(),d=u-1-1,{tr:f}=n;return f.delete(u,a.after()).insert(d,a.parent.content),f.setSelection(EV.create(f.doc,d)),r.dispatch(f.scrollIntoView()),!0},LV=/^\s*>\s$/,RV=LR.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return oB(`blockquote`,{...FI(this.options.HTMLAttributes,e),children:oB(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
188
|
+
${n}`}}),s}function bH(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var xH=class e extends MV{constructor(){super(...arguments),this.type=`node`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function SH(e){return new FV({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=pB(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(LB(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var CH=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,wH=xH.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,yB(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);c.draggable=!1;let l=yB(this.options.HTMLAttributes,o);Object.entries(l).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),l.src!==null&&(c.src=l.src);let u=new lH({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility=`hidden`,d.style.pointerEvents=`none`,c.onload=()=>{d.style.visibility=``,d.style.pointerEvents=``},u}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[aH({find:CH,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),TH=gi(),{getOwnPropertyNames:EH,getOwnPropertySymbols:DH}=Object,{hasOwnProperty:OH}=Object.prototype;function kH(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function AH(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function jH(e){return e?.[Symbol.toStringTag]}function MH(e){return EH(e).concat(DH(e))}var NH=Object.hasOwn||((e,t)=>OH.call(e,t));function PH(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var FH=`__v`,IH=`__o`,LH=`_owner`,{getOwnPropertyDescriptor:RH,keys:zH}=Object;function BH(e,t){return e.byteLength===t.byteLength&&$H(new Uint8Array(e),new Uint8Array(t))}function VH(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function HH(e,t){return e.byteLength===t.byteLength&&$H(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function UH(e,t){return PH(e.getTime(),t.getTime())}function WH(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function GH(e,t){return e===t}function KH(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var qH=PH;function JH(e,t,n){let r=zH(e),i=r.length;if(zH(t).length!==i)return!1;for(;i-- >0;)if(!tU(e,t,n,r[i]))return!1;return!0}function YH(e,t,n){let r=MH(e),i=r.length;if(MH(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!tU(e,t,n,a)||(o=RH(e,a),s=RH(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function XH(e,t){return PH(e.valueOf(),t.valueOf())}function ZH(e,t){return e.source===t.source&&e.flags===t.flags}function QH(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function $H(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function eU(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function tU(e,t,n,r){return(r===LH||r===IH||r===FH)&&(e.$$typeof||t.$$typeof)?!0:NH(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var nU=`[object ArrayBuffer]`,rU=`[object Arguments]`,iU=`[object Boolean]`,aU=`[object DataView]`,oU=`[object Date]`,sU=`[object Error]`,cU=`[object Map]`,lU=`[object Number]`,uU=`[object Object]`,dU=`[object RegExp]`,fU=`[object Set]`,pU=`[object String]`,mU={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},hU=`[object URL]`,gU=Object.prototype.toString;function _U({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=gU.call(h);if(b===oU)return r(h,g,_);if(b===dU)return u(h,g,_);if(b===cU)return o(h,g,_);if(b===fU)return d(h,g,_);if(b===uU)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===hU)return p(h,g,_);if(b===sU)return i(h,g,_);if(b===rU)return c(h,g,_);if(mU[b])return f(h,g,_);if(b===nU)return e(h,g,_);if(b===aU)return n(h,g,_);if(b===iU||b===lU||b===pU)return l(h,g,_);if(m){let e=m[b];if(!e){let t=jH(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function vU({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:BH,areArraysEqual:n?YH:VH,areDataViewsEqual:HH,areDatesEqual:UH,areErrorsEqual:WH,areFunctionsEqual:GH,areMapsEqual:n?kH(KH,YH):KH,areNumbersEqual:qH,areObjectsEqual:n?YH:JH,arePrimitiveWrappersEqual:XH,areRegExpsEqual:ZH,areSetsEqual:n?kH(QH,YH):QH,areTypedArraysEqual:n?kH($H,YH):$H,areUrlsEqual:eU,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=AH(r.areArraysEqual),t=AH(r.areMapsEqual),n=AH(r.areObjectsEqual),i=AH(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function yU(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function bU({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var xU=SU();SU({strict:!0}),SU({circular:!0}),SU({circular:!0,strict:!0}),SU({createInternalComparator:()=>PH}),SU({strict:!0,createInternalComparator:()=>PH}),SU({circular:!0,createInternalComparator:()=>PH}),SU({circular:!0,createInternalComparator:()=>PH,strict:!0});function SU(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=_U(vU(e));return bU({circular:t,comparator:a,createState:r,equals:n?n(a):yU(a),strict:i})}var CU=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},wU=({contentComponent:e})=>{let t=(0,TH.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,H.jsx)(H.Fragment,{children:Object.values(t)})};function TU(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:ki.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var EU=class extends V.Component{constructor(e){super(e),this.editorContentRef=V.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=TU(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){let e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{ref:CU(t,this.editorContentRef),...n}),e?.contentComponent&&(0,H.jsx)(wU,{contentComponent:e.contentComponent})]})}},DU=(0,V.forwardRef)((e,t)=>{let n=V.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return V.createElement(EU,{key:n,innerRef:t,...e})}),OU=V.memo(DU),kU=typeof window<`u`?V.useLayoutEffect:V.useEffect,AU=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function jU(e){let[t]=(0,V.useState)(()=>new AU(e.editor)),n=(0,vi.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??xU);return kU(()=>t.watch(e.editor),[e.editor,t]),(0,V.useDebugValue)(n),n}var MU=!1,NU=typeof window>`u`,PU=NU||!!(typeof window<`u`&&window.next),FU=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){let e=this.options.current.immediatelyRender,t=e??!0;return NU?(t&&MU&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),t=!1):PU&&e===void 0&&(t=!1,MU&&console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.")),t?this.createEditor():null}createEditor(){return new rH({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length?e.extensions.every((e,n)=>e===t.extensions?.[n]):!1:e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function IU(e={},t=[]){let n=(0,V.useRef)(e);n.current=e;let[r]=(0,V.useState)(()=>new FU(n)),i=(0,TH.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,V.useDebugValue)(i),(0,V.useEffect)(r.onRender(t)),jU({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var LU=(0,V.createContext)({editor:null});LU.Consumer;var RU=(0,V.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),zU=()=>(0,V.useContext)(RU);V.forwardRef((e,t)=>{let{onDragStart:n}=zU();return(0,H.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),V.createContext({markViewContentRef:()=>{}});var BU=(0,V.createContext)({get editor(){throw Error(`useTiptap must be used within a <Tiptap> provider`)}});BU.displayName=`TiptapContext`;var VU=()=>(0,V.useContext)(BU);function HU({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,V.useMemo)(()=>({editor:r}),[r]),a=(0,V.useMemo)(()=>({editor:r}),[r]);return(0,H.jsx)(LU.Provider,{value:a,children:(0,H.jsx)(BU.Provider,{value:i,children:n})})}HU.displayName=`Tiptap`;function UU({...e}){let{editor:t}=VU();return(0,H.jsx)(OU,{editor:t,...e})}UU.displayName=`Tiptap.Content`,Object.assign(HU,{Content:UU});var WU=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]};function GU(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=GU(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function KU(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=KU(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var qU=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return GU(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return KU(this,e,t,n)}findIndex(e){if(e==0)return YU(0,e);if(e==this.size)return YU(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?YU(t+1,i):YU(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};qU.empty=new qU([],0);var JU={index:0,offset:0};function YU(e,t){return JU.index=e,JU.offset=t,JU}function XU(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!XU(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!XU(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var ZU=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&XU(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 RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ZU.none=[];var QU=class extends Error{},$U=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=tW(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(eW(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(qU.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};$U.empty=new $U(qU.empty,0,0);function eW(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(eW(a.content,t-i-1,n-i-1)))}function tW(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=tW(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function nW(e,t,n){if(n.openStart>e.depth)throw new QU(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new QU(`Inconsistent open depths`);return rW(e,t,n,0)}function rW(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=rW(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return cW(a,uW(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return cW(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=dW(n,e);return cW(a,lW(e,i,o,t,r))}}function iW(e,t){if(!t.type.compatibleContent(e.type))throw new QU(`Cannot join `+t.type.name+` onto `+e.type.name)}function aW(e,t,n){let r=e.node(n);return iW(r,t.node(n)),r}function oW(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function sW(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(oW(e.nodeAfter,r),a++));for(let e=a;e<o;e++)oW(i.child(e),r);t&&t.depth==n&&t.textOffset&&oW(t.nodeBefore,r)}function cW(e,t){return e.type.checkContent(t),e.copy(t)}function lW(e,t,n,r,i){let a=e.depth>i&&aW(e,t,i+1),o=r.depth>i&&aW(n,r,i+1),s=[];return sW(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(iW(a,o),oW(cW(a,lW(e,t,n,r,i+1)),s)):(a&&oW(cW(a,uW(e,t,i+1)),s),sW(t,n,i,s),o&&oW(cW(o,uW(n,r,i+1)),s)),sW(r,null,i,s),new qU(s)}function uW(e,t,n){let r=[];return sW(null,e,n,r),e.depth>n&&oW(cW(aW(e,t,n+1),uW(e,t,n+1)),r),sW(t,null,n,r),new qU(r)}function dW(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(qU.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var fW=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ZU.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new gW(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=hW.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else hW.set(t,r=new pW);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%mW,i}},pW=class{constructor(){this.elts=[],this.i=0}},mW=12,hW=new WeakMap,gW=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},_W=Object.create(null),vW=class e{constructor(e,t,n,r=ZU.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||qU.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&XU(this.attrs,t||e.defaultAttrs||_W)&&ZU.sameSet(this.marks,n||ZU.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return $U.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new $U(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return nW(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return fW.resolveCached(this,e)}resolveNoCache(e){return fW.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),yW(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=qU.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ZU.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ZU.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=qU.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};vW.prototype.text=void 0;function yW(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var bW=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new xW(t,n);if(r.next==null)return e.empty;let i=SW(r);r.next&&r.err(`Unexpected trailing text`);let a=MW(kW(i));return NW(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return qU.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
189
|
+
`)}};bW.empty=new bW(!0);var xW=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function SW(e){let t=[];do t.push(CW(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function CW(e){let t=[];do t.push(wW(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function wW(e){let t=OW(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=EW(e,t);else break;return t}function TW(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function EW(e,t){let n=TW(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:TW(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function DW(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function OW(e){if(e.eat(`(`)){let t=SW(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=DW(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function kW(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function AW(e,t){return t-e}function jW(e,t){let n=[];return r(t),n.sort(AW);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function MW(e){let t=Object.create(null);return n(jW(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);jW(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new bW(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(AW);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function NW(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}var PW=65535,FW=2**16;function IW(e,t){return e+t*FW}function LW(e){return e&PW}function RW(e){return(e-(e&PW))/FW}var zW=1,BW=2,VW=4,HW=8,UW=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&HW)>0}get deletedBefore(){return(this.delInfo&(zW|VW))>0}get deletedAfter(){return(this.delInfo&(BW|VW))>0}get deletedAcross(){return(this.delInfo&VW)>0}},WW=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=LW(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+RW(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:IW(o/3,e-s),f=e==s?BW:e==u?zW:VW;return(t<0?e!=s:e!=u)&&(f|=HW),new UW(a,f,d)}r+=l-c}return n?e+r:new UW(e+r,0,null)}touches(e,t){let n=0,r=LW(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};WW.empty=new WW([]);var GW=Object.create(null),KW=class{getMap(){return WW.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=GW[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in GW)throw RangeError(`Duplicate use of step JSON ID `+e);return GW[e]=t,t.prototype.jsonID=e,t}},qW=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof QU)return e.fail(t.message);throw t}}};function JW(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(JW(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return qU.fromArray(r)}var YW=class e extends KW{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new $U(JW(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return qW.fromReplace(e,this.from,this.to,i)}invert(){return new XW(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};KW.jsonID(`addMark`,YW);var XW=class e extends KW{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new $U(JW(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return qW.fromReplace(e,this.from,this.to,n)}invert(){return new YW(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};KW.jsonID(`removeMark`,XW);var ZW=class e extends KW{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return qW.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return qW.fromReplace(e,this.pos,this.pos+1,new $U(qU.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new QW(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};KW.jsonID(`addNodeMark`,ZW);var QW=class e extends KW{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return qW.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return qW.fromReplace(e,this.pos,this.pos+1,new $U(qU.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new ZW(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};KW.jsonID(`removeNodeMark`,QW);var $W=class e extends KW{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&tG(e,this.from,this.to)?qW.fail(`Structure replace would overwrite content`):qW.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new WW([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?$U.empty:new $U(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?$U.empty:new $U(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,$U.fromJSON(t,n.slice),!!n.structure)}};$W.MAP_BIAS=1,KW.jsonID(`replace`,$W);var eG=class e extends KW{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(tG(e,this.from,this.gapFrom)||tG(e,this.gapTo,this.to)))return qW.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return qW.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?qW.fromReplace(e,this.from,this.to,n):qW.fail(`Content does not fit in gap`)}getMap(){return new WW([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,$U.fromJSON(t,n.slice),n.insert,!!n.structure)}};KW.jsonID(`replaceAround`,eG);function tG(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}var nG=class e extends KW{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return qW.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return qW.fromReplace(e,this.pos,this.pos+1,new $U(qU.from(r),0,+!t.isLeaf))}getMap(){return WW.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};KW.jsonID(`attr`,nG);var rG=class e extends KW{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return qW.ok(n)}getMap(){return WW.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};KW.jsonID(`docAttr`,rG);var iG=class extends Error{};iG=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},iG.prototype=Object.create(Error.prototype),iG.prototype.constructor=iG,iG.prototype.name=`TransformError`;var aG=Object.create(null),oG=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new sG(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=$U.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?$U.empty:t),o==0&&_G(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),_G(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new uG(e):gG(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?gG(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):gG(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new mG(e.node(0))}static atStart(e){return gG(e,e,0,0,1)||new mG(e)}static atEnd(e){return gG(e,e,e.content.size,e.childCount,-1)||new mG(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=aG[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in aG)throw RangeError(`Duplicate use of selection JSON ID `+e);return aG[e]=t,t.prototype.jsonID=e,t}getBookmark(){return uG.between(this.$anchor,this.$head).getBookmark()}};oG.prototype.visible=!0;var sG=class{constructor(e,t){this.$from=e,this.$to=t}},cG=!1;function lG(e){!cG&&!e.parent.inlineContent&&(cG=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var uG=class e extends oG{constructor(e,t=e){lG(e),lG(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return oG.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=$U.empty){if(super.replace(e,t),t==$U.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new dG(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=oG.findFrom(n,r,!0)||oG.findFrom(n,-r,!0);if(e)n=e.$head;else return oG.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(oG.findFrom(t,-r,!0)||oG.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};oG.jsonID(`text`,uG);var dG=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return uG.between(e.resolve(this.anchor),e.resolve(this.head))}},fG=class e extends oG{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?oG.near(a):new e(a)}content(){return new $U(qU.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new pG(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};fG.prototype.visible=!1,oG.jsonID(`node`,fG);var pG=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new dG(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&fG.isSelectable(n)?new fG(t):oG.near(t)}},mG=class e extends oG{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=$U.empty){if(t==$U.empty){e.delete(0,e.doc.content.size);let t=oG.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return hG}};oG.jsonID(`all`,mG);var hG={map(){return this},resolve(e){return new mG(e)}};function gG(e,t,n,r,i,a=!1){if(t.inlineContent)return uG.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=gG(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&fG.isSelectable(r))return fG.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function _G(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof $W||i instanceof eG))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(oG.near(e.doc.resolve(o),n))}function vG(e,t){return!t||!e?e:e.bind(t)}var yG=class{constructor(e,t,n){this.name=e,this.init=vG(t.init,n),this.apply=vG(t.apply,n)}};new yG(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new yG(`selection`,{init(e,t){return e.selection||oG.atStart(t.doc)},apply(e){return e.selection}}),new yG(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new yG(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});var bG=(e,t)=>{let{state:n,view:r}=e,{selection:i}=n;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0)return!1;let o=a.depth-1,s=a.node(o),c=a.index(o);if(c===0)return!1;if(s.type===t)return e.commands.lift(t.name);let l=s.child(c-1);if(l.type!==t||!l.lastChild?.isTextblock)return!1;let u=a.before(),d=u-1-1,{tr:f}=n;return f.delete(u,a.after()).insert(d,a.parent.content),f.setSelection(uG.create(f.doc,d)),r.dispatch(f.scrollIntoView()),!0},xG=/^\s*>\s$/,SG=xH.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return WU(`blockquote`,{...yB(this.options.HTMLAttributes,e),children:WU(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
|
|
190
190
|
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
|
|
191
191
|
`))}),n.join(`
|
|
192
192
|
>
|
|
193
|
-
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>
|
|
193
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>bG(this.editor,this.type)}},addInputRules(){return[sH({find:xG,type:this.type})]}}),CG=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,wG=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,TG=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,EG=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,DG=NV.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return WU(`strong`,{...yB(this.options.HTMLAttributes,e),children:WU(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[iH({find:CG,type:this.type}),iH({find:TG,type:this.type})]},addPasteRules(){return[SH({find:wG,type:this.type}),SH({find:EG,type:this.type})]}}),OG=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},kG=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},AG=NV.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,yB(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[iH({find:OG,type:this.type})]},addPasteRules(){return[SH({find:kG,type:this.type})]}}),jG=4,MG=/^```([a-z]+)?[\s\n]$/,NG=/^~~~([a-z]+)?[\s\n]$/,PG=xH.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:jG,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,yB(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
|
|
194
194
|
`):`\`\`\`${r}
|
|
195
195
|
|
|
196
|
-
\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??
|
|
196
|
+
\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??jG,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
|
|
197
197
|
`,`
|
|
198
198
|
`).split(`
|
|
199
199
|
`).map(e=>o+e).join(`
|
|
200
|
-
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??
|
|
200
|
+
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??jG,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
|
|
201
201
|
`,`
|
|
202
202
|
`).split(`
|
|
203
203
|
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(X.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
|
|
@@ -206,29 +206,29 @@ ${n}`}}),s}function IR(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants
|
|
|
206
206
|
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
|
|
207
207
|
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
208
208
|
|
|
209
|
-
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(
|
|
210
|
-
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(X.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),
|
|
209
|
+
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(UM.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[oH({find:MG,type:this.type,getAttributes:e=>({language:e[1]})}),oH({find:NG,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new lN({key:new fN(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
|
|
210
|
+
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(X.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),FG=xH.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
211
211
|
|
|
212
|
-
`):``}),
|
|
212
|
+
`):``}),IG=xH.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,yB(this.options.HTMLAttributes,e)]},renderText(){return`
|
|
213
213
|
`},renderMarkdown:()=>`
|
|
214
|
-
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),$V=LR.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,FI(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>SR({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),eH=LR.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,FI(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!ER(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return dL(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(X.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Z.create(t.doc,n.pos)):t.setSelection(X.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(X.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[xR({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),tH=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,nH=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,rH=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,iH=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,aH=YL.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,FI(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[bR({find:tH,type:this.type}),bR({find:rH,type:this.type})]},addPasteRules(){return[RR({find:nH,type:this.type}),RR({find:iH,type:this.type})]}}),oH=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,sH=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,cH=`numeric`,lH=`ascii`,uH=`alpha`,dH=`asciinumeric`,fH=`alphanumeric`,pH=`domain`,mH=`emoji`,hH=`scheme`,gH=`slashscheme`,_H=`whitespace`;function vH(e,t){return e in t||(t[e]=[]),t[e]}function yH(e,t,n){t[cH]&&(t[dH]=!0,t[fH]=!0),t[lH]&&(t[dH]=!0,t[uH]=!0),t[dH]&&(t[fH]=!0),t[uH]&&(t[fH]=!0),t[fH]&&(t[pH]=!0),t[mH]&&(t[pH]=!0);for(let r in t){let t=vH(r,n);t.indexOf(e)<0&&t.push(e)}}function bH(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function xH(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}xH.groups={},xH.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=xH.groups;let i;return t&&t.j?i=t:(i=new xH(t),n&&r&&yH(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=xH.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new xH,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new xH,a&&(r&&(o.t&&typeof o.t==`string`?yH(a,Object.assign(bH(o.t,r),n),r):n&&yH(a,n,r)),o.t=a),i.j[e]=o,o}};var SH=(e,t,n,r,i)=>e.ta(t,n,r,i),CH=(e,t,n,r,i)=>e.tr(t,n,r,i),wH=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),TH=`WORD`,EH=`UWORD`,DH=`ASCIINUMERICAL`,OH=`ALPHANUMERICAL`,kH=`LOCALHOST`,AH=`TLD`,jH=`UTLD`,MH=`SCHEME`,NH=`SLASH_SCHEME`,PH=`NUM`,FH=`WS`,IH=`NL`,LH=`OPENBRACE`,RH=`CLOSEBRACE`,zH=`OPENBRACKET`,BH=`CLOSEBRACKET`,VH=`OPENPAREN`,HH=`CLOSEPAREN`,UH=`OPENANGLEBRACKET`,WH=`CLOSEANGLEBRACKET`,GH=`FULLWIDTHLEFTPAREN`,KH=`FULLWIDTHRIGHTPAREN`,qH=`LEFTCORNERBRACKET`,JH=`RIGHTCORNERBRACKET`,YH=`LEFTWHITECORNERBRACKET`,XH=`RIGHTWHITECORNERBRACKET`,ZH=`FULLWIDTHLESSTHAN`,QH=`FULLWIDTHGREATERTHAN`,$H=`AMPERSAND`,eU=`APOSTROPHE`,tU=`ASTERISK`,nU=`AT`,rU=`BACKSLASH`,iU=`BACKTICK`,aU=`CARET`,oU=`COLON`,sU=`COMMA`,cU=`DOLLAR`,lU=`DOT`,uU=`EQUALS`,dU=`EXCLAMATION`,fU=`HYPHEN`,pU=`PERCENT`,mU=`PIPE`,hU=`PLUS`,gU=`POUND`,_U=`QUERY`,vU=`QUOTE`,yU=`FULLWIDTHMIDDLEDOT`,bU=`SEMI`,xU=`SLASH`,SU=`TILDE`,CU=`UNDERSCORE`,wU=`EMOJI`,TU=`SYM`,EU=Object.freeze({__proto__:null,ALPHANUMERICAL:OH,AMPERSAND:$H,APOSTROPHE:eU,ASCIINUMERICAL:DH,ASTERISK:tU,AT:nU,BACKSLASH:rU,BACKTICK:iU,CARET:aU,CLOSEANGLEBRACKET:WH,CLOSEBRACE:RH,CLOSEBRACKET:BH,CLOSEPAREN:HH,COLON:oU,COMMA:sU,DOLLAR:cU,DOT:lU,EMOJI:wU,EQUALS:uU,EXCLAMATION:dU,FULLWIDTHGREATERTHAN:QH,FULLWIDTHLEFTPAREN:GH,FULLWIDTHLESSTHAN:ZH,FULLWIDTHMIDDLEDOT:yU,FULLWIDTHRIGHTPAREN:KH,HYPHEN:fU,LEFTCORNERBRACKET:qH,LEFTWHITECORNERBRACKET:YH,LOCALHOST:kH,NL:IH,NUM:PH,OPENANGLEBRACKET:UH,OPENBRACE:LH,OPENBRACKET:zH,OPENPAREN:VH,PERCENT:pU,PIPE:mU,PLUS:hU,POUND:gU,QUERY:_U,QUOTE:vU,RIGHTCORNERBRACKET:JH,RIGHTWHITECORNERBRACKET:XH,SCHEME:MH,SEMI:bU,SLASH:xU,SLASH_SCHEME:NH,SYM:TU,TILDE:SU,TLD:AH,UNDERSCORE:CU,UTLD:jH,UWORD:EH,WORD:TH,WS:FH}),DU=/[a-z]/,OU=/\p{L}/u,kU=/\p{Emoji}/u,AU=/\d/,jU=/\s/,MU=`\r`,NU=`
|
|
215
|
-
`,
|
|
214
|
+
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),LG=xH.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,yB(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>oH({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),RG=xH.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,yB(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!uH(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return YB(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(X.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Z.create(t.doc,n.pos)):t.setSelection(X.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(X.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[aH({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),zG=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,BG=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,VG=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,HG=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,UG=NV.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,yB(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[iH({find:zG,type:this.type}),iH({find:VG,type:this.type})]},addPasteRules(){return[SH({find:BG,type:this.type}),SH({find:HG,type:this.type})]}}),WG=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,GG=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,KG=`numeric`,qG=`ascii`,JG=`alpha`,YG=`asciinumeric`,XG=`alphanumeric`,ZG=`domain`,QG=`emoji`,$G=`scheme`,eK=`slashscheme`,tK=`whitespace`;function nK(e,t){return e in t||(t[e]=[]),t[e]}function rK(e,t,n){t[KG]&&(t[YG]=!0,t[XG]=!0),t[qG]&&(t[YG]=!0,t[JG]=!0),t[YG]&&(t[XG]=!0),t[JG]&&(t[XG]=!0),t[XG]&&(t[ZG]=!0),t[QG]&&(t[ZG]=!0);for(let r in t){let t=nK(r,n);t.indexOf(e)<0&&t.push(e)}}function iK(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function aK(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}aK.groups={},aK.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;n<t.jr.length;n++){let r=t.jr[n][0],i=t.jr[n][1];if(i&&r.test(e))return i}return t.jd},has(e,t=!1){return t?e in this.j:!!this.go(e)},ta(e,t,n,r){for(let i=0;i<e.length;i++)this.tt(e[i],t,n,r)},tr(e,t,n,r){r||=aK.groups;let i;return t&&t.j?i=t:(i=new aK(t),n&&r&&rK(t,n,r)),this.jr.push([e,i]),i},ts(e,t,n,r){let i=this,a=e.length;if(!a)return i;for(let t=0;t<a-1;t++)i=i.tt(e[t]);return i.tt(e[a-1],t,n,r)},tt(e,t,n,r){r||=aK.groups;let i=this;if(t&&t.j)return i.j[e]=t,t;let a=t,o,s=i.go(e);return s?(o=new aK,Object.assign(o.j,s.j),o.jr.push.apply(o.jr,s.jr),o.jd=s.jd,o.t=s.t):o=new aK,a&&(r&&(o.t&&typeof o.t==`string`?rK(a,Object.assign(iK(o.t,r),n),r):n&&rK(a,n,r)),o.t=a),i.j[e]=o,o}};var oK=(e,t,n,r,i)=>e.ta(t,n,r,i),sK=(e,t,n,r,i)=>e.tr(t,n,r,i),cK=(e,t,n,r,i)=>e.ts(t,n,r,i),$=(e,t,n,r,i)=>e.tt(t,n,r,i),lK=`WORD`,uK=`UWORD`,dK=`ASCIINUMERICAL`,fK=`ALPHANUMERICAL`,pK=`LOCALHOST`,mK=`TLD`,hK=`UTLD`,gK=`SCHEME`,_K=`SLASH_SCHEME`,vK=`NUM`,yK=`WS`,bK=`NL`,xK=`OPENBRACE`,SK=`CLOSEBRACE`,CK=`OPENBRACKET`,wK=`CLOSEBRACKET`,TK=`OPENPAREN`,EK=`CLOSEPAREN`,DK=`OPENANGLEBRACKET`,OK=`CLOSEANGLEBRACKET`,kK=`FULLWIDTHLEFTPAREN`,AK=`FULLWIDTHRIGHTPAREN`,jK=`LEFTCORNERBRACKET`,MK=`RIGHTCORNERBRACKET`,NK=`LEFTWHITECORNERBRACKET`,PK=`RIGHTWHITECORNERBRACKET`,FK=`FULLWIDTHLESSTHAN`,IK=`FULLWIDTHGREATERTHAN`,LK=`AMPERSAND`,RK=`APOSTROPHE`,zK=`ASTERISK`,BK=`AT`,VK=`BACKSLASH`,HK=`BACKTICK`,UK=`CARET`,WK=`COLON`,GK=`COMMA`,KK=`DOLLAR`,qK=`DOT`,JK=`EQUALS`,YK=`EXCLAMATION`,XK=`HYPHEN`,ZK=`PERCENT`,QK=`PIPE`,$K=`PLUS`,eq=`POUND`,tq=`QUERY`,nq=`QUOTE`,rq=`FULLWIDTHMIDDLEDOT`,iq=`SEMI`,aq=`SLASH`,oq=`TILDE`,sq=`UNDERSCORE`,cq=`EMOJI`,lq=`SYM`,uq=Object.freeze({__proto__:null,ALPHANUMERICAL:fK,AMPERSAND:LK,APOSTROPHE:RK,ASCIINUMERICAL:dK,ASTERISK:zK,AT:BK,BACKSLASH:VK,BACKTICK:HK,CARET:UK,CLOSEANGLEBRACKET:OK,CLOSEBRACE:SK,CLOSEBRACKET:wK,CLOSEPAREN:EK,COLON:WK,COMMA:GK,DOLLAR:KK,DOT:qK,EMOJI:cq,EQUALS:JK,EXCLAMATION:YK,FULLWIDTHGREATERTHAN:IK,FULLWIDTHLEFTPAREN:kK,FULLWIDTHLESSTHAN:FK,FULLWIDTHMIDDLEDOT:rq,FULLWIDTHRIGHTPAREN:AK,HYPHEN:XK,LEFTCORNERBRACKET:jK,LEFTWHITECORNERBRACKET:NK,LOCALHOST:pK,NL:bK,NUM:vK,OPENANGLEBRACKET:DK,OPENBRACE:xK,OPENBRACKET:CK,OPENPAREN:TK,PERCENT:ZK,PIPE:QK,PLUS:$K,POUND:eq,QUERY:tq,QUOTE:nq,RIGHTCORNERBRACKET:MK,RIGHTWHITECORNERBRACKET:PK,SCHEME:gK,SEMI:iq,SLASH:aq,SLASH_SCHEME:_K,SYM:lq,TILDE:oq,TLD:mK,UNDERSCORE:sq,UTLD:hK,UWORD:uK,WORD:lK,WS:yK}),dq=/[a-z]/,fq=/\p{L}/u,pq=/\p{Emoji}/u,mq=/\d/,hq=/\s/,gq=`\r`,_q=`
|
|
215
|
+
`,vq=`️`,yq=``,bq=``,xq=null,Sq=null;function Cq(e=[]){let t={};aK.groups=t;let n=new aK;xq??=Dq(WG),Sq??=Dq(GG),$(n,`'`,RK),$(n,`{`,xK),$(n,`}`,SK),$(n,`[`,CK),$(n,`]`,wK),$(n,`(`,TK),$(n,`)`,EK),$(n,`<`,DK),$(n,`>`,OK),$(n,`(`,kK),$(n,`)`,AK),$(n,`「`,jK),$(n,`」`,MK),$(n,`『`,NK),$(n,`』`,PK),$(n,`<`,FK),$(n,`>`,IK),$(n,`&`,LK),$(n,`*`,zK),$(n,`@`,BK),$(n,"`",HK),$(n,`^`,UK),$(n,`:`,WK),$(n,`,`,GK),$(n,`$`,KK),$(n,`.`,qK),$(n,`=`,JK),$(n,`!`,YK),$(n,`-`,XK),$(n,`%`,ZK),$(n,`|`,QK),$(n,`+`,$K),$(n,`#`,eq),$(n,`?`,tq),$(n,`"`,nq),$(n,`/`,aq),$(n,`;`,iq),$(n,`~`,oq),$(n,`_`,sq),$(n,`\\`,VK),$(n,`・`,rq);let r=sK(n,mq,vK,{[KG]:!0});sK(r,mq,r);let i=sK(r,dq,dK,{[YG]:!0}),a=sK(r,fq,fK,{[XG]:!0}),o=sK(n,dq,lK,{[qG]:!0});sK(o,mq,i),sK(o,dq,o),sK(i,mq,i),sK(i,dq,i);let s=sK(n,fq,uK,{[JG]:!0});sK(s,dq),sK(s,mq,a),sK(s,fq,s),sK(a,mq,a),sK(a,dq),sK(a,fq,a);let c=$(n,_q,bK,{[tK]:!0}),l=$(n,gq,yK,{[tK]:!0}),u=sK(n,hq,yK,{[tK]:!0});$(n,bq,u),$(l,_q,c),$(l,bq,u),sK(l,hq,u),$(u,gq),$(u,_q),sK(u,hq,u),$(u,bq,u);let d=sK(n,pq,cq,{[QG]:!0});$(d,`#`),sK(d,pq,d),$(d,vq,d);let f=$(d,yq);$(f,`#`),sK(f,pq,d);let p=[[dq,o],[mq,i]],m=[[dq,null],[fq,s],[mq,a]];for(let e=0;e<xq.length;e++)Eq(n,xq[e],mK,lK,p);for(let e=0;e<Sq.length;e++)Eq(n,Sq[e],hK,uK,m);rK(mK,{tld:!0,ascii:!0},t),rK(hK,{utld:!0,alpha:!0},t),Eq(n,`file`,gK,lK,p),Eq(n,`mailto`,gK,lK,p),Eq(n,`http`,_K,lK,p),Eq(n,`https`,_K,lK,p),Eq(n,`ftp`,_K,lK,p),Eq(n,`ftps`,_K,lK,p),rK(gK,{scheme:!0,ascii:!0},t),rK(_K,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[$G]:!0}:{[eK]:!0};r.indexOf(`-`)>=0?i[ZG]=!0:dq.test(r)?mq.test(r)?i[YG]=!0:i[qG]=!0:i[KG]=!0,cK(n,r,r,i)}return cK(n,`localhost`,pK,{ascii:!0}),n.jd=new aK(lq),{start:n,tokens:Object.assign({groups:t},uq)}}function wq(e,t){let n=Tq(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function Tq(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function Eq(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new aK(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new aK(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function Dq(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var Oq={defaultProtocol:`http`,events:null,format:Aq,formatHref:Aq,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function kq(e,t=null){let n=Object.assign({},Oq);e&&(n=Object.assign(n,e instanceof kq?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i}kq.prototype={o:Oq,ignoreTags:[],defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:Oq[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function Aq(e){return e}function jq(e,t){this.t=`token`,this.v=e,this.tk=t}jq.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=Oq.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Mq(e,t){class n extends jq{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var Nq=Mq(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Pq=Mq(`text`),Fq=Mq(`nl`),Iq=Mq(`url`,{isLink:!0,toHref(e=Oq.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==pK&&e[1].t===WK}}),Lq=e=>new aK(e);function Rq({groups:e}){let t=e.domain.concat([LK,zK,BK,VK,HK,UK,KK,JK,XK,vK,ZK,QK,$K,eq,aq,lq,oq,sq]),n=[RK,WK,GK,qK,YK,ZK,tq,nq,iq,DK,OK,xK,SK,wK,CK,TK,EK,kK,AK,jK,MK,NK,PK,FK,IK],r=[LK,RK,zK,VK,HK,UK,KK,JK,XK,xK,SK,ZK,QK,$K,eq,tq,aq,lq,oq,sq],i=Lq(),a=$(i,oq);oK(a,r,a),oK(a,e.domain,a);let o=Lq(),s=Lq(),c=Lq();oK(i,e.domain,o),oK(i,e.scheme,s),oK(i,e.slashscheme,c),oK(o,r,a),oK(o,e.domain,o);let l=$(o,BK);$(a,BK,l),$(s,BK,l),$(c,BK,l);let u=$(a,qK);oK(u,r,a),oK(u,e.domain,a);let d=Lq();oK(l,e.domain,d),oK(d,e.domain,d);let f=$(d,qK);oK(f,e.domain,d);let p=Lq(Nq);oK(f,e.tld,p),oK(f,e.utld,p),$(l,pK,p);let m=$(d,XK);$(m,XK,m),oK(m,e.domain,d),oK(p,e.domain,d),$(p,qK,f),$(p,XK,m);let h=$(o,XK),g=$(o,qK);$(h,XK,h),oK(h,e.domain,o),oK(g,r,a),oK(g,e.domain,o);let _=Lq(Iq);oK(g,e.tld,_),oK(g,e.utld,_),oK(_,e.domain,o),oK(_,r,a),$(_,qK,g),$(_,XK,h),$(_,BK,l);let v=$(_,WK),y=Lq(Iq);oK(v,e.numeric,y);let b=Lq(Iq),x=Lq();oK(b,t,b),oK(b,n,x),oK(x,t,b),oK(x,n,x),$(_,aq,b),$(y,aq,b);let S=$(s,WK),C=$($($(c,WK),aq),aq);oK(s,e.domain,o),$(s,qK,g),$(s,XK,h),oK(c,e.domain,o),$(c,qK,g),$(c,XK,h),oK(S,e.domain,b),$(S,aq,b),$(S,tq,b),oK(C,e.domain,b),oK(C,t,b),$(C,aq,b);let w=[[xK,SK],[CK,wK],[TK,EK],[DK,OK],[kK,AK],[jK,MK],[NK,PK],[FK,IK]];for(let e=0;e<w.length;e++){let[r,i]=w[e],a=$(b,r);$(x,r,a);let o=Lq(Iq);oK(a,t,o);let s=Lq();oK(a,n,s),$(a,i,b),oK(o,t,o),oK(o,n,s),oK(s,t,o),oK(s,n,s),$(o,i,b),$(s,i,b)}return $(i,pK,_),$(i,bK,Fq),{start:i,tokens:uq}}function zq(e,t,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let s=e,c=null,l=null,u=0,d=null,f=-1;for(;i<r&&!(c=s.go(n[i].t));)o.push(n[i++]);for(;i<r&&(l=c||s.go(n[i].t));)c=null,s=l,s.accepts()?(f=0,d=s):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(Bq(Pq,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Bq(e,t,r))}}return o.length>0&&a.push(Bq(Pq,t,o)),a}function Bq(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Vq=typeof console<`u`&&console&&console.warn||(()=>{}),Hq=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,Uq={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Wq(){return aK.groups={},Uq.scanner=null,Uq.parser=null,Uq.tokenQueue=[],Uq.pluginQueue=[],Uq.customSchemes=[],Uq.initialized=!1,Uq}function Gq(e,t=!1){if(Uq.initialized&&Vq(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Hq}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format.
|
|
216
216
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
217
217
|
2. Cannot start or end with "-"
|
|
218
|
-
3. "-" cannot repeat`);
|
|
219
|
-
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
218
|
+
3. "-" cannot repeat`);Uq.customSchemes.push([e,t])}function Kq(){Uq.scanner=Cq(Uq.customSchemes);for(let e=0;e<Uq.tokenQueue.length;e++)Uq.tokenQueue[e][1]({scanner:Uq.scanner});Uq.parser=Rq(Uq.scanner.tokens);for(let e=0;e<Uq.pluginQueue.length;e++)Uq.pluginQueue[e][1]({scanner:Uq.scanner,parser:Uq.parser});return Uq.initialized=!0,Uq}function qq(e){return Uq.initialized||Kq(),zq(Uq.parser.start,e,wq(Uq.scanner.start,e))}qq.scan=wq;function Jq(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new kq(n),i=qq(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var Yq=`[\0- \xA0 -\u2029 ]`,Xq=new RegExp(Yq),Zq=RegExp(`${Yq}$`),Qq=new RegExp(Yq,`g`);function $q(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function eJ(e){return new lN({key:new fN(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(IB(aB(n.doc,[...t])).forEach(({newRange:t})=>{let n=sB(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!Zq.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Xq).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=qq(n).map(t=>t.toObject(e.defaultProtocol));if(!$q(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{LB(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function tJ(e){return new lN({key:new fN(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=NB(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}function nJ(e){return new lN({key:new fN(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=Jq(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function rJ(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(Qq,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,`i`))}var iJ=NV.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){Gq(e);return}Gq(e.scheme,e.optionalSlashes)})},onDestroy(){Wq()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!rJ(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!rJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!rJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,yB(this.options.HTMLAttributes,e),0]:[`a`,yB(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!rJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!rJ(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[SH({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=Jq(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!rJ(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(eJ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!rJ(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(tJ({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(nJ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),aJ=Object.defineProperty,oJ=(e,t)=>{for(var n in t)aJ(e,n,{get:t[n],enumerable:!0})},sJ=`listItem`,cJ=`textStyle`,lJ=/^\s*([-+*])\s$/,uJ=xH.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,yB(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
219
|
+
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(sJ,this.editor.getAttributes(cJ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=sH({find:lJ,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=sH({find:lJ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(cJ),editor:this.editor})),[e]}}),dJ=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},fJ=(e,t,n,r)=>{let i=dJ(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,J.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},pJ=(e,t,n)=>fJ(e.state,e.view.dispatch,t,n),mJ=(e,t)=>HV.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>pJ(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}});function hJ(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function gJ(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var _J=xH.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,yB(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(hJ(e))return{type:`listItem`,content:[{type:`paragraph`,content:gJ(e.text||``,t)}]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else{let i=e.tokens[0];if(i&&i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:r}},renderMarkdown:(e,t,n)=>yH(e,t,e=>e.parentType===`bulletList`?`- `:e.parentType===`orderedList`?`${(e.meta?.parentAttrs?.start||1)+e.index}. `:`- `,n),addExtensions(){return[mJ(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});oJ({},{findListItemPos:()=>vJ,getNextListDepth:()=>yJ,handleBackspace:()=>xJ,handleDelete:()=>wJ,hasListBefore:()=>bJ,hasListItemAfter:()=>TJ,hasListItemBefore:()=>EJ,listItemHasSubList:()=>DJ,nextListIsDeeper:()=>SJ,nextListIsHigher:()=>CJ});var vJ=(e,t)=>{let{$from:n}=t.selection,r=QR(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},yJ=(e,t)=>{let n=vJ(e,t);if(!n)return!1;let[,r]=RB(t,e,n.$pos.pos+4);return r},bJ=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},xJ=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Vz(e.state,t)&&bJ(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}return!Vz(e.state,t)||!GB(e.state)?!1:e.chain().liftListItem(t).run()},SJ=(e,t)=>{let n=yJ(e,t),r=vJ(e,t);return!r||!n?!1:n>r.depth},CJ=(e,t)=>{let n=yJ(e,t),r=vJ(e,t);return!r||!n?!1:n<r.depth},wJ=(e,t)=>{if(!Vz(e.state,t)||!WB(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:SJ(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():CJ(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},TJ=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return!(r.index()===r.parent.childCount-1||r.nodeAfter?.type.name!==e)},EJ=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return!(r.index()===0||r.nodeBefore?.type.name!==e)},DJ=(e,t,n)=>{if(!n)return!1;let r=QR(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},OJ=HV.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&wJ(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&wJ(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&xJ(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&xJ(e,n,r)&&(t=!0)}),t}}}}),kJ=/^(\s*)(\d+)\.\s+(.*)$/,AJ=/^\s/;function jJ(e){let t=e.trimStart();return/^[-+*]\s+/.test(t)||/^\d+\.\s+/.test(t)||/^>\s?/.test(t)||/^```/.test(t)||/^~~~/.test(t)}function MJ(e){let t=[],n=[],r=!1;return e.forEach(e=>{if(r){n.push(e);return}if(e.trim()===``){r=!0,n.push(e);return}if(t.length>0&&jJ(e)){r=!0,n.push(e);return}t.push(e)}),{paragraphLines:t,blockLines:n}}function NJ(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n],a=i.match(kJ);if(!a)break;let[,o,s,c]=a,l=o.length,u=[c],d=n+1,f=[i],p=!1;for(;d<e.length;){let t=e[d];if(t.match(kJ))break;if(t.trim()===``)f.push(t),u.push(``),p=!0,d+=1;else if(t.match(AJ))f.push(t),u.push(t.slice(l+2)),d+=1;else{if(p)break;f.push(t),u.push(t),d+=1}}t.push({indent:l,number:parseInt(s,10),content:u.join(`
|
|
220
220
|
`).trim(),contentLines:u,raw:f.join(`
|
|
221
|
-
`)}),r=d,n=d}return[t,r]}function
|
|
221
|
+
`)}),r=d,n=d}return[t,r]}function PJ(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=MJ(a.contentLines),c=o.join(`
|
|
222
222
|
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
|
|
223
|
-
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=
|
|
224
|
-
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function
|
|
223
|
+
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=PJ(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,items:e,raw:f.map(e=>e.raw).join(`
|
|
224
|
+
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function FJ(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var IJ=`listItem`,LJ=`textStyle`,RJ=/^(\d+)\.\s$/,zJ=xH.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,yB(this.options.HTMLAttributes,n),0]:[`ol`,yB(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.items?FJ(e.items,t):[];return n===1?{type:`orderedList`,content:r}:{type:`orderedList`,attrs:{start:n},content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
225
225
|
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(`
|
|
226
|
-
`),[i,a]=
|
|
227
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
228
|
-
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=PR(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=PR(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});iR.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(EW.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(NW.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(WW.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(tG.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(rG.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(iG.configure(this.options.taskList)),e}});var aG=` `,oG=`\xA0`,sG=LR.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,FI(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===aG||n[0].text===aG||n[0].raw===oG||n[0].text===oG)&&r.length===1&&r[0].type===`text`&&(r[0].text===aG||r[0].text===oG)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?aG:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cG=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,lG=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,uG=YL.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,FI(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[bR({find:cG,type:this.type})]},addPasteRules(){return[RR({find:lG,type:this.type})]}}),dG=LR.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),fG=YL.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,FI(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function pG(e={}){return new Tk({view(t){return new mG(t,e)}})}var mG=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=RO(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},hG=class e extends ak{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):ak.near(r)}content(){return Y.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new gG(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!vG(e)||!yG(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Z.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};hG.prototype.visible=!1,hG.findFrom=hG.findGapCursorFrom,ak.jsonID(`gapcursor`,hG);var gG=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return hG.valid(t)?new hG(t):ak.near(t)}};function _G(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function vG(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||_G(e.type))return!0;if(e.inlineContent)return!1}}return!0}function yG(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||_G(e.type))return!0;if(e.inlineContent)return!1}}return!0}function bG(){return new Tk({props:{decorations:TG,createSelectionBetween(e,t,n){return t.pos==n.pos&&hG.valid(n)?new hG(n):null},handleClick:CG,handleKeyDown:xG,handleDOMEvents:{beforeinput:wG}}})}var xG=tF({ArrowLeft:SG(`horiz`,-1),ArrowRight:SG(`horiz`,1),ArrowUp:SG(`vert`,-1),ArrowDown:SG(`vert`,1)});function SG(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof X){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=hG.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new hG(c))),!0):!1}}function CG(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!hG.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Z.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new hG(r))),!0)}function wG(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof hG))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=J.empty;for(let e=r.length-1;e>=0;e--)i=J.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Y(i,0,0));return a.setSelection(X.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function TG(e){if(!(e.selection instanceof hG))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,eP.create(e.doc,[ZN.widget(e.selection.head,t,{key:`gapcursor`})])}var EG=200,DG=function(){};DG.prototype.append=function(e){return e.length?(e=DG.from(e),!this.length&&e||e.length<EG&&this.leafAppend(e)||this.length<EG&&e.leafPrepend(this)||this.appendInner(e)):this},DG.prototype.prepend=function(e){return e.length?DG.from(e).append(this):this},DG.prototype.appendInner=function(e){return new kG(this,e)},DG.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?DG.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},DG.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},DG.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},DG.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},DG.from=function(e){return e instanceof DG?e:e&&e.length?new OG(e):DG.empty};var OG=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=EG)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=EG)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(DG);DG.empty=new OG([]);var kG=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(DG),AG=500,jG=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new NG(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new NG(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new NG(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>FG&&(s=MG(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new nO;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new NG(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new NG(i,o,l))}else r.push(new NG(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new NG(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>AG&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new NG(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(DG.from(i.reverse()),a)}};jG.empty=new jG(DG.empty,0);function MG(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var NG=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},PG=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},FG=20;function IG(e,t,n,r){let i=n.getMeta(WG),a;if(i)return i.historyState;n.getMeta(GG)&&(e=new PG(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(WG))return o.getMeta(WG).redo?new PG(e.done.addTransform(n,void 0,r,UG(t)),e.undone,RG(n.mapping.maps),e.prevTime,e.prevComposition):new PG(e.done,e.undone.addTransform(n,void 0,r,UG(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!LG(n,e.prevRanges)),s=o?zG(e.prevRanges,n.mapping):RG(n.mapping.maps);return new PG(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,UG(t)),jG.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new PG(e.done.rebased(n,a),e.undone.rebased(n,a),zG(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new PG(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),zG(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function LG(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function RG(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function zG(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function BG(e,t,n){let r=UG(t),i=WG.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new PG(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(WG,{redo:n,historyState:c})}var VG=!1,HG=null;function UG(e){let t=e.plugins;if(HG!=t){VG=!1,HG=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){VG=!0;break}}return VG}var WG=new Ok(`history`),GG=new Ok(`closeHistory`);function KG(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Tk({key:WG,state:{init(){return new PG(jG.empty,jG.empty,null,0,-1)},apply(t,n,r){return IG(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?JG:n==`historyRedo`?YG:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function qG(e,t){return(n,r)=>{let i=WG.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=BG(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var JG=qG(!1,!0),YG=qG(!0,!0);iR.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Tk({key:new Ok(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var XG=iR.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[pG(this.options)]}});iR.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new Tk({key:new Ok(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return eP.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(ZN.node(t,t+e.nodeSize,{class:this.options.className}))}),eP.create(e,a)}}})]}});var ZG=iR.create({name:`gapCursor`,addProseMirrorPlugins(){return[bG()]},extendNodeSchema(e){return{allowGapCursor:kI(Q(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),QG=`placeholder`,$G=new Ok(`tiptap__placeholder`),eK=200;function tK(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),ZN.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function nK(e,t){return typeof e==`function`?e(t):e}function rK({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&uL(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(tK({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:nK(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else{let i=$G.getState(e.state),c=i?.topPos??0,l=i?.bottomPos??r.content.size;r.nodesBetween(c,l,(r,i)=>{let c=a>=i&&a<=i+r.nodeSize,l=!r.isLeaf&&uL(r);return r.type.isTextblock&&(c||!t.showOnlyCurrent)&&l&&o.push(tK({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:c,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:nK(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:c})},node:r,pos:i})),t.includeChildren})}return eP.create(r,o)}function iK(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function aK(e){let t=getComputedStyle(e),n=`${t.overflow} ${t.overflowY} ${t.overflowX}`;return/auto|scroll|overlay/.test(n)}function oK(e){let t=e;for(;t;){if(aK(t))return t;let e=t.parentElement;if(!e){let e=t.getRootNode();if(e instanceof ShadowRoot){t=e.host;continue}return window}t=e}return window}function sK(e){return e===window?{top:0,bottom:window.innerHeight}:e.getBoundingClientRect()}function cK({doc:e,view:t,scrollContainer:n}){let r=t.dom.getBoundingClientRect(),i=n?sK(n):{top:0,bottom:window.innerHeight},a=Math.max(r.top,i.top)-eK,o=Math.min(r.bottom,i.bottom)+eK;if(a>=o)return{top:0,bottom:e.content.size};let s=getComputedStyle(t.dom).direction===`rtl`?Math.max(r.right-2,r.left+2):r.left+2,c=t.posAtCoords({left:s,top:a+2}),l=t.posAtCoords({left:s,top:o-2});return{top:c?c.pos:0,bottom:l?l.pos:e.content.size}}var lK={init(){return{topPos:null,bottomPos:null}},apply(e,t){let n=e.getMeta($G);return n?.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:t.topPos===null?null:e.mapping.map(t.topPos),bottomPos:t.bottomPos===null?null:e.mapping.map(t.bottomPos)}:t}};function uK(e){let t=oK(e.dom),n=()=>{let n=cK({view:e,doc:e.state.doc,scrollContainer:t}),r=$G.getState(e.state);if(r?.topPos===n.top&&r?.bottomPos===n.bottom)return;let i=e.state.tr.setMeta($G,{positions:n});e.dispatch(i)},r=null,i=0,a=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;let e=performance.now();e-i>=150?(i=e,n()):a()}))};return t.addEventListener(`scroll`,a,{passive:!0}),n(),{update(t,n){e.state.doc.content.size!==n.doc.content.size&&a()},destroy:()=>{r!==null&&cancelAnimationFrame(r),t.removeEventListener(`scroll`,a)}}}function dK({editor:e,options:t}){let n=t.dataAttribute?`data-${iK(t.dataAttribute)}`:`data-${QG}`;return new Tk({key:$G,state:lK,view:uK,props:{decorations:({doc:r,selection:i})=>rK({editor:e,options:t,dataAttribute:n,doc:r,selection:i})}})}iR.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:QG,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[dK({editor:this.editor,options:this.options})]}});var fK=`.ProseMirror:not(.ProseMirror-focused) *::selection {
|
|
226
|
+
`),[i,a]=NJ(r);if(i.length===0)return;let o=PJ(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(`
|
|
227
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(IJ,this.editor.getAttributes(LJ)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=sH({find:RJ,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=sH({find:RJ,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(LJ)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),BJ=/^\s*(\[([( |x])?\])\s$/,VJ=xH.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,yB(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>yH(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addExtensions(){return this.options.nested?[mJ(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=bB(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[sH({find:BJ,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),HJ=xH.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,yB(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
|
|
228
|
+
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=vH(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=vH(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});HV.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(uJ.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(_J.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(OJ.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(zJ.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(VJ.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(HJ.configure(this.options.taskList)),e}});var UJ=` `,WJ=`\xA0`,GJ=xH.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,yB(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===UJ||n[0].text===UJ||n[0].raw===WJ||n[0].text===WJ)&&r.length===1&&r[0].type===`text`&&(r[0].text===UJ||r[0].text===WJ)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?UJ:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),KJ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,qJ=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,JJ=NV.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,yB(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[iH({find:KJ,type:this.type})]},addPasteRules(){return[SH({find:qJ,type:this.type})]}}),YJ=xH.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),XJ=NV.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,yB(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function ZJ(e={}){return new lN({view(t){return new QJ(t,e)}})}var QJ=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=SM(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},$J=class e extends UM{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):UM.near(r)}content(){return Y.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new eY(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!nY(e)||!rY(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Z.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};$J.prototype.visible=!1,$J.findFrom=$J.findGapCursorFrom,UM.jsonID(`gapcursor`,$J);var eY=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $J.valid(t)?new $J(t):UM.near(t)}};function tY(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function nY(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||tY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function rY(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||tY(e.type))return!0;if(e.inlineContent)return!1}}return!0}function iY(){return new lN({props:{decorations:lY,createSelectionBetween(e,t,n){return t.pos==n.pos&&$J.valid(n)?new $J(n):null},handleClick:sY,handleKeyDown:aY,handleDOMEvents:{beforeinput:cY}}})}var aY=zR({ArrowLeft:oY(`horiz`,-1),ArrowRight:oY(`horiz`,1),ArrowUp:oY(`vert`,-1),ArrowDown:oY(`vert`,1)});function oY(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof X){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=$J.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new $J(c))),!0):!1}}function sY(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!$J.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Z.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new $J(r))),!0)}function cY(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof $J))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=J.empty;for(let e=r.length-1;e>=0;e--)i=J.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Y(i,0,0));return a.setSelection(X.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function lY(e){if(!(e.selection instanceof $J))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,RL.create(e.doc,[FL.widget(e.selection.head,t,{key:`gapcursor`})])}var uY=200,dY=function(){};dY.prototype.append=function(e){return e.length?(e=dY.from(e),!this.length&&e||e.length<uY&&this.leafAppend(e)||this.length<uY&&e.leafPrepend(this)||this.appendInner(e)):this},dY.prototype.prepend=function(e){return e.length?dY.from(e).append(this):this},dY.prototype.appendInner=function(e){return new pY(this,e)},dY.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?dY.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},dY.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},dY.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},dY.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},dY.from=function(e){return e instanceof dY?e:e&&e.length?new fY(e):dY.empty};var fY=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=uY)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=uY)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(dY);dY.empty=new fY([]);var pY=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(dY),mY=500,hY=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new _Y(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new _Y(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new _Y(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>yY&&(s=gY(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new Bj;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new _Y(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new _Y(i,o,l))}else r.push(new _Y(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new _Y(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>mY&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new _Y(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(dY.from(i.reverse()),a)}};hY.empty=new hY(dY.empty,0);function gY(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var _Y=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},vY=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},yY=20;function bY(e,t,n,r){let i=n.getMeta(OY),a;if(i)return i.historyState;n.getMeta(kY)&&(e=new vY(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(OY))return o.getMeta(OY).redo?new vY(e.done.addTransform(n,void 0,r,DY(t)),e.undone,SY(n.mapping.maps),e.prevTime,e.prevComposition):new vY(e.done,e.undone.addTransform(n,void 0,r,DY(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!xY(n,e.prevRanges)),s=o?CY(e.prevRanges,n.mapping):SY(n.mapping.maps);return new vY(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,DY(t)),hY.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new vY(e.done.rebased(n,a),e.undone.rebased(n,a),CY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new vY(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),CY(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function xY(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function SY(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function CY(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function wY(e,t,n){let r=DY(t),i=OY.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new vY(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(OY,{redo:n,historyState:c})}var TY=!1,EY=null;function DY(e){let t=e.plugins;if(EY!=t){TY=!1,EY=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){TY=!0;break}}return TY}var OY=new fN(`history`),kY=new fN(`closeHistory`);function AY(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new lN({key:OY,state:{init(){return new vY(hY.empty,hY.empty,null,0,-1)},apply(t,n,r){return bY(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?MY:n==`historyRedo`?NY:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function jY(e,t){return(n,r)=>{let i=OY.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=wY(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var MY=jY(!1,!0),NY=jY(!0,!0);HV.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new lN({key:new fN(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var PY=HV.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[ZJ(this.options)]}});HV.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new lN({key:new fN(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return RL.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(FL.node(t,t+e.nodeSize,{class:this.options.className}))}),RL.create(e,a)}}})]}});var FY=HV.create({name:`gapCursor`,addProseMirrorPlugins(){return[iY()]},extendNodeSchema(e){return{allowGapCursor:pB(Q(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),IY=`placeholder`,LY=new fN(`tiptap__placeholder`),RY=200;function zY(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),FL.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function BY(e,t){return typeof e==`function`?e(t):e}function VY({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!(e.isEditable||!t.showOnlyWhenEditable))return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&JB(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(zY({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:BY(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else{let i=LY.getState(e.state),c=i?.topPos??0,l=i?.bottomPos??r.content.size;r.nodesBetween(c,l,(r,i)=>{let c=a>=i&&a<=i+r.nodeSize,l=!r.isLeaf&&JB(r);return r.type.isTextblock&&(c||!t.showOnlyCurrent)&&l&&o.push(zY({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:c,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:BY(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:c})},node:r,pos:i})),t.includeChildren})}return RL.create(r,o)}function HY(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function UY(e){let t=getComputedStyle(e),n=`${t.overflow} ${t.overflowY} ${t.overflowX}`;return/auto|scroll|overlay/.test(n)}function WY(e){let t=e;for(;t;){if(UY(t))return t;let e=t.parentElement;if(!e){let e=t.getRootNode();if(e instanceof ShadowRoot){t=e.host;continue}return window}t=e}return window}function GY(e){return e===window?{top:0,bottom:window.innerHeight}:e.getBoundingClientRect()}function KY({doc:e,view:t,scrollContainer:n}){let r=t.dom.getBoundingClientRect(),i=n?GY(n):{top:0,bottom:window.innerHeight},a=Math.max(r.top,i.top)-RY,o=Math.min(r.bottom,i.bottom)+RY;if(a>=o)return{top:0,bottom:e.content.size};let s=getComputedStyle(t.dom).direction===`rtl`?Math.max(r.right-2,r.left+2):r.left+2,c=t.posAtCoords({left:s,top:a+2}),l=t.posAtCoords({left:s,top:o-2});return{top:c?c.pos:0,bottom:l?l.pos:e.content.size}}var qY={init(){return{topPos:null,bottomPos:null}},apply(e,t){let n=e.getMeta(LY);return n?.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:t.topPos===null?null:e.mapping.map(t.topPos),bottomPos:t.bottomPos===null?null:e.mapping.map(t.bottomPos)}:t}};function JY(e){let t=WY(e.dom),n=()=>{let n=KY({view:e,doc:e.state.doc,scrollContainer:t}),r=LY.getState(e.state);if(r?.topPos===n.top&&r?.bottomPos===n.bottom)return;let i=e.state.tr.setMeta(LY,{positions:n});e.dispatch(i)},r=null,i=0,a=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;let e=performance.now();e-i>=150?(i=e,n()):a()}))};return t.addEventListener(`scroll`,a,{passive:!0}),n(),{update(t,n){e.state.doc.content.size!==n.doc.content.size&&a()},destroy:()=>{r!==null&&cancelAnimationFrame(r),t.removeEventListener(`scroll`,a)}}}function YY({editor:e,options:t}){let n=t.dataAttribute?`data-${HY(t.dataAttribute)}`:`data-${IY}`;return new lN({key:LY,state:qY,view:JY,props:{decorations:({doc:r,selection:i})=>VY({editor:e,options:t,dataAttribute:n,doc:r,selection:i})}})}HV.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:IY,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[YY({editor:this.editor,options:this.options})]}});var XY=`.ProseMirror:not(.ProseMirror-focused) *::selection {
|
|
229
229
|
background: transparent;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {
|
|
233
233
|
background: transparent;
|
|
234
|
-
}`;iR.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return e.options.injectCSS&&typeof document<`u`&&vR(fK,e.options.injectNonce,`selection`),[new Tk({key:new Ok(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||dL(n.selection)||e.view.dragging?null:eP.create(n.doc,[ZN.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function pK({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var mK=iR.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new Ok(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new Tk({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!pK({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!pK({node:r,types:n})}}})]}}),hK=iR.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>JG(e,t),redo:()=>({state:e,dispatch:t})=>YG(e,t)}},addProseMirrorPlugins(){return[KG(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),gK=iR.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(UV.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(RV.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(EW.configure(this.options.bulletList)),this.options.code!==!1&&e.push(KV.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(XV.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(ZV.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(XG.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(ZG.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(QV.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push($V.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(hK.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(eH.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(aH.configure(this.options.italic)),this.options.listItem!==!1&&e.push(NW.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(WW.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(bW.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(tG.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(sG.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(uG.configure(this.options.strike)),this.options.text!==!1&&e.push(dG.configure(this.options.text)),this.options.underline!==!1&&e.push(fG.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(mK.configure(this.options?.trailingNode)),e}});function _K(e,t,n){let r=e.state.schema.nodes.image;if(r===void 0)return!1;let i=Array.from(t??[]).filter(e=>e.type.startsWith(`image/`));for(let t of i){let i=new FileReader;i.onload=()=>{if(typeof i.result!=`string`)return;let a=r.create({src:i.result,alt:t.name}),o=n===void 0?e.state.tr.replaceSelectionWith(a):e.state.tr.insert(Math.min(n,e.state.doc.content.size),a);e.dispatch(o)},i.readAsDataURL(t)}return i.length>0}function vK({document:e,mode:t,onSave:n,onDelete:r,isSaving:i=!1,isDeleting:a=!1}){let[o,s]=(0,V.useState)(e.title),[c,l]=(0,V.useState)(e.status_line??``),u=Qz({extensions:[gK,BR.configure({allowBase64:!0})],content:Dc(e.body??``),editable:t===`editor`,editorProps:{attributes:{class:`document-editor-content`},handlePaste:(e,t)=>_K(e,t.clipboardData?.files),handleDrop:(e,t,n,r)=>{if(r)return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY})?.pos;return _K(e,t.dataTransfer?.files,i)}}});return(0,V.useEffect)(()=>{s(e.title),l(e.status_line??``)},[e.title,e.status_line]),(0,V.useEffect)(()=>{u.setEditable(t===`editor`)},[u,t]),(0,V.useEffect)(()=>{let t=u.getHTML(),n=Dc(e.body??``);t!==n&&u.commands.setContent(n,{emitUpdate:!1})},[u,e.body]),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`,alignItems:`center`,marginBottom:`1rem`},children:[t===`editor`?(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>{s(e.target.value)},"aria-label":`Document title`,style:{flex:1,fontSize:`1.5rem`,fontWeight:600,border:`none`,borderBottom:`1px solid #e5e7eb`,padding:`0.25rem 0`}}):(0,H.jsx)(`h1`,{style:{margin:0,flex:1},children:o}),t===`editor`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{n({title:o,body:u.getHTML(),status_line:c.trim()===``?null:c})},disabled:i,style:{padding:`0.5rem 1rem`,borderRadius:6,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,cursor:i?`wait`:`pointer`},children:i?`Saving…`:`Save`}),r===void 0?null:(0,H.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Delete this document?`)&&r()},disabled:a,style:{padding:`0.5rem 1rem`,borderRadius:6,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontWeight:600,cursor:a?`wait`:`pointer`},children:a?`Deleting…`:`Delete`})]}):null]}),(0,H.jsx)(`label`,{htmlFor:`status-line`,style:{display:`block`,fontSize:`0.875rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Status`}),t===`editor`?(0,H.jsx)(`input`,{id:`status-line`,type:`text`,value:c,onChange:e=>{l(e.target.value)},placeholder:`Status: draft`,style:{width:`100%`,marginBottom:`1rem`,padding:`0.5rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`}}):c===``?null:(0,H.jsx)(`p`,{style:{marginTop:0,marginBottom:`1rem`,color:`#374151`},children:c}),t===`editor`?(0,H.jsx)(yK,{editor:u}):null,t===`reader`?(0,H.jsx)(`div`,{className:`document-reader-content`,dangerouslySetInnerHTML:{__html:Kl(Dc(e.body??``))},style:{lineHeight:1.6,padding:`1rem`,border:`1px solid #e5e7eb`,borderRadius:8,minHeight:`12rem`}}):(0,H.jsx)(`div`,{style:{border:`1px solid #e5e7eb`,borderRadius:8,padding:`0.75rem 1rem`,minHeight:`12rem`},children:(0,H.jsx)(Wz,{editor:u})})]})}function yK({editor:e}){let t=(0,V.useRef)(null),n=e=>({padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,background:e?`#e5e7eb`:`#fff`,fontWeight:e?600:400,cursor:`pointer`});return(0,H.jsxs)(`div`,{role:`toolbar`,"aria-label":`Formatting`,style:{display:`flex`,gap:`0.5rem`,marginBottom:`0.5rem`,flexWrap:`wrap`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleBold().run(),"aria-pressed":e.isActive(`bold`),style:n(e.isActive(`bold`)),children:`Bold`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleItalic().run(),"aria-pressed":e.isActive(`italic`),style:n(e.isActive(`italic`)),children:`Italic`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),"aria-pressed":e.isActive(`heading`,{level:2}),style:n(e.isActive(`heading`,{level:2})),children:`H2`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleBulletList().run(),"aria-pressed":e.isActive(`bulletList`),style:n(e.isActive(`bulletList`)),children:`List`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>t.current?.click(),style:n(!1),children:`Image`}),(0,H.jsx)(`input`,{ref:t,type:`file`,accept:`image/*`,"aria-label":`Insert image`,style:{display:`none`},onChange:t=>{_K(e.view,t.target.files),t.target.value=``}})]})}function bK(){let{id:e,docId:t}=xK.useParams(),n=Di(),{data:r,isLoading:i,error:a}=Ga(e),{data:o,isLoading:s,error:c}=ro(t),l=io(),u=ao(),[d,f]=(0,V.useState)(`editor`);return i||s?(0,H.jsx)(`p`,{children:`Loading document…`}):a===null?c===null?r===void 0?(0,H.jsx)(`p`,{children:`Project not found.`}):o===void 0?(0,H.jsx)(`p`,{children:`Document not found.`}):o.project_id===e?(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`p`,{children:(0,H.jsxs)(Vi,{to:`/projects/$id/overview`,params:{id:e},style:{color:`#555`},children:[`← `,r.name]})}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,marginBottom:`1rem`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(`reader`)},"aria-pressed":d===`reader`,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:d===`reader`?`#e5e7eb`:`#fff`,fontWeight:d===`reader`?600:400,cursor:`pointer`},children:`Reader`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(`editor`)},"aria-pressed":d===`editor`,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:d===`editor`?`#e5e7eb`:`#fff`,fontWeight:d===`editor`?600:400,cursor:`pointer`},children:`Editor`})]}),l.error===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{color:`#b91c1c`},children:[`Save failed: `,l.error.message]}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`1rem`,alignItems:`flex-start`},children:[(0,H.jsx)(`div`,{style:{flex:1,minWidth:0},children:(0,H.jsx)(vK,{document:o,mode:d,isSaving:l.isPending,isDeleting:u.isPending,onSave:e=>{l.mutate({id:t,input:e})},onDelete:()=>{u.mutate({id:t,projectId:e},{onSuccess:()=>{n({to:`/projects/$id/overview`,params:{id:e}})}})}})}),(0,H.jsx)(SE,{documentId:t,projectId:e})]})]}):(0,H.jsx)(`p`,{role:`alert`,children:`Document does not belong to this project.`}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load document: `,c.message]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load project: `,a.message]})}var xK=qi(`/projects/$id/documents/$docId`)({component:bK}),SK=bo.update({id:`/`,path:`/`,getParentRoute:()=>vo}),CK=To.update({id:`/settings/mcp`,path:`/settings/mcp`,getParentRoute:()=>vo}),wK=gu.update({id:`/p/$shareToken`,path:`/p/$shareToken`,getParentRoute:()=>vo}),TK=yu.update({id:`/projects/$id/overview`,path:`/projects/$id/overview`,getParentRoute:()=>vo}),EK=uC.update({id:`/projects/$id/flow`,path:`/projects/$id/flow`,getParentRoute:()=>vo}),DK={IndexRoute:SK,PShareTokenRoute:wK,SettingsMcpRoute:CK,ProjectsIdBoardRoute:vE.update({id:`/projects/$id/board`,path:`/projects/$id/board`,getParentRoute:()=>vo}),ProjectsIdFlowRoute:EK,ProjectsIdOverviewRoute:TK,ProjectsIdDocumentsDocIdRoute:xK.update({id:`/projects/$id/documents/$docId`,path:`/projects/$id/documents/$docId`,getParentRoute:()=>vo})},OK=vo._addFileChildren(DK)._addFileTypes(),kK=new Re,AK=ca({routeTree:OK}),jK=document.getElementById(`root`);jK!==null&&(0,fa.createRoot)(jK).render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(He,{client:kK,children:(0,H.jsx)(da,{router:AK})})}));
|
|
234
|
+
}`;HV.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return e.options.injectCSS&&typeof document<`u`&&nH(XY,e.options.injectNonce,`selection`),[new lN({key:new fN(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||YB(n.selection)||e.view.dragging?null:RL.create(n.doc,[FL.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function ZY({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var QY=HV.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new fN(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new lN({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!ZY({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!ZY({node:r,types:n})}}})]}}),$Y=HV.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>MY(e,t),redo:()=>({state:e,dispatch:t})=>NY(e,t)}},addProseMirrorPlugins(){return[AY(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),eX=HV.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(DG.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(SG.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(uJ.configure(this.options.bulletList)),this.options.code!==!1&&e.push(AG.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(PG.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(FG.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(PY.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(FY.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(IG.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(LG.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push($Y.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(RG.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(UG.configure(this.options.italic)),this.options.listItem!==!1&&e.push(_J.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(OJ.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(iJ.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(zJ.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(GJ.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(JJ.configure(this.options.strike)),this.options.text!==!1&&e.push(YJ.configure(this.options.text)),this.options.underline!==!1&&e.push(XJ.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(QY.configure(this.options?.trailingNode)),e}});function tX(e,t,n){let r=e.state.schema.nodes.image;if(r===void 0)return!1;let i=Array.from(t??[]).filter(e=>e.type.startsWith(`image/`));for(let t of i){let i=new FileReader;i.onload=()=>{if(typeof i.result!=`string`)return;let a=r.create({src:i.result,alt:t.name}),o=n===void 0?e.state.tr.replaceSelectionWith(a):e.state.tr.insert(Math.min(n,e.state.doc.content.size),a);e.dispatch(o)},i.readAsDataURL(t)}return i.length>0}function nX({document:e,mode:t,onSave:n,onDelete:r,isSaving:i=!1,isDeleting:a=!1}){let[o,s]=(0,V.useState)(e.title),[c,l]=(0,V.useState)(e.status_line??``),u=IU({extensions:[eX,wH.configure({allowBase64:!0})],content:Dc(e.body??``),editable:t===`editor`,editorProps:{attributes:{class:`document-editor-content`},handlePaste:(e,t)=>tX(e,t.clipboardData?.files),handleDrop:(e,t,n,r)=>{if(r)return!1;let i=e.posAtCoords({left:t.clientX,top:t.clientY})?.pos;return tX(e,t.dataTransfer?.files,i)}}});return(0,V.useEffect)(()=>{s(e.title),l(e.status_line??``)},[e.title,e.status_line]),(0,V.useEffect)(()=>{u.setEditable(t===`editor`)},[u,t]),(0,V.useEffect)(()=>{let t=u.getHTML(),n=Dc(e.body??``);t!==n&&u.commands.setContent(n,{emitUpdate:!1})},[u,e.body]),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`,alignItems:`center`,marginBottom:`1rem`},children:[t===`editor`?(0,H.jsx)(`input`,{type:`text`,value:o,onChange:e=>{s(e.target.value)},"aria-label":`Document title`,style:{flex:1,fontSize:`1.5rem`,fontWeight:600,border:`none`,borderBottom:`1px solid #e5e7eb`,padding:`0.25rem 0`}}):(0,H.jsx)(`h1`,{style:{margin:0,flex:1},children:o}),t===`editor`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{n({title:o,body:u.getHTML(),status_line:c.trim()===``?null:c})},disabled:i,style:{padding:`0.5rem 1rem`,borderRadius:6,border:`1px solid #1d4ed8`,background:`#1d4ed8`,color:`#fff`,fontWeight:600,cursor:i?`wait`:`pointer`},children:i?`Saving…`:`Save`}),r===void 0?null:(0,H.jsx)(`button`,{type:`button`,onClick:()=>{confirm(`Delete this document?`)&&r()},disabled:a,style:{padding:`0.5rem 1rem`,borderRadius:6,border:`1px solid #fca5a5`,background:`#fef2f2`,color:`#b91c1c`,fontWeight:600,cursor:a?`wait`:`pointer`},children:a?`Deleting…`:`Delete`})]}):null]}),(0,H.jsx)(`label`,{htmlFor:`status-line`,style:{display:`block`,fontSize:`0.875rem`,color:`#6b7280`,marginBottom:`0.25rem`},children:`Status`}),t===`editor`?(0,H.jsx)(`input`,{id:`status-line`,type:`text`,value:c,onChange:e=>{l(e.target.value)},placeholder:`Status: draft`,style:{width:`100%`,marginBottom:`1rem`,padding:`0.5rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`}}):c===``?null:(0,H.jsx)(`p`,{style:{marginTop:0,marginBottom:`1rem`,color:`#374151`},children:c}),t===`editor`?(0,H.jsx)(rX,{editor:u}):null,t===`reader`?(0,H.jsx)(`div`,{className:`document-reader-content`,dangerouslySetInnerHTML:{__html:Kl(Dc(e.body??``))},style:{lineHeight:1.6,padding:`1rem`,border:`1px solid #e5e7eb`,borderRadius:8,minHeight:`12rem`}}):(0,H.jsx)(`div`,{style:{border:`1px solid #e5e7eb`,borderRadius:8,padding:`0.75rem 1rem`,minHeight:`12rem`},children:(0,H.jsx)(OU,{editor:u})})]})}function rX({editor:e}){let t=(0,V.useRef)(null),n=e=>({padding:`0.25rem 0.5rem`,borderRadius:4,border:`1px solid #d1d5db`,background:e?`#e5e7eb`:`#fff`,fontWeight:e?600:400,cursor:`pointer`});return(0,H.jsxs)(`div`,{role:`toolbar`,"aria-label":`Formatting`,style:{display:`flex`,gap:`0.5rem`,marginBottom:`0.5rem`,flexWrap:`wrap`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleBold().run(),"aria-pressed":e.isActive(`bold`),style:n(e.isActive(`bold`)),children:`Bold`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleItalic().run(),"aria-pressed":e.isActive(`italic`),style:n(e.isActive(`italic`)),children:`Italic`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),"aria-pressed":e.isActive(`heading`,{level:2}),style:n(e.isActive(`heading`,{level:2})),children:`H2`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>e.chain().focus().toggleBulletList().run(),"aria-pressed":e.isActive(`bulletList`),style:n(e.isActive(`bulletList`)),children:`List`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>t.current?.click(),style:n(!1),children:`Image`}),(0,H.jsx)(`input`,{ref:t,type:`file`,accept:`image/*`,"aria-label":`Insert image`,style:{display:`none`},onChange:t=>{tX(e.view,t.target.files),t.target.value=``}})]})}function iX(){let{id:e,docId:t}=aX.useParams(),n=Di(),{data:r,isLoading:i,error:a}=Ga(e),{data:o,isLoading:s,error:c}=ro(t),l=io(),u=ao(),[d,f]=(0,V.useState)(`editor`);return i||s?(0,H.jsx)(`p`,{children:`Loading document…`}):a===null?c===null?r===void 0?(0,H.jsx)(`p`,{children:`Project not found.`}):o===void 0?(0,H.jsx)(`p`,{children:`Document not found.`}):o.project_id===e?(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`p`,{children:(0,H.jsxs)(Vi,{to:`/projects/$id/overview`,params:{id:e},style:{color:`#555`},children:[`← `,r.name]})}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,marginBottom:`1rem`},children:[(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(`reader`)},"aria-pressed":d===`reader`,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:d===`reader`?`#e5e7eb`:`#fff`,fontWeight:d===`reader`?600:400,cursor:`pointer`},children:`Reader`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{f(`editor`)},"aria-pressed":d===`editor`,style:{padding:`0.375rem 0.75rem`,borderRadius:6,border:`1px solid #d1d5db`,background:d===`editor`?`#e5e7eb`:`#fff`,fontWeight:d===`editor`?600:400,cursor:`pointer`},children:`Editor`})]}),l.error===null?null:(0,H.jsxs)(`p`,{role:`alert`,style:{color:`#b91c1c`},children:[`Save failed: `,l.error.message]}),(0,H.jsxs)(`div`,{style:{display:`flex`,gap:`1rem`,alignItems:`flex-start`},children:[(0,H.jsx)(`div`,{style:{flex:1,minWidth:0},children:(0,H.jsx)(nX,{document:o,mode:d,isSaving:l.isPending,isDeleting:u.isPending,onSave:e=>{l.mutate({id:t,input:e})},onDelete:()=>{u.mutate({id:t,projectId:e},{onSuccess:()=>{n({to:`/projects/$id/overview`,params:{id:e}})}})}})}),(0,H.jsx)(oA,{documentId:t,projectId:e})]})]}):(0,H.jsx)(`p`,{role:`alert`,children:`Document does not belong to this project.`}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load document: `,c.message]}):(0,H.jsxs)(`p`,{role:`alert`,children:[`Failed to load project: `,a.message]})}var aX=qi(`/projects/$id/documents/$docId`)({component:iX}),oX=bo.update({id:`/`,path:`/`,getParentRoute:()=>vo}),sX=To.update({id:`/settings/mcp`,path:`/settings/mcp`,getParentRoute:()=>vo}),cX=gu.update({id:`/p/$shareToken`,path:`/p/$shareToken`,getParentRoute:()=>vo}),lX=yu.update({id:`/projects/$id/overview`,path:`/projects/$id/overview`,getParentRoute:()=>vo}),uX=JE.update({id:`/projects/$id/flow`,path:`/projects/$id/flow`,getParentRoute:()=>vo}),dX={IndexRoute:oX,PShareTokenRoute:cX,SettingsMcpRoute:sX,ProjectsIdBoardRoute:nA.update({id:`/projects/$id/board`,path:`/projects/$id/board`,getParentRoute:()=>vo}),ProjectsIdFlowRoute:uX,ProjectsIdOverviewRoute:lX,ProjectsIdDocumentsDocIdRoute:aX.update({id:`/projects/$id/documents/$docId`,path:`/projects/$id/documents/$docId`,getParentRoute:()=>vo})},fX=vo._addFileChildren(dX)._addFileTypes(),pX=new Re,mX=ca({routeTree:fX}),hX=document.getElementById(`root`);hX!==null&&(0,fa.createRoot)(hX).render((0,H.jsx)(V.StrictMode,{children:(0,H.jsx)(He,{client:pX,children:(0,H.jsx)(da,{router:mX})})}));
|