From 4f9b491fd4ff3d74b7db76b01a4908f8a1460013 Mon Sep 17 00:00:00 2001 From: Shane Friedman Date: Fri, 20 Sep 2024 12:43:46 -0400 Subject: [PATCH] Update to prosemirror-view 1.34.3 selectionFromDOM --- .../{index-Bf2Wm9-4.js => index-CCUXxA_L.js} | 2 +- docs/index.html | 2 +- src/selection/selectionFromDOM.ts | 53 ++++++++++++++----- 3 files changed, 42 insertions(+), 15 deletions(-) rename docs/assets/{index-Bf2Wm9-4.js => index-CCUXxA_L.js} (97%) diff --git a/docs/assets/index-Bf2Wm9-4.js b/docs/assets/index-CCUXxA_L.js similarity index 97% rename from docs/assets/index-Bf2Wm9-4.js rename to docs/assets/index-CCUXxA_L.js index b0f7f84f..b1d19614 100644 --- a/docs/assets/index-Bf2Wm9-4.js +++ b/docs/assets/index-CCUXxA_L.js @@ -45,7 +45,7 @@ `+i[s].replace(" at new "," at ");return n.displayName&&a.includes("")&&(a=a.replace("",n.displayName)),a}while(1<=s&&0<=l);break}}}finally{Ha=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?ji(n):""}function wC(n){switch(n.tag){case 5:return ji(n.type);case 16:return ji("Lazy");case 13:return ji("Suspense");case 19:return ji("SuspenseList");case 0:case 2:case 15:return n=ja(n.type,!1),n;case 11:return n=ja(n.type.render,!1),n;case 1:return n=ja(n.type,!0),n;default:return""}}function Xu(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Mr:return"Fragment";case Nr:return"Portal";case Qu:return"Profiler";case Mf:return"StrictMode";case Yu:return"Suspense";case Gu:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case Iy:return(n.displayName||"Context")+".Consumer";case by:return(n._context.displayName||"Context")+".Provider";case Ef:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Of:return e=n.displayName||null,e!==null?e:Xu(n.type)||"Memo";case rn:e=n._payload,n=n._init;try{return Xu(n(e))}catch{}}return null}function kC(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Xu(e);case 8:return e===Mf?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function On(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function Py(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function vC(n){var e=Py(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,o=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function ms(n){n._valueTracker||(n._valueTracker=vC(n))}function Fy(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=Py(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function kl(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function Zu(n,e){var t=e.checked;return X({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function _h(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=On(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Ly(n,e){e=e.checked,e!=null&&Nf(n,"checked",e,!1)}function ec(n,e){Ly(n,e);var t=On(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?tc(n,e.type,t):e.hasOwnProperty("defaultValue")&&tc(n,e.type,On(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function Wh(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function tc(n,e,t){(e!=="number"||kl(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var Ki=Array.isArray;function Br(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=gs.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function No(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var to={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},xC=["Webkit","ms","Moz","O"];Object.keys(to).forEach(function(n){xC.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),to[e]=to[n]})});function Jy(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||to.hasOwnProperty(n)&&to[n]?(""+e).trim():e+"px"}function _y(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=Jy(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var CC=X({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ic(n,e){if(e){if(CC[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(N(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(N(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(N(61))}if(e.style!=null&&typeof e.style!="object")throw Error(N(62))}}function oc(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var sc=null;function Df(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var lc=null,Vr=null,Jr=null;function jh(n){if(n=Zo(n)){if(typeof lc!="function")throw Error(N(280));var e=n.stateNode;e&&(e=ea(e),lc(n.stateNode,n.type,e))}}function Wy(n){Vr?Jr?Jr.push(n):Jr=[n]:Vr=n}function Uy(){if(Vr){var n=Vr,e=Jr;if(Jr=Vr=null,jh(n),e)for(n=0;n>>=0,n===0?32:31-(zC(n)/PC|0)|0}var ys=64,Ss=4194304;function qi(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function Nl(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,o=n.pingedLanes,s=t&268435455;if(s!==0){var l=s&~i;l!==0?r=qi(l):(o&=s,o!==0&&(r=qi(o)))}else s=t&~i,s!==0?r=qi(s):o!==0&&(r=qi(o));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function Go(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-vt(e),n[e]=t}function BC(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=ro),tp=" ",np=!1;function c0(n,e){switch(n){case"keyup":return hN.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function f0(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Er=!1;function mN(n,e){switch(n){case"compositionend":return f0(e);case"keypress":return e.which!==32?null:(np=!0,tp);case"textInput":return n=e.data,n===tp&&np?null:n;default:return null}}function gN(n,e){if(Er)return n==="compositionend"||!Ff&&c0(n,e)?(n=a0(),Zs=If=pn=null,Er=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=sp(t)}}function m0(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?m0(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function g0(){for(var n=window,e=kl();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=kl(n.document)}return e}function Lf(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function MN(n){var e=g0(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&m0(t.ownerDocument.documentElement,t)){if(r!==null&&Lf(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!n.extend&&o>r&&(i=r,r=o,o=i),i=lp(t,o);var s=lp(t,r);i&&s&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==s.node||n.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),o>r?(n.addRange(e),n.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,Or=null,hc=null,oo=null,pc=!1;function ap(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;pc||Or==null||Or!==kl(r)||(r=Or,"selectionStart"in r&&Lf(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),oo&&Ro(oo,r)||(oo=r,r=Ol(hc,"onSelect"),0Rr||(n.current=kc[Rr],kc[Rr]=null,Rr--)}function j(n,e){Rr++,kc[Rr]=n.current,n.current=e}var Dn={},Oe=bn(Dn),Ue=bn(!1),ir=Dn;function ni(n,e){var t=n.type.contextTypes;if(!t)return Dn;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in t)i[o]=e[o];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function He(n){return n=n.childContextTypes,n!=null}function Tl(){q(Ue),q(Oe)}function mp(n,e,t){if(Oe.current!==Dn)throw Error(N(168));j(Oe,e),j(Ue,t)}function M0(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(N(108,kC(n)||"Unknown",i));return X({},t,r)}function Rl(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||Dn,ir=Oe.current,j(Oe,n),j(Ue,Ue.current),!0}function gp(n,e,t){var r=n.stateNode;if(!r)throw Error(N(169));t?(n=M0(n,e,ir),r.__reactInternalMemoizedMergedChildContext=n,q(Ue),q(Oe),j(Oe,n)):q(Ue),j(Ue,t)}var Ut=null,ta=!1,su=!1;function E0(n){Ut===null?Ut=[n]:Ut.push(n)}function LN(n){ta=!0,E0(n)}function In(){if(!su&&Ut!==null){su=!0;var n=0,e=H;try{var t=Ut;for(H=1;n>=s,i-=s,Ht=1<<32-vt(e)+i|t<T?(b=O,O=null):b=O.sibling;var z=d(g,O,S[T],x);if(z===null){O===null&&(O=b);break}n&&O&&z.alternate===null&&e(g,O),y=o(z,y,T),E===null?M=z:E.sibling=z,E=z,O=b}if(T===S.length)return t(g,O),Q&&Jn(g,T),M;if(O===null){for(;TT?(b=O,O=null):b=O.sibling;var se=d(g,O,z.value,x);if(se===null){O===null&&(O=b);break}n&&O&&se.alternate===null&&e(g,O),y=o(se,y,T),E===null?M=se:E.sibling=se,E=se,O=b}if(z.done)return t(g,O),Q&&Jn(g,T),M;if(O===null){for(;!z.done;T++,z=S.next())z=f(g,z.value,x),z!==null&&(y=o(z,y,T),E===null?M=z:E.sibling=z,E=z);return Q&&Jn(g,T),M}for(O=r(g,O);!z.done;T++,z=S.next())z=p(O,g,T,z.value,x),z!==null&&(n&&z.alternate!==null&&O.delete(z.key===null?T:z.key),y=o(z,y,T),E===null?M=z:E.sibling=z,E=z);return n&&O.forEach(function(W){return e(g,W)}),Q&&Jn(g,T),M}function w(g,y,S,x){if(typeof S=="object"&&S!==null&&S.type===Mr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case ps:e:{for(var M=S.key,E=y;E!==null;){if(E.key===M){if(M=S.type,M===Mr){if(E.tag===7){t(g,E.sibling),y=i(E,S.props.children),y.return=g,g=y;break e}}else if(E.elementType===M||typeof M=="object"&&M!==null&&M.$$typeof===rn&&Cp(M)===E.type){t(g,E.sibling),y=i(E,S.props),y.ref=ki(g,E,S),y.return=g,g=y;break e}t(g,E);break}else e(g,E);E=E.sibling}S.type===Mr?(y=tr(S.props.children,g.mode,x,S.key),y.return=g,g=y):(x=ll(S.type,S.key,S.props,null,g.mode,x),x.ref=ki(g,y,S),x.return=g,g=x)}return s(g);case Nr:e:{for(E=S.key;y!==null;){if(y.key===E)if(y.tag===4&&y.stateNode.containerInfo===S.containerInfo&&y.stateNode.implementation===S.implementation){t(g,y.sibling),y=i(y,S.children||[]),y.return=g,g=y;break e}else{t(g,y);break}else e(g,y);y=y.sibling}y=pu(S,g.mode,x),y.return=g,g=y}return s(g);case rn:return E=S._init,w(g,y,E(S._payload),x)}if(Ki(S))return h(g,y,S,x);if(mi(S))return m(g,y,S,x);Ms(g,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,y!==null&&y.tag===6?(t(g,y.sibling),y=i(y,S),y.return=g,g=y):(t(g,y),y=hu(S,g.mode,x),y.return=g,g=y),s(g)):t(g,y)}return w}var ii=z0(!0),P0=z0(!1),es={},bt=bn(es),zo=bn(es),Po=bn(es);function Qn(n){if(n===es)throw Error(N(174));return n}function jf(n,e){switch(j(Po,e),j(zo,n),j(bt,es),n=e.nodeType,n){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:rc(null,"");break;default:n=n===8?e.parentNode:e,e=n.namespaceURI||null,n=n.tagName,e=rc(e,n)}q(bt),j(bt,e)}function oi(){q(bt),q(zo),q(Po)}function F0(n){Qn(Po.current);var e=Qn(bt.current),t=rc(e,n.type);e!==t&&(j(zo,n),j(bt,t))}function Kf(n){zo.current===n&&(q(bt),q(zo))}var Y=bn(0);function Fl(n){for(var e=n;e!==null;){if(e.tag===13){var t=e.memoizedState;if(t!==null&&(t=t.dehydrated,t===null||t.data==="$?"||t.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break;for(;e.sibling===null;){if(e.return===null||e.return===n)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var lu=[];function qf(){for(var n=0;nt?t:4,n(!0);var r=au.transition;au.transition={};try{n(!1),e()}finally{H=t,au.transition=r}}function X0(){return pt().memoizedState}function JN(n,e,t){var r=Nn(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Z0(n))e1(e,t);else if(t=R0(n,e,t,r),t!==null){var i=Ae();xt(t,n,r,i),t1(t,e,r)}}function _N(n,e,t){var r=Nn(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Z0(n))e1(e,i);else{var o=n.alternate;if(n.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var s=e.lastRenderedState,l=o(s,t);if(i.hasEagerState=!0,i.eagerState=l,Nt(l,s)){var a=e.interleaved;a===null?(i.next=i,Uf(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}t=R0(n,e,i,r),t!==null&&(i=Ae(),xt(t,n,r,i),t1(t,e,r))}}function Z0(n){var e=n.alternate;return n===G||e!==null&&e===G}function e1(n,e){so=Ll=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function t1(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,Rf(n,t)}}var $l={readContext:ht,useCallback:ve,useContext:ve,useEffect:ve,useImperativeHandle:ve,useInsertionEffect:ve,useLayoutEffect:ve,useMemo:ve,useReducer:ve,useRef:ve,useState:ve,useDebugValue:ve,useDeferredValue:ve,useTransition:ve,useMutableSource:ve,useSyncExternalStore:ve,useId:ve,unstable_isNewReconciler:!1},WN={readContext:ht,useCallback:function(n,e){return Et().memoizedState=[n,e===void 0?null:e],n},useContext:ht,useEffect:Mp,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,rl(4194308,4,K0.bind(null,e,n),t)},useLayoutEffect:function(n,e){return rl(4194308,4,n,e)},useInsertionEffect:function(n,e){return rl(4,2,n,e)},useMemo:function(n,e){var t=Et();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=Et();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=JN.bind(null,G,n),[r.memoizedState,n]},useRef:function(n){var e=Et();return n={current:n},e.memoizedState=n},useState:Np,useDebugValue:Zf,useDeferredValue:function(n){return Et().memoizedState=n},useTransition:function(){var n=Np(!1),e=n[0];return n=VN.bind(null,n[1]),Et().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=G,i=Et();if(Q){if(t===void 0)throw Error(N(407));t=t()}else{if(t=e(),de===null)throw Error(N(349));sr&30||B0(r,e,t)}i.memoizedState=t;var o={value:t,getSnapshot:e};return i.queue=o,Mp(J0.bind(null,r,o,n),[n]),r.flags|=2048,$o(9,V0.bind(null,r,o,t,e),void 0,null),t},useId:function(){var n=Et(),e=de.identifierPrefix;if(Q){var t=jt,r=Ht;t=(r&~(1<<32-vt(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=Fo++,0<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=s.createElement(t,{is:r.is}):(n=s.createElement(t),t==="select"&&(s=n,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):n=s.createElementNS(n,t),n[Ot]=e,n[Io]=r,c1(n,e,!1,!1),e.stateNode=n;e:{switch(s=oc(t,r),t){case"dialog":K("cancel",n),K("close",n),i=r;break;case"iframe":case"object":case"embed":K("load",n),i=r;break;case"video":case"audio":for(i=0;ili&&(e.flags|=128,r=!0,vi(o,!1),e.lanes=4194304)}else{if(!r)if(n=Fl(s),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),vi(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return xe(e),null}else 2*ne()-o.renderingStartTime>li&&t!==1073741824&&(e.flags|=128,r=!0,vi(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(t=o.last,t!==null?t.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=ne(),e.sibling=null,t=Y.current,j(Y,r?t&1|2:t&1),e):(xe(e),null);case 22:case 23:return od(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ge&1073741824&&(xe(e),e.subtreeFlags&6&&(e.flags|=8192)):xe(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function GN(n,e){switch(Bf(e),e.tag){case 1:return He(e.type)&&Tl(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return oi(),q(Ue),q(Oe),qf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Kf(e),null;case 13:if(q(Y),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(N(340));ri()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return q(Y),null;case 4:return oi(),null;case 10:return Wf(e.type._context),null;case 22:case 23:return od(),null;case 24:return null;default:return null}}var Os=!1,Ne=!1,XN=typeof WeakSet=="function"?WeakSet:Set,D=null;function zr(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){Z(n,e,r)}else t.current=null}function bc(n,e,t){try{t()}catch(r){Z(n,e,r)}}var zp=!1;function ZN(n,e){if(mc=Ml,n=g0(),Lf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{t.nodeType,o.nodeType}catch{t=null;break e}var s=0,l=-1,a=-1,u=0,c=0,f=n,d=null;t:for(;;){for(var p;f!==t||i!==0&&f.nodeType!==3||(l=s+i),f!==o||r!==0&&f.nodeType!==3||(a=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===n)break t;if(d===t&&++u===i&&(l=s),d===o&&++c===r&&(a=s),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}t=l===-1||a===-1?null:{start:l,end:a}}else t=null}t=t||{start:0,end:0}}else t=null;for(gc={focusedElem:n,selectionRange:t},Ml=!1,D=e;D!==null;)if(e=D,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,D=n;else for(;D!==null;){e=D;try{var h=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var m=h.memoizedProps,w=h.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:yt(e.type,m),w);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(x){Z(e,e.return,x)}if(n=e.sibling,n!==null){n.return=e.return,D=n;break}D=e.return}return h=zp,zp=!1,h}function lo(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var o=i.destroy;i.destroy=void 0,o!==void 0&&bc(e,t,o)}i=i.next}while(i!==r)}}function ia(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function Ic(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function h1(n){var e=n.alternate;e!==null&&(n.alternate=null,h1(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Ot],delete e[Io],delete e[wc],delete e[PN],delete e[FN])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function p1(n){return n.tag===5||n.tag===3||n.tag===4}function Pp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||p1(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function zc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Dl));else if(r!==4&&(n=n.child,n!==null))for(zc(n,e,t),n=n.sibling;n!==null;)zc(n,e,t),n=n.sibling}function Pc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(Pc(n,e,t),n=n.sibling;n!==null;)Pc(n,e,t),n=n.sibling}var pe=null,St=!1;function en(n,e,t){for(t=t.child;t!==null;)m1(n,e,t),t=t.sibling}function m1(n,e,t){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Yl,t)}catch{}switch(t.tag){case 5:Ne||zr(t,e);case 6:var r=pe,i=St;pe=null,en(n,e,t),pe=r,St=i,pe!==null&&(St?(n=pe,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):pe.removeChild(t.stateNode));break;case 18:pe!==null&&(St?(n=pe,t=t.stateNode,n.nodeType===8?ou(n.parentNode,t):n.nodeType===1&&ou(n,t),Do(n)):ou(pe,t.stateNode));break;case 4:r=pe,i=St,pe=t.stateNode.containerInfo,St=!0,en(n,e,t),pe=r,St=i;break;case 0:case 11:case 14:case 15:if(!Ne&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&bc(t,e,s),i=i.next}while(i!==r)}en(n,e,t);break;case 1:if(!Ne&&(zr(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(l){Z(t,e,l)}en(n,e,t);break;case 21:en(n,e,t);break;case 22:t.mode&1?(Ne=(r=Ne)||t.memoizedState!==null,en(n,e,t),Ne=r):en(n,e,t);break;default:en(n,e,t)}}function Fp(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new XN),e.forEach(function(r){var i=aM.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function gt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=ne()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tM(r/1960))-r,10n?16:n,mn===null)var r=!1;else{if(n=mn,mn=null,Jl=0,V&6)throw Error(N(331));var i=V;for(V|=4,D=n.current;D!==null;){var o=D,s=o.child;if(D.flags&16){var l=o.deletions;if(l!==null){for(var a=0;ane()-rd?er(n,0):nd|=t),je(n,e)}function C1(n,e){e===0&&(n.mode&1?(e=Ss,Ss<<=1,!(Ss&130023424)&&(Ss=4194304)):e=1);var t=Ae();n=Gt(n,e),n!==null&&(Go(n,e,t),je(n,t))}function lM(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),C1(n,t)}function aM(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(N(314))}r!==null&&r.delete(e),C1(n,t)}var N1;N1=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ue.current)_e=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return _e=!1,QN(n,e,t);_e=!!(n.flags&131072)}else _e=!1,Q&&e.flags&1048576&&O0(e,bl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;il(n,e),n=e.pendingProps;var i=ni(e,Oe.current);Wr(e,t),i=Yf(null,e,r,n,i,t);var o=Gf();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,He(r)?(o=!0,Rl(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Hf(e),i.updater=na,e.stateNode=i,i._reactInternals=e,Mc(e,r,n,t),e=Dc(null,e,r,!0,o,t)):(e.tag=0,Q&&o&&$f(e),Te(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(il(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=cM(r),n=yt(r,n),i){case 0:e=Oc(null,e,r,n,t);break e;case 1:e=Ap(null,e,r,n,t);break e;case 11:e=Tp(null,e,r,n,t);break e;case 14:e=Rp(null,e,r,yt(r.type,n),t);break e}throw Error(N(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Oc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Ap(n,e,r,i,t);case 3:e:{if(l1(e),n===null)throw Error(N(387));r=e.pendingProps,o=e.memoizedState,i=o.element,A0(n,e),Pl(e,r,null,t);var s=e.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=si(Error(N(423)),e),e=bp(n,e,r,t,i);break e}else if(r!==i){i=si(Error(N(424)),e),e=bp(n,e,r,t,i);break e}else for(Ze=vn(e.stateNode.containerInfo.firstChild),tt=e,Q=!0,kt=null,t=P0(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(ri(),r===i){e=Xt(n,e,t);break e}Te(n,e,r,t)}e=e.child}return e;case 5:return F0(e),n===null&&xc(e),r=e.type,i=e.pendingProps,o=n!==null?n.memoizedProps:null,s=i.children,yc(r,i)?s=null:o!==null&&yc(r,o)&&(e.flags|=32),s1(n,e),Te(n,e,s,t),e.child;case 6:return n===null&&xc(e),null;case 13:return a1(n,e,t);case 4:return jf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=ii(e,null,r,t):Te(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Tp(n,e,r,i,t);case 7:return Te(n,e,e.pendingProps,t),e.child;case 8:return Te(n,e,e.pendingProps.children,t),e.child;case 12:return Te(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,j(Il,r._currentValue),r._currentValue=s,o!==null)if(Nt(o.value,s)){if(o.children===i.children&&!Ue.current){e=Xt(n,e,t);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=qt(-1,t&-t),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Cc(o.return,t,e),l.lanes|=t;break}a=a.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(N(341));s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),Cc(s,t,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Te(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Wr(e,t),i=ht(i),r=r(i),e.flags|=1,Te(n,e,r,t),e.child;case 14:return r=e.type,i=yt(r,e.pendingProps),i=yt(r.type,i),Rp(n,e,r,i,t);case 15:return i1(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),il(n,e),e.tag=1,He(r)?(n=!0,Rl(e)):n=!1,Wr(e,t),I0(e,r,i),Mc(e,r,i,t),Dc(null,e,r,!0,n,t);case 19:return u1(n,e,t);case 22:return o1(n,e,t)}throw Error(N(156,e.tag))};function M1(n,e){return Gy(n,e)}function uM(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ct(n,e,t,r){return new uM(n,e,t,r)}function ld(n){return n=n.prototype,!(!n||!n.isReactComponent)}function cM(n){if(typeof n=="function")return ld(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Ef)return 11;if(n===Of)return 14}return 2}function Mn(n,e){var t=n.alternate;return t===null?(t=ct(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function ll(n,e,t,r,i,o){var s=2;if(r=n,typeof n=="function")ld(n)&&(s=1);else if(typeof n=="string")s=5;else e:switch(n){case Mr:return tr(t.children,i,o,e);case Mf:s=8,i|=8;break;case Qu:return n=ct(12,t,e,i|2),n.elementType=Qu,n.lanes=o,n;case Yu:return n=ct(13,t,e,i),n.elementType=Yu,n.lanes=o,n;case Gu:return n=ct(19,t,e,i),n.elementType=Gu,n.lanes=o,n;case zy:return sa(t,i,o,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case by:s=10;break e;case Iy:s=9;break e;case Ef:s=11;break e;case Of:s=14;break e;case rn:s=16,r=null;break e}throw Error(N(130,n==null?n:typeof n,""))}return e=ct(s,t,e,i),e.elementType=n,e.type=r,e.lanes=o,e}function tr(n,e,t,r){return n=ct(7,n,r,e),n.lanes=t,n}function sa(n,e,t,r){return n=ct(22,n,r,e),n.elementType=zy,n.lanes=t,n.stateNode={isHidden:!1},n}function hu(n,e,t){return n=ct(6,n,null,e),n.lanes=t,n}function pu(n,e,t){return e=ct(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function fM(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qa(0),this.expirationTimes=qa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qa(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ad(n,e,t,r,i,o,s,l,a){return n=new fM(n,e,t,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ct(3,null,null,e),n.current=o,o.stateNode=n,o.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hf(o),n}function dM(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(T1)}catch(n){console.error(n)}}T1(),Oy.exports=rt;var ai=Oy.exports,R1,Up=ai;R1=Up.createRoot,Up.hydrateRoot;const ts=C.createContext(null),A1=C.createContext(null);function yM(n){const 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(const 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"),[ye.node(0,n.state.doc.content.size,e)]}const SM=[],wM={},Vc=_.empty;class Un{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,wM));return Un.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let i=0;it instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t0;)e++;n.splice(e,0,t)}function vM(n,e){const t=[];return n.someProp("decorations",r=>{const i=r(n.state);i&&i!=Vc&&t.push(i)}),e&&t.push(_.create(n.state.doc,[e])),Un.from(t)}const dd=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},jp=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},xM=function(n,e,t,r){return t&&(Kp(n,e,t,r,-1)||Kp(n,e,t,r,1))},CM=/^(img|br|input|textarea|hr)$/i;function Kp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ul(n))){const o=n.parentNode;if(!o||o.nodeType!=1||MM(n)||CM.test(n.nodeName)||n.contentEditable=="false")return!1;e=dd(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Ul(n):0}else return!1}}function Ul(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function NM(n,e,t){for(let r=e==0,i=e==Ul(n);r||i;){if(n==t)return!0;const o=dd(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Ul(n)}return!1}function MM(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 I1=function(n){return n.focusNode&&xM(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},z1=C.createContext(null);function EM(n,e){const t=C.useContext(z1);C.useLayoutEffect(()=>t(n),e)}function P1(n,e){const{view:t}=C.useContext(ts);EM(()=>{if(t)return n(t)},e&&[t,...e])}const OM=C.forwardRef(function({widget:e,pos:t,...r},i){const[o,s]=C.useState(!0),l=C.useRef(null);return C.useImperativeHandle(i,()=>l.current,[]),P1(a=>{if(!a||!l.current)return;a.domObserver.disconnectSelection();const u=a.domSelection(),c=document.createRange(),f=l.current;f.nodeName=="IMG"&&f.parentNode?c.setEnd(f.parentNode,dd(f)+1):c.setEnd(f,0),c.collapse(!1),u.removeAllRanges(),u.addRange(c),s(!1),a.domObserver.connectSelection()},[]),o?A.jsx("img",{ref:l,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...r}):null});function DM(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const TM={side:0};class Vo{constructor(e,t){this.Component=e,this.spec=t??TM,this.side=this.spec.side??0}map(e,t,r,i){const{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new ye(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Vo&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&DM(this.spec,e.spec))}destroy(){}}function F1(n,e,t){return new ye(n,n,new Vo(e,t))}function mu(){return Math.floor(Math.random()*16777215).toString(16)}const Jo=new jo("@nytimes/react-prosemirror/reactKeys");function RM(){let n=!1;return new $t({key:Jo,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((i,o)=>{const s=mu();return r.posToKey.set(o,s),r.keyToPos.set(s,o),!0}),r},apply(e,t,r,i){if(!e.docChanged||n)return t;const o=e.getMeta(Jo),s=(o==null?void 0:o.type)==="bustKey"&&o.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort(([u],[c])=>u-c);for(const[u,c]of a){const{pos:f,deleted:d}=e.mapping.mapResult(u);if(d)continue;let p=c;s===c&&(p=mu()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return i.doc.descendants((u,c)=>{if(l.posToKey.has(c))return!0;const f=mu();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function gu(n,e,t={}){var s;if(e===null)return!1;const r=t.from??n.state.selection.from,i=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,i,e)))return!0;const{tr:o}=n.state;if(t.marks&&o.ensureMarks(t.marks),o.insertText(e,r,i),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(i),u=l.start(a),c=(s=Jo.getState(n.state))==null?void 0:s.posToKey.get(u-1);o.setMeta(Jo,{type:"bustKey",payload:{key:c}})}return n.dispatch(o),!0}function AM(n){let e=null,t=null;return new $t({props:{handleDOMEvents:{compositionstart(r){var s;const{state:i}=r;r.dispatch(i.tr.deleteSelection());const o=i.selection.$from;return i.selection.empty&&(i.storedMarks||!o.textOffset&&o.parentOffset&&((s=o.nodeBefore)!=null&&s.marks.some(l=>l.type.spec.inclusive===!1)))&&n(F1(i.selection.from,OM,{key:"cursor-wrapper",marks:i.storedMarks??o.marks()})),t=i.storedMarks??o.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return gu(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,i){var o,s;switch(i.preventDefault(),i.inputType){case"insertCompositionText":{if(i.data===null)break;e=i.data;break}case"insertReplacementText":{const l=i.getTargetRanges();(s=(o=i.dataTransfer)==null?void 0:o.items[0])==null||s.getAsString(a=>{for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset,1),f=r.posAtDOM(u.endContainer,u.endOffset,1);gu(r,a,{from:c,to:f})}});break}case"insertText":{gu(r,i.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=i.getTargetRanges(),{tr:a}=r.state;for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset),f=r.posAtDOM(u.endContainer,u.endOffset),{doc:d}=r.state,p=d.resolve(c).marksAcross(d.resolve(f));a.delete(c,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Lt=typeof navigator<"u"?navigator:null,qp=typeof document<"u"?document:null,zn=Lt&&Lt.userAgent||"",Jc=/Edge\/(\d+)/.exec(zn),L1=/MSIE \d/.exec(zn),_c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zn),fa=!!(L1||_c||Jc),bM=L1?document.documentMode:_c?+_c[1]:Jc?+Jc[1]:0,$1=!fa&&/gecko\/(\d+)/i.test(zn),IM=$1&&+(/Firefox\/(\d+)/.exec(zn)||[0,0])[1],Wc=!fa&&/Chrome\/(\d+)/.exec(zn),zM=!!Wc,PM=Wc?+Wc[1]:0,B1=!fa&&!!Lt&&/Apple Computer/.test(Lt.vendor),V1=B1&&(/Mobile\/\w+/.test(zn)||!!Lt&&Lt.maxTouchPoints>2),FM=V1||(Lt?/Mac/.test(Lt.platform):!1),LM=Lt?/Win/.test(Lt.platform):!1,$M=/Android \d/.test(zn),J1=!!qp&&"webkitFontSmoothing"in qp.documentElement.style,BM=J1?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Ee={ie:fa,ie_version:bM,gecko:$1,gecko_version:IM,chrome:zM,chrome_version:PM,safari:B1,ios:V1,mac:FM,windows:LM,android:$M,webkit:J1,webkit_version:BM};function yu(n){return n.editable&&!n.hasFocus()?!1:VM(n)}function VM(n){var t,r;const 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(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function JM(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function Qp(n,e=null){const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode);const o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;const l=r.resolve(s);let a,u;if(I1(t)){for(a=l;i&&!i.node;)i=i.parent;const c=i.node;if(i&&c.isAtom&&I.isSelectable(c)&&i.parent&&!(c.isInline&&NM(t.focusNode,t.focusOffset,i.dom))){const f=i.posBefore;u=new I(s==f?l:r.resolve(f))}}else{const c=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){const c=e=="pointer"||n.state.selection.head{(r.anchorNode!=i||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!_1(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const tm=Ee.safari||Ee.chrome&&Ee.chrome_version<63;function Rs(n,e=!1){const t=n,r=t.state.selection;if(UM(t,r),!!_1(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ee.chrome){const i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Hl(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)jM(t);else{const{anchor:i,head:o}=r;let s,l;tm&&!(r instanceof $)&&(r.$from.parent.inlineContent||(s=Zp(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=Zp(t,r.to))),t.docView.setSelection(i,o,t.root,e),tm&&(s&&em(s),l&&em(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&KM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}class qM{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 QM{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new qM,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let o=e.focusNode;o;o=jp(o))t.add(o);for(let o=e.anchorNode;o;o=jp(o))if(t.has(o)){r=o;break}const i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=Qp(e,r);if(i&&!e.state.selection.eq(i)){const o=e.state.tr.setSelection(i);r=="pointer"?o.setMeta("pointer",!0):r=="key"&&o.scrollIntoView(),t&&o.setMeta("composition",t),e.dispatch(o)}}selectionToDOM(){const{view:e}=this;Rs(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&yu(e)&&!this.ignoreSelectionChange(t);let i=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(yu(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Rs(this.view);if(Ee.ie&&Ee.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Hl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const ui=0,nm=1,As=2,_o=3;class ns{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ui,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;tsn(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 o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){const o=this.getDesc(i);let s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){const 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){const o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof md){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof hd&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?sn(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=sn(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;ch&&s<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=s.createElement(t,{is:r.is}):(n=s.createElement(t),t==="select"&&(s=n,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):n=s.createElementNS(n,t),n[Ot]=e,n[Io]=r,c1(n,e,!1,!1),e.stateNode=n;e:{switch(s=oc(t,r),t){case"dialog":K("cancel",n),K("close",n),i=r;break;case"iframe":case"object":case"embed":K("load",n),i=r;break;case"video":case"audio":for(i=0;ili&&(e.flags|=128,r=!0,vi(o,!1),e.lanes=4194304)}else{if(!r)if(n=Fl(s),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),vi(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return xe(e),null}else 2*ne()-o.renderingStartTime>li&&t!==1073741824&&(e.flags|=128,r=!0,vi(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(t=o.last,t!==null?t.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=ne(),e.sibling=null,t=Y.current,j(Y,r?t&1|2:t&1),e):(xe(e),null);case 22:case 23:return od(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ge&1073741824&&(xe(e),e.subtreeFlags&6&&(e.flags|=8192)):xe(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function GN(n,e){switch(Bf(e),e.tag){case 1:return He(e.type)&&Tl(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return oi(),q(Ue),q(Oe),qf(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return Kf(e),null;case 13:if(q(Y),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(N(340));ri()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return q(Y),null;case 4:return oi(),null;case 10:return Wf(e.type._context),null;case 22:case 23:return od(),null;case 24:return null;default:return null}}var Os=!1,Ne=!1,XN=typeof WeakSet=="function"?WeakSet:Set,D=null;function zr(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){Z(n,e,r)}else t.current=null}function bc(n,e,t){try{t()}catch(r){Z(n,e,r)}}var zp=!1;function ZN(n,e){if(mc=Ml,n=g0(),Lf(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{t.nodeType,o.nodeType}catch{t=null;break e}var s=0,l=-1,a=-1,u=0,c=0,f=n,d=null;t:for(;;){for(var p;f!==t||i!==0&&f.nodeType!==3||(l=s+i),f!==o||r!==0&&f.nodeType!==3||(a=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===n)break t;if(d===t&&++u===i&&(l=s),d===o&&++c===r&&(a=s),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}t=l===-1||a===-1?null:{start:l,end:a}}else t=null}t=t||{start:0,end:0}}else t=null;for(gc={focusedElem:n,selectionRange:t},Ml=!1,D=e;D!==null;)if(e=D,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,D=n;else for(;D!==null;){e=D;try{var h=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var m=h.memoizedProps,w=h.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:yt(e.type,m),w);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(x){Z(e,e.return,x)}if(n=e.sibling,n!==null){n.return=e.return,D=n;break}D=e.return}return h=zp,zp=!1,h}function lo(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var o=i.destroy;i.destroy=void 0,o!==void 0&&bc(e,t,o)}i=i.next}while(i!==r)}}function ia(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function Ic(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function h1(n){var e=n.alternate;e!==null&&(n.alternate=null,h1(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Ot],delete e[Io],delete e[wc],delete e[PN],delete e[FN])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function p1(n){return n.tag===5||n.tag===3||n.tag===4}function Pp(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||p1(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function zc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=Dl));else if(r!==4&&(n=n.child,n!==null))for(zc(n,e,t),n=n.sibling;n!==null;)zc(n,e,t),n=n.sibling}function Pc(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(Pc(n,e,t),n=n.sibling;n!==null;)Pc(n,e,t),n=n.sibling}var pe=null,St=!1;function en(n,e,t){for(t=t.child;t!==null;)m1(n,e,t),t=t.sibling}function m1(n,e,t){if(At&&typeof At.onCommitFiberUnmount=="function")try{At.onCommitFiberUnmount(Yl,t)}catch{}switch(t.tag){case 5:Ne||zr(t,e);case 6:var r=pe,i=St;pe=null,en(n,e,t),pe=r,St=i,pe!==null&&(St?(n=pe,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):pe.removeChild(t.stateNode));break;case 18:pe!==null&&(St?(n=pe,t=t.stateNode,n.nodeType===8?ou(n.parentNode,t):n.nodeType===1&&ou(n,t),Do(n)):ou(pe,t.stateNode));break;case 4:r=pe,i=St,pe=t.stateNode.containerInfo,St=!0,en(n,e,t),pe=r,St=i;break;case 0:case 11:case 14:case 15:if(!Ne&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&bc(t,e,s),i=i.next}while(i!==r)}en(n,e,t);break;case 1:if(!Ne&&(zr(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(l){Z(t,e,l)}en(n,e,t);break;case 21:en(n,e,t);break;case 22:t.mode&1?(Ne=(r=Ne)||t.memoizedState!==null,en(n,e,t),Ne=r):en(n,e,t);break;default:en(n,e,t)}}function Fp(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new XN),e.forEach(function(r){var i=aM.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function gt(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=ne()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*tM(r/1960))-r,10n?16:n,mn===null)var r=!1;else{if(n=mn,mn=null,Jl=0,V&6)throw Error(N(331));var i=V;for(V|=4,D=n.current;D!==null;){var o=D,s=o.child;if(D.flags&16){var l=o.deletions;if(l!==null){for(var a=0;ane()-rd?er(n,0):nd|=t),je(n,e)}function C1(n,e){e===0&&(n.mode&1?(e=Ss,Ss<<=1,!(Ss&130023424)&&(Ss=4194304)):e=1);var t=Ae();n=Gt(n,e),n!==null&&(Go(n,e,t),je(n,t))}function lM(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),C1(n,t)}function aM(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(N(314))}r!==null&&r.delete(e),C1(n,t)}var N1;N1=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||Ue.current)_e=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return _e=!1,QN(n,e,t);_e=!!(n.flags&131072)}else _e=!1,Q&&e.flags&1048576&&O0(e,bl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;il(n,e),n=e.pendingProps;var i=ni(e,Oe.current);Wr(e,t),i=Yf(null,e,r,n,i,t);var o=Gf();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,He(r)?(o=!0,Rl(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Hf(e),i.updater=na,e.stateNode=i,i._reactInternals=e,Mc(e,r,n,t),e=Dc(null,e,r,!0,o,t)):(e.tag=0,Q&&o&&$f(e),Te(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(il(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=cM(r),n=yt(r,n),i){case 0:e=Oc(null,e,r,n,t);break e;case 1:e=Ap(null,e,r,n,t);break e;case 11:e=Tp(null,e,r,n,t);break e;case 14:e=Rp(null,e,r,yt(r.type,n),t);break e}throw Error(N(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Oc(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Ap(n,e,r,i,t);case 3:e:{if(l1(e),n===null)throw Error(N(387));r=e.pendingProps,o=e.memoizedState,i=o.element,A0(n,e),Pl(e,r,null,t);var s=e.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=si(Error(N(423)),e),e=bp(n,e,r,t,i);break e}else if(r!==i){i=si(Error(N(424)),e),e=bp(n,e,r,t,i);break e}else for(Ze=vn(e.stateNode.containerInfo.firstChild),tt=e,Q=!0,kt=null,t=P0(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(ri(),r===i){e=Xt(n,e,t);break e}Te(n,e,r,t)}e=e.child}return e;case 5:return F0(e),n===null&&xc(e),r=e.type,i=e.pendingProps,o=n!==null?n.memoizedProps:null,s=i.children,yc(r,i)?s=null:o!==null&&yc(r,o)&&(e.flags|=32),s1(n,e),Te(n,e,s,t),e.child;case 6:return n===null&&xc(e),null;case 13:return a1(n,e,t);case 4:return jf(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=ii(e,null,r,t):Te(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),Tp(n,e,r,i,t);case 7:return Te(n,e,e.pendingProps,t),e.child;case 8:return Te(n,e,e.pendingProps.children,t),e.child;case 12:return Te(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,j(Il,r._currentValue),r._currentValue=s,o!==null)if(Nt(o.value,s)){if(o.children===i.children&&!Ue.current){e=Xt(n,e,t);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=qt(-1,t&-t),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=t,a=o.alternate,a!==null&&(a.lanes|=t),Cc(o.return,t,e),l.lanes|=t;break}a=a.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(N(341));s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),Cc(s,t,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Te(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Wr(e,t),i=ht(i),r=r(i),e.flags|=1,Te(n,e,r,t),e.child;case 14:return r=e.type,i=yt(r,e.pendingProps),i=yt(r.type,i),Rp(n,e,r,i,t);case 15:return i1(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:yt(r,i),il(n,e),e.tag=1,He(r)?(n=!0,Rl(e)):n=!1,Wr(e,t),I0(e,r,i),Mc(e,r,i,t),Dc(null,e,r,!0,n,t);case 19:return u1(n,e,t);case 22:return o1(n,e,t)}throw Error(N(156,e.tag))};function M1(n,e){return Gy(n,e)}function uM(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ct(n,e,t,r){return new uM(n,e,t,r)}function ld(n){return n=n.prototype,!(!n||!n.isReactComponent)}function cM(n){if(typeof n=="function")return ld(n)?1:0;if(n!=null){if(n=n.$$typeof,n===Ef)return 11;if(n===Of)return 14}return 2}function Mn(n,e){var t=n.alternate;return t===null?(t=ct(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function ll(n,e,t,r,i,o){var s=2;if(r=n,typeof n=="function")ld(n)&&(s=1);else if(typeof n=="string")s=5;else e:switch(n){case Mr:return tr(t.children,i,o,e);case Mf:s=8,i|=8;break;case Qu:return n=ct(12,t,e,i|2),n.elementType=Qu,n.lanes=o,n;case Yu:return n=ct(13,t,e,i),n.elementType=Yu,n.lanes=o,n;case Gu:return n=ct(19,t,e,i),n.elementType=Gu,n.lanes=o,n;case zy:return sa(t,i,o,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case by:s=10;break e;case Iy:s=9;break e;case Ef:s=11;break e;case Of:s=14;break e;case rn:s=16,r=null;break e}throw Error(N(130,n==null?n:typeof n,""))}return e=ct(s,t,e,i),e.elementType=n,e.type=r,e.lanes=o,e}function tr(n,e,t,r){return n=ct(7,n,r,e),n.lanes=t,n}function sa(n,e,t,r){return n=ct(22,n,r,e),n.elementType=zy,n.lanes=t,n.stateNode={isHidden:!1},n}function hu(n,e,t){return n=ct(6,n,null,e),n.lanes=t,n}function pu(n,e,t){return e=ct(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function fM(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qa(0),this.expirationTimes=qa(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qa(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ad(n,e,t,r,i,o,s,l,a){return n=new fM(n,e,t,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=ct(3,null,null,e),n.current=o,o.stateNode=n,o.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hf(o),n}function dM(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(T1)}catch(n){console.error(n)}}T1(),Oy.exports=rt;var ai=Oy.exports,R1,Up=ai;R1=Up.createRoot,Up.hydrateRoot;const ts=C.createContext(null),A1=C.createContext(null);function yM(n){const 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(const 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"),[ye.node(0,n.state.doc.content.size,e)]}const SM=[],wM={},Vc=_.empty;class Un{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,wM));return Un.from(r)}forChild(e,t){if(t.isLeaf)return _.empty;let r=[];for(let i=0;it instanceof _)?e:e.reduce((t,r)=>t.concat(r instanceof _?r:r.members),[]))}}forEachSet(e){for(let t=0;t0;)e++;n.splice(e,0,t)}function vM(n,e){const t=[];return n.someProp("decorations",r=>{const i=r(n.state);i&&i!=Vc&&t.push(i)}),e&&t.push(_.create(n.state.doc,[e])),Un.from(t)}const dd=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},jp=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},xM=function(n,e,t,r){return t&&(Kp(n,e,t,r,-1)||Kp(n,e,t,r,1))},CM=/^(img|br|input|textarea|hr)$/i;function Kp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Ul(n))){const o=n.parentNode;if(!o||o.nodeType!=1||MM(n)||CM.test(n.nodeName)||n.contentEditable=="false")return!1;e=dd(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Ul(n):0}else return!1}}function Ul(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function NM(n,e,t){for(let r=e==0,i=e==Ul(n);r||i;){if(n==t)return!0;const o=dd(n);if(n=n.parentNode,!n)return!1;r=r&&o==0,i=i&&o==Ul(n)}return!1}function MM(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 I1=function(n){return n.focusNode&&xM(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},z1=C.createContext(null);function EM(n,e){const t=C.useContext(z1);C.useLayoutEffect(()=>t(n),e)}function P1(n,e){const{view:t}=C.useContext(ts);EM(()=>{if(t)return n(t)},e&&[t,...e])}const OM=C.forwardRef(function({widget:e,pos:t,...r},i){const[o,s]=C.useState(!0),l=C.useRef(null);return C.useImperativeHandle(i,()=>l.current,[]),P1(a=>{if(!a||!l.current)return;a.domObserver.disconnectSelection();const u=a.domSelection(),c=document.createRange(),f=l.current;f.nodeName=="IMG"&&f.parentNode?c.setEnd(f.parentNode,dd(f)+1):c.setEnd(f,0),c.collapse(!1),u.removeAllRanges(),u.addRange(c),s(!1),a.domObserver.connectSelection()},[]),o?A.jsx("img",{ref:l,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...r}):null});function DM(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const TM={side:0};class Vo{constructor(e,t){this.Component=e,this.spec=t??TM,this.side=this.spec.side??0}map(e,t,r,i){const{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new ye(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Vo&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&DM(this.spec,e.spec))}destroy(){}}function F1(n,e,t){return new ye(n,n,new Vo(e,t))}function mu(){return Math.floor(Math.random()*16777215).toString(16)}const Jo=new jo("@nytimes/react-prosemirror/reactKeys");function RM(){let n=!1;return new $t({key:Jo,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((i,o)=>{const s=mu();return r.posToKey.set(o,s),r.keyToPos.set(s,o),!0}),r},apply(e,t,r,i){if(!e.docChanged||n)return t;const o=e.getMeta(Jo),s=(o==null?void 0:o.type)==="bustKey"&&o.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort(([u],[c])=>u-c);for(const[u,c]of a){const{pos:f,deleted:d}=e.mapping.mapResult(u);if(d)continue;let p=c;s===c&&(p=mu()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return i.doc.descendants((u,c)=>{if(l.posToKey.has(c))return!0;const f=mu();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function gu(n,e,t={}){var s;if(e===null)return!1;const r=t.from??n.state.selection.from,i=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,i,e)))return!0;const{tr:o}=n.state;if(t.marks&&o.ensureMarks(t.marks),o.insertText(e,r,i),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(i),u=l.start(a),c=(s=Jo.getState(n.state))==null?void 0:s.posToKey.get(u-1);o.setMeta(Jo,{type:"bustKey",payload:{key:c}})}return n.dispatch(o),!0}function AM(n){let e=null,t=null;return new $t({props:{handleDOMEvents:{compositionstart(r){var s;const{state:i}=r;r.dispatch(i.tr.deleteSelection());const o=i.selection.$from;return i.selection.empty&&(i.storedMarks||!o.textOffset&&o.parentOffset&&((s=o.nodeBefore)!=null&&s.marks.some(l=>l.type.spec.inclusive===!1)))&&n(F1(i.selection.from,OM,{key:"cursor-wrapper",marks:i.storedMarks??o.marks()})),t=i.storedMarks??o.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return gu(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,i){var o,s;switch(i.preventDefault(),i.inputType){case"insertCompositionText":{if(i.data===null)break;e=i.data;break}case"insertReplacementText":{const l=i.getTargetRanges();(s=(o=i.dataTransfer)==null?void 0:o.items[0])==null||s.getAsString(a=>{for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset,1),f=r.posAtDOM(u.endContainer,u.endOffset,1);gu(r,a,{from:c,to:f})}});break}case"insertText":{gu(r,i.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=i.getTargetRanges(),{tr:a}=r.state;for(const u of l){const c=r.posAtDOM(u.startContainer,u.startOffset),f=r.posAtDOM(u.endContainer,u.endOffset),{doc:d}=r.state,p=d.resolve(c).marksAcross(d.resolve(f));a.delete(c,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Lt=typeof navigator<"u"?navigator:null,qp=typeof document<"u"?document:null,zn=Lt&&Lt.userAgent||"",Jc=/Edge\/(\d+)/.exec(zn),L1=/MSIE \d/.exec(zn),_c=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(zn),fa=!!(L1||_c||Jc),bM=L1?document.documentMode:_c?+_c[1]:Jc?+Jc[1]:0,$1=!fa&&/gecko\/(\d+)/i.test(zn),IM=$1&&+(/Firefox\/(\d+)/.exec(zn)||[0,0])[1],Wc=!fa&&/Chrome\/(\d+)/.exec(zn),zM=!!Wc,PM=Wc?+Wc[1]:0,B1=!fa&&!!Lt&&/Apple Computer/.test(Lt.vendor),V1=B1&&(/Mobile\/\w+/.test(zn)||!!Lt&&Lt.maxTouchPoints>2),FM=V1||(Lt?/Mac/.test(Lt.platform):!1),LM=Lt?/Win/.test(Lt.platform):!1,$M=/Android \d/.test(zn),J1=!!qp&&"webkitFontSmoothing"in qp.documentElement.style,BM=J1?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Ee={ie:fa,ie_version:bM,gecko:$1,gecko_version:IM,chrome:zM,chrome_version:PM,safari:B1,ios:V1,mac:FM,windows:LM,android:$M,webkit:J1,webkit_version:BM};function yu(n){return n.editable&&!n.hasFocus()?!1:VM(n)}function VM(n){var t,r;const 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(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function JM(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||$.between(e,t,r)}function Qp(n,e=null){const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode);const o=i&&i.size==0;let s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(I1(t)){for(a=s;i&&!i.node;)i=i.parent;const f=i.node;if(i&&f.isAtom&&I.isSelectable(f)&&i.parent&&!(f.isInline&&NM(t.focusNode,t.focusOffset,i.dom))){const d=i.posBefore;u=new I(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let p=0;p{(r.anchorNode!=i||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!_1(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const tm=Ee.safari||Ee.chrome&&Ee.chrome_version<63;function Rs(n,e=!1){const t=n,r=t.state.selection;if(UM(t,r),!!_1(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ee.chrome){const i=t.domSelectionRange(),o=t.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&Hl(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)jM(t);else{const{anchor:i,head:o}=r;let s,l;tm&&!(r instanceof $)&&(r.$from.parent.inlineContent||(s=Zp(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=Zp(t,r.to))),t.docView.setSelection(i,o,t.root,e),tm&&(s&&em(s),l&&em(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&KM(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}class qM{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 QM{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new qM,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let o=e.focusNode;o;o=jp(o))t.add(o);for(let o=e.anchorNode;o;o=jp(o))if(t.has(o)){r=o;break}const i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=Qp(e,r);if(i&&!e.state.selection.eq(i)){const o=e.state.tr.setSelection(i);r=="pointer"?o.setMeta("pointer",!0):r=="key"&&o.scrollIntoView(),t&&o.setMeta("composition",t),e.dispatch(o)}}selectionToDOM(){const{view:e}=this;Rs(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&yu(e)&&!this.ignoreSelectionChange(t);let i=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(yu(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Rs(this.view);if(Ee.ie&&Ee.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Hl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const ui=0,nm=1,As=2,_o=3;class ns{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ui,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;tsn(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 o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){const o=this.getDesc(i);let s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){const 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){const o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof md){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof hd&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?sn(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&t<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,c);e=s;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=sn(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>t||l==this.children.length-1)){t=u;for(let c=l+1;ch&&st){const h=l;l=a,a=h}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}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=r:er){const l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?As:nm,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=_o:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?As:_o}r=s}this.dirty=As}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?As:nm;t.dirtythis.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){const r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>v.empty)}return e}matchesNode(e,t,r){return this.dirty==ui&&e.eq(this.node)&&ZM(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(e,t,r,i){return!0}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}class XM extends pd{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,s,null,l,()=>!1)}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!0}inParent(){const 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"}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=_o)}get domAtom(){return!1}}class md extends ns{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ui&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function ZM(n,e){if(n.length!=e.length)return!1;for(let t=0;t{u=!!a.call(this,s,l)}),u||l.defaultPrevented)return!0}return!1};e[r]=o}return new $t({key:new jo("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function tE(){const[n,e]=C.useState(new Map),t=C.useCallback((o,s)=>{const l=n.get(o)??[];l.unshift(s),n.has(o)||(n.set(o,l),e(new Map(n)))},[n]),r=C.useCallback((o,s)=>{const l=n.get(o);l==null||l.splice(l.indexOf(s),1)},[n]),i=C.useMemo(()=>eE(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:i}}function W1(){const[,n]=C.useReducer(e=>e+1,0);return n}function nE(n){const e=Object.create(null);function t(r){for(const i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function rE(n,e){let t=0,r=0;for(const i in n){if(n[i]!=e[i])return!0;t++}for(const i in e)r++;return t!=r}function iE(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function rm(n){return!n.someProp("editable",e=>e(n.state)===!1)}class oE extends bv{constructor(e,t){super(e,{state:cn.create({schema:t.state.schema,plugins:t.state.plugins}),plugins:t.plugins}),this.shouldUpdatePluginViews=!1,this.shouldUpdatePluginViews=!0,this._props=t,this.oldProps={state:t.state},this.state=t.state,this.domObserver.stop(),this.domObserver=new QM(this),this.domObserver.start(),this.editable=rm(this),this.docView.dom.replaceChildren(),this.docView=t.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const e=nE(this);return rE(this.nodeViews,e)}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state,this.editable=rm(this)}runPendingEffects(){if(iE(this.props,this.oldProps)){const e=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(e)}}update(e){super.update(e),this.oldProps=e}updatePluginViews(e){this.shouldUpdatePluginViews&&super.updatePluginViews(e)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const sE=new Tm({nodes:{doc:{content:"text*"},text:{inline:!0}}}),lE=cn.create({schema:sE});function aE(n,e){const[t,r]=C.useState(null),[i,o]=C.useState(null),s=W1(),l=e.defaultState??lE,[a,u]=C.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=tE(),h=C.useCallback(x=>{ai.flushSync(()=>{o(x)})},[]),m=C.useMemo(()=>[...e.plugins??[],f,AM(h)],[e.plugins,f,h]),w=C.useCallback(function(M){ai.flushSync(()=>{e.state||u(E=>E.apply(M)),e.dispatchTransaction&&e.dispatchTransaction.call(this,M)})},[e.dispatchTransaction,e.state]),g=document.createElement("div"),y=C.useRef(new pd(void 0,[],c.doc,[],_.empty,g,null,g,()=>!1)),S={...e,state:c,plugins:m,dispatchTransaction:w,docView:y.current};return C.useLayoutEffect(()=>()=>{t==null||t.destroy()},[t]),C.useLayoutEffect(()=>{if(t&&t.dom!==n&&r(null),!!n&&!t){const x=new oE({mount:n},S);r(x),x.dom.addEventListener("compositionend",s);return}}),C.useLayoutEffect(()=>{if(t!=null&&t.needsRedraw){r(null);return}else t==null||t.domObserver.selectionToDOM(),t==null||t.runPendingEffects()}),t==null||t.pureSetProps(S),C.useMemo(()=>({view:t,state:c,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[t,c,d,p,i])}function uE({children:n}){const e=C.useRef(new Set).current,t=C.useRef(new Set).current,r=C.useRef(!1),i=W1(),o=C.useRef(!0),s=C.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=C.useCallback(a=>{let u;const c=()=>{u=a()};return e.add(c),s(),()=>{e.delete(c),u&&(r.current?(t.add(u),s()):u())}},[e,t,s]);return C.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{t.forEach(a=>a()),t.clear()})),C.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),A.jsx(z1.Provider,{value:l,children:n})}const mt=C.createContext([]);function U1(n,e,t,r,i,o,s){const[l,a]=C.useState(!0),u=C.useRef(o),c=C.useRef(()=>!1),f=C.useCallback(h=>{c.current=h},[]),d=C.useContext(mt),p=[];return C.useLayoutEffect(()=>{if(!n||!t.current)return;const h=p[0];u.current?(u.current.parent=void 0,u.current.children=p,u.current.node=n,u.current.outerDeco=i,u.current.innerDeco=r,u.current.dom=(e==null?void 0:e.current)??t.current,u.current.dom.pmViewDesc=u.current,u.current.contentDOM=(s==null?void 0:s.current)??u.current.contentDOM??(h==null?void 0:h.dom.parentElement)??null,u.current.nodeDOM=t.current):u.current=new pd(void 0,p,n,i,r,(e==null?void 0:e.current)??t.current,(h==null?void 0:h.dom.parentElement)??null,t.current,m=>!!c.current(m)),a(u.current.contentDOM!==null),d.push(u.current);for(const m of p)m.parent=u.current}),{hasContentDOM:l,childDescriptors:p,setStopEvent:f}}function cE(n,e){return n.type.side-e.type.side}function fE(n,e,t,r){const i=e.locals(n);let o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let d=o+c.nodeSize;if(c.isText){let h=d;s!h.inline):l.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function da(){const{state:n}=C.useContext(ts);return n}function H1(){const n=da();return Jo.getState(n)}var j1={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see diff --git a/docs/index.html b/docs/index.html index da587107..1cc29f2c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ React-ProseMirror Demo - + diff --git a/src/selection/selectionFromDOM.ts b/src/selection/selectionFromDOM.ts index a821559d..a3db372c 100644 --- a/src/selection/selectionFromDOM.ts +++ b/src/selection/selectionFromDOM.ts @@ -25,16 +25,17 @@ export function selectionFromDOM( const domSel = view.domSelectionRange(), doc = view.state.doc; if (!domSel.focusNode) return null; - // @ts-expect-error Internel property + // @ts-expect-error Internal method let nearestDesc = view.docView.nearestDesc(domSel.focusNode); const inWidget = nearestDesc && nearestDesc.size == 0; - // @ts-expect-error Internel property - const head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset, 1); + // @ts-expect-error Internal method + let head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset, 1); if (head < 0) return null; - const $head = doc.resolve(head); - let $anchor, selection; + let $head = doc.resolve(head), + anchor, + selection; if (selectionCollapsed(domSel)) { - $anchor = $head; + anchor = head; while (nearestDesc && !nearestDesc.node) nearestDesc = nearestDesc.parent; const nearestDescNode = (nearestDesc as NodeViewDesc).node; if ( @@ -51,16 +52,42 @@ export function selectionFromDOM( selection = new NodeSelection(head == pos ? $head : doc.resolve(pos)); } } else { - // @ts-expect-error Internal property - const anchor = view.docView.posFromDOM( + if ( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - domSel.anchorNode!, - domSel.anchorOffset, - 1 - ); + domSel instanceof view.dom.ownerDocument.defaultView!.Selection && + domSel.rangeCount > 1 + ) { + let min = head, + max = head; + for (let i = 0; i < domSel.rangeCount; i++) { + const range = domSel.getRangeAt(i); + min = Math.min( + min, + // @ts-expect-error Internal method + view.docView.posFromDOM(range.startContainer, range.startOffset, 1) + ); + max = Math.max( + max, + // @ts-expect-error Internal method + view.docView.posFromDOM(range.endContainer, range.endOffset, -1) + ); + } + if (min < 0) return null; + [anchor, head] = + max == view.state.selection.anchor ? [max, min] : [min, max]; + $head = doc.resolve(head); + } else { + // @ts-expect-error Internal method + anchor = view.docView.posFromDOM( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + domSel.anchorNode!, + domSel.anchorOffset, + 1 + ); + } if (anchor < 0) return null; - $anchor = doc.resolve(anchor); } + const $anchor = doc.resolve(anchor); if (!selection) { const bias =