PageSourceSearch

https://forwardint.macaly-app.com/assets/index-CrGJrGSq.js

js forwardint.macaly-app.com collected 2026-10-03 04:59:17 UTC 486,103 bytes, 150 lines download raw bytes

1import{r as v,R as J,k as m,v as Yh,b as Zh,u as Xh,n as ee,g as U,p as qe,L as Qh}from"./index-BgC-7ug5.js";import{s as yc}from"./index-BHYsOjCv.js";import{L as bc,a as ef}from"./locations-CG0VzcvW.js";import{a as Ln,g as vs,H as Ta}from"./housereel-categories-ZL4AWXWr.js";var Bo={x:0,y:0,width:0,height:0,unit:"px"},ln=(n,e,t)=>Math.min(Math.max(n,e),t),tf=(...n)=>n.filter(e=>e&&typeof e=="string").join(" "),Aa=(n,e)=>n===e||n.width===e.width&&n.height===e.height&&n.x===e.x&&n.y===e.y&&n.unit===e.unit;function ws(n,e,t,r){let i=Fe(n,t,r);return n.width&&(i.height=i.width/e),n.height&&(i.width=i.height*e),i.y+i.height>r&&(i.height=r-i.y,i.width=i.height*e),i.x+i.width>t&&(i.width=t-i.x,i.height=i.width/e),n.unit==="%"?Ct(i,t,r):i}function Ss(n,e,t){let r=Fe(n,e,t);return r.x=(e-r.width)/2,r.y=(t-r.height)/2,n.unit==="%"?Ct(r,e,t):r}function Ct(n,e,t){return n.unit==="%"?{...Bo,...n,unit:"%"}:{unit:"%",x:n.x?n.x/e*100:0,y:n.y?n.y/t*100:0,width:n.width?n.width/e*100:0,height:n.height?n.height/t*100:0}}function Fe(n,e,t){return!n.unit||n.unit==="px"?{...Bo,...n,unit:"px"}:{unit:"px",x:n.x?n.x*e/100:0,y:n.y?n.y*t/100:0,width:n.width?n.width*e/100:0,height:n.height?n.height*t/100:0}}function Oa(n,e,t,r,i,s=0,o=0,a=r,l=i){let c={...n},d=Math.min(s,r),u=Math.min(o,i),f=Math.min(a,r),h=Math.min(l,i);e&&(e>1?(d=o?o*e:d,u=d/e,f=a*e):(u=s?s/e:u,d=u*e,h=l/e)),c.y<0&&(c.height=Math.max(c.height+c.y,u),c.y=0),c.x<0&&(c.width=Math.max(c.width+c.x,d),c.x=0);let p=r-(c.x+c.width);p<0&&(c.x=Math.min(c.x,r-d),c.width+=p);let y=i-(c.y+c.height);if(y<0&&(c.y=Math.min(c.y,i-u),c.height+=y),c.width<d&&((t==="sw"||t=="nw")&&(c.x-=d-c.width),c.width=d),c.height<u&&((t==="nw"||t=="ne")&&(c.y-=u-c.height),c.height=u),c.width>f&&((t==="sw"||t=="nw")&&(c.x-=f-c.width),c.width=f),c.height>h&&((t==="nw"||t=="ne")&&(c.y-=h-c.height),c.height=h),e){let g=c.width/c.height;if(g<e){let b=Math.max(c.width/e,u);(t==="nw"||t=="ne")&&(c.y-=b-c.height),c.height=b}else if(g>e){let b=Math.max(c.height*e,d);(t==="sw"||t=="nw")&&(c.x-=b-c.width),c.width=b}}return c}function nf(n,e,t,r){let i={...n};return e==="ArrowLeft"?r==="nw"?(i.x-=t,i.y-=t,i.width+=t,i.height+=t):r==="w"?(i.x-=t,i.width+=t):r==="sw"?(i.x-=t,i.width+=t,i.height+=t):r==="ne"?(i.y+=t,i.width-=t,i.height-=t):r==="e"?i.width-=t:r==="se"&&(i.width-=t,i.height-=t):e==="ArrowRight"&&(r==="nw"?(i.x+=t,i.y+=t,i.width-=t,i.height-=t):r==="w"?(i.x+=t,i.width-=t):r==="sw"?(i.x+=t,i.width-=t,i.height-=t):r==="ne"?(i.y-=t,i.width+=t,i.height+=t):r==="e"?i.width+=t:r==="se"&&(i.width+=t,i.height+=t)),e==="ArrowUp"?r==="nw"?(i.x-=t,i.y-=t,i.width+=t,i.height+=t):r==="n"?(i.y-=t,i.height+=t):r==="ne"?(i.y-=t,i.width+=t,i.height+=t):r==="sw"?(i.x+=t,i.width-=t,i.height-=t):r==="s"?i.height-=t:r==="se"&&(i.width-=t,i.height-=t):e==="ArrowDown"&&(r==="nw"?(i.x+=t,i.y+=t,i.width-=t,i.height-=t):r==="n"?(i.y+=t,i.height-=t):r==="ne"?(i.y+=t,i.width-=t,i.height-=t):r==="sw"?(i.x-=t,i.width+=t,i.height+=t):r==="s"?i.height+=t:r==="se"&&(i.width+=t,i.height+=t)),i}var cn={capture:!0,passive:!1},rf=0,Ia=class Xe extends v.PureComponent{static xOrds=["e","w"];static yOrds=["n","s"];static xyOrds=["nw","ne","se","sw"];static nudgeStep=1;static nudgeStepMedium=10;static nudgeStepLarge=100;static defaultProps={ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}};get document(){return document}docMoveBound=!1;mouseDownOnCrop=!1;dragStarted=!1;evData={startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0};componentRef=v.createRef();mediaRef=v.createRef();resizeObserver;initChangeCalled=!1;instanceId=`rc-${rf++}`;state={cropIsActive:!1,newCropIsBeingDrawn:!1};getBox(){let e=this.mediaRef.current;if(!e)return{x:0,y:0,width:0,height:0};let{x:t,y:r,width:i,height:s}=e.getBoundingClientRect();return{x:t,y:r,width:i,height:s}}componentDidUpdate(e){let{crop:t,onComplete:r}=this.props;if(r&&!e.crop&&t){let{width:i,height:s}=this.getBox();i&&s&&r(Fe(t,i,s),Ct(t,i,s))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||=(this.document.addEventListener("pointermove",this.onDocPointerMove,cn),this.document.addEventListener("pointerup",this.onDocPointerDone,cn),this.document.addEventListener("pointercancel",this.onDocPointerDone,cn),!0)}unbindDocMove(){this.docMoveBound&&=(this.document.removeEventListener("pointermove",this.onDocPointerMove,cn),this.document.removeEventListener("pointerup",this.onDocPointerDone,cn),this.document.removeEventListener("pointercancel",this.onDocPointerDone,cn),!1)}onCropPointerDown=e=>{let{crop:t,disabled:r}=this.props,i=this.getBox();if(!t)return;let s=Fe(t,i.width,i.height);if(r)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let o=e.target.dataset.ord,a=!!o,l=e.clientX,c=e.clientY,d=s.x,u=s.y;if(o){let f=e.clientX-i.x,h=e.clientY-i.y,p=0,y=0;o==="ne"||o=="e"?(p=f-(s.x+s.width),y=h-s.y,d=s.x,u=s.y+s.height):o==="se"||o==="s"?(p=f-(s.x+s.width),y=h-(s.y+s.height),d=s.x,u=s.y):o==="sw"||o=="w"?(p=f-s.x,y=h-(s.y+s.height),d=s.x+s.width,u=s.y):(o==="nw"||o=="n")&&(p=f-s.x,y=h-s.y,d=s.x+s.width,u=s.y+s.height),l=d+i.x+p,c=u+i.y+y}this.evData={startClientX:l,startClientY:c,startCropX:d,startCropY:u,clientX:e.clientX,clientY:e.clientY,isResize:a,ord:o},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})};onComponentPointerDown=e=>{let{crop:t,disabled:r,locked:i,keepSelection:s,onChange:o}=this.props,a=this.getBox();if(r||i||s&&t)return;e.cancelable&&e.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});let l=e.clientX-a.x,c=e.clientY-a.y,d={unit:"px",x:l,y:c,width:0,height:0};this.evData={startClientX:e.clientX,startClientY:e.clientY,startCropX:l,startCropY:c,clientX:e.clientX,clientY:e.clientY,isResize:!0},this.mouseDownOnCrop=!0,o(Fe(d,a.width,a.height),Ct(d,a.width,a.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})};onDocPointerMove=e=>{let{crop:t,disabled:r,onChange:i,onDragStart:s}=this.props,o=this.getBox();if(r||!t||!this.mouseDownOnCrop)return;e.cancelable&&e.preventDefault(),this.dragStarted||(this.dragStarted=!0,s&&s(e));let{evData:a}=this;a.clientX=e.clientX,a.clientY=e.clientY;let l;l=a.isResize?this.resizeCrop():this.dragCrop(),Aa(t,l)||i(Fe(l,o.width,o.height),Ct(l,o.width,o.height))};onComponentKeyDown=e=>{let{crop:t,disabled:r,onChange:i,onComplete:s}=this.props;if(r)return;let o=e.key,a=!1;if(!t)return;let l=this.getBox(),c=this.makePixelCrop(l),d=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?Xe.nudgeStepLarge:e.shiftKey?Xe.nudgeStepMedium:Xe.nudgeStep;if(o==="ArrowLeft"?(c.x-=d,a=!0):o==="ArrowRight"?(c.x+=d,a=!0):o==="ArrowUp"?(c.y-=d,a=!0):o==="ArrowDown"&&(c.y+=d,a=!0),a){e.cancelable&&e.preventDefault(),c.x=ln(c.x,0,l.width-c.width),c.y=ln(c.y,0,l.height-c.height);let u=Fe(c,l.width,l.height),f=Ct(c,l.width,l.height);i(u,f),s&&s(u,f)}};onHandlerKeyDown=(e,t)=>{let{aspect:r=0,crop:i,disabled:s,minWidth:o=0,minHeight:a=0,maxWidth:l,maxHeight:c,onChange:d,onComplete:u}=this.props,f=this.getBox();if(s||!i)return;if(e.key==="ArrowUp"||e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight")e.stopPropagation(),e.preventDefault();else return;let h=(navigator.platform.match("Mac")?e.metaKey:e.ctrlKey)?Xe.nudgeStepLarge:e.shiftKey?Xe.nudgeStepMedium:Xe.nudgeStep,p=Oa(nf(Fe(i,f.width,f.height),e.key,h,t),r,t,f.width,f.height,o,a,l,c);if(!Aa(i,p)){let y=Ct(p,f.width,f.height);d(p,y),u&&u(p,y)}};onDocPointerDone=e=>{let{crop:t,disabled:r,onComplete:i,onDragEnd:s}=this.props,o=this.getBox();this.unbindDocMove(),!(r||!t)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,s&&s(e),i&&i(Fe(t,o.width,o.height),Ct(t,o.width,o.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))};onDragFocus=()=>{this.componentRef.current?.scrollTo(0,0)};getCropStyle(){let{crop:e}=this.props;if(e)return{top:`${e.y}${e.unit}`,left:`${e.x}${e.unit}`,width:`${e.width}${e.unit}`,height:`${e.height}${e.unit}`}}dragCrop(){let{evData:e}=this,t=this.getBox(),r=this.makePixelCrop(t),i=e.clientX-e.startClientX,s=e.clientY-e.startClientY;
1return r.x=ln(e.startCropX+i,0,t.width-r.width),r.y=ln(e.startCropY+s,0,t.height-r.height),r}getPointRegion(e,t,r,i){let{evData:s}=this,o=s.clientX-e.x,a=s.clientY-e.y,l;l=i&&t?t==="nw"||t==="n"||t==="ne":a<s.startCropY;let c;return c=r&&t?t==="nw"||t==="w"||t==="sw":o<s.startCropX,c?l?"nw":"sw":l?"ne":"se"}resolveMinDimensions(e,t,r=0,i=0){let s=Math.min(r,e.width),o=Math.min(i,e.height);return!t||!s&&!o?[s,o]:t>1?s?[s,s/t]:[o*t,o]:o?[o*t,o]:[s,s/t]}resizeCrop(){let{evData:e}=this,{aspect:t=0,maxWidth:r,maxHeight:i}=this.props,s=this.getBox(),[o,a]=this.resolveMinDimensions(s,t,this.props.minWidth,this.props.minHeight),l=this.makePixelCrop(s),c=this.getPointRegion(s,e.ord,o,a),d=e.ord||c,u=e.clientX-e.startClientX,f=e.clientY-e.startClientY;(o&&d==="nw"||d==="w"||d==="sw")&&(u=Math.min(u,-o)),(a&&d==="nw"||d==="n"||d==="ne")&&(f=Math.min(f,-a));let h={unit:"px",x:0,y:0,width:0,height:0};c==="ne"?(h.x=e.startCropX,h.width=u,t?(h.height=h.width/t,h.y=e.startCropY-h.height):(h.height=Math.abs(f),h.y=e.startCropY-h.height)):c==="se"?(h.x=e.startCropX,h.y=e.startCropY,h.width=u,t?h.height=h.width/t:h.height=f):c==="sw"?(h.x=e.startCropX+u,h.y=e.startCropY,h.width=Math.abs(u),t?h.height=h.width/t:h.height=f):c==="nw"&&(h.x=e.startCropX+u,h.width=Math.abs(u),t?(h.height=h.width/t,h.y=e.startCropY-h.height):(h.height=Math.abs(f),h.y=e.startCropY+f));let p=Oa(h,t,c,s.width,s.height,o,a,r,i);return t||Xe.xyOrds.indexOf(d)>-1?l=p:Xe.xOrds.indexOf(d)>-1?(l.x=p.x,l.width=p.width):Xe.yOrds.indexOf(d)>-1&&(l.y=p.y,l.height=p.height),l.x=ln(l.x,0,s.width-l.width),l.y=ln(l.y,0,s.height-l.height),l}renderCropSelection(){let{ariaLabels:e=Xe.defaultProps.ariaLabels,disabled:t,locked:r,renderSelectionAddon:i,ruleOfThirds:s,crop:o}=this.props,a=this.getCropStyle();if(o)return J.createElement("div",{style:a,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":e.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!t&&!r&&J.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},J.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),J.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),J.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),J.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":e.nwDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"nw"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":e.nDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"n"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":e.neDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"ne"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":e.eDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"e"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":e.seDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"se"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":e.sDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"s"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":e.swDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"sw"),role:"button"}),J.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":e.wDragHandle,onKeyDown:l=>this.onHandlerKeyDown(l,"w"),role:"button"})),i&&J.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:l=>l.stopPropagation()},i(this.state)),s&&J.createElement(J.Fragment,null,J.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),J.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(e){return Fe({...Bo,...this.props.crop||{}},e.width,e.height)}render(){let{aspect:e,children:t,circularCrop:r,className:i,crop:s,disabled:o,locked:a,style:l,ruleOfThirds:c}=this.props,{cropIsActive:d,newCropIsBeingDrawn:u}=this.state,f=s?this.renderCropSelection():null,h=tf("ReactCrop",i,d&&"ReactCrop--active",o&&"ReactCrop--disabled",a&&"ReactCrop--locked",u&&"ReactCrop--new-crop",s&&e&&"ReactCrop--fixed-aspect",s&&r&&"ReactCrop--circular-crop",s&&c&&"ReactCrop--rule-of-thirds",!this.dragStarted&&s&&!s.width&&!s.height&&"ReactCrop--invisible-crop",r&&"ReactCrop--no-animate");return J.createElement("div",{ref:this.componentRef,className:h,style:l},J.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},t),s?J.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},J.createElement("defs",null,J.createElement("mask",{id:`hole-${this.instanceId}`},J.createElement("rect",{width:"100%",height:"100%",fill:"white"}),r?J.createElement("ellipse",{cx:`${s.x+s.width/2}${s.unit}`,cy:`${s.y+s.height/2}${s.unit}`,rx:`${s.width/2}${s.unit}`,ry:`${s.height/2}${s.unit}`,fill:"black"}):J.createElement("rect",{x:`${s.x}${s.unit}`,y:`${s.y}${s.unit}`,width:`${s.width}${s.unit}`,height:`${s.height}${s.unit}`,fill:"black"}))),J.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,f)}};function Pn(n,e,t,r,i){return new Promise((s,o)=>
1{const a=n.naturalWidth/e.renderedW,l=n.naturalHeight/e.renderedH,c=e.pixelCrop.x*a,d=e.pixelCrop.y*l,u=e.pixelCrop.width*a,f=e.pixelCrop.height*l;if(u<=0||f<=0)return o(new Error(`Neplatný ořez: srcW=${u} srcH=${f}`));const h=Math.min(1,t/u,r/f),p=Math.round(u*h),y=Math.round(f*h),g=document.createElement("canvas");g.width=p,g.height=y;const b=g.getContext("2d");if(!b)return o(new Error("Canvas context unavailable"));b.drawImage(n,c,d,u,f,0,0,p,y),g.toBlob(k=>{if(!k)return o(new Error("toBlob failed"));s({blob:k,width:p,height:y})},"image/webp",i)})}function no({file:n,fileIndex:e,fileTotal:t,onConfirm:r,onSkip:i,onCancel:s}){const[o,a]=v.useState("landscape"),[l,c]=v.useState(!1),[d,u]=v.useState({unit:"%",width:90,height:50.625,x:5,y:24.69}),[f,h]=v.useState({unit:"%",width:50.625,height:90,x:24.69,y:5}),[p,y]=v.useState(null),[g,b]=v.useState(null),[k,N]=v.useState(!1),[A,S]=v.useState(!1),I=v.useRef(null),O=v.useRef(null),L=v.useRef("");L.current||(L.current=URL.createObjectURL(n));const C=L.current;v.useEffect(()=>{const j=L.current;return()=>{j&&URL.revokeObjectURL(j)}},[]);const D=v.useCallback(j=>{const P=j.currentTarget,q=P.width,X=P.height;console.log("Landscape image loaded:",q,"x",X,"| natural:",P.naturalWidth,"x",P.naturalHeight);const w=Ss(ws({unit:"%",width:90},16/9,q,X),q,X);u(w);const Y=Fe(w,q,X);y({pixelCrop:Y,renderedW:q,renderedH:X})},[]),Z=v.useCallback(j=>{const P=j.currentTarget,q=P.width,X=P.height;if(console.log("Mobile image loaded:",q,"x",X,"| natural:",P.naturalWidth,"x",P.naturalHeight),q===0||X===0)return;const w=Ss(ws({unit:"%",width:45},9/16,q,X),q,X);h(w);const Y=Fe(w,q,X);b({pixelCrop:Y,renderedW:q,renderedH:X})},[]),G=v.useCallback(()=>{a("mobile"),c(!0);const j=O.current;if(j&&j.naturalWidth>0&&!g){const P=j.clientWidth||j.width,q=j.clientHeight||j.height,X=P>0?P:j.naturalWidth,w=q>0?q:j.naturalHeight,Y=Ss(ws({unit:"%",width:45},9/16,X,w),X,w);h(Y);const re=Fe(Y,X,w);b({pixelCrop:re,renderedW:X,renderedH:w})}},[g]),W=v.useCallback(async()=>{const j=I.current;if(!(!j||!p)){N(!0);try{console.log("Cropping landscape only:",p);const[P,q]=await Promise.all([Pn(j,p,1920,1080,.85),Pn(j,p,400,225,.7)]);r({landscapeBlob:P.blob,landscapeWidth:P.width,landscapeHeight:P.height,thumbBlob:q.blob})}catch(P){console.error("Landscape-only crop failed:",P)}finally{N(!1)}}},[p,r]),E=v.useCallback(async()=>{if(o==="landscape"){G();return}const j=I.current,P=O.current;if(!j||!p||!g){console.error("Missing refs or crop data",{imgL:!!j,imgM:!!P,cropDataLandscape:p,cropDataMobile:g});return}N(!0);try{console.log("Cropping landscape:",p),console.log("Cropping mobile:",g);const[q,X,w]=await Promise.all([Pn(j,p,1920,1080,.85),Pn(P??j,g,1080,1920,.85),Pn(j,p,400,225,.7)]);r({landscapeBlob:q.blob,landscapeWidth:q.width,landscapeHeight:q.height,mobileBlob:X.blob,mobileWidth:X.width,mobileHeight:X.height,thumbBlob:w.blob})}catch(q){console.error("Crop failed:",q)}finally{N(!1)}},[o,p,g,G,r]),$=o==="landscape"?!!p:!!p&&!!g;return m.jsx("div",{className:"crop-modal-backdrop",children:m.jsxs("div",{className:"crop-modal",children:[m.jsxs("div",{className:"crop-modal-header",children:[m.jsxs("div",{className:"crop-modal-title",children:[m.jsx("span",{className:"crop-modal-filename",children:n.name}),t>1&&m.jsxs("span",{className:"crop-modal-counter",children:[e+1," / ",t]})]}),m.jsx("button",{className:"media-modal-close",onClick:s,title:"Zrušit nahrávání",children:"✕"})]}),m.jsxs("div",{className:"crop-tabs",children:[m.jsx("button",{className:`crop-tab${o==="landscape"?" crop-tab--active":""}`,onClick:()=>a("landscape"),children:"① Landscape 16:9"}),m.jsx("button",{className:`crop-tab${o==="mobile"?" crop-tab--active":""}`,onClick:G,children:"② Mobil na výšku 9:16"})]}),m.jsxs("div",{className:"crop-canvas-wrap",children:[m.jsx("div",{style:{display:o==="landscape"?"flex":"none",justifyContent:"center",width:"100%"},children:m.jsx(Ia,{crop:d,onChange:j=>u(j),onComplete:j=>{const P=I.current;!P||P.width===0||y({pixelCrop:j,renderedW:P.width,renderedH:P.height})},aspect:16/9,minWidth:50,children:m.jsx("img",{ref:I,src:C,alt:n.name,className:"crop-preview-img",onLoad:D})})}),l&&m.jsx("div",{style:{display:o==="mobile"?"flex":"none",justifyContent:"center",width:"100%"},children:m.jsx(Ia,{crop:f,onChange:j=>h(j),onComplete:j=>{const P=O.current;!P||P.width===0||b({pixelCrop:j,renderedW:P.width,renderedH:P.height})},aspect:9/16,minWidth:40,children:m.jsx("img",{ref:O,src:C,alt:n.name,className:"crop-preview-img",onLoad:Z})})})]}),e<t-1&&m.jsxs("label",{className:"crop-skip-remaining",children:[m.jsx("input",{type:"checkbox",checked:A,onChange:j=>S(j.target.checked)}),"Přeskočit ořez i u dalších ",t-e-1," souborů v této dávce"]}),m.jsxs("div",{className:"crop-modal-actions",children:[m.jsx("button",{className:"admin-btn admin-btn--ghost",onClick:()=>i(A),disabled:k,children:A?"Přeskočit ořez u zbytku dávky":"Přeskočit ořez"}),o==="landscape"&&m.jsx("button",{className:"admin-btn admin-btn--secondary",onClick:()=>{W()},disabled:k||!p,title:"Uloží pouze landscape verzi bez mobilní varianty",children:k?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"admin-spinner admin-spinner--xs",style:{marginRight:"0.4rem"}})," Zpracovávám…"]}):"Uložit Landscape"}),m.jsx("button",{className:"admin-btn admin-btn--primary",onClick:()=>{E()},disabled:k||!$,children:k?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"admin-spinner admin-spinner--xs",style:{marginRight:"0.4rem"}})," Zpracovávám…"]}):o==="landscape"?"Pokračovat na Mobil →":"Nahrát obrázek ↑"})]}),m.jsx("p",{className:"crop-modal-hint",children:o==="landscape"?"Upravte výřez 16:9. Uložte jen L
1andscape, nebo pokračujte na mobilní variantu.":'Nastavte portrait výřez 9:16 pro mobilní zobrazení, pak klikněte „Nahrát obrázek".'})]})})}function ke(n){this.content=n}ke.prototype={constructor:ke,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new ke(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new ke(t)},addToStart:function(n,e){return new ke([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ke(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new ke(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=ke.from(n),n.size?new ke(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ke.from(n),n.size?new ke(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ke.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};ke.from=function(n){if(n instanceof ke)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ke(e)};function kc(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){let o=i.text,a=s.text,l=0;for(;o[l]==a[l];l++)t++;return l&&l<o.length&&l<a.length&&wc(o.charCodeAt(l-1))&&vc(o.charCodeAt(l))&&t--,t}if(i.content.size||s.content.size){let o=kc(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function xc(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){t-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:t,b:r};if(o.isText&&o.text!=a.text){let c=o.text,d=a.text,u=c.length,f=d.length;for(;u>0&&f>0&&c[u-1]==d[f-1];)u--,f--,t--,r--;return u&&f&&u<c.length&&wc(c.charCodeAt(u-1))&&vc(c.charCodeAt(u))&&(t++,r++),{a:t,b:r}}if(o.content.size||a.content.size){let c=xc(o.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}function vc(n){return n>=56320&&n<57344}function wc(n){return n>=55296&&n<56320}let T=class Te{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,a=0;a<t;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new Te(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),r.push(a),i+=a.nodeSize),o=l}return new Te(r,i)}cutByIndex(e,t){return e==t?Te.empty:e==0&&t==this.content.length?this:new Te(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;
vendor: 8,965 bytes, line 1
1let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new Te(i,s)}addToStart(e){return new Te([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Te(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return kc(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return xc(this,e,t,r)}findIndex(e){if(e==0)return Pr(0,e);if(e==this.size)return Pr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?Pr(t+1,s):Pr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return Te.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return Te.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Te.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new Te(t||e,r)}static from(e){if(!e)return Te.empty;if(e instanceof Te)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Te([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};T.empty=new T([],0);const Cs={index:0,offset:0};function Pr(n,e){return Cs.index=n,Cs.offset=e,Cs}function ui(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ui(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ui(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let te=class ro{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ui(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ro.none;if(e instanceof ro)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};te.none=[];let hi=class extends Error{},R=class hn{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Cc(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new hn(r,this.openStart,this.openEnd)}removeBetween(e,t){return new hn(Sc(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return hn.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new hn(T.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new hn(e,r,i)}};R.empty=new R(T.empty,0,0);function Sc(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:a}=n.findIndex(t);if(i==e||s.isText){if(a!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Sc(s.content,e-i-1,t-i-1)))}function Cc(n,e,t,r,i,s){let{index:o,offset:a}=n.findIndex(e),l=n.maybeChild(o);if(a==e||l.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Cc(l.content,e-a-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,l);return c&&n.replaceChild(o,l.copy(c))}function sf(n,e,t){if(t.openStart>n.depth)throw new hi("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new hi("Inconsistent open depths");return Nc(n,e,t,0)}function Nc(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Nc(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,a=o.content;return qt(o,a.cut(0,n.parentOffset).append(t.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=of(t,n);return qt(s,Mc(n,o,a,e,r))}else return qt(s,fi(n,e,r))}function Ec(n,e){if(!e.type.compatibleContent(n.type))throw new hi("Cannot join "+e.type.name+" onto "+n.type.name)}function io(n,e,t){let r=n.node(t);return Ec(r,e.node(t)),r}function Kt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function ir(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Kt(n.nodeAfter,r),s++));for(let a=s;a<o;a++)Kt(i.child(a),r);e&&e.depth==t&&e.textOffset&&Kt(e.nodeBefore,r)}function qt(n,e){return n.type.checkContent(e),n.copy(e)}function Mc(n,e,t,r,i){let s=n.depth>i&&io(n,e,i+1),o=r.depth>i&&io(t,r,i+1),a=[];return ir(null,n,i,a),s&&o&&e.index(i)==t.index(i)?(Ec(s,o),Kt(qt(s,Mc(n,e,t,r,i+1)),a)):(s&&Kt(qt(s,fi(n,e,i+1)),a),ir(e,t,i,a),o&&Kt(qt(o,fi(t,r,i+1)),a)),ir(r,null,i,a),new T(a)}function fi(n,e,t){let r=[];if(ir(null,n,t,r),n.depth>t){let i=io(n,e,t+1);Kt(qt(i,fi(n,e,t+1)),r)}return ir(e,null,t,r),new T(r)}function of(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(T.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class yr{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();
vendor: 12,386 bytes, lines 1-2
1if(e.content.size==0)return te.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let a=r;r=i,i=a}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new pi(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),c=s-l;if(r.push(o,a,i+l),!c||(o=o.child(a),o.isText))break;s=c-1,i+=l+1}return new yr(t,r,s)}static resolveCached(e,t){let r=Da.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==t)return o}else Da.set(e,r=new af);let i=r.elts[r.i]=yr.resolve(e,t);return r.i=(r.i+1)%lf,i}}class af{constructor(){this.elts=[],this.i=0}}const lf=12,Da=new WeakMap;class pi{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const cf=Object.create(null);class et{constructor(e,t,r,i=te.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||T.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ui(this.attrs,t||e.defaultAttrs||cf)&&te.sameSet(this.marks,r||te.none)}copy(e=null){return e==this.content?this:new et(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new et(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return R.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),a=i.start(o),c=i.node(o).content.cut(i.pos-a,s.pos-a);return new R(c,i.depth-o,s.depth-o)}replace(e,t,r){return sf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return yr.resolveCached(this,e)}resolveNoCache(e){return yr.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Tc(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=T.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=te.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!te.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=T.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}et.prototype.text=void 0;class mi extends et{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Tc(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new mi(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new mi(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Tc(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Zt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new df(e,t);if(r.next==null)return Zt.empty;let i=Ac(r);r.next&&r.err("Unexpected trailing text");let s=yf(gf(i));return bf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,a){let l=o.matchFragment(e,r);if(l&&(!t||l.validEnd))return T.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,a.concat(d));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
2`)}}Zt.empty=new Zt(!0);class df{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ac(n){let e=[];do e.push(uf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function uf(n){let e=[];do e.push(hf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function hf(n){let e=mf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=ff(n,e);else break;return e}function Ra(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function ff(n,e){let t=Ra(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ra(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function pf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function mf(n){if(n.eat("(")){let e=Ac(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=pf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function gf(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=s(o.exprs[l],a);if(l==o.exprs.length-1)return c;i(c,a=t())}else if(o.type=="star"){let l=t();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=t();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let d=t();i(s(o.expr,l),d),l=d}if(o.max==-1)i(s(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let d=t();r(l,d),i(s(o.expr,l),d),l=d}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Oc(n,e){return e-n}function ja(n,e){let t=[];return r(e),t.sort(Oc);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:a,to:l}=s[o];!a&&t.indexOf(l)==-1&&r(l)}}}function yf(n){let e=Object.create(null);return t(ja(n,0));function t(r){let i=[];r.forEach(o=>
vendor: 12,144 bytes, lines 2-3
2{n[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<i.length;d++)i[d][0]==a&&(c=i[d][1]);ja(n,l).forEach(d=>{c||i.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let s=e[r.join(",")]=new Zt(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let a=i[o][1].sort(Oc);s.next.push({type:i[o][0],next:e[a.join(",")]||t(a)})}return s}}function bf(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,o=[];for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];o.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ic(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Dc(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Rc(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${r}`);for(let i in n)n[i].validate&&n[i].validate(e[i])}function jc(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new xf(n,r,e[r]);return t}let La=class Lc{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=jc(e,r.attrs),this.defaultAttrs=Ic(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Zt.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:Dc(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new et(this,this.computeAttrs(e),T.from(t),te.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new et(this,this.computeAttrs(e),t,te.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=T.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(T.empty,!0);return s?new et(this,e,t.append(s),te.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Rc(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:te.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Lc(s,t,o));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function kf(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class xf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?kf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class ts{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=jc(e,i.attrs),this.excluded=null;let s=Ic(this.attrs);this.instance=s?new te(this,s):null}create(e=null){return!e&&this.instance?this.instance:new te(this,Dc(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new ts(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Rc(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Pc{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=ke.from(e.nodes),t.marks=ke.from(e.marks||{}),this.nodes=La.compile(this.spec.nodes,this),this.marks=ts.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Zt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?Pa(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:Pa(this,o.split(" "))}this.nodeFromJSON=i=>et.fromJSON(this,i),this.markFromJSON=i=>te.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof La){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new mi(r,r.defaultAttrs,e,te.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Pa(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let a in n.marks){let l=n.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function vf(n){return n.tag!=null}function wf(n){return n.style!=null}class At{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(vf(i))this.tags.push(i);else if(wf(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Ba(this,t,!1);return r.addAll(e,te.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ba(this,t,!0);return r.addAll(e,te.none,t.from,t.to),R.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Nf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let a=t[o];if((a.priority==null?50:a.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=$a(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=$a(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new At(e,At.schemaRules(e)))}}const zc={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},Sf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Bc={ol:!0,ul:!0},br=1,so=2,sr=4;function za(n,e,t){return e!=null?(e?br:0)|(e==="full"?so:0):n&&n.whitespace=="pre"?br|so:t&~sr}class zr{constructor(e,t,r,i,s,o){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=te.none,this.match=s||(o&sr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&br)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!zc.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ba{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=za(null,t.preserveWhitespace,0)|(r?sr:0);i?s=new zr(i.type,i.attrs,te.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new zr(null,null,te.none,!0,null,o):s=new zr(e.schema.topNodeType,null,te.none,!0,null,o),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&so?"full":this.localPreserveWS||(i.options&br)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
3`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),t,!0),a[l]&&this.insertNode(o.text(a[l]),t,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;Bc.hasOwnProperty(o)&&this.parser.normalizeLists&&Cf(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Sf.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;
vendor: 5,227 bytes, lines 3-4
3if(zc.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=l&&l.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4`),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 r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(s,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?t=t.filter(c=>!l.clearMark(c)):t=t.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return t}addElementByRule(e,t,r,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,t.attrs||null,r,t.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[t.mark];r=r.concat(l.create(t.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof t.contentElement=="string"?l=e.querySelector(t.contentElement):typeof t.contentElement=="function"?l=t.contentElement(e):t.contentElement&&(l=t.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,r){let i,s;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!i||i.length>c.length+a)&&(i=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=te.none;for(let a of i.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Fa(a.type,e.type))&&(o=a.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=za(e,s,o.options);o.options&sr&&o.content.length==0&&(a|=sr);let l=te.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):Fa(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new zr(e,t,l,i,null,a)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=br)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let c=t[a];if(c==""){if(a==t.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let d=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];
vendor: 4,264 bytes, line 4
4if(r.isTextblock&&r.defaultAttrs)return r}}}function Cf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Bc.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Nf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function $a(n){let e={};for(let t in n)e[t]=n[t];return e}function Fa(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],o=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||s.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class rn{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Br(t).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let a=0,l=0;for(;a<s.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)i=s.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],d=this.serializeMark(c,o.isInline,t);d&&(s.push([c,i]),i.appendChild(d.dom),i=d.contentDOM||d.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){if(e.isText)return Br(t).createTextNode(e.text);let{dom:r,contentDOM:i}=Qr(Br(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Qr(Br(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:Qr(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new rn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ha(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ha(e.marks)}}function Ha(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Br(n){return n.document||window.document}const Ua=new WeakMap;function Ef(n){let e=Ua.get(n);return e===void 0&&Ua.set(n,e=Mf(n)),e}function Mf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function Qr(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ef(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let a,l=t?n.createElementNS(t,i):n.createElement(i),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?l.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof f=="string")l.appendChild(n.createTextNode(f));else{let{dom:h,contentDOM:p}=Qr(n,f,t,r);if(l.appendChild(h),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}const $c=65535,Fc=Math.pow(2,16);function Tf(n,e){return n+e*Fc}function Va(n){return n&$c}function Af(n){return(n-(n&$c))/Fc}const Hc=1,Uc=2,ei=4,Vc=8;let oo=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Vc)>0}get deletedBefore(){return(this.delInfo&(Hc|ei))>0}get deletedAfter(){return(this.delInfo&(Uc|ei))>0}get deletedAcross(){return(this.delInfo&ei)>0}},Xt=class fn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fn.empty)return fn.empty}recover(e){let t=0,r=Va(e);if(!this.inverted)for(let i=0;i<r;
vendor: 3,515 bytes, line 4
4i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Af(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+s],d=this.ranges[a+o],u=l+c;if(e<=u){let f=c?e==l?-1:e==u?1:t:t,h=l+i+(f<0?0:d);if(r)return h;let p=e==(t<0?l:u)?null:Tf(a/3,e-l),y=e==l?Uc:e==u?Hc:ei;return(t<0?e!=l:e!=u)&&(y|=Vc),new oo(h,y,p)}i+=d-c}return r?e+i:new oo(e+i,0,null)}touches(e,t){let r=0,i=Va(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],d=l+c;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),c=this.ranges[i+t],d=this.ranges[i+r];e(a,a+c,l,l+d),s+=d-c}}invert(){return new fn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fn.empty:new fn(e<0?[0,-e,0]:[0,0,e])}};Xt.empty=new Xt([]);class kr{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new kr(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new kr;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],a=o.mapResult(e,t);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new oo(e,i,null)}}const Ns=Object.create(null);let Ee=class{getMap(){return Xt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ns[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ns)throw new RangeError("Duplicate use of step JSON ID "+e);return Ns[e]=t,t.prototype.jsonID=e,t}},Oe=class Hn{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Hn(e,null)}static fail(e){return new Hn(null,e)}static fromReplace(e,t,r,i){try{return Hn.ok(e.replace(t,r,i))}catch(s){if(s instanceof hi)return Hn.fail(s.message);throw s}}};function $o(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy($o(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return T.fromArray(r)}
vendor: 5,279 bytes, line 4
4let Fo=class Un extends Ee{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new R($o(t.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return Oe.fromReplace(e,this.from,this.to,s)}invert(){return new In(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Un(t.pos,r.pos,this.mark)}merge(e){return e instanceof Un&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Un(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Un(t.from,t.to,e.markFromJSON(t.mark))}};Ee.jsonID("addMark",Fo);let In=class Vn extends Ee{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new R($o(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Oe.fromReplace(e,this.from,this.to,r)}invert(){return new Fo(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Vn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Vn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Vn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Vn(t.from,t.to,e.markFromJSON(t.mark))}};Ee.jsonID("removeMark",In);let Ho=class _n extends Ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Oe.fromReplace(e,this.pos,this.pos+1,new R(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new _n(this.pos,t.marks[i]);return new _n(this.pos,this.mark)}}return new gi(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new _n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new _n(t.pos,e.markFromJSON(t.mark))}};Ee.jsonID("addNodeMark",Ho);let gi=class ao extends Ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Oe.fromReplace(e,this.pos,this.pos+1,new R(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ho(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ao(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ao(t.pos,e.markFromJSON(t.mark))}};Ee.jsonID("removeNodeMark",gi);let Ye=class vt extends Ee{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&lo(e,this.from,this.to)?Oe.fail("Structure replace would overwrite content"):Oe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Xt([this.from,this.to-this.from,this.slice.size])}invert(e){return new vt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&vt.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new vt(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof vt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?R.empty:new R(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new vt(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?R.empty:new R(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new vt(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new vt(t.from,t.to,R.fromJSON(e,t.slice),!!t.structure)}};Ye.MAP_BIAS=1;Ee.jsonID("replace",Ye);
vendor: 2,395 bytes, line 4
4let Be=class ti extends Ee{constructor(e,t,r,i,s,o,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(lo(e,this.from,this.gapFrom)||lo(e,this.gapTo,this.to)))return Oe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Oe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Oe.fromReplace(e,this.from,this.to,r):Oe.fail("Content does not fit in gap")}getMap(){return new Xt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ti(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new ti(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ti(t.from,t.to,t.gapFrom,t.gapTo,R.fromJSON(e,t.slice),t.insert,!!t.structure)}};Ee.jsonID("replaceAround",Be);function lo(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function Of(n,e,t,r){let i=[],s=[],o,a;n.doc.nodesBetween(e,t,(l,c,d)=>{if(!l.isInline)return;let u=l.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,t),p=r.addToSet(u);for(let y=0;y<u.length;y++)u[y].isInSet(p)||(o&&o.to==f&&o.mark.eq(u[y])?o.to=h:i.push(o=new In(f,h,u[y])));a&&a.to==f?a.to=h:s.push(a=new Fo(f,h,r))}}
vendor: 5,958 bytes, lines 4-5
4),i.forEach(l=>n.step(l)),s.forEach(l=>n.step(l))}function If(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof ts){let c=o.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,t);for(let d=0;d<l.length;d++){let u=l[d],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(a,e),to:c,step:s})}}}),i.forEach(o=>n.step(new In(o.from,o.to,o.style)))}function Uo(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Ye(a,d,R.empty));else{r=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new In(a,d,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new R(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new Ye(a+f.index,a+f.index+f[0].length,p))}}a=d}if(!r.validEnd){let l=r.fillBefore(T.empty,!0);n.replace(a,a,new R(l,0,0))}for(let l=o.length-1;l>=0;l--)n.step(o[l])}function Df(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Dn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,i=0,s=0;;--r){let o=n.$from.node(r),a=n.$from.index(r)+i,l=n.$to.indexAfter(r)-s;if(r<n.depth&&o.canReplace(a,l,t))return r;if(r==0||o.type.spec.isolating||!Df(o,a,l))break;a&&(i=1),l<o.childCount&&(s=1)}return null}function Rf(n,e,t){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,c=a,d=T.empty,u=0;for(let p=s,y=!1;p>t;p--)y||r.index(p)>0?(y=!0,d=T.from(r.node(p).copy(d)),u++):l--;let f=T.empty,h=0;for(let p=s,y=!1;p>t;p--)y||i.after(p+1)<i.end(p)?(y=!0,f=T.from(i.node(p).copy(f)),h++):c++;n.step(new Be(l,c,o,a,new R(d.append(f),u,h),d.size-u,!0))}function Vo(n,e,t=null,r=n){let i=jf(n,e),s=i&&Lf(r,e);return s?i.map(_a).concat({type:e,attrs:t}).concat(s.map(_a)):null}function _a(n){return{type:n,attrs:null}}function jf(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Lf(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<i;c++)l=l.matchType(t.child(c).type);return!l||!l.validEnd?null:o}function Pf(n,e,t){let r=T.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let a=t[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=T.from(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new Be(i,s,i,s,new R(r,0,0),t.length,!0))}function zf(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,l)&&Bf(n.doc,n.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Wc(n,o,a,s),Uo(n,n.mapping.slice(s).map(a,1),r,void 0,c===null);let d=n.mapping.slice(s),u=d.map(a,1),f=d.map(a+o.nodeSize,1);return n.step(new Be(u,f,u+1,f-1,new R(T.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&_c(n,o,a,s),!1}})}function _c(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function Wc(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
5`))}})}function Bf(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function $f(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Be(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new R(T.from(o),0,0),1,!0))}function mt(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>s;c--,d--){let u=i.node(c),f=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let y=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!y.type.validContent(h))return!1}let a=i.indexAfter(s),l=r&&r[0];return i.node(s).canReplaceWith(a,a,l?l.type:i.node(s+1).type)}function Ff(n,e,t=1,r){let i=n.doc.resolve(e),s=T.empty,o=T.empty;for(let a=i.depth,l=i.depth-t,c=t-1;a>l;a--,c--){s=T.from(i.node(a).copy(s));let d=r&&r[c];o=T.from(d?d.type.create(d.attrs,o):i.node(a).copy(o))}n.step(new Ye(e,e,new R(s.append(o),t,t),!0))}function Lt(n,e){let t=n.resolve(e),r=t.index();return Kc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Hf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Kc(n,e){return!!(n&&e&&!n.isLeaf&&Hf(n,e))}function ns(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,o,a=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):t>
vendor: 6,840 bytes, line 5
50?(s=r.node(i+1),a++,o=r.node(i).maybeChild(a)):(s=r.node(i).maybeChild(a-1),o=r.node(i+1)),s&&!s.isTextblock&&Kc(s,o)&&r.node(i).canReplace(a,a+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Uf(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);d&&!u?r=!1:!d&&u&&(r=!0)}let a=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);Wc(n,d.node(),d.before(),a)}o.inlineContent&&Uo(n,e+t-1,o,s.node().contentMatchAt(s.index()),r==null);let l=n.mapping.slice(a),c=l.map(e-t);if(n.step(new Ye(c,l.map(e+t,-1),R.empty,!0)),r===!0){let d=n.doc.resolve(c);_c(n,d.node(),d.before(),n.steps.length)}return n}function Vf(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function qc(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=r.depth;o>=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,l=r.index(o)+(a>0?1:0),c=r.node(o),d=!1;if(s==1)d=c.canReplace(l,l,i);else{let u=c.contentMatchAt(l).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(l,l,u[0])}if(d)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}return null}function rs(n,e,t=e,r=R.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return Jc(i,s,r)?new Ye(e,t,r):new _f(i,s,r).fit()}function Jc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class _f{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=T.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=T.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,a=i.depth;for(;o&&a&&s.childCount==1;)s=s.firstChild.content,o--,a--;let l=new R(s,o,a);return e>-1?new Be(r.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||r.pos!=this.$to.pos?new Ye(r.pos,i.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Es(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(T.from(o),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:u};if(t==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:d};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Es(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new R(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Es(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new R(Wn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new R(Wn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let y=0;y<s.length;y++)this.openFrontierNode(s[y]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));u=u.matchFragment(i)}let h=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let y=a.child(c),g=u.matchType(y.type);if(!g)break;c++,(c>1||l==0||y.content.size)&&(u=g,d.push(Gc(y.mark(f.allowedMarks(y.marks)),c==1?l:0,c==a.childCount?h:-1)))}let p=c==a.childCount;p||(h=-1),this.placed=Kn(this.placed,t,T.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,g=a;y<h;y++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?R.empty:new R(Wn(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new R(Wn(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ms(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Ms(e,t,i,r,s);if(o){for(let a=t-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=Ms(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Kn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Kn(this.placed,this.depth,T.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=Kn(this.placed,this.frontier.length,t))}}function Wn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Wn(n.firstChild.content,e-1,t)))}function Kn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Kn(n.lastChild.content,e-1,t)))}function Es(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Gc(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Gc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.t
vendor: 3,249 bytes, line 5
5ype.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),n.copy(r)}function Ms(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,o);return a&&!Wf(t,s.content,o)?a:null}function Wf(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Kf(n){return n.spec.defining||n.spec.definingForContent}function qf(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(Jc(i,s,r))return n.step(new Ye(e,t,r));let o=Zc(i,s);o[o.length-1]==0&&o.pop();let a=-(i.depth+1);o.unshift(a);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?a=f:i.before(f)==h&&o.splice(1,0,-f)}let l=o.indexOf(a),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=Kf(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(a)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let y=0;y<o.length;y++){let g=o[(y+l)%o.length],b=!0;g<0&&(b=!1,g=-g);let k=i.node(g-1),N=i.index(g-1);if(k.canReplaceWith(N,N,p.type,p.marks))return n.replace(i.before(g),b?s.after(g):t,new R(Yc(r.content,0,r.openStart,h),h,r.openEnd))}}let u=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function Yc(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Yc(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(T.empty,!0))}return n}function Jf(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Vf(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new R(T.from(r),0,0))}function Gf(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(t),a=!1;for(let l=r.depth;l>o;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=i.depth;l>o;l--)i.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&e==r.start(l);l--)e=r.before(l);for(let l=i.depth;l>0&&t==i.start(l);l--)t=i.before(l);r=n.doc.resolve(e),i=n.doc.resolve(t)}}let s=Zc(r,i);for(let o=0;o<s.length;o++){let a=s[o],l=o==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return n.delete(r.start(a),i.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),i.indexAfter(a-1))))return n.delete(r.before(a),i.after(a))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&t>r.end(o)&&i.end(o)-t!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return n.delete(r.before(o),t);n.delete(e,t)}function Zc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}
vendor: 2,078 bytes, line 5
5let Xc=class ni extends Ee{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Oe.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Oe.fromReplace(e,this.pos,this.pos+1,new R(T.from(i),0,t.isLeaf?0:1))}getMap(){return Xt.empty}invert(e){return new ni(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ni(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ni(t.pos,t.attr,t.value)}};Ee.jsonID("attr",Xc);let Qc=class co extends Ee{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Oe.ok(r)}getMap(){return Xt.empty}invert(e){return new co(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new co(t.attr,t.value)}};Ee.jsonID("docAttr",Qc);let wn=class extends Error{};wn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};wn.prototype=Object.create(Error.prototype);wn.prototype.constructor=wn;wn.prototype.name="TransformError";class ed{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new kr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new wn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let i=this.mapping.maps[r];
vendor: 2,817 bytes, line 5
5r&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,a,l)=>{e=Math.min(e,a),t=Math.max(t,l)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=R.empty){let i=rs(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new R(T.from(r),0,0))}delete(e,t){return this.replace(e,t,R.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return qf(this,e,t,r),this}replaceRangeWith(e,t,r){return Jf(this,e,t,r),this}deleteRange(e,t){return Gf(this,e,t),this}lift(e,t){return Rf(this,e,t),this}join(e,t=1){return Uf(this,e,t),this}wrap(e,t){return Pf(this,e,t),this}setBlockType(e,t=e,r,i=null){return zf(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return $f(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Xc(e,t,r)),this}setDocAttribute(e,t){return this.step(new Qc(e,t)),this}addNodeMark(e,t){return this.step(new Ho(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof te)t.isInSet(r.marks)&&this.step(new gi(e,t));else{let i=r.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new gi(e,s)),i=s.removeFromSet(i);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,t=1,r){return Ff(this,e,t,r),this}addMark(e,t,r){return Of(this,e,t,r),this}removeMark(e,t,r){return If(this,e,t,r),this}clearIncompatible(e,t,r){return Uo(this,e,t,r),this}}const Ts=Object.create(null);let V=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Yf(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=R.empty){let r=t.content.lastChild,i=null;for(let a=0;a<t.openEnd;a++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],d=e.mapping.slice(s);e.replaceRange(d.map(l.pos),d.map(c.pos),a?R.empty:t),a==0&&qa(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:a}=i[s],l=e.mapping.slice(r),c=l.map(o.pos),d=l.map(a.pos);s?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),qa(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new H(e):pn(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?pn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):pn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}
5static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new gt(e.node(0))}static atStart(e){return pn(e,e,0,0,1)||new gt(e)}static atEnd(e){return pn(e,e,e.content.size,e.childCount,-1)||new gt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ts[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ts)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ts[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}};V.prototype.visible=!0;let Yf=class{constructor(e,t){this.$from=e,this.$to=t}},Wa=!1;function Ka(n){!Wa&&!n.parent.inlineContent&&(Wa=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}let H=class qn extends V{constructor(e,t=e){Ka(e),Ka(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return V.near(r);let i=e.resolve(t.map(this.anchor));return new qn(i.parent.inlineContent?i:r,r)}replace(e,t=R.empty){if(super.replace(e,t),t==R.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new td(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new qn(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=V.findFrom(t,r,!0)||V.findFrom(t,-r,!0);if(s)t=s.$head;else return V.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(V.findFrom(e,-r,!0)||V.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new qn(e,t)}};V.jsonID("text",H);let td=class nd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new nd(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}},F=class Jn extends V{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?V.near(s):new Jn(s)}content(){return new R(T.from(this.node),0,0)}eq(e){return e instanceof Jn&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zf(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Jn(e.resolve(t.anchor))}static create(e,t){return new Jn(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};F.prototype.visible=!1;V.jsonID("node",F);let Zf=class rd{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new td(r,r):new rd(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&F.isSelectable(r)?new F(t):V.near(t)}},gt=class ri extends V{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=R.empty){if(t==R.empty){e.delete(0,e.doc.content.size);let r=V.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ri(e)}map(e){return new ri(e)}eq(e){return e instanceof ri}getBookmark(){return Xf}};V.jsonID("all",gt);const Xf={map(){return this},resolve(n){return new gt(n)}};function pn(n,e,t,r,i,s=!1){if(e.inlineContent)return H.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&F.isSelectable(a))return F.create(n,t-(i<0?a.nodeSize:0))}else{let l=pn(n,a,t+i,i<0?a.childCount:0,i,s);if(l)return l}t+=a.nodeSize*i}return null}function qa(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Ye||i instanceof Be))return;let s=n.mapping.maps[r],o;
vendor: 6,660 bytes, line 5
5s.forEach((a,l,c,d)=>{o==null&&(o=d)}),n.setSelection(V.near(n.doc.resolve(o),t))}const Ja=1,$r=2,Ga=4;class Qf extends ed{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ja)&~$r,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ja)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$r,this}ensureMarks(e){return te.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&$r)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~$r,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||te.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(V.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|=Ga,this}get scrolledIntoView(){return(this.updated&Ga)>0}}function Ya(n,e){return!e||!n?n:n.bind(e)}let Gn=class{constructor(e,t,r){this.name=e,this.init=Ya(t.init,r),this.apply=Ya(t.apply,r)}};const ep=[new Gn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Gn("selection",{init(n,e){return n.selection||V.atStart(e.doc)},apply(n){return n.selection}}),new Gn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Gn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class As{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ep.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Gn(r.key,r.spec.state,r))})}}class xn{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=i?i[o].n:0,c=i?i[o].state:this,d=l<t.length&&a.spec.appendTransaction.call(a,l?t.slice(l):t,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new xn(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Qf(this)}static create(e){let t=new As(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new xn(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new As(this.schema,e.plugins),r=t.fields,i=new xn(t);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new As(e.schema,e.plugins),s=new xn(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=et.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=V.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,a)){s[o.name]=c.fromJSON.call(l,e,t[a],s);return}}s[o.name]=o.init(e,s)}}),s}}function id(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=id(i,e,{})),t[r]=i}return t}class ae{constructor(e){this.spec=e,this.props={},e.props&&id(e.props,this,this.props),this.key=e.key?e.key.key:sd("plugin")}getState(e){return e[this.key]}}const Os=Object.create(null);function sd(n){return n in Os?n+"$"+ ++Os[n]:(Os[n]=0,n+"$")}class me{constructor(e="key"){this.key=sd(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const od=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const ld=(n,e,t)=>
vendor: 5,349 bytes, lines 5-6
5{let r=ad(n,t);if(!r)return!1;let i=_o(r);if(!i){let o=r.blockRange(),a=o&&Dn(o);return a==null?!1:(e&&e(n.tr.lift(o,a).scrollIntoView()),!0)}let s=i.nodeBefore;if(yd(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Sn(s,"end")||F.isSelectable(s)))for(let o=r.depth;;o--){let a=rs(n.doc,r.before(o),r.after(o),R.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=n.tr.step(a);l.setSelection(Sn(s,"end")?V.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):F.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},tp=(n,e,t)=>{let r=ad(n,t);if(!r)return!1;let i=_o(r);return i?cd(n,i,e):!1},np=(n,e,t)=>{let r=ud(n,t);if(!r)return!1;let i=Wo(r);return i?cd(n,i,e):!1};function cd(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=rs(n.doc,s,l,R.empty);if(!c||c.from!=s||c instanceof Ye&&c.slice.size>=l-s)return!1;if(t){let d=n.tr.step(c);d.setSelection(H.create(d.doc,s)),t(d.scrollIntoView())}return!0}function Sn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const dd=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=_o(r)}let o=s&&s.nodeBefore;return!o||!F.isSelectable(o)?!1:(e&&e(n.tr.setSelection(F.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function _o(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function ud(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const hd=(n,e,t)=>{let r=ud(n,t);if(!r)return!1;let i=Wo(r);if(!i)return!1;let s=i.nodeAfter;if(yd(n,i,e,1))return!0;if(r.parent.content.size==0&&(Sn(s,"start")||F.isSelectable(s))){let o=rs(n.doc,r.before(),r.after(),R.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=n.tr.step(o);a.setSelection(Sn(s,"start")?V.findFrom(a.doc.resolve(a.mapping.map(i.pos)),1):F.create(a.doc,a.mapping.map(i.pos))),e(a.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},fd=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Wo(r)}let o=s&&s.nodeAfter;return!o||!F.isSelectable(o)?!1:(e&&e(n.tr.setSelection(F.create(n.doc,s.pos)).scrollIntoView()),!0)};function Wo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const rp=(n,e)=>{let t=n.selection,r=t instanceof F,i;if(r){if(t.node.isTextblock||!Lt(n.doc,t.from))return!1;i=t.from}else if(i=ns(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(F.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},ip=(n,e)=>{let t=n.selection,r;if(t instanceof F){if(t.node.isTextblock||!Lt(n.doc,t.to))return!1;r=t.to}else if(r=ns(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},sp=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Dn(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},pd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
6`).scrollIntoView()),!0)};function Ko(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const op=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Ko(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let a=t.after(),l=n.tr.replaceWith(a,a,o.createAndFill());l.setSelection(V.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},md=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof gt||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ko(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,a=n.tr.insert(o,s.createAndFill());a.setSelection(H.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},gd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(mt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Dn(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function ap(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof F&&e.selection.node.isBlock)return!r.parentOffset||!mt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],o,a,l=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),a=Ko(r.
vendor: 8,151 bytes, line 6
6node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(l&&a?{type:a}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof H||e.selection instanceof gt)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=mt(d.doc,u,s.length,s);if(f||(s[0]=a?{type:a}:null,f=mt(d.doc,u,s.length,s)),!f)return!1;if(d.split(u,s.length,s),!l&&c&&r.node(o).type!=a){let h=d.mapping.map(r.before(o)),p=d.doc.resolve(h);a&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,a)&&d.setNodeMarkup(d.mapping.map(r.before(o)),a)}return t&&t(d.scrollIntoView()),!0}}const lp=ap(),cp=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(F.create(n.doc,i))),!0)};function dp(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Lt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function yd(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,o,a,l=i.type.spec.isolating||s.type.spec.isolating;if(!l&&dp(n,e,t))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&a.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=T.empty;for(let b=o.length-1;b>=0;b--)p=T.from(o[b].create(null,p));p=T.from(i.copy(p));let y=n.tr.step(new Be(e.pos-1,h,e.pos,h,new R(p,1,0),o.length,!0)),g=y.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Lt(y.doc,g.pos)&&y.join(g.pos),t(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&l?null:V.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Dn(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&Sn(s,"start",!0)&&Sn(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let y=s,g=1;for(;!y.isTextblock;y=y.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,y.content)){if(t){let b=T.empty;for(let N=p.length-1;N>=0;N--)b=T.from(p[N].copy(b));let k=n.tr.step(new Be(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new R(b,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function bd(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(H.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const up=bd(-1),hp=bd(1);function fp(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),a=o&&Vo(o,n,e);return a?(r&&r(t.tr.wrap(o,a).scrollIntoView()),!0):!1}}function Za(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:a}}=t.selection.ranges[s];t.doc.nodesBetween(o,a,(l,c)=>{if(i)return!1;if(!(!l.isTextblock||l.hasMarkup(n,e)))if(l.type==n)i=!0;else{let d=t.doc.resolve(c),u=d.index();i=d.parent.canReplaceWith(u,u+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=t.selection.ranges[o];s.setBlockType(a,l,n,e)}r(s.scrollIntoView())}return!0}}function qo(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}qo(od,ld,dd);qo(od,hd,fd);qo(pd,md,gd,lp);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function pp(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let a=r?t.tr:null;return mp(a,o,n,e)?(r&&r(a.scrollIntoView()),!0):!1}}function mp(n,e,t,r=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);s=new pi(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new pi(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let a=Vo(s,t,r,e);return a?(n&&gp(n,e,a,i,t),!0):!1}function gp(n,e,t,r,i){let s=T.empty;for(let d=t.length-1;d>=0;d--)s=T.from(t[d].type.create(t[d].attrs,s));n.step(new Be(e.start-(r?2:0),e.end,e.start,e.end,new R(s,0,0),t.length,!0));let o=0;for(let d=0;d<t.length;d++)t[d].type==i&&(o=d+1);let a=t.length-o,l=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,f=!0;d<u;d++,f=!1)!f&&mt(n.doc,l,a)&&(n.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return n}function yp(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?bp(e,t,n,s):kp(e,t,s):!0:!1}}function bp(n,e,t,r){let i=n.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Be(s-1,o,s,o,new R(T.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new pi(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const a=Dn(r);if(a==null)return!1;i.lift(r,a);let l=i.doc.resolve(i.mapping.map(s,-1)-1);return Lt(i.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&i.join(l.pos),e(i.scrollIntoView()),!0}function kp(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,y=t.startIndex;p>y;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let a=t.startIndex==0,l=t.endIndex==i.childCount,c=s.node(-1),d=s.index(-1);if(!c.canReplace(d+(a?0:1),d+1,o.content.append(l?T.empty:T.from(i))))return!1;let u=s.pos,f=u+o.nodeSize;return r.step(new Be(u-(a?1:0),f+(l?1:0),u+1,f-1,new R((a?T.empty:T.from(i.copy(T.empty))).append(l?T.empty:T.from(i.copy(T.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function xp(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let a=s.parent,l=a.child(o-1);if(l.type!=n)return!1;if(t){let c=l.lastChild&&l.lastChild.type==a.type,d=T.from(c?n.create():null),u=new R(T.from(n.create(null,T.from(a.type.create(null,d)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new Be(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}const xe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Cn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let uo=null;const ht=function(n,e,t){let r=uo||(uo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},vp=function(){uo=null},Qt=function(n,e,t,r){return t&&(Xa(n,e,t,r,-1)||Xa(n,e,t,r,1))},wp=/^(img|br|input|textarea|hr)$/i;function Xa(n,e,t,r,i){for(var s;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ke(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Or(n)||wp.test(n.nodeName)||n.contentEditable=="false")return!1;e=xe(n)+(i<0?0:1),n=o}else if(n.nodeType==1){let o=n.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else n=o,e=i<0?Ke(n):0}else return!1}}function Ke(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Sp(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ke(n)}else if(n.parentNode&&!Or(n))e=xe(n),n=n.parentNode;else return null}}function Cp(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Or(n))e=xe(n)+1,n=n.parentNode;else return null}}function Np(n,e,t){for(let r=e==0,i=e==Ke(n);r||i;){if(n==t)return!0;let s=xe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Ke(n)}}function Or(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const is=function(n){return n.focusNode&&Qt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ft(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ep(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Mp(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);
vendor: 9,404 bytes, line 6
6if(r)return{node:r.offsetNode,offset:Math.min(Ke(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Ke(r.startContainer),r.startOffset)}}}const it=typeof navigator<"u"?navigator:null,Qa=typeof document<"u"?document:null,Pt=it&&it.userAgent||"",ho=/Edge\/(\d+)/.exec(Pt),kd=/MSIE \d/.exec(Pt),fo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Pt),ze=!!(kd||fo||ho),Ot=kd?document.documentMode:fo?+fo[1]:ho?+ho[1]:0,Je=!ze&&/gecko\/(\d+)/i.test(Pt);Je&&+(/Firefox\/(\d+)/.exec(Pt)||[0,0])[1];const po=!ze&&/Chrome\/(\d+)/.exec(Pt),ye=!!po,xd=po?+po[1]:0,Ne=!ze&&!!it&&/Apple Computer/.test(it.vendor),Nn=Ne&&(/Mobile\/\w+/.test(Pt)||!!it&&it.maxTouchPoints>2),We=Nn||(it?/Mac/.test(it.platform):!1),vd=it?/Win/.test(it.platform):!1,ft=/Android \d/.test(Pt),Ir=!!Qa&&"webkitFontSmoothing"in Qa.documentElement.style,Tp=Ir?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ap(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function lt(n,e){return typeof n=="number"?n:n[e]}function Op(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function el(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;){if(o.nodeType!=1){o=Cn(o);continue}let a=o,l=a==s.body,c=l?Ap(s):Op(a),d=0,u=0;if(e.top<c.top+lt(r,"top")?u=-(c.top-e.top+lt(i,"top")):e.bottom>c.bottom-lt(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+lt(i,"top")-c.top:e.bottom-c.bottom+lt(i,"bottom")),e.left<c.left+lt(r,"left")?d=-(c.left-e.left+lt(i,"left")):e.right>c.right-lt(r,"right")&&(d=e.right-c.right+lt(i,"right")),d||u)if(l)s.defaultView.scrollBy(d,u);else{let h=a.scrollLeft,p=a.scrollTop;u&&(a.scrollTop+=u),d&&(a.scrollLeft+=d);let y=a.scrollLeft-h,g=a.scrollTop-p;e={left:e.left-y,top:e.top-g,right:e.right-y,bottom:e.bottom-g}}let f=l?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Cn(o)}}function Ip(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=n.root.elementFromPoint(s,o);if(!a||a==n.dom||!n.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=t-20){r=a,i=l.top;break}}return{refDOM:r,refTop:i,stack:wd(n.dom)}}function wd(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Cn(r));return e}function Dp({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Sd(t,r==0?0:r-e)}function Sd(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let dn=null;function Rp(n){if(n.setActive)return n.setActive();if(dn)return n.focus(dn);let e=wd(n);n.focus(dn==null?{get preventScroll(){return dn={preventScroll:!0},!0}}:void 0),dn||(dn=!1,Sd(e,0))}function Cd(n,e){let t,r=2e8,i,s=0,o=e.top,a=e.top,l,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=ht(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=o&&p.bottom>=a){o=Math.max(p.bottom,o),a=Math.min(p.top,a);let y=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(y<r){t=d,r=y,i=y&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&y&&(s=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=u+1)}}return!t&&l&&(t=l,i=c,r=0),t&&t.nodeType==3?jp(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Cd(t,i)}function jp(n,e){let t=n.nodeValue.length,r=document.createRange(),i;for(let s=0;s<t;s++){r.setEnd(n,s+1),r.setStart(n,s);let o=wt(r,1);if(o.top!=o.bottom&&Jo(e,o)){i={node:n,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:n,offset:0}}function Jo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Lp(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Pp(n,e,t){let{node:r,offset:i}=Cd(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function zp(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let a=n.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!o&&l.left>r.left||l.top>r.top?i=a.posBefore:(!o&&l.right<r.left||l.bottom<r.top)&&(i=a.posAfter),o=!0),!a.contentDOM&&i<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;s=a.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function Nd(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(Jo(e,c))return Nd(o,e,c)}}if((s=(s+1)%r)==i)break}return n}function Bp(n,e){let t=n.dom.ownerDocument,r,i=0,s=Mp(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),a;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!Jo(e,c)||(o=Nd(n.dom,e,c),!o))return null}if(Ne)for(let c=o;r&&c;c=Cn(c))c.draggable&&(r=void 0);if(o=Lp(o,e),r){if(Je&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;Ir&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(a=zp(n,r,i,e))}a==null&&(a=Pp(n,o,e));let l=n.docView.nearestDesc(o,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function tl(n){return n.top<n.bottom||n.left<n.right}function wt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(tl(r))return r}return Array.prototype.find.call(t,tl)||n.getBoundingClientRect()}const $p=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ed(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Ir||Je;if(r.nodeType==3)if(o&&($p.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let l=wt(ht(r,i,i),t);if(Je&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=wt(ht(r,i-1,i-1),-1);if(c.top==l.top){let d=wt(ht(r,i,i+1),-1);if(d.top!=l.top)return zn(d,d.left<c.left)}}return l}else{let l=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==r.nodeValue.length?(l--,d=1):t<0?l--:c++,zn(wt(ht(r,l,c),d),d<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Ke(r))){let l=r.childNodes[i-1];if(l.nodeType==1)return Is(l.getBoundingClientRect(),!1)}if(s==null&&i<Ke(r)){let l=r.childNodes[i];if(l.nodeType==1)return Is(l.getBoundingClientRect(),!0)}return Is(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Ke(r))){let l=r.childNodes[i-1],c=l.nodeType==3?ht(l,Ke(l)-(o?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return zn(wt(c,1),!1)}if(s==null&&i<Ke(r)){let l=r.childNodes[i];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?ht(l,0,o?0:1):l.nodeType==1?l:null:null;if(c)return zn(wt(c,-1),!0)}return zn(wt(r.nodeType==3?ht(r):r,-t),t>=0)}function zn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Is(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Md(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function Fp(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Md(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let a=n.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let o=Ed(n,i.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=ht(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(t=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const Hp=/[\u0590-\u08ac]/;function Up(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,a=n.domSelection();return a?!Hp.test(r.parent.textContent)||!a.modify?t=="left"||t=="backward"?s:o:Md(n,e,()=>
vendor: 5,068 bytes, line 6
6{let{focusNode:l,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:y}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==y;try{a.collapse(d,u),l&&(l!=d||c!=u)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let nl=null,rl=null,il=!1;function Vp(n,e,t){return nl==e&&rl==t?il:(nl=e,rl=t,il=t=="up"||t=="down"?Fp(n,e,t):Up(n,e,t))}const Ge=0,sl=1,Ht=2,st=3;class Dr{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ge,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>xe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let a=i.children[o];if(a.size){i=a;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],a=s+o.size;if(a>e||o instanceof Ad){i=e-s;break}s=a}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Td&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?xe(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?xe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=r,a=0;;a++){let l=this.children[a],c=o+l.size;if(i==-1&&e<=c){let d=o+l.border;if(e>=d&&t<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,t,d);e=o;for(let u=a;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=xe(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||a==this.children.length-1)){t=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=xe(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);
vendor: 2,134 bytes, lines 6-7
6if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let y=this.children[h],g=p+y.size;if(s>p&&o<g)return y.setSelection(e-p-y.border,t-p-y.border,r,i);p=g}let a=this.domFromPos(e,e?-1:1),l=t==e?a:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if((Je||Ne)&&e==t){let{node:h,offset:p}=a;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
7`),u&&p==h.nodeValue.length)for(let y=h,g;y;y=y.parentNode){if(g=y.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:xe(g)+1});break}let b=y.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let y=h.childNodes[p-1];u=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(Je&&d.focusNode&&d.focusNode!=l.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||u&&Ne)&&Qt(a.node,a.offset,d.anchorNode,d.anchorOffset)&&Qt(l.node,l.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&Je)){c.collapse(a.node,a.offset);try{e!=t&&c.extend(l.node,l.offset),f=!0}catch{}}if(!f){if(e>t){let p=a;a=l,l=p}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&t>=r:e<o&&t>r){let a=r+s.border,l=o-s.border;if(e>=a&&t<=l){this.dirty=e==r||t==o?Ht:sl,e==a&&t==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=st:s.markDirty(e-a,t-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Ht:st}r=o}this.dirty=Ht}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Ht:sl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}
vendor: 4,851 bytes, line 7
7class Td extends Dr{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let a=document.createElement("span");a.appendChild(o),o=a}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ge&&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}}class _p extends Dr{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class en extends Dr{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=rn.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new en(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&st||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=st&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ge){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ge}}slice(e,t,r){let i=en.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=go(s,t,o,r)),e>0&&(s=go(s,0,e,r));for(let a=0;a<s.length;a++)s[a].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class It extends Dr{constructor(e,t,r,i,s,o,a,l,c){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=a}static create(e,t,r,i,s,o){let a=s.nodeViews[t.type.name],l,c=a&&a(t,s,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,i),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=rn.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Dd(d,r,t),c?l=new Wp(e,t,r,i,d,u||null,f,c,s,o+1):t.isText?new ss(e,t,r,i,d,f,s):new It(e,t,r,i,d,u||null,f,s,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 r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>T.empty)}return e}matchesNode(e,t,r){return this.dirty==Ge&&e.eq(this.node)&&yi(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new qp(this,o&&o.node,e);Yp(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,d):c.type.side>=0&&!u&&l.syncToMarks(d==this.node.childCount?te.none:this.node.child(d).marks,r,e,d),l.placeWidget(c,e,i)},(c,d,u,f)=>{l.syncToMarks(c.marks,r,e,f);let h;l.findNodeMatch(c,d,u,f)||a&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,d,u,h,e)||l.updateNextNode(c,d,u,e,f,i)||l.addNode(c,d,u,e,i),i+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Ht)&&(o&&this.protectLocalComposition(e,o),Od(this.contentDOM,this.children,e),Nn&&Zp(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof H)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,a=Xp(this.node.content,o,r-t,i-t);return a<0?null:{node:s,pos:a,text:o}}else return{node:s,pos:-1,text:""}}
vendor: 4,957 bytes, line 7
7protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new _p(this,s,t,i);e.input.compositionNodes.push(o),this.children=go(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==st||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ge}updateOuterDeco(e){if(yi(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Id(this.dom,this.nodeDOM,mo(this.outerDeco,this.node,t),mo(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.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 ol(n,e,t,r,i){Dd(r,e,n);let s=new It(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class ss extends It{constructor(e,t,r,i,s,o,a){super(e,t,r,i,s,null,o,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==st||this.dirty!=Ge&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ge||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ge,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new ss(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=st)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ad extends Dr{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ge&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Wp extends It{constructor(e,t,r,i,s,o,a,l,c,d){super(e,t,r,i,s,o,a,c,d),this.spec=l}update(e,t,r,i){if(this.dirty==st)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}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 Od(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],a=o.dom;if(a.parentNode==n){for(;a!=r;)r=al(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(a,r);if(o instanceof en){let l=r?r.previousSibling:n.lastChild;Od(o.contentDOM,o.children,t),r=l?l.nextSibling:n.firstChild}}for(;r;)r=al(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const or=function(n){n&&(this.nodeName=n)};or.prototype=Object.create(null);const Ut=[new or];function mo(n,e,t){if(n.length==0)return Ut;let r=t?Ut[0]:new or,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new or(o.nodeName));for(let a in o){let l=o[a];l!=null&&(t&&i.length==1&&i.push(r=new or(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return i}function Id(n,e,t,r){if(t==Ut&&r==Ut)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],a=t[s];if(s){let l;a&&a.nodeName==o.nodeName&&i!=n&&(l=i.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(i),a=Ut[0]),i=l}Kp(i,a||Ut[0],o)}return i}function Kp(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);
vendor: 17,651 bytes, lines 7-10
7if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function Dd(n,e,t){return Id(n,n,Ut,mo(e,t,n.nodeType!=1))}function yi(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function al(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class qp{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Jp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,i){let s=0,o=this.stack.length>>1,a=Math.min(o,e.length);for(;s<a&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Ge,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){l=d;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=en.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,r))s=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=a;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==st&&o.dom==o.contentDOM&&(o.dirty=Ht),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof It){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let d=l.dom,u,f=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=st&&yi(t,l.outerDeco));if(!f&&l.update(e,t,r,i))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(l,e,t,r,i,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Ht,u.updateChildren(i,o+1),u.dirty=Ge),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!yi(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let a=It.create(this.top,t,r,i,s,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,t,r,i,s){let o=It.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Td(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof en;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ss)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ne||ye)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Ad(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Jp(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let a;for(;;)if(r){let c=t.children[r-1];if(c instanceof en)t=c,r=c.children.length;else{a=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let l=a.node;if(l){if(l!=n.child(i-1))break;--i,s.set(a,i),o.push(a)}}return{index:i,matched:s,matches:o.reverse()}}function Gp(n,e){return n.type.side-e.type.side}function Yp(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,i,e.forChild(s,d),c),s+=d.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let d,u;for(;o<i.length&&i[o].to==s;){let g=i[o++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Gp);for(let g=0;g<u.length;g++)t(u[g],c,!!l)}else t(d,c,!!l);let f,h;if(l)h=-1,f=l,l=null;else if(c<n.childCount)h=c,f=n.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=s&&a.splice(g--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)a.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let g=p;o<i.length&&i[o].from<g&&(g=i[o].from);for(let b=0;b<a.length;b++)a[b].to<g&&(g=a[b].to);g<p&&(l=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let y=f.isInline&&!f.isLeaf?a.filter(g=>!g.inline):a.slice();r(f,y,e.forChild(s,f),h),s=p}}function Zp(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Xp(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),a=s;if(s+=o.nodeSize,!o.isText)continue;let l=o.text;for(;i<n.childCount;){let c=n.child(i++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=t){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=t)return a+c;if(t==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function go(n,e,t,r,i){let s=[];for(let o=0,a=0;o<n.length;o++){let l=n[o],c=a,d=a+=l.size;c>=t||d<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),i&&(s.push(i),i=void 0),d>t&&s.push(l.slice(t-c,l.size,r)))}return s}function Go(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(is(t)){for(l=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&F.isSelectable(u)&&i.parent&&!(u.isInline&&Np(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new F(o==f?a:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[l,o]=f==n.state.selection.anchor?[f,u]:[u,f],a=r.resolve(o)}else l=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=e=="pointer"||n.state.selection.head<a.pos&&!s?1:-1;c=Yo(n,d,a,u)}return c}function Rd(n){return n.editable?n.hasFocus():Ld(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function yt(n,e=!1){let t=n.state.selection;if(jd(n,t),!Rd(n))return;let r=n.input.mouseDown;if(!e&&ye&&r){let i=n.domSelectionRange(),s=n.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Qt(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&r.delaySelUpdate()){n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)em(n);else{let{anchor:i,head:s}=t,o,a;ll&&!(t instanceof H)&&(t.$from.parent.inlineContent||(o=cl(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(a=cl(n,t.to))),n.docView.setSelection(i,s,n,e),ll&&(o&&dl(o),a&&dl(a)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Qp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}const ll=Ne||ye&&xd<63;function cl(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Ne&&i&&i.contentEditable=="false")return Ds(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Ds(i);if(s)return Ds(s)}}function Ds(n){return n.contentEditable="true",Ne&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function dl(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Qp(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Rd(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function em(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom,r=t.nodeName=="IMG";r?e.collapse(t.parentNode,xe(t)+1):e.collapse(t,0),!r&&!n.state.selection.visible&&ze&&Ot<=11&&(t.disabled=!0,t.disabled=!1)}function jd(n,e){if(e instanceof F){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ul(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ul(n)}function ul(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Yo(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||H.between(e,t,r)}function hl(n){return n.editable&&!n.hasFocus()?!1:Ld(n)}function Ld(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function tm(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Qt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function yo(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&V.findFrom(s,e)}function Nt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function fl(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Nt(n,new H(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=yo(n.state,e);return i&&i instanceof F?Nt(n,i):!1}else if(!(We&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let a=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=n.docView.descAt(a))&&!o.contentDOM?F.isSelectable(s)?Nt(n,new F(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Ir?Nt(n,new H(n.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof F&&r.node.isInline)return Nt(n,new H(e>0?r.$to:r.$from));{let i=yo(n.state,e);return i?Nt(n,i):!1}}}function bi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ar(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function un(n,e){return e<0?nm(n):rm(n)}function nm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(Je&&t.nodeType==1&&r<bi(t)&&ar(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let a=t.childNodes[r-1];if(ar(a,-1))i=t,s=--r;else if(a.nodeType==3)t=a,r=t.nodeValue.length;else break}}else{if(Pd(t))break;{let a=t.previousSibling;for(;a&&ar(a,-1);)i=t.parentNode,s=xe(a),a=a.previousSibling;if(a)t=a,r=bi(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?bo(n,t,r):i&&bo(n,i,s)}function rm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=bi(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let a=t.childNodes[r];if(ar(a,1))s=t,o=++r;else break}else{if(Pd(t))break;{let a=t.nextSibling;for(;a&&ar(a,1);)s=a.parentNode,o=xe(a)+1,a=a.nextSibling;if(a)t=a,r=0,i=bi(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&bo(n,s,o)}function Pd(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function im(n,e){for(;n&&e==n.childNodes.length&&!Or(n);)e=xe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function sm(n,e){for(;n&&!e&&!Or(n);)e=xe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function bo(n,e,t){if(e.nodeType!=3){let s,o;(o=im(e,t))?(e=o,t=0):(s=sm(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(is(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&yt(n)},50)}function pl(n,e){let t=n.state.doc.resolve(e);if(!(ye||vd)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ml(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||We&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=yo(n.state,e);if(o&&o instanceof F)return Nt(n,o)}if(!i.parent.inlineContent){let o=e<0?i:s,a=r instanceof gt?V.near(o,e):V.findFrom(o,e);return a?Nt(n,a):!1}return!1}function gl(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function yl(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function om(n){if(!Ne||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;yl(n,r,"true"),setTimeout(()=>yl(n,r,"false"),20)}return!1}function am(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function lm(n,e){let t=e.keyCode,r=am(e);if(t==8||We&&t==72&&r=="c")return gl(n,-1)||un(n,-1);if(t==46&&!e.shiftKey||We&&t==68&&r=="c")return gl(n,1)||un(n,1);if(t==13||t==27)return!0;if(t==37||We&&t==66&&r=="c"){let i=t==37?pl(n,n.state.selection.from)=="ltr"?-1:1:-1;return fl(n,i,r)||un(n,i)}else if(t==39||We&&t==70&&r=="c"){let i=t==39?pl(n,n.state.selection.from)=="ltr"?1:-1:1;return fl(n,i,r)||un(n,i)}else{if(t==38||We&&t==80&&r=="c")return ml(n,-1,r)||un(n,-1);if(t==40||We&&t==78&&r=="c")return om(n)||ml(n,1,r)||un(n,1);if(r==(We?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Zo(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||rn.fromSchema(n.state.schema),a=Ud(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Hd[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=a.createElement(d[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),u++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
8
9`);return{dom:l,text:f,slice:e}}function zd(n,e,t,r,i){let s=i.parent.type.spec.code,o,a;if(!t&&!e)return null;let l=!!e&&(r||s||!t);if(l){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return a=new R(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
10`))),0,0),n.someProp("transformPasted",f=>{a=f(a,n,!0)}),a;let u=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(u)a=u;else{let f=i.marks(),{schema:h}=n.state,p=rn.fromSchema(h);
vendor: 5,566 bytes, line 10
10o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let g=o.appendChild(document.createElement("p"));y&&g.appendChild(p.serializeNode(h.text(y,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),o=hm(t),Ir&&fm(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(a||(a=(n.someProp("clipboardParser")||n.someProp("domParser")||At.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!cm.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)a=pm(bl(a,+d[1],+d[2]),d[4]);else if(a=R.maxOpen(dm(a.content,i),!0),a.openStart||a.openEnd){let u=0,f=0;for(let h=a.content.firstChild;u<a.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=a.content.lastChild;f<a.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);a=bl(a,u,f)}return n.someProp("transformPasted",u=>{a=u(a,n,l)}),a}const cm=/^(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 dm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(a=>{if(!o)return;let l=i.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&s.length&&$d(l,s,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Fd(o[o.length-1],s.length));let d=Bd(a,l);o.push(d),i=i.matchType(d.type),s=l}}),o)return T.from(o)}return n}function Bd(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function $d(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=$d(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(T.from(Bd(t,n,i+1))))}}function Fd(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Fd(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function ko(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,a=o.content;return n.childCount>1&&(s=0),i<r-1&&(a=ko(a,e,t,r,i+1,s)),i>=t&&(a=e<0?o.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(a))}function bl(n,e,t){return e<n.openStart&&(n=new R(ko(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new R(ko(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Hd={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let kl=null;function Ud(){return kl||(kl=document.implementation.createHTMLDocument("title"))}let Rs=null;function um(n){let e=window.trustedTypes;return e?(Rs||(Rs=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Rs.createHTML(n)):n}function hm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ud().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Hd[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=um(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function fm(n){let e=n.querySelectorAll(ye?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function pm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let a=r.length-2;a>=0;a-=2){let l=t.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;i=T.from(l.create(r[a+1],i)),s++,o++}return new R(i,s,o)}const Re={},je={},mm={touchstart:!0,touchmove:!0};class gm{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 ym(n){for(let e in Re){let t=Re[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{km(n,r)&&!Xo(n,r)&&(n.editable||!(r.type in je))&&t(n,r)},mm[e]?{passive:!0}:void 0)}Ne&&n.dom.addEventListener("input",()=>null),xo(n)}function pt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function bm(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function xo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Xo(n,r))})}function Xo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function km(n,e){if(!e.bubbles)return!0;
vendor: 13,314 bytes, line 10
10if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function xm(n,e){!Xo(n,e)&&Re[e.type]&&(n.editable||!(e.type in je))&&Re[e.type](n,e)}je.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Kd(n)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ft&&ye&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Nn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Ft(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||lm(n,t)?t.preventDefault():pt(n,"key")};je.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};je.keypress=(n,e)=>{let t=e;if(Kd(n)||!t.charCode||t.ctrlKey&&!t.altKey||We&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode),s=()=>n.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i,s))&&n.dispatch(s()),t.preventDefault()}};function Rr(n){return{left:n.clientX,top:n.clientY}}function vm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Qo(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,a=>o>s.depth?a(n,t,s.nodeAfter,s.before(o),i,!0):a(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function jr(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function wm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&F.isSelectable(r)?(jr(n,new F(t)),!0):!1}function Sm(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof F&&(r=t.node);let s=n.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let a=o>s.depth?s.nodeAfter:s.node(o);if(F.isSelectable(a)){r&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(jr(n,F.create(n.state.doc,i)),!0):!1}function Cm(n,e,t,r,i){return Qo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?Sm(n,t):wm(n,t))}function Nm(n,e,t,r){return Qo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Em(n,e,t,r){return Qo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||Mm(n,t,r)}function Mm(n,e,t){if(t.button!=0)return!1;let r=Vd(n,e,!0),i=n.state.doc;return r?(jr(n,r),r instanceof H&&i.eq(n.state.doc)&&(n.input.mouseDown=new Am(n,r)),!0):!1}function Vd(n,e,t){let r=n.state.doc;if(e==-1)return r.inlineContent?H.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),a=i.before(s);if(o.inlineContent)return H.create(r,a+1,a+1+o.content.size);if(t&&F.isSelectable(o))return F.create(r,a)}return null}function ea(n){return ki(n)}const _d=We?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=ea(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&vm(t,n.input.lastClick)&&!t[_d]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let o=n.posAtCoords(Rr(t));o&&(s=="singleClick"?n.input.mouseDown=new Tm(n,o,t,!!r):(s=="doubleClick"?Nm:Em)(n,o.pos,o.inside,t)?t.preventDefault():pt(n,"pointer"))};class Wd{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class Tm extends Wd{constructor(e,t,r,i){super(e),this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[_d],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let d=e.state.doc.resolve(t.pos);s=d.parent,o=d.depth?d.before():0}const a=i?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof F&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Je&&!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()),pt(e,"pointer")}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||yt(this.view)})}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(Rr(e))),this.updateAllowDefault(e),this.allowDefault||!t?pt(this.view,"pointer"):Cm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ne&&this.mightDrag&&!this.mightDrag.node.isAtom||ye&&!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)?(jr(this.view,V.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):pt(this.view,"pointer")}move(e){this.updateAllowDefault(e),pt(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class Am extends Wd{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),pt(this.view,"pointer");let t=this.view.posAtCoords(Rr(e)),r=t&&Vd(this.view,t.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,a]=r.from<s.from?[s.to,r.from]:[s.from,r.to];jr(this.view,H.create(i,o,a))}}Re.touchstart=n=>{n.input.lastTouch=Date.now(),ea(n),pt(n,"pointer")};Re.touchmove=n=>{n.input.lastTouch=Date.now(),pt(n,"pointer")};Re.contextmenu=n=>ea(n);function Kd(n,e){return n.composing?!0:Ne&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Om=ft?5e3:-1;je.compositionstart=je.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ye&&vd&&Im(n)))n.markCursor=n.state.storedMarks||t.marks(),ki(n,!0),n.markCursor=null;else if(ki(n,!e.selection.empty),Je&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let a=n.domSelection();a&&a.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}qd(n,Om)};function Im(n){let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return r.nodeType==1&&r.contentEditable=="false"}je.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,qd(n,20))};function qd(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>ki(n),e))}function Jd(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Dm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Sp(e.focusNode,e.focusOffset),r=Cp(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return r}}return t||r}function ki(n,e=!1){if(!(ft&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Jd(n),e||n.docView&&n.docView.dirty){let t=Go(n),r=n.state.selection;return t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Rm(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const xr=ze&&Ot<15||Nn&&Tp<604;Re.copy=je.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=xr?null:t.clipboardData,o=r.content(),{dom:a,text:l}=Zo(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Rm(n,a),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function jm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Lm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?vr(n,r.value,null,i,e):vr(n,r.textContent,r.innerHTML,i,e)},50)}function vr(n,e,t,r,i){let s=zd(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",l=>l(n,i,s||R.empty)))return!0;if(!s)return!1;let o=jm(s),a=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Gd(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}je.paste=(n,e)=>{let t=e;if(n.composing&&!ft)return;let r=xr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&vr(n,Gd(r),r.getData("text/html"),i,t)?t.preventDefault():Lm(n,t)};class Yd{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Pm=We?"altKey":"ctrlKey";function Zd(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Pm]}Re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(Rr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof F?i.to-1:i.to))){if(r&&r.mightDrag)o=F.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(o=F.create(n.state.doc,u.posBefore))}}let a=(o||n.state.selection).content(),{dom:l,text:c,slice:d}=Zo(n,a);(!t.dataTransfer.files.length||!ye||xd>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(xr?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",xr||t.dataTransfer.setData("text/plain",c),n.dragging=new Yd(d,Zd(n,t),o)};Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};je.dragover=je.dragenter=(n,e)=>e.preventDefault();je.drop=(n,e)=>{try{zm(n,e,n.dragging)}finally{n.dragging=null}};function zm(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Rr(e));if(!r)return;let i=n.state.doc.resolve(r.pos),s=t&&t.slice;s?n.someProp("transformPasted",h=>{s=h(s,n,!1)}):s=zd(n,Gd(e.dataTransfer),xr?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(t&&Zd(n,e));if(n.someProp("handleDrop",h=>h(n,e,s||R.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let a=s?qc(n.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let l=n.state.tr;if(o){let{node:h}=t;h?h.replace(l):l.deleteSelection()}
vendor: 9,548 bytes, line 10
10let c=l.mapping.map(a),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,u=l.doc;if(d?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(u))return;let f=l.doc.resolve(c);if(d&&F.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new F(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,y,g,b)=>h=b),l.setSelection(Yo(n,f,l.doc.resolve(h)))}n.focus(),n.dispatch(l.setMeta("uiEvent","drop"))}Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&yt(n)},20))};Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Re.beforeinput=(n,e)=>{if(ye&&ft&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ft(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in je)Re[n]=je[n];function wr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class xi{constructor(e,t){this.toDOM=e,this.spec=t||Jt,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new Ie(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xi&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&wr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Dt{constructor(e,t){this.attrs=e,this.spec=t||Jt}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Ie(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Dt&&wr(this.attrs,e.attrs)&&wr(this.spec,e.spec)}static is(e){return e.type instanceof Dt}destroy(){}}class ta{constructor(e,t){this.attrs=e,this.spec=t||Jt}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Ie(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof ta&&wr(this.attrs,e.attrs)&&wr(this.spec,e.spec)}destroy(){}}class Ie{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Ie(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Ie(e,e,new xi(t,r))}static inline(e,t,r,i){return new Ie(e,t,new Dt(r,i))}static node(e,t,r,i){return new Ie(e,t,new ta(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Dt}get widget(){return this.type instanceof xi}}const mn=[],Jt={};class oe{constructor(e,t){this.local=e.length?e:mn,this.children=t.length?t:mn}static create(e,t){return t.length?vi(t,e,0,Jt):Se}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let a=this.local[o];a.from<=t&&a.to>=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+i,a.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,t-a,r,i+a,s)}}map(e,t,r){return this==Se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Jt)}mapInner(e,t,r,i,s){let o;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,i);l&&l.type.valid(t,l)?(o||(o=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?Bm(this.children,o||[],e,t,r,i,s):o?new oe(o.sort(Gt),mn):Se}add(e,t){return t.length?this==Se?oe.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((a,l)=>{let c=l+r,d;if(d=Qd(t,a,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<l;)s+=3;i[s]==l?i[s+2]=i[s+2].addInner(a,d,c+1):i.splice(s,0,l,l+a.nodeSize,vi(d,a,c+1,Jt)),s+=3}});let o=Xd(s?eu(t):t,-r);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||o.splice(a--,1);return new oe(o.length?this.local.concat(o).sort(Gt):this.local,i||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,a=r[s]+t,l=r[s+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(o,a+1);c!=Se?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let a=0;a<i.length;a++)i[a].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(a--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new oe(i,r):Se}forChild(e,t){if(this==Se)return this;if(t.isLeaf)return oe.empty;let r,i;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,o=s+t.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<o&&l.to>s&&l.type instanceof Dt){let c=Math.max(s,l.from)-s,d=Math.min(o,l.to)-s;c<d&&(i||(i=[])).push(l.copy(c,d))}}if(i){let a=new oe(i.sort(Gt),mn);return r?new Tt([a,r]):a}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof oe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return na(this.localsInner(e))}localsInner(e){if(this==Se)return mn;if(e.inlineContent||!this.local.some(Dt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Dt||t.push(this.local[r]);return t}forEachSet(e){e(this)}}oe.empty=new oe([],[]);oe.removeOverlap=na;const Se=oe.empty;class Tt{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,Jt));return Tt.from(r)}forChild(e,t){if(t.isLeaf)return oe.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=Se&&(s instanceof Tt?r=r.concat(s.members):r.push(s))}return Tt.from(r)}eq(e){if(!(e instanceof Tt)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?na(r?t:t.sort(Gt)):mn}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new Tt(e.every(t=>t instanceof oe)?e:e.reduce((t,r)=>t.concat(r instanceof oe?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Bm(n,e,t,r,i,s,o){let a=n.slice();for(let c=0,d=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,y)=>{let g=y-p-(h-f);for(let b=0;b<a.length;b+=3){let k=a[b+1];if(k<0||f>k+d-u)continue;let N=a[b]+d-u;h>=N?a[b+1]=f<=N?-2:-1:f>=d&&g&&(a[b]+=g,a[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=t.map(n[c]+s),u=d-i;if(u<0||u>=r.content.size){l=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-i,{index:p,offset:y}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&y==u&&y+g.nodeSize==h){let b=a[c+2].mapInner(t,g,d+1,n[c]+s+1,o);b!=Se?(a[c]=u,a[c+1]=h,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=$m(a,n,e,t,i,s,o),d=vi(c,r,0,o);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<a.length&&a[f]<h;)f+=3;a.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new oe(e.sort(Gt),a)}function Xd(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Ie(i.from+e,i.to+e,i.type))}return t}function $m(n,e,t,r,i,s,o){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,i,c);u?t.push(u):o.onRemove&&o.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<n.length;l+=3)n[l+1]==-1&&a(n[l+2],e[l]+s+1);return t}function Qd(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function eu(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function vi(n,e,t,r){let i=[],s=!1;e.forEach((a,l)=>{let c=Qd(n,a,l+t);if(c){s=!0;let d=vi(c,a,t+l+1,r);d!=Se&&i.push(l,l+a.nodeSize,d)}});let o=Xd(s?eu(n):n,-t).sort(Gt);for(let a=0;a<o.length;a++)o[a].type.valid(e,o[a])||(r.onRemove&&r.onRemove(o[a].spec),o.splice(a--,1));return o.length||i.length?new oe(o,i):Se}function Gt(n,e){return n.from-e.from||n.to-e.to}function na(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),xl(e,i+1,s.c
vendor: 25,218 bytes, line 10
10opy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),xl(e,i,r.copy(s.from,r.to)));break}}}return e}function xl(n,e,t){for(;e<n.length&&Gt(t,n[e])>0;)e++;n.splice(e,0,t)}function js(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Se&&e.push(r)}),n.cursorWrapper&&e.push(oe.create(n.state.doc,[n.cursorWrapper.deco])),Tt.from(e)}const Fm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Hm=ze&&Ot<=11;class Um{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Vm{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Um,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);ze&&Ot<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Ne&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Hm&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Fm)),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(hl(this.view)){if(this.suppressingSelectionUpdates)return yt(this.view);if(ze&&Ot<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=Cn(s))t.add(s);for(let s=e.anchorNode;s;s=Cn(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&hl(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,a=!1,l=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],l);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ye&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&u.nodeType==1;){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(Je&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Km(e,u)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&is(r)&&(c=Go(e))&&c.eq(V.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,yt(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),_m(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qm(e,l)),this.handleDOMChange(s,o,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||yt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(ze&&Ot<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?xe(i)+1:0,a=r.localPosFromDOM(e.target,o,-1),l=s&&s.parentNode==e.target?xe(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let vl=new WeakMap,wl=!1;function _m(n){if(!vl.has(n)&&(vl.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Je,wl)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."),wl=!0}}function Sl(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return Qt(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function Wm(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return Sl(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Sl(n,t):null}function Km(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function qm(n,e){var t;let{focusNode:r,focusOffset:i}=n.domSelectionRange();for(let s of e)if(((t=s.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let a=o;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(s,a.firstChild),r==s&&n.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function Jm(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:a}=n.docView.parseRange(e,t),l=n.domSelectionRange(),c,d=l.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:l.anchorOffset}],is(l)||c.push({node:l.focusNode,offset:l.focusOffset})),ye&&n.input.lastKeyCode===8)for(let g=s;g>i;g--){let b=r.childNodes[g-1],k=b.pmViewDesc;if(b.nodeName=="BR"&&!k){s=g;break}if(!k||k.size)break}let u=n.state.doc,f=n.someProp("domParser")||At.fromSchema(n.state.schema),h=u.resolve(o),p=null,y=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Gm,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+o,head:b+o}}return{doc:y,sel:p,from:o,to:a}}function Gm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Ne&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Ne&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ym=/^(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 Zm(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=Go(n,O);if(L&&!n.state.selection.eq(L)){if(ye&&ft&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,Ft(13,"Enter"))))return;let C=n.state.tr.setSelection(L);O=="pointer"?C.setMeta("pointer",!0):O=="key"&&C.scrollIntoView(),s&&C.setMeta("composition",s),n.dispatch(C)}return}let o=n.state.doc.resolve(e),a=o.sharedDepth(t);e=o.before(a+1),t=n.state.doc.resolve(t).after(a+1);let l=n.state.selection,c=Jm(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=eg(u.content,c.doc.content,c.from,f,h);if(p&&n.input.domChangeCount++,(Nn&&n.input.lastIOSEnter>Date.now()-225||ft)&&i.some(O=>O.nodeType==1&&!Ym.test(O.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",O=>O(n,Ft(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof H&&!l.empty&&l.$head.sameParent(l.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let O=Cl(n,n.state.doc,c.sel);if(O&&!O.eq(n.state.selection)){let L=n.state.tr.setSelection(O);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof H&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ze&&Ot<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let y=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),k=y.sameParent(g)&&y.parent.inlineContent&&b.end()>=p.endA;if((Nn&&n.input.lastIOSEnter>Date.now()-225&&(!k||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!k&&y.pos<c.doc.content.size&&(!y.sameParent(g)||!y.parent.inlineContent)&&y.pos<g.pos&&!/\S/.test(c.doc.textBetween(y.pos,g.pos,"","")))&&n.someProp("handleKeyDown",O=>O(n,Ft(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Qm(d,p.start,p.endA,y,g)&&n.someProp("handleKeyDown",O=>O(n,Ft(8,"Backspace")))){ft&&ye&&n.domObserver.suppressSelectionUpdates();return}ye&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),ft&&!k&&y.start()!=g.start()&&g.parentOffset==0&&y.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(O){return O(n,Ft(13,"Enter"))})},20));let N=p.start,A=p.endA,S=O=>{let L=O||n.state.tr.replace(N,A,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let C=Cl(n,L.doc,c.sel);C&&!(ye&&n.composing&&C.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(C.head==N||C.head==L.mapping.map(A)-1)||ze&&C.empty&&C.head==N)&&L.setSelection(C)}return s&&L.setMeta("composition",s),L.scrollIntoView()},I;if(k)if(y.pos==g.pos){ze&&Ot<=11&&y.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>yt(n),20));let O=S(n.state.tr.delete(N,A)),L=d.resolve(p.start).marksAcross(d.resolve(p.endA));L&&O.ensureMarks(L),n.dispatch(O)}else if(p.endA==p.endB&&(I=Xm(y.parent.content.cut(y.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let O=S(n.state.tr);I.type=="add"?O.addMark(N,A,I.mark):O.removeMark(N,A,I.mark),n.dispatch(O)}else if(y.parent.child(y.index()).isText&&y.index()==g.index()-(g.textOffset?0:1)){let O=y.parent.textBetween(y.parentOffset,g.parentOffset),L=()=>S(n.state.tr.insertText(O,N,A));n.someProp("handleTextInput",C=>C(n,N,A,O,L))||n.dispatch(L())}else n.dispatch(S());else n.dispatch(S())}function Cl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Yo(n,e.resolve(t.anchor),e.resolve(t.head))}function Xm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,a,l;for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);for(let d=0;d<t.length;d++)s=t[d].removeFromSet(s);if(i.length==1&&s.length==0)a=i[0],o="add",l=d=>d.mark(a.addToSet(d.marks));else if(i.length==0&&s.length==1)a=s[0],o="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(T.from(c).eq(n))return{mark:a,type:o}}function Qm(n,e,t,r,i){if(t-e<=i.pos-r.pos||Ls(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let a=s.nodeAfter;return a!=null&&t==e+a.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(Ls(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Ls(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Ls(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function eg(n,e,t,r,i){let s=n.findDiffStart(e,t),o=t+n.size,a=t+e.size;if(s==null)return null;let{a:l,b:c}=n.findDiffEnd(e,o,a);if(i=="end"){let d=Math.max(0,s-Math.min(l,c));r-=l+d-s}if(l<s&&o<a){let d=r<=s&&r>=l?s-r:0;s-=d,c=s+(c-l),l=s}else if(c<s){let d=r<=s&&r>=c?s-r:0;s-=d,l=s+(l-c),c=s}return{start:s,endA:l,endB:c}}class tu{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 gm,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Al),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=Ml(this),El(this),this.nodeViews=Tl(this),this.docView=ol(this.state.doc,Nl(this),js(this),this.dom,this),this.domObserver=new Vm(this,(r,i,s,o)=>Zm(this,r,i,s,o)),this.domObserver.start(),ym(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&&xo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Al),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Jd(this),o=!0),this.state=e;let a=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Tl(this);ng(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&xo(this),this.editable=Ml(this),El(this);let l=js(this),c=Nl(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(i.selection))&&(o=!0);let f=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Ip(this);if(o){this.domObserver.stop();let h=u&&(ze||ye)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&tg(i.selection,e.selection);if(u){let y=ye?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Dm(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ol(e.doc,c,l,this.dom,this)),y&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}let p=this.input.mouseDown;h||!(p&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&tm(this)&&p.delaySelUpdate())?yt(this,h):(jd(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Dp(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof F){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&el(this,t.getBoundingClientRect(),e)}else el(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Yd(e.slice,e.move,i<0?void 0:F.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(i=t?t(a):a))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let a=s[o].props[e];if(a!=null&&(i=t?t(a):a))return i}}hasFocus(){if(ze){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&&Rp(this.dom),yt(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Bp(this,e)}coordsAtPos(e,t=1){return Ed(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Vp(this,t||this.state,e)}pasteHTML(e,t){return vr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return vr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Zo(this,e)}destroy(){this.docView&&(bm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],js(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,vp())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xm(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ne&&this.root.nodeType===11&&Ep(this.dom.ownerDocument)==this.dom&&Wm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}tu.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function Nl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ie.node(0,n.state.doc.content.size,e)]}function El(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ie.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Ml(n){return!n.someProp("editable",e=>e(n.state)===!1)}function tg(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Tl(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ng(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function Al(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Rt={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:"'"},wi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},rg=typeof navigator<"u"&&/Mac/.test(navigator.platform),ig=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ve=0;ve<10;ve++)Rt[48+ve]=Rt[96+ve]=String(ve);for(var ve=1;ve<=24;ve++)Rt[ve+111]="F"+ve;for(var ve=65;ve<=90;ve++)Rt[ve]=String.fromCharCode(ve+32),wi[ve]=String.fromCharCode(ve);for(var Ps in Rt)wi.hasOwnProperty(Ps)||(wi[Ps]=Rt[Ps]);function sg(n){var e=rg&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||ig&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?wi:Rt)[n.keyCode]||n.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}const og=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ag=typeof navigator<"u"&&/Win/.test(navigator.platform);function lg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))og?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function cg(n){let e=Object.create(null);for(let t in n)e[lg(t)]=n[t];return e}
vendor: 5,057 bytes, line 10
10function zs(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function dg(n){return new ae({props:{handleKeyDown:nu(n)}})}function nu(n){let e=cg(n);return function(t,r){let i=sg(r),s,o=e[zs(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let a=e[zs(i,r,!1)];if(a&&a(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(ag&&r.ctrlKey&&r.altKey)&&(s=Rt[r.keyCode])&&s!=i){let a=e[zs(s,r)];if(a&&a(t.state,t.dispatch,t))return!0}}return!1}}var ug=Object.defineProperty,ra=(n,e)=>{for(var t in e)ug(n,t,{get:e[t],enumerable:!0})};function as(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}var ls=class{constructor(n){this.editor=n.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=n.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:n,editor:e,state:t}=this,{view:r}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(n).map(([o,a])=>[o,(...c)=>{const d=a(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o=[],a=!!n,l=n||i.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),o.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(t).map(([u,f])=>[u,(...p)=>{const y=this.buildProps(l,e),g=f(...p)(y);return o.push(g),d}])),run:c};return d}createCan(n){const{rawCommands:e,state:t}=this,r=!1,i=n||t.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(n,e=!0){const{rawCommands:t,editor:r,state:i}=this,{view:s}=r,o={tr:n,editor:r,view:s,state:as({state:i,transaction:n}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(n,e),can:()=>this.createCan(n),get commands(){return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...c)=>l(...c)(o)]))}};return o}},ru={};ra(ru,{blur:()=>hg,clearContent:()=>fg,clearNodes:()=>pg,command:()=>mg,createParagraphNear:()=>gg,cut:()=>yg,deleteCurrentNode:()=>bg,deleteNode:()=>kg,deleteRange:()=>xg,deleteSelection:()=>Sg,enter:()=>Cg,exitCode:()=>Ng,extendMarkRange:()=>Eg,first:()=>Mg,focus:()=>Ag,forEach:()=>Og,insertContent:()=>Ig,insertContentAt:()=>jg,joinBackward:()=>zg,joinDown:()=>Pg,joinForward:()=>Bg,joinItemBackward:()=>$g,joinItemForward:()=>Fg,joinTextblockBackward:()=>Hg,joinTextblockForward:()=>Ug,joinUp:()=>Lg,keyboardShortcut:()=>_g,lift:()=>Wg,liftEmptyBlock:()=>Kg,liftListItem:()=>qg,newlineInCode:()=>Jg,resetAttributes:()=>Gg,scrollIntoView:()=>Yg,selectAll:()=>Zg,selectNodeBackward:()=>Xg,selectNodeForward:()=>Qg,selectParentNode:()=>ey,selectTextblockEnd:()=>ty,selectTextblockStart:()=>ny,setContent:()=>ry,setMark:()=>Cy,setMeta:()=>Ny,setNode:()=>Ey,setNodeSelection:()=>My,setTextDirection:()=>Ty,setTextSelection:()=>Ay,sinkListItem:()=>Oy,splitBlock:()=>Iy,splitListItem:()=>Dy,toggleList:()=>jy,toggleMark:()=>Ly,toggleNode:()=>Py,toggleWrap:()=>zy,undoInputRule:()=>By,unsetAllMarks:()=>$y,unsetMark:()=>Fy,unsetTextDirection:()=>Hy,updateAttributes:()=>Uy,wrapIn:()=>Vy,wrapInList:()=>_y});var hg=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())==null||t.removeAllRanges())}),!0),fg=(n=!0)=>({commands:e})=>e.setContent("",{emitUpdate:n}),pg=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.doc.nodesBetween(s.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),f=c.resolve(d.map(l+a.nodeSize)),h=u.blockRange(f);if(!h)return;const p=Dn(h);if(a.type.isTextblock){const{defaultType:y}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,y)}(p||p===0)&&e.lift(h,p)})}),!0},mg=n=>e=>n(e),gg=()=>({state:n,dispatch:e})=>md(n,e),yg=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new H(r.doc.resolve(Math.max(o-1,0)))),!0},bg=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const a=i.before(s),l=i.after(s);n.delete(a,l).scrollIntoView()}return!0}return!1};function he(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);
10return e.nodes[n]}return n}var kg=n=>({tr:e,state:t,dispatch:r})=>{const i=he(n,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const l=s.before(o),c=s.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},xg=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},vg=n=>n.content?/^text(\*|\+)/.test(n.content):!1,Ol=(n,e,t)=>{if(!n.parent.isInline||t==="left"&&n.pos>n.start()||t==="right"&&n.pos<n.end())return n.pos;const r=e.nodes[n.parent.type.name].spec;return vg(r)?t==="left"?n.start()-1:n.end()+1:n.pos},wg=(n,e,t)=>{const r=Ol(n,t,"left"),i=Ol(e,t,"right");return{from:r,to:i}},Sg=()=>({state:n,dispatch:e})=>{const{$from:t,$to:r}=n.selection;if(n.selection.empty)return!1;const{from:i,to:s}=wg(t,r,n.schema);return e&&(n.tr.deleteRange(i,s).scrollIntoView(),e(n.tr)),!0},Cg=()=>({commands:n})=>n.keyboardShortcut("Enter"),Ng=()=>({state:n,dispatch:e})=>op(n,e);function ia(n){return Object.prototype.toString.call(n)==="[object RegExp]"}function Si(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:ia(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function iu(n,e,t={}){return n.find(r=>r.type===e&&Si(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Il(n,e,t={}){return!!iu(n,e,t)}function sa(n,e,t){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=n.parent.childBefore(n.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!t){const c=r.node.marks.find(d=>d.type===e);c&&(t=c.attrs)}if(!iu([...r.node.marks],e,t))return;let s=r.index,o=n.start()+r.offset,a=s+1,l=o+r.node.nodeSize;for(;s>0&&Il([...n.parent.child(s-1).marks],e,t);)s-=1,o-=n.parent.child(s).nodeSize;for(;a<n.parent.childCount&&Il([...n.parent.child(a).marks],e,t);)l+=n.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function kt(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}var Eg=(n,e)=>({tr:t,state:r,dispatch:i})=>{const s=kt(n,r.schema),{doc:o,selection:a}=t,{$from:l,from:c,to:d}=a;if(i){const u=sa(l,s,e);if(u&&u.from<=c&&u.to>=d){const f=H.create(o,u.from,u.to);t.setSelection(f)}}return!0},Mg=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function su(n){return n instanceof H}function Vt(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function ou(n,e=null){if(!e)return null;const t=V.atStart(n),r=V.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?H.create(n,Vt(0,i,s),Vt(n.content.size,i,s)):H.create(n,Vt(e,i,s),Vt(e,i,s))}function Dl(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ci(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Tg(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Ag=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ci()||Dl())&&r.dom.focus(),Tg()&&!Ci()&&!Dl()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};try{if(r.hasFocus()&&n===null||n===!1)return!0}catch{return!1}if(s&&n===null&&!su(t.state.selection))return o(),!0;const a=ou(i.doc,n)||t.state.selection,l=t.state.selection.eq(a);return s&&(l||i.setSelection(a),l&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},Og=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Ig=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),au=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&au(r)}return n};function Fr(n){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return au(t)}function Sr(n,e,t){if(n instanceof et||n instanceof T)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return T.fromArray(n.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(n);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Sr("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,a="";const l=new Pc({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?At.fromSchema(l).parseSlice(Fr(n),t.parseOptions):At.fromSchema(l).parse(Fr(n),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=At.fromSchema(e);return t.slice?s.parseSlice(Fr(n),t.parseOptions).content:s.parse(Fr(n),t.parseOptions)}return Sr("",e,t)}function Dg(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof Ye||i instanceof Be))return;const s=n.mapping.maps[r];let o=0;
vendor: 7,323 bytes, line 10
10s.forEach((a,l,c,d)=>{o===0&&(o=d)}),n.setSelection(V.near(n.doc.resolve(o),t))}var Rg=n=>!("type"in n),jg=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let a;const l=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Sr(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=Sr(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return l(g),!1}let{from:d,to:u}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,h=!0;if((Rg(a)?a:[a]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),d===u&&h){const{parent:g}=r.doc.resolve(d);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(d-=1,u+=1)}let y;if(f){if(Array.isArray(e))y=e.map(g=>g.text||"").join("");else if(e instanceof T){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),y=g}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,u)}else{y=a;const g=r.doc.resolve(d),b=g.node(),k=g.parentOffset===0,N=b.isText||b.isTextblock,A=b.content.size>0;k&&N&&A&&h&&(d=Math.max(0,d-1)),r.replaceWith(d,u,y)}t.updateSelection&&Dg(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:y}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:y})}return!0},Lg=()=>({state:n,dispatch:e})=>rp(n,e),Pg=()=>({state:n,dispatch:e})=>ip(n,e),zg=()=>({state:n,dispatch:e})=>ld(n,e),Bg=()=>({state:n,dispatch:e})=>hd(n,e),$g=()=>({state:n,dispatch:e,tr:t})=>{try{const r=ns(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Fg=()=>({state:n,dispatch:e,tr:t})=>{try{const r=ns(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Hg=()=>({state:n,dispatch:e})=>tp(n,e),Ug=()=>({state:n,dispatch:e})=>np(n,e);function lu(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Vg(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))Ci()||lu()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}var _g=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=Vg(n).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,a))});return l?.steps.forEach(c=>{const d=c.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function jt(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?he(e,n.schema):null,a=[];n.doc.nodesBetween(r,i,(u,f)=>{if(u.isText)return;const h=Math.max(r,f),p=Math.min(i,f+u.nodeSize);a.push({node:u,from:h,to:p})});const l=i-r,c=a.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Si(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=l}var Wg=(n,e={})=>({state:t,dispatch:r})=>{const i=he(n,t.schema);return jt(t,i,e)?sp(t,r):!1},Kg=()=>({state:n,dispatch:e})=>gd(n,e),qg=n=>({state:e,dispatch:t})=>{const r=he(n,e.schema);return yp(r)(e,t)},Jg=()=>({state:n,dispatch:e})=>pd(n,e);function cs(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Rl(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var Gg=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const a=cs(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=he(n,r.schema)),a==="mark"&&(o=kt(n,r.schema));let l=!1;return t.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{s&&s===d.type&&(l=!0,i&&t.setNodeMarkup(u,void 0,Rl(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(f=>{o===f.type&&(l=!0,i&&t.addMark(u,u+d.nodeSize,o.create(Rl(f.attrs,e))))})})}),l},Yg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Zg=()=>({tr:n,dispatch:e})=>{if(e){const t=new gt(n.doc);n.setSelection(t)}return!0},Xg=()=>({state:n,dispatch:e})=>dd(n,e),Qg=()=>({state:n,dispatch:e})=>fd(n,e),ey=()=>({state:n,dispatch:e})=>cp(n,e),ty=()=>({state:n,dispatch:e})=>hp(n,e),ny=()=>({state:n,dispatch:e})=>up(n,e);function vo(n,e,t={},r={}){return Sr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var ry=(n,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:a})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=vo(n,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:l.content.size},n,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function cu(n,e){const t=kt(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===t.name);return a?{...a.attrs}:{}}function du(n,e){const t=new ed(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function iy(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function sy(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function oy(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function ds(n){return e=>oy(e.$from,n)}function z(n,e,t){return n.config[e]===void 0&&n.parent?z(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?z(n.parent,e,t):null}):n.config[e]}function oa(n){return n.map(e=>{const t={name:e.name,options:e.options,storage:e.storage},r=z(e,"addExtensions",t);return r?[e,...oa(r())]:e}).flat(10)}function aa(n,e){const t=rn.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function uu(n){return typeof n=="function"}function Q(n,e=void 0,...t){return uu(n)?e?n.bind(e)(...t):n(...t):n}function ay(n={}){return Object.keys(n).length===0&&n.constructor===Object}function En(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function hu(n){const e=[],{nodeExtensions:t,markExtensions:r}=En(n),i=[...t,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=t.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...o,...a];
10return n.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage,extensions:i},u=z(c,"addGlobalAttributes",d);if(!u)return;u().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=l:h.types==="nodes"?p=o:h.types==="marks"?p=a:p=[],p.forEach(y=>{Object.entries(h.attributes).forEach(([g,b])=>{e.push({type:y,name:g,attribute:{...s,...b}})})})})}),i.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage},u=z(c,"addAttributes",d);if(!u)return;const f=u();Object.entries(f).forEach(([h,p])=>{const y={...s,...p};typeof y?.default=="function"&&(y.default=y.default()),y?.isRequired&&y?.default===void 0&&delete y.default,e.push({type:c.name,name:h,attribute:y})})}),e}function ly(n){const e=[];let t="",r=!1,i=!1,s=0;const o=n.length;for(let a=0;a<o;a+=1){const l=n[a];if(l==="'"&&!i){r=!r,t+=l;continue}if(l==='"'&&!r){i=!i,t+=l;continue}if(!r&&!i){if(l==="("){s+=1,t+=l;continue}if(l===")"&&s>0){s-=1,t+=l;continue}if(l===";"&&s===0){e.push(t),t="";continue}}t+=l}return t&&e.push(t),e}function jl(n){const e=[],t=ly(n||""),r=t.length;for(let i=0;i<r;i+=1){const s=t[i],o=s.indexOf(":");if(o===-1)continue;const a=s.slice(0,o).trim(),l=s.slice(o+1).trim();a&&l&&e.push([a,l])}return e}function fe(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const a=s?String(s).split(" "):[],l=r[i]?r[i].split(" "):[],c=a.filter(d=>!l.includes(d));r[i]=[...l,...c].join(" ")}else if(i==="style"){const a=new Map([...jl(r[i]),...jl(s)]);r[i]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else r[i]=s}),r},{})}function Cr(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>fe(t,r),{})}function cy(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Ll(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(t):cy(t.getAttribute(o.name));return a==null?s:{...s,[o.name]:a}},{});return{...r,...i}}}}function Pl(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&ay(t)?!1:t!=null))}function zl(n){var e,t;const r={};return!((e=n?.attribute)!=null&&e.isRequired)&&"default"in(n?.attribute||{})&&(r.default=n.attribute.default),((t=n?.attribute)==null?void 0:t.validate)!==void 0&&(r.validate=n.attribute.validate),[n.name,r]}function dy(n,e){var t;const r=hu(n),{nodeExtensions:i,markExtensions:s}=En(n),o=(t=i.find(c=>z(c,"topNode")))==null?void 0:t.name,a=Object.fromEntries(i.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((b,k)=>{const N=z(k,"extendNodeSchema",u);return{...b,...N?N(c):{}}},{}),h=Pl({...f,content:Q(z(c,"content",u)),marks:Q(z(c,"marks",u)),group:Q(z(c,"group",u)),inline:Q(z(c,"inline",u)),atom:Q(z(c,"atom",u)),selectable:Q(z(c,"selectable",u)),draggable:Q(z(c,"draggable",u)),code:Q(z(c,"code",u)),whitespace:Q(z(c,"whitespace",u)),linebreakReplacement:Q(z(c,"linebreakReplacement",u)),defining:Q(z(c,"defining",u)),isolating:Q(z(c,"isolating",u)),attrs:Object.fromEntries(d.map(zl))}),p=Q(z(c,"parseHTML",u));p&&(h.parseDOM=p.map(b=>Ll(b,d)));const y=z(c,"renderHTML",u);y&&(h.toDOM=b=>y({node:b,HTMLAttributes:Cr(b,d)}));const g=z(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),l=Object.fromEntries(s.map(c=>{const d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,b)=>{const k=z(b,"extendMarkSchema",u);return{...g,...k?k(c):{}}},{}),h=Pl({...f,inclusive:Q(z(c,"inclusive",u)),excludes:Q(z(c,"excludes",u)),group:Q(z(c,"group",u)),spanning:Q(z(c,"spanning",u)),code:Q(z(c,"code",u)),attrs:Object.fromEntries(d.map(zl))}),p=Q(z(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>Ll(g,d)));const y=z(c,"renderHTML",u);return y&&(h.toDOM=g=>y({mark:g,HTMLAttributes:Cr(g,d)})),[c.name,h]}));return new Pc({topNode:o,nodes:a,marks:l})}function uy(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}function lr(n){return n.sort((t,r)=>{const i=z(t,"priority")||100,s=z(r,"priority")||100;return i>s?-1:i<s?1:0})}function fu(n){const e=lr(oa(n)),t=uy(e.map(r=>r.name));return t.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function pu(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
11
12`,textSerializers:o={}}=t||{};let a="";return n.nodesBetween(r,i,(l,c,d,u)=>{var f;l.isBlock&&c>r&&(a+=s);const h=o?.[l.type.name];if(h)return d&&(a+=h({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(f=l?.text)==null?void 0:f.slice(Math.max(r,c)-c,i-c))}),a}function hy(n,e){const t={from:0,to:n.content.size};return pu(n,t,e)}function mu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function fy(n,e){const t=he(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,a=>{s.push(a)});const o=s.reverse().find(a=>a.type.name===t.name);return o?{...o.attrs}:{}}function gu(n,e){const t=cs(typeof e=="string"?e:e.name,n.schema);return t==="node"?fy(n,e):t==="mark"?cu(n,e):{}}function py(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function my(n){const e=py(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function yu(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=t[s];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=e.slice(s).map(a,-1),d=e.slice(s).map(l),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),my(r)}function la(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),o=sa(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var gy=(n,e,t,r=20)=>{const i=n.doc.resolve(t);let s=r,o=null;for(;s>0&&o===null;){const a=i.node(s);a?.type.name===e?o=a:s-=1}return[o,s]};function Bn(n,e){return e.nodes[n]||e.marks[n]||null}function ii(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var yy=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,a)=>{var l,c;const d=((c=(l=i.type.spec).toText)==null?void 0:c.call(l,{node:i,pos:s,parent:o,index:a}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-s))}),t};function wo(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?kt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Si(u.attrs,t,{strict:!1}));let o=0;const a=[];if(i.forEach(({$from:u,$to:f})=>{const h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(y,g)=>{if(s&&y.inlineContent&&!y.type.allowsMarkType(s))return!1;if(!y.isText&&!y.marks.length)return;const b=Math.max(h,g),k=Math.min(p,g+y.nodeSize),N=k-b;o+=N,a.push(...y.marks.map(A=>({mark:A,from:b,to:k})))})}),o===0)return!1;const l=a.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Si(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=a.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,f)=>u+f.to-f.from,0);return(l>0?l+c:l)>=o}function by(n,e,t={}){if(!e)return jt(n,null,t)||wo(n,null,t);const r=cs(e,n.schema);return r==="node"?jt(n,e,t):r==="mark"?wo(n,e,t):!1}var ky=(n,e)=>{const{$from:t,$to:r,$anchor:i}=n.selection;if(e){const s=ds(a=>a.type.name===e)(n.selection);if(!s)return!1;const o=n.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||t.pos!==r.pos)},xy=n=>{const{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Bl(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Bs(n,e){const{nodeExtensions:t}=En(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=Q(z(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Nr(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;
vendor: 4,171 bytes, line 12
12if(n.isText)return!/\S/.test((r=n.text)!=null?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(Nr(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function bu(n){return n instanceof F}var ku=class xu{constructor(e){this.position=e}static fromJSON(e){return new xu(e.position)}toJSON(){return{position:this.position}}};function vy(n,e){const t=e.mapping.mapResult(n.position);return{position:new ku(t.pos),mapResult:t}}function wy(n){return new ku(n)}function Sy(n,e,t){var r;const{selection:i}=e;let s=null;if(su(i)&&(s=i.$cursor),s){const a=(r=n.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(a)||!a.some(c=>c.type.excludes(t)))}const{ranges:o}=i;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(a.pos,l.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(t));c=h&&p}return!c}),c})}var Cy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:a}=s,l=kt(n,r.schema);if(i)if(o){const c=cu(r,l);t.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{const p=Math.max(h,d),y=Math.min(h+f.nodeSize,u);f.marks.find(b=>b.type===l)?f.marks.forEach(b=>{l===b.type&&t.addMark(p,y,l.create({...b.attrs,...e}))}):t.addMark(p,y,l.create(e))})});return Sy(r,t,l)},Ny=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Ey=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=he(n,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:a})=>Za(s,{...o,...e})(t)?!0:a.clearNodes()).command(({state:a})=>Za(s,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},My=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=Vt(n,0,r.content.size),s=F.create(r,i);e.setSelection(s)}return!0},Ty=(n,e)=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=r;let o,a;return typeof e=="number"?(o=e,a=e):e&&"from"in e&&"to"in e?(o=e.from,a=e.to):(o=s.from,a=s.to),i&&t.doc.nodesBetween(o,a,(l,c)=>{l.isText||t.setNodeMarkup(c,void 0,{...l.attrs,dir:n})}),!0},Ay=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,o=H.atStart(r).from,a=H.atEnd(r).to,l=Vt(i,o,a),c=Vt(s,o,a),d=H.create(r,l,c);e.setSelection(d)}return!0},Oy=n=>({state:e,dispatch:t})=>{const r=he(n,e.schema);return xp(r)(e,t)};function $l(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var Iy=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:a,$to:l}=s,c=i.extensionManager.attributes,d=ii(c,a.node().type.name,a.node().attrs);if(s instanceof F&&s.node.isBlock)return!a.parentOffset||!mt(o,a.pos)?!1:(r&&(n&&$l(t,i.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:iy(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=u&&f?[{type:f,attrs:d}]:void 0,p=mt(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&mt(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(s instanceof H&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),f&&!u&&!a.parentOffset&&a.parent.type!==f)){const y=e.mapping.map(a.before()),g=e.doc.resolve(y);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}n&&$l(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Dy=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var o;const a=he(n,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const f=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if
12(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(i){let b=T.empty;const k=l.index(-1)?1:l.index(-2)?2:3;for(let L=l.depth-k;L>=l.depth-3;L-=1)b=T.from(l.node(L).copy(b));const N=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A={...ii(f,l.node().type.name,l.node().attrs),...e},S=((o=a.contentMatch.defaultType)==null?void 0:o.createAndFill(A))||void 0;b=b.append(T.from(a.createAndFill(null,S)||void 0));const I=l.before(l.depth-(k-1));t.replace(I,l.after(-N),new R(b,4-k,0));let O=-1;t.doc.nodesBetween(I,t.doc.content.size,(L,C)=>{if(O>-1)return!1;L.isTextblock&&L.content.size===0&&(O=C+1)}),O>-1&&t.setSelection(H.near(t.doc.resolve(O))),t.scrollIntoView()}return!0}const h=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,p={...ii(f,u.type.name,u.attrs),...e},y={...ii(f,l.node().type.name,l.node().attrs),...e};t.delete(l.pos,c.pos);const g=h?[{type:a,attrs:p},{type:h,attrs:y}]:[{type:a,attrs:p}];if(!mt(t.doc,l.pos,2))return!1;if(i){const{selection:b,storedMarks:k}=r,{splittableMarks:N}=s.extensionManager,A=k||b.$to.parentOffset&&b.$from.marks();if(t.split(l.pos,2,g).scrollIntoView(),!A||!i)return!0;const S=A.filter(I=>N.includes(I.type.name));t.ensureMarks(S)}return!0},$s=(n,e)=>{const t=ds(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&Lt(n.doc,t.pos)&&n.join(t.pos),!0},Fs=(n,e)=>{const t=ds(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===i?.type&&Lt(n.doc,r)&&n.join(r),!0};function Ry(n){const e=n.doc,t=e.firstChild;if(!t)return null;const r=e.resolve(1),i=e.resolve(t.nodeSize-1);return H.between(r,i)}var jy=(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:f}=i.extensionManager,h=he(n,o.schema),p=he(e,o.schema),{selection:y,storedMarks:g}=o,{$from:b,$to:k}=y,N=b.blockRange(k),A=g||y.$to.parentOffset&&y.$from.marks();if(!N)return!1;const S=ds(W=>Bs(W.type.name,u))(y),I=y.from===0&&y.to===o.doc.content.size,O=o.doc.content.content,L=O.length===1?O[0]:null,C=I&&L&&Bs(L.type.name,u)?{node:L,pos:0}:null,D=S??C,Z=!!S&&N.depth>=1&&N.depth-S.depth<=1,G=!!C;if((Z||G)&&D){if(D.node.type===h)return I&&G?l().command(({tr:W,dispatch:E})=>{const $=Ry(W);return $?(W.setSelection($),E&&E(W),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Bs(D.node.type.name,u)&&h.validContent(D.node.content))return l().command(()=>(s.setNodeMarkup(D.pos,h),!0)).command(()=>$s(s,h)).command(()=>Fs(s,h)).run()}return!t||!A||!a?l().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>$s(s,h)).command(()=>Fs(s,h)).run():l().command(()=>{const W=d().wrapInList(h,r),E=A.filter($=>f.includes($.type.name));return s.ensureMarks(E),W?!0:c.clearNodes()}).wrapInList(h,r).command(()=>$s(s,h)).command(()=>Fs(s,h)).run()},Ly=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=kt(n,r.schema);return wo(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Py=(n,e,t={})=>({state:r,commands:i})=>{const s=he(n,r.schema),o=he(e,r.schema),a=jt(r,s,t);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?i.setNode(o,l):i.setNode(s,{...l,...t})},zy=(n,e={})=>({state:t,commands:r})=>{const i=he(n,t.schema);return jt(t,i,e)?r.lift(i):r.wrapIn(i,e)},By=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.tr,a=s.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,n.schema.text(s.text,l))}else o.delete(s.from,s.to)}return!0}}return!1},$y=(n={})=>({tr:e,dispatch:t,editor:r})=>{const{ignoreClearable:i=!1}=n,{selection:s}=e,{empty:o,ranges:a}=s;if(o)return!0;const{nonClearableMarks:l}=r.extensionManager;if(t){const c=Object.values(r.schema.marks).filter(d=>i||!l.includes(d.name));a.forEach(d=>{for(const u of c)e.removeMark(d.$from.pos,d.$to.pos,u)})}return!0},Fy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=t,l=kt(n,r.schema),{$from:c,empty:d,ranges:u}=a;if(!i)return!0;
vendor: 10,377 bytes, lines 12-13
12if(d&&o){let{from:f,to:h}=a;const p=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,y=sa(c,l,p);y&&(f=y.from,h=y.to),t.removeMark(f,h,l)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,l)});return t.removeStoredMark(l),!0},Hy=n=>({tr:e,state:t,dispatch:r})=>{const{selection:i}=t;let s,o;return typeof n=="number"?(s=n,o=n):n&&"from"in n&&"to"in n?(s=n.from,o=n.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},Uy=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const a=cs(typeof n=="string"?n:n.name,r.schema);if(!a)return!1;a==="node"&&(s=he(n,r.schema)),a==="mark"&&(o=kt(n,r.schema));let l=!1;return t.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let f,h,p,y;t.selection.empty?r.doc.nodesBetween(d,u,(g,b)=>{s&&s===g.type&&(l=!0,p=Math.max(b,d),y=Math.min(b+g.nodeSize,u),f=b,h=g)}):r.doc.nodesBetween(d,u,(g,b)=>{b<d&&s&&s===g.type&&(l=!0,p=Math.max(b,d),y=Math.min(b+g.nodeSize,u),f=b,h=g),b>=d&&b<=u&&(s&&s===g.type&&(l=!0,i&&t.setNodeMarkup(b,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(k=>{if(o===k.type&&(l=!0,i)){const N=Math.max(b,d),A=Math.min(b+g.nodeSize,u);t.addMark(N,A,o.create({...k.attrs,...e}))}}))}),h&&(f!==void 0&&i&&t.setNodeMarkup(f,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&t.addMark(p,y,o.create({...g.attrs,...e}))}))}),l},Vy=(n,e={})=>({state:t,dispatch:r})=>{const i=he(n,t.schema);return fp(i,e)(t,r)},_y=(n,e={})=>({state:t,dispatch:r})=>{const i=he(n,t.schema);return pp(i,e)(t,r)},Wy=class{constructor(){this.callbacks={}}on(n,e){return this.callbacks[n]||(this.callbacks[n]=[]),this.callbacks[n].push(e),this}emit(n,...e){const t=this.callbacks[n];return t&&t.forEach(r=>r.apply(this,e)),this}off(n,e){const t=this.callbacks[n];return t&&(e?this.callbacks[n]=t.filter(r=>r!==e):delete this.callbacks[n]),this}once(n,e){const t=(...r)=>{this.off(n,t),e.apply(this,r)};return this.on(n,t)}removeAllListeners(){this.callbacks={}}},us=class{constructor(n){var e;this.find=n.find,this.handler=n.handler,this.undoable=(e=n.undoable)!=null?e:!0}},Ky=(n,e)=>{if(ia(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Hr(n){var e;const{editor:t,from:r,to:i,text:s,rules:o,plugin:a}=n,{view:l}=t;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const u=yy(c)+s;return o.forEach(f=>{if(d)return;const h=Ky(u,f.find);if(!h)return;const p=l.state.tr,y=as({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:i},{commands:b,chain:k,can:N}=new ls({editor:t,state:y});f.handler({state:y,range:g,match:h,commands:b,chain:k,can:N})===null||!p.steps.length||(f.undoable&&p.setMeta(a,{transform:p,from:r,to:i,text:s}),l.dispatch(p),d=!0)}),d}function qy(n){const{editor:e,rules:t}=n,r=new ae({state:{init(){return null},apply(i,s,o){const a=i.getMeta(r);if(a)return a;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=aa(T.from(d),o.schema);const{from:u}=l,f=u+d.length;Hr({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,a){return Hr({editor:e,from:s,to:o,text:a,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Hr({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Hr({editor:e,from:o.pos,to:o.pos,text:`
13`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Jy(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ur(n){return Jy(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function vu(n,e){const t={...n};return Ur(n)&&Ur(e)&&Object.keys(e).forEach(r=>{Ur(e[r])&&Ur(n[r])?t[r]=vu(n[r],e[r]):t[r]=e[r]}),t}var ca=class{constructor(n={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...n},this.name=this.config.name}get options(){return{...Q(z(this,"addOptions",{name:this.name}))}}get storage(){return{...Q(z(this,"addStorage",{name:this.name,options:this.options}))}}configure(n={}){const e=this.extend({...this.config,addOptions:()=>vu(this.options,n)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(n={}){const e=new this.constructor({...this.config,...n});return e.parent=this,this.child=e,e.name="name"in n?n.name:e.parent.name,e}},sn=class wu extends ca{constructor(){super(...arguments),this.type="mark"}static create(e={}){const t=typeof e=="function"?e():e;return new wu(t)}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>c?.type.name===t.name))return!1;const l=o.find(c=>c?.type.name===t.name);return l&&r.removeStoredMark(l),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function Gy(n){return typeof n=="number"}var Yy=class{constructor(n){this.find=n.find,this.handler=n.handler}},Zy=(n,e,t)=>{if(ia(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function Xy(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:a}=n,{commands:l,chain:c,can:d}=new ls({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,i,(h,p)=>{var y,g,b,k,N;if((g=(y=h.type)==null?void 0:y.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;const A=(N=(k=(b=h.content)==null?void 0:b.size)!=null?k:h.nodeSize)!=null?N:0,S=Math.max(r,p),I=Math.min(i,p+A);if(S>=I)return;const O=h.isText?h.text||"":h.textBetween(S-p,I-p,void 0,"");Zy(O,s.find,o).forEach(C=>{if(C.index===void 0)return;const D=S+C.index+1,Z=D+C[0].length,G={from:t.tr.mapping.map(D),to:t.tr.mapping.map(Z)},W=s.handler({state:t,range:G,match:C,commands:l,chain:c,can:d,pasteEvent:o,dropEvent:a});u.push(W)})}),u.every(h=>h!==null)}var Vr=null,Qy=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)==null||e.setData("text/html",n),t};function eb(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{const y=d.tr,g=as({state:d,transaction:y});if(!(!Xy({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:a})||!y.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,y}};return t.map(d=>new ae({view(u){const f=p=>{var y;r=(y=u.dom.parentElement)!=null&&y.contains(p.target)?u.dom.parentElement:null,r&&(Vr=e)},h=()=>{Vr&&(Vr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(s=r===u.dom.parentElement,a=f,!s){const h=Vr;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return o=f,i=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,f,h)=>{const p=u[0],y=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,b=p.getMeta("applyPasteRules"),k=!!b;if(!y&&!g&&!k)return;if(k){let{text:S}=b;typeof S=="string"?S=S:S=aa(T.from(S),h.schema);const{from:I}=b,O=I+S.length,L=Qy(S);return l({rule:d,state:h,from:I,to:{b:O},pasteEvt:L})}const N=f.doc.content.findDiffStart(h.doc.content),A=f.doc.content.findDiffEnd(h.doc.content);if(!(!Gy(N)||!A||N===A.b))return l({rule:d,state:h,from:N,to:A,pasteEvt:o})}}))}var hs=class{constructor(n,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=n,this.extensions=fu(n),this.schema=dy(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((n,e)=>{const t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Bn(e.name,this.schema)},r=z(e,"addCommands",t);return r?{...n,...r()}:n},{})}get plugins(){const{editor:n}=this;return lr([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:n,type:Bn(r.name,this.schema)},s=[],o=z(r,"addKeyboardShortcuts",i);let a={};if(r.type==="mark"&&z(r,"exitable",i)&&(a.ArrowRight=()=>sn.handleExit({editor:n,mark:r})),o){const f=Object.fromEntries(Object.entries(o()).map(([h,p])=>[h,()=>p({editor:n})]));a={...a,...f}}const l=dg(a);s.push(l);const c=z(r,"addInputRules",i);if(Bl(r,n.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=qy({editor:n,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}const d=z(r,"addPasteRules",i);if(Bl(r,n.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const h=eb({editor:n,rules:f});s.push(...h)}}const u=z(r,"addProseMirrorPlugins",i);if(u){const f=u();s.push(...f)}return s})}get attributes(){return hu(this.extensions)}get nodeViews(){const{editor:n}=this,{nodeExtensions:e}=En(this.extensions);return Object.fromEntries(e.filter(t=>!!z(t,"addNodeView")).map(t=>{const r=this.attributes.filter(l=>l.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:he(t.name,this.schema)},s=z(t,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const a=(l,c,d,u,f)=>{const h=Cr(l,r);return o({node:l,view:c,getPos:d,decorations:u,innerDecorations:f,editor:n,extension:t,HTMLAttributes:h})};return[t.name,a]}
13))}dispatchTransaction(n){const{editor:e}=this;return lr([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Bn(i.name,this.schema)},o=z(i,"dispatchTransaction",s);return o?a=>{o.call(s,{transaction:a,next:r})}:r},n)}transformPastedHTML(n){const{editor:e}=this;return lr([...this.extensions]).reduce((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:Bn(i.name,this.schema)},o=z(i,"transformPastedHTML",s);return o?(a,l)=>{const c=r(a,l);return o.call(s,c)}:r},n||(r=>r))}get markViews(){const{editor:n}=this,{markExtensions:e}=En(this.extensions);return Object.fromEntries(e.filter(t=>!!z(t,"addMarkView")).map(t=>{const r=this.attributes.filter(a=>a.type===t.name),i={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:n,type:kt(t.name,this.schema)},s=z(t,"addMarkView",i);if(!s)return[];const o=(a,l,c)=>{const d=Cr(a,r);return s()({mark:a,view:l,inline:c,editor:n,extension:t,HTMLAttributes:d,updateAttributes:u=>{fb(a,n,u)}})};return[t.name,o]}))}destroy(){this.extensions.forEach(n=>{let e=n;for(;e.parent;){const t=e.parent;t.child===e&&(t.child=null),e=t}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const n=this.extensions;this.editor.extensionStorage=Object.fromEntries(n.map(e=>[e.name,e.storage])),n.forEach(e=>{var t,r;const i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Bn(e.name,this.schema)};e.type==="mark"&&(((t=Q(z(e,"keepOnSplit",i)))==null||t)&&this.splittableMarks.push(e.name),(r=Q(z(e,"clearable",i)))==null||r||this.nonClearableMarks.push(e.name));const s=z(e,"onBeforeCreate",i),o=z(e,"onCreate",i),a=z(e,"onUpdate",i),l=z(e,"onSelectionUpdate",i),c=z(e,"onTransaction",i),d=z(e,"onFocus",i),u=z(e,"onBlur",i),f=z(e,"onDestroy",i);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),a&&this.editor.on("update",a),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}};hs.resolve=fu;hs.sort=lr;hs.flatten=oa;var tb={};ra(tb,{ClipboardTextSerializer:()=>Cu,Commands:()=>Nu,Delete:()=>Eu,Drop:()=>Mu,Editable:()=>Tu,FocusEvents:()=>Ou,Keymap:()=>Iu,Paste:()=>Du,Tabindex:()=>Ru,TextDirection:()=>ju,focusEventsPluginKey:()=>Au});var de=class Su extends ca{constructor(){super(...arguments),this.type="extension"}static create(e={}){const t=typeof e=="function"?e():e;return new Su(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}},Cu=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ae({key:new me("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,s=mu(t),{blockSeparator:o}=this.options,a={...o!==void 0?{blockSeparator:o}:{},textSerializers:s};return[...i.ranges].sort((c,d)=>c.$from.pos-d.$from.pos).map(({$from:c,$to:d})=>pu(r,{from:c.pos,to:d.pos},a)).join(o??`
14
15`)}}})]}}),Nu=de.create({name:"commands",addCommands(){return{...ru}}}),Eu=de.create({name:"delete",onUpdate({transaction:n,appendedTransactions:e}){var t,r,i;const s=()=>{var o,a,l,c;if((c=(l=(a=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,n))!=null?c:n.getMeta("y-sync$"))return;const d=du(n.before,[n,...e]);yu(d).forEach(h=>{d.mapping.mapResult(h.oldRange.from).deletedAfter&&d.mapping.mapResult(h.oldRange.to).deletedBefore&&d.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,y)=>{const g=y+p.nodeSize-2,b=h.oldRange.from<=y&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:y,to:g,newFrom:d.mapping.map(y),newTo:d.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!b,editor:this.editor,transaction:n,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((h,p)=>{var y,g;if(h instanceof In){const b=f.slice(p).map(h.from,-1),k=f.slice(p).map(h.to),N=f.invert().map(b,-1),A=f.invert().map(k),S=b>0?(y=d.doc.nodeAt(b-1))==null?void 0:y.marks.some(O=>O.eq(h.mark)):!1,I=(g=d.doc.nodeAt(k))==null?void 0:g.marks.some(O=>O.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:N,to:A},newRange:{from:b,to:k},partial:!!(I||S),editor:this.editor,transaction:n,combinedTransform:d})}})};(i=(r=(t=this.editor.options.coreExtensionOptions)==null?void 0:t.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),Mu=de.create({name:"drop",addProseMirrorPlugins(){return[new ae({key:new me("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>
vendor: 20,035 bytes, lines 15-87
15{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),Tu=de.create({name:"editable",addProseMirrorPlugins(){return[new ae({key:new me("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Au=new me("focusEvents"),Ou=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ae({key:Au,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Iu=de.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:u}=l,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?a.doc.resolve(f-1):u,y=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,b=y&&p.parent.childCount===1?g===u.pos:V.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ci()||lu()?s:i},addProseMirrorPlugins(){return[new ae({key:new me("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(y=>y.getMeta("composition")))return;const r=n.some(y=>y.docChanged)&&!e.doc.eq(t.doc),i=n.some(y=>y.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:a}=e.selection,l=V.atStart(e.doc).from,c=V.atEnd(e.doc).to;if(s||!(o===l&&a===c)||!Nr(t.doc))return;const f=t.tr,h=as({state:t,transaction:f}),{commands:p}=new ls({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),Du=de.create({name:"paste",addProseMirrorPlugins(){return[new ae({key:new me("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),Ru=de.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new ae({key:new me("tabindex"),props:{attributes:()=>{var n;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(n=this.options.value)!=null?n:"0"}}}})]}}),ju=de.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:n}=En(this.extensions);return[{types:n.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const 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 ae({key:new me("textDirection"),props:{attributes:()=>{const n=this.options.direction;return n?{dir:n}:{}}}})]}}),nb=class Yn{constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Yn(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Yn(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Yn(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=t.isInline,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!i&&!o&&l.depth<=this.depth)return;const c=new Yn(l,this.editor,i,i||o?t:null);i&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let a=0;a<o.length;a+=1){const l=o[a];if(s[l]!==t[l])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(l=>t[l]===o.node.attrs[l])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},rb=`.ProseMirror {
16  position: relative;
17}
18
19.ProseMirror {
20  word-wrap: break-word;
21  white-space: pre-wrap;
22  white-space: break-spaces;
23  -webkit-font-variant-ligatures: none;
24  font-variant-ligatures: none;
25  font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
26}
27
28.ProseMirror [contenteditable="false"] {
29  white-space: normal;
30}
31
32.ProseMirror [contenteditable="false"] [contenteditable="true"] {
33  white-space: pre-wrap;
34}
35
36.ProseMirror pre {
37  white-space: pre-wrap;
38}
39
40img.ProseMirror-separator {
41  display: inline !important;
42  border: none !important;
43  margin: 0 !important;
44  width: 0 !important;
45  height: 0 !important;
46}
47
48.ProseMirror-gapcursor {
49  display: none;
50  pointer-events: none;
51  position: absolute;
52  margin: 0;
53}
54
55.ProseMirror-gapcursor:after {
56  content: "";
57  display: block;
58  position: absolute;
59  top: -2px;
60  width: 20px;
61  border-top: 1px solid black;
62  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
63}
64
65@keyframes ProseMirror-cursor-blink {
66  to {
67    visibility: hidden;
68  }
69}
70
71.ProseMirror-hideselection *::selection {
72  background: transparent;
73}
74
75.ProseMirror-hideselection *::-moz-selection {
76  background: transparent;
77}
78
79.ProseMirror-hideselection * {
80  caret-color: transparent;
81}
82
83.ProseMirror-focused .ProseMirror-gapcursor {
84  display: block;
85}`;function Lu(n,e,t){const r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var ib=class extends Wy{constructor(n={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:vy,createMappablePosition:wy},this.setOptions(n),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),t=ou(e,this.options.autofocus);this.editorState=xn.create({doc:e,schema:this.schema,selection:t||void 0}),this.options.element&&this.mount(this.options.element)}mount(n){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(n),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const n=this.editorView.dom;n?.editor&&delete n.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(n){console.warn("Failed to remove CSS element:",n)}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=Lu(rb,this.options.injectNonce))}setOptions(n={}){this.options={...this.options,...n},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(n,e=!0){this.setOptions({editable:n}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:n=>{this.editorState=n},dispatch:n=>{this.dispatchTransaction(n)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(n,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in n)return Reflect.get(n,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(n,e){const t=uu(e)?e(n,[...this.state.plugins]):[...this.state.plugins,n],r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}unregisterPlugin(n){if(this.isDestroyed)return;const e=this.state.plugins;let t=e;if([].concat(n).forEach(i=>{const s=typeof i=="string"?`${i}$`:i.key;t=t.filter(o=>!o.key.startsWith(s))}),e.length===t.length)return;const r=this.state.reconfigure({plugins:t});return this.view.updateState(r),r}createExtensionManager(){var n,e,t,r;const s=[...this.options.enableCoreExtensions?[Tu,Cu.configure({blockSeparator:(e=(n=this.options.coreExtensionOptions)==null?void 0:n.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Nu,Ou,Iu,Ru.configure({value:(r=(t=this.options.coreExtensionOptions)==null?void 0:t.tabindex)==null?void 0:r.value}),Mu,Du,Eu,ju.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new hs(s,this)}createCommandManager(){this.commandManager=new ls({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let n;try{n=vo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(t=>t.name!=="collaboration"),this.createExtensionManager()}}),n=vo(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return n}createView(n){const{editorProps:e,enableExtensionDispatchTransaction:t}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=t?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new tu(n,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.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(n){this.isCapturingTransaction=!0,n(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(n){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=n;return}n.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:t}=this.state.applyTransaction(n),r=!this.state.selection.eq(e.selection),i=t.includes(n),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:n,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:n,appendedTransactions:t.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:n});const o=t.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=o?.getMeta("focus"),l=o?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),!(n.getMeta("preventUpdate")||!t.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:n,appendedTransactions:t.slice(1)})}getAttributes(n){return gu(this.state,n)}isActive(n,e){const t=typeof n=="string"?n:null,r=typeof n=="string"?e:n;return by(this.state,t,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return aa(this.state.doc.content,this.schema)}getText(n){const{blockSeparator:e=`
86
87`,textSerializers:t={}}=n||{};return hy(this.state.doc,{blockSeparator:e,textSerializers:{...mu(this.schema),...t}})}get isEmpty(){return Nr(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var n,e;return(e=(n=this.editorView)==null?void 0:n.isDestroyed)!=null?e:!0}$node(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelector(n,e))||null}$nodes(n,e){var t;return((t=this.$doc)==null?void 0:t.querySelectorAll(n,e))||null}$pos(n){const e=this.state.doc.resolve(n),t=n>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new nb(e,this,!1,t)}get $doc(){return this.$pos(0)}};function Mn(n){return new us({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Q(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=t.from+a.indexOf(o),d=c+o.length;if(la(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(y=>y===n.type&&y!==h.mark.type)).filter(h=>h.to>c).length)return null;d<t.to&&s.delete(d,t.to),c>t.from&&s.delete(t.from+l,c);const f=t.from+l+o.length;s.addMark(t.from+l,f,n.type.create(i||{})),s.removeStoredMark(n.type)}},undoable:n.undoable})}function sb(n){return new us({find:n.find,handler:({state:e,range:t,match:r})=>{const i=Q(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let a=t.to;const l=n.type.create(i);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>a?d=a:a=d+r[1].length;const u=r[0][r[0].length-1];s.insertText(u,o+r[0].length-1),s.replaceWith(d,a,l)}else if(r[0]){const c=n.type.isInline?o:o-1;s.insert(c,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(a))}s.scrollIntoView()},undoable:n.undoable})}function So(n){return new us({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=Q(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)},undoable:n.undoable})}function Tn(n){return new us({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=Q(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),l=o.doc.resolve(t.from).blockRange(),c=l&&Vo(l,n.type,s);if(!c)return null;if(o.wrap(l,c),n.keepMarks&&n.editor){const{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){const y=p.filter(g=>h.includes(g.type.name));o.ensureMarks(y)}}if(n.keepAttributes){const u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,s).run()}const d=o.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Lt(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&o.join(t.from-1)},undoable:n.undoable})}function ob(n,e){const{selection:t}=n,{$from:r}=t;if(t instanceof F){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var ab={};ra(ab,{createAtomBlockMarkdownSpec:()=>lb,createBlockMarkdownSpec:()=>cb,createInlineMarkdownSpec:()=>hb,parseAttributes:()=>da,parseIndentedBlocks:()=>Co,renderNestedMarkdownContent:()=>ha,serializeAttributes:()=>ua});function da(n){if(!n?.trim())return{};const e={},t=[],r=n.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}
87__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const c=i.map(d=>d.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,d])=>{var u;const f=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=t[f];h&&(e[c]=h.slice(1,-1))});const l=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 l&&l.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function ua(n){if(!n||Object.keys(n).length===0)return"";const e=[];return n.class&&String(n.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),n.id&&e.push(`#${n.id}`),Object.entries(n).forEach(([t,r])=>{t==="class"||t==="id"||(r===!0?e.push(t):r!==!1&&r!=null&&e.push(`${t}="${String(r)}"`))}),e.join(" ")}function lb(n){const{nodeName:e,name:t,parseAttributes:r=da,serializeAttributes:i=ua,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:a}=n,l=t||e,c=d=>{if(!a)return d;const u={};return a.forEach(f=>{f in d&&(u[f]=d[f])}),u};return{parseMarkdown:(d,u)=>{const f={...s,...d.attributes};return u.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const f=new RegExp(`^:::${l}(?:\\s|$)`,"m"),h=(u=d.match(f))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(d,u,f){const h=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(h);if(!p)return;const y=p[1]||"",g=r(y);if(!o.find(k=>!(k in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:d=>{const u=c(d.attrs||{}),f=i(u),h=f?` {${f}}`:"";return`:::${l}${h} :::`}}}function cb(n){const{nodeName:e,name:t,getContent:r,parseAttributes:i=da,serializeAttributes:s=ua,defaultAttributes:o={},content:a="block",allowedAttributes:l}=n,c=t||e,d=u=>{if(!l)return u;const f={};return l.forEach(h=>{h in u&&(f[h]=u[h])}),f};return{parseMarkdown:(u,f)=>{let h;if(r){const y=r(u);h=typeof y=="string"?[{type:"text",text:y}]:y}else a==="block"?h=f.parseChildren(u.tokens||[]):h=f.parseInline(u.tokens||[]);const p={...o,...u.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=u.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(u,f,h){var p;const y=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(y);if(!g)return;const[b,k=""]=g,N=i(k);let A=1;const S=b.length;let I="";const O=/^:::([\w-]*)(\s.*)?/gm,L=u.slice(S);for(O.lastIndex=0;;){const C=O.exec(L);if(C===null)break;const D=C.index,Z=C[1];if(!((p=C[2])!=null&&p.endsWith(":::"))){if(Z)A+=1;else if(A-=1,A===0){const G=L.slice(0,D);I=G.trim();const W=u.slice(0,S+D+C[0].length);let E=[];if(I)if(a==="block")for(E=h.blockTokens(G),E.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=h.inlineTokens($.text))});E.length>0;){const $=E[E.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))E.pop();else break}else E=h.inlineTokens(I);return{type:e,raw:W,attributes:N,content:I,tokens:E}}}}}},renderMarkdown:(u,f)=>{const h=d(u.attrs||{}),p=s(h),y=p?` {${p}}`:"",g=f.renderChildren(u.content||[],`
88
89`);return`:::${c}${y}
90
91${g}
92
93:::`}}}function db(n){if(!n.trim())return{};const e={},t=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=t.exec(n);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=t.exec(n)}return e}function ub(n){return Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(" ")}function hb(n){const{nodeName:e,name:t,getContent:r,parseAttributes:i=db,serializeAttributes:s=ub,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=n,c=t||e,d=f=>{if(!l)return f;const h={};return l.forEach(p=>{const y=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(y in f){const b=f[y];if(g!==void 0&&b===g)return;h[y]=b}}),h},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const p={...o,...f.attributes};if(a)return h.createNode(e,p);const y=r?r(f):f.content||"";return y?h.createNode(e,p,[h.createTextNode(y)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=a?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=f.match(h),y=p?.index;return y!==void 0?y:-1},tokenize(f,h,p){const y=a?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),g=f.match(y);if(!g)return;let b="",k="";if(a){const[,A]=g;k=A}else{const[,A,S]=g;k=A,b=S||""}const N=i(k.trim());return{type:e,raw:g[0],content:b.trim(),attributes:N}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=d(f.attrs||{}),y=s(p),g=y?` ${y}`:"";return a?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function Co(n,e,t){var r,i,s,o;const a=n.split(`
94`),l=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<a.length;){const f=a[d],h=f.match(e.itemPattern);if(!h){if(l.length>0)break;if(f.trim()===""){d+=1,c=`${c}${f}
95`;continue}else return}const p=e.extractItemData(h),{indentLevel:y,mainContent:g}=p;c=`${c}${f}
96`;const b=[g];for(d+=1;d<a.length;){const S=a[d];if(S.trim()===""){const O=a.slice(d+1).findIndex(D=>D.trim()!=="");if(O===-1)break;if((((i=(r=a[d+1+O].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){b.push(S),c=`${c}${S}
97`,d+=1;continue}else break}if((((o=(s=S.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>y)b.push(S),c=`${c}${S}
98`,d+=1;else break}let k;const N=b.slice(1);if(N.length>0){const S=N.map(I=>I.slice(y+u)).join(`
99`);S.trim()&&(e.customNestedParser?k=e.customNestedParser(S):k=t.blockTokens(S))}const A=e.createToken(p,k);l.push(A)}if(l.length!==0)return{items:l,raw:c}}function ha(n,e,t,r){if(!n||!Array.isArray(n.content))return"";const i=typeof t=="function"?t(r):t,[s,...o]=n.content,a=e.renderChildren([s]);let l=`${i}${a}`;return o&&o.length>0&&o.forEach((c,d)=>{var u,f;const h=(f=(u=e.renderChild)==null?void 0:u.call(e,c,d+1))!=null?f:e.renderChildren([c]);if(h!=null){const p=h.split(`
100`).map(y=>y?e.indent(y):e.indent("")).join(`
101`);l+=c.type==="paragraph"?`
102
103${p}`:`
104${p}`}}),l}function fb(n,e,t={}){const{state:r}=e,{doc:i,tr:s}=r,o=n;i.descendants((a,l)=>{const c=s.mapping.map(l),d=s.mapping.map(l)+a.nodeSize;let u=null;if(a.marks.forEach(h=>{if(h!==o)return!1;u=h}),!u)return;let f=!1;if(Object.keys(t).forEach(h=>{t[h]!==u.attrs[h]&&(f=!0)}),f){const h=n.type.create({...n.attrs,...t});s.removeMark(c,d,n.type),s.addMark(c,d,h)}}),s.docChanged&&e.view.dispatch(s)}var Ue=class Pu extends ca{constructor(){super(...arguments),this.type="node"}static create(e={}){const t=typeof e=="function"?e():e;return new Pu(t)}configure(e){return super.configure(e)}extend(e){const t=typeof e=="function"?e():e;return super.extend(t)}};function tn(n){return new Yy({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=Q(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=t.to;if(a){const d=l.search(/\S/),u=t.from+l.indexOf(a),f=u+a.length;if(la(t.from,t.to,e.doc).filter(y=>y.mark.type.excluded.find(b=>b===n.type&&b!==y.mark.type)).filter(y=>y.to>u).length)return null;f<t.to&&o.delete(f,t.to),u>
vendor: 6,391 bytes, line 104
104t.from&&o.delete(t.from+d,u),c=t.from+d+a.length,o.addMark(t.from+d,c,n.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(n.type)}}})}const{getOwnPropertyNames:pb,getOwnPropertySymbols:mb}=Object,{hasOwnProperty:gb}=Object.prototype;function Hs(n,e){return function(r,i,s){return n(r,i,s)&&e(r,i,s)}}function _r(n){return function(t,r,i){if(!t||!r||typeof t!="object"||typeof r!="object")return n(t,r,i);const{cache:s}=i,o=s.get(t),a=s.get(r);if(o&&a)return o===r&&a===t;s.set(t,r),s.set(r,t);const l=n(t,r,i);return s.delete(t),s.delete(r),l}}function yb(n){return n?.[Symbol.toStringTag]}function Fl(n){return pb(n).concat(mb(n))}const bb=Object.hasOwn||((n,e)=>gb.call(n,e));function on(n,e){return n===e||!n&&!e&&n!==n&&e!==e}const kb="__v",xb="__o",vb="_owner",{getOwnPropertyDescriptor:Hl,keys:Ul}=Object;function wb(n,e){return n.byteLength===e.byteLength&&Ni(new Uint8Array(n),new Uint8Array(e))}function Sb(n,e,t){let r=n.length;if(e.length!==r)return!1;for(;r-- >0;)if(!t.equals(n[r],e[r],r,r,n,e,t))return!1;return!0}function Cb(n,e){return n.byteLength===e.byteLength&&Ni(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Nb(n,e){return on(n.getTime(),e.getTime())}function Eb(n,e){return n.name===e.name&&n.message===e.message&&n.cause===e.cause&&n.stack===e.stack}function Mb(n,e){return n===e}function Vl(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=n.entries();let o,a,l=0;for(;(o=s.next())&&!o.done;){const c=e.entries();let d=!1,u=0;for(;(a=c.next())&&!a.done;){if(i[u]){u++;continue}const f=o.value,h=a.value;if(t.equals(f[0],h[0],l,u,n,e,t)&&t.equals(f[1],h[1],f[0],h[0],n,e,t)){d=i[u]=!0;break}u++}if(!d)return!1;l++}return!0}const Tb=on;function Ab(n,e,t){const r=Ul(n);let i=r.length;if(Ul(e).length!==i)return!1;for(;i-- >0;)if(!zu(n,e,t,r[i]))return!1;return!0}function $n(n,e,t){const r=Fl(n);let i=r.length;if(Fl(e).length!==i)return!1;let s,o,a;for(;i-- >0;)if(s=r[i],!zu(n,e,t,s)||(o=Hl(n,s),a=Hl(e,s),(o||a)&&(!o||!a||o.configurable!==a.configurable||o.enumerable!==a.enumerable||o.writable!==a.writable)))return!1;return!0}function Ob(n,e){return on(n.valueOf(),e.valueOf())}function Ib(n,e){return n.source===e.source&&n.flags===e.flags}function _l(n,e,t){const r=n.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=n.values();let o,a;for(;(o=s.next())&&!o.done;){const l=e.values();let c=!1,d=0;for(;(a=l.next())&&!a.done;){if(!i[d]&&t.equals(o.value,a.value,o.value,a.value,n,e,t)){c=i[d]=!0;break}d++}if(!c)return!1}return!0}function Ni(n,e){let t=n.byteLength;if(e.byteLength!==t||n.byteOffset!==e.byteOffset)return!1;for(;t-- >0;)if(n[t]!==e[t])return!1;return!0}function Db(n,e){return n.hostname===e.hostname&&n.pathname===e.pathname&&n.protocol===e.protocol&&n.port===e.port&&n.hash===e.hash&&n.username===e.username&&n.password===e.password}function zu(n,e,t,r){return(r===vb||r===xb||r===kb)&&(n.$$typeof||e.$$typeof)?!0:bb(e,r)&&t.equals(n[r],e[r],r,r,n,e,t)}const Rb="[object ArrayBuffer]",jb="[object Arguments]",Lb="[object Boolean]",Pb="[object DataView]",zb="[object Date]",Bb="[object Error]",$b="[object Map]",Fb="[object Number]",Hb="[object Object]",Ub="[object RegExp]",Vb="[object Set]",_b="[object String]",Wb={"[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},Kb="[object URL]",qb=Object.prototype.toString;function Jb({areArrayBuffersEqual:n,areArraysEqual:e,areDataViewsEqual:t,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,b,k){if(g===b)return!0;if(g==null||b==null)return!1;const N=typeof g;if(N!==typeof b)return!1;if(N!=="object")return N==="number"?a(g,b,k):N==="function"?s(g,b,k):!1;const A=g.constructor;if(A!==b.constructor)return!1;if(A===Object)return l(g,b,k);if(Array.isArray(g))return e(g,b,k);if(A===Date)return r(g,b,k);if(A===RegExp)return d(g,b,k);if(A===Map)return o(g,b,k);if(A===Set)return u(g,b,k);const S=qb.call(g);if(S===zb)return r(g,b,k);if(S===Ub)return d(g,b,k);if(S===$b)return o(g,b,k);if(S===Vb)return u(g,b,k);if(S===Hb)return typeof g.then!="function"&&typeof b.then!="function"&&l(g,b,k);if(S===Kb)return h(g,b,k);if(S===Bb)return i(g,b,k);if(S===jb)return l(g,b,k);if(Wb[S])return f(g,b,k);if(S===Rb)return n(g,b,k);if(S===Pb)return t(g,b,k);if(S===Lb||S===Fb||S===_b)return c(g,b,k);if(p){let I=p[S];if(!I){const O=yb(g);O&&(I=p[O])}if(I)return I(g,b,k)}return!1}}function Gb({circular:n,createCustomConfig:e,strict:t}){let r={areArrayBuffersEqual:wb,areArraysEqual:t?$n:Sb,areDataViewsEqual:Cb,areDatesEqual:Nb,areErrorsEqual:Eb,areFunctionsEqual:Mb,areMapsEqual:t?Hs(Vl,$n):Vl,areNumbersEqual:Tb,areObjectsEqual:t?$n:Ab,arePrimitiveWrappersEqual:Ob,areRegExpsEqual:Ib,areSetsEqual:t?Hs(_l,$n):_l,areTypedArraysEqual:t?Hs(Ni,$n):Ni,areUrlsEqual:Db,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),n){const i=_r(r.areArraysEqual),s=_r(r.areMapsEqual),o=_r(r.areObjectsEqual),a=_r(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:a})}return r}function Yb(n){return function(e,t,r,i,s,o,a){return n(e,t,a)}}function Zb({circular:n,comparator:e,createState:t,equals:r,strict:i}){if(t)return function(a,l){const{cache:c=n?new WeakMap:void 0,meta:d}=t();return e(a,l,{cache:c,equals:r,meta:d,strict:i})};if(n)return function(a,l){return e(a,l,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const s={cache:void 0,equals:r,meta:void 0,strict:i};return function(a,l){return e(a,l,s)}}const Xb=zt();zt({strict:!0});zt({circular:!0});zt({circular:!0,strict:!0});zt({createInternalComparator:()=>on});zt({strict:!0,createInternalComparator:()=>on});zt({circular:!0,createInternalComparator:()=>on});zt({circular:!0,createInternalComparator:()=>on,strict:!0});function zt(n={}){const{circular:e=!1,createInternalComparator:t,createState:r,strict:i=!1}=n,s=Gb(n),o=Jb(s),a=t?t(o):Yb(o);
104return Zb({circular:e,comparator:o,createState:r,equals:a,strict:i})}var Qb=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},e0=({contentComponent:n})=>{const e=yc.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function t0(){const n=new Set;let e={};return{subscribe(t){return n.add(t),()=>{n.delete(t)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(t,r){e={...e,[t]:Zh.createPortal(r.reactElement,r.element,t)},n.forEach(i=>i())},removeRenderer(t){const r={...e};delete r[t],e=r,n.forEach(i=>i())}}}var n0=class extends J.Component{constructor(n){super(n),this.editorContentRef=J.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var n;const e=this.props.editor;if(e&&!e.isDestroyed&&((n=e.view.dom)!=null&&n.parentNode)){if(e.contentComponent)return;const t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=t0(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var n;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((n=e.view.dom)!=null&&n.parentNode))return;const t=document.createElement("div");t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){const{editor:n,innerRef:e,...t}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:Qb(e,this.editorContentRef),...t}),n?.contentComponent&&m.jsx(e0,{contentComponent:n.contentComponent})]})}},r0=v.forwardRef((n,e)=>{const t=J.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return J.createElement(n0,{key:t,innerRef:e,...n})}),Bu=J.memo(r0),i0=typeof window<"u"?v.useLayoutEffect:v.useEffect,s0=class{constructor(n){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=n,this.lastSnapshot={editor:n,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(n){return this.subscribers.add(n),()=>{this.subscribers.delete(n)}}watch(n){if(this.editor=n,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}};function o0(n){var e;const[t]=v.useState(()=>new s0(n.editor)),r=Yh.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!=null?e:Xb);return i0(()=>t.watch(n.editor),[n.editor,t]),v.useDebugValue(r),r}var a0=!1,$u=typeof window>"u",l0=$u||!!(typeof window<"u"&&window.next),c0=class Fu{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(t=>t())}getInitialEditor(){const e=this.options.current.immediatelyRender;let t=e??!0;return $u?(t&&a0&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),t=!1):l0&&e===void 0&&(t=!1),t?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)}
104,onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new ib(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(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((i,s)=>{var o;return i===((o=t.extensions)==null?void 0:o[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Fu.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{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((r,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const 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 d0(n={},e=[]){const t=v.useRef(n);t.current=n;const[r]=v.useState(()=>new c0(t)),i=yc.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return v.useDebugValue(i),v.useEffect(r.onRender(e)),o0({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1||n.shouldRerenderOnTransaction===void 0?null:n.immediatelyRender&&s===0?0:s+1}),i}var Hu=v.createContext({editor:null});Hu.Consumer;var u0=v.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),h0=()=>v.useContext(u0);J.forwardRef((n,e)=>{const{onDragStart:t}=h0(),r=n.as||"div";return m.jsx(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});J.createContext({markViewContentRef:()=>{}});var fa=v.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});fa.displayName="TiptapContext";var f0=()=>v.useContext(fa);function Uu({editor:n,instance:e,children:t}){const r=n??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const i=v.useMemo(()=>({editor:r}),[r]),s=v.useMemo(()=>({editor:r}),[r]);return m.jsx(Hu.Provider,{value:s,children:m.jsx(fa.Provider,{value:i,children:t})})}Uu.displayName="Tiptap";function Vu({...n}){const{editor:e}=f0();return m.jsx(Bu,{editor:e,...n})}Vu.displayName="Tiptap.Content";Object.assign(Uu,{Content:Vu});var Ei=(n,e)=>{if(n==="slot")return 0;if(n instanceof Function)return n(e);const{children:t,...r}=e??{};if(n==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[n,r,t]};function _u(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=_u(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Wu(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){t-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:t,b:r};if(o.isText&&o.text!=a.text){let c=0,d=Math.min(o.text.length,a.text.length);for(;c<d&&o.text[o.text.length-c-1]==a.text[a.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||a.content.size){let c=Wu(o.content,a.content,t-1,r-1);if(c)return c}t-=l,r-=l}}var bt=class Ae{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,a=0;a<t;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,t-d),r,i+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}
vendor: 4,407 bytes, line 104
104textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,t-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new Ae(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>t)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,t-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,t-o-1))),r.push(a),i+=a.nodeSize),o=l}return new Ae(r,i)}cutByIndex(e,t){return e==t?Ae.empty:e==0&&t==this.content.length?this:new Ae(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new Ae(i,s)}addToStart(e){return new Ae([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ae(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return _u(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Wu(this,e,t,r)}findIndex(e){if(e==0)return Wr(0,e);if(e==this.size)return Wr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let i=this.child(t),s=r+i.nodeSize;if(s>=e)return s==e?Wr(t+1,s):Wr(t,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return Ae.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return Ae.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ae.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new Ae(t||e,r)}static from(e){if(!e)return Ae.empty;if(e instanceof Ae)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Ae([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};bt.empty=new bt([],0);var Us={index:0,offset:0};function Wr(n,e){return Us.index=n,Us.offset=e,Us}var p0=class extends Error{},ue=class gn{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=qu(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new gn(r,this.openStart,this.openEnd)}removeBetween(e,t){return new gn(Ku(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return gn.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new gn(bt.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;
vendor: 19,095 bytes, line 104
104return new gn(e,r,i)}};ue.empty=new ue(bt.empty,0,0);function Ku(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:a}=n.findIndex(t);if(i==e||s.isText){if(a!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Ku(s.content,e-i-1,t-i-1)))}function qu(n,e,t,r,i,s){let{index:o,offset:a}=n.findIndex(e),l=n.maybeChild(o);if(a==e||l.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=qu(l.content,e-a-1,t,o==0?r-1:0,o==n.childCount-1?i-1:0,l);return c&&n.replaceChild(o,l.copy(c))}var Ju=65535,Gu=Math.pow(2,16);function m0(n,e){return n+e*Gu}function Wl(n){return n&Ju}function g0(n){return(n-(n&Ju))/Gu}var Yu=1,Zu=2,si=4,Xu=8,Kl=class{constructor(n,e,t){this.pos=n,this.delInfo=e,this.recover=t}get deleted(){return(this.delInfo&Xu)>0}get deletedBefore(){return(this.delInfo&(Yu|si))>0}get deletedAfter(){return(this.delInfo&(Zu|si))>0}get deletedAcross(){return(this.delInfo&si)>0}},nn=class yn{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&yn.empty)return yn.empty}recover(e){let t=0,r=Wl(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+g0(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let c=this.ranges[a+s],d=this.ranges[a+o],u=l+c;if(e<=u){let f=c?e==l?-1:e==u?1:t:t,h=l+i+(f<0?0:d);if(r)return h;let p=e==(t<0?l:u)?null:m0(a/3,e-l),y=e==l?Zu:e==u?Yu:si;return(t<0?e!=l:e!=u)&&(y|=Xu),new Kl(h,y,p)}i+=d-c}return r?e+i:new Kl(e+i,0,null)}touches(e,t){let r=0,i=Wl(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],d=l+c;if(e<=d&&a==i*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),c=this.ranges[i+t],d=this.ranges[i+r];e(a,a+c,l,l+d),s+=d-c}}invert(){return new yn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?yn.empty:new yn(e<0?[0,-e,0]:[0,0,e])}};nn.empty=new nn([]);var Vs=Object.create(null),Me=class{getMap(){return nn.empty}merge(n){return null}static fromJSON(n,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let t=Vs[e.stepType];if(!t)throw new RangeError(`No step type ${e.stepType} defined`);return t.fromJSON(n,e)}static jsonID(n,e){if(n in Vs)throw new RangeError("Duplicate use of step JSON ID "+n);return Vs[n]=e,e.prototype.jsonID=n,e}},De=class Zn{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Zn(e,null)}static fail(e){return new Zn(null,e)}static fromReplace(e,t,r,i){try{return Zn.ok(e.replace(t,r,i))}catch(s){if(s instanceof p0)return Zn.fail(s.message);throw s}}};function pa(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(pa(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return bt.fromArray(r)}var Qu=class Xn extends Me{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new ue(pa(t.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return De.fromReplace(e,this.from,this.to,s)}invert(){return new eh(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Xn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Xn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Xn(t.from,t.to,e.markFromJSON(t.mark))}};Me.jsonID("addMark",Qu);var eh=class Qn extends Me{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new ue(pa(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return De.fromReplace(e,this.from,this.to,r)}invert(){return new Qu(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Qn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Qn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Qn(t.from,t.to,e.markFromJSON(t.mark))}};Me.jsonID("removeMark",eh);var th=class er extends Me{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return De.fromReplace(e,this.pos,this.pos+1,new ue(bt.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new er(this.pos,t.marks[i]);return new er(this.pos,this.mark)}}return new nh(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new er(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new er(t.pos,e.markFromJSON(t.mark))}};Me.jsonID("addNodeMark",th);var nh=class No extends Me{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return De.fromReplace(e,this.pos,this.pos+1,new ue(bt.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new th(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new No(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new No(t.pos,e.markFromJSON(t.mark))}};Me.jsonID("removeNodeMark",nh);var ma=class St extends Me{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Eo(e,this.from,this.to)?De.fail("Structure replace would overwrite content"):De.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new nn([this.from,this.to-this.from,this.slice.size])}invert(e){return new St(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&St.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new St(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof St)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?ue.empty:new ue(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new St(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?ue.empty:new ue(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new St(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new St(t.from,t.to,ue.fromJSON(e,t.slice),!!t.structure)}};ma.MAP_BIAS=1;Me.jsonID("replace",ma);var rh=class oi extends Me{constructor(e,t,r,i,s,o,a=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(Eo(e,this.from,this.gapFrom)||Eo(e,this.gapTo,this.to)))return De.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return De.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?De.fromReplace(e,this.from,this.to,r):De.fail("Content does not fit in gap")}getMap(){return new nn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new oi(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new oi(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new oi(t.from,t.to,t.gapFrom,t.gapTo,ue.fromJSON(e,t.slice),t.insert,!!t.structure)}};Me.jsonID("replaceAround",rh);function Eo(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}var y0=class ai extends Me{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return De.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return De.fromReplace(e,this.pos,this.pos+1,new ue(bt.from(i),0,t.isLeaf?0:1))}getMap(){return nn.empty}invert(e){return new ai(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ai(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ai(t.pos,t.attr,t.value)}};Me.jsonID("attr",y0);var b0=class Mo extends Me{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return De.ok(r)}getMap(){return nn.empty}invert(e){return new Mo(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Mo(t.attr,t.value)}};Me.jsonID("docAttr",b0);var Er=class extends Error{};Er=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Er.prototype=Object.create(Error.prototype);Er.prototype.constructor=Er;Er.prototype.name="TransformError";var _s=Object.create(null),ge=class{constructor(n,e,t){this.$anchor=n,this.$head=e,this.ranges=t||[new k0(n.min(e),n.max(e))]}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 n=this.ranges;for(let e=0;e<n.length;e++)if(n[e].$from.pos!=n[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(n,e=ue.empty){let t=e.content.lastChild,r=null;for(let o=0;o<e.openEnd;o++)r=t,t=t.lastChild;let i=n.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=n.mapping.slice(i);n.replaceRange(c.map(a.pos),c.map(l.pos),o?ue.empty:e),o==0&&Gl(n,i,(t?t.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(n,e){let t=n.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:o}=r[i],a=n.mapping.slice(t),l=a.map(s.pos),c=a.map(o.pos);i?n.deleteRange(l,c):(n.replaceRangeWith(l,c,e),Gl(n,t,e.isInline?-1:1))}}static findFrom(n,e,t=!1){let r=n.parent.inlineContent?new An(n):bn(n.node(0),n.parent,n.pos,n.index(),e,t);if(r)return r;for(let i=n.depth-1;i>=0;i--){let s=e<0?bn(n.node(0),n.node(i),n.before(i+1),n.index(i),e,t):bn(n.node(0),n.node(i),n.after(i+1),n.index(i)+1,e,t);if(s)return s}return null}static near(n,e=1){return this.findFrom(n,e)||this.findFrom(n,-e)||new cr(n.node(0))}static atStart(n){return bn(n,n,0,0,1)||new cr(n)}static atEnd(n){return bn(n,n,n.content.size,n.childCount,-1)||new cr(n)}static fromJSON(n,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let t=_s[e.type];if(!t)throw new RangeError(`No selection type ${e.type} defined`);return t.fromJSON(n,e)}static jsonID(n,e){if(n in _s)throw new RangeError("Duplicate use of selection JSON ID "+n);return _s[n]=e,e.prototype.jsonID=n,e}getBookmark(){return An.between(this.$anchor,this.$head).getBookmark()}};ge.prototype.visible=!0;var k0=class{constructor(n,e){this.$from=n,this.$to=e}},ql=!1;function Jl(n){!ql&&!n.parent.inlineContent&&(ql=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var An=class tr extends ge{constructor(e,t=e){Jl(e),Jl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ge.near(r);let i=e.resolve(t.map(this.anchor));return new tr(i.parent.inlineContent?i:r,r)}replace(e,t=ue.empty){if(super.replace(e,t),t==ue.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof tr&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ih(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new tr(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=ge.findFrom(t,r,!0)||ge.findFrom(t,-r,!0);if(s)t=s.$head;else return ge.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ge.findFrom(e,-r,!0)||ge.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new tr(e,t)}};ge.jsonID("text",An);var ih=class sh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new sh(e.map(this.anchor),e.map(this.head))}resolve(e){return An.between(e.resolve(this.anchor),e.resolve(this.head))}},On=class nr extends ge{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?ge.near(s):new nr(s)}content(){return new ue(bt.from(this.node),0,0)}eq(e){return e instanceof nr&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new x0(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new nr(e.resolve(t.anchor))}static create(e,t){return new nr(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};On.prototype.visible=!1;ge.jsonID("node",On);var x0=class oh{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new ih(r,r):new oh(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&On.isSelectable(r)?new On(t):ge.near(t)}},cr=class li extends ge{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=ue.empty){if(t==ue.empty){e.delete(0,e.doc.content.size);let r=ge.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new li(e)}map(e){return new li(e)}eq(e){return e instanceof li}getBookmark(){return v0}};ge.jsonID("all",cr);var v0={map(){return this},resolve(n){return new cr(n)}};function bn(n,e,t,r,i,s=!1){if(e.inlineContent)return An.create(n,t);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let a=e.child(o);if(a.isAtom){if(!s&&On.isSelectable(a))return On.create(n,t-(i<0?a.nodeSize:0))}else{let l=bn(n,a,t+i,i<0?a.childCount:0,i,s);if(l)return l}t+=a.nodeSize*i}return null}function Gl(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof ma||i instanceof rh))return;let s=n.mapping.maps[r],o;s.forEach((a,l,c,d)=>{o==null&&(o=d)}),n.setSelection(ge.near(n.doc.resolve(o),t))}function Yl(n,e){return!e||!n?n:n.bind(e)}var Kr=class{constructor(n,e,t){this.name=n,this.init=Yl(e.init,t),this.apply=Yl(e.apply,t)}};new Kr("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Kr("selection",{init(n,e){return n.selection||ge.atStart(e.doc)},apply(n){return n.selection}}),new Kr("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Kr("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});var w0=(n,e)=>{var t;const{state:r,view:i}=n,{selection:s}=r;if(!s.empty)return!1;const{$from:o}=s;if(o.parentOffset!==0)return!1;const a=o.depth-1,l=o.node(a),c=o.index(a);if(c===0)return!1;if(l.type===e)return n.commands.lift(e.name);const d=l.child(c-1);if(d.type!==e||!((t=d.lastChild)!=null&&t.isTextblock))return!1;const u=o.before(),h=u-1-1,{tr:p}=r;return p.delete(u,o.after()).insert(h,o.parent.content),p.setSelection(An.create(p.doc,h)),i.dispatch(p.scrollIntoView()),!0},S0=/^\s*>\s$/,C0=Ue.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}
104){return Ei("blockquote",{...fe(this.options.HTMLAttributes,n),children:Ei("slot",{})})},parseMarkdown:(n,e)=>{var t;const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;return e.createNode("blockquote",void 0,r(n.tokens||[]))},renderMarkdown:(n,e)=>{if(!n.content)return"";const t=">",r=[];return n.content.forEach((i,s)=>{var o,a;const d=((a=(o=e.renderChild)==null?void 0:o.call(e,i,s))!=null?a:e.renderChildren([i])).split(`
105`).map(u=>u.trim()===""?t:`${t} ${u}`);r.push(d.join(`
106`))}),r.join(`
107${t}
108`)},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>w0(this.editor,this.type)}},addInputRules(){return[Tn({find:S0,type:this.type})]}}),N0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,E0=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,M0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,T0=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,A0=sn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return Ei("strong",{...fe(this.options.HTMLAttributes,n),children:Ei("slot",{})})},markdownTokenName:"strong",parseMarkdown:(n,e)=>e.applyMark("bold",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(n,e)=>`**${e.renderChildren(n)}**`,addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}}
vendor: 1,109 bytes, line 108
108,addInputRules(){return[Mn({find:N0,type:this.type}),Mn({find:M0,type:this.type})]},addPasteRules(){return[tn({find:E0,type:this.type}),tn({find:T0,type:this.type})]}}),O0=n=>{const e=/`([^`]+)`(?!`)$/.exec(n);return!e||e.index>0&&n[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},I0=n=>{const e=/`([^`]+)`(?!`)/g,t=[];let r;for(;(r=e.exec(n))!==null;)r.index>0&&n[r.index-1]==="`"||t.push({index:r.index,text:r[0],replaceWith:r[1]});return t},D0=sn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"codespan",parseMarkdown:(n,e)=>e.applyMark("code",[{type:"text",text:n.text||""}]),renderMarkdown:(n,e)=>n.content?`\`${e.renderChildren(n.content)}\``:"",addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}}
vendor: 6,959 bytes, lines 108-129
108,addInputRules(){return[Mn({find:O0,type:this.type})]},addPasteRules(){return[tn({find:I0,type:this.type})]}}),Ws=4,R0=/^```([a-z]+)?[\s\n]$/,j0=/^~~~([a-z]+)?[\s\n]$/,L0=Ue.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ws,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const s=[...((e=n.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",fe(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(n,e)=>{var t,r;return((t=n.raw)==null?void 0:t.startsWith("```"))===!1&&((r=n.raw)==null?void 0:r.startsWith("~~~"))===!1&&n.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:n.lang||null},n.text?[e.createTextNode(n.text)]:[])},renderMarkdown:(n,e)=>{var t;let r="";const i=((t=n.attrs)==null?void 0:t.language)||"";return n.content?r=[`\`\`\`${i}`,e.renderChildren(n.content),"```"].join(`
109`):r=`\`\`\`${i}
110
111\`\`\``,r},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Ws,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const a=" ".repeat(t);return o?n.commands.insertContent(a):n.commands.command(({tr:l})=>{const{from:c,to:d}=i,h=r.doc.textBetween(c,d,`
112`,`
113`).split(`
114`).map(p=>a+p).join(`
115`);return l.replaceWith(c,d,r.schema.text(h)),!0})},"Shift-Tab":({editor:n})=>{var e;if(!this.options.enableTabIndentation)return!1;const t=(e=this.options.tabSize)!=null?e:Ws,{state:r}=n,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?n.commands.command(({tr:a})=>{var l;const{pos:c}=s,d=s.start(),u=s.end(),h=r.doc.textBetween(d,u,`
116`,`
117`).split(`
118`);let p=0,y=0;const g=c-d;for(let I=0;I<h.length;I+=1){if(y+h[I].length>=g){p=I;break}y+=h[I].length+1}const k=((l=h[p].match(/^ */))==null?void 0:l[0])||"",N=Math.min(k.length,t);if(N===0)return!0;let A=d;for(let I=0;I<p;I+=1)A+=h[I].length+1;return a.delete(A,A+N),c-A<=N&&a.setSelection(H.create(a.doc,A)),!0}):n.commands.command(({tr:a})=>{const{from:l,to:c}=i,f=r.doc.textBetween(l,c,`
119`,`
120`).split(`
121`).map(h=>{var p;const y=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(y.length,t);return h.slice(g)}).join(`
122`);return a.replaceWith(l,c,r.schema.text(f)),!0})},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
123
124`);return!s||!o?!1:n.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const a=i.after();return a===void 0?!1:r.nodeAt(a)?n.commands.command(({tr:c})=>(c.setSelection(V.near(r.resolve(a))),!0)):n.commands.exitCode()}}},addInputRules(){return[So({find:R0,type:this.type,getAttributes:n=>({language:n[1]})}),So({find:j0,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new ae({key:new me("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!t||!s)return!1;const{tr:o,schema:a}=n.state,l=a.text(t.replace(/\r\n?/g,`
125`));return o.replaceSelectionWith(this.type.create({language:s},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(H.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),P0=Ue.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
126
127`):""}),z0=Ue.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",fe(this.options.HTMLAttributes,n)]},renderText(){return`
128`},renderMarkdown:()=>`  
129`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&l&&o){const u=l.filter(f=>a.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),B0=Ue.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,fe(this.options.HTMLAttributes,e),0]},parseMarkdown:(n,e)=>e.createNode("heading",{level:n.depth||1},e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>{var t;const r=(t=n.attrs)!=null&&t.level?parseInt(n.attrs.level,10):1,i="#".repeat(r);return n.content?`${i} ${e.renderChildren(n.content)}`:""},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>So({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}}
129)\\s$`),type:this.type,getAttributes:{level:n}}))}}),$0=Ue.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",fe(this.options.HTMLAttributes,n)]},markdownTokenName:"hr",parseMarkdown:(n,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{if(!ob(e,e.schema.nodes[this.name]))return!1;const{selection:t}=e,{$to:r}=t,i=n();return bu(t)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:a})=>{if(a){const{$to:l}=o.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(H.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(F.create(o.doc,l.pos)):o.setSelection(H.create(o.doc,l.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(H.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[sb({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.t
vendor: 1,046 bytes, line 129
129ype})]}}),F0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,H0=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,U0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,V0=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,_0=sn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",fe(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(n,e)=>e.applyMark("italic",e.parseInline(n.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(n,e)=>`*${e.renderChildren(n)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}}
129,addInputRules(){return[Mn({find:F0,type:this.type}),Mn({find:U0,type:this.type})]},addPasteRules(){return[tn({find:H0,type:this.type}),tn({find:V0,type:this.type})]}});const W0="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yac
129hts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",K0="ελ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",To="numeric",Ao="ascii",Oo="alpha",dr="asciinumeric",rr="alphanumeric",Io="domain",ah="emoji",q0="scheme",J0="slashscheme",Ks="whitespace";function G0(n,e){return n in e||(e[n]=[]),e[n]}function _t(n,e,t){e[To]&&(e[dr]=!0,e[rr]=!0),e[Ao]&&(e[dr]=!0,e[Oo]=!0),e[dr]&&(e[rr]=!0),e[Oo]&&(e[rr]=!0),e[rr]&&(e[Io]=!0),e[ah]&&(e[Io]=!0);for(const r in e){const i=G0(r,t);i.indexOf(n)<0&&i.push(n)}}function Y0(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Pe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Pe.groups={};Pe.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(n))return s}return e.jd},has(n,e=!1){return e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||Pe.groups;let i;
vendor: 13,849 bytes, lines 129-133
129return e&&e.j?i=e:(i=new Pe(e),t&&r&&_t(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const s=n.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(n[o]);return i.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Pe.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const s=e;let o,a=i.go(n);if(a?(o=new Pe,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new Pe,s){if(r)if(o.t&&typeof o.t=="string"){const l=Object.assign(Y0(o.t,r),t);_t(s,l,r)}else t&&_t(s,t,r);o.t=s}return i.j[n]=o,o}};const _=(n,e,t,r,i)=>n.ta(e,t,r,i),le=(n,e,t,r,i)=>n.tr(e,t,r,i),Zl=(n,e,t,r,i)=>n.ts(e,t,r,i),M=(n,e,t,r,i)=>n.tt(e,t,r,i),ut="WORD",Do="UWORD",lh="ASCIINUMERICAL",ch="ALPHANUMERICAL",Mr="LOCALHOST",Ro="TLD",jo="UTLD",ci="SCHEME",kn="SLASH_SCHEME",ga="NUM",Lo="WS",ya="NL",ur="OPENBRACE",hr="CLOSEBRACE",Mi="OPENBRACKET",Ti="CLOSEBRACKET",Ai="OPENPAREN",Oi="CLOSEPAREN",Ii="OPENANGLEBRACKET",Di="CLOSEANGLEBRACKET",Ri="FULLWIDTHLEFTPAREN",ji="FULLWIDTHRIGHTPAREN",Li="LEFTCORNERBRACKET",Pi="RIGHTCORNERBRACKET",zi="LEFTWHITECORNERBRACKET",Bi="RIGHTWHITECORNERBRACKET",$i="FULLWIDTHLESSTHAN",Fi="FULLWIDTHGREATERTHAN",Hi="AMPERSAND",Ui="APOSTROPHE",Vi="ASTERISK",Et="AT",_i="BACKSLASH",Wi="BACKTICK",Ki="CARET",Wt="COLON",ba="COMMA",qi="DOLLAR",tt="DOT",Ji="EQUALS",ka="EXCLAMATION",_e="HYPHEN",fr="PERCENT",Gi="PIPE",Yi="PLUS",Zi="POUND",pr="QUERY",xa="QUOTE",dh="FULLWIDTHMIDDLEDOT",va="SEMI",nt="SLASH",mr="TILDE",Xi="UNDERSCORE",uh="EMOJI",Qi="SYM";var hh=Object.freeze({__proto__:null,ALPHANUMERICAL:ch,AMPERSAND:Hi,APOSTROPHE:Ui,ASCIINUMERICAL:lh,ASTERISK:Vi,AT:Et,BACKSLASH:_i,BACKTICK:Wi,CARET:Ki,CLOSEANGLEBRACKET:Di,CLOSEBRACE:hr,CLOSEBRACKET:Ti,CLOSEPAREN:Oi,COLON:Wt,COMMA:ba,DOLLAR:qi,DOT:tt,EMOJI:uh,EQUALS:Ji,EXCLAMATION:ka,FULLWIDTHGREATERTHAN:Fi,FULLWIDTHLEFTPAREN:Ri,FULLWIDTHLESSTHAN:$i,FULLWIDTHMIDDLEDOT:dh,FULLWIDTHRIGHTPAREN:ji,HYPHEN:_e,LEFTCORNERBRACKET:Li,LEFTWHITECORNERBRACKET:zi,LOCALHOST:Mr,NL:ya,NUM:ga,OPENANGLEBRACKET:Ii,OPENBRACE:ur,OPENBRACKET:Mi,OPENPAREN:Ai,PERCENT:fr,PIPE:Gi,PLUS:Yi,POUND:Zi,QUERY:pr,QUOTE:xa,RIGHTCORNERBRACKET:Pi,RIGHTWHITECORNERBRACKET:Bi,SCHEME:ci,SEMI:va,SLASH:nt,SLASH_SCHEME:kn,SYM:Qi,TILDE:mr,TLD:Ro,UNDERSCORE:Xi,UTLD:jo,UWORD:Do,WORD:ut,WS:Lo});const ct=/[a-z]/,Fn=new RegExp("\\p{L}","u"),qs=new RegExp("\\p{Emoji}","u"),dt=/\d/,Js=/\s/,Xl="\r",Gs=`
130`,Z0="️",X0="‍",Ys="";let qr=null,Jr=null;function Q0(n=[]){const e={};Pe.groups=e;const t=new Pe;qr==null&&(qr=Ql(W0)),Jr==null&&(Jr=Ql(K0)),M(t,"'",Ui),M(t,"{",ur),M(t,"}",hr),M(t,"[",Mi),M(t,"]",Ti),M(t,"(",Ai),M(t,")",Oi),M(t,"<",Ii),M(t,">",Di),M(t,"(",Ri),M(t,")",ji),M(t,"「",Li),M(t,"」",Pi),M(t,"『",zi),M(t,"』",Bi),M(t,"<",$i),M(t,">",Fi),M(t,"&",Hi),M(t,"*",Vi),M(t,"@",Et),M(t,"`",Wi),M(t,"^",Ki),M(t,":",Wt),M(t,",",ba),M(t,"$",qi),M(t,".",tt),M(t,"=",Ji),M(t,"!",ka),M(t,"-",_e),M(t,"%",fr),M(t,"|",Gi),M(t,"+",Yi),M(t,"#",Zi),M(t,"?",pr),M(t,'"',xa),M(t,"/",nt),M(t,";",va),M(t,"~",mr),M(t,"_",Xi),M(t,"\\",_i),M(t,"・",dh);const r=le(t,dt,ga,{[To]:!0});le(r,dt,r);const i=le(r,ct,lh,{[dr]:!0}),s=le(r,Fn,ch,{[rr]:!0}),o=le(t,ct,ut,{[Ao]:!0});le(o,dt,i),le(o,ct,o),le(i,dt,i),le(i,ct,i);const a=le(t,Fn,Do,{[Oo]:!0});le(a,ct),le(a,dt,s),le(a,Fn,a),le(s,dt,s),le(s,ct),le(s,Fn,s);const l=M(t,Gs,ya,{[Ks]:!0}),c=M(t,Xl,Lo,{[Ks]:!0}),d=le(t,Js,Lo,{[Ks]:!0});M(t,Ys,d),M(c,Gs,l),M(c,Ys,d),le(c,Js,d),M(d,Xl),M(d,Gs),le(d,Js,d),M(d,Ys,d);const u=le(t,qs,uh,{[ah]:!0});M(u,"#"),le(u,qs,u),M(u,Z0,u);const f=M(u,X0);M(f,"#"),le(f,qs,u);const h=[[ct,o],[dt,i]],p=[[ct,null],[Fn,a],[dt,s]];for(let y=0;y<qr.length;y++)xt(t,qr[y],Ro,ut,h);for(let y=0;y<Jr.length;y++)xt(t,Jr[y],jo,Do,p);_t(Ro,{tld:!0,ascii:!0},e),_t(jo,{utld:!0,alpha:!0},e),xt(t,"file",ci,ut,h),xt(t,"mailto",ci,ut,h),xt(t,"http",kn,ut,h),xt(t,"https",kn,ut,h),xt(t,"ftp",kn,ut,h),xt(t,"ftps",kn,ut,h),_t(ci,{scheme:!0,ascii:!0},e),_t(kn,{slashscheme:!0,ascii:!0},e),n=n.sort((y,g)=>y[0]>g[0]?1:-1);for(let y=0;y<n.length;y++){const g=n[y][0],k=n[y][1]?{[q0]:!0}:{[J0]:!0};g.indexOf("-")>=0?k[Io]=!0:ct.test(g)?dt.test(g)?k[dr]=!0:k[Ao]=!0:k[To]=!0,Zl(t,g,g,k)}return Zl(t,"localhost",Mr,{ascii:!0}),t.jd=new Pe(Qi),{start:t,tokens:Object.assign({groups:e},hh)}}function fh(n,e){const t=ek(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o<r;){let a=n,l=null,c=0,d=null,u=-1,f=-1;for(;o<r&&(l=a.go(t[o]));)a=l,a.accepts()?(u=0,f=0,d=a):u>=0&&(u+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=u,o-=f,c-=u,i.push({t:d.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function ek(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),s,o=i<55296||i>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function xt(n,e,t,r,i){let s;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];n.j[l]?s=n.j[l]:(s=new Pe(r),s.jr=i.slice(),n.j[l]=s),n=s}return s=new Pe(t),s.jr=i.slice(),n.j[e[o-1]]=s,s}function Ql(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let s=0;for(;i.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const Tr={defaultProtocol:"http",events:null,format:ec,formatHref:ec,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function wa(n,e=null){let t=Object.assign({},Tr);n&&(t=Object.assign(t,n instanceof wa?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}wa.prototype={o:Tr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:Tr[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function ec(n){return n}function ph(n,e){this.t="token",this.v=n,this.tk=e}ph.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Tr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:i,attributes:o,content:s,eventListeners:u}}};function fs(n,e){class t extends ph{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const tk=fs("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),tc=fs("text"),nk=fs("nl"),Gr=fs("url",{isLink:!0,toHref(n=Tr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Mr&&n[1].t===Wt}}),Ve=n=>new Pe(n);function rk({groups:n}){const e=n.domain.concat([Hi,Vi,Et,_i,Wi,Ki,qi,Ji,_e,ga,fr,Gi,Yi,Zi,nt,Qi,mr,Xi]),t=[Ui,Wt,ba,tt,ka,fr,pr,xa,va,Ii,Di,ur,hr,Ti,Mi,Ai,Oi,Ri,ji,Li,Pi,zi,Bi,$i,Fi],r=[Hi,Ui,Vi,_i,Wi,Ki,qi,Ji,_e,ur,hr,fr,Gi,Yi,Zi,pr,nt,Qi,mr,Xi],i=Ve(),s=M(i,mr);_(s,r,s),_(s,n.domain,s);const o=Ve(),a=Ve(),l=Ve();_(i,n.domain,o),_(i,n.scheme,a),_(i,n.slashscheme,l),_(o,r,s),_(o,n.domain,o);const c=M(o,Et);M(s,Et,c),M(a,Et,c),M(l,Et,c);const d=M(s,tt);_(d,r,s),_(d,n.domain,s);const u=Ve();_(c,n.domain,u),_(u,n.domain,u);const f=M(u,tt);_(f,n.domain,u);const h=Ve(tk);_(f,n.tld,h),_(f,n.utld,h),M(c,Mr,h);const p=M(u,_e);M(p,_e,p),_(p,n.domain,u),_(h,n.domain,u),M(h,tt,f),M(h,_e,p);const y=M(o,_e),g=M(o,tt);M(y,_e,y),_(y,n.domain,o),_(g,r,s),_(g,n.domain,o);const b=Ve(Gr);_(g,n.tld,b),_(g,n.utld,b),_(b,n.domain,o),_(b,r,s),M(b,tt,g),M(b,_e,y),M(b,Et,c);const k=M(b,Wt),N=Ve(Gr);_(k,n.numeric,N);const A=Ve(Gr),S=Ve();_(A,e,A),_(A,t,S),_(S,e,A),_(S,t,S),M(b,nt,A),M(N,nt,A);const I=M(a,Wt),O=M(l,Wt),L=M(O,nt),C=M(L,nt);_(a,n.domain,o),M(a,tt,g),M(a,_e,y),_(l,n.domain,o),M(l,tt,g),M(l,_e,y),_(I,n.domain,A),M(I,nt,A),M(I,pr,A),_(C,n.domain,A),_(C,e,A),M(C,nt,A);const D=[[ur,hr],[Mi,Ti],[Ai,Oi],[Ii,Di],[Ri,ji],[Li,Pi],[zi,Bi],[$i,Fi]];for(let Z=0;Z<D.length;Z++){const[G,W]=D[Z],E=M(A,G);M(S,G,E);const $=Ve(Gr);_(E,e,$);const j=Ve();_(E,t,j),M(E,W,A),_($,e,$),_($,t,j),_(j,e,$),_(j,t,j),M($,W,A),M(j,W,A)}return M(i,Mr,b),M(i,ya,nk),{start:i,tokens:hh}}function ik(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i<r;){let a=n,l=null,c=null,d=0,u=null,f=-1;for(;i<r&&!(l=a.go(t[i].t));)o.push(t[i++]);for(;i<r&&(c=l||a.go(t[i].t));)l=null,a=c,a.accepts()?(f=0,u=a):f>=0&&f++,i++,d++;if(f<0)i-=d,i<r&&(o.push(t[i]),i++);else{o.length>0&&(s.push(Zs(tc,e,o)),o=[]),i-=f,d-=f;const h=u.t,p=t.slice(i-d,i);s.push(Zs(h,e,p))}}return o.length>0&&s.push(Zs(tc,e,o)),s}function Zs(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const sk=typeof console<"u"&&console&&console.warn||(()=>{}),ok="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ie={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ak(){return Pe.groups={},ie.scanner=null,ie.parser=null,ie.tokenQueue=[],ie.pluginQueue=[],ie.customSchemes=[],ie.initialized=!1,ie}function nc(n,e=!1){if(ie.initialized&&sk(`linkifyjs: already initialized - will not register custom scheme "${n}" ${ok}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
1311. Must only contain digits, lowercase ASCII letters or "-"
1322. Cannot start or end with "-"
1333. "-" cannot repeat`);ie.customSchemes.push([n,e])}function lk(){ie.scanner=Q0(ie.customSchemes);for(let n=0;n<ie.tokenQueue.length;n++)ie.tokenQueue[n][1]({scanner:ie.scanner});ie.parser=rk(ie.scanner.tokens);for(let n=0;n<ie.pluginQueue.length;n++)ie.pluginQueue[n][1]({scanner:ie.scanner,parser:ie.parser});return ie.initialized=!0,ie}function Sa(n){return ie.initialized||lk(),ik(ie.parser.start,n,fh(ie.scanner.start,n))}Sa.scan=fh;function mh(n,e=null,t=null){if(e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new wa(t),i=Sa(n),s=[];for(let o=0;o<i.length;o++){const a=i[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&s.push(a.toFormattedObject(r))}return s}var Ca="[\0-   ᠎ -\u2029  ]",ck=new RegExp(Ca),dk=new RegExp(`${Ca}$`),uk=new RegExp(Ca,"g");function hk(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function fk(n){return new ae({key:new me("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,a=du(t.doc,[...e]);if(yu(a).forEach(({newRange:c})=>{const d=sy(r.doc,c,h=>h.isTextblock);let u,f;if(d.length>1)u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!dk.test(h))return;u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&f){const h=f.split(ck).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],y=u.pos+f.lastIndexOf(p);if(!p)return!1;const g=Sa(p).map(b=>b.toObject(n.defaultProtocol));if(!hk(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{la(b.from,b.to,r.doc).some(k=>k.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function pk(n){return new ae({key:new me("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const l=r.target;if(!l)return!1;const c=n.editor.view.dom;o=l.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(n.enableClickSelection&&(a=n.editor.commands.extendMarkRange(n.type.name)),n.openOnClick){const l=gu(e.state,n.type.name),c=(i=o.href)!=null?i:l.href,d=(s=o.target)!=null?s:l.target;c&&(window.open(c,d),a=!0)}return a}}})}function mk(n){return new ae({key:new me("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{shouldAutoLink:i}=n,{state:s}=e,{selection:o}=s,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const c=mh(l,{defaultProtocol:n.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||i!==void 0&&!i(c.value)?!1:n.editor.commands.setMark(n.type,{href:c.href})}}})}function $t(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(uk,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var gk=sn.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 `val
133idate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){nc(n);return}nc(n.scheme,n.optionalSlashes)})},onDestroy(){ak()},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:(n,e)=>!!$t(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(n),t=/^[a-z][a-z0-9+.-]*:/i.test(n);if(e||t&&!n.includes("@"))return!0;const i=(n.includes("@")?n.split("@").pop():n).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){return{href:{default:null,parseHTML(n){return n.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:n=>{const e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!$t(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",fe(this.options.HTMLAttributes,n),0]:["a",fe(this.options.HTMLAttributes,{...n,href:""}),0]},markdownTokenName:"link",parseMarkdown:(n,e)=>e.applyMark("link",e.parseInline(n.tokens||[]),{href:n.href,title:n.title||null}),renderMarkdown:(n,e)=>{var t,r,i,s;const o=(r=(t=n.attrs)==null?void 0:t.href)!=null?r:"",a=(s=(i=n.attrs)==null?void 0:i.title)!=null?s:"",l=e.renderChildren(n);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:n=>({chain:e})=>{const{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{const{href:t}=n||{};return t&&!this.options.isAllowedUri(t,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[tn({find:n=>{const e=[];if(n){const{protocols:t,defaultProtocol:r}=this.options,i=mh(n).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!$t(o,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e}
vendor: 1,848 bytes, lines 133-134
133,type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(fk({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!$t(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),n.push(pk({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&n.push(mk({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),n}}),yk=Object.defineProperty,bk=(n,e)=>{for(var t in e)yk(n,t,{get:e[t],enumerable:!0})},kk="listItem",rc="textStyle",ic=/^\s*([-+*])\s$/,gh=Ue.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:n}){return["ul",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>n.type!=="list"||n.ordered?[]:{type:"bulletList",content:n.items?e.parseChildren(n.items):[]},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
134`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kk,this.editor.getAttributes(rc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}}
134,addInputRules(){let n=Tn({find:ic,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Tn({find:ic,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(rc),editor:this.editor})),[n]}}),xk=(n,e,t)=>{const{selection:r}=n;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let h=i.depth;h>0;h-=1)if(i.node(h).type.name===e){s=h;break}if(s<0)return null;const o=i.node(s),a=i.index(s);if(a+1>=o.childCount)return null;const l=o.child(a+1);if(!t.includes(l.type.name))return null;const c=n.schema.nodes[e];let d=!1;if(l.forEach(h=>{h.type===c&&h.childCount>1&&(d=!0)}),!d)return null;const u=n.doc.resolve(i.after()).nodeAfter;if(!u||!t.includes(u.type.name))return null;const f=[];return u.forEach(h=>{f.push(h)}),f.length===0?null:{listItemDepth:s,nestedList:u,nestedListPos:i.after(),insertPos:i.after(s),items:f}},vk=(n,e,t,r)=>{const i=xk(n,t,r);if(!i)return!1;const{selection:s}=n,{nestedList:o,nestedListPos:a,insertPos:l,items:c}=i,d=n.tr;d.delete(a,a+o.nodeSize);const u=d.mapping.map(l);return d.insert(u,T.from(c)),d.setSelection(s.map(d.doc,d.mapping)),e&&e(d),!0},wk=(n,e,t)=>vk(n.state,n.view.dispatch,e,t),yh=(n,e)=>de.create({name:`${n}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const t=()=>wk(this.editor,n,e);return{Delete:t,"Mod-Delete":t}}});function Sk(n){var e,t;const r=(e=n.tokens)==null?void 0:e[0];return!!(n.text&&((t=n.tokens)==null?void 0:t.length)===1&&r?.type==="list"&&r.ordered&&r.raw===n.text)}function Ck(n,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(n)):e.parseInline([{type:"text",raw:n,text:n}])}var bh=Ue.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"list_item",parseMarkdown:(n,e)=>{var t;if(n.type!=="list_item")return[];const r=(t=e.parseBlockChildren)!=null?t:e.parseChildren;let i=[];if(n.tokens&&n.tokens.length>0){if(Sk(n))return{type:"listItem",content:[{type:"paragraph",content:Ck(n.text||"",e)}]};if(n.tokens.some(o=>o.type==="paragraph"))i=r(n.tokens);else{const o=n.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],n.tokens.length>1){const l=n.tokens.slice(1),c=r(l);i.push(...c)}}else i=r(n.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(n,e,t)=>ha(n,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},t),addExtensions(){return[yh(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)}}}),Nk={};bk(Nk,{findListItemPos:()=>ps,getNextListDepth:()=>Na,handleBackspace:()=>Po,handleDelete:()=>zo,hasListBefore:()=>kh,hasListItemAfter:()=>Ek,hasListItemBefore:()=>Mk,listItemHasSubList:()=>Tk,nextListIsDeeper:()=>xh,nextListIsHigher:()=>vh});var ps=(n,e)=>{const{$from:t}=e.selection,r=he(n,e.schema);let i=null,s=t.depth,o=t.pos,a=null;for(;s>0&&a===null;)i=t.node(s),i.type===r?a=s:(s-=1,o-=1);return a===null?null:{$pos:e.doc.resolve(o),depth:a}},Na=(n,e)=>{const t=ps(n,e);if(!t)return!1;const[,r]=gy(e,n,t.$pos.pos+4);return r},kh=(n,e,t)=>{const{$anchor:r}=n.selection,i=Math.max(0,r.pos-2),s=n.doc.resolve(i).node();return!(!s||!t.includes(s.type.name))},Po=(n,e,t)=>{if(n.commands.undoInputRule())return!0;if(n.state.selection.from!==n.state.selection.to)return!1;if(!jt(n.state,e)&&kh(n.state,e,t)){const{$anchor:r}=n.state.selection,i=n.state.doc.resolve(r.before()-1),s=[];i.node().descendants((l,c)=>{l.type.name===e&&s.push({node:l,pos:c})});const o=s.at(-1);if(!o)return!1;const a=n.state.doc.resolve(i.start()+o.pos+1);return n.chain().cut({from:r.start()-1,to:r.end()+1},a.end()).joinForward().run()}return!jt(n.state,e)||!xy(n.state)?!1:n.chain().liftListItem(e).run()},xh=(n,e)=>{const t=Na(n,e),r=ps(n,e);return!r||!t?!1:t>r.depth},vh=(n,e)=>{const t=Na(n,e),r=ps(n,e);return!r||!t?!1:t<r.depth},zo=(n,e)=>{if(!jt(n.state,e)||!ky(n.state,e))return!1;const{selection:t}=n.state,{$from:r,$to:i}=t;return!t.empty&&r.sameParent(i)?!1:xh(e,n.state)?n.chain().focus(n.state.selection.from+4).lift(e).joinBackward().run():vh(e,n.state)?n.chain().joinForward().joinBackward().run():n.commands.joinItemForward()},Ek=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((t=i.nodeAfter)==null?void 0:t.type.name)!==n)},Mk=(n,e)=>{var t;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((t=i.nodeBefore)==null?void 0:t.type.name)!==n)},Tk=(n,e,t)=>{if(!t)return!1;const r=he(n,e.schema);let i=!1;
134return t.descendants(s=>{s.type===r&&(i=!0)}),i},wh=de.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&zo(n,t)&&(e=!0)}),e},"Mod-Delete":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t})=>{n.state.schema.nodes[t]!==void 0&&zo(n,t)&&(e=!0)}),e},Backspace:({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Po(n,t,r)&&(e=!0)}),e},"Mod-Backspace":({editor:n})=>{let e=!1;return this.options.listTypes.forEach(({itemName:t,wrapperNames:r})=>{n.state.schema.nodes[t]!==void 0&&Po(n,t,r)&&(e=!0)}),e}}}}),sc=/^(\s*)(\d+)\.\s+(.*)$/,Ak=/^\s/;function Ok(n){const e=n.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function Ik(n){const e=[],t=[];let r=!1;return n.forEach(i=>{if(r){t.push(i);return}if(i.trim()===""){r=!0,t.push(i);return}if(e.length>0&&Ok(i)){r=!0,t.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:t}}function Dk(n){const e=[];let t=0,r=0;for(;t<n.length;){const i=n[t],s=i.match(sc);if(!s)break;const[,o,a,l]=s,c=o.length,d=[l];let u=t+1;const f=[i];let h=!1;for(;u<n.length;){const p=n[u];if(p.match(sc))break;if(p.trim()==="")f.push(p),d.push(""),h=!0,u+=1;else if(p.match(Ak))f.push(p),d.push(p.slice(c+2)),u+=1;else{if(h)break;f.push(p),d.push(p),u+=1}}e.push({indent:c,number:parseInt(a,10),content:d.join(`
135`).trim(),contentLines:d,raw:f.join(`
136`)}),r=u,t=u}return[e,r]}function Sh(n,e,t){const r=[];let i=0;for(;i<n.length;){const s=n[i];if(s.indent===e){const{paragraphLines:o,blockLines:a}=Ik(s.contentLines),l=o.join(`
137`).trim(),c=[];l&&c.push({type:"paragraph",raw:l,tokens:t.inlineTokens(l)});const d=a.join(`
138`).trim();if(d){const h=t.blockTokens(d);c.push(...h)}let u=i+1;const f=[];for(;u<n.length&&n[u].indent>e;)f.push(n[u]),u+=1;if(f.length>0){const h=Math.min(...f.map(y=>y.indent)),p=Sh(f,h,t);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(y=>y.raw).join(`
139`)})}r.push({type:"list_item",raw:s.raw,tokens:c}),i=u}else i+=1}return r}function Rk(n,e){return n.map(t=>{if(t.type!=="list_item")return e.parseChildren([t])[0];const r=[];return t.tokens&&t.tokens.length>0&&t.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var jk="listItem",oc="textStyle",ac=/^(\d+)\.\s$/,Ch=Ue.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",fe(this.options.HTMLAttributes,t),0]:["ol",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"list",parseMarkdown:(n,e)=>{if(n.type!=="list"||!n.ordered)return[];const t=n.start||1,r=n.items?Rk(n.items,e):[];return t!==1?{type:"orderedList",attrs:{start:t},content:r}:{type:"orderedList",content:r}},renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
140`):"",markdownTokenizer:{name:"orderedList",level:"block",start:n=>{const e=n.match(/^(\s*)(\d+)\.\s+/),t=e?.index;return t!==void 0?t:-1},tokenize:(n,e,t)=>{var r;const i=n.split(`
141`),[s,o]=Dk(i);if(s.length===0)return;const a=Sh(s,0,t);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:i.slice(0,o).join(`
142`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jk,this.editor.getAttributes(oc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}}
142,addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Tn({find:ac,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)&&(n=Tn({find:ac,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(oc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Lk=/^\s*(\[([( |x])?\])\s$/,Pk=Ue.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:n=>{const e=n.getAttribute("data-checked");return e===""||e==="true"},renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",fe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(n,e)=>{const t=[];if(n.tokens&&n.tokens.length>0?t.push(e.createNode("paragraph",{},e.parseInline(n.tokens))):n.text?t.push(e.createNode("paragraph",{},[e.createNode("text",{text:n.text})])):t.push(e.createNode("paragraph",{},[])),n.nestedTokens&&n.nestedTokens.length>0){const r=e.parseChildren(n.nestedTokens);t.push(...r)}return e.createNode("taskItem",{checked:n.checked||!1},t)},renderMarkdown:(n,e)=>{var t;const i=`- [${(t=n.attrs)!=null&&t.checked?"x":" "}] `;return ha(n,e,i)},addExtensions(){return this.options.nested?[yh(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=u=>{var f,h;a.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,u,a.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};c(n),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",u=>u.preventDefault()),a.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:f}=u.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=t();if(typeof p!="number")return!1;const y=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...y?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,f])=>{i.setAttribute(u,f)}),i.dataset.checked=n.attrs.checked,a.checked=n.attrs.checked,s.append(a,o),i.append(s,l),Object.entries(e).forEach(([u,f])=>{i.setAttribute(u,f)});let d=new Set(Object.keys(e));return{dom:i,contentDOM:l,update:u=>{if(u.type!==this.type)return!1;i.dataset.checked=u.attrs.checked,a.checked=u.attrs.checked,c(u);const f=r.extensionManager.attributes,h=Cr(u,f),p=new Set(Object.keys(h)),y=this.options.HTMLAttributes;return d.forEach(g=>{p.has(g)||(g in y?i.setAttribute(g,y[g]):i.removeAttribute(g))}),Object.entries(h).forEach(([g,b])=>{b==null?g in y?i.setAttribute(g,y[g]):i.removeAttribute(g):i.setAttribute(g,b)}),d=p,!0}}}}
142,addInputRules(){return[Tn({find:Lk,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),zk=Ue.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:n}){return["ul",fe(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},parseMarkdown:(n,e)=>e.createNode("taskList",{},e.parseChildren(n.items||[])),renderMarkdown:(n,e)=>n.content?e.renderChildren(n.content,`
143`):"",markdownTokenizer:{name:"taskList",level:"block",start(n){var e;const t=(e=n.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return t!==void 0?t:-1},tokenize(n,e,t){const r=s=>{const o=Co(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:t.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},t);return o?[{type:"taskList",raw:o.raw,items:o.items}]:t.blockTokens(s)},i=Co(n,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:t.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},t);if(i)return{type:"taskList",raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});de.create({name:"listKit",addExtensions(){const n=[];return this.options.bulletList!==!1&&n.push(gh.configure(this.options.bulletList)),this.options.listItem!==!1&&n.push(bh.configure(this.options.listItem)),this.options.listKeymap!==!1&&n.push(wh.configure(this.options.listKeymap)),this.options.orderedList!==!1&&n.push(Ch.configure(this.options.orderedList)),this.options.taskItem!==!1&&n.push(Pk.configure(this.options.taskItem)),this.options.taskList!==!1&&n.push(zk.configure(this.options.taskList)),n}});var Yr="&nbsp;",Xs=" ",Bk=Ue.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",fe(this.options.HTMLAttributes,n),0]},parseMarkdown:(n,e)=>{const t=n.tokens||[];if(t.length===1&&t[0].type==="image")return e.parseChildren([t[0]]);const r=e.parseInline(t);return t.length===1&&t[0].type==="text"&&(t[0].raw===Yr||t[0].text===Yr||t[0].raw===Xs||t[0].text===Xs)&&r.length===1&&r[0].type==="text"&&(r[0].text===Yr||r[0].text===Xs)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(n,e,t)=>{var r,i;if(!n)return"";const s=Array.isArray(n.content)?n.content:[];if(s.length===0){const o=Array.isArray((r=t?.previousNode)==null?void 0:r.content)?t.previousNode.content:[];return((i=t?.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?Yr:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),$k=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Fk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hk=sn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",fe(this.options.HTMLAttributes,n),0]},markdownTokenName:"del",parseMarkdown:(n,e)=>e.applyMark("strike",e.parseInline(n.tokens||[])),renderMarkdown:(n,e)=>`~~${e.renderChildren(n)}~~`,addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}}
vendor: 4,431 bytes, line 143
143,addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Mn({find:$k,type:this.type})]},addPasteRules(){return[tn({find:Fk,type:this.type})]}}),Uk=Ue.create({name:"text",group:"inline",parseMarkdown:n=>({type:"text",text:n.text||""}),renderMarkdown:n=>n.text||""}),Nh=sn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",fe(this.options.HTMLAttributes,n),0]},parseMarkdown(n,e){return e.applyMark(this.name||"underline",e.parseInline(n.tokens||[]))},renderMarkdown(n,e){return`++${e.renderChildren(n)}++`},markdownTokenizer:{name:"underline",level:"inline",start(n){return n.indexOf("++")},tokenize(n,e,t){const i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(n);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:t.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Vk=Nh;function _k(n={}){return new ae({view(e){return new Wk(e,n)}})}class Wk{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}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,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,a=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),y=u?p.bottom:p.top;u&&f&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:p.left,right:p.right,top:y-g,bottom:y+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;r={left:u.left-f,right:u.left+f,top:u.top,bottom:u.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.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,d;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=l.getBoundingClientRect(),f=u.width/l.offsetWidth,h=u.height/l.offsetHeight;c=u.left-l.scrollLeft*f,d=u.top-l.scrollTop*h}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/a+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/a+"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}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=qc(this.editorView.state.doc,o,this.editorView.dragging.slice);a!=null&&(o=a)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ce extends V{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));
vendor: 13,886 bytes, line 143
143return ce.valid(r)?new ce(r):V.near(r)}content(){return R.empty}eq(e){return e instanceof ce&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ce(e.resolve(t.pos))}getBookmark(){return new Ea(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Kk(e)||!qk(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&ce.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let a=e.node(o);if(t>0?e.indexAfter(o)<a.childCount:e.index(o)>0){s=a.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let l=e.doc.resolve(i);if(ce.valid(l))return l}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!F.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;let a=e.doc.resolve(i);if(ce.valid(a))return a}return null}}}ce.prototype.visible=!1;ce.findFrom=ce.findGapCursorFrom;V.jsonID("gapcursor",ce);class Ea{constructor(e){this.pos=e}map(e){return new Ea(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ce.valid(t)?new ce(t):V.near(t)}}function Eh(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Kk(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Eh(i.type))return!0;if(i.inlineContent)return!1}}return!0}function qk(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Eh(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Jk(){return new ae({props:{decorations:Xk,createSelectionBetween(n,e,t){return e.pos==t.pos&&ce.valid(t)?new ce(t):null},handleClick:Yk,handleKeyDown:Gk,handleDOMEvents:{beforeinput:Zk}}})}const Gk=nu({ArrowLeft:Zr("horiz",-1),ArrowRight:Zr("horiz",1),ArrowUp:Zr("vert",-1),ArrowDown:Zr("vert",1)});function Zr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,a=e>0?o.$to:o.$from,l=o.empty;if(o instanceof H){if(!s.endOfTextblock(t)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=ce.findGapCursorFrom(a,e,l);return c?(i&&i(r.tr.setSelection(new ce(c))),!0):!1}}function Yk(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ce.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&F.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ce(r))),!0)}function Zk(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ce))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=T.empty;for(let o=r.length-1;o>=0;o--)i=T.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new R(i,0,0));return s.setSelection(H.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Xk(n){if(!(n.selection instanceof ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",oe.create(n.doc,[Ie.widget(n.selection.head,e,{key:"gapcursor"})])}var es=200,be=function(){};be.prototype.append=function(e){return e.length?(e=be.from(e),!this.length&&e||e.length<es&&this.leafAppend(e)||this.length<es&&e.leafPrepend(this)||this.appendInner(e)):this};be.prototype.prepend=function(e){return e.length?be.from(e).append(this):this};be.prototype.appendInner=function(e){return new Qk(this,e)};be.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?be.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};be.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};be.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};be.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i};be.from=function(e){return e instanceof be?e:e&&e.length?new Mh(e):be.empty};var Mh=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,a){for(var l=s;l<o;l++)if(i(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,a){for(var l=s-1;l>=o;l--)if(i(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=es)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=es)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(be);be.empty=new Mh([]);var Qk=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,o){var a=this.left.length;if(i<a&&this.left.forEachInner(r,i,Math.min(s,a),o)===!1||s>a&&this.right.forEachInner(r,Math.max(i-a,0),Math.min(this.length,s)-a,o+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var a=this.left.length;if(i>a&&this.right.forEachInvertedInner(r,i-a,Math.max(s,a)-a,o+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(i,a),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(be);const ex=500;class Qe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,a,l,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,d.push(u);return}if(i){d.push(new rt(u.map));let h=u.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new rt(p,void 0,void 0,c.length+d.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(u.step);if(u.selection)return a=i?u.selection.map(i.slice(s)):u.selection,l=new Qe(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:o,selection:a}}addTransform(e,t,r,i){let s=[],o=this.eventCount,a=this.items,l=!i&&a.length?a.get(a.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new rt(e.mapping.maps[d],u,t),h;(h=l&&l.merge(f))&&(f=h,d?s.pop():a=a.slice(0,a.length-1)),s.push(f),t&&(o++,t=void 0),i||(l=f)}let c=o-r.depth;return c>nx&&(a=tx(a,c),o-=c),new Qe(a.append(s),o)}remapping(e,t){let r=new kr;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,t),r}addMaps(e){return this.eventCount==0?this:new Qe(this.items.append(e.map(t=>new rt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},i);let l=t;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let y=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new rt(p,y,g))}else r.push(new rt(p))},i);let c=[];for(let f=t;f<o;f++)c.push(new rt(s.maps[f]));let d=this.items.slice(0,i).append(c).append(r),u=new Qe(d,a);return u.emptyItemCount()>ex&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((o,a)=>{if(a>=e)i.push(o),o.selection&&s++;else if(o.step){let l=o.step.map(t.slice(r)),c=l&&l.getMap();if(r--,c&&t.appendMap(c,r),l){let d=o.selection&&o.selection.map(t.slice(r));d&&s++;let u=new rt(c.invert(),l,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else o.map&&r--},this.items.length,0),new Qe(be.from(i.reverse()),s)}}Qe.empty=new Qe(be.empty,0);function tx(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class rt{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new rt(t.getMap().invert(),t,this.selection)}}}class Mt{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const nx=20;function rx(n,e,t,r){let i=t.getMeta(Yt),s;if(i)return i.historyState;t.getMeta(ox)&&(n=new Mt(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Yt))return o.getMeta(Yt).redo?new Mt(n.done.addTransform(t,void 0,r,di(e)),n.undone,lc(t.mapping.maps),n.prevTime,n.prevComposition):new Mt(n.done,n.undone.addTransform(t,void 0,r,di(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let a=t.getMeta("composition"),l=n.prevTime==0||!o&&n.prevComposition!=a&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ix(t,n.prevRanges)),c=o?Qs(n.prevRanges,t.mapping):lc(t.mapping.maps);return new Mt(n.done.addTransform(t,l?e.selection.getBookmark():void 0,r,di(e)),Qe.empty,c,t.time,a??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Mt(n.done.rebased(t,s),n.undone.rebased(t,s),Qs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Mt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Qs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ix(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function lc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,o)=>e.push(s,o));return e}function Qs(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function sx(n,e,t){let r=di(e),i=Yt.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),a=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),l=new Mt(t?a:s.remaining,t?s.remaining:a,null,0,-1);return s.transform.setSelection(o).setMeta(Yt,{redo:t,historyState:l})}let eo=!1,cc=null;function di(n){let e=n.plugins;if(cc!=e){eo=!1,cc=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){eo=!0;break}}return eo}const Yt=new me("history"),ox=new me("closeHistory");function ax(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new ae({key:Yt,state:{init(){return new Mt(Qe.empty,Qe.empty,null,0,-1)},apply(e,t,r){return rx(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?Ah:r=="historyRedo"?Oh:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function Th(n,e){return(t,r)=>{let i=Yt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=sx(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Ah=Th(!1,!0),Oh=Th(!0,!0);de.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=n?.node||this.editor.state.doc;if((n?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=n?.node||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new ae({key:new me("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const a=o-i,l=0,c=a;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const d=r.tr.deleteRange(l,c);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;
143if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,d=a;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}});var lx=de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[_k(this.options)]}});de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ae({key:new me("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!t||!r)return oe.create(n,[]);let o=0;this.options.mode==="deepest"&&n.descendants((l,c)=>{if(l.isText)return;if(!(i>=c&&i<=c+l.nodeSize-1))return!1;o+=1});let a=0;return n.descendants((l,c)=>{if(l.isText||!(i>=c&&i<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&o-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(Ie.node(c,c+l.nodeSize,{class:this.options.className}))}),oe.create(n,s)}}})]}});var cx=de.create({name:"gapCursor",addProseMirrorPlugins(){return[Jk()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=Q(z(n,"allowGapCursor",t)))!=null?e:null}}}),Ih="placeholder",Ar=new me("tiptap__placeholder"),dc=200;function uc(n){const{editor:e,placeholder:t,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:a,classes:{emptyNode:l,emptyEditor:c}}=n,d=[l];return o&&d.push(c),Ie.node(i,i+s.nodeSize,{class:d.join(" "),[r]:typeof t=="function"?t({editor:e,node:s,pos:i,hasAnchor:a}):t})}function hc(n,e){return typeof n=="function"?n(e):n}function dx({editor:n,options:e,dataAttribute:t,doc:r,selection:i}){var s,o;if(!(n.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:l}=i,c=[],d=n.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const f=r.resolve(l),h=f.depth>0?f.node(1):f.nodeAfter,p=f.depth>0?f.before(1):l;if(h&&h.type.isTextblock&&Nr(h)){const y=l>=p&&l<=p+h.nodeSize;c.push(uc({editor:n,isEmptyDoc:d,dataAttribute:t,hasAnchor:y,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:hc(e.emptyNodeClass,{editor:n,node:h,pos:p,hasA
143nchor:y})},node:h,pos:p}))}}else{const f=Ar.getState(n.state),h=(s=f?.topPos)!=null?s:0,p=(o=f?.bottomPos)!=null?o:r.content.size;r.nodesBetween(h,p,(y,g)=>{const b=l>=g&&l<=g+y.nodeSize,k=!y.isLeaf&&Nr(y);return y.type.isTextblock&&(b||!e.showOnlyCurrent)&&k&&c.push(uc({editor:n,isEmptyDoc:d,dataAttribute:t,hasAnchor:b,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:hc(e.emptyNodeClass,{editor:n,node:y,pos:g,hasAnchor:b})},node:y,pos:g})),e.includeChildren})}return oe.create(r,c)}function ux(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function hx(n){const e=getComputedStyle(n),t=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(t)}function fx(n){let e=n;for(;e;){if(hx(e))return e;const t=e.parentElement;if(!t){const r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}e=t}return window}function px(n){return n===window?{top:0,bottom:window.innerHeight}:n.getBoundingClientRect()}function mx({doc:n,view:e,scrollContainer:t}){const r=e.dom.getBoundingClientRect(),i=t?px(t):{top:0,bottom:window.innerHeight},s=Math.max(r.top,i.top)-dc,o=Math.min(r.bottom,i.bottom)+dc;if(s>=o)return{top:0,bottom:n.content.size};const l=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,c=e.posAtCoords({left:l,top:s+2}),d=e.posAtCoords({left:l,top:o-2});return{top:c?c.pos:0,bottom:d?d.pos:n.content.size}}var gx={init(){return{topPos:null,bottomPos:null}},apply(n,e){const t=n.getMeta(Ar);return t?.positions?{topPos:t.positions.top,bottomPos:t.positions.bottom}:n.docChanged?{topPos:e.topPos!==null?n.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?n.mapping.map(e.bottomPos):null}:e}};function yx(n){const e=fx(n.dom),t=()=>{const a=mx({view:n,doc:n.state.doc,scrollContainer:e}),l=Ar.getState(n.state);if(l?.topPos===a.top&&l?.bottomPos===a.bottom)return;const c=n.state.tr.setMeta(Ar,{positions:a});n.dispatch(c)};let r=null,i=0;const s=150,o=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;const a=performance.now();a-i>=s?(i=a,t()):o()}))};return e.addEventListener("scroll",o,{passive:!0}),t(),{update(a,l){n.state.doc.content.size!==l.doc.content.size&&o()},destroy:()=>{r!==null&&cancelAnimationFrame(r),e.removeEventListener("scroll",o)}}}function bx({editor:n,options:e}){const t=e.dataAttribute?`data-${ux(e.dataAttribute)}`:`data-${Ih}`;return new ae({key:Ar,state:gx,view:yx,props:{decorations:({doc:r,selection:i})=>dx({editor:n,options:e,dataAttribute:t,doc:r,selection:i})}})}de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Ih,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[bx({editor:this.editor,options:this.options})]}});var kx=`.ProseMirror:not(.ProseMirror-focused) *::selection {
144  background: transparent;
145}
146
147.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {
148  background: transparent;
149}`;de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return n.options.injectCSS&&typeof document<"u"&&Lu(kx,n.options.injectNonce,"selection"),[new ae({key:new me("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||bu(t.selection)||n.view.dragging?null:oe.create(t.doc,[Ie.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});var xx="skipTrailingNode";function fc({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||e?.type===n}var vx=de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new me(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new ae({key:e,appendTransaction:(i,s,o)=>{const{doc:a,tr:l,schema:c}
149=o,d=e.getState(o),u=a.content.size,f=c.nodes[t];if(!i.some(h=>h.getMeta(xx))&&d)return l.insert(u,f.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!fc({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!fc({node:o,types:r})}}})]}}),wx=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Ah(n,e),redo:()=>({state:n,dispatch:e})=>Oh(n,e)}},addProseMirrorPlugins(){return[ax(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()}}}),Sx=de.create({name:"starterKit",addExtensions(){var n,e,t,r;const i=[];return this.options.bold!==!1&&i.push(A0.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(C0.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(gh.configure(this.options.bulletList)),this.options.code!==!1&&i.push(D0.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(L0.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(P0.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(lx.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(cx.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(z0.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(B0.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(wx.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push($0.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(_0.configure(this.options.italic)),this.options.listItem!==!1&&i.push(bh.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(wh.configure((n=this.options)==null?void 0:n.listKeymap)),this.options.link!==!1&&i.push(gk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Ch.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(Bk.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Hk.configure(this.options.strike)),this.options.text!==!1&&i.push(Uk.configure(this.options.text)),this.options.underline!==!1&&i.push(Nh.configure((t=this.options)==null?void 0:t.underline)),this.options.trailingNode!==!1&&i.push(vx.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),Cx=Sx;function pc({value:n,onChange:e,placeholder:t}){const r=d0({extensions:[Cx.configure({heading:{levels:[2,3]},horizontalRule:!1,codeBlock:!1,code:!1}),Vk],content:n,onUpdate({editor:s}){const o=s.getHTML();e(o==="<p></p>"?"":o)},editorProps:{attributes:{class:"rich-editor-content","data-placeholder":t??"Začněte psát…"}}});if(v.useEffect(()=>{if(!r)return;const s=r.getHTML(),o=n||"";s!==o&&r.commands.setContent(o)},[n,r]),!r)return null;const i=({active:s,title:o,onClick:a,children:l})=>m.jsx("button",{type:"button",title:o,onClick:a,className:`rich-toolbar-btn${s?" rich-toolbar-btn--active":""}`,children:l});return m.jsxs("div",{className:"rich-editor",children:[m.jsxs("div",{className:"rich-toolbar",children:[m.jsx(i,{active:r.isActive("bold"),title:"Tučně (Ctrl+B)",onClick:()=>r.chain().focus().toggleBold().run(),children:m.jsx("strong",{children:"B"})}),m.jsx(i,{active:r.isActive("italic"),title:"Kurzíva (Ctrl+I)",onClick:()=>r.chain().focus().toggleItalic().run(),children:m.jsx("em",{children:"I"})}),m.jsx(i,{active:r.isActive("underline"),title:"Podtržení (Ctrl+U)",onClick:()=>r.chain().focus().toggleUnderline().run(),children:m.jsx("span",{style:{textDecoration:"underline"},children:"U"})}),m.jsx("span",{className:"rich-toolbar-sep"}),m.jsx(i,{active:r.isActive("heading",{level:2}),title:"Nadpis H2",onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),children:"H2"}),m.jsx(i,{active:r.isActive("heading",{level:3}),title:"Nadpis H3",onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),children:"H3"}),m.jsx("span",{className:"rich-toolbar-sep"}),m.jsx(i,{active:r.isActive("bulletList"),title:"Odrážkový seznam",onClick:()=>r.chain().focus().toggleBulletList().run(),children:"≡"}),m.jsx(i,{active:r.isActive("orderedList"),title:"Číslovaný seznam",onClick:()=>r.chain().focus().toggleOrderedList().run(),children:"1."}),m.jsx("span",{className:"rich-toolbar-sep"}),m.jsx(i,{title:"Vymazat formátování",onClick:()=>r.chain().focus().clearNodes().unsetAllMarks().run(),children:"✕"})]}),m.jsx(Bu,{editor:r})]})}function Ce(n){return n.trim()===""?void 0:n.trim()}function mc(){return m.jsxs("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",viewBox:"0 0 24 24","aria-hidden":"true",children:[m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"}),m.jsx("circle",{cx:"12",cy:"12",r:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}function gc(){return m.jsxs("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",viewBox:"0 0 24 24","aria-hidden":"true",children:[m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94m3.36-2.68A10.07 10.07 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19m-6.72-1.07a3 3 0 11-4.24-4.24"}),m.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23",strokeLinecap:"round"})]})}function He(n){const e=n instanceof Error?n.message:String(n),t=e.match(/\] Server Error (.+)/);if(t){const r=t[1].trim();return!r||r.toLowerCase().startsWith("called by")||r.toLowerCase().startsWith("uncaught")?"Nastala chyba na serveru. Zkuste to znovu.":r}return e.includes("[CONVEX")?"Nastala chyba na serveru. Zkuste to znovu.":e}let Nx=0,gr=null;function B(n,e="success"){if(!gr)return;const t=++Nx;gr(r=>[...r,{id:t,message:n,type:e}]),setTimeout(()=>{gr?.(r=>r.filter(i=>i.id!==t))},4500)}function Ex(){const[n,e]=v.useState([]);return v.useEffect(()=>(gr=e,()=>{gr=null}),[]),n.length===0?null:m.jsx("div",{className:"toast-container","aria-live":"polite",children:n.map(t=>m.jsxs("div",{className:`toast toast--${t.type}`,children:[m.jsx("span",{className:"toast-icon",children:t.type==="success"?"✓":"✕"}),m.jsx("span",{className:"toast-message",children:t.message}),m.jsx("button",{className:"toast-close",onClick:()=>e(r=>r.filter(i=>i.id!==t.id)),"aria-label":"Zavřít",children:"×"})]},t.id))})}function Zx(){const{signOut:n}=Xh(),[e,t]=v.useState("housereel"),[r,i]=v.useState(!1),s=ee(U.seed.seedDefaultContent),o=qe(U.seed.hasContent),[a,l]=v.useState(!1),[c,d]=v.useState(!1),u=p=>{t(p),i(!1)},f=async()=>
149{l(!0);try{await s({}),d(!0)}finally{l(!1)}},h={home:"Domů – Slider",housereel:"Housereel",contact:"Kontakt",media:"Mediální knihovna",locations:"Services",settings:"Nastavení"};return m.jsxs("div",{className:"admin-shell",children:[m.jsx(Ex,{}),m.jsxs("div",{className:"admin-mobile-bar",children:[m.jsxs("button",{className:"admin-burger",onClick:()=>i(!0),"aria-label":"Otevřít menu",children:[m.jsx("span",{}),m.jsx("span",{}),m.jsx("span",{})]}),m.jsx("span",{className:"admin-mobile-title",children:h[e]})]}),r&&m.jsx("div",{className:"admin-sidebar-backdrop",onClick:()=>i(!1)}),m.jsxs("aside",{className:`admin-sidebar${r?" admin-sidebar--open":""}`,children:[m.jsxs("div",{className:"admin-sidebar-logo",children:[m.jsx("img",{src:"https://assets.macaly-user-data.dev/cdn-cgi/image/format=webp,width=2000,height=2000,fit=scale-down,quality=90,anim=true/mp40gdr62rv336cccufw7q5b/j06o77lwm1eij7bv17lmunkl/Hh5r-NiG09jocdXNluSOv.png",alt:"Forward International",className:"w-full h-auto"}),m.jsx("span",{className:"admin-logo-sub",children:"ADMIN"})]}),m.jsx("nav",{className:"admin-nav",children:Object.keys(h).filter(p=>p!=="contact"&&p!=="settings").map(p=>m.jsx("button",{onClick:()=>u(p),className:`admin-nav-item${e===p?" active":""}`,children:h[p]},p))}),m.jsxs("div",{className:"admin-sidebar-bottom",children:[o&&!o.hasNews&&!c&&m.jsx("button",{onClick:f,disabled:a,className:"admin-btn admin-btn--primary admin-btn--seed",title:"Načte výchozí obsah ze starého webu",children:a?"Načítám…":"↓ Načíst výchozí obsah"}),c&&m.jsx("div",{className:"admin-seed-done",children:"✓ Obsah načten"}),m.jsx("button",{onClick:()=>u("settings"),className:`admin-nav-item${e==="settings"?" active":""}`,children:"⚙ Nastavení"}),m.jsx(Qh,{to:"/",className:"admin-nav-link",children:"← Web"}),m.jsx("button",{onClick:()=>void n(),className:"admin-nav-item admin-nav-item--logout",children:"Odhlásit se"})]})]}),m.jsxs("main",{className:"admin-main",children:[m.jsx("div",{className:"admin-section-header admin-section-header--desktop",children:m.jsx("h1",{className:"admin-section-title",children:h[e]})}),m.jsxs("div",{className:"admin-content",children:[e==="home"&&m.jsx(Ax,{}),e==="housereel"&&m.jsx(Rx,{}),e==="contact"&&m.jsx(jx,{}),e==="media"&&m.jsx(zx,{}),e==="locations"&&m.jsx($x,{}),e==="settings"&&m.jsx(Lx,{})]})]})]})}function Mx(n){const e=ee(U.content.generateUploadUrl),[t,r]=v.useState(!1),[i,s]=v.useState(!1);return{upload:v.useCallback(async a=>{if(!a.type.startsWith("image/")&&!a.type.startsWith("video/")){B("Podporovány jsou pouze obrázky a videa.","error");return}r(!0);try{const l=await e(),c=await fetch(l,{method:"POST",headers:{"Content-Type":a.type},body:a});if(!c.ok)throw new Error(`Upload selhal: ${c.statusText}`);const{storageId:d}=await c.json(),u=l.split("/api/")[0]+`/api/storage/${d}`;console.log("Soubor nahrán, storageId:",d),n(u,d)}catch(l){console.error("Chyba při nahrávání:",l),B("Nahrávání se nezdařilo. Zkuste znovu.","error")}finally{r(!1)}},[e,n]),uploading:t,dragOver:i,setDragOver:s}}function Tx(n,e){const[t,r]=v.useState(null),[i,s]=v.useState(null),o=v.useRef(null),a=v.useRef(null),l=v.useCallback(u=>{o.current=u,a.current=u,r(u),s(u)},[]),c=v.useCallback(u=>{a.current!==u&&(a.current=u,s(u))},[]),d=v.useCallback(()=>{const u=o.current,f=a.current;if(o.current=null,a.current=null,r(null),s(null),u===null||f===null||u===f)return;const h=[...n],p=h.splice(u,1)[0];if(p){h.splice(f,0,p);try{Promise.resolve(e(h.map(y=>y._id))).catch(y=>{console.error("Reorder uložení selhalo:",y)})}catch(y){console.error("Reorder uložení selhalo:",y)}}},[n,e]);return{handleDragStart:l,handleDragEnter:c,handleDragEnd:d,dragFrom:t,dragOver:i}}function ne({label:n,value:e,onChange:t,placeholder:r,type:i="text",multiline:s}){return m.jsxs("div",{className:"admin-field",children:[m.jsx("label",{className:"admin-field-label",children:n}),s?m.jsx("textarea",{className:"admin-input admin-input--textarea",value:e,onChange:o=>t(o.target.value),placeholder:r,rows:3}
149):m.jsx("input",{type:i,className:"admin-input",value:e,onChange:o=>t(o.target.value),placeholder:r})]})}function Ax(){const n=qe(U.content.listHomeSlides)??[],e=ee(U.content.createHomeSlide),t=ee(U.content.updateHomeSlide),r=ee(U.content.deleteHomeSlide),i=ee(U.content.generateUploadUrl),o=qe(U.content.getSettings)?.czEnabled??!0,[a,l]=v.useState(null),[c,d]=v.useState(!1),[u,f]=v.useState(null),[h,p]=v.useState("form"),[y,g]=v.useState(!1),[b,k]=v.useState(!1),N=v.useRef(null),A={titleCs:"",titleEn:"",subtitleCs:"",subtitleEn:"",vimeoId:"",imageUrl:"",linkUrl:"",linkLabel:"",altText:"",order:n.length,storageId:void 0,mobileStorageId:void 0},[S,I]=v.useState(A),O=async E=>{const $=await i(),j=await fetch($,{method:"POST",headers:{"Content-Type":"image/webp"},body:E.landscapeBlob});if(!j.ok)throw new Error("Upload landscape selhal");const{storageId:P}=await j.json();if(!E.mobileBlob)return{storageId:P,mobileStorageId:void 0};const q=await i(),X=await fetch(q,{method:"POST",headers:{"Content-Type":"image/webp"},body:E.mobileBlob});if(!X.ok)throw new Error("Upload mobilní varianty selhal");const{storageId:w}=await X.json();return{storageId:P,mobileStorageId:w}},L=async E=>{k(!0);try{const{storageId:$,mobileStorageId:j}=await O(E);if(h==="form")I(P=>({...P,storageId:$,mobileStorageId:j,imageUrl:""})),B("Obrázek nahrán — uložte slide pro potvrzení.");else{const P=n.find(q=>q._id===h);P&&(await t({id:P._id,titleCs:P.titleCs,titleEn:P.titleEn,subtitleCs:P.subtitleCs,subtitleEn:P.subtitleEn,vimeoId:P.vimeoId||void 0,imageUrl:void 0,storageId:$,mobileStorageId:j,linkUrl:P.linkUrl||void 0,linkLabel:P.linkLabel||void 0,altText:P.altText||void 0,order:P.order}),B("Ořez slidu byl uložen."))}}catch($){B(`Nahrávání selhalo: ${He($)}`,"error")}finally{k(!1),f(null)}},C=async E=>{const $=E.imageUrl;if(!$){B("Slide nemá obrázek pro ořez","error");return}g(!0);try{const j=await fetch($);if(!j.ok)throw new Error(`Fetch selhal: ${j.status}`);const P=await j.blob(),q=new File([P],"slide.webp",{type:P.type||"image/webp"});p(E._id),f(q)}catch{B("Obrázek se nepodařilo načíst. Zkuste jiný soubor.","error")}finally{g(!1)}},D=async()=>{const E={titleCs:S.titleCs,titleEn:S.titleEn,subtitleCs:S.subtitleCs,subtitleEn:S.subtitleEn,vimeoId:Ce(S.vimeoId),imageUrl:Ce(S.imageUrl),linkUrl:Ce(S.linkUrl),linkLabel:Ce(S.linkLabel),altText:Ce(S.altText),order:S.order,...S.storageId?{storageId:S.storageId}:{},...S.mobileStorageId?{mobileStorageId:S.mobileStorageId}:{}};try{a?(await t({id:a,...E}),l(null),B("Slide byl uložen.")):(await e(E),d(!1),B("Slide byl přidán.")),I(A)}catch($){B(`Uložení se nezdařilo: ${He($)}`,"error")}},Z=async(E,$)=>{if(confirm(`Opravdu smazat slide "${$}"?`))try{await r({id:E}),B("Slide byl smazán.")}catch(j){B(`Smazání se nezdařilo: ${He(j)}`,"error")}},G=E=>{l(E._id),I({titleCs:E.titleCs,titleEn:E.titleEn,subtitleCs:E.subtitleCs,subtitleEn:E.subtitleEn,vimeoId:E.vimeoId||"",imageUrl:E.imageUrl||"",linkUrl:E.linkUrl||"",linkLabel:E.linkLabel||"",altText:E.altText||"",order:E.order,storageId:E.storageId,mobileStorageId:E.mobileStorageId})},W=S.imageUrl||void 0;return m.jsxs("div",{children:[m.jsx("div",{className:"admin-toolbar",children:m.jsx("button",{onClick:()=>{d(!0),l(null),I(A)},className:"admin-btn admin-btn--primary",children:"+ Přidat slide"})}),(c||a)&&m.jsxs("div",{className:"admin-form-box",children:[m.jsx("h3",{className:"admin-form-title",children:a?"Upravit slide":"Nový slide"}),m.jsxs("div",{className:"admin-form-grid",children:[o&&m.jsx(ne,{label:"Nadpis (CZ)",value:S.titleCs,onChange:E=>I({...S,titleCs:E})}),m.jsx(ne,{label:"Nadpis (EN)",value:S.titleEn,onChange:E=>I({...S,titleEn:E})}),o&&m.jsx(ne,{label:"Podnadpis (CZ)",value:S.subtitleCs,onChange:E=>I({...S,subtitleCs:E})}),m.jsx(ne,{label:"Podnadpis (EN)",value:S.subtitleEn,onChange:E=>I({...S,subtitleEn:E})}),m.jsx(ne,{label:"Vimeo ID (video na pozadí)",value:S.vimeoId,onChange:E=>I({...S,vimeoId:E}),placeholder:"např. 123456789"}),m.jsxs("div",{className:"admin-field admin-field--full",children:[m.jsx("label",{className:"admin-field-label",children:"Obrázek pozadí (alternativa k videu)"}),m.jsx("input",{ref:N,type:"file",accept:"image/*",style:{display:"none"},onChange:E=>{const $=E.target.files?.[0];$&&(p("form"),f($)),E.target.value=""}}
149),W?m.jsxs("div",{className:"admin-slide-img-preview",children:[m.jsx("img",{src:W,alt:"Náhled slidu",className:"admin-dropzone-img"}),m.jsxs("div",{className:"admin-slide-img-btns",children:[m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm",onClick:()=>N.current?.click(),disabled:b,children:"Změnit obrázek"}),m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm",onClick:()=>void C({_id:a,imageUrl:S.imageUrl}),disabled:y||b||!S.imageUrl,title:"Znovu oříznout — otevře ořezávací nástroj",children:y?"…":"✂ Upravit ořez"})]})]}):S.storageId?m.jsxs("div",{className:"admin-slide-img-preview",children:[m.jsx("div",{className:"admin-dropzone admin-dropzone--placeholder",children:m.jsx("span",{children:"✓ Obrázek nahrán (uložte slide)"})}),m.jsx("div",{className:"admin-slide-img-btns",children:m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm",onClick:()=>N.current?.click(),disabled:b,children:"Změnit obrázek"})})]}):m.jsx("div",{className:`admin-dropzone${b?" admin-dropzone--uploading":""}`,onClick:()=>!b&&N.current?.click(),children:b?m.jsxs("div",{className:"admin-dropzone-uploading",children:[m.jsx("div",{className:"admin-spinner"}),m.jsx("span",{children:"Nahrávám…"})]}):m.jsxs("div",{className:"admin-dropzone-empty",children:[m.jsx("svg",{width:"32",height:"32",fill:"none",stroke:"currentColor",strokeWidth:"1.5",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),m.jsx("span",{children:"Klikněte pro výběr obrázku"}),m.jsx("span",{className:"admin-dropzone-hint",children:"Otevře ořezávací nástroj (16:9 + 9:16)"})]})})]}),m.jsx(ne,{label:"Alt text obrázku (SEO)",value:S.altText,onChange:E=>I({...S,altText:E}),placeholder:"Popis obrázku pro vyhledávače"}),m.jsx(ne,{label:"URL tlačítka (CTA link)",value:S.linkUrl,onChange:E=>I({...S,linkUrl:E}),placeholder:"/cs/housereel"}),m.jsx(ne,{label:"Text tlačítka",value:S.linkLabel,onChange:E=>I({...S,linkLabel:E}),placeholder:"HOUSEREEL"})]}),m.jsxs("div",{className:"admin-form-actions",children:[m.jsx("button",{onClick:D,className:"admin-btn admin-btn--primary",children:"Uložit"}),m.jsx("button",{onClick:()=>{l(null),d(!1)},className:"admin-btn admin-btn--ghost",children:"Zrušit"})]})]}),m.jsx("div",{className:"admin-card-grid",children:n.map(E=>m.jsxs("div",{className:"admin-card",children:[m.jsx("div",{className:"admin-card-thumb",children:E.imageUrl?m.jsx("img",{src:E.imageUrl,alt:E.titleCs}):m.jsxs("div",{className:"admin-card-no-img",children:["📹 ",E.vimeoId||"Bez média"]})}),m.jsxs("div",{className:"admin-card-body",children:[m.jsx("p",{className:"admin-card-name",children:E.titleCs||E.subtitleCs||"Bez názvu"}),E.vimeoId&&m.jsx("span",{className:"admin-badge",children:"Vimeo"}),E.mobileImageUrl&&m.jsx("span",{className:"admin-badge admin-badge--mobile",children:"📱 Mobil"})]}),m.jsxs("div",{className:"admin-card-actions",children:[m.jsx("button",{onClick:()=>G(E),className:"admin-btn admin-btn--sm",children:"Upravit"}),E.imageUrl&&m.jsx("button",{onClick:()=>void C(E),className:"admin-btn admin-btn--sm",disabled:y||b,title:"Znovu oříznout obrázek slidu",children:y&&h===E._id?"…":"✂"}),m.jsx("button",{onClick:()=>void Z(E._id,E.titleCs||E.subtitleCs||"Bez názvu"),className:"admin-btn admin-btn--sm admin-btn--danger",children:"Smazat"})]})]},E._id))}),u&&m.jsx(no,{file:u,fileIndex:0,fileTotal:1,onConfirm:E=>{L(E)},onSkip:()=>f(null),onCancel:()=>f(null)})]})}function Ox({children:n,onClose:e}){return v.useEffect(()=>{const t=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e]),m.jsx("div",{className:"admin-edit-modal-backdrop",onClick:t=>{t.target===t.currentTarget&&e()},children:m.jsxs("div",{className:"admin-edit-modal",children:[m.jsx("button",{className:"admin-edit-modal-close",onClick:e,"aria-label":"Zavřít",children:"✕"}),n]})})}function Ix({open:n,onClose:e,onSelect:t}){const[r,i]=v.useState(""),[s,o]=v.useState(""),[a,l]=v.useState("crop"),[c,d]=v.useState(!1);v.useEffect(()=>{const g=setTimeout(()=>
149o(r),300);return()=>clearTimeout(g)},[r]);const u=qe(U.media.list,{search:s||void 0})??[],f=u.filter(g=>!g.usageCount).length,h=c?u.filter(g=>!g.usageCount):u;if(!n)return null;const p=c?"Všechny obrázky jsou někde použité.":`Žádná média${r?" pro tento výraz":""}.`,y=g=>{g.url&&(t(g.url),e())};return m.jsx("div",{className:"media-modal-backdrop",onClick:g=>{g.target===g.currentTarget&&e()},children:m.jsxs("div",{className:"media-picker-modal",children:[m.jsxs("div",{className:"media-picker-header",children:[m.jsxs("h3",{className:"admin-form-title",style:{margin:0},children:["Vybrat z mediální knihovny (",h.length,")"]}),m.jsx("button",{className:"media-modal-close",onClick:e,children:"✕"})]}),m.jsxs("div",{className:"media-picker-controls",children:[m.jsx("input",{type:"search",className:"admin-input media-search",placeholder:"Hledat podle názvu…",value:r,onChange:g=>i(g.target.value),autoFocus:!0}),m.jsxs("div",{className:"media-view-toggle",role:"group","aria-label":"Zobrazení mediální knihovny",children:[m.jsx("button",{type:"button",className:`media-view-toggle-btn${a==="crop"?" media-view-toggle-btn--active":""}`,onClick:()=>l("crop"),title:"Ořez — jednotné poměry stran",children:"Ořez"}),m.jsx("button",{type:"button",className:`media-view-toggle-btn${a==="masonry"?" media-view-toggle-btn--active":""}`,onClick:()=>l("masonry"),title:"Kaskádová mřížka — zachovává originální poměr stran",children:"Masonry"}),m.jsx("button",{type:"button",className:`media-view-toggle-btn${a==="justified"?" media-view-toggle-btn--active":""}`,onClick:()=>l("justified"),title:"Justified — sjednocená výška řádků",children:"Justified"})]}),m.jsxs("button",{type:"button",className:`media-unused-toggle${c?" media-unused-toggle--active":""}`,onClick:()=>d(g=>!g),title:"Zobrazit jen obrázky, které nejsou nikde na webu použité","aria-pressed":c,children:[m.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),m.jsx("circle",{cx:"12",cy:"12",r:"3"}),m.jsx("path",{strokeLinecap:"round",d:"M3 3l18 18"})]}),"Nepoužité",f>0?` (${f})`:""]})]}),h.length===0&&m.jsx("p",{className:"admin-empty",style:{margin:"0 1rem 1rem"},children:p}),a==="crop"&&m.jsx("div",{className:"media-picker-grid",children:h.map(g=>m.jsxs("button",{className:"media-picker-item",onClick:()=>y(g),title:g.name,children:[g.thumbUrl?m.jsx("img",{src:g.thumbUrl,alt:g.altText??g.name,className:"media-picker-item-img",loading:"lazy"}):m.jsx("div",{className:"media-item-placeholder",children:"?"}),m.jsx(vn,{item:g}),m.jsx("span",{className:"media-picker-item-name",children:g.name})]},g._id))}),a==="masonry"&&m.jsx("div",{className:"media-picker-masonry",children:h.map(g=>m.jsxs("button",{className:"media-picker-item media-picker-item--masonry",onClick:()=>y(g),title:g.name,children:[g.thumbUrl?m.jsx("img",{src:g.thumbUrl,alt:g.altText??g.name,className:"media-picker-item-img media-item-img--natural",style:g.width&&g.height?{aspectRatio:`${g.width} / ${g.height}`}:void 0,loading:"lazy"}):m.jsx("div",{className:"media-item-placeholder",children:"?"}),m.jsx(vn,{item:g}),m.jsx("span",{className:"media-picker-item-name",children:g.name})]},g._id))}),a==="justified"&&m.jsx("div",{className:"media-picker-justified",children:h.map(g=>{const b=g.width&&g.height?g.width/g.height:1.3333333333333333;return m.jsxs("button",{className:"media-picker-item media-picker-item--justified",style:{flexGrow:b,flexBasis:`${b*130}px`},onClick:()=>y(g),title:g.name,children:[g.thumbUrl?m.jsx("img",{src:g.thumbUrl,alt:g.altText??g.name,className:"media-picker-item-img",loading:"lazy"}):m.jsx("div",{className:"media-item-placeholder",children:"?"}),m.jsx(vn,{item:g}),m.jsx("span",{className:"media-picker-item-name",children:g.name})]},g._id)})})]})})}function Dx({currentUrl:n,onUploaded:e,onSelect:t}){const[r,i]=v.useState(!1),s=v.useRef(null),{upload:o,uploading:a,dragOver:l,setDragOver:c}=Mx(e),d=f=>{f.preventDefault(),c(!1);const h=f.dataTransfer.files[0];h&&o(h)},u=f=>{const h=f.target.files?.[0];h&&o(h),f.target.value=""};return m.jsxs("div",{className:"thumbnail-picker",children:[m.jsx(Ix,{open:r,onClose:()=>i(!1),onSelect:t}
149),m.jsx("input",{ref:s,type:"file",accept:"image/*",onChange:u,style:{display:"none"}}),n?m.jsxs("div",{className:"thumbnail-picker-selected",children:[m.jsxs("div",{className:"thumbnail-picker-img-wrap",children:[m.jsx("img",{src:n,alt:"Náhled",className:"thumbnail-picker-img"}),m.jsx("button",{type:"button",className:"thumbnail-picker-remove",onClick:()=>t(""),title:"Odebrat obrázek",children:"✕"})]}),m.jsxs("div",{className:"thumbnail-picker-change-row",children:[m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm",onClick:()=>s.current?.click(),children:"↑ Nahrát jiný"}),m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm",onClick:()=>i(!0),children:"↗ Knihovna"})]})]}):m.jsx("div",{className:`thumbnail-picker-zone${l?" thumbnail-picker-zone--over":""}${a?" thumbnail-picker-zone--uploading":""}`,onDragOver:f=>{f.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:d,children:a?m.jsxs("div",{className:"thumbnail-picker-zone-inner",children:[m.jsx("div",{className:"admin-spinner"}),m.jsx("span",{children:"Nahrávám…"})]}):m.jsxs("div",{className:"thumbnail-picker-zone-inner",children:[m.jsx("button",{type:"button",className:"thumbnail-picker-upload-btn",onClick:()=>s.current?.click(),title:"Nahrát obrázek",children:m.jsx("svg",{width:"28",height:"28",fill:"none",stroke:"currentColor",strokeWidth:"1.8",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),m.jsx("span",{className:"thumbnail-picker-zone-label",children:"Přetáhnout nebo nahrát obrázek"}),m.jsx("button",{type:"button",className:"thumbnail-picker-library-btn",onClick:()=>i(!0),children:"⊞ Knihovna"})]})})]})}function Rx(){const n=qe(U.content.listHouseReelItems,{includeUnpublished:!0})??[],e=ee(U.content.createHouseReelItem),t=ee(U.content.updateHouseReelItem),r=ee(U.content.deleteHouseReelItem),i=ee(U.content.reorderHouseReelItems),s=ee(U.content.toggleHouseReelItemPublished),o=ee(U.content.toggleHouseReelShowInNews);ee(U.content.migrateNewsToHouseReel),qe(U.content.listNewsPosts,{includeUnpublished:!0})?.length;const l=qe(U.content.getSettings)?.czEnabled??!0,[c,d]=v.useState(!1),[u,f]=v.useState(null),[h,p]=v.useState(!1),[y,g]=v.useState(!1),b={titleCs:"",titleEn:"",categories:["housereel"],director:"",dop:"",agency:"",vimeoId:"",thumbnailUrl:"",altText:"",seoDescription:"",showInNews:!1,published:!1},[k,N]=v.useState(b),A=async()=>{const w={titleCs:k.titleCs,titleEn:k.titleEn,categories:k.categories,published:k.published,showInNews:k.showInNews},Y=re=>re.trim()||null;try{u?(await t({id:u,...w,director:Y(k.director),dop:Y(k.dop),agency:Y(k.agency),vimeoId:Y(k.vimeoId),thumbnailUrl:Y(k.thumbnailUrl),altText:Y(k.altText),seoDescription:Y(k.seoDescription),storageId:k.storageId??null,order:n.find(re=>re._id===u)?.order??0}),f(null),B("Housereel položka byla uložena.")):(await e({...w,director:Ce(k.director),dop:Ce(k.dop),agency:Ce(k.agency),vimeoId:Ce(k.vimeoId),thumbnailUrl:Ce(k.thumbnailUrl),altText:Ce(k.altText),seoDescription:Ce(k.seoDescription),...k.storageId?{storageId:k.storageId}:{},order:n.length}),p(!1),B("Housereel položka byla přidána.")),N(b)}catch(re){console.error("Uložení Housereel položky selhalo:",re),B(`Uložení se nezdařilo: ${He(re)}`,"error")}},S=async w=>{try{await r({id:w}),f(null),p(!1),g(!1),B("Položka byla smazána.")}catch(Y){g(!1),B(`Smazání se nezdařilo: ${He(Y)}`,"error")}},I=w=>{f(w._id),N({titleCs:w.titleCs,titleEn:w.titleEn,categories:Ln(w),director:w.director||"",dop:w.dop||"",agency:w.agency||"",vimeoId:w.vimeoId||"",thumbnailUrl:w.thumbnailUrl||"",altText:w.altText||"",seoDescription:w.seoDescription||"",storageId:w.storageId,published:w.published??!0,showInNews:w.showInNews??!1})},[O,L]=v.useState("all"),[C,D]=v.useState(""),Z=v.useCallback(w=>{const Y=C.trim().toLowerCase();if(!Y)return!0;const re=Ln(w).map(Rn=>`${Rn} ${vs(Rn,"cs")} ${vs(Rn,"en")}`).join(" ");return[w.titleEn,w.director,w.agency,w.dop,w.seoDescription,re].filter(
149Boolean).join(" ").toLowerCase().includes(Y)},[C]),W=(O==="all"?n:O==="news"?n.filter(w=>w.showInNews===!0):n.filter(w=>Ln(w).includes(O))).filter(Z),E=v.useCallback(async w=>{try{await i({orderedIds:w})}catch(Y){console.error("Reorder Housereel selhal:",Y),B("Změna pořadí se nepodařila uložit. Zkuste to znovu.","error")}},[i]),{handleDragStart:$,handleDragEnter:j,handleDragEnd:P,dragFrom:q,dragOver:X}=Tx(W,E);return m.jsxs("div",{children:[m.jsxs("div",{className:"admin-toolbar",children:[m.jsx("button",{onClick:()=>{p(!0),f(null),N(b)},className:"admin-btn admin-btn--primary",children:"+ Přidat Housereel"}),m.jsx("input",{type:"search",className:"admin-input admin-toolbar-search",placeholder:"Hledat (Název EN, Director, Agency, D.O.P., SEO popis, Kategorie)…",value:C,onChange:w=>D(w.target.value),"data-testid":"housereel-search"}),m.jsx("span",{className:"admin-hint",children:"Přetáhněte karty pro změnu pořadí"})]}),m.jsxs("div",{className:"admin-filter-bar","data-testid":"housereel-category-filter",children:[m.jsx("button",{className:`admin-filter-btn${O==="all"?" admin-filter-btn--active":""}`,onClick:()=>L("all"),children:"Vše"}),Ta.map(w=>m.jsx("button",{className:`admin-filter-btn${O===w.slug?" admin-filter-btn--active":""}`,onClick:()=>L(w.slug),children:w.labelCs},w.slug)),m.jsx("button",{className:`admin-filter-btn${O==="news"?" admin-filter-btn--active":""}`,onClick:()=>L("news"),title:"Zobrazit položky označené pro Novinky",children:"NEWS ★"})]}),(h||u)&&m.jsxs(Ox,{onClose:()=>{f(null),p(!1),g(!1)},children:[m.jsx("h3",{className:"admin-form-title",children:u?"Upravit Housereel":"Nový Housereel"}),m.jsxs("div",{className:"admin-form-grid",children:[l&&m.jsx(ne,{label:"Název (CZ)",value:k.titleCs,onChange:w=>N({...k,titleCs:w}),placeholder:"např. Stará Myslivecká"}),m.jsx(ne,{label:"Název (EN)",value:k.titleEn,onChange:w=>N({...k,titleEn:w})}),m.jsxs("div",{className:"admin-field admin-field--full",children:[m.jsx("label",{className:"admin-field-label",children:"Kategorie"}),m.jsx("div",{className:"admin-checkbox-group",children:Ta.map(w=>m.jsxs("label",{className:"admin-checkbox-label",children:[m.jsx("input",{type:"checkbox",checked:k.categories.includes(w.slug),onChange:Y=>{const re=Y.target.checked?[...k.categories,w.slug]:k.categories.filter(Ze=>Ze!==w.slug);N({...k,categories:re})}}),m.jsx("span",{children:w.labelCs})]},w.slug))})]}),m.jsx(ne,{label:"DIRECTOR",value:k.director,onChange:w=>N({...k,director:w}),placeholder:"např. Jan Krofta"}),m.jsx(ne,{label:"D.O.P.",value:k.dop,onChange:w=>N({...k,dop:w}),placeholder:"např. Martin Matyášek"}),m.jsx(ne,{label:"Agency",value:k.agency,onChange:w=>N({...k,agency:w}),placeholder:"např. Česká produkční"}),m.jsx(ne,{label:"Vimeo URL nebo ID",value:k.vimeoId,onChange:w=>N({...k,vimeoId:w}),placeholder:"např. 123456789"}),m.jsxs("div",{className:"admin-field admin-field--full",children:[m.jsx("label",{className:"admin-field-label",children:"Obrázek (thumbnail)"}),m.jsx(Dx,{currentUrl:k.thumbnailUrl||void 0,onUploaded:(w,Y)=>N({...k,thumbnailUrl:w,storageId:Y}),onSelect:w=>N({...k,thumbnailUrl:w,storageId:null})})]}),m.jsx(ne,{label:"Alt text (SEO popis obrázku)",value:k.altText,onChange:w=>N({...k,altText:w}),placeholder:"Krátký popis obrázku pro vyhledávače"}),m.jsx(ne,{label:"SEO popis",value:k.seoDescription,onChange:w=>N({...k,seoDescription:w}),multiline:!0,placeholder:"Delší popis pro SEO..."})]}),m.jsxs("div",{className:"admin-form-actions",children:[m.jsx("button",{onClick:A,className:"admin-btn admin-btn--primary",children:"Uložit"}),m.jsx("button",{onClick:()=>{f(null),p(!1),g(!1)},className:"admin-btn admin-btn--ghost",children:"Zrušit"}),u&&(y?m.jsxs("span",{className:"admin-delete-confirm",children:[m.jsx("span",{className:"admin-delete-confirm-label",children:"Opravdu smazat?"}),m.jsx("button",{onClick:()=>void S(u),className:"admin-btn admin-btn--danger",children:"Ano, smazat"}),m.jsx("button",{onClick:()=>g(!1),className:"admin-btn admin-btn--ghost",children:"Ne"})]}):m.jsx("button",{onClick:()=>g(!0),className:"admin-btn admin-btn--danger",children:"Smazat"})),m.jsxs("button",{type:"button",className:`admin-visibility-btn${k.published?" admin-visibility-btn--visible":" admin-visibility-btn--hidden"}`,onClick:()=>N({...k,published:!k.published}),title:k.published?"Zobrazeno na webu — kliknout pro skrytí":"Skryto z webu — kliknout pro zobrazení",children:[k.published?m.jsx(mc,{}):m.jsx(gc,{}),m.jsx("span",{children:k.published?"Zobrazeno":"Skryto"})]}),m.jsxs("button",{type:"button",className:`admin-visibility-btn admin-visibility-btn--news${k.showInNews?" admin-visibility-btn--news-on":" admin-visibility-btn--news-off"}`,onClick:()=>N({...k,showInNews:!k.showInNews}),title:k.showInNews?"Zobrazeno v Novinkách — kliknout pro skrytí":"Skryto z Novinek — kliknout pro zobrazení",children:[m.jsx("span",{children:k.showInNews?"★":"☆"}),m.jsx("span",{children:k.showInNews?"V novinkách":"Bez novinek"})]})]})]}),m.jsxs("div",{className:"admin-card-grid",children:[W.length===0&&m.jsx("p",{className:"admin-empty",children:"Žádné položky."}),W.map((w,Y)=>m.jsxs(v.Fragment,{children:[q!==null&&q!==X&&X===Y&&m.jsx("div",{className:"admin-card admin-card--placeholder","aria-hidden":"true"}),m.jsxs("div",{className:`admin-card admin-card--draggable${u===w._id?" admin-card--editing":""}${w.published?"":" admin-card--hidden"}${q===Y?" admin-card--dragging":""}`,draggable:!0,onDragStart:()=>$(Y),onDragEnter:()=>j(Y),onDragEnd:P,onDragOver:re=>re.preventDefault(),children:[m.jsx("div",{className:"admin-card-drag-handle",title:"Přetáhněte pro změnu pořadí",children:"⠿"}),m.jsx("div",{className:"admin-card-thumb",children:w.thumbnailUrl?m.jsx("img",{src:w.thumbnailUrl,alt:w.altText||w.titleCs}):w.vimeoId?m.jsx("div",{className:"admin-card-no-img",children:"▶ Vimeo"}):m.jsx("div",{className:"admin-card-no-img",children:"Bez obrázku"})}),m.jsxs("div",{className:"admin-card-body",children:[m.jsx("p",{className:"admin-card-name",children:w.titleCs||w.titleEn||"Bez názvu"}),Ln(w).length>0&&m.jsx("div",{className:"admin-card-categories",children:Ln(w).map(re=>m.jsx("span",{className:"admin-card-category",children:vs(re,"cs")},re))}),w.director&&m.jsxs("p",{className:"admin-card-sub",children:["Dir: ",w.director]}),w.dop&&m.jsxs("p",{className:"admin-card-sub",children:["D.O.P.: ",w.dop]}),w.agency&&m.jsxs("p",{className:"admin-card-sub",children:["Agency: ",w.agency]}),w.vimeoId&&m.jsx("span",{className:"admin-badge",children:"Vimeo"})]}),m.jsxs("div",{className:"admin-card-actions",children:[m.jsx("button",{onClick:()=>I(w),className:"admin-btn admin-btn--sm",children:"Upravit"}),m.jsx("button",{onClick:()=>s({id:w._id}),className:`admin-btn admin-btn--sm admin-btn--icon${w.published?" admin-btn--vis-on":" admin-btn--vis-off"}`,title:w.published?"Skrýt z webu":"Zobrazit na webu",children:w.published?m.jsx(mc,{}):m.jsx(gc,{})}),m.jsx("button",{onClick:()=>o({id:w._id}),className:`admin-btn admin-btn--sm admin-btn--icon${w.showInNews?" admin-btn--news-on":" admin-btn--news-off"}`,title:w.showInNews?"Zobrazeno v Novinkách — kliknout pro skrytí":"Skryto z Novinky — kliknout pro zobrazení",children:w.showInNews?"★":"☆"})]})]})]},w._id))]})]})}function jx(){const n=qe(U.content.listContactOffices)??[],e=ee(U.content.createContactOffice),t=ee(U.content.updateContactOffice),r=ee(U.content.deleteContactOffice),[i,s]=v.useState(null),[o,a]=v.useState(!1),l={city:"",countryCs:"",countryEn:"",addressCs:"",addressEn:"",phone:"",email:""},[c,d]=v.useState(l),u=async()=>{const p={...c,phone:Ce(c.phone),email:Ce(c.email)};try{i?(await t({id:i,...p,order:n.find(y=>y._id===i)?.order??0}),s(null),B("Kancelář byla uložena.")):(await e({...p,order:n.length}),a(!1),B("Kancelář byla přidána.")),d(l)}catch(y){B(`Uložení se nezdařilo: ${He(y)}`,"error")}},f=async(p,y)=>{if(confirm(`Opravdu smazat kancelář "${y}"?`))try{await r({id:p}),B("Kancelář byla smazána.")}catch(g){B(`Smazání se nezdařilo: ${He(g)}
149`,"error")}},h=p=>{s(p._id),d({city:p.city,countryCs:p.countryCs,countryEn:p.countryEn,addressCs:p.addressCs,addressEn:p.addressEn,phone:p.phone||"",email:p.email||""})};return m.jsxs("div",{children:[m.jsx("div",{className:"admin-toolbar",children:m.jsx("button",{onClick:()=>{a(!0),s(null),d(l)},className:"admin-btn admin-btn--primary",children:"+ Přidat kancelář"})}),(o||i)&&m.jsxs("div",{className:"admin-form-box",children:[m.jsx("h3",{className:"admin-form-title",children:i?"Upravit kancelář":"Nová kancelář"}),m.jsxs("div",{className:"admin-form-grid",children:[m.jsx(ne,{label:"Město",value:c.city,onChange:p=>d({...c,city:p})}),m.jsx(ne,{label:"Stát (CZ)",value:c.countryCs,onChange:p=>d({...c,countryCs:p})}),m.jsx(ne,{label:"Stát (EN)",value:c.countryEn,onChange:p=>d({...c,countryEn:p})}),m.jsx(ne,{label:"Adresa (CZ)",value:c.addressCs,onChange:p=>d({...c,addressCs:p}),multiline:!0}),m.jsx(ne,{label:"Adresa (EN)",value:c.addressEn,onChange:p=>d({...c,addressEn:p}),multiline:!0}),m.jsx(ne,{label:"Telefon",value:c.phone,onChange:p=>d({...c,phone:p}),placeholder:"+420 xxx xxx xxx"}),m.jsx(ne,{label:"E-mail",value:c.email,onChange:p=>d({...c,email:p}),placeholder:"[email protected]"})]}),m.jsxs("div",{className:"admin-form-actions",children:[m.jsx("button",{onClick:u,className:"admin-btn admin-btn--primary",children:"Uložit"}),m.jsx("button",{onClick:()=>{s(null),a(!1)},className:"admin-btn admin-btn--ghost",children:"ZruÅ¡it"})]})]}),m.jsxs("div",{className:"admin-list",children:[n.length===0&&m.jsx("p",{className:"admin-empty",children:"Žádné kanceláře."}),n.map(p=>m.jsxs("div",{className:"admin-list-item",children:[m.jsxs("div",{className:"admin-list-item-info",children:[m.jsx("strong",{children:p.city}),m.jsxs("span",{className:"admin-muted",children:[" — ",p.countryCs]}),p.email&&m.jsx("span",{className:"admin-badge",children:p.email})]}),m.jsxs("div",{className:"admin-list-item-actions",children:[m.jsx("button",{onClick:()=>h(p),className:"admin-btn admin-btn--sm",children:"Upravit"}),m.jsx("button",{onClick:()=>void f(p._id,p.city),className:"admin-btn admin-btn--sm admin-btn--danger",children:"Smazat"})]})]},p._id))]})]})}function Lx(){const n=qe(U.content.getSettings),e=ee(U.content.updateSettings),[t,r]=v.useState(!1),i=n?.czEnabled??!0,s=n?.maintenanceMode??!1,[o,a]=v.useState(""),[l,c]=v.useState("");v.useEffect(()=>{n&&(a(n.maintenanceBannerCs??""),c(n.maintenanceBannerEn??""))},[n?.maintenanceBannerCs,n?.maintenanceBannerEn]);const d=async()=>{r(!0);try{await e({czEnabled:!i,maintenanceMode:s,maintenanceBannerCs:o,maintenanceBannerEn:l}),B(i?"Česká verze webu byla skryta.":"Česká verze webu byla zapnuta.")}catch(h){B(`Nastala chyba: ${He(h)}`,"error")}finally{r(!1)}},u=async()=>{r(!0);try{await e({czEnabled:i,maintenanceMode:!s,maintenanceBannerCs:o,maintenanceBannerEn:l}),B(s?"Režim aktualizace byl vypnut — plná navigace obnovena.":"Režim aktualizace byl zapnut — v menu je viditelný jen Kontakt.")}catch(h){B(`Nastala chyba: ${He(h)}`,"error")}finally{r(!1)}},f=async()=>{r(!0);try{await e({czEnabled:i,maintenanceMode:s,maintenanceBannerCs:o,maintenanceBannerEn:l}),B("Text banneru byl uložen.")}catch(h){B(`Nastala chyba: ${He(h)}`,"error")}finally{r(!1)}};return n===void 0?m.jsx("div",{className:"admin-empty",children:"Načítám…"}):m.jsxs("div",{style:{maxWidth:560},children:[m.jsxs("div",{className:"admin-settings-card",style:{marginBottom:"1rem"},children:[m.jsxs("div",{className:"admin-settings-row",children:[m.jsxs("div",{className:"admin-settings-info",children:[m.jsx("p",{className:"admin-settings-label",children:"Režim aktualizace webu"}),m.jsx("p",{className:"admin-settings-desc",children:"Pokud je zapnuto, v navigaci bude viditelná pouze záložka Kontakt a sociální sítě. Slider na úvodní stránce zůstane zachován."})]}),m.jsx("button",{type:"button",className:`admin-toggle${s?" admin-toggle--on":" admin-toggle--off"}`,onClick:u,disabled:t,"aria-label":s?"Vypnout režim aktualizace":"Zapnout režim aktualizace",children:m.jsx("span",{className:"admin-toggle-knob"})})]}),m.jsx("p",{className:"admin-settings-status",children:s?"⚠ Režim aktualizace je ZAPNUTÝ — navigace je minimální (pouze Kontakt)":"✓ Normální provoz — plná navigace zobrazena"}),m.jsxs("div",{style:{marginTop:"1.25rem",display:"flex",flexDirection:"column",gap:"0.75rem"},children:[m.jsxs("div",{children:[m.jsx("label",{className:"admin-settings-label",style:{display:"block",marginBottom:"0.35rem"},children:"Text banneru (CZ)"}),m.jsx("input",{type:"text",className:"admin-input",value:o,onChange:h=>a(h.target.value),placeholder:"Web se právě aktualizuje."})]}),m.jsxs("div",{children:[m.jsx("label",{className:"admin-settings-label",style:{display:"block",marginBottom:"0.35rem"},children:"Text banneru (EN)"}),m.jsx("input",{type:"text",className:"admin-input",value:l,onCh
149ange:h=>c(h.target.value),placeholder:"Website is currently being updated."})]}),m.jsx("button",{type:"button",className:"admin-btn admin-btn--primary",onClick:f,disabled:t,style:{alignSelf:"flex-start"},children:t?"Ukládám…":"Uložit text"})]})]}),m.jsxs("div",{className:"admin-settings-card",children:[m.jsxs("div",{className:"admin-settings-row",children:[m.jsxs("div",{className:"admin-settings-info",children:[m.jsx("p",{className:"admin-settings-label",children:"Česká verze webu (CZ)"}),m.jsx("p",{className:"admin-settings-desc",children:"Pokud je vypnuto, přepínač CZ/EN zmizí z webu a na webu bude dostupná pouze anglická verze. CZ pole ve formulářích budou skryta (data se neztratí)."})]}),m.jsx("button",{type:"button",className:`admin-toggle${i?" admin-toggle--on":" admin-toggle--off"}`,onClick:d,disabled:t,"aria-label":i?"Vypnout českou verzi":"Zapnout českou verzi",children:m.jsx("span",{className:"admin-toggle-knob"})})]}),m.jsx("p",{className:"admin-settings-status",children:i?"✓ CZ verze je zapnutá — web zobrazuje přepínač CZ / EN":"✕ CZ verze je vypnutá — web zobrazuje pouze EN"})]})]})}function Px(n){return!n.usageLocations||n.usageLocations.length===0?"Nikde nepoužito":n.usageLocations.map(e=>`${e.label}: ${e.title}`).join(`
150`)}function vn({item:n}){const e=!!n.usageCount;return m.jsx("span",{className:`media-item-usage${e?"":" media-item-usage--unused"}`,title:Px(n),children:e?`${n.usageCount}×`:"nepoužito"})}function to(n,e,t,r){return new Promise((i,s)=>{const o=new Image,a=URL.createObjectURL(n);o.onload=()=>{URL.revokeObjectURL(a);const l=o.naturalWidth,c=o.naturalHeight,d=Math.min(1,e/l,t/c),u=document.createElement("canvas");u.width=Math.round(l*d),u.height=Math.round(c*d);const f=u.getContext("2d");if(!f)return s(new Error("Canvas context not available"));f.drawImage(o,0,0,u.width,u.height),u.toBlob(h=>{if(!h)return s(new Error("Canvas toBlob failed"));i({blob:h,width:u.width,height:u.height})},"image/webp",r)},o.onerror=s,o.src=a})}function Xr(n,e){return e||n===0?"Ext. URL":n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function zx(){const[n,e]=v.useState(""),[t,r]=v.useState(""),[i,s]=v.useState(null),[o,a]=v.useState(!1),[l,c]=v.useState(""),[d,u]=v.useState({name:"",altText:"",description:""}),[f,h]=v.useState(!1),[p,y]=v.useState(!1),[g,b]=v.useState(!1),k=v.useRef(null),N=v.useRef(!1),[A,S]=v.useState(!1),[I,O]=v.useState("crop"),[L,C]=v.useState(!1);v.useEffect(()=>{const x=setTimeout(()=>r(n),350);return()=>clearTimeout(x)},[n]);const[D,Z]=v.useState([]),[G,W]=v.useState(0),[E,$]=v.useState(null),[j,P]=v.useState(null),[q,X]=v.useState(!1),w=qe(U.media.list,{search:t||void 0})??[],Y=w.filter(x=>!x.usageCount).length,re=L?w.filter(x=>!x.usageCount):w,Ze=ee(U.media.generateUploadUrl),Rn=ee(U.media.create),Dh=ee(U.media.update),Rh=ee(U.media.remove),jh=ee(U.media.replaceStorage);ee(U.media.setMobileVariant);const Lh=ee(U.media.recropMedia),ms=async(x,K)=>{const se=x.name.replace(/\.[^.]+$/,"");console.log("Nahrávám:",se,K?"(ořezáno)":"(bez ořezu)");let pe,we,$e,ot,Le=null,an=0,jn=0;if(K)pe=K.landscapeBlob,we=K.landscapeWidth,$e=K.landscapeHeight,ot=K.thumbBlob,Le=K.mobileBlob??null,an=K.mobileWidth??0,jn=K.mobileHeight??0;else{const[Bt,at]=await Promise.all([to(x,3840,2160,.85),to(x,400,250,.7)]);pe=Bt.blob,we=Bt.width,$e=Bt.height,ot=at.blob}let Lr;if(K){const Bt=await Ze({}),at=await fetch(Bt,{method:"POST",headers:{"Content-Type":x.type||"application/octet-stream"},body:x});if(at.ok){const{storageId:xs}=await at.json();Lr=xs,console.log("Originál uložen:",se,x.size,"B")}else console.warn("Upload originálu selhal (nekritické):",at.statusText)}const Kh=await Ze({}),ys=await fetch(Kh,{method:"POST",headers:{"Content-Type":"image/webp"},body:pe});if(!ys.ok)throw new Error(`Upload selhal: ${ys.statusText}`);const{storageId:qh}=await ys.json(),Jh=await Ze({}),bs=await fetch(Jh,{method:"POST",headers:{"Content-Type":"image/webp"},body:ot});if(!bs.ok)throw new Error(`Upload thumbnailů selhal: ${bs.statusText}`);const{storageId:Gh}=await bs.json();let ks;if(Le){const Bt=await Ze({}),at=await fetch(Bt,{method:"POST",headers:{"Content-Type":"image/webp"},body:Le});if(!at.ok)throw new Error(`Upload mobilní varianty selhal: ${at.statusText}`);const{storageId:xs}=await at.json();ks=xs}await Rn({name:se,storageId:qh,thumbnailStorageId:Gh,...ks?{mobileStorageId:ks,mobileWidth:an,mobileHeight:jn,mobileSizeBytes:Le.size}:{},...Lr?{originalStorageId:Lr,originalSizeBytes:x.size}:{},mimeType:"image/webp",sizeBytes:pe.size,width:we,height:$e}),console.log("Nahrán soubor:",se)},Ma=x=>{const K=x.filter(se=>se.type.startsWith("image/"));if(K.length===0){B("Vyberte obrázky (JPEG, PNG, WebP, GIF…)","error");return}Z(K),W(0)},Ph=async x=>{const K=D[G];a(!0),c(`Nahrávám ${G+1}/${D.length}: ${K.name}`);try{await ms(K,x)}catch(se){console.error("Chyba při nahrávání:",K.name,se),B(`Chyba při nahrávání ${K.name}`,"error")}
150a(!1),c(""),G+1<D.length?W(G+1):(Z([]),W(0),B(`${D.length===1?"Obrázek byl nahrán.":`${D.length} obrázků bylo nahráno.`}`))},zh=x=>{if(x){const se=D.slice(G);Z([]),W(0),(async()=>{a(!0);for(let pe=0;pe<se.length;pe++){const we=se[pe];c(`Nahrávám (bez ořezu) ${pe+1}/${se.length}: ${we.name}`);try{await ms(we)}catch($e){console.error("Chyba při nahrávání (přeskočit vše):",we.name,$e),B(`Chyba při nahrávání ${we.name}`,"error")}}a(!1),c(""),B(`${se.length===1?"Obrázek byl nahrán.":`${se.length} obrázků bylo nahráno.`}`)})();return}const K=D[G];a(!0),c(`Nahrávám ${G+1}/${D.length}: ${K.name}`),ms(K).then(()=>{a(!1),c(""),G+1<D.length?W(G+1):(Z([]),W(0),B(`${D.length===1?"Obrázek byl nahrán.":`${D.length} obrázků bylo nahráno.`}`))}).catch(se=>{console.error("Chyba při nahrávání (skip):",K.name,se),B(`Chyba při nahrávání ${K.name}`,"error"),a(!1),c(""),Z([])})},Bh=()=>{Z([]),W(0)},$h=async x=>{const K=x,se=K.resolvedOriginalUrl??K.url;if(!se){B("Fotka nemá URL","error");return}X(!0);try{const pe=!!K.resolvedOriginalUrl;console.log("Načítám fotku pro re-crop:",x.name,pe?"(originál)":"(landscape verze)");const we=await fetch(se);if(!we.ok)throw new Error(`Fetch selhal: ${we.status}`);const $e=await we.blob(),ot=pe?x.mimeType?.includes("png")?".png":x.mimeType?.includes("gif")?".gif":".jpg":".webp",Le=new File([$e],`${x.name}${ot}`,{type:$e.type||"image/webp"});P(x._id),$(Le),s(null)}catch(pe){console.error("Načítání fotky pro ořez selhalo:",pe),B("Fotku se nepodařilo načíst. Zkuste jiný soubor.","error")}finally{X(!1)}},Fh=async x=>{if(j){a(!0),c("Nahrávám nové varianty…");try{console.log("Re-crop: nahrávám landscape, thumbnail, mobile");const K=await Ze({}),se=await fetch(K,{method:"POST",headers:{"Content-Type":"image/webp"},body:x.landscapeBlob});if(!se.ok)throw new Error("Upload landscape selhal");const{storageId:pe}=await se.json(),we=await Ze({}),$e=await fetch(we,{method:"POST",headers:{"Content-Type":"image/webp"},body:x.thumbBlob});if(!$e.ok)throw new Error("Upload thumbnail selhal");const{storageId:ot}=await $e.json();let Le;if(x.mobileBlob){const an=await Ze({}),jn=await fetch(an,{method:"POST",headers:{"Content-Type":"image/webp"},body:x.mobileBlob});if(!jn.ok)throw new Error("Upload mobilní varianty selhal");Le=(await jn.json()).storageId}await Lh({id:j,newStorageId:pe,newThumbnailStorageId:ot,...Le?{newMobileStorageId:Le,newMobileWidth:x.mobileWidth,newMobileHeight:x.mobileHeight,newMobileSizeBytes:x.mobileBlob?.size}:{},newSizeBytes:x.landscapeBlob.size,newWidth:x.landscapeWidth,newHeight:x.landscapeHeight}),console.log("Re-crop dokončen"),B("Ořez byl uložen.")}catch(K){console.error("Re-crop selhal:",K),B("Opětovné oříznutí selhalo. Zkuste to znovu.","error")}finally{a(!1),c(""),$(null),P(null)}}},Hh=x=>{x.target.files&&x.target.files.length>0&&(Ma(Array.from(x.target.files)),x.target.value="")},Uh=x=>{x.preventDefault(),S(!1),N.current=!1,x.dataTransfer.files.length>0&&Ma(Array.from(x.dataTransfer.files))},gs=x=>{s(x),u({name:x.name,altText:x.altText??"",description:x.description??""})},Vh=async()=>{if(i){h(!0);try{await Dh({id:i._id,name:d.name,altText:Ce(d.altText),description:Ce(d.description)}),s(null),B("Metadata byla uložena.")}catch(x){B(`Uložení se nezdařilo: ${He(x)}`,"error")}finally{h(!1)}}},_h=async()=>{if(i&&confirm(`Opravdu smazat "${i.name}"? Tuto akci nelze vrátit.`)){y(!0);try{await Rh({id:i._id}),s(null),B("Soubor byl smazán.")}catch(x){B(`Smazání se nezdařilo: ${He(x)}`,"error")}finally{y(!1)}}},Wh=async()=>{if(!(!i?.url||!i?.storageId)){b(!0);try{console.log("Konvertuji na WebP:",i.name);const x=await fetch(i.url);if(!x.ok)throw new Error(`Fetch selhal: ${x.status}`);const K=await x.blob(),se=new File([K],i.name,{type:K.type}),{blob:pe,width:we,height:$e}=await to(se,3840,2160,.85),ot=await Ze({}),Le=await fetch(ot,{method:"POST",headers:{"Content-Type":"image/webp"},body:pe});if(!Le.ok)throw new Error(`Upload selhal: ${Le.statusText}`);const{storageId:an}=await Le.json();await jh({id:i._id,newStorageId:an,newMimeType:"image/webp",newSizeBytes:pe.size,newWidth:we,newHeight:$e}),console.log("Konverze dokončena:",i.name),s(null),B("Obrázek byl převeden na WebP.")}catch(x){console.error("Konverze selhala:",x),B("Konverze selhala. Zkuste to znovu.","error")}finally{b(!1)}}};return m.jsxs("div",{children:[m.jsxs("div",{className:`media-dropzone${A?" media-dropzone--over":""}`,onDragOver:x=>{x.preventDefault(),N.current||(N.current=!0,S(!0))},onDragLeave:x=>{x.currentTarget.contains(x.relatedTarget)||(N.current=!1,S(!1))},onDrop:Uh,onClick:()=>!o&&k.current?.click(),children:[m.jsx("input",{ref:k,type:"file",accept:"image/*",multiple:!0,onChange:Hh,style:{display:"none"}}),o?m.jsxs("div",{className:"media-dropzone-uploading",children:[m.jsx("div",{className:"admin-spinner"}),m.jsx("span",{children:l})]}):m.jsxs("div",{className:"media-dropzone-idle",children:[m.jsx("svg",{width:"36",height:"36",fill:"none",stroke:"currentColor",strokeWidth:"1.5",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),m.jsx("span",{children:"Přetáhněte obrázky nebo klikněte pro výběr"}),m.jsx("span",{className:"media-dropzone-hint",children:"JPEG, PNG, WebP, GIF • automaticky konvertuje na WebP"})]})]}),m.jsxs("div",{className:"media-toolbar",children:[m.jsx("input",{type:"search",className:"admin-input media-search",placeholder:"Hledat podle názvu…",value:n,onChange:x=>e(x.target.value)}),m.jsxs("div",{className:"media-view-toggle",role:"group","aria-label":"Zobrazení mediální knihovny",children:[m.jsx("button",{type:"button",className:`media-view-toggle-btn${I==="crop"?" media-view-toggle-btn--active":""}`,onClick:()=>O("crop"),title:"Ořez — jednotné poměry stran",children:"Ořez"}),m.jsx("button",{type:"button",className:`media-view-toggle-btn${I==="masonry"?" media-view-toggle-btn--active":""}`,onClick:()=>O("masonry"),title:"Kaskádová mřížka — zachovává originální poměr stran",children:"Masonry"}),m.jsx("button",{type:"button",className:`media-view-toggle-btn${I==="justified"?" media-view-toggle-btn--active":""}`,onClick:()=>O("justified"),title:"Justified — sjednocená výška řádků",children:"Justified"})]}),m.jsxs("button",{type:"button",className:`media-unused-toggle${L?" media-unused-toggle--active":""}`,onClick:()=>C(x=>!x),title:"Zobrazit jen obrázky, které nejsou nikde na webu použité","aria-pressed":L,children:[m.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2 12s3.5-
1507 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),m.jsx("circle",{cx:"12",cy:"12",r:"3"}),m.jsx("path",{strokeLinecap:"round",d:"M3 3l18 18"})]}),"Nepoužité",Y>0?` (${Y})`:""]}),m.jsxs("span",{className:"admin-hint",children:[re.length," ",re.length===1?"soubor":re.length<5?"soubory":"souborů"]})]}),re.length===0&&!o&&m.jsx("p",{className:"admin-empty",children:L?"Všechny obrázky jsou někde použité.":`Žádná média${n?" pro tento vyhledávací výraz":""}.`}),I==="crop"&&m.jsx("div",{className:"admin-media-grid",children:re.map(x=>m.jsxs("button",{className:"media-item",onClick:()=>gs(x),children:[x.thumbUrl?m.jsx("img",{src:x.thumbUrl,alt:x.altText??x.name,className:"media-item-img",loading:"lazy"}):m.jsx("div",{className:"media-item-placeholder",children:"?"}),m.jsx(vn,{item:x}),m.jsxs("div",{className:"media-item-overlay",children:[m.jsx("span",{className:"media-item-name",children:x.name}),m.jsxs("span",{className:"media-item-meta",children:[x.width&&x.height?`${x.width}×${x.height}`:""," ",Xr(x.sizeBytes,!!x.externalUrl)]})]})]},x._id))}),I==="masonry"&&m.jsx("div",{className:"admin-media-masonry",children:re.map(x=>m.jsxs("button",{className:"media-item media-item--masonry",onClick:()=>gs(x),children:[x.thumbUrl?m.jsx("img",{src:x.thumbUrl,alt:x.altText??x.name,className:"media-item-img media-item-img--natural",style:x.width&&x.height?{aspectRatio:`${x.width} / ${x.height}`}:void 0,loading:"lazy"}):m.jsx("div",{className:"media-item-placeholder",children:"?"}),m.jsx(vn,{item:x}),m.jsxs("div",{className:"media-item-overlay",children:[m.jsx("span",{className:"media-item-name",children:x.name}),m.jsxs("span",{className:"media-item-meta",children:[x.width&&x.height?`${x.width}×${x.height}`:""," ",Xr(x.sizeBytes,!!x.externalUrl)]})]})]},x._id))}),I==="justified"&&m.jsx("div",{className:"admin-media-justified",children:re.map(x=>{const K=x.width&&x.height?x.width/x.height:1.3333333333333333;return m.jsxs("button",{className:"media-item media-item--justified",style:{flexGrow:K,flexBasis:`${K*160}px`},onClick:()=>gs(x),children:[x.thumbUrl?m.jsx("img",{src:x.thumbUrl,alt:x.altText??x.name,className:"media-item-img",loading:"lazy"}):m.jsx("div",{className:"media-item-placeholder",children:"?"}),m.jsx(vn,{item:x}),m.jsxs("div",{className:"media-item-overlay",children:[m.jsx("span",{className:"media-item-name",children:x.name}),m.jsxs("span",{className:"media-item-meta",children:[x.width&&x.height?`${x.width}×${x.height}`:""," ",Xr(x.sizeBytes,!!x.externalUrl)]})]})]},x._id)})}),i&&m.jsx("div",{className:"media-modal-backdrop",onClick:x=>{x.target===x.currentTarget&&s(null)},children:m.jsxs("div",{className:"media-modal",children:[m.jsx("button",{className:"media-modal-close",onClick:()=>s(null),children:"✕"}),m.jsxs("div",{className:"media-modal-body",children:[m.jsxs("div",{className:"media-modal-preview",children:[m.jsxs("div",{className:"media-modal-variants",children:[i.url&&m.jsxs("div",{className:"media-modal-variant",children:[m.jsx("span",{className:"media-modal-variant-label",children:"Landscape 16:9"}),m.jsx("img",{src:i.url,alt:i.altText??i.name,className:"media-modal-img"})]}),i.mobileUrl&&m.jsxs("div",{className:"media-modal-variant media-modal-variant--mobile",children:[m.jsx("span",{className:"media-modal-variant-label",children:"Mobil 9:16"}),m.jsx("img",{src:i.mobileUrl,alt:`${i.altText??i.name} — mobil`,className:"media-modal-img media-modal-img--mobile"})]})]}),m.jsxs("div",{className:"media-modal-info",children:[i.width&&i.height&&m.jsxs("span",{children:[i.width," × ",i.height," px"]}),m.jsx("span",{children:Xr(i.sizeBytes,!!i.externalUrl)}),m.jsx("span",{className:"media-modal-mime",children:i.mimeType}),i.storageId&&m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm media-webp-btn",onClick:()=>void $h(i),disabled:q||o,title:"Znovu oříznout — otevře ořezávací nástroj s aktuální verzí fotografie",children:q?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"admin-spinner admin-spinner--xs"})," Načítám…"]}):"✂ Upravit ořez"}),i.storageId&&i.mimeType!=="image/webp"&&m.jsx("button",{type:"button",className:"admin-btn admin-btn--sm media-webp-btn",onClick:()=>void Wh(),disabled:g,title:"Převést obrázek na WebP formát (menší velikost, lepší kvalita)",children:g?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"admin-spinner admin-spinner--xs"})," Konvertuji…"]}):"⟳ Převést na WebP"})]}),i.url&&m.jsx("div",{className:"media-modal-url-row",children:m.jsx("input",{type:"text",readOnly:!0,value:i.url,className:"admin-input media-url-input",onClick:x=>x.target.select()})})]}),m.jsxs("div",{className:"media-modal-fields",children:[m.jsx("h3",{className:"admin-form-title",children:"Upravit metadata"}),m.jsx(ne,{label:"Název souboru",value:d.name,onChange:x=>u({...d,name:x})}),m.jsx(ne,{label:"Alt text (SEO)",value:d.altText,onChange:x=>u({...d,altText:x}),placeholder:"Popis obrázku pro vyhledávače"}),m.jsx(ne,{label:"Poznámka",value:d.description,onChange:x=>u({...d,description:x}),multiline:!0,placeholder:"Interní poznámka…"}),m.jsxs("div",{className:"admin-form-actions",children:[m.jsx("button",{onClick:Vh,disabled:f,className:"admin-btn admin-btn--primary",children:f?"Ukládám…":"Uložit"}),m.jsx("button",{onClick:_h,disabled:p,className:"admin-btn admin-btn--danger",children:p?"Mažu…":"Smazat"})]})]})]})]})}),D.length>
1500&&m.jsx(no,{file:D[G],fileIndex:G,fileTotal:D.length,onConfirm:x=>{Ph(x)},onSkip:zh,onCancel:Bh},G),E&&j&&m.jsx(no,{file:E,fileIndex:0,fileTotal:1,onConfirm:x=>{Fh(x)},onSkip:()=>{$(null),P(null)},onCancel:()=>{$(null),P(null)}})]})}function Bx({city:n}){const e=qe(U.content.listLocationPhotos,{city:n})??[],t=qe(U.content.getServiceContent,{city:n}),r=ee(U.content.addLocationPhoto),i=ee(U.content.removeLocationPhoto),s=ee(U.content.generateUploadUrl),o=ee(U.content.upsertServiceContent),[a,l]=v.useState(!1),[c,d]=v.useState(!1),[u,f]=v.useState(!1),h=v.useRef(null),p=ef[n],[y,g]=v.useState({titleEn:"",titleCs:"",subtitleEn:"",subtitleCs:"",paragraphsEn:"",paragraphsCs:"",ctaLabelEn:"",ctaLabelCs:"",ctaUrl:"",columns:1}),[b,k]=v.useState(!1);v.useEffect(()=>{b||t!==void 0&&(t?g({titleEn:t.titleEn,titleCs:t.titleCs,subtitleEn:t.subtitleEn,subtitleCs:t.subtitleCs,paragraphsEn:t.paragraphsEn,paragraphsCs:t.paragraphsCs,ctaLabelEn:t.ctaLabelEn,ctaLabelCs:t.ctaLabelCs,ctaUrl:t.ctaUrl,columns:t.columns??1}):p&&g({titleEn:p.title,titleCs:p.title,subtitleEn:p.subtitle,subtitleCs:p.subtitle,paragraphsEn:p.paragraphs.map(C=>`<p>${C}</p>`).join(""),paragraphsCs:p.paragraphs.map(C=>`<p>${C}</p>`).join(""),ctaLabelEn:p.ctaLabel,ctaLabelCs:p.ctaLabel,ctaUrl:p.cta,columns:1}),k(!0))},[t,b,p]),v.useEffect(()=>{k(!1)},[n]);const N=async()=>{f(!0);try{await o({city:n,...y,columns:y.columns}),B("Texty uloženy.")}catch(C){console.error("Uložení textů selhalo:",C),B(`Uložení se nezdařilo: ${He(C)}`,"error")}finally{f(!1)}},A=async C=>{const D=Array.from(C).filter(Z=>Z.type.startsWith("image/"));if(D.length){l(!0);try{for(const Z of D){const G=await s(),W=await fetch(G,{method:"POST",headers:{"Content-Type":Z.type},body:Z});if(!W.ok)throw new Error(`Upload selhal: ${W.statusText}`);const{storageId:E}=await W.json(),$=G.split("/api/")[0]+`/api/storage/${E}`;await r({city:n,url:$,storageId:E,altText:Z.name.replace(/\.[^.]+$/,"")}),console.log("Service photo uploaded:",E,"for",n)}B(`${D.length>1?D.length+" fotek":"Fotka"} přidána.`)}catch(Z){console.error("Chyba uploadu:",Z),B("Nahrávání selhalo.","error")}finally{l(!1)}}},S=C=>{C.preventDefault(),d(!1),C.dataTransfer.files.length&&A(C.dataTransfer.files)},I=C=>{C.target.files?.length&&A(C.target.files),C.target.value=""},O=async C=>{if(confirm("Smazat tuto fotku?"))try{await i({id:C}),B("Fotka smazána.")}catch(D){console.error("Mazání selhalo:",D),B("Mazání selhalo.","error")}},L=bc.find(C=>C.slug===n)?.labelEn??n;return m.jsxs("div",{children:[m.jsxs("h3",{className:"admin-form-title",style:{marginBottom:"1.25rem"},children:["Texty stránky — ",L]}),m.jsxs("div",{className:"admin-form-grid",style:{marginBottom:"1.5rem"},children:[m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Nadpis (EN)"}),m.jsx("input",{className:"admin-input",value:y.titleEn,onChange:C=>g(D=>({...D,titleEn:C.target.value})),placeholder:"Prague"})]}),m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Nadpis (CZ)"}),m.jsx("input",{className:"admin-input",value:y.titleCs,onChange:C=>g(D=>({...D,titleCs:C.target.value})),placeholder:"Praha"})]}),m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Podtitulek (EN)"}),m.jsx("input",{className:"admin-input",value:y.subtitleEn,onChange:C=>g(D=>({...D,subtitleEn:C.target.value})),placeholder:"The very heart of Europe."})]}),m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Podtitulek (CZ)"}),m.jsx("input",{className:"admin-input",value:y.subtitleCs,onChange:C=>g(D=>({...D,subtitleCs:C.target.value})),placeholder:"Srdce Evropy."})]})]}),m.jsxs("div",{className:"admin-form-grid",style:{marginBottom:"1.5rem"},children:[m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Obsah stránky (EN)"}),m.jsx(pc,{value:y.paragraphsEn,onChange:C=>g(D=>({...D,paragraphsEn:C})),placeholder:"Napište obsah stránky v angličtině…"})]}),m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Obsah stránky (CZ)"}),m.jsx(pc,{value:y.paragraphsCs,onChange:C=>g(D=>({...D,paragraphsCs:C})),placeholder:"Napište obsah stránky česky…"})]})]}),m.jsxs("div",{className:"admin-form-field",style:{marginBottom:"1.5rem"},children:[m.jsx("label",{className:"admin-label",children:"Rozložení obsahu — počet sloupců"}),m.jsx("div",{className:"service-columns-picker",children:[1,2,3,4].map(C=>m.jsxs("button",{type:"button",className:`service-col-btn${y.columns===C?" service-col-btn--active":""}`,onClick:()=>g(D=>({...D,columns:C})),title:`${C} ${C===1?"sloupec":C<5?"sloupce":"sloupců"}`,children:[m.jsx("span",{className:"service-col-btn-icon",children:Array.from({length:C}).map((D,Z)=>m.jsx("span",{className:"service-col-btn-bar"},Z))}),m.jsx("span",{children:C})]},C))})]}),m.jsxs("div",{className:"admin-form-grid",style:{marginBottom:"0.5rem"},children:[m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Text tlačítka / CTA (EN)"}),m.jsx("input",{className:"admin-input",value:y.ctaLabelEn,onChange:C=>g(D=>({...D,ctaLabelEn:C.target.value})),placeholder:"Join the gang."})]}),m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"Text tlačítka / CTA (CZ)"}),m.jsx("input",{className:"admin-input",value:y.ctaLabelCs,onChange:C=>g(D=>({...D,ctaLabelCs:C.target.value})),placeholder:"Pojďte do toho."})]}),m.jsxs("div",{className:"admin-form-field",children:[m.jsx("label",{className:"admin-label",children:"URL odkazu CTA"}),m.jsx("input",{className:"admin-input",value:y.ctaUrl,onChange:C=>g(D=>({...D,ctaUrl:C.target.value})),placeholder:"/en/contact"})]})]}),m.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:"2.5rem"},children:m.jsx("button",{className:"admin-btn admin-btn--primary",onClick:()=>void N(),disabled:u,children:u?m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"admin-spinner admin-spinner--xs",style:{marginRight:"0.4rem"}}),"Ukládám…"]}):"Uložit texty"})}),m.jsxs("h3",{className:"admin-form-title",style:{marginBottom:"1rem"},children:["Fotogalerie — ",L]}),m.jsxs("div",{className:`media-dropzone${c?" media-dropzone--over":""}`,onDragOver:C=>{C.preventDefault(),d(!0)},onDragLeave:()=>d(!1),onDrop:S,onClick:()=>!a&&h.current?.click(),style:{marginBottom:"2rem"},children:[m.jsx("input",{ref:h,type:"file",accept:"image/*",multiple:!0,onChange:I,style:{display:"none"}}),a?m.jsxs("div",{className:"media-dropzone-uploading",children:[m.jsx("div",{className:"admin-spinner"}),m.jsx("span",{children:"Nahrávám…"})]}):m.jsxs("div",{className:"media-dropzone-idle",children:[m.jsx("svg",{width:"36",height:"36",fill:"none",stroke:"currentColor",strokeWidth:"1.5",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),m.jsx("span",{children:"Přetáhněte fotky nebo klikněte pro výběr"}),m.jsx("span",{className:"media-dropzone-hint",children:"JPEG, PNG, WebP • více najednou"})]})]}),e.length===0?m.jsxs("p",{className:"admin-empty",children:["Žádné fotky pro ",L,". Nahrajte první."]}):m.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"1rem"},children:e.filter(C=>C.url).map(C=>m.jsxs("div",{style:{position:"relative",aspectRatio:"16/9",borderRadius:"4px",overflow:"hidden",background:"var(--muted)"},children:[m.jsx("img",{src:C.url||"",alt:C.altText??L,style:{width:"100%",height:"100%",objectFit:"cover"}}),m.jsx("button",{onClick:()=>void O(C._id),style:{position:"absolute",top:"6px",right:"6px",background:"rgba(0,0,0,0.6)",color:"#fff",border:"none",borderRadius:"50%",width:"28px",height:"28px",cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center"},title:"Smazat","aria-label":"Smazat fotku",children:"✕"})]},C._id))})]})}function $x(){const[n,e]=v.useState("prague");return m.jsxs("div",{children:[m.jsx("div",{className:"admin-tabs",style:{marginBottom:"1.5rem"},children:bc.map(t=>m.jsx("button",{className:`admin-tab${n===t.slug?" admin-tab--active":""}`,onClick:()=>e(t.slug),children:t.labelEn},t.slug))}),m.jsx(Bx,{city:n},n)]})}export{Zx as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.