owncast/static/web/_next/static/chunks/d2094a0f-b38d8b465e494a1e.js
2023-02-27 17:15:17 +00:00

1 line
55 KiB
JavaScript
Vendored

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8700],{96391:function(e,t,r){r.d(t,{BU:function(){return tL},CX:function(){return td},F3:function(){return ew},UE:function(){return tg},mH:function(){return tb},vt:function(){return e_}});var a=r(6907),n=r.n(a),o=r(23279),i=r.n(o),s=r(23493),l=r.n(s),d=r(67294),c=r(94203),u=r(77493),f=r(58354),v=r(18156),h=r(73935);function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e,t){if(null==e)return{};var r,a,n=function(e,t){if(null==e)return{};var r,a,n={},o=Object.keys(e);for(a=0;a<o.length;a++)r=o[a],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)r=o[a],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var m=0;class w{constructor(){this.id="".concat(m++)}}var b=new WeakMap,M=new WeakMap,k=new WeakMap,x=new WeakMap,y=new WeakMap,E=new WeakMap,L=new WeakMap,C=new WeakMap,D=new WeakMap,O=new WeakMap,S=new WeakMap,B=new WeakMap,F=new WeakMap,T=new WeakMap,R=new WeakMap,P=new WeakMap,N=new WeakMap,W=new WeakMap,j=new WeakMap,A=new WeakMap,I=new WeakMap,q=Symbol("placeholder"),Y=Symbol("mark-placeholder"),_=globalThis.Text,$=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,U=e=>V(e)&&8===e.nodeType,z=e=>V(e)&&1===e.nodeType,V=e=>{var t=$(e);return!!t&&e instanceof t.Node},K=e=>{var t=e&&e.anchorNode&&$(e.anchorNode);return!!t&&e instanceof t.Selection},H=e=>V(e)&&3===e.nodeType,X=e=>e.clipboardData&&""!==e.clipboardData.getData("text/plain")&&1===e.clipboardData.types.length,J=e=>{var[t,r]=e;if(z(t)&&t.childNodes.length){var a=r===t.childNodes.length,n=a?r-1:r;for([t,n]=G(t,n,a?"backward":"forward"),a=n<r;z(t)&&t.childNodes.length;){var o=a?t.childNodes.length-1:0;t=Q(t,o,a?"backward":"forward")}r=a&&null!=t.textContent?t.textContent.length:0}return[t,r]},Z=e=>{for(var t=e&&e.parentNode;t;){if("[object ShadowRoot]"===t.toString())return!0;t=t.parentNode}return!1},G=(e,t,r)=>{for(var{childNodes:a}=e,n=a[t],o=t,i=!1,s=!1;(U(n)||z(n)&&0===n.childNodes.length||z(n)&&"false"===n.getAttribute("contenteditable"))&&(!i||!s);){if(o>=a.length){i=!0,o=t-1,r="backward";continue}if(o<0){s=!0,o=t+1,r="forward";continue}n=a[o],t=o,o+="forward"===r?1:-1}return[n,t]},Q=(e,t,r)=>{var[a]=G(e,t,r);return a},ee=e=>{var t="";if(H(e)&&e.nodeValue)return e.nodeValue;if(z(e)){for(var r of Array.from(e.childNodes))t+=ee(r);var a=getComputedStyle(e).getPropertyValue("display");("block"===a||"list"===a||"BR"===e.tagName)&&(t+="\n")}return t},et=/data-slate-fragment="(.+?)"/m,er=e=>{var[,t]=e.getData("text/html").match(et)||[];return t},ea=(e,t,r)=>{var{target:a}=t;if(z(a)&&a.matches('[contentEditable="false"]'))return!1;var{document:n}=ew.getWindow(e);if(n.contains(a))return ew.hasDOMNode(e,a,{editable:!0});var o=r.find(e=>{var{addedNodes:t,removedNodes:r}=e;for(var n of t)if(n===a||n.contains(a))return!0;for(var o of r)if(o===a||o.contains(a))return!0});return!!o&&o!==t&&ea(e,o,r)},en=parseInt(d.version.split(".")[0],10)>=17,eo="undefined"!=typeof navigator&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ei="undefined"!=typeof navigator&&/Mac OS X/.test(navigator.userAgent),es="undefined"!=typeof navigator&&/Android/.test(navigator.userAgent),el="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),ed="undefined"!=typeof navigator&&/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),ec="undefined"!=typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),eu="undefined"!=typeof navigator&&/Chrome/i.test(navigator.userAgent),ef="undefined"!=typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),ev="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),eh="undefined"!=typeof navigator&&/.*UCBrowser/.test(navigator.userAgent),ep="undefined"!=typeof navigator&&/.*Wechat/.test(navigator.userAgent),eg=!!("undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement),em=!ef&&!ec&&"undefined"!=typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges,ew={isComposing:e=>!!B.get(e),getWindow(e){var t=k.get(e);if(!t)throw Error("Unable to find a host window element for this editor");return t},findKey(e,t){var r=C.get(t);return r||(r=new w,C.set(t,r)),r},findPath(e,t){for(var r=[],a=t;;){var n=M.get(a);if(null==n){if(u.ML.isEditor(a))return r;break}var o=b.get(a);if(null==o)break;r.unshift(o),a=n}throw Error("Unable to find the path for Slate node: ".concat(u.o4.stringify(t)))},findDocumentOrShadowRoot(e){var t=ew.toDOMNode(e,e),r=t.getRootNode();return(r instanceof Document||r instanceof ShadowRoot)&&null!=r.getSelection?r:t.ownerDocument},isFocused:e=>!!S.get(e),isReadOnly:e=>!!O.get(e),blur(e){var t=ew.toDOMNode(e,e),r=ew.findDocumentOrShadowRoot(e);S.set(e,!1),r.activeElement===t&&t.blur()},focus(e){var t=ew.toDOMNode(e,e),r=ew.findDocumentOrShadowRoot(e);S.set(e,!0),r.activeElement!==t&&t.focus({preventScroll:!0})},deselect(e){var{selection:t}=e,r=ew.findDocumentOrShadowRoot(e).getSelection();r&&r.rangeCount>0&&r.removeAllRanges(),t&&u.YR.deselect(e)},hasDOMNode(e,t){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{editable:n=!1}=a,o=ew.toDOMNode(e,e);try{r=z(t)?t:t.parentElement}catch(e){if(!e.message.includes('Permission denied to access property "nodeType"'))throw e}return!!r&&r.closest("[data-slate-editor]")===o&&(!n||!!r.isContentEditable||"boolean"==typeof r.isContentEditable&&r.closest('[contenteditable="false"]')===o||!!r.getAttribute("data-slate-zero-width"))},insertData(e,t){e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),setFragmentData(e,t,r){e.setFragmentData(t,r)},toDOMNode(e,t){var r=D.get(e),a=u.ML.isEditor(t)?x.get(e):null==r?void 0:r.get(ew.findKey(e,t));if(!a)throw Error("Cannot resolve a DOM node from Slate node: ".concat(u.o4.stringify(t)));return a},toDOMPoint(e,t){var[r]=u.ML.node(e,t.path),a=ew.toDOMNode(e,r);u.ML.void(e,{at:t})&&(t={path:t.path,offset:0});for(var n=Array.from(a.querySelectorAll("[data-slate-string], [data-slate-zero-width]")),o=0,i=0;i<n.length;i++){var s=n[i],l=s.childNodes[0];if(null!=l&&null!=l.textContent){var{length:d}=l.textContent,c=s.getAttribute("data-slate-length"),f=o+(null==c?d:parseInt(c,10)),v=n[i+1];if(t.offset===f&&null!=v&&v.hasAttribute("data-slate-mark-placeholder")){var h,p,g=v.childNodes[0];h=[g instanceof _?g:v,null!==(p=v.textContent)&&void 0!==p&&p.startsWith("\uFEFF")?1:0];break}if(t.offset<=f){h=[l,Math.min(d,Math.max(0,t.offset-o))];break}o=f}}if(!h)throw Error("Cannot resolve a DOM point from Slate point: ".concat(u.o4.stringify(t)));return h},toDOMRange(e,t){var{anchor:r,focus:a}=t,n=u.e6.isBackward(t),o=ew.toDOMPoint(e,r),i=u.e6.isCollapsed(t)?o:ew.toDOMPoint(e,a),s=ew.getWindow(e).document.createRange(),[l,d]=n?i:o,[c,f]=n?o:i,v=!!(z(l)?l:l.parentElement).getAttribute("data-slate-zero-width"),h=!!(z(c)?c:c.parentElement).getAttribute("data-slate-zero-width");return s.setStart(l,v?1:d),s.setEnd(c,h?1:f),s},toSlateNode(e,t){var r=z(t)?t:t.parentElement;r&&!r.hasAttribute("data-slate-node")&&(r=r.closest("[data-slate-node]"));var a=r?E.get(r):null;if(!a)throw Error("Cannot resolve a Slate node from DOM node: ".concat(r));return a},findEventRange(e,t){"nativeEvent"in t&&(t=t.nativeEvent);var r,{clientX:a,clientY:n,target:o}=t;if(null==a||null==n)throw Error("Cannot resolve a Slate range from a DOM event: ".concat(t));var i=ew.toSlateNode(e,t.target),s=ew.findPath(e,i);if(u.W_.isElement(i)&&u.ML.isVoid(e,i)){var l=o.getBoundingClientRect(),d=e.isInline(i)?a-l.left<l.left+l.width-a:n-l.top<l.top+l.height-n,c=u.ML.point(e,s,{edge:d?"start":"end"}),f=d?u.ML.before(e,c):u.ML.after(e,c);if(f)return u.ML.range(e,f)}var{document:v}=ew.getWindow(e);if(v.caretRangeFromPoint)r=v.caretRangeFromPoint(a,n);else{var h=v.caretPositionFromPoint(a,n);h&&((r=v.createRange()).setStart(h.offsetNode,h.offset),r.setEnd(h.offsetNode,h.offset))}if(!r)throw Error("Cannot resolve a Slate range from a DOM event: ".concat(t));return ew.toSlateRange(e,r,{exactMatch:!1,suppressThrow:!1})},toSlatePoint(e,t,r){var{exactMatch:a,suppressThrow:n}=r,[o,i]=a?t:J(t),s=o.parentNode,l=null,d=0;if(s){var c,f,v=ew.toDOMNode(e,e),h=s.closest('[data-slate-void="true"]'),p=h&&v.contains(h)?h:null,g=s.closest("[data-slate-leaf]"),m=null;if(g){if(l=g.closest('[data-slate-node="text"]')){var w=ew.getWindow(e).document.createRange();w.setStart(l,0),w.setEnd(o,i);var b=w.cloneContents();[...Array.prototype.slice.call(b.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(b.querySelectorAll("[contenteditable=false]"))].forEach(e=>{if(es&&!a&&e.hasAttribute("data-slate-zero-width")&&e.textContent.length>0&&"\uFEFF"!==e.textContext){e.textContent.startsWith("\uFEFF")&&(e.textContent=e.textContent.slice(1));return}e.parentNode.removeChild(e)}),d=b.textContent.length,m=l}}else if(p){for(var M=p.querySelectorAll("[data-slate-leaf]"),k=0;k<M.length;k++){var x=M[k];if(ew.hasDOMNode(e,x)){g=x;break}}g?(l=g.closest('[data-slate-node="text"]'),d=(m=g).textContent.length,m.querySelectorAll("[data-slate-zero-width]").forEach(e=>{d-=e.textContent.length})):d=1}m&&d===m.textContent.length&&es&&"z"===m.getAttribute("data-slate-zero-width")&&null!==(c=m.textContent)&&void 0!==c&&c.startsWith("\uFEFF")&&(s.hasAttribute("data-slate-zero-width")||el&&null!==(f=m.textContent)&&void 0!==f&&f.endsWith("\n\n"))&&d--}if(es&&!l&&!a){var y=s.hasAttribute("data-slate-node")?s:s.closest("[data-slate-node]");if(y&&ew.hasDOMNode(e,y,{editable:!0})){var E=ew.toSlateNode(e,y),{path:L,offset:C}=u.ML.start(e,ew.findPath(e,E));return y.querySelector("[data-slate-leaf]")||(C=i),{path:L,offset:C}}}if(!l){if(n)return null;throw Error("Cannot resolve a Slate point from DOM point: ".concat(t))}var D=ew.toSlateNode(e,l);return{path:ew.findPath(e,D),offset:d}},toSlateRange(e,t,r){var a,n,o,i,s,{exactMatch:l,suppressThrow:d}=r;if((K(t)?t.anchorNode:t.startContainer)&&(K(t)?(a=t.anchorNode,n=t.anchorOffset,o=t.focusNode,i=t.focusOffset,s=eu&&Z(a)?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed):(a=t.startContainer,n=t.startOffset,o=t.endContainer,i=t.endOffset,s=t.collapsed)),null==a||null==o||null==n||null==i)throw Error("Cannot resolve a Slate range from DOM range: ".concat(t));var c=ew.toSlatePoint(e,[a,n],{exactMatch:l,suppressThrow:d});if(!c)return null;var f=s?c:ew.toSlatePoint(e,[o,i],{exactMatch:l,suppressThrow:d});if(!f)return null;if(el&&!s&&a!==o){var v=u.ML.isEnd(e,c,c.path),h=u.ML.isStart(e,f,f.path);v&&(c=u.ML.after(e,c)||c),h&&(f=u.ML.before(e,f)||f)}var p={anchor:c,focus:f};return u.e6.isExpanded(p)&&u.e6.isForward(p)&&z(o)&&u.ML.void(e,{at:p.focus,mode:"highest"})&&(p=u.ML.unhangRange(e,p,{voids:!0})),p},hasRange(e,t){var{anchor:r,focus:a}=t;return u.ML.hasPath(e,r.path)&&u.ML.hasPath(e,a.path)},hasTarget:(e,t)=>V(t)&&ew.hasDOMNode(e,t),hasEditableTarget:(e,t)=>V(t)&&ew.hasDOMNode(e,t,{editable:!0}),hasSelectableTarget:(e,t)=>ew.hasEditableTarget(e,t)||ew.isTargetInsideNonReadonlyVoid(e,t),isTargetInsideNonReadonlyVoid(e,t){if(O.get(e))return!1;var r=ew.hasTarget(e,t)&&ew.toSlateNode(e,t);return u.W_.isElement(r)&&u.ML.isVoid(e,r)},androidScheduleFlush(e){var t;null===(t=R.get(e))||void 0===t||t()},androidPendingDiffs:e=>W.get(e)},eb=["anchor","focus"],eM=["anchor","focus"],ek=(e,t)=>Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(r=>t.hasOwnProperty(r)&&e[r]===t[r]),ex=(e,t)=>{var r=g(e,eb),a=g(t,eM);return e[q]===t[q]&&ek(r,a)},ey=(e,t)=>{if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++){var a=e[r],n=t[r];if(!u.e6.equals(a,n)||!ex(a,n))return!1}return!0},eE=(e,t)=>{if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++){var a=e[r],n=t[r];if(a.anchor.offset!==n.anchor.offset||a.focus.offset!==n.focus.offset||!ex(a,n))return!1}return!0},eL=eg?d.useLayoutEffect:d.useEffect,eC=e=>{var{isLast:t,leaf:r,parent:a,text:n}=e,o=eB(),i=ew.findPath(o,n),s=u.y$.parent(i),l=!0===r[Y];return o.isVoid(a)?d.createElement(eO,{length:u.NB.string(a).length}):""!==r.text||a.children[a.children.length-1]!==n||o.isInline(a)||""!==u.ML.string(o,s)?""===r.text?d.createElement(eO,{isMarkPlaceholder:l}):t&&"\n"===r.text.slice(-1)?d.createElement(eD,{isTrailing:!0,text:r.text}):d.createElement(eD,{text:r.text}):d.createElement(eO,{isLineBreak:!0,isMarkPlaceholder:l})},eD=e=>{var{text:t,isTrailing:r=!1}=e,a=(0,d.useRef)(null),n=()=>"".concat(null!=t?t:"").concat(r?"\n":"");return(eL(()=>{var e=n();a.current&&a.current.textContent!==e&&(a.current.textContent=e)}),a.current)?d.createElement("span",{"data-slate-string":!0,ref:a}):d.createElement("span",{"data-slate-string":!0,ref:a},n())},eO=e=>{var{length:t=0,isLineBreak:r=!1,isMarkPlaceholder:a=!1}=e,n={"data-slate-zero-width":r?"n":"z","data-slate-length":t};return a&&(n["data-slate-mark-placeholder"]=!0),d.createElement("span",Object.assign({},n),es&&r?null:"\uFEFF",r?d.createElement("br",null):null)},eS=(0,d.createContext)(null),eB=()=>{var e=(0,d.useContext)(eS);if(!e)throw Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},eF=e=>{var{leaf:t,isLast:r,text:a,parent:n,renderPlaceholder:o,renderLeaf:i=e=>d.createElement(eR,Object.assign({},e))}=e,s=(0,d.useRef)(null),l=(0,d.useRef)(null),c=eB(),u=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{u.current&&u.current.disconnect()},[]),(0,d.useEffect)(()=>{var e=null==l?void 0:l.current;if(e?y.set(c,e):y.delete(c),u.current)u.current.disconnect(),e&&u.current.observe(e);else if(e){var t=window.ResizeObserver||f.do;u.current=new t(()=>{var e=I.get(c);null==e||e()}),u.current.observe(e)}if(!e&&s.current){var r=I.get(c);null==r||r()}return s.current=l.current,()=>{y.delete(c)}},[l,t]);var v=d.createElement(eC,{isLast:r,leaf:t,parent:n,text:a});if(t[q]){var h={children:t.placeholder,attributes:{"data-slate-placeholder":!0,style:{position:"absolute",pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",textDecoration:"none"},contentEditable:!1,ref:l}};v=d.createElement(d.Fragment,null,o(h),v)}return i({attributes:{"data-slate-leaf":!0},children:v,leaf:t,text:a})},eT=d.memo(eF,(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&u.xv.equals(t.leaf,e.leaf)&&t.leaf[q]===e.leaf[q]),eR=e=>{var{attributes:t,children:r}=e;return d.createElement("span",Object.assign({},t),r)},eP=e=>{for(var{decorations:t,isLast:r,parent:a,renderPlaceholder:n,renderLeaf:o,text:i}=e,s=eB(),l=(0,d.useRef)(null),c=u.xv.decorations(i,t),f=ew.findKey(s,i),v=[],h=0;h<c.length;h++){var p=c[h];v.push(d.createElement(eT,{isLast:r&&h===c.length-1,key:"".concat(f.id,"-").concat(h),renderPlaceholder:n,leaf:p,text:i,parent:a,renderLeaf:o}))}var g=(0,d.useCallback)(e=>{var t=D.get(s);e?(null==t||t.set(f,e),L.set(i,e),E.set(e,i)):(null==t||t.delete(f),L.delete(i),l.current&&E.delete(l.current)),l.current=e},[l,s,f,i]);return d.createElement("span",{"data-slate-node":"text",ref:g},v)},eN=d.memo(eP,(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&eE(t.decorations,e.decorations)),eW=e=>{var{decorations:t,element:r,renderElement:a=e=>d.createElement(eA,Object.assign({},e)),renderPlaceholder:o,renderLeaf:i,selection:s}=e,l=eB(),c=ez(),f=l.isInline(r),v=ew.findKey(l,r),h=(0,d.useCallback)(e=>{var t=D.get(l);e?(null==t||t.set(v,e),L.set(r,e),E.set(e,r)):(null==t||t.delete(v),L.delete(r))},[l,v,r]),p=e$({decorations:t,node:r,renderElement:a,renderPlaceholder:o,renderLeaf:i,selection:s}),g={"data-slate-node":"element",ref:h};if(f&&(g["data-slate-inline"]=!0),!f&&u.ML.hasInlines(l,r)){var m=u.NB.string(r),w=n()(m);"rtl"===w&&(g.dir=w)}if(u.ML.isVoid(l,r)){g["data-slate-void"]=!0,!c&&f&&(g.contentEditable=!1);var[[k]]=u.NB.texts(r);p=d.createElement(f?"span":"div",{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},d.createElement(eN,{renderPlaceholder:o,decorations:[],isLast:!1,parent:r,text:k})),b.set(k,0),M.set(k,r)}return a({attributes:g,children:p,element:r})},ej=d.memo(eW,(e,t)=>e.element===t.element&&e.renderElement===t.renderElement&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&ey(e.decorations,t.decorations)&&(e.selection===t.selection||!!e.selection&&!!t.selection&&u.e6.equals(e.selection,t.selection))),eA=e=>{var{attributes:t,children:r,element:a}=e,n=eB().isInline(a)?"span":"div";return d.createElement(n,Object.assign({},t,{style:{position:"relative"}}),r)},eI=(0,d.createContext)(()=>[]),eq=()=>(0,d.useContext)(eI),eY=(0,d.createContext)(!1),e_=()=>(0,d.useContext)(eY),e$=e=>{for(var{decorations:t,node:r,renderElement:a,renderPlaceholder:n,renderLeaf:o,selection:i}=e,s=eq(),l=eB(),c=ew.findPath(l,r),f=[],v=u.W_.isElement(r)&&!l.isInline(r)&&u.ML.hasInlines(l,r),h=0;h<r.children.length;h++){var p=c.concat(h),g=r.children[h],m=ew.findKey(l,g),w=u.ML.range(l,p),k=i&&u.e6.intersection(w,i),x=s([g,p]);for(var y of t){var E=u.e6.intersection(y,w);E&&x.push(E)}u.W_.isElement(g)?f.push(d.createElement(eY.Provider,{key:"provider-".concat(m.id),value:!!k},d.createElement(ej,{decorations:x,element:g,key:m.id,renderElement:a,renderPlaceholder:n,renderLeaf:o,selection:k}))):f.push(d.createElement(eN,{decorations:x,key:m.id,isLast:v&&h===r.children.length-1,parent:r,renderPlaceholder:n,renderLeaf:o,text:g})),b.set(g,h),M.set(g,r)}return f},eU=(0,d.createContext)(!1),ez=()=>(0,d.useContext)(eU),eV=(0,d.createContext)(null),eK=()=>{var e=(0,d.useContext)(eV);if(!e)throw Error("The `useSlate` hook must be used inside the <Slate> component's context.");var{editor:t}=e;return t},eH={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"left",moveForward:"right",moveWordBackward:"ctrl+left",moveWordForward:"ctrl+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",insertSoftBreak:"shift+enter",splitBlock:"enter",undo:"mod+z"},eX={moveLineBackward:"opt+up",moveLineForward:"opt+down",moveWordBackward:"opt+left",moveWordForward:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},eJ={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},eZ=e=>{var t=eH[e],r=eX[e],a=eJ[e],n=t&&(0,v.TB)(t),o=r&&(0,v.TB)(r),i=a&&(0,v.TB)(a);return e=>!!(n&&n(e)||ei&&o&&o(e)||!ei&&i&&i(e))},eG={isBold:eZ("bold"),isCompose:eZ("compose"),isMoveBackward:eZ("moveBackward"),isMoveForward:eZ("moveForward"),isDeleteBackward:eZ("deleteBackward"),isDeleteForward:eZ("deleteForward"),isDeleteLineBackward:eZ("deleteLineBackward"),isDeleteLineForward:eZ("deleteLineForward"),isDeleteWordBackward:eZ("deleteWordBackward"),isDeleteWordForward:eZ("deleteWordForward"),isExtendBackward:eZ("extendBackward"),isExtendForward:eZ("extendForward"),isExtendLineBackward:eZ("extendLineBackward"),isExtendLineForward:eZ("extendLineForward"),isItalic:eZ("italic"),isMoveLineBackward:eZ("moveLineBackward"),isMoveLineForward:eZ("moveLineForward"),isMoveWordBackward:eZ("moveWordBackward"),isMoveWordForward:eZ("moveWordForward"),isRedo:eZ("redo"),isSoftBreak:eZ("insertSoftBreak"),isSplitBlock:eZ("splitBlock"),isTransposeCharacter:eZ("transposeCharacter"),isUndo:eZ("undo")},eQ=(e,t)=>{var r=[],a=()=>{r=[]};return{registerMutations:a=>{if(t.current){var n=a.filter(t=>ea(e,t,a));r.push(...n)}},restoreDOM:function(){r.reverse().forEach(e=>{if("characterData"===e.type){e.target.textContent=e.oldValue;return}e.removedNodes.forEach(t=>{e.target.insertBefore(t,e.nextSibling)}),e.addedNodes.forEach(t=>{e.target.removeChild(t)})}),a()},clear:a}},e0={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class e1 extends d.Component{constructor(){super(...arguments),this.context=null,this.manager=null,this.mutationObserver=null}observe(){var e,{node:t}=this.props;if(!t.current)throw Error("Failed to attach MutationObserver, `node` is undefined");null===(e=this.mutationObserver)||void 0===e||e.observe(t.current,e0)}componentDidMount(){var{receivedUserInput:e}=this.props,t=this.context;this.manager=eQ(t,e),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var e,t,r,a,n=null===(e=this.mutationObserver)||void 0===e?void 0:e.takeRecords();return null!=n&&n.length&&(null===(a=this.manager)||void 0===a||a.registerMutations(n)),null===(t=this.mutationObserver)||void 0===t||t.disconnect(),null===(r=this.manager)||void 0===r||r.restoreDOM(),null}componentDidUpdate(){var e;null===(e=this.manager)||void 0===e||e.clear(),this.observe()}componentWillUnmount(){var e;null===(e=this.mutationObserver)||void 0===e||e.disconnect()}render(){return this.props.children}}e1.contextType=eS;var e6=es?e1:e=>{var{children:t}=e;return d.createElement(d.Fragment,null,t)};function e2(e,t){var{start:r,end:a,text:n}=t,o=e.slice(r,a),i=function(e,t){for(var r=Math.min(e.length,t.length),a=0;a<r;a++)if(e.charAt(a)!==t.charAt(a))return a;return r}(o,n),s=Math.min(o.length-i,n.length-i),l=function(e,t,r){for(var a=Math.min(e.length,t.length,r),n=0;n<a;n++)if(e.charAt(e.length-n-1)!==t.charAt(t.length-n-1))return n;return a}(o,n,s),d={start:r+i,end:a-l,text:n.slice(i,n.length-l)};return d.start===d.end&&0===d.text.length?null:d}function e9(e,t){var{path:r,offset:a}=t;if(!u.ML.hasPath(e,r))return null;var n=u.NB.get(e,r);if(!u.xv.isText(n))return null;var o=u.ML.above(e,{match:t=>u.W_.isElement(t)&&u.ML.isBlock(e,t),at:r});if(!o)return null;for(;a>n.text.length;){var i=u.ML.next(e,{at:r,match:u.xv.isText});if(!i||!u.y$.isDescendant(i[1],o[1]))return null;a-=n.text.length,n=i[0],r=i[1]}return{path:r,offset:a}}function e3(e,t){var r=e9(e,t.anchor);if(!r)return null;if(u.e6.isCollapsed(t))return{anchor:r,focus:r};var a=e9(e,t.focus);return a?{anchor:r,focus:a}:null}function e7(e,t,r){var a=W.get(e),n=null==a?void 0:a.find(e=>{var{path:r}=e;return u.y$.equals(r,t.path)});if(!n||t.offset<=n.diff.start)return u.E9.transform(t,r,{affinity:"backward"});var{diff:o}=n;if(t.offset<=o.start+o.text.length){var i={path:t.path,offset:o.start},s=u.E9.transform(i,r,{affinity:"backward"});return s?{path:s.path,offset:s.offset+t.offset-o.start}:null}var l={path:t.path,offset:t.offset-o.text.length+o.end-o.start},d=u.E9.transform(l,r,{affinity:"backward"});return d?"split_node"===r.type&&u.y$.equals(r.path,t.path)&&l.offset<r.position&&o.start<r.position?d:{path:d.path,offset:d.offset+o.text.length-o.end+o.start}:null}function e4(e,t,r){var a=e7(e,t.anchor,r);if(!a)return null;if(u.e6.isCollapsed(t))return{anchor:a,focus:a};var n=e7(e,t.focus,r);return n?{anchor:a,focus:n}:null}function e5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function e8(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?e5(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):e5(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var te=function(){},tt=["node"];function tr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}var ta={subtree:!0,childList:!0,characterData:!0},tn=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderLeaf","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],to=["text"];function ti(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function ts(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ti(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ti(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var tl=e=>d.createElement(d.Fragment,null,e$(e)),td=e=>{var t,r,a,o,s,c,{autoFocus:f,decorate:v=tu,onDOMBeforeInput:h,placeholder:m,readOnly:w=!1,renderElement:b,renderLeaf:M,renderPlaceholder:C=e=>d.createElement(tc,Object.assign({},e)),scrollSelectionIntoView:D=tf,style:T={},as:_="div",disableDefaultStyles:U=!1}=e,H=g(e,tn),J=eK(),[Z,G]=(0,d.useState)(!1),Q=(0,d.useRef)(null),ee=(0,d.useRef)([]),{onUserInput:et,receivedUserInput:er}=(t=eB(),r=(0,d.useRef)(!1),a=(0,d.useRef)(0),o=(0,d.useCallback)(()=>{if(!r.current){r.current=!0;var e=ew.getWindow(t);e.cancelAnimationFrame(a.current),a.current=e.requestAnimationFrame(()=>{r.current=!1})}},[]),(0,d.useEffect)(()=>()=>cancelAnimationFrame(a.current),[]),{receivedUserInput:r,onUserInput:o}),[,en]=(0,d.useReducer)(e=>e+1,0);I.set(J,en),O.set(J,w);var ei=(0,d.useMemo)(()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}),[]);(0,d.useEffect)(()=>{Q.current&&f&&Q.current.focus()},[f]);var ec=(0,d.useCallback)(l()(()=>{if((es||!ew.isComposing(J))&&(!ei.isUpdatingSelection||null!=eb&&eb.isFlushing())&&!ei.isDraggingInternally){var e=ew.findDocumentOrShadowRoot(J),{activeElement:t}=e,r=ew.toDOMNode(J,J),a=e.getSelection();if(t===r?(ei.latestElement=t,S.set(J,!0)):S.delete(J),!a)return u.YR.deselect(J);var{anchorNode:n,focusNode:o}=a,i=ew.hasEditableTarget(J,n)||ew.isTargetInsideNonReadonlyVoid(J,n),s=ew.hasEditableTarget(J,o)||ew.isTargetInsideNonReadonlyVoid(J,o);if(i&&s){var l=ew.toSlateRange(J,a,{exactMatch:!1,suppressThrow:!0});l&&(ew.isComposing(J)||null!=eb&&eb.hasPendingChanges()||null!=eb&&eb.isFlushing()?null==eb||eb.handleUserSelect(l):u.YR.select(J,l))}!w||i&&s||u.YR.deselect(J)}},100),[w]),ef=(0,d.useMemo)(()=>i()(ec,0),[ec]),eb=function(e){var t,{node:r}=e,a=g(e,tt);if(!es)return null;var n=eB(),o=(t=(0,d.useRef)(!1),(0,d.useEffect)(()=>(t.current=!0,()=>{t.current=!1}),[]),t.current),[i]=(0,d.useState)(()=>(function(e){var{editor:t,scheduleOnDOMSelectionChange:r,onDOMSelectionChange:a}=e,n=!1,o=null,i=null,s=null,l=0,d=!1,c=()=>{var e=A.get(t);if(A.delete(t),e){var{selection:r}=t,a=e3(t,e);!a||r&&u.e6.equals(a,r)||u.YR.select(t,a)}},f=()=>{var e=j.get(t);if(j.delete(t),e){if(e.at){var r=u.E9.isPoint(e.at)?e9(t,e.at):e3(t,e.at);if(!r)return;var a=u.ML.range(t,r);t.selection&&u.e6.equals(t.selection,a)||u.YR.select(t,r)}e.run()}},v=()=>{if(i&&(clearTimeout(i),i=null),s&&(clearTimeout(s),s=null),!w()&&!m()){c();return}n||(n=!0,setTimeout(()=>n=!1)),m()&&(n="action");var e=t.selection&&u.ML.rangeRef(t,t.selection,{affinity:"forward"});N.set(t,t.marks),te("flush",j.get(t),W.get(t));for(var o=!!(null!==(l=W.get(t))&&void 0!==l&&l.length);v=null===(h=W.get(t))||void 0===h?void 0:h[0];){var l,v,h,p,g=P.get(t);void 0!==g&&(P.delete(t),t.marks=g),g&&!1===d&&(d=null);var b=function(e){var{path:t,diff:r}=e;return{anchor:{path:t,offset:r.start},focus:{path:t,offset:r.end}}}(v);t.selection&&u.e6.equals(t.selection,b)||u.YR.select(t,b),v.diff.text?u.ML.insertText(t,v.diff.text):u.ML.deleteFragment(t),W.set(t,null===(p=W.get(t))||void 0===p?void 0:p.filter(e=>{var{id:t}=e;return t!==v.id})),!function(e,t){var{path:r,diff:a}=t;if(!u.ML.hasPath(e,r))return!1;var n=u.NB.get(e,r);if(!u.xv.isText(n))return!1;if(a.start!==n.text.length||0===a.text.length)return n.text.slice(a.start,a.start+a.text.length)===a.text;var o=u.y$.next(r);if(!u.ML.hasPath(e,o))return!1;var i=u.NB.get(e,o);return u.xv.isText(i)&&i.text.startsWith(a.text)}(t,v)&&(o=!1,j.delete(t),N.delete(t),n="action",A.delete(t),r.cancel(),a.cancel(),null==e||e.unref())}var M=null==e?void 0:e.unref();if(!M||A.get(t)||t.selection&&u.e6.equals(M,t.selection)||u.YR.select(t,M),m()){f();return}o&&r(),r.flush(),a.flush(),c();var k=N.get(t);N.delete(t),void 0!==k&&(t.marks=k,t.onChange())},h=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=y.get(t);if(r){if(w()||e){r.style.display="none";return}r.style.removeProperty("display")}},p=(e,r)=>{var a,n,o,i,s,d,c,f,v=null!==(f=W.get(t))&&void 0!==f?f:[];W.set(t,v);var p=u.NB.leaf(t,e),g=v.findIndex(t=>u.y$.equals(t.path,e));if(g<0){e2(p.text,r)&&v.push({path:e,diff:r,id:l++}),h();return}var m=(a=p.text,o=Math.min((n=v[g].diff).start,r.start),i=Math.max(0,Math.min(n.start+n.text.length,r.end)-r.start),s=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];return r.reduce((e,t)=>e.slice(0,t.start)+t.text+e.slice(t.end),e)}(a,n,r),d=Math.max(r.start+r.text.length,n.start+n.text.length+(n.start+n.text.length>r.start?r.text.length:0)-i),c=s.slice(o,d),e2(a,{start:o,end:Math.max(n.end,r.end-n.text.length+(n.end-n.start)),text:c}));if(!m){v.splice(g,1),h();return}v[g]=e8(e8({},v[g]),{},{diff:m})},g=function(e){var{at:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d=!1,A.delete(t),r.cancel(),a.cancel(),m()&&v(),j.set(t,{at:n,run:e}),s=setTimeout(v)},m=()=>!!j.get(t),w=()=>{var e;return!!(null!==(e=W.get(t))&&void 0!==e&&e.length)},b=e=>{A.set(t,e),i&&(clearTimeout(i),i=null);var{selection:r}=t;if(e){var a=!r||!u.y$.equals(r.anchor.path,e.anchor.path),n=!r||!u.y$.equals(r.anchor.path.slice(0,-1),e.anchor.path.slice(0,-1));(a&&d||n)&&(d=!1),(a||!w())&&(i=setTimeout(v,200))}},M=()=>{m()||(s=setTimeout(v))};return{flush:v,scheduleFlush:M,hasPendingDiffs:w,hasPendingAction:m,hasPendingChanges:()=>m()||w(),isFlushing:()=>n,handleUserSelect:b,handleCompositionEnd:e=>{o&&clearTimeout(o),o=setTimeout(()=>{B.set(t,!1),v()},25)},handleCompositionStart:e=>{B.set(t,!0),o&&(clearTimeout(o),o=null)},handleDOMBeforeInput:e=>{i&&(clearTimeout(i),i=null);var{inputType:r}=e,a=null,n=e.dataTransfer||e.data||void 0;!1!==d&&"insertText"!==r&&"insertCompositionText"!==r&&(d=!1);var[o]=e.getTargetRanges();o&&(a=ew.toSlateRange(t,o,{exactMatch:!1,suppressThrow:!0}));var s=ew.getWindow(t).getSelection();if(!a&&s&&(o=s,a=ew.toSlateRange(t,s,{exactMatch:!1,suppressThrow:!0})),a=null!==(y=a)&&void 0!==y?y:t.selection){if(u.e6.isExpanded(a)&&r.startsWith("delete")){var[l,c]=u.e6.edges(a);if(u.NB.leaf(t,l.path).text.length===l.offset&&0===c.offset){var f=u.ML.next(t,{at:l.path,match:u.xv.isText});f&&u.y$.equals(f[1],c.path)&&(a={anchor:c,focus:c})}}if(u.e6.isExpanded(a)&&r.startsWith("delete")){if(u.y$.equals(a.anchor.path,a.focus.path)){var[v,h]=u.e6.edges(a),m={path:a.anchor.path,offset:v.offset};return b(u.ML.range(t,m,m)),p(a.anchor.path,{text:"",end:h.offset,start:v.offset})}var w=r.endsWith("Backward")?"backward":"forward";return g(()=>u.ML.deleteFragment(t,{direction:w}),{at:a})}switch(r){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return g(()=>u.ML.deleteFragment(t),{at:a});case"deleteContent":case"deleteContentForward":var{anchor:k}=a;if(u.e6.isCollapsed(a)){var x=u.NB.leaf(t,k.path);if(k.offset<x.text.length)return p(k.path,{text:"",start:k.offset,end:k.offset+1})}return g(()=>u.ML.deleteForward(t),{at:a});case"deleteContentBackward":var y,E,{anchor:L}=a;if((K(o)?o.isCollapsed:!!(null!==(E=o)&&void 0!==E&&E.collapsed))&&u.e6.isCollapsed(a)&&L.offset>0)return p(L.path,{text:"",start:L.offset-1,end:L.offset});return g(()=>u.ML.deleteBackward(t),{at:a});case"deleteEntireSoftLine":return g(()=>{u.ML.deleteBackward(t,{unit:"line"}),u.ML.deleteForward(t,{unit:"line"})},{at:a});case"deleteHardLineBackward":return g(()=>u.ML.deleteBackward(t,{unit:"block"}),{at:a});case"deleteSoftLineBackward":return g(()=>u.ML.deleteBackward(t,{unit:"line"}),{at:a});case"deleteHardLineForward":return g(()=>u.ML.deleteForward(t,{unit:"block"}),{at:a});case"deleteSoftLineForward":return g(()=>u.ML.deleteForward(t,{unit:"line"}),{at:a});case"deleteWordBackward":return g(()=>u.ML.deleteBackward(t,{unit:"word"}),{at:a});case"deleteWordForward":return g(()=>u.ML.deleteForward(t,{unit:"word"}),{at:a});case"insertLineBreak":return g(()=>u.ML.insertSoftBreak(t),{at:a});case"insertParagraph":return g(()=>u.ML.insertBreak(t),{at:a});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if((null==n?void 0:n.constructor.name)==="DataTransfer")return g(()=>ew.insertData(t,n),{at:a});if("string"==typeof n&&n.includes("\n"))return g(()=>u.ML.insertSoftBreak(t),{at:u.e6.end(a)});var C=null!=n?n:"";if(P.get(t)&&(C=C.replace("\uFEFF","")),u.y$.equals(a.anchor.path,a.focus.path)){var[D,O]=u.e6.edges(a),S={start:D.offset,end:O.offset,text:C};if(C&&d&&"insertCompositionText"===r){var B=d.start+d.text.search(/\S|$/);S.start+S.text.search(/\S|$/)===B+1&&S.end===d.start+d.text.length?(S.start-=1,d=null,M()):d=!1}else d="insertText"===r&&(null===d?S:!!(d&&u.e6.isCollapsed(a))&&d.end+d.text.length===D.offset&&e8(e8({},d),{},{text:d.text+C}));p(D.path,S);return}return g(()=>u.ML.insertText(t,C),{at:a})}}},handleKeyDown:e=>{w()||(h(!0),setTimeout(h))},handleDomMutations:e=>{if(!(w()||m())&&e.some(r=>ea(t,r,e))){var r;null===(r=I.get(t))||void 0===r||r()}},handleInput:()=>{(m()||!w())&&v()}}})(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tr(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({editor:n},a)));return!function(e,t,r){var[a]=(0,d.useState)(()=>new MutationObserver(t));eL(()=>{a.takeRecords()}),(0,d.useEffect)(()=>{if(!e.current)throw Error("Failed to attach MutationObserver, `node` is undefined");return a.observe(e.current,r),()=>a.disconnect()},[])}(r,i.handleDomMutations,ta),R.set(n,i.scheduleFlush),o&&i.flush(),i}({node:Q,onDOMSelectionChange:ec,scheduleOnDOMSelectionChange:ef});eL(()=>{Q.current&&(e=$(Q.current))?(k.set(J,e),x.set(J,Q.current),L.set(J,Q.current),E.set(Q.current,J)):L.delete(J);var e,{selection:t}=J,r=ew.findDocumentOrShadowRoot(J).getSelection();if(!(!r||!ew.isFocused(J)||null!=eb&&eb.hasPendingAction())){var a=e=>{var a="None"!==r.type;if(t||a){var n=x.get(J),o=!1;if(n.contains(r.anchorNode)&&n.contains(r.focusNode)&&(o=!0),a&&o&&t&&!e){var i=ew.toSlateRange(J,r,{exactMatch:!0,suppressThrow:!0});if(i&&u.e6.equals(i,t)){if(!ei.hasMarkPlaceholder)return;var s,{anchorNode:l}=r;if(null!=l&&null!==(s=l.parentElement)&&void 0!==s&&s.hasAttribute("data-slate-mark-placeholder"))return}}if(t&&!ew.hasRange(J,t)){J.selection=ew.toSlateRange(J,r,{exactMatch:!1,suppressThrow:!0});return}ei.isUpdatingSelection=!0;var d=t&&ew.toDOMRange(J,t);return d?(u.e6.isBackward(t)?r.setBaseAndExtent(d.endContainer,d.endOffset,d.startContainer,d.startOffset):r.setBaseAndExtent(d.startContainer,d.startOffset,d.endContainer,d.endOffset),D(J,d)):r.removeAllRanges(),d}},n=a(),o=(null==eb?void 0:eb.isFlushing())==="action";if(!es||!o){setTimeout(()=>{n&&el&&ew.toDOMNode(J,J).focus(),ei.isUpdatingSelection=!1});return}var i=null,s=requestAnimationFrame(()=>{if(o){var e=e=>{try{ew.toDOMNode(J,J).focus(),a(e)}catch(e){}};e(),i=setTimeout(()=>{e(!0),ei.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(s),i&&clearTimeout(i)}}});var eM=(0,d.useCallback)(e=>{if(et(),!w&&ew.hasEditableTarget(J,e.target)&&!th(e,h)){if(eb)return eb.handleDOMBeforeInput(e);ef.flush(),ec.flush();var{selection:t}=J,{inputType:r}=e,a=e.dataTransfer||e.data||void 0,n="insertCompositionText"===r||"deleteCompositionText"===r;if(!(n&&ew.isComposing(J))){var o=!1;if("insertText"===r&&t&&u.e6.isCollapsed(t)&&e.data&&1===e.data.length&&/[a-z ]/i.test(e.data)&&0!==t.anchor.offset){o=!0,J.marks&&(o=!1);var{anchor:i}=t,[s,l]=ew.toDOMPoint(J,i),d=null===(v=s.parentElement)||void 0===v?void 0:v.closest("a"),c=ew.getWindow(J);if(o&&d&&ew.hasDOMNode(J,d)){var f,v,p,g,m=null==c?void 0:c.document.createTreeWalker(d,NodeFilter.SHOW_TEXT).lastChild();m===s&&(null===(g=m.textContent)||void 0===g?void 0:g.length)===l&&(o=!1)}if(o&&s.parentElement&&(null==c?void 0:null===(p=c.getComputedStyle(s.parentElement))||void 0===p?void 0:p.whiteSpace)==="pre"){var b=u.ML.above(J,{at:i.path,match:e=>u.W_.isElement(e)&&u.ML.isBlock(J,e)});b&&u.NB.string(b[0]).includes(" ")&&(o=!1)}}if(!r.startsWith("delete")||r.startsWith("deleteBy")){var[M]=e.getTargetRanges();if(M){var k=ew.toSlateRange(J,M,{exactMatch:!1,suppressThrow:!1});if(!t||!u.e6.equals(t,k)){o=!1;var x=!n&&J.selection&&u.ML.rangeRef(J,J.selection);u.YR.select(J,k),x&&F.set(J,x)}}}if(!n){if(o||e.preventDefault(),t&&u.e6.isExpanded(t)&&r.startsWith("delete")){var y=r.endsWith("Backward")?"backward":"forward";u.ML.deleteFragment(J,{direction:y});return}switch(r){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":u.ML.deleteFragment(J);break;case"deleteContent":case"deleteContentForward":u.ML.deleteForward(J);break;case"deleteContentBackward":u.ML.deleteBackward(J);break;case"deleteEntireSoftLine":u.ML.deleteBackward(J,{unit:"line"}),u.ML.deleteForward(J,{unit:"line"});break;case"deleteHardLineBackward":u.ML.deleteBackward(J,{unit:"block"});break;case"deleteSoftLineBackward":u.ML.deleteBackward(J,{unit:"line"});break;case"deleteHardLineForward":u.ML.deleteForward(J,{unit:"block"});break;case"deleteSoftLineForward":u.ML.deleteForward(J,{unit:"line"});break;case"deleteWordBackward":u.ML.deleteBackward(J,{unit:"word"});break;case"deleteWordForward":u.ML.deleteForward(J,{unit:"word"});break;case"insertLineBreak":u.ML.insertSoftBreak(J);break;case"insertParagraph":u.ML.insertBreak(J);break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":"insertFromComposition"===r&&ew.isComposing(J)&&(G(!1),B.set(J,!1)),(null==a?void 0:a.constructor.name)==="DataTransfer"?ew.insertData(J,a):"string"==typeof a&&(o?ee.current.push(()=>u.ML.insertText(J,a)):u.ML.insertText(J,a))}var E=null===(f=F.get(J))||void 0===f?void 0:f.unref();F.delete(J),!E||J.selection&&u.e6.equals(J.selection,E)||u.YR.select(J,E)}}}},[w,h]),ek=(0,d.useCallback)(e=>{null==e&&(x.delete(J),L.delete(J),em&&Q.current.removeEventListener("beforeinput",eM)),Q.current=e},[Q,eM]);eL(()=>(Q.current&&em&&Q.current.addEventListener("beforeinput",eM),()=>{Q.current&&em&&Q.current.removeEventListener("beforeinput",eM)}),[eM]),eL(()=>{var e=ew.getWindow(J);return e.document.addEventListener("selectionchange",ef),()=>{e.document.removeEventListener("selectionchange",ef)}},[ef]);var ex=v([J,[]]);if(m&&1===J.children.length&&1===Array.from(u.NB.texts(J)).length&&""===u.NB.string(J)&&!Z){var ey=u.ML.start(J,[]);ex.push({[q]:!0,placeholder:m,anchor:ey,focus:ey})}var{marks:eE}=J;if(ei.hasMarkPlaceholder=!1,J.selection&&u.e6.isCollapsed(J.selection)&&eE){var{anchor:eC}=J.selection,eD=u.NB.leaf(J,eC.path),eO=g(eD,to);if(!u.xv.equals(eD,eE,{loose:!0})){ei.hasMarkPlaceholder=!0;var eS=Object.fromEntries(Object.keys(eO).map(e=>[e,null]));ex.push(ts(ts(ts({[Y]:!0},eS),eE),{},{anchor:eC,focus:eC}))}}(0,d.useEffect)(()=>{setTimeout(()=>{var{selection:e}=J;if(e){var{anchor:t}=e,r=u.NB.leaf(J,t.path);if(eE&&!u.xv.equals(r,eE,{loose:!0})){P.set(J,eE);return}}P.delete(J)})});var eF=null===(s=y.get(J))||void 0===s?void 0:null===(c=s.getBoundingClientRect())||void 0===c?void 0:c.height;return d.createElement(eU.Provider,{value:w},d.createElement(eI.Provider,{value:v},d.createElement(e6,{node:Q,receivedUserInput:er},d.createElement(_,Object.assign({role:w?void 0:"textbox","aria-multiline":!w||void 0},H,{spellCheck:(!!em||!eg)&&H.spellCheck,autoCorrect:em||!eg?H.autoCorrect:"false",autoCapitalize:em||!eg?H.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!w,zindex:-1,suppressContentEditableWarning:!0,ref:ek,style:ts(ts({},U?{}:ts({position:"relative",outline:"none",whiteSpace:"pre-wrap",wordWrap:"break-word"},eF?{minHeight:eF}:{})),T),onBeforeInput:(0,d.useCallback)(e=>{if(!em&&!w&&!tv(e,H.onBeforeInput)&&ew.hasSelectableTarget(J,e.target)&&(e.preventDefault(),!ew.isComposing(J))){var t=e.data;u.ML.insertText(J,t)}},[w]),onInput:(0,d.useCallback)(e=>{if(eb){eb.handleInput();return}for(var t of ee.current)t();ee.current=[]},[]),onBlur:(0,d.useCallback)(e=>{if(!(w||ei.isUpdatingSelection||!ew.hasSelectableTarget(J,e.target)||tv(e,H.onBlur))){var t=ew.findDocumentOrShadowRoot(J);if(ei.latestElement!==t.activeElement){var{relatedTarget:r}=e;if(!(r===ew.toDOMNode(J,J)||z(r)&&r.hasAttribute("data-slate-spacer"))){if(null!=r&&V(r)&&ew.hasDOMNode(J,r)){var a=ew.toSlateNode(J,r);if(u.W_.isElement(a)&&!J.isVoid(a))return}if(ed){var n=t.getSelection();null==n||n.removeAllRanges()}S.delete(J)}}}},[w,H.onBlur]),onClick:(0,d.useCallback)(e=>{if(ew.hasTarget(J,e.target)&&!tv(e,H.onClick)&&V(e.target)){var t=ew.toSlateNode(J,e.target),r=ew.findPath(J,t);if(u.ML.hasPath(J,r)&&u.NB.get(J,r)===t){if(3===e.detail&&r.length>=1){var a=r;if(!(u.W_.isElement(t)&&u.ML.isBlock(J,t))){var n,o=u.ML.above(J,{match:e=>u.W_.isElement(e)&&u.ML.isBlock(J,e),at:r});a=null!==(n=null==o?void 0:o[1])&&void 0!==n?n:r.slice(0,1)}var i=u.ML.range(J,a);u.YR.select(J,i);return}if(!w){var s=u.ML.start(J,r),l=u.ML.end(J,r),d=u.ML.void(J,{at:s}),c=u.ML.void(J,{at:l});if(d&&c&&u.y$.equals(d[1],c[1])){var f=u.ML.range(J,s);u.YR.select(J,f)}}}}},[w,H.onClick]),onCompositionEnd:(0,d.useCallback)(e=>{if(ew.hasSelectableTarget(J,e.target)&&(ew.isComposing(J)&&(G(!1),B.set(J,!1)),null==eb||eb.handleCompositionEnd(e),!tv(e,H.onCompositionEnd)&&!es&&!ed&&!ev&&!eo&&!ep&&!eh&&e.data)){var t=P.get(J);P.delete(J),void 0!==t&&(N.set(J,J.marks),J.marks=t),u.ML.insertText(J,e.data);var r=N.get(J);N.delete(J),void 0!==r&&(J.marks=r)}},[H.onCompositionEnd]),onCompositionUpdate:(0,d.useCallback)(e=>{!ew.hasSelectableTarget(J,e.target)||tv(e,H.onCompositionUpdate)||ew.isComposing(J)||(G(!0),B.set(J,!0))},[H.onCompositionUpdate]),onCompositionStart:(0,d.useCallback)(e=>{if(ew.hasSelectableTarget(J,e.target)&&(null==eb||eb.handleCompositionStart(e),!tv(e,H.onCompositionStart)&&!es)){G(!0);var{selection:t}=J;if(t){if(u.e6.isExpanded(t)){u.ML.deleteFragment(J);return}var r=u.ML.above(J,{match:e=>u.W_.isElement(e)&&u.ML.isInline(J,e),mode:"highest"});if(r){var[,a]=r;if(u.ML.isEnd(J,t.anchor,a)){var n=u.ML.after(J,a);u.YR.setSelection(J,{anchor:n,focus:n})}}}}},[H.onCompositionStart]),onCopy:(0,d.useCallback)(e=>{ew.hasSelectableTarget(J,e.target)&&!tv(e,H.onCopy)&&(e.preventDefault(),ew.setFragmentData(J,e.clipboardData,"copy"))},[H.onCopy]),onCut:(0,d.useCallback)(e=>{if(!w&&ew.hasSelectableTarget(J,e.target)&&!tv(e,H.onCut)){e.preventDefault(),ew.setFragmentData(J,e.clipboardData,"cut");var{selection:t}=J;if(t){if(u.e6.isExpanded(t))u.ML.deleteFragment(J);else{var r=u.NB.parent(J,t.anchor.path);u.ML.isVoid(J,r)&&u.YR.delete(J)}}}},[w,H.onCut]),onDragOver:(0,d.useCallback)(e=>{if(ew.hasTarget(J,e.target)&&!tv(e,H.onDragOver)){var t=ew.toSlateNode(J,e.target);u.W_.isElement(t)&&u.ML.isVoid(J,t)&&e.preventDefault()}},[H.onDragOver]),onDragStart:(0,d.useCallback)(e=>{if(!w&&ew.hasTarget(J,e.target)&&!tv(e,H.onDragStart)){var t=ew.toSlateNode(J,e.target),r=ew.findPath(J,t);if(u.W_.isElement(t)&&u.ML.isVoid(J,t)||u.ML.void(J,{at:r,voids:!0})){var a=u.ML.range(J,r);u.YR.select(J,a)}ei.isDraggingInternally=!0,ew.setFragmentData(J,e.dataTransfer,"drag")}},[w,H.onDragStart]),onDrop:(0,d.useCallback)(e=>{if(!w&&ew.hasTarget(J,e.target)&&!tv(e,H.onDrop)){e.preventDefault();var t=J.selection,r=ew.findEventRange(J,e),a=e.dataTransfer;u.YR.select(J,r),ei.isDraggingInternally&&t&&!u.e6.equals(t,r)&&!u.ML.void(J,{at:r,voids:!0})&&u.YR.delete(J,{at:t}),ew.insertData(J,a),ew.isFocused(J)||ew.focus(J)}ei.isDraggingInternally=!1},[w,H.onDrop]),onDragEnd:(0,d.useCallback)(e=>{!w&&ei.isDraggingInternally&&H.onDragEnd&&ew.hasTarget(J,e.target)&&H.onDragEnd(e),ei.isDraggingInternally=!1},[w,H.onDragEnd]),onFocus:(0,d.useCallback)(e=>{if(!w&&!ei.isUpdatingSelection&&ew.hasEditableTarget(J,e.target)&&!tv(e,H.onFocus)){var t=ew.toDOMNode(J,J),r=ew.findDocumentOrShadowRoot(J);if(ei.latestElement=r.activeElement,el&&e.target!==t){t.focus();return}S.set(J,!0)}},[w,H.onFocus]),onKeyDown:(0,d.useCallback)(e=>{if(!w&&ew.hasEditableTarget(J,e.target)){null==eb||eb.handleKeyDown(e);var{nativeEvent:t}=e;if(ew.isComposing(J)&&!1===t.isComposing&&(B.set(J,!1),G(!1)),!(tv(e,H.onKeyDown)||ew.isComposing(J))){var{selection:r}=J,a=J.children[null!==r?r.focus.path[0]:0],o="rtl"===n()(u.NB.string(a));if(eG.isRedo(t)){e.preventDefault(),"function"==typeof J.redo&&J.redo();return}if(eG.isUndo(t)){e.preventDefault(),"function"==typeof J.undo&&J.undo();return}if(eG.isMoveLineBackward(t)){e.preventDefault(),u.YR.move(J,{unit:"line",reverse:!0});return}if(eG.isMoveLineForward(t)){e.preventDefault(),u.YR.move(J,{unit:"line"});return}if(eG.isExtendLineBackward(t)){e.preventDefault(),u.YR.move(J,{unit:"line",edge:"focus",reverse:!0});return}if(eG.isExtendLineForward(t)){e.preventDefault(),u.YR.move(J,{unit:"line",edge:"focus"});return}if(eG.isMoveBackward(t)){e.preventDefault(),r&&u.e6.isCollapsed(r)?u.YR.move(J,{reverse:!o}):u.YR.collapse(J,{edge:"start"});return}if(eG.isMoveForward(t)){e.preventDefault(),r&&u.e6.isCollapsed(r)?u.YR.move(J,{reverse:o}):u.YR.collapse(J,{edge:"end"});return}if(eG.isMoveWordBackward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)&&u.YR.collapse(J,{edge:"focus"}),u.YR.move(J,{unit:"word",reverse:!o});return}if(eG.isMoveWordForward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)&&u.YR.collapse(J,{edge:"focus"}),u.YR.move(J,{unit:"word",reverse:o});return}if(em){if((eu||ed)&&r&&(eG.isDeleteBackward(t)||eG.isDeleteForward(t))&&u.e6.isCollapsed(r)){var i=u.NB.parent(J,r.anchor.path);if(u.W_.isElement(i)&&u.ML.isVoid(J,i)&&(u.ML.isInline(J,i)||u.ML.isBlock(J,i))){e.preventDefault(),u.ML.deleteBackward(J,{unit:"block"});return}}}else{if(eG.isBold(t)||eG.isItalic(t)||eG.isTransposeCharacter(t)){e.preventDefault();return}if(eG.isSoftBreak(t)){e.preventDefault(),u.ML.insertSoftBreak(J);return}if(eG.isSplitBlock(t)){e.preventDefault(),u.ML.insertBreak(J);return}if(eG.isDeleteBackward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)?u.ML.deleteFragment(J,{direction:"backward"}):u.ML.deleteBackward(J);return}if(eG.isDeleteForward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)?u.ML.deleteFragment(J,{direction:"forward"}):u.ML.deleteForward(J);return}if(eG.isDeleteLineBackward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)?u.ML.deleteFragment(J,{direction:"backward"}):u.ML.deleteBackward(J,{unit:"line"});return}if(eG.isDeleteLineForward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)?u.ML.deleteFragment(J,{direction:"forward"}):u.ML.deleteForward(J,{unit:"line"});return}if(eG.isDeleteWordBackward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)?u.ML.deleteFragment(J,{direction:"backward"}):u.ML.deleteBackward(J,{unit:"word"});return}if(eG.isDeleteWordForward(t)){e.preventDefault(),r&&u.e6.isExpanded(r)?u.ML.deleteFragment(J,{direction:"forward"}):u.ML.deleteForward(J,{unit:"word"});return}}}}},[w,H.onKeyDown]),onPaste:(0,d.useCallback)(e=>{!w&&ew.hasEditableTarget(J,e.target)&&!tv(e,H.onPaste)&&(!em||X(e.nativeEvent))&&(e.preventDefault(),ew.insertData(J,e.clipboardData))},[w,H.onPaste])}),d.createElement(tl,{decorations:ex,node:J,renderElement:b,renderPlaceholder:C,renderLeaf:M,selection:J.selection})))))},tc=e=>{var{attributes:t,children:r}=e;return d.createElement("span",Object.assign({},t),r,es&&d.createElement("br",null))},tu=()=>[],tf=(e,t)=>{if(t.getBoundingClientRect&&(!e.selection||e.selection&&u.e6.isCollapsed(e.selection))){var r=t.startContainer.parentElement;r.getBoundingClientRect=t.getBoundingClientRect.bind(t),(0,c.Z)(r,{scrollMode:"if-needed"}),delete r.getBoundingClientRect}},tv=(e,t)=>{if(!t)return!1;var r=t(e);return null!=r?r:e.isDefaultPrevented()||e.isPropagationStopped()},th=(e,t)=>{if(!t)return!1;var r=t(e);return null!=r?r:e.defaultPrevented},tp=(0,d.createContext)(!1),tg=()=>(0,d.useContext)(tp),tm=(0,d.createContext)({}),tw=["editor","children","onChange","value"],tb=e=>{var t,r,a,{editor:n,children:o,onChange:i,value:s}=e,l=g(e,tw),c=(0,d.useRef)(!1),[f,v]=d.useState(()=>{if(!u.NB.isNodeList(s))throw Error("[Slate] value is invalid! Expected a list of elements but got: ".concat(u.o4.stringify(s)));if(!u.ML.isEditor(n))throw Error("[Slate] editor is invalid! You passed: ".concat(u.o4.stringify(n)));return n.children=s,Object.assign(n,l),{v:0,editor:n}}),{selectorContext:h,onChange:p}=(t=(0,d.useRef)([]).current,r=(0,d.useRef)({editor:n}).current,a=(0,d.useCallback)(e=>{r.editor=e,t.forEach(t=>t(e))},[]),{selectorContext:(0,d.useMemo)(()=>({getSlate:()=>r.editor,addEventListener:e=>(t.push(e),()=>{t.splice(t.indexOf(e),1)})}),[t,r]),onChange:a}),m=(0,d.useCallback)(()=>{i&&i(n.children),v(e=>({v:e.v+1,editor:n})),p(n)},[i]);(0,d.useEffect)(()=>(T.set(n,m),()=>{T.set(n,()=>{}),c.current=!0}),[m]);var[w,b]=(0,d.useState)(ew.isFocused(n));return(0,d.useEffect)(()=>{b(ew.isFocused(n))}),eL(()=>{var e=()=>b(ew.isFocused(n));return en?(document.addEventListener("focusin",e),document.addEventListener("focusout",e),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",e)}):(document.addEventListener("focus",e,!0),document.addEventListener("blur",e,!0),()=>{document.removeEventListener("focus",e,!0),document.removeEventListener("blur",e,!0)})},[]),d.createElement(tm.Provider,{value:h},d.createElement(eV.Provider,{value:f},d.createElement(eS.Provider,{value:f.editor},d.createElement(tp.Provider,{value:w},o))))},tM=(e,t)=>{var r=(t.top+t.bottom)/2;return e.top<=r&&e.bottom>=r},tk=(e,t,r)=>{var a=ew.toDOMRange(e,t).getBoundingClientRect(),n=ew.toDOMRange(e,r).getBoundingClientRect();return tM(a,n)&&tM(n,a)},tx=(e,t)=>{var r=u.ML.range(e,u.e6.end(t)),a=Array.from(u.ML.positions(e,{at:t})),n=0,o=a.length,i=Math.floor(o/2);if(tk(e,u.ML.range(e,a[n]),r))return u.ML.range(e,a[n],r);if(a.length<2)return u.ML.range(e,a[a.length-1],r);for(;i!==a.length&&i!==n;)tk(e,u.ML.range(e,a[i]),r)?o=i:n=i,i=Math.floor((n+o)/2);return u.ML.range(e,a[o],r)};function ty(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,a)}return r}function tE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ty(Object(r),!0).forEach(function(t){p(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ty(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var tL=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x-slate-fragment",r=e,{apply:a,onChange:n,deleteBackward:o,addMark:i,removeMark:s}=r;return D.set(r,new WeakMap),r.addMark=(e,t)=>{var a,n;null===(a=R.get(r))||void 0===a||a(),!P.get(r)&&null!==(n=W.get(r))&&void 0!==n&&n.length&&P.set(r,null),N.delete(r),i(e,t)},r.removeMark=e=>{var t;!P.get(r)&&null!==(t=W.get(r))&&void 0!==t&&t.length&&P.set(r,null),N.delete(r),s(e)},r.deleteBackward=e=>{if("line"!==e)return o(e);if(r.selection&&u.e6.isCollapsed(r.selection)){var t=u.ML.above(r,{match:e=>u.W_.isElement(e)&&u.ML.isBlock(r,e),at:r.selection});if(t){var[,a]=t,n=u.ML.range(r,a,r.selection.anchor),i=tx(r,n);u.e6.isCollapsed(i)||u.YR.delete(r,{at:i})}}},r.apply=e=>{var t,n=[],o=W.get(r);if(null!=o&&o.length){var i=o.map(t=>(function(e,t){var{path:r,diff:a,id:n}=e;switch(t.type){case"insert_text":if(!u.y$.equals(t.path,r)||t.offset>=a.end)return e;if(t.offset<=a.start)return{diff:{start:t.text.length+a.start,end:t.text.length+a.end,text:a.text},id:n,path:r};return{diff:{start:a.start,end:a.end+t.text.length,text:a.text},id:n,path:r};case"remove_text":if(!u.y$.equals(t.path,r)||t.offset>=a.end)return e;if(t.offset+t.text.length<=a.start)return{diff:{start:a.start-t.text.length,end:a.end-t.text.length,text:a.text},id:n,path:r};return{diff:{start:a.start,end:a.end-t.text.length,text:a.text},id:n,path:r};case"split_node":if(!u.y$.equals(t.path,r)||t.position>=a.end)return{diff:a,id:n,path:u.y$.transform(r,t,{affinity:"backward"})};if(t.position>a.start)return{diff:{start:a.start,end:Math.min(t.position,a.end),text:a.text},id:n,path:r};return{diff:{start:a.start-t.position,end:a.end-t.position,text:a.text},id:n,path:u.y$.transform(r,t,{affinity:"forward"})};case"merge_node":if(!u.y$.equals(t.path,r))return{diff:a,id:n,path:u.y$.transform(r,t)};return{diff:{start:a.start+t.position,end:a.end+t.position,text:a.text},id:n,path:u.y$.transform(r,t)}}var o=u.y$.transform(r,t);return o?{diff:a,path:o,id:n}:null})(t,e)).filter(Boolean);W.set(r,i)}var s=A.get(r);s&&A.set(r,e4(r,s,e));var l=j.get(r);if(null!=l&&l.at){var d=u.E9.isPoint(null==l?void 0:l.at)?e7(r,l.at,e):e4(r,l.at,e);j.set(r,d?tE(tE({},l),{},{at:d}):null)}switch(e.type){case"insert_text":case"remove_text":case"set_node":case"split_node":n.push(...tC(r,e.path));break;case"set_selection":null===(t=F.get(r))||void 0===t||t.unref(),F.delete(r);break;case"insert_node":case"remove_node":n.push(...tC(r,u.y$.parent(e.path)));break;case"merge_node":n.push(...tC(r,u.y$.previous(e.path)));break;case"move_node":n.push(...tC(r,u.y$.common(u.y$.parent(e.path),u.y$.parent(e.newPath))))}for(var[c,f]of(a(e),n)){var[v]=u.ML.node(r,c);C.set(v,f)}},r.setFragmentData=e=>{var{selection:a}=r;if(a){var[n,o]=u.e6.edges(a),i=u.ML.void(r,{at:n.path}),s=u.ML.void(r,{at:o.path});if(!u.e6.isCollapsed(a)||i){var l=ew.toDOMRange(r,a),d=l.cloneContents(),c=d.childNodes[0];if(d.childNodes.forEach(e=>{e.textContent&&""!==e.textContent.trim()&&(c=e)}),s){var[f]=s,v=l.cloneRange(),h=ew.toDOMNode(r,f);v.setEndAfter(h),d=v.cloneContents()}if(i&&(c=d.querySelector("[data-slate-spacer]")),Array.from(d.querySelectorAll("[data-slate-zero-width]")).forEach(e=>{var t="n"===e.getAttribute("data-slate-zero-width");e.textContent=t?"\n":""}),H(c)){var p=c.ownerDocument.createElement("span");p.style.whiteSpace="pre",p.appendChild(c),d.appendChild(p),c=p}var g=JSON.stringify(r.getFragment()),m=window.btoa(encodeURIComponent(g));c.setAttribute("data-slate-fragment",m),e.setData("application/".concat(t),m);var w=d.ownerDocument.createElement("div");return w.appendChild(d),w.setAttribute("hidden","true"),d.ownerDocument.body.appendChild(w),e.setData("text/html",w.innerHTML),e.setData("text/plain",ee(w)),d.ownerDocument.body.removeChild(w),e}}},r.insertData=e=>{r.insertFragmentData(e)||r.insertTextData(e)},r.insertFragmentData=e=>{var a=e.getData("application/".concat(t))||er(e);if(a){var n=JSON.parse(decodeURIComponent(window.atob(a)));return r.insertFragment(n),!0}return!1},r.insertTextData=e=>{var t=e.getData("text/plain");if(t){var a=t.split(/\r\n|\r|\n/),n=!1;for(var o of a)n&&u.YR.splitNodes(r,{always:!0}),r.insertText(o),n=!0;return!0}return!1},r.onChange=e=>{h.unstable_batchedUpdates(()=>{var t=T.get(r);t&&t(),n(e)})},r},tC=(e,t)=>{var r=[];for(var[a,n]of u.ML.levels(e,{at:t})){var o=ew.findKey(e,a);r.push([n,o])}return r}}}]);