slate-react 0.147.2 → 0.147.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/android-input-manager/android-input-manager.d.ts.map +1 -1
- package/dist/index.es.js +10 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +12 -1
- package/dist/slate-react.min.js +1 -1
- package/package.json +2 -2
package/dist/slate-react.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("slate")):"function"==typeof define&&define.amd?define(["exports","react","slate"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SlateReact={},e.React,e.Slate)}(this,(function(e,t,n){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}var a=i((function(e){e.exports=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n},e.exports.__esModule=!0,e.exports.default=e.exports}));o(a);var s=i((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o=a(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports})),l=o(s),c=i((function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));o(c);var u=i((function(e){var t=c.default;e.exports=function(e,n){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,n||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));o(u);var d=i((function(e){var t=c.default;e.exports=function(e){var n=u(e,"string");return"symbol"==t(n)?n:n+""},e.exports.__esModule=!0,e.exports.default=e.exports}));o(d);var f=i((function(e){e.exports=function(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports})),h=o(f),p=i((function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}));o(p);var v=i((function(e){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports}));o(v);var g=i((function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}));o(g);var m=i((function(e){e.exports=function(e,t){if(e){if("string"==typeof e)return g(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}));o(m);var y=i((function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}));o(y);var b=i((function(e){e.exports=function(e,t){return p(e)||v(e,t)||m(e,t)||y()},e.exports.__esModule=!0,e.exports.default=e.exports})),w=o(b),E=function(e){if(e=String(e||""),k.test(e))return"rtl";if(C.test(e))return"ltr";return"neutral"},x="֑-߿יִ-﷽ﹰ-ﻼ",O="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",k=new RegExp("^[^"+O+"]*["+x+"]"),C=new RegExp("^[^"+x+"]*["+O+"]");var S=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},T="object"==typeof r&&r&&r.Object===Object&&r,P="object"==typeof self&&self&&self.Object===Object&&self,D=T||P||Function("return this")(),R=function(){return D.Date.now()},N=/\s/;var M=function(e){for(var t=e.length;t--&&N.test(e.charAt(t)););return t},j=/^\s+/;var B=function(e){return e?e.slice(0,M(e)+1).replace(j,""):e},A=D.Symbol,_=Object.prototype,F=_.hasOwnProperty,I=_.toString,L=A?A.toStringTag:void 0;var W=function(e){var t=F.call(e,L),n=e[L];try{e[L]=void 0;var r=!0}catch(e){}var o=I.call(e);return r&&(t?e[L]=n:delete e[L]),o},z=Object.prototype.toString;var U=function(e){return z.call(e)},q=A?A.toStringTag:void 0;var V=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":q&&q in Object(e)?W(e):U(e)};var K=function(e){return null!=e&&"object"==typeof e};var H=function(e){return"symbol"==typeof e||K(e)&&"[object Symbol]"==V(e)},$=/^[-+]0x[0-9a-f]+$/i,X=/^0b[01]+$/i,G=/^0o[0-7]+$/i,Y=parseInt;var J=function(e){if("number"==typeof e)return e;if(H(e))return NaN;if(S(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=S(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=B(e);var n=X.test(e);return n||G.test(e)?Y(e.slice(2),n?2:8):$.test(e)?NaN:+e},Z=Math.max,Q=Math.min;var ee=function(e,t,n){var r,o,i,a,s,l,c=0,u=!1,d=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=r,i=o;return r=o=void 0,c=t,a=e.apply(i,n)}function p(e){return c=e,s=setTimeout(g,t),u?h(e):a}function v(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function g(){var e=R();if(v(e))return m(e);s=setTimeout(g,function(e){var n=t-(e-l);return d?Q(n,i-(e-c)):n}(e))}function m(e){return s=void 0,f&&r?h(e):(r=o=void 0,a)}function y(){var e=R(),n=v(e);if(r=arguments,o=this,l=e,n){if(void 0===s)return p(l);if(d)return clearTimeout(s),s=setTimeout(g,t),h(l)}return void 0===s&&(s=setTimeout(g,t)),a}return t=J(t)||0,S(n)&&(u=!!n.leading,i=(d="maxWait"in n)?Z(J(n.maxWait)||0,t):i,f="trailing"in n?!!n.trailing:f),y.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=o=s=void 0},y.flush=function(){return void 0===s?a:m(R())},y};var te=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return S(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),ee(e,t,{leading:r,maxWait:t,trailing:o})};const ne=e=>"object"==typeof e&&null!=e&&1===e.nodeType,re=(e,t)=>(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e,oe=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return re(n.overflowY,t)||re(n.overflowX,t)||(e=>{const t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},ie=(e,t,n,r,o,i,a,s)=>i<e&&a>t||i>e&&a<t?0:i<=e&&s<=n||a>=t&&s>=n?i-e-r:a>t&&s<n||i<e&&s>n?a-t+o:0,ae=e=>{const t=e.parentElement;return null==t?e.getRootNode().host||null:t},se=(e,t)=>{var n,r,o,i;if("undefined"==typeof document)return[];const{scrollMode:a,block:s,inline:l,boundary:c,skipOverflowHiddenElements:u}=t,d="function"==typeof c?c:e=>e!==c;if(!ne(e))throw new TypeError("Invalid target");const f=document.scrollingElement||document.documentElement,h=[];let p=e;for(;ne(p)&&d(p);){if(p=ae(p),p===f){h.push(p);break}null!=p&&p===document.body&&oe(p)&&!oe(document.documentElement)||null!=p&&oe(p,u)&&h.push(p)}const v=null!=(r=null==(n=window.visualViewport)?void 0:n.width)?r:innerWidth,g=null!=(i=null==(o=window.visualViewport)?void 0:o.height)?i:innerHeight,{scrollX:m,scrollY:y}=window,{height:b,width:w,top:E,right:x,bottom:O,left:k}=e.getBoundingClientRect(),{top:C,right:S,bottom:T,left:P}=(e=>{const t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);let D="start"===s||"nearest"===s?E-C:"end"===s?O+T:E+b/2-C+T,R="center"===l?k+w/2-P+S:"end"===l?x+S:k-P;const N=[];for(let e=0;e<h.length;e++){const t=h[e],{height:n,width:r,top:o,right:i,bottom:c,left:u}=t.getBoundingClientRect();if("if-needed"===a&&E>=0&&k>=0&&O<=g&&x<=v&&E>=o&&O<=c&&k>=u&&x<=i)return N;const d=getComputedStyle(t),p=parseInt(d.borderLeftWidth,10),C=parseInt(d.borderTopWidth,10),S=parseInt(d.borderRightWidth,10),T=parseInt(d.borderBottomWidth,10);let P=0,M=0;const j="offsetWidth"in t?t.offsetWidth-t.clientWidth-p-S:0,B="offsetHeight"in t?t.offsetHeight-t.clientHeight-C-T:0,A="offsetWidth"in t?0===t.offsetWidth?0:r/t.offsetWidth:0,_="offsetHeight"in t?0===t.offsetHeight?0:n/t.offsetHeight:0;if(f===t)P="start"===s?D:"end"===s?D-g:"nearest"===s?ie(y,y+g,g,C,T,y+D,y+D+b,b):D-g/2,M="start"===l?R:"center"===l?R-v/2:"end"===l?R-v:ie(m,m+v,v,p,S,m+R,m+R+w,w),P=Math.max(0,P+y),M=Math.max(0,M+m);else{P="start"===s?D-o-C:"end"===s?D-c+T+B:"nearest"===s?ie(o,c,n,C,T+B,D,D+b,b):D-(o+n/2)+B/2,M="start"===l?R-u-p:"center"===l?R-(u+r/2)+j/2:"end"===l?R-i+S+j:ie(u,i,r,p,S+j,R,R+w,w);const{scrollLeft:e,scrollTop:a}=t;P=0===_?0:Math.max(0,Math.min(a+P/_,t.scrollHeight-n/_+B)),M=0===A?0:Math.max(0,Math.min(e+M/A,t.scrollWidth-r/A+j)),D+=a-P,R+=e-M}N.push({el:t,top:P,left:M})}return N};function le(e,t){if(!e.isConnected||!(e=>{let t=e;for(;t&&t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}return!1})(e))return;const n=(e=>{const t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);if((e=>"object"==typeof e&&"function"==typeof e.behavior)(t))return t.behavior(se(e,t));const r="boolean"==typeof t||null==t?void 0:t.behavior;for(const{el:o,top:i,left:a}of se(e,(e=>!1===e?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&0!==Object.keys(e).length)(e)?e:{block:"start",inline:"nearest"})(t))){const e=i-n.top+n.bottom,t=a-n.left+n.right;o.scroll({top:e,left:t,behavior:r})}}var ce=t.createContext(null),ue=function(){var e=t.useContext(ce);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},de=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});for(var n="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),r={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},o={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:n?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},i={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},a=1;a<20;a++)i["f"+a]=111+a;function s(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return l(e,t)})),o=function(e){return r.some((function(t){return c(t,e)}))};return null==n?o:o(n)}function l(e,t){var n=t&&t.byKey,a={},s=(e=e.replace("++","+add")).split("+"),l=s.length;for(var c in r)a[r[c]]=!1;var f=!0,h=!1,p=void 0;try{for(var v,g=s[Symbol.iterator]();!(f=(v=g.next()).done);f=!0){var m=v.value,y=m.endsWith("?")&&m.length>1;y&&(m=m.slice(0,-1));var b=d(m),w=r[b];if(m.length>1&&!w&&!o[m]&&!i[b])throw new TypeError('Unknown modifier: "'+m+'"');1!==l&&w||(n?a.key=b:a.which=u(m)),w&&(a[w]=!y||null)}}catch(e){h=!0,p=e}finally{try{!f&&g.return&&g.return()}finally{if(h)throw p}}return a}function c(e,t){for(var n in e){var r=e[n],o=void 0;if(null!=r&&((null!=(o="key"===n&&null!=t.key?t.key.toLowerCase():"which"===n?91===r&&93===t.which?91:t.which:t[n])||!1!==r)&&o!==r))return!1}return!0}function u(e){return e=d(e),i[e]||e.toUpperCase().charCodeAt(0)}function d(e){return e=e.toLowerCase(),e=o[e]||e}t.default=s,t.isHotkey=s,t.isCodeHotkey=function(e,t){return s(e,t)},t.isKeyHotkey=function(e,t){return s(e,{byKey:!0},t)},t.parseHotkey=l,t.compareHotkey=c,t.toKeyCode=u,t.toKeyName=d}));o(de);var fe=de.isHotkey;function he(e){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},he(e)}function pe(e){var t=function(e,t){if("object"!=he(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=he(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==he(t)?t:t+""}function ve(e,t,n){return(t=pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}de.isCodeHotkey,de.isKeyHotkey,de.parseHotkey,de.compareHotkey,de.toKeyCode,de.toKeyName;var ge=globalThis.Node,me=globalThis.Text;const ye=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,be=e=>we(e)&&1===e.nodeType,we=e=>{const t=ye(e);return!!t&&e instanceof t.Node},Ee=e=>{const t=e&&e.anchorNode&&ye(e.anchorNode);return!!t&&e instanceof t.Selection},xe=e=>we(e)&&3===e.nodeType,Oe=(e,t,n)=>{if("number"!=typeof t)throw new Error("Expected index to be a number");const{childNodes:r}=e;let o=r[t],i=t,a=!1,s=!1;for(;(we(l=o)&&8===l.nodeType||be(o)&&0===o.childNodes.length||be(o)&&"false"===o.getAttribute("contenteditable"))&&(!a||!s);)i>=r.length?(a=!0,i=t-1,n="backward"):i<0?(s=!0,i=t+1,n="forward"):(o=r[i],t=i,i+="forward"===n?1:-1);var l;return[o,t]},ke=(e,t,n)=>{const[r]=Oe(e,t,n);return r},Ce=e=>{let t="";if(xe(e)&&e.nodeValue)return e.nodeValue;if(be(e)){var n;if(e.hasAttribute("data-slate-spacer"))return t;if("BR"===e.tagName&&"n"===(null===(n=e.parentElement)||void 0===n?void 0:n.getAttribute("data-slate-zero-width")))return t;for(const n of Array.from(e.childNodes))t+=Ce(n);const r=getComputedStyle(e).getPropertyValue("display"),o="block"===r||"list"===r,i=!!e.closest('[data-slate-inline="true"]');("BR"===e.tagName||o&&!i)&&(t+="\n")}return t},Se=/<[^>]*\sdata-slate-fragment="([^"]+)"/m,Te=e=>null!=e.getSelection?e.getSelection():document.getSelection(),Pe=(e,t,n)=>{const{target:r}=t;if(be(r)&&r.matches('[contentEditable="false"]'))return!1;const{document:o}=xt.getWindow(e);if(Ne(o,r))return xt.hasDOMNode(e,r,{editable:!0});const i=n.find((({addedNodes:e,removedNodes:t})=>{for(const t of e)if(t===r||Ne(t,r))return!0;for(const e of t)if(e===r||Ne(e,r))return!0}));return!(!i||i===t)&&Pe(e,i,n)},De=(e,t)=>Boolean(e.compareDocumentPosition(t)&ge.DOCUMENT_POSITION_PRECEDING),Re=(e,t)=>{if(!e)return null;let n=e;for(;n;){if(n.matches&&n.matches(t))return n;if(n.parentElement)n=n.parentElement;else{if(!n.parentNode||!("host"in n.parentNode))return null;n=n.parentNode.host}}return null},Ne=(e,t)=>{if(!e||!t)return!1;if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;if(!n.parentNode)return!1;n="host"in n.parentNode?n.parentNode.host:n.parentNode}return!1};var Me,je;const Be="undefined"!=typeof navigator&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ae="undefined"!=typeof navigator&&/Mac OS X/.test(navigator.userAgent),_e="undefined"!=typeof navigator&&/Android/.test(navigator.userAgent),Fe="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Ie="undefined"!=typeof navigator&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),Le="undefined"!=typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),We="undefined"!=typeof navigator&&/Chrome/i.test(navigator.userAgent),ze="undefined"!=typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),Ue=_e&&"undefined"!=typeof navigator&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),qe="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),Ve="undefined"!=typeof navigator&&/.*UCBrowser/.test(navigator.userAgent),Ke="undefined"!=typeof navigator&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent)&&(!We||ze),He=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement);"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&null!==(Me=navigator.userAgent.match(/Version\/(\d+)/))&&void 0!==Me&&Me[1]&&parseInt(null===(je=navigator.userAgent.match(/Version\/(\d+)/))||void 0===je?void 0:je[1],10);const $e=!ze&&!Ue&&!Le&&"undefined"!=typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges;let Xe=0;class Ge{constructor(){ve(this,"id",void 0),this.id=""+Xe++}}const Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakMap,ot=new WeakMap,it=new WeakMap,at=new WeakMap,st=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,pt=new WeakMap,vt=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=Symbol("placeholder"),bt=Symbol("mark-placeholder");function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const xt={androidPendingDiffs:e=>pt.get(e),androidScheduleFlush:e=>{var t;null===(t=dt.get(e))||void 0===t||t()},blur:e=>{const t=xt.toDOMNode(e,e),n=xt.findDocumentOrShadowRoot(e);st.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{const{selection:t}=e,r=xt.findDocumentOrShadowRoot(e),o=Te(r);o&&o.rangeCount>0&&o.removeAllRanges(),t&&n.Transforms.deselect(e)},findDocumentOrShadowRoot:e=>{const t=xt.toDOMNode(e,e),n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},findEventRange:(e,t,r={})=>{const{suppressThrow:o=!1}=r;"nativeEvent"in t&&(t=t.nativeEvent);const{clientX:i,clientY:a,target:s}=t;if(null==i||null==a){if(o)return null;throw new Error(`Cannot resolve a Slate range from a DOM event: ${t}`)}let l,c,u;try{l=xt.toSlateNode(e,t.target)}catch(e){if(o)return null;throw e}try{c=xt.findPath(e,l)}catch(e){if(o)return null;throw e}if(n.Node.isElement(l)&&n.Editor.isVoid(e,l)){const t=s.getBoundingClientRect(),r=e.isInline(l)?i-t.left<t.left+t.width-i:a-t.top<t.top+t.height-a,o=n.Editor.point(e,c,{edge:r?"start":"end"}),u=r?n.Editor.before(e,o):n.Editor.after(e,o);if(u){return n.Editor.range(e,u)}}const{document:d}=xt.getWindow(e),f=xt.findDocumentOrShadowRoot(e),h=f===d?null:f,p=e=>{if(!e)return null;const t=d.createRange();return t.setStart(e.offsetNode,e.offset),t.setEnd(e.offsetNode,e.offset),t};if(u=h&&d.caretPositionFromPoint?p(d.caretPositionFromPoint(i,a,{shadowRoots:[h]})):d.caretRangeFromPoint?d.caretRangeFromPoint(i,a):p(d.caretPositionFromPoint(i,a)),!u){if(o)return null;throw new Error(`Cannot resolve a Slate range from a DOM event: ${t}`)}return xt.toSlateRange(e,u,{exactMatch:!1,suppressThrow:o})},findKey:(e,t)=>{let n=ot.get(t);return n||(n=new Ge,ot.set(t,n)),n},findPath:(e,t)=>{const r=[];let o=t;for(;;){const t=Ze.get(o);if(null==t){if(o===e)return r;break}const n=Je.get(o);if(null==n||t.children[n]!==o)break;r.unshift(n),o=t}const i=n.Node.findPath(e,t);if(i)return i;throw new Error(`Unable to find the path for Slate node: ${n.Scrubber.stringify(t)}`)},focus:(e,t={retries:5})=>{if(st.get(e))return;if(!xt.isMounted(e))return;if(t.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(e.operations.length>0)return void setTimeout((()=>{xt.focus(e,{retries:t.retries-1})}),10);const r=xt.toDOMNode(e,e),o=xt.findDocumentOrShadowRoot(e);if(o.activeElement!==r){const t=e.selection&&o instanceof Document?xt.toDOMRange(e,e.selection):null;if(e.selection||n.Transforms.select(e,n.Editor.start(e,[])),st.set(e,!0),r.focus({preventScroll:!0}),t){const e=Te(o);null==e||e.removeAllRanges(),null==e||e.addRange(t)}}},getWindow:e=>{const t=Qe.get(e);if(!t)throw new Error("Unable to find a host window element for this editor");return t},hasDOMNode:(e,t,n={})=>{const{editable:r=!1}=n;if(!xt.isMounted(e))return!1;const o=xt.toDOMNode(e,e);let i;try{i=be(t)?t:t.parentElement}catch(e){if(e instanceof Error&&!e.message.includes('Permission denied to access property "nodeType"'))throw e}if(!i||Re(i,"[data-slate-editor]")!==o)return!1;const a=Re(i,'[contenteditable="true" i], [contenteditable=""], [contenteditable="plaintext-only" i]'),s=a&&a!==o?Re(a,'[contenteditable="false" i]'):null;if(s&&s!==o&&Re(s,"[data-slate-editor]")===o){var l;const e=null!==(l=Re(i,'[data-slate-node="text"]'))&&void 0!==l?l:null==a?void 0:a.querySelector('[data-slate-node="text"]');if(!e||null==a||!a.contains(e)||Re(e,"[data-slate-editor]")!==o)return!1}return!(r&&!i.isContentEditable)||("boolean"==typeof i.isContentEditable&&Re(i,'[contenteditable="false"]')===o||!!i.getAttribute("data-slate-zero-width"))},hasEditableTarget:(e,t)=>we(t)&&xt.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{if("function"==typeof e.hasRange)return e.hasRange(t);const{anchor:r,focus:o}=t;return n.Editor.hasPath(e,r.path)&&n.Editor.hasPath(e,o.path)},hasSelectableTarget:(e,t)=>xt.hasEditableTarget(e,t)||xt.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>we(t)&&xt.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!lt.get(e),getWord:(e,t={})=>{var r,o;if("function"!=typeof n.Editor.word)throw new Error("DOMEditor.getWord needs slate 0.136.0 or later");const i=xt.isComposing(e)?kt(e):void 0,a=null!==(r=null==i?void 0:i.view)&&void 0!==r?r:e,s=n.Editor.word(a,Et(Et({},t),{},{at:null!==(o=t.at)&&void 0!==o?o:null==i?void 0:i.point}));return s&&{range:s,text:n.Editor.string(a,s)}},isFocused:e=>!!st.get(e),isMounted:e=>!!et.get(e),isReadOnly:e=>!!at.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(at.get(e))return!1;if(!xt.hasTarget(e,t))return!1;const r=xt.toSlateNode(e,t);return n.Node.isElement(r)&&n.Editor.isVoid(e,r)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{const r=xt.resolveDOMNode(e,t);if(!r)throw new Error(`Cannot resolve a DOM node from Slate node: ${n.Scrubber.stringify(t)}`);return r},resolveDOMPoint:(e,t)=>{var r;if(!n.Node.has(e,t.path))return null;const o=null===(r=it.get(e))||void 0===r?void 0:r.get(xt.findKey(e,n.Node.get(e,t.path)));return o?Tt(e,o,t):null},resolveDOMRange:(e,t)=>{var r,o;const i=xt.resolveDOMPoint(e,t.anchor);if(!i)return null;const a=n.Range.isCollapsed(t)?i:xt.resolveDOMPoint(e,t.focus),s=null!==(r=Qe.get(e))&&void 0!==r?r:null===(o=i[0].ownerDocument)||void 0===o?void 0:o.defaultView;if(!a||!s)return null;try{return Pt(s,i,a,n.Range.isBackward(t))}catch(e){return null}},resolveEventRange:(e,t)=>xt.findEventRange(e,t,{suppressThrow:!0}),resolveDOMNode:(e,t)=>{var n,r;return null!==(n=t===e?et.get(e):null===(r=it.get(e))||void 0===r?void 0:r.get(xt.findKey(e,t)))&&void 0!==n?n:null},resolveSlateNode:(e,t)=>{var n;const r=Ct(t);return null!==(n=r&&nt.get(r))&&void 0!==n?n:null},resolveSlatePoint:(e,t,n={})=>{try{var r;return xt.toSlatePoint(e,t,{exactMatch:null!==(r=n.exactMatch)&&void 0!==r&&r,searchDirection:n.searchDirection,suppressThrow:!0})}catch(e){return null}},resolveSlateRange:(e,t,n={})=>{try{var r;return xt.toSlateRange(e,t,{exactMatch:null!==(r=n.exactMatch)&&void 0!==r&&r,suppressThrow:!0})}catch(e){return null}},toDOMPoint:(e,t)=>{const[r]=n.Editor.node(e,t.path),o=xt.toDOMNode(e,r),i=Tt(e,o,t);if(!i)throw new Error(St(t));return i},toDOMRange:(e,t)=>{const{anchor:r,focus:o}=t,i=xt.toDOMPoint(e,r),a=n.Range.isCollapsed(t)?i:xt.toDOMPoint(e,o);return Pt(xt.getWindow(e),i,a,n.Range.isBackward(t))},toSlateNode:(e,t)=>{const n=Ct(t),r=n?nt.get(n):null;if(!r)throw new Error(`Cannot resolve a Slate node from DOM node: ${n}`);return r},toSlatePoint:(e,t,r)=>{const{exactMatch:o,suppressThrow:i}=r,[a,s]=o?t:(e=>{let[t,n]=e;if(be(t)&&t.childNodes.length){let e=n===t.childNodes.length,r=e?n-1:n;for([t,r]=Oe(t,r,e?"backward":"forward"),e=r<n;be(t)&&t.childNodes.length;){const n=e?t.childNodes.length-1:0;t=ke(t,n,e?"backward":"forward")}n=e&&null!=t.textContent?t.textContent.length:0}return[t,n]})(t),l=a.parentNode;let c,u,d=r.searchDirection,f=null,h=0;if(l){var p,v;const t=xt.toDOMNode(e,e),n=l.closest('[data-slate-void="true"]'),r=n&&Ne(t,n)?n:null,i=l.closest('[contenteditable="false"]'),c=i&&Ne(t,i)?i:null;let u=l.closest("[data-slate-leaf]"),y=null;if(u){if(f=u.closest('[data-slate-node="text"]'),f){const t=xt.getWindow(e).document.createRange();t.setStart(f,0),t.setEnd(a,l.hasAttribute("data-slate-trailing")&&a===l.lastChild&&"\n"===a.textContent?0:s);const n=t.cloneContents();[...Array.prototype.slice.call(n.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(n.querySelectorAll("[contenteditable=false]"))].forEach((e=>{_e&&!o&&e.hasAttribute("data-slate-zero-width")&&e.textContent.length>0&&"\ufeff"!==e.textContext?e.textContent.startsWith("\ufeff")&&(e.textContent=e.textContent.slice(1)):e.parentNode.removeChild(e)})),h=n.textContent.length,y=f}}else if(r){const t=r.querySelectorAll("[data-slate-leaf]");for(let n=0;n<t.length;n++){const r=t[n];if(xt.hasDOMNode(e,r)){u=r;break}}u?(f=u.closest('[data-slate-node="text"]'),y=u,h=y.textContent.length,y.querySelectorAll("[data-slate-zero-width]").forEach((e=>{h-=e.textContent.length}))):h=1}else if(c){const e=e=>e?e.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],t=c.closest('[data-slate-node="element"]');if("backward"===d||!d){var g;u=null!==(g=[...e(null==t?void 0:t.previousElementSibling),...e(t)].findLast((e=>De(c,e))))&&void 0!==g?g:null,u&&(d="backward")}if("forward"===d||!d){var m;u=null!==(m=[...e(t),...e(null==t?void 0:t.nextElementSibling)].find((e=>{return t=e,Boolean(c.compareDocumentPosition(t)&ge.DOCUMENT_POSITION_FOLLOWING);var t})))&&void 0!==m?m:null,u&&(d="forward")}u&&(f=u.closest('[data-slate-node="text"]'),y=u,"forward"===d?h=0:(h=y.textContent.length,y.querySelectorAll("[data-slate-zero-width]").forEach((e=>{h-=e.textContent.length}))))}y&&h===y.textContent.length&&_e&&"z"===y.getAttribute("data-slate-zero-width")&&null!==(p=y.textContent)&&void 0!==p&&p.startsWith("\ufeff")&&(l.hasAttribute("data-slate-zero-width")||Fe&&null!==(v=y.textContent)&&void 0!==v&&v.endsWith("\n\n"))&&h--}if(_e&&!f&&!o){const t=l.hasAttribute("data-slate-node")?l:l.closest("[data-slate-node]");if(t&&xt.hasDOMNode(e,t,{editable:!0})){const r=xt.toSlateNode(e,t);let o;try{o=xt.findPath(e,r)}catch(e){if(i)return null;throw e}let{path:a,offset:l}=n.Editor.start(e,o);return t.querySelector("[data-slate-leaf]")||(l=s),{path:a,offset:l}}}if(!f){if(i)return null;throw new Error(`Cannot resolve a Slate point from DOM point: ${t}`)}try{c=xt.toSlateNode(e,f)}catch(e){if(i)return null;throw e}try{u=xt.findPath(e,c)}catch(e){if(i)return null;throw e}return{path:u,offset:h}},toSlateRange:(e,t,r)=>{var o,i;const{exactMatch:a,suppressThrow:s}=r;let l,c,u,d,f;if(Ee(t)?t.anchorNode:t.startContainer)if(Ee(t)){if(Fe&&t.rangeCount>1){u=t.focusNode;const m=t.getRangeAt(0),y=t.getRangeAt(t.rangeCount-1);if(u instanceof HTMLTableRowElement&&m.startContainer instanceof HTMLTableRowElement&&y.startContainer instanceof HTMLTableRowElement){function b(e){return e.childElementCount>0?b(e.children[0]):e}const w=m.startContainer,E=y.startContainer,x=b(w.children[m.startOffset]),O=b(E.children[y.startOffset]);d=0,l=O.childNodes.length>0?O.childNodes[0]:O,u=x.childNodes.length>0?x.childNodes[0]:x,c=O instanceof HTMLElement?O.innerHTML.length:0}else m.startContainer===u?(l=y.endContainer,c=y.endOffset,d=m.startOffset):(l=m.startContainer,c=m.endOffset,d=y.startOffset)}else l=t.anchorNode,c=t.anchorOffset,u=t.focusNode,d=t.focusOffset;f=We&&(e=>{let t=e&&e.parentNode;for(;t;){if("[object ShadowRoot]"===t.toString())return!0;t=t.parentNode}return!1})(l)||Fe?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed}else l=t.startContainer,c=t.startOffset,u=t.endContainer,d=t.endOffset,f=t.collapsed;if(null==l||null==u||null==c||null==d)throw new Error(`Cannot resolve a Slate range from DOM range: ${t}`);!Fe||null!==(o=u.parentElement)&&void 0!==o&&o.hasAttribute("data-slate-trailing")||null===(i=u.textContent)||void 0===i||!i.endsWith("\n\n")||d!==u.textContent.length||d--;const h=xt.toSlatePoint(e,[l,c],{exactMatch:a,suppressThrow:s});if(!h)return null;const p=De(l,u)||l===u&&d<c,v=f?h:xt.toSlatePoint(e,[u,d],{exactMatch:a,suppressThrow:s,searchDirection:p?"forward":"backward"});if(!v)return null;let g={anchor:h,focus:v};return n.Range.isExpanded(g)&&n.Range.isForward(g)&&be(u)&&!u.closest('[data-slate-void="true"]')&&n.Editor.void(e,{at:g.focus,mode:"highest"})&&(g=n.Editor.unhangRange(e,g,{voids:!0})),g}},Ot=(e,t,n)=>e.map(((e,r)=>r!==t[0]?e:1===t.length?Et(Et({},e),{},{text:n}):Et(Et({},e),{},{children:Ot(e.children,t.slice(1),n)}))),kt=e=>{var t;const r=xt.getWindow(e).getSelection();if(null==r||!r.focusNode)return;const o=xt.toSlatePoint(e,[r.focusNode,r.focusOffset],{exactMatch:!1,suppressThrow:!0});if(!o)return;const i=(null!==(t=xt.toDOMNode(e,n.Node.get(e,o.path)).textContent)&&void 0!==t?t:"").replace(/\uFEFF/g,""),a=n.createEditor();return a.isInline=e.isInline,a.isVoid=e.isVoid,a.children=Ot(e.children,o.path,i),{view:a,point:o}},Ct=e=>{var t;const n=be(e)?e:e.parentElement;return null!=n&&n.hasAttribute("data-slate-node")?n:null!==(t=null==n?void 0:n.closest("[data-slate-node]"))&&void 0!==t?t:null},St=e=>`Cannot resolve a DOM point from Slate point: ${n.Scrubber.stringify(e)}`,Tt=(e,t,r)=>{let o=null;n.Editor.void(e,{at:r})&&(r={path:r.path,offset:0});const i=Array.from(t.querySelectorAll("[data-slate-string], [data-slate-zero-width]"));let a=0;for(let e=0;e<i.length;e++){const t=i[e],n=t.childNodes[0];if(null==n||null==n.textContent)continue;const{length:l}=n.textContent,c=t.getAttribute("data-slate-length"),u=a+(null==c?l:parseInt(c,10)),d=i[e+1];if(r.offset===u&&null!=d&&d.hasAttribute("data-slate-mark-placeholder")){var s;const e=d.childNodes[0];o=[e instanceof me?e:d,null!==(s=d.textContent)&&void 0!==s&&s.startsWith("\ufeff")?1:0];break}if(r.offset<=u){const e=Math.min(l,Math.max(0,r.offset-a));o=e===l&&t.hasAttribute("data-slate-trailing")?[t.lastChild,0]:[n,e];break}a=u}return o},Pt=(e,t,n,r)=>{const o=e.document.createRange(),[i,a]=r?n:t,[s,l]=r?t:n,c=!!(be(i)?i:i.parentElement).getAttribute("data-slate-zero-width"),u=!!(be(s)?s:s.parentElement).getAttribute("data-slate-zero-width");return o.setStart(i,c?1:a),o.setEnd(s,u?1:l),o};function Dt(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Rt(e,t){const{path:r,diff:o}=t;if(!n.Editor.hasPath(e,r))return!1;const i=n.Node.get(e,r);if(!n.Node.isText(i))return!1;if(o.start!==i.text.length||0===o.text.length)return i.text.slice(o.start,o.start+o.text.length)===o.text;const a=n.Path.next(r);if(!n.Editor.hasPath(e,a))return!1;const s=n.Node.get(e,a);return n.Node.isText(s)&&s.text.startsWith(o.text)}function Nt(e,...t){return t.reduce(((e,t)=>e.slice(0,t.start)+t.text+e.slice(t.end)),e)}function Mt(e,t){const{start:n,end:r,text:o}=t,i=e.slice(n,r),a=function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charAt(r)!==t.charAt(r))return r;return n}(i,o),s=function(e,t,n){const r=Math.min(e.length,t.length,n);for(let n=0;n<r;n++)if(e.charAt(e.length-n-1)!==t.charAt(t.length-n-1))return n;return r}(i,o,Math.min(i.length-a,o.length-a)),l={start:n+a,end:r-s,text:o.slice(a,o.length-s)};return l.start===l.end&&0===l.text.length?null:l}function jt(e){const{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}function Bt(e,t){let{path:r,offset:o}=t;if(!n.Editor.hasPath(e,r))return null;let i=n.Node.get(e,r);if(!n.Node.isText(i))return null;const a=n.Editor.above(e,{match:t=>n.Node.isElement(t)&&n.Editor.isBlock(e,t),at:r});if(!a)return null;for(;o>i.text.length;){const t=n.Editor.next(e,{at:r,match:n.Node.isText});if(!t||!n.Path.isDescendant(t[1],a[1]))return null;o-=i.text.length,i=t[0],r=t[1]}return{path:r,offset:o}}function At(e,t){const r=Bt(e,t.anchor);if(!r)return null;if(n.Range.isCollapsed(t))return{anchor:r,focus:r};const o=Bt(e,t.focus);return o?{anchor:r,focus:o}:null}function _t(e,t,r){const o=pt.get(e),i=null==o?void 0:o.find((({path:e})=>n.Path.equals(e,t.path)));if(!i||t.offset<=i.diff.start)return n.Point.transform(t,r,{affinity:"backward"});const{diff:a}=i;if("insert_node"===r.type&&n.Text.isText(r.node)&&r.node.text===a.text&&a.start===a.end&&n.Path.equals(r.path,n.Path.next(t.path))&&t.offset<=a.start+a.text.length&&n.Node.leaf(e,t.path).text.length===a.start)return{path:r.path,offset:t.offset-a.start};if(t.offset<=a.start+a.text.length){const e={path:t.path,offset:a.start},o=n.Point.transform(e,r,{affinity:"backward"});return o?{path:o.path,offset:o.offset+t.offset-a.start}:null}const s={path:t.path,offset:t.offset-a.text.length+a.end-a.start},l=n.Point.transform(s,r,{affinity:"backward"});return l?"split_node"===r.type&&n.Path.equals(r.path,t.path)&&s.offset<r.position&&a.start<r.position?l:{path:l.path,offset:l.offset+a.text.length-a.end+a.start}:null}function Ft(e,t,r){const o=_t(e,t.anchor,r);if(!o)return null;if(n.Range.isCollapsed(t))return{anchor:o,focus:o};const i=_t(e,t.focus,r);return i?{anchor:o,focus:i}:null}const It=(e,t)=>{const n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n},Lt=(e,t,n)=>{try{const r=xt.toDOMRange(e,t),o=xt.toDOMRange(e,n),i=r.getBoundingClientRect(),a=o.getBoundingClientRect();return It(i,a)&&It(a,i)}catch(e){return!1}};function Wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wt(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ut=new WeakSet,qt=e=>Ze.has(e)||Ut.has(e)||n.Node.isElement(e)&&e.children.some(qt),Vt=e=>n.Node.isElement(e)?zt(zt({},e),{},{children:e.children.map(Vt)}):zt({},e),Kt=e=>{Ut.add(e),n.Node.isElement(e)&&e.children.forEach(Kt)},Ht=e=>{const t=qt(e)?Vt(e):e;return Kt(t),t},$t=["children"],Xt=["children"],Gt=["children"];function Yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Jt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yt(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Zt=(e,t="x-slate-fragment")=>{const r=e,{apply:o,onChange:i,deleteBackward:a,addMark:s,removeMark:l,insertNodes:c}=r;return r.insertNodes=(e,t)=>{c(n.Node.isNode(e)?Ht(e):e.map(Ht),t)},it.set(r,new WeakMap),r.addMark=(e,t)=>{var n,o;null===(n=dt.get(r))||void 0===n||n(),!ft.get(r)&&null!==(o=pt.get(r))&&void 0!==o&&o.length&&ft.set(r,null),ht.delete(r),s(e,t)},r.removeMark=e=>{var t;!ft.get(r)&&null!==(t=pt.get(r))&&void 0!==t&&t.length&&ft.set(r,null),ht.delete(r),l(e)},r.deleteBackward=e=>{if("line"!==e)return a(e);if(r.selection&&n.Range.isCollapsed(r.selection)){const e=n.Editor.above(r,{match:e=>n.Node.isElement(e)&&n.Editor.isBlock(r,e),at:r.selection});if(e){const[,t]=e,o=n.Editor.range(r,t,r.selection.anchor),i=((e,t)=>{const r=n.Editor.range(e,n.Range.end(t)),o=Array.from(n.Editor.positions(e,{at:t}));let i=0,a=o.length,s=Math.floor(a/2);if(Lt(e,n.Editor.range(e,o[i]),r))return n.Editor.range(e,o[i],r);if(o.length<2)return n.Editor.range(e,o[o.length-1],r);for(;s!==o.length&&s!==i;)Lt(e,n.Editor.range(e,o[s]),r)?a=s:i=s,s=Math.floor((i+a)/2);return n.Editor.range(e,o[i],r)})(r,o);n.Range.isCollapsed(i)?a("character"):n.Transforms.delete(r,{at:i})}}},r.apply=t=>{const i=[],a=[],s=pt.get(r);if(null!=s&&s.length){const e=s.map((e=>function(e,t){const{path:r,diff:o,id:i}=e;switch(t.type){case"insert_text":return!n.Path.equals(t.path,r)||t.offset>=o.end?e:t.offset<=o.start?{diff:{start:t.text.length+o.start,end:t.text.length+o.end,text:o.text},id:i,path:r}:{diff:{start:o.start,end:o.end+t.text.length,text:o.text},id:i,path:r};case"remove_text":return!n.Path.equals(t.path,r)||t.offset>=o.end?e:t.offset+t.text.length<=o.start?{diff:{start:o.start-t.text.length,end:o.end-t.text.length,text:o.text},id:i,path:r}:{diff:{start:o.start,end:o.end-t.text.length,text:o.text},id:i,path:r};case"split_node":return!n.Path.equals(t.path,r)||t.position>=o.end?{diff:o,id:i,path:n.Path.transform(r,t,{affinity:"backward"})}:t.position>o.start?{diff:{start:o.start,end:Math.min(t.position,o.end),text:o.text},id:i,path:r}:{diff:{start:o.start-t.position,end:o.end-t.position,text:o.text},id:i,path:n.Path.transform(r,t,{affinity:"forward"})};case"merge_node":return n.Path.equals(t.path,r)?{diff:{start:o.start+t.position,end:o.end+t.position,text:o.text},id:i,path:n.Path.transform(r,t)}:{diff:o,id:i,path:n.Path.transform(r,t)}}const a=n.Path.transform(r,t);return a?{diff:o,path:a,id:i}:null}(e,t))).filter(Boolean);pt.set(r,e)}const l=gt.get(r);l&>.set(r,Ft(r,l,t));const c=vt.get(r);if(null!=c&&c.at){const e=n.Location.isPoint(null==c?void 0:c.at)?_t(r,c.at,t):Ft(r,c.at,t);vt.set(r,e?Jt(Jt({},c),{},{at:e}):null)}switch(t.type){case"insert_text":case"remove_text":case"set_node":case"split_node":i.push(...Qt(r,t.path));break;case"set_selection":var u;null===(u=ct.get(r))||void 0===u||u.unref(),ct.delete(r);break;case"insert_node":case"remove_node":i.push(...Qt(r,n.Path.parent(t.path)));break;case"merge_node":{const e=n.Path.previous(t.path);i.push(...Qt(r,e));break}case"move_node":{const o=n.Path.common(n.Path.parent(t.path),n.Path.parent(t.newPath));let s;i.push(...Qt(r,o)),n.Path.isBefore(t.path,t.newPath)?(i.push(...Qt(r,n.Path.parent(t.path))),s=t.newPath):(i.push(...Qt(r,n.Path.parent(t.newPath))),s=t.path);const l=n.Node.get(e,n.Path.parent(s)),c=xt.findKey(r,l),u=n.Editor.pathRef(r,n.Path.parent(s));a.push([u,c]);break}}switch(o(t),t.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":case"insert_text":case"remove_text":case"set_selection":Ye.set(r,!0)}for(const[e,t]of i){const[o]=n.Editor.node(r,e);ot.set(o,t)}for(const[e,t]of a){if(e.current){const[o]=n.Editor.node(r,e.current);ot.set(o,t)}e.unref()}},r.onDOMError=e=>{"function"==typeof globalThis.reportError?globalThis.reportError(e):setTimeout((()=>{throw e}))},r.setFragmentData=e=>{const{selection:o}=r;if(!o)return;const[i,a]=n.Range.edges(o),s=n.Editor.void(r,{at:i.path}),l=n.Editor.void(r,{at:a.path});if(n.Range.isCollapsed(o)&&!s)return;const c=xt.toDOMRange(r,o);let u=c.cloneContents(),d=c.commonAncestorContainer,f=u.childNodes[0];if(u.childNodes.forEach((e=>{e.textContent&&""!==e.textContent.trim()&&(f=e)})),l){const[e]=l,t=c.cloneRange(),n=xt.toDOMNode(r,e);t.setEndAfter(n),u=t.cloneContents(),d=t.commonAncestorContainer}if(s&&(f=u.querySelector("[data-slate-spacer]")),Array.from(u.querySelectorAll("[data-slate-zero-width]")).forEach((e=>{const t="n"===e.getAttribute("data-slate-zero-width");e.textContent="",t&&e.appendChild(e.ownerDocument.createElement("br"))})),xe(f)){const e=f.ownerDocument.createElement("span");e.style.whiteSpace="pre",e.appendChild(f),u.appendChild(e),f=e}const h=r.getFragment(),p=JSON.stringify(h),v=window.btoa(encodeURIComponent(p));f.setAttribute("data-slate-fragment",v),e.setData(`application/${t}`,v),u=((e,t,n,r)=>{const o=null!==e.querySelector("li");let i=e;for(let e=be(t)?t:t.parentElement;e&&e!==n;e=e.parentElement)if(o&&["OL","UL","LI"].includes(e.nodeName)||r&&"true"===e.getAttribute("data-slate-inline")&&!e.hasAttribute("data-slate-void")){const t=e.cloneNode(!1);t.appendChild(i),i=e.ownerDocument.createDocumentFragment(),i.appendChild(t)}return i})(u,d,xt.toDOMNode(r,r),!s&&!l);const g=u.ownerDocument.createElement("div");return g.appendChild(u),g.setAttribute("hidden","true"),u.ownerDocument.body.appendChild(g),e.setData("text/html",g.innerHTML),e.setData("text/plain",Ce(g)),u.ownerDocument.body.removeChild(g),e},r.insertData=e=>{r.insertFragmentData(e)||r.insertTextData(e)},r.insertFragmentData=e=>{const n=e.getData(`application/${t}`)||(e=>{const t=e.getData("text/html"),[,n]=t.match(Se)||[];return n})(e);if(n){const e=decodeURIComponent(window.atob(n)),t=JSON.parse(e);return r.insertFragment(t),!0}return!1},r.insertTextData=e=>{const t=e.getData("text/plain");if(!t)return!1;const n=t.split(/\r\n|\r|\n/);if(1===n.length)return r.insertText(t),!0;if(en(r))return tn(r,n),!0;const o=nn(r,n);return o&&r.insertFragment(o),!0},r.onChange=e=>{const t=ut.get(r);t&&t(e),i(e)},r},Qt=(e,t)=>{const r=[];for(const[o,i]of n.Editor.levels(e,{at:t})){const t=xt.findKey(e,o);r.push([i,t])}return r},en=e=>!!e.selection&&!!n.Editor.above(e,{at:n.Range.start(e.selection),match:t=>n.Element.isElement(t)&&n.Editor.isInline(e,t)}),tn=(e,t)=>{var r;const o=null!==(r=n.Editor.marks(e))&&void 0!==r?r:{},i=t.slice(1,-1);if(e.insertText(t[0]),n.Transforms.splitNodes(e,{always:!0}),i.length&&e.selection){const{anchor:t}=e.selection,[[r,a]]=n.Editor.nodes(e,{at:t,match:t=>n.Element.isElement(t)&&n.Editor.isBlock(e,t),mode:"lowest"}),{children:s}=r,l=Dt(r,$t),c=Array.from(n.Editor.nodes(e,{at:t,match:t=>n.Element.isElement(t)&&n.Editor.isInline(e,t)}),(([e])=>{let{children:t}=e;return Dt(e,Xt)})),u=e=>c.reduceRight(((e,t)=>Jt(Jt({},t),{},{children:[e]})),Jt(Jt({},o),{},{text:e}));n.Transforms.insertNodes(e,i.map((e=>Jt(Jt({},l),{},{children:[u(e)]}))),{at:a,select:!1})}e.insertText(t[t.length-1])},nn=(e,t)=>{var r;if(!e.selection)return null;const o=n.Editor.above(e,{at:n.Range.start(e.selection),match:t=>n.Element.isElement(t)&&n.Editor.isBlock(e,t),mode:"lowest"});if(!o)return null;const[i]=o,{children:a}=i,s=Dt(i,Gt),l=null!==(r=n.Editor.marks(e))&&void 0!==r?r:{};return t.map((e=>Jt(Jt({},s),{},{children:[Jt(Jt({},l),{},{text:e})]})))},rn={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"},on={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"},an={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},sn=e=>{const t=rn[e],n=on[e],r=an[e],o=t&&fe(t),i=n&&fe(n),a=r&&fe(r);return e=>!(!o||!o(e))||(!!(Ae&&i&&i(e))||!(Ae||!a||!a(e)))};var ln={isBold:sn("bold"),isCompose:sn("compose"),isMoveBackward:sn("moveBackward"),isMoveForward:sn("moveForward"),isDeleteBackward:sn("deleteBackward"),isDeleteForward:sn("deleteForward"),isDeleteLineBackward:sn("deleteLineBackward"),isDeleteLineForward:sn("deleteLineForward"),isDeleteWordBackward:sn("deleteWordBackward"),isDeleteWordForward:sn("deleteWordForward"),isExtendBackward:sn("extendBackward"),isExtendForward:sn("extendForward"),isExtendLineBackward:sn("extendLineBackward"),isExtendLineForward:sn("extendLineForward"),isItalic:sn("italic"),isMoveLineBackward:sn("moveLineBackward"),isMoveLineForward:sn("moveLineForward"),isMoveWordBackward:sn("moveWordBackward"),isMoveWordForward:sn("moveWordForward"),isRedo:sn("redo"),isSoftBreak:sn("insertSoftBreak"),isSplitBlock:sn("splitBlock"),isTransposeCharacter:sn("transposeCharacter"),isUndo:sn("undo")};const cn=["anchor","focus"],un=["anchor","focus"];function dn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dn(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const hn=(e,t)=>{const{anchor:n,focus:r}=e,o=Dt(e,cn),{anchor:i,focus:a}=t,s=Dt(t,un);return e[yt]===t[yt]&&(l=o,c=s,Object.keys(l).length===Object.keys(c).length&&Object.keys(l).every((e=>c.hasOwnProperty(e)&&l[e]===c[e])));var l,c},pn=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],i=t[r];if(!n.Range.equals(o,i)||!hn(o,i))return!1}return!0},vn=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],o=t[n];if(r.anchor.offset!==o.anchor.offset||r.focus.offset!==o.focus.offset||!hn(r,o))return!1}return!0};function gn(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function mn(){}var yn={d:{f:mn,r:function(){throw Error(gn(522))},D:mn,C:mn,L:mn,m:mn,X:mn,S:mn,M:mn},p:0,findDOMNode:null},bn=Symbol.for("react.portal");function wn(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:bn,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}var En=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function xn(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}var On={__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:yn,createPortal:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!t||1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType)throw Error(gn(299));return wn(e,t,null,n)},flushSync:function(e){var t=En.T,n=yn.p;try{if(En.T=null,yn.p=2,e)return e()}finally{En.T=t,yn.p=n,yn.d.f()}},preconnect:function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,yn.d.C(e,t))},prefetchDNS:function(e){"string"==typeof e&&yn.d.D(e)},preinit:function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=xn(n,t.crossOrigin),o="string"==typeof t.integrity?t.integrity:void 0,i="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?yn.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:o,fetchPriority:i}):"script"===n&&yn.d.X(e,{crossOrigin:r,integrity:o,fetchPriority:i,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},preinitModule:function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=xn(t.as,t.crossOrigin);yn.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&yn.d.M(e)},preload:function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=xn(n,t.crossOrigin);yn.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},preloadModule:function(e,t){if("string"==typeof e)if(t){var n=xn(t.as,t.crossOrigin);yn.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else yn.d.m(e)},requestFormReset:function(e){yn.d.r(e)},unstable_batchedUpdates:function(e,t){return e(t)},useFormState:function(e,t,n){return En.H.useFormState(e,t,n)},useFormStatus:function(){return En.H.useHostTransitionStatus()},version:"19.2.8"},kn=i((function(e,t){}));kn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,kn.createPortal,kn.flushSync,kn.preconnect,kn.prefetchDNS,kn.preinit,kn.preinitModule,kn.preload,kn.preloadModule,kn.requestFormReset,kn.unstable_batchedUpdates,kn.useFormState,kn.useFormStatus,kn.version;var Cn=i((function(e){!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),e.exports=On}));Cn.findDOMNode;var Sn=xt;function Tn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Pn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Tn(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Dn=new WeakMap;function Rn(e){var t=e.editor,r=e.scheduleOnDOMSelectionChange,o=e.onDOMSelectionChange,i=!1,a=!1,s=null,l=null,c=null,u=0,d=!1,f=!1,h=0,p=!1,v=function(){var e=gt.get(t);if(gt.delete(t),e){var r=t.selection,o=At(t,e);!o||r&&n.Range.equals(o,r)||n.Transforms.select(t,o)}},g=function(){var e=vt.get(t);if(vt.delete(t),e){if(e.at){var r=n.Location.isPoint(e.at)?Bt(t,e.at):At(t,e.at);if(!r)return;var o=n.Editor.range(t,r);t.selection&&n.Range.equals(t.selection,o)||n.Transforms.select(t,r)}e.run()}},m=function(){if(!lt.get(t)||d)return!1;try{var e=Sn.toDOMNode(t,t),n=Sn.getWindow(t).document.activeElement;if(n!==e&&!e.contains(n))return!1}catch(e){}return Date.now()-u<5e3},y=function(){return!(null===(e=pt.get(t))||void 0===e||!e.some((function(e){var r=e.path;try{return 0===n.Node.leaf(t,r).text.length}catch(e){return!1}})))||C()&&void 0!==ft.get(t);var e},b=function(){if(l&&(clearTimeout(l),l=null),c&&(clearTimeout(c),c=null),!a&&m()&&y())l=setTimeout(b,50);else if(C()||k()){i||(i=!0,setTimeout((function(){return i=!1}))),k()&&(i="action");var e=t.selection&&n.Editor.rangeRef(t,t.selection,{affinity:"forward"});ht.set(t,t.marks),vt.get(t),pt.get(t);for(var s,u=C();s=null===(d=pt.get(t))||void 0===d?void 0:d[0];){var d,h,w=ft.get(t);void 0!==w&&(ft.delete(t),t.marks=w),w&&!1===p&&(p=null);var E=jt(s);t.selection&&n.Range.equals(t.selection,E)||n.Transforms.select(t,E),s.diff.text?n.Editor.insertText(t,s.diff.text):n.Editor.deleteFragment(t),pt.set(t,null===(h=pt.get(t))||void 0===h?void 0:h.filter((function(e){return e.id!==s.id}))),Rt(t,s)||(u=!1,vt.delete(t),ht.delete(t),i="action",gt.delete(t),r.cancel(),o.cancel(),null==e||e.unref())}var x,O,S=null==e?void 0:e.unref();if(!S||gt.get(t)||t.selection&&n.Range.equals(S,t.selection)||n.Transforms.select(t,S),k())return O=t.children,g(),f&&t.children===O&&(null===(x=mt.get(t))||void 0===x||x()),void(f=!1);u&&r(),r.flush(),o.flush(),v();var T=ht.get(t);ht.delete(t),void 0!==T&&T!==t.marks&&(t.marks=T,t.onChange())}else v()},E=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=tt.get(t);n&&(C()||e?n.style.display="none":n.style.removeProperty("display"))},x=function(e,r){var o,i=null!==(o=pt.get(t))&&void 0!==o?o:[];pt.set(t,i);var a=n.Node.leaf(t,e),s=i.findIndex((function(t){return n.Path.equals(t.path,e)}));if(s<0)return Mt(a.text,r)&&i.push({path:e,diff:r,id:h++}),void E();var l=function(e,t,n){const r=Math.min(t.start,n.start),o=Math.max(0,Math.min(t.start+t.text.length,n.end)-n.start),i=Nt(e,t,n),a=Math.max(n.start+n.text.length,t.start+t.text.length+(t.start+t.text.length>n.start?n.text.length:0)-o),s=i.slice(r,a);return Mt(e,{start:r,end:Math.max(t.end,n.end-t.text.length+(t.end-t.start)),text:s})}(a.text,i[s].diff,r);if(!l)return i.splice(s,1),void E();i[s]=Pn(Pn({},i[s]),{},{diff:l})},O=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.at;p=!1,gt.delete(t),r.cancel(),o.cancel(),k()&&b(),c&&clearTimeout(c),vt.set(t,{at:i,run:e}),c=setTimeout(b)},k=function(){return!!vt.get(t)},C=function(){var e;return!(null===(e=pt.get(t))||void 0===e||!e.length)},S=function(e){gt.set(t,e),l&&(clearTimeout(l),l=null);var r=t.selection;if(e){var o=!r||!n.Path.equals(r.anchor.path,e.anchor.path),i=!r||!n.Path.equals(r.anchor.path.slice(0,-1),e.anchor.path.slice(0,-1));(o&&p||i)&&(p=!1),(o||C())&&(l=setTimeout(b,200))}},T=function(){k()||(c&&clearTimeout(c),c=setTimeout(b))};return{flush:b,flushDeferredDiffs:function(){if(!i&&m()&&y()){a=!0;try{b()}finally{a=!1}}},scheduleFlush:T,hasPendingDiffs:C,hasPendingAction:k,hasPendingChanges:function(){return k()||C()},isFlushing:function(){return i},handleUserSelect:S,handleCompositionEnd:function(e){if(s&&clearTimeout(s),y()&&!i)return Cn.flushSync((function(){lt.set(t,!1),b()})),void E();s=setTimeout((function(){var e;(lt.set(t,!1),b(),d)&&(null===(e=mt.get(t))||void 0===e||e());E()}),25)},handleCompositionStart:function(e){lt.set(t,!0),u=Date.now(),d=!1,s&&(clearTimeout(s),s=null)},handleDOMBeforeInput:function(e){l&&(clearTimeout(l),l=null);var r=Ye.get(t),o=e.inputType;if("insertCompositionText"===o||"deleteCompositionText"===o)if(u=Date.now(),e.data)d=!1;else{d=!0;var i=pt.get(t);if(null!=i&&i.length){var a=i.every((function(e){var r=e.path;try{return 0===n.Node.leaf(t,r).text.length}catch(e){return!1}}));a&&(pt.set(t,[]),gt.delete(t))}}var s=null,c=e.dataTransfer||e.data||void 0;!1!==p&&"insertText"!==o&&"insertCompositionText"!==o&&(p=!1);var f=e.getTargetRanges(),h=w(f,1)[0];h&&!r&&(s=Sn.toSlateRange(t,h,{exactMatch:!1,suppressThrow:!0}));var v=Sn.getWindow(t).getSelection();if(s||!v||r||(h=v,s=Sn.toSlateRange(t,v,{exactMatch:!1,suppressThrow:!0})),s=null!=s?s:t.selection){var g,m=!0;if(o.startsWith("delete")){var y=o.endsWith("Backward")?"backward":"forward",b=n.Range.edges(s),E=w(b,2),k=E[0],C=E[1],P=n.Editor.leaf(t,k.path),D=w(P,2),R=D[0],N=D[1];if(n.Range.isExpanded(s)&&R.text.length===k.offset&&0===C.offset){var M=n.Editor.next(t,{at:k.path,match:n.Node.isText});if(M&&n.Path.equals(M[1],C.path))if("backward"===y){s={anchor:C,focus:C},k=C;var j=w(M,2);R=j[0],N=j[1]}else s={anchor:k,focus:k},C=k}var B={text:"",start:k.offset,end:C.offset},A=pt.get(t),_=null==A?void 0:A.find((function(e){return n.Path.equals(e.path,N)})),F=_?[_.diff,B]:[B];if(0===Nt.apply(void 0,[R.text].concat(F)).length&&(m=!1),n.Range.isExpanded(s)){if(m&&n.Path.equals(s.anchor.path,s.focus.path)){var I={path:s.anchor.path,offset:k.offset},L=n.Editor.range(t,I,I);return S(L),x(s.anchor.path,{text:"",end:C.offset,start:k.offset}),void("deleteContentBackward"===o&&T())}return O((function(){return n.Editor.deleteFragment(t,{direction:y})}),{at:s})}}switch(o){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return O((function(){return n.Editor.deleteFragment(t)}),{at:s});case"deleteContent":case"deleteContentForward":var W=s.anchor;if(m&&n.Range.isCollapsed(s)){var z=n.Node.leaf(t,W.path);if(W.offset<z.text.length)return x(W.path,{text:"",start:W.offset,end:W.offset+1})}return O((function(){return n.Editor.deleteForward(t)}),{at:s});case"deleteContentBackward":var U,q=s.anchor,V=Ee(h)?h.isCollapsed:!(null===(U=h)||void 0===U||!U.collapsed);return m&&V&&n.Range.isCollapsed(s)&&q.offset>0?(x(q.path,{text:"",start:q.offset-1,end:q.offset}),void T()):O((function(){return n.Editor.deleteBackward(t)}),{at:s});case"deleteEntireSoftLine":return O((function(){n.Editor.deleteBackward(t,{unit:"line"}),n.Editor.deleteForward(t,{unit:"line"})}),{at:s});case"deleteHardLineBackward":return O((function(){return n.Editor.deleteBackward(t,{unit:"block"})}),{at:s});case"deleteSoftLineBackward":return O((function(){return n.Editor.deleteBackward(t,{unit:"line"})}),{at:s});case"deleteHardLineForward":return O((function(){return n.Editor.deleteForward(t,{unit:"block"})}),{at:s});case"deleteSoftLineForward":return O((function(){return n.Editor.deleteForward(t,{unit:"line"})}),{at:s});case"deleteWordBackward":return O((function(){return n.Editor.deleteBackward(t,{unit:"word"})}),{at:s});case"deleteWordForward":return O((function(){return n.Editor.deleteForward(t,{unit:"word"})}),{at:s});case"insertLineBreak":return O((function(){return n.Editor.insertSoftBreak(t)}),{at:s});case"insertParagraph":return O((function(){return n.Editor.insertBreak(t)}),{at:s});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if("DataTransfer"===(null==(g=c)?void 0:g.constructor.name))return O((function(){return Sn.insertData(t,c)}),{at:s});var K=null!=c?c:"";if(ft.get(t)&&(K=K.replace("\ufeff","")),"insertText"===o&&/.*\n.*\n$/.test(K)&&(K=K.slice(0,-1)),K.includes("\n"))return O((function(){var e=K.split("\n");e.forEach((function(r,o){r&&n.Editor.insertText(t,r),o!==e.length-1&&n.Editor.insertSoftBreak(t)}))}),{at:s});if("insertText"===o&&!Sn.isComposing(t)&&n.Range.isCollapsed(s)&&"function"==typeof n.Editor.insertionPoint&&!n.Point.equals(n.Editor.insertionPoint(t,s.anchor),s.anchor)){var H,$=Ee(h)?h.anchorNode:null===(H=h)||void 0===H?void 0:H.startContainer,X=we($)&&3===$.nodeType?{node:$,text:$.textContent}:null;return e.preventDefault(),O((function(){X&&X.node.isConnected&&X.node.textContent!==X.text&&(X.node.textContent=X.text),n.Editor.insertText(t,K)}),{at:s})}if(n.Path.equals(s.anchor.path,s.focus.path)){var G=n.Range.edges(s),Y=w(G,2),J=Y[0],Z=Y[1],Q={start:J.offset,end:Z.offset,text:K};if(K&&p&&"insertCompositionText"===o){var ee=p.start+p.text.search(/\S|$/);Q.start+Q.text.search(/\S|$/)===ee+1&&Q.end===p.start+p.text.length?(Q.start-=1,p=null,T()):p=!1}else p="insertText"===o&&(null===p?Q:!(!p||!n.Range.isCollapsed(s)||p.end+p.text.length!==J.offset)&&Pn(Pn({},p),{},{text:p.text+K}));if(m){var te=t.selection;if(x(J.path,Q),te){var ne={path:J.path,offset:J.offset+K.length};O((function(){}),{at:ne})}return}}return O((function(){return n.Editor.insertText(t,K)}),{at:s})}}},handleKeyDown:function(e){C()||(E(!0),setTimeout(E))},handleDomMutations:function(e){var n;C()||e.some((function(n){return Pe(t,n,e)}))&&(k()?f=!0:null===(n=mt.get(t))||void 0===n||n())},handleInput:function(){!k()&&C()||b()}}}var Nn=He?t.useLayoutEffect:t.useEffect;var Mn=["node"];function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Bn,An={subtree:!0,childList:!0,characterData:!0},_n=_e?function(e){var n=e.node,r=l(e,Mn);if(!_e)return null;var o,i=ue(),a=(o=t.useRef(!1),t.useEffect((function(){return o.current=!0,function(){o.current=!1}}),[]),o.current),s=t.useState((function(){return Rn(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({editor:i},r))})),c=w(s,1)[0];return function(e,n,r){var o=t.useState((function(){return new MutationObserver(n)})),i=w(o,1)[0];Nn((function(){i.takeRecords()})),t.useEffect((function(){if(!e.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");return i.observe(e.current,r),function(){return i.disconnect()}}),[i,e,r])}(n,c.handleDomMutations,An),dt.set(i,c.scheduleFlush),Dn.set(i,c.flushDeferredDiffs),a&&c.flush(),c}:function(){return null},Fn=[],In="ResizeObserver loop completed with undelivered notifications.";!function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(Bn||(Bn={}));var Ln,Wn=function(e){return Object.freeze(e)},zn=function(e,t){this.inlineSize=e,this.blockSize=t,Wn(this)},Un=function(){function e(e,t,n,r){return this.x=e,this.y=t,this.width=n,this.height=r,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Wn(this)}return e.prototype.toJSON=function(){var e=this;return{x:e.x,y:e.y,top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.width,height:e.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),qn=function(e){return e instanceof SVGElement&&"getBBox"in e},Vn=function(e){if(qn(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,i=o.offsetWidth,a=o.offsetHeight;return!(i||a||e.getClientRects().length)},Kn=function(e){var t;if(e instanceof Element)return!0;var n=null===(t=null==e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},Hn="undefined"!=typeof window?window:{},$n=new WeakMap,Xn=/auto|scroll/,Gn=/^tb|vertical/,Yn=/msie|trident/i.test(Hn.navigator&&Hn.navigator.userAgent),Jn=function(e){return parseFloat(e||"0")},Zn=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=!1),new zn((n?t:e)||0,(n?e:t)||0)},Qn=Wn({devicePixelContentBoxSize:Zn(),borderBoxSize:Zn(),contentBoxSize:Zn(),contentRect:new Un(0,0,0,0)}),er=function(e,t){if(void 0===t&&(t=!1),$n.has(e)&&!t)return $n.get(e);if(Vn(e))return $n.set(e,Qn),Qn;var n=getComputedStyle(e),r=qn(e)&&e.ownerSVGElement&&e.getBBox(),o=!Yn&&"border-box"===n.boxSizing,i=Gn.test(n.writingMode||""),a=!r&&Xn.test(n.overflowY||""),s=!r&&Xn.test(n.overflowX||""),l=r?0:Jn(n.paddingTop),c=r?0:Jn(n.paddingRight),u=r?0:Jn(n.paddingBottom),d=r?0:Jn(n.paddingLeft),f=r?0:Jn(n.borderTopWidth),h=r?0:Jn(n.borderRightWidth),p=r?0:Jn(n.borderBottomWidth),v=d+c,g=l+u,m=(r?0:Jn(n.borderLeftWidth))+h,y=f+p,b=s?e.offsetHeight-y-e.clientHeight:0,w=a?e.offsetWidth-m-e.clientWidth:0,E=o?v+m:0,x=o?g+y:0,O=r?r.width:Jn(n.width)-E-w,k=r?r.height:Jn(n.height)-x-b,C=O+v+w+m,S=k+g+b+y,T=Wn({devicePixelContentBoxSize:Zn(Math.round(O*devicePixelRatio),Math.round(k*devicePixelRatio),i),borderBoxSize:Zn(C,S,i),contentBoxSize:Zn(O,k,i),contentRect:new Un(d,l,O,k)});return $n.set(e,T),T},tr=function(e,t,n){var r=er(e,n),o=r.borderBoxSize,i=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(t){case Bn.DEVICE_PIXEL_CONTENT_BOX:return a;case Bn.BORDER_BOX:return o;default:return i}},nr=function(e){var t=er(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Wn([t.borderBoxSize]),this.contentBoxSize=Wn([t.contentBoxSize]),this.devicePixelContentBoxSize=Wn([t.devicePixelContentBoxSize])},rr=function(e){if(Vn(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},or=function(){var e=1/0,t=[];Fn.forEach((function(n){if(0!==n.activeTargets.length){var r=[];n.activeTargets.forEach((function(t){var n=new nr(t.target),o=rr(t.target);r.push(n),t.lastReportedSize=tr(t.target,t.observedBox),o<e&&(e=o)})),t.push((function(){n.callback.call(n.observer,r,n.observer)})),n.activeTargets.splice(0,n.activeTargets.length)}}));for(var n=0,r=t;n<r.length;n++){(0,r[n])()}return e},ir=function(e){Fn.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(n){n.isActive()&&(rr(n.target)>e?t.activeTargets.push(n):t.skippedTargets.push(n))}))}))},ar=function(){var e,t=0;for(ir(t);Fn.some((function(e){return e.activeTargets.length>0}));)t=or(),ir(t);return Fn.some((function(e){return e.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?e=new ErrorEvent("error",{message:In}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=In),window.dispatchEvent(e)),t>0},sr=[],lr=function(e){if(!Ln){var t=0,n=document.createTextNode("");new MutationObserver((function(){return sr.splice(0).forEach((function(e){return e()}))})).observe(n,{characterData:!0}),Ln=function(){n.textContent="".concat(t?t--:t++)}}sr.push(e),Ln()},cr=0,ur={attributes:!0,characterData:!0,childList:!0,subtree:!0},dr=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],fr=function(e){return void 0===e&&(e=0),Date.now()+e},hr=!1,pr=new(function(){function e(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return e.prototype.run=function(e){var t=this;if(void 0===e&&(e=250),!hr){hr=!0;var n,r=fr(e);n=function(){var n=!1;try{n=ar()}finally{if(hr=!1,e=r-fr(),!cr)return;n?t.run(1e3):e>0?t.run(e):t.start()}},lr((function(){requestAnimationFrame(n)}))}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var e=this,t=function(){return e.observer&&e.observer.observe(document.body,ur)};document.body?t():Hn.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),dr.forEach((function(t){return Hn.addEventListener(t,e.listener,!0)})))},e.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),dr.forEach((function(t){return Hn.removeEventListener(t,e.listener,!0)})),this.stopped=!0)},e}()),vr=function(e){!cr&&e>0&&pr.start(),!(cr+=e)&&pr.stop()},gr=function(){function e(e,t){this.target=e,this.observedBox=t||Bn.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var e,t=tr(this.target,this.observedBox,!0);return e=this.target,qn(e)||function(e){switch(e.tagName){case"INPUT":if("image"!==e.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(e)||"inline"!==getComputedStyle(e).display||(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),mr=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},yr=new WeakMap,br=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},wr=function(){function e(){}return e.connect=function(e,t){var n=new mr(e,t);yr.set(e,n)},e.observe=function(e,t,n){var r=yr.get(e),o=0===r.observationTargets.length;br(r.observationTargets,t)<0&&(o&&Fn.push(r),r.observationTargets.push(new gr(t,n&&n.box)),vr(1),pr.schedule())},e.unobserve=function(e,t){var n=yr.get(e),r=br(n.observationTargets,t),o=1===n.observationTargets.length;r>=0&&(o&&Fn.splice(Fn.indexOf(n),1),n.observationTargets.splice(r,1),vr(-1))},e.disconnect=function(e){var t=this,n=yr.get(e);n.observationTargets.slice().forEach((function(n){return t.unobserve(e,n.target)})),n.activeTargets.splice(0,n.activeTargets.length)},e}(),Er=function(){function e(e){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof e)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");wr.connect(this,e)}return e.prototype.observe=function(e,t){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Kn(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");wr.observe(this,e,t)},e.prototype.unobserve=function(e){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Kn(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");wr.unobserve(this,e)},e.prototype.disconnect=function(){wr.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();function xr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Or=function(e){var r=e.isLast,o=e.leaf,i=e.parent,a=e.text,s=ue(),l=Sn.findPath(s,a),c=n.Path.parent(l),u=Boolean(o[bt]);return s.isVoid(i)?t.createElement(Sr,{length:n.Node.string(i).length}):""!==o.text||i.children[i.children.length-1]!==a||s.isInline(i)||""!==n.Editor.string(s,c)?""===o.text?t.createElement(Sr,{isMarkPlaceholder:u}):r&&"\n"===o.text.slice(-1)?t.createElement(kr,{isTrailing:!0,text:o.text}):t.createElement(kr,{text:o.text}):t.createElement(Sr,{isLineBreak:!0,isMarkPlaceholder:u})},kr=function(e){var n=e.text,r=e.isTrailing,o=void 0!==r&&r,i=ue(),a=t.useRef(null),s=function(){return"".concat(null!=n?n:"").concat(o?"\n":"")},l=t.useState(s),c=w(l,1)[0];return Nn((function(){var e,t,r,l=s();if(a.current&&a.current.textContent!==l){if(_e&<.get(i)){var c,u=null===(c=Sn.getWindow(i).getSelection())||void 0===c?void 0:c.anchorNode;if(u&&a.current.contains(u))return}a.current.textContent=l}Fe&&(null===(r=a.current)||void 0===r||r.toggleAttribute("data-slate-trailing",o));var d=null===(e=a.current)||void 0===e?void 0:e.firstChild;Fe&&o&&1===(null===(t=a.current)||void 0===t?void 0:t.childNodes.length)&&3===(null==d?void 0:d.nodeType)&&d.splitText(n.length)})),t.createElement(Cr,{ref:a},c)},Cr=t.memo(t.forwardRef((function(e,n){return t.createElement("span",{"data-slate-string":!0,ref:n},e.children)}))),Sr=function(e){var n=e.length,r=void 0===n?0:n,o=e.isLineBreak,i=void 0!==o&&o,a=e.isMarkPlaceholder,s={"data-slate-zero-width":i?"n":"z","data-slate-length":r};return void 0!==a&&a&&(s["data-slate-mark-placeholder"]=!0),t.createElement("span",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},s),"\ufeff",i?t.createElement("br",null):null)},Tr=function(e,t){return e.children[e.children.length-1]===t},Pr=function(e,t,r,o){return e===t||(i=e,a=t,s=Object.keys(i).filter((function(e){return"children"!==e})),l=Object.keys(a).filter((function(e){return"children"!==e})),s.length===l.length&&s.every((function(e){return e in a&&i[e]===a[e]}))&&Tr(e,r)===Tr(t,o)&&(""!==o.text||""===n.Node.string(e)==(""===n.Node.string(t))));var i,a,s,l};function Dr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Rr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Dr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Nr=_e?300:0;function Mr(e){e.current&&(clearTimeout(e.current),e.current=null)}var jr=function(e){return t.createElement(_r,Rr({},e))},Br=function(e){var n=e.leaf,r=e.isLast,o=e.text,i=e.parent,a=e.renderPlaceholder,s=e.renderLeaf,l=void 0===s?jr:s,c=e.leafPosition,u=ue(),d=t.useRef(null),f=t.useRef(null),h=t.useState(!1),p=w(h,2),v=p[0],g=p[1],m=t.useRef(null),y=t.useCallback((function(e){if(function(e,t){e.current&&(e.current.disconnect(),t&&(e.current=null))}(d,null==e),null==e){var t;tt.delete(u),null===(t=n.onPlaceholderResize)||void 0===t||t.call(n,null)}else{if(tt.set(u,e),!d.current){var r=window.ResizeObserver||Er;d.current=new r((function(){var t;null===(t=n.onPlaceholderResize)||void 0===t||t.call(n,e)}))}d.current.observe(e),f.current=e}}),[f,n,u]),b=t.createElement(Or,{isLast:r,leaf:n,parent:i,text:o}),E=Boolean(n[yt]);if(t.useEffect((function(){return E?m.current||(m.current=setTimeout((function(){g(!0),m.current=null}),Nr)):(Mr(m),g(!1)),function(){return Mr(m)}}),[E,g]),E&&v){var x={children:n.placeholder,attributes:{"data-slate-placeholder":!0,"aria-hidden":!0,style:{position:"absolute",top:0,pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",WebkitUserSelect:"none",textDecoration:"none",WebkitUserModify:Ie?"inherit":void 0},contentEditable:!1,ref:y}};b=t.createElement(t.Fragment,null,b,a(x))}return l({attributes:{"data-slate-leaf":!0},children:b,leaf:n,text:o,leafPosition:c})},Ar=t.memo(Br,(function(e,t){return Pr(e.parent,t.parent,e.text,t.text)&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&n.Text.equals(t.leaf,e.leaf)&&t.leaf[yt]===e.leaf[yt]})),_r=function(e){var n=e.attributes,r=e.children;return t.createElement("span",Rr({},n),r)},Fr=i((function(e){e.exports=function(e){if(Array.isArray(e))return g(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Fr);var Ir=i((function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Ir);var Lr=i((function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Lr);var Wr=i((function(e){e.exports=function(e){return Fr(e)||Ir(e)||m(e)||Lr()},e.exports.__esModule=!0,e.exports.default=e.exports})),zr=o(Wr);function Ur(e,n){var r,o=t.useReducer((function(e){return e+1}),0),i=w(o,2)[1],a=t.useRef(void 0),s=t.useRef((function(){return null})),l=t.useRef(null);try{if(e!==s.current||a.current){var c=e();r=n(l.current,c)?l.current:c}else r=l.current}catch(e){throw a.current&&e instanceof Error&&(e.message+="\nThe error may be correlated with this previous error:\n".concat(a.current.stack,"\n\n")),e}return s.current=e,l.current=r,a.current=void 0,[r,t.useCallback((function(){try{var e=s.current();if(n(l.current,e))return;l.current=e}catch(e){e instanceof Error?a.current=e:a.current=new Error(String(e))}i()}),[])]}var qr=t.createContext({}),Vr=function(e,r){var o=ue(),i=t.useContext(qr),a=i.decorate,s=i.addEventListener,l=Ur((function(){var t=Sn.findPath(o,e),r=a([e,t]);if(n.Node.isText(e)){var i=n.Editor.range(o,t);return r.flatMap((function(e){var t=n.Range.intersection(e,i);return t?[t]:[]}))}return r}),n.Node.isText(e)?vn:pn),c=w(l,2),u=c[0],d=c[1];return Nn((function(){var e=s(d);return d(),e}),[s,d]),t.useMemo((function(){return[].concat(zr(u),zr(r))}),[u,r])};function Kr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Hr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Kr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $r=function(e){return t.createElement(Yr,Hr({},e))},Xr=function(e){for(var r=e.decorations,o=e.isLast,i=e.parent,a=e.renderPlaceholder,s=e.renderLeaf,l=e.renderText,c=void 0===l?$r:l,u=e.text,d=ue(),f=t.useRef(null),h=Vr(u,r),p=n.Text.decorations(u,h),v=Sn.findKey(d,u),g=[],m=0;m<p.length;m++){var y=p[m],b=y.leaf,w=y.position;g.push(t.createElement(Ar,{isLast:o&&m===p.length-1,key:"".concat(v.id,"-").concat(m),renderPlaceholder:a,leaf:b,leafPosition:w,text:u,parent:i,renderLeaf:s}))}var E=t.useCallback((function(e){var t=it.get(d);e?(null==t||t.set(v,e),rt.set(u,e),nt.set(e,u)):(null==t||t.delete(v),rt.delete(u),f.current&&nt.delete(f.current)),f.current=e}),[f,d,v,u]);return c({text:u,children:g,attributes:{"data-slate-node":"text",ref:E}})},Gr=t.memo(Xr,(function(e,t){return Pr(e.parent,t.parent,e.text,t.text)&&t.isLast===e.isLast&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&vn(t.decorations,e.decorations)})),Yr=function(e){var n=e.attributes,r=e.children;return t.createElement("span",Hr({},n),r)};function Jr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Zr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Qr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return eo(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?eo(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function eo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var to=function(e){var t,r=Qr(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=E(n.Node.string(o));if("neutral"!==i)return i}}catch(e){r.e(e)}finally{r.f()}},no=function(e,t){return function(e,t){return n.Editor.isVoid(e,t)?[n.Node.texts(t).next().value[0]]:t.children}(e,t).findIndex((function(e){return!rt.has(e)}))},ro=function(e){return t.createElement(ao,Zr({},e))},oo=function(e){var r=e.decorations,o=e.element,i=e.renderElement,a=void 0===i?ro:i,s=e.renderChunk,l=e.renderPlaceholder,c=e.renderLeaf,u=e.renderText,d=ue(),f=Do(),h=d.isInline(o),p=Vr(o,r),v=Sn.findKey(d,o),g=t.useCallback((function(e){var t=it.get(d);e?(null==t||t.set(v,e),rt.set(o,e),nt.set(e,o)):(null==t||t.delete(v),rt.delete(o))}),[d,v,o]);Nn((function(){var e=no(d,o);if(-1!==e){var t=o.type,n=Sn.findPath(d,o);d.onDOMError(new Error("renderElement didn't render the children of the ".concat("string"==typeof t?'"'.concat(t,'" '):"","element at path ").concat(JSON.stringify(n),": child ").concat(e," has no DOM node. Render the `children` prop inside the element.")))}}),[d,o]);var m=So({decorations:p,node:o,renderElement:a,renderChunk:s,renderPlaceholder:l,renderLeaf:c,renderText:u}),y={"data-slate-node":"element",ref:g};if(h&&(y["data-slate-inline"]=!0),!h&&n.Editor.hasInlines(d,o)){var b=n.Node.string(o),x=""===b?function(e){var t,n=Ze.get(e),r=Je.get(e);if(n&&void 0!==r){var o=n.children.slice(0,r).reverse(),i=n.children.slice(r+1);return null!==(t=to(o))&&void 0!==t?t:to(i)}}(o):E(b);"rtl"===x&&(y.dir=x)}if(n.Editor.isVoid(d,o)){y["data-slate-void"]=!0,!f&&h&&(y.contentEditable=!1);var O=h?"span":"div",k=n.Node.texts(o),C=w(k,1),S=w(C[0],1)[0];m=t.createElement(O,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute",userSelect:"none",WebkitUserSelect:"none"}},t.createElement(Gr,{renderPlaceholder:l,decorations:[],isLast:!1,parent:o,text:S})),Je.set(S,0),Ze.set(S,o)}return a({attributes:y,children:m,element:o})},io=t.memo(oo,(function(e,t){return e.element===t.element&&e.renderElement===t.renderElement&&e.renderChunk===t.renderChunk&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&pn(e.decorations,t.decorations)})),ao=function(e){var n=e.attributes,r=e.children,o=e.element,i=ue().isInline(o)?"span":"div";return t.createElement(i,Zr(Zr({},n),{},{style:{position:"relative"}}),r)},so=i((function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports})),lo=o(so),co=i((function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports})),uo=o(co),fo=function(){return uo((function e(t,n){var r=n.chunkSize,o=n.debug;lo(this,e),h(this,"root",void 0),h(this,"chunkSize",void 0),h(this,"debug",void 0),h(this,"reachedEnd",void 0),h(this,"pointerChunk",void 0),h(this,"pointerIndex",void 0),h(this,"pointerIndexStack",void 0),h(this,"cachedPointerNode",void 0),this.root=t,this.chunkSize=r,this.debug=null!=o&&o,this.pointerChunk=t,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.validateState()}),[{key:"readLeaf",value:function(){if(this.reachedEnd)return null;for(;;){if(this.pointerIndex+1<this.pointerSiblings.length){this.pointerIndex++,this.cachedPointerNode=void 0;break}if("root"===this.pointerChunk.type)return this.reachedEnd=!0,null;this.exitChunk()}return this.validateState(),this.enterChunkUntilLeaf(!1),this.pointerNode}},{key:"returnToPreviousLeaf",value:function(){if(this.reachedEnd)return this.reachedEnd=!1,void this.enterChunkUntilLeaf(!0);for(;;){if(this.pointerIndex>=1){this.pointerIndex--,this.cachedPointerNode=void 0;break}if("root"===this.pointerChunk.type)return void(this.pointerIndex=-1);this.exitChunk()}this.validateState(),this.enterChunkUntilLeaf(!0)}},{key:"insertBefore",value:function(e){this.returnToPreviousLeaf(),this.insertAfter(e),this.readLeaf()}},{key:"insertAfter",value:function(e){if(0!==e.length){for(var t=0,n=0;"chunk"===this.pointerChunk.type&&this.pointerIndex===this.pointerSiblings.length-1;){var r=this.chunkSize-this.pointerSiblings.length,o=Math.min(r,e.length);if(o>0){var i=e.splice(0,o);this.rawInsertAfter(i,t)}this.exitChunk(),t++}if(0!==e.length){var a=this.savePointer(),s=null;if(this.readLeaf())for(;"chunk"===this.pointerChunk.type&&0===this.pointerIndex;){var l=this.chunkSize-this.pointerSiblings.length,c=Math.min(l,e.length);if(c>0){var u=e.splice(-c,c);this.pointerIndex=-1,this.cachedPointerNode=void 0,this.rawInsertAfter(u,n),s||(s=this.savePointer())}this.exitChunk(),n++}this.restorePointer(a);var d=Math.max(t,n);this.rawInsertAfter(e,d),s&&this.restorePointer(s),this.validateState()}}}},{key:"remove",value:function(){this.pointerSiblings.splice(this.pointerIndex--,1),this.cachedPointerNode=void 0,0===this.pointerSiblings.length&&"chunk"===this.pointerChunk.type?(this.exitChunk(),this.remove()):this.invalidateChunk(),this.validateState()}},{key:"invalidateChunk",value:function(){for(var e=this.pointerChunk;"chunk"===e.type;e=e.parent)this.root.modifiedChunks.add(e)}},{key:"atStart",get:function(){return"root"===this.pointerChunk.type&&-1===this.pointerIndex}},{key:"pointerSiblings",get:function(){return this.pointerChunk.children}},{key:"getPointerNode",value:function(){return this.reachedEnd||-1===this.pointerIndex?null:this.pointerSiblings[this.pointerIndex]}},{key:"pointerNode",get:function(){if(void 0!==this.cachedPointerNode)return this.cachedPointerNode;var e=this.getPointerNode();return this.cachedPointerNode=e,e}},{key:"getChunkPath",value:function(e){for(var t=[],n=e;"chunk"===n.type;n=n.parent){var r=n.parent.children.indexOf(n);if(-1===r)return null;t.unshift(r)}return t}},{key:"savePointer",value:function(){if(this.atStart)return"start";if(!this.pointerNode)throw new Error("Cannot save pointer when pointerNode is null");return{chunk:this.pointerChunk,node:this.pointerNode}}},{key:"restorePointer",value:function(e){if("start"===e)return this.pointerChunk=this.root,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,void(this.cachedPointerNode=void 0);var t=e.chunk,n=e.node,r=t.children.indexOf(n);if(-1===r)throw new Error("Cannot restore point because saved node is no longer in saved chunk");var o=this.getChunkPath(t);if(!o)throw new Error("Cannot restore point because saved chunk is no longer connected to root");this.pointerChunk=t,this.pointerIndex=r,this.pointerIndexStack=o,this.reachedEnd=!1,this.cachedPointerNode=n,this.validateState()}},{key:"enterChunk",value:function(e){var t;if("chunk"!==(null===(t=this.pointerNode)||void 0===t?void 0:t.type))throw new Error("Cannot enter non-chunk");if(this.pointerIndexStack.push(this.pointerIndex),this.pointerChunk=this.pointerNode,this.pointerIndex=e?this.pointerSiblings.length-1:0,this.cachedPointerNode=void 0,this.validateState(),0===this.pointerChunk.children.length)throw new Error("Cannot enter empty chunk")}},{key:"enterChunkUntilLeaf",value:function(e){for(;"chunk"===(null===(t=this.pointerNode)||void 0===t?void 0:t.type);){var t;this.enterChunk(e)}}},{key:"exitChunk",value:function(){if("root"===this.pointerChunk.type)throw new Error("Cannot exit root");var e=this.pointerChunk;this.pointerChunk=e.parent,this.pointerIndex=this.pointerIndexStack.pop(),this.cachedPointerNode=void 0,this.validateState()}},{key:"rawInsertAfter",value:function(e,t){var n,r=this;if(0!==e.length){for(var o=function(e,t,n){if(1===n)return e;for(var i=[],a=0;a<r.chunkSize;a++){var s=e.slice(a*n,(a+1)*n);if(0===s.length)break;var l={type:"chunk",key:new Ge,parent:t,children:[]};l.children=o(s,l,n/r.chunkSize),i.push(l)}return i},i=this.pointerSiblings.length+e.length,a=0,s=this.chunkSize;s<i;s*=this.chunkSize)a++;var l=Math.max(a,t),c=Math.pow(this.chunkSize,l),u=o(e,this.pointerChunk,c);(n=this.pointerSiblings).splice.apply(n,[this.pointerIndex+1,0].concat(zr(u))),this.pointerIndex+=u.length,this.cachedPointerNode=void 0,this.invalidateChunk(),this.validateState()}}},{key:"validateState",value:function(){if(this.debug){var e=function(t){if("chunk"===t.type){var n=t.parent,r=t.children;if(!n.children.includes(t))throw new Error("Debug: Chunk ".concat(t.key.id," has an incorrect parent property"));r.forEach(e)}};if(this.root.children.forEach(e),void 0!==this.cachedPointerNode&&this.cachedPointerNode!==this.getPointerNode())throw new Error("Debug: The cached pointer is incorrect and has not been invalidated");var t=this.getChunkPath(this.pointerChunk);if(!t)throw new Error("Debug: The pointer chunk is not connected to the root");if(!n.Path.equals(this.pointerIndexStack,t))throw new Error("Debug: The cached index stack [".concat(this.pointerIndexStack.join(", "),"] does not match the path of the pointer chunk [").concat(t.join(", "),"]"))}}}])}(),ho=function(){return uo((function e(t,n){lo(this,e),h(this,"editor",void 0),h(this,"children",void 0),h(this,"cachedKeys",void 0),h(this,"pointerIndex",void 0),this.editor=t,this.children=n,this.cachedKeys=new Array(n.length),this.pointerIndex=0}),[{key:"read",value:function(e){if(1===e)return[this.children[this.pointerIndex++]];var t=this.remaining(e);return this.pointerIndex+=e,t}},{key:"remaining",value:function(e){return void 0===e?this.children.slice(this.pointerIndex):this.children.slice(this.pointerIndex,this.pointerIndex+e)}},{key:"reachedEnd",get:function(){return this.pointerIndex>=this.children.length}},{key:"lookAhead",value:function(e,t){var n=this.children.indexOf(e,this.pointerIndex);if(n>-1)return n-this.pointerIndex;for(var r=this.pointerIndex;r<this.children.length;r++){var o=this.children[r];if(this.findKey(o,r)===t)return r-this.pointerIndex}return-1}},{key:"toChunkLeaves",value:function(e,t){var n=this;return e.map((function(e,r){return{type:"leaf",node:e,key:n.findKey(e,t+r),index:t+r}}))}},{key:"findKey",value:function(e,t){var n=this.cachedKeys[t];if(n)return n;var r=Sn.findKey(this.editor,e);return this.cachedKeys[t]=r,r}}])}(),po=function(e,t){for(var n,r=t.chunkTree,o=t.children,i=t.chunkSize,a=t.rerenderChildren,s=void 0===a?[]:a,l=t.onInsert,c=t.onUpdate,u=t.onIndexChange,d=t.debug,f=new fo(r,{chunkSize:i,debug:d}),h=new ho(e,o),p=function(){var e=h.lookAhead(n.node,n.key),t=e>0&&r.movedNodeKeys.has(n.key);if(-1===e||t)return f.remove(),1;var o=h.pointerIndex,i=h.read(e+1),a=i.pop();if(i.length){var d=h.toChunkLeaves(i,o);f.insertBefore(d),i.forEach((function(e,t){null==l||l(e,o+t)}))}var p=h.pointerIndex-1;n.node!==a&&(n.node=a,f.invalidateChunk(),null==c||c(a,p)),n.index!==p&&(n.index=p,null==u||u(a,p)),s.includes(p)&&f.invalidateChunk()};n=f.readLeaf();)p();if(!h.reachedEnd){var v=h.remaining(),g=h.toChunkLeaves(v,h.pointerIndex);f.returnToPreviousLeaf(),f.insertAfter(g),v.forEach((function(e,t){null==l||l(e,h.pointerIndex+t)}))}r.movedNodeKeys.clear()};function vo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function go(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vo(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var mo=new WeakMap,yo=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Sn.findKey(e,t),o=mo.get(r);return o||(o={type:"root",movedNodeKeys:new Set,modifiedChunks:new Set,children:[]},mo.set(r,o)),n.reconcile&&po(e,go({chunkTree:o,children:t.children},n.reconcile)),o};function bo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var wo=function(e){return e.children},Eo=function(e){var n=e.root,r=e.ancestor,o=e.renderElement,i=e.renderChunk,a=void 0===i?wo:i;return r.children.map((function(e){if("chunk"===e.type){var i=e.key.id,s=a({highest:r===n,lowest:e.children.some((function(e){return"leaf"===e.type})),attributes:{"data-slate-chunk":!0},children:t.createElement(Oo,{root:n,ancestor:e,renderElement:o,renderChunk:a})});return t.createElement(t.Fragment,{key:i},s)}var l=e.node;return o(l,e.index,e.key)}))},xo=function(e){return t.useEffect((function(){e.root.modifiedChunks.clear()})),t.createElement(Eo,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?bo(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},e))},Oo=t.memo(Eo,(function(e,t){return e.root===t.root&&e.renderElement===t.renderElement&&e.renderChunk===t.renderChunk&&!t.root.modifiedChunks.has(t.ancestor)})),ko=t.createContext(null),Co=function(){return t.useContext(ko)},So=function(e){var r=e.decorations,o=e.node,i=e.renderElement,a=e.renderChunk,s=e.renderPlaceholder,l=e.renderText,c=e.renderLeaf,u=ue();Ye.set(u,!1);var d=n.Node.isElement(o)&&!u.isInline(o)&&n.Editor.hasInlines(u,o)?null:u.getChunkSize(o),f=!!d,h=To(u,o,r),p=h.decorationsByChild,v=h.childrenToRedecorate;f||o.children.forEach((function(e,t){Je.set(e,t),Ze.set(e,o)}));var g=t.useCallback((function(e,n,r){var o=null!=r?r:Sn.findKey(u,e);return t.createElement(ko.Provider,{key:"provider-".concat(o.id),value:e},t.createElement(io,{decorations:p[n],element:e,key:o.id,renderElement:i,renderChunk:a,renderPlaceholder:s,renderLeaf:c,renderText:l}))}),[u,p,i,a,s,c,l]);if(!f)return o.children.map((function(e,r){return n.Node.isText(e)?function(e,n){var r=Sn.findKey(u,e);return t.createElement(Gr,{decorations:p[n],key:r.id,isLast:n===o.children.length-1,parent:o,renderPlaceholder:s,renderLeaf:c,renderText:l,text:e})}(e,r):g(e,r)}));var m=yo(u,o,{reconcile:{chunkSize:d,rerenderChildren:v,onInsert:function(e,t){Je.set(e,t),Ze.set(e,o)},onUpdate:function(e,t){Je.set(e,t),Ze.set(e,o)},onIndexChange:function(e,t){Je.set(e,t)}}});return t.createElement(xo,{root:m,ancestor:m,renderElement:g,renderChunk:a})},To=function(e,r,o){var i=((e,t,r)=>{const o=Array.from(t.children,(()=>[]));if(0===r.length)return o;const i=xt.findPath(e,t),a=i.length,s=n.Editor.range(e,i),l=new Array(t.children.length),c=t=>{const r=l[t];if(r)return r;const o=n.Editor.range(e,[...i,t]);return l[t]=o,o};for(const e of r){const t=n.Range.intersection(s,e);if(!t)continue;const[r,i]=n.Range.edges(t),l=r.path[a],u=i.path[a];for(let t=l;t<=u;t++){const r=o[t];if(!r)continue;const i=c(t),a=n.Range.intersection(i,e);a&&r.push(fn(fn({},e),a))}}return o})(e,r,o),a=t.useRef(i).current,s=[];a.length=i.length;for(var l=0;l<i.length;l++){var c,u=i[l],d=null!==(c=a[l])&&void 0!==c?c:null;pn(d,u)||(a[l]=u,s.push(l))}return{decorationsByChild:a,childrenToRedecorate:s}},Po=t.createContext(!1),Do=function(){return t.useContext(Po)},Ro=t.createContext({}),No=function(e,t){return e===t};function Mo(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:No,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.deferred,i=t.useContext(Ro);if(!i)throw new Error("The `useSlateSelector` hook must be used inside the <Slate> component's context.");var a=i.addEventListener,s=ue(),l=t.useCallback((function(){return e(s)}),[s,e]),c=Ur(l,n),u=w(c,2),d=u[0],f=u[1];return Nn((function(){var e=a(f,{deferred:o});return f(),e}),[a,f,o]),d}var jo=function(){var e=t.useContext(Ro).addEventListener,n=t.useReducer((function(e){return e+1}),0),r=w(n,2)[1];if(!e)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");return Nn((function(){return e(r)}),[e]),ue()},Bo=new WeakMap;var Ao=function(e){return be(e)&&e.hasAttribute("data-slate-placeholder")},_o=function(e,t){var n=[],r=function(){n=[]};return{registerMutations:function(r){var o;if(t.current){var i=r.filter((function(t){return o=(n=t).addedNodes,i=n.removedNodes,!((a=[].concat(zr(Array.from(o)),zr(Array.from(i)))).length>0&&a.every(Ao))&&Pe(e,t,r);var n,o,i,a}));(o=n).push.apply(o,zr(i))}},restoreDOM:function(){n.length>0&&(n.reverse().forEach((function(e){"characterData"!==e.type&&(e.removedNodes.forEach((function(t){e.target.insertBefore(t,e.nextSibling)})),e.addedNodes.forEach((function(t){e.target.removeChild(t)})))})),r())},clear:r}},Fo=function(e){var t=e.target;if("characterData"===e.type)t.nodeValue=e.oldValue;else if("attributes"===e.type&&be(t)){var n=e.attributeName;null===e.oldValue?t.removeAttribute(n):t.setAttribute(n,e.oldValue)}else e.addedNodes.forEach((function(e){var t;return null===(t=e.parentNode)||void 0===t?void 0:t.removeChild(e)})),e.removedNodes.forEach((function(n){return t.insertBefore(n,e.nextSibling)}))},Io=function(e,t){var n=Sn.resolveDOMRange(e,{anchor:t,focus:t});if(!n)return null;var r=Array.from(n.getClientRects()),o=w(r,1)[0];return(null!=o?o:n.getBoundingClientRect()).top},Lo=function(e,t,r){var o=n.Editor.above(e,{at:t,match:function(t){return n.Node.isElement(t)&&e.isInline(t)}});if(!o||e.isVoid(o[0])||e.isElementReadOnly(o[0])||!(r?n.Editor.isStart(e,t,o[1]):n.Editor.isEnd(e,t,o[1])))return"character";if(r&&!n.Path.hasPrevious(o[1]))return"character";var i=r?n.Path.previous(o[1]):n.Path.next(o[1]);if(!n.Editor.hasPath(e,i))return"character";var a=n.Node.get(e,i);return n.Node.isText(a)&&""===a.text?"offset":"character"},Wo=function(e,t){var r=e.selection;if(r&&n.Range.isCollapsed(r)){var o=Te(Sn.findDocumentOrShadowRoot(e)),i=null==o?void 0:o.anchorNode;if(o&&function(e){return we(e)&&e.nodeType===e.TEXT_NODE}(i)){var a=o.anchorOffset,s=a-t.length;if(!(s<0||i.data.slice(s,a)!==t)&&Sn.hasDOMNode(e,i,{editable:!0})){var l=Sn.findPath(e,Sn.toSlateNode(e,i));n.Path.equals(l,r.anchor.path)&&!n.Editor.void(e,{at:r})||i.deleteData(s,t.length)}}}};function zo(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Uo(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Uo(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function Uo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var qo=function(e,t){var r;return null===(r=n.Editor.above(e,{at:t,match:function(t){return n.Node.isElement(t)&&n.Editor.isBlock(e,t)}}))||void 0===r?void 0:r[1]},Vo=function(e,t){var r=n.Range.edges(t),o=w(r,2),i=o[0],a=o[1],s=qo(e,i),l=qo(e,a);return s&&l&&1===s.length&&1===l.length&&!(s[0]>=l[0])&&n.Editor.isStart(e,i,s)&&n.Editor.isStart(e,a,l)?Array.from({length:l[0]-s[0]},(function(e,t){return[s[0]+t]})):null},Ko=function(e,t){if(n.Range.isCollapsed(t)){var r=n.Editor.void(e,{at:t});r&&n.Transforms.removeNodes(e,{at:r[1],voids:!0})}else{var o=Vo(e,t);if(!o)return n.Transforms.select(e,t),void n.Editor.deleteFragment(e);var i=n.Editor.pathRef(e,n.Path.next(o[o.length-1]));n.Editor.withoutNormalizing(e,(function(){var t,r=zo(zr(o).reverse());try{for(r.s();!(t=r.n()).done;){var i=t.value;n.Transforms.removeNodes(e,{at:i})}}catch(e){r.e(e)}finally{r.f()}}));var a=i.unref();a&&n.Transforms.select(e,n.Editor.start(e,a))}},Ho=i((function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Ho);var $o=i((function(e){var t=c.default;e.exports=function(e,n){if(n&&("object"==t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return Ho(e)},e.exports.__esModule=!0,e.exports.default=e.exports})),Xo=o($o),Go=i((function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})),Yo=o(Go),Jo=i((function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));o(Jo);var Zo=i((function(e){e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Jo(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports})),Qo=o(Zo);function ei(e,t,n){return t=Yo(t),Xo(e,ti()?Reflect.construct(t,n||[],Yo(e).constructor):t.apply(e,n))}function ti(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ti=function(){return!!e})()}var ni={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0},ri=function(e){function t(){var e;lo(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=ei(this,t,[].concat(r)),h(e,"context",null),h(e,"manager",null),h(e,"mutationObserver",null),e}return Qo(t,e),uo(t,[{key:"observe",value:function(){var e,t=this.props.node;if(!t.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");null===(e=this.mutationObserver)||void 0===e||e.observe(t.current,ni)}},{key:"componentDidMount",value:function(){var e=this.props.receivedUserInput,t=this.context;this.manager=_o(t,e),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}},{key:"getSnapshotBeforeUpdate",value:function(){var e,t,n,r,o=null===(e=this.mutationObserver)||void 0===e?void 0:e.takeRecords();null!=o&&o.length&&(null===(r=this.manager)||void 0===r||r.registerMutations(o));return null===(t=this.mutationObserver)||void 0===t||t.disconnect(),null===(n=this.manager)||void 0===n||n.restoreDOM(),null}},{key:"componentDidUpdate",value:function(){var e;null===(e=this.manager)||void 0===e||e.clear(),this.observe()}},{key:"componentWillUnmount",value:function(){var e;null===(e=this.mutationObserver)||void 0===e||e.disconnect()}},{key:"render",value:function(){return this.props.children}}])}(t.Component);h(ri,"contextType",ce);var oi=_e?ri:function(e){var n=e.children;return t.createElement(t.Fragment,null,n)},ii=new WeakMap,ai=t.createContext(!1),si=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderChunk","renderLeaf","renderText","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],li=["text"];function ci(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return ui(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ui(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function ui(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function di(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?di(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):di(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var hi=function(e){return we(e)&&3===e.nodeType},pi=function(e){return t.createElement(t.Fragment,null,So(e))},vi=t.forwardRef((function(e,r){var o=t.useCallback((function(e){return t.createElement(wi,fi({},e))}),[]),i=e.autoFocus,a=e.decorate,s=void 0===a?Ei:a,c=e.onDOMBeforeInput,u=e.placeholder,d=e.readOnly,f=void 0!==d&&d,p=e.renderElement,v=e.renderChunk,g=e.renderLeaf,m=e.renderText,y=e.renderPlaceholder,b=void 0===y?o:y,x=e.scrollSelectionIntoView,O=void 0===x?xi:x,k=e.style,C=void 0===k?{}:k,S=e.as,T=void 0===S?"div":S,P=e.disableDefaultStyles,D=void 0!==P&&P,R=l(e,si),N=jo(),M=t.useState(!1),j=w(M,2),B=j[0],A=j[1];Nn((function(){return ii.set(N,B),function(){ii.delete(N)}}),[N,B]);var _=t.useRef(null),F=t.useRef(N.children),I=t.useRef(N.selection),L=t.useRef(!1),W=t.useRef(!1),z=t.useRef([]),U=t.useRef(null),q=t.useState(),V=w(q,2),K=V[0],H=V[1],$=t.useRef(!1),X=function(e){var n=t.useMemo((function(){var t=_o(e,{current:!0}),n=null,r=function(){null!=n||(n=new MutationObserver(t.registerMutations)),n.observe(Sn.toDOMNode(e,e),{childList:!0,subtree:!0})},o=function(){n&&(t.registerMutations(n.takeRecords()),n.disconnect())};return{observe:r,track:function(e){(n||null!=e&&e.includes("\n"))&&r()},pause:o,restore:function(){o(),t.restoreDOM()},clear:function(){var e;null===(e=n)||void 0===e||e.disconnect(),n=null,t.clear()}}}),[e]);return t.useEffect((function(){return function(){return n.clear()}}),[n]),n}(N),G=function(e){var n=t.useMemo((function(){var t=[],n=null,r=function(e){var n;0===t.length&&setTimeout((function(){t=[]})),(n=t).push.apply(n,zr(e))};return{observe:function(){null!=n||(n=new MutationObserver(r)),n.observe(Sn.toDOMNode(e,e),{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},disconnect:function(){var e;null===(e=n)||void 0===e||e.disconnect(),t=[]},revert:function(){var e,r,o=[].concat(zr(t),zr(null!==(e=null===(r=n)||void 0===r?void 0:r.takeRecords())&&void 0!==e?e:[]));t=[],o.reverse().forEach(Fo)}}}),[e]);return t.useEffect((function(){return n.observe(),n.disconnect}),[n]),n}(N),Y=t.useRef(!1),J=function(){var e=ue(),n=t.useRef(!1),r=t.useRef(0),o=t.useCallback((function(){if(!n.current){n.current=!0;var t=Sn.getWindow(e);t.cancelAnimationFrame(r.current),r.current=t.requestAnimationFrame((function(){n.current=!1}))}}),[e]);return t.useEffect((function(){return function(){return cancelAnimationFrame(r.current)}}),[]),{receivedUserInput:n,onUserInput:o}}(),Z=J.onUserInput,Q=J.receivedUserInput,ne=t.useReducer((function(e){return e+1}),0),re=w(ne,2)[1];mt.set(N,re),at.set(N,f);var oe=t.useMemo((function(){return{isBlurring:!1,isDraggingInternally:!1,isTabbing:!1,pendingSelection:null,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}}),[]);t.useEffect((function(){_.current&&i&&(N.children.length>0?Sn.focus(N):_.current.focus())}),[i,N]);var ie=t.useRef(void 0),ae=t.useMemo((function(){return te((function(){if(Ye.get(N))ae();else{oe.pendingSelection=null;var e=Sn.toDOMNode(N,N).getRootNode();if(!$.current&&Ie&&e instanceof ShadowRoot){$.current=!0;var t=(()=>{let e=document.activeElement;for(;null!==(t=e)&&void 0!==t&&t.shadowRoot&&null!==(n=e.shadowRoot)&&void 0!==n&&n.activeElement;){var t,n,r;e=null===(r=e)||void 0===r||null===(r=r.shadowRoot)||void 0===r?void 0:r.activeElement}return e})();return t?document.execCommand("indent"):n.Transforms.deselect(N),void($.current=!1)}var r=ie.current;if((_e||!Sn.isComposing(N))&&(!oe.isUpdatingSelection||null!=r&&r.isFlushing())&&!oe.isDraggingInternally){var o=Sn.findDocumentOrShadowRoot(N),i=o.activeElement,a=Sn.toDOMNode(N,N),s=Te(o);if(i===a?(oe.latestElement=i,st.set(N,!0)):st.delete(N),!s)return n.Transforms.deselect(N);var l=s.anchorNode,c=s.focusNode,u=Sn.hasEditableTarget(N,l)||Sn.isTargetInsideNonReadonlyVoid(N,l),d=Sn.hasTarget(N,c),h=we(i)&&a.contains(i);if(u&&d&&(f||h||oe.isBlurring)){var p=Sn.toSlateRange(N,s,{exactMatch:!1,suppressThrow:!0});if(p)if(Sn.isComposing(N)||null!=r&&r.hasPendingChanges()||null!=r&&r.isFlushing())null==r||r.handleUserSelect(p);else s.isCollapsed&&!mi(l)&&N.selection&&n.Range.equals(p,N.selection)?yi(N,s,oe):n.Transforms.select(N,p)}!f||u&&d||n.Transforms.deselect(N)}}}),100)}),[N,f,oe]),se=t.useMemo((function(){return ee(ae,0)}),[ae]),le=t.useCallback((function(){var e=Sn.toDOMNode(N,N).getRootNode();se.flush(),Ie&&e instanceof ShadowRoot||ae(),ae.flush()}),[N,ae,se]);ie.current=_n({node:_,onDOMSelectionChange:ae,scheduleOnDOMSelectionChange:se}),Nn((function(){var e,t,r;_.current&&(r=ye(_.current))?(Qe.set(N,r),et.set(N,_.current),rt.set(N,_.current),nt.set(_.current,N)):rt.delete(N);var o=N.selection,i=L.current;L.current=!1;var a=W.current;W.current=!1;var s=(i&&F.current!==N.children||a)&&!!o&&(!I.current||!n.Range.equals(I.current,o));F.current=N.children,I.current=o;var l=Sn.findDocumentOrShadowRoot(N),c=Te(l);if(c&&Sn.isFocused(N)&&(null===(e=ie.current)||void 0===e||!e.hasPendingAction())){var u=function(e){var t="None"!==c.type;if(o||t){var r,i=c.focusNode;if(Fe&&c.rangeCount>1){var a=c.getRangeAt(0),l=c.getRangeAt(c.rangeCount-1);r=a.startContainer===i?l.endContainer:a.startContainer}else r=c.anchorNode;var u=et.get(N),d=!1;if(Ne(u,r)&&Ne(u,i)&&(d=!0),t&&d&&o&&!e){var f,h=Sn.toSlateRange(N,c,{exactMatch:!0,suppressThrow:!0});if(h&&n.Range.equals(h,o)&&(!oe.hasMarkPlaceholder||null!==(f=r)&&void 0!==f&&null!==(f=f.parentElement)&&void 0!==f&&f.hasAttribute("data-slate-mark-placeholder")))return void(s&&O(N,c.getRangeAt(0)))}if(!o||Sn.hasRange(N,o)){var p=oe.pendingSelection;if(oe.pendingSelection=null,!p||e||p.basedOn!==o||o&&n.Range.equals(p.range,o)){oe.isUpdatingSelection=!0;var v=o&&Sn.resolveDOMRange(N,o);return v?(Sn.isComposing(N)&&!_e?c.rangeCount>0&&c.collapseToEnd():n.Range.isBackward(o)?c.setBaseAndExtent(v.endContainer,v.endOffset,v.startContainer,v.startOffset):c.setBaseAndExtent(v.startContainer,v.startOffset,v.endContainer,v.endOffset),O(N,v)):c.removeAllRanges(),v}n.Transforms.select(N,p.range)}else N.selection=Sn.toSlateRange(N,c,{exactMatch:!1,suppressThrow:!0})}};c.rangeCount<=1&&u();var d="action"===(null===(t=ie.current)||void 0===t?void 0:t.isFlushing());if(_e&&d){var f=null,h=requestAnimationFrame((function(){if(d){var e=function(e){var t=et.get(N);t&&(t.focus(),u(e))};e(),f=setTimeout((function(){e(!0),oe.isUpdatingSelection=!1}))}}));return function(){cancelAnimationFrame(h),f&&clearTimeout(f)}}setTimeout((function(){oe.isUpdatingSelection=!1}))}}));var ce=t.useCallback((function(e){if(f)Ci(e,c);else if(Sn.hasEditableTarget(N,e.target)){Si(N,e);var t=Sn.toDOMNode(N,N).getRootNode();if(null!=$&&$.current&&Ie&&t instanceof ShadowRoot){var r=e.getTargetRanges()[0],o=new window.Range;o.setStart(r.startContainer,r.startOffset),o.setEnd(r.endContainer,r.endOffset);var i=Sn.toSlateRange(N,o,{exactMatch:!1,suppressThrow:!0});return i&&n.Transforms.select(N,i),e.preventDefault(),void e.stopImmediatePropagation()}if(Z(),L.current=!0,!Ci(e,c)){var a;if(ie.current)return ie.current.handleDOMBeforeInput(e);le();var s=N.selection,l=e.inputType,u=e.dataTransfer||e.data||void 0,d="insertCompositionText"===l||"deleteCompositionText"===l;if(d&&Sn.isComposing(N))return void((We||Y.current)&&X.track(e.data));var h=!1,p=null;if("insertText"===l&&s&&n.Range.isCollapsed(s)&&e.data&&1===e.data.length&&/[a-z ]/i.test(e.data)&&0!==s.anchor.offset){h=!0,(N.marks||"function"==typeof n.Editor.insertionPoint&&!n.Point.equals(n.Editor.insertionPoint(N,s.anchor),s.anchor))&&(h=!1);var v=Te(Sn.findDocumentOrShadowRoot(N)),g=null==v?void 0:v.anchorNode;if(mi(g)||(h=!1),!Ye.get(N)){var m=s.anchor,y=Sn.resolveDOMPoint(N,m);if(y){var b,E,x=w(y,2),O=x[0],k=x[1],C=null===(b=O.parentElement)||void 0===b?void 0:b.closest("a"),S=Sn.getWindow(N);if(h&&C&&Sn.hasDOMNode(N,C)){var T,P=null==S?void 0:S.document.createTreeWalker(C,NodeFilter.SHOW_TEXT).lastChild();P===O&&(null===(T=P.textContent)||void 0===T?void 0:T.length)===k&&(h=!1)}if(h&&O.parentElement&&"pre"===(null==S||null===(E=S.getComputedStyle(O.parentElement))||void 0===E?void 0:E.whiteSpace)){var D=n.Editor.above(N,{at:m.path,match:function(e){return n.Node.isElement(e)&&n.Editor.isBlock(N,e)}});D&&n.Node.string(D[0]).includes("\t")&&(h=!1)}h&&hi(O)&&(p=null!=v&&v.isCollapsed&&hi(g)?[g,v.anchorOffset]:[O,k])}else h=!1}}if((!l.startsWith("delete")||l.startsWith("deleteBy"))&&!Ye.get(N)){var R=e.getTargetRanges(),M=w(R,1)[0];if(M){var j=Sn.toSlateRange(N,M,{exactMatch:!1,suppressThrow:!0});if(j){if(!s||!n.Range.equals(s,j)){h=!1;var B=!d&&N.selection&&!function(e,t,r){if(!n.Range.isCollapsed(t)||!n.Range.isCollapsed(r))return!1;var o=n.Path.isBefore(t.anchor.path,r.anchor.path)?[t.anchor,r.anchor]:[r.anchor,t.anchor],i=w(o,2),a=i[0],s=i[1];if(0!==s.offset||!n.Path.equals(n.Path.next(a.path),s.path))return!1;var l=n.Node.get(e,a.path);return n.Node.isText(l)&&a.offset===l.text.length}(N,N.selection,j)&&n.Editor.rangeRef(N,N.selection);n.Transforms.select(N,j),B&&ct.set(N,B)}}else h=!1;h&&hi(M.startContainer)&&(p=[M.startContainer,M.startOffset])}}if(d)return;if(h||(U.current=null,e.preventDefault()),s&&n.Range.isExpanded(s)&&l.startsWith("delete")){var _=l.endsWith("Backward")?"backward":"forward";return void n.Editor.deleteFragment(N,{direction:_})}switch(l){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":n.Editor.deleteFragment(N);break;case"deleteContent":case"deleteContentForward":n.Editor.deleteForward(N);break;case"deleteContentBackward":n.Editor.deleteBackward(N);break;case"deleteEntireSoftLine":n.Editor.deleteBackward(N,{unit:"line"}),n.Editor.deleteForward(N,{unit:"line"});break;case"deleteHardLineBackward":n.Editor.deleteBackward(N,{unit:"block"});break;case"deleteSoftLineBackward":n.Editor.deleteBackward(N,{unit:"line"});break;case"deleteHardLineForward":n.Editor.deleteForward(N,{unit:"block"});break;case"deleteSoftLineForward":n.Editor.deleteForward(N,{unit:"line"});break;case"deleteWordBackward":n.Editor.deleteBackward(N,{unit:"word"});break;case"deleteWordForward":n.Editor.deleteForward(N,{unit:"word"});break;case"insertLineBreak":n.Editor.insertSoftBreak(N);break;case"insertParagraph":n.Editor.insertBreak(N);break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if("insertFromComposition"===l&&Sn.isComposing(N)&&(A(!1),lt.set(N,!1)),"DataTransfer"===(null==u?void 0:u.constructor.name))Sn.insertData(N,u);else if("string"==typeof u)if(h){if(U.current=null,p&&s){var F=n.Editor.leaf(N,s.anchor),I=w(F,1)[0],W=w(p,2),q=W[0],V=W[1];U.current={point:s.anchor,text:I.text,domNode:q,domOffset:V,domText:q.data,char:u}}z.current.push((function(){return n.Editor.insertText(N,u)}))}else n.Editor.insertText(N,u)}var K=null===(a=ct.get(N))||void 0===a?void 0:a.unref();ct.delete(N),!K||N.selection&&n.Range.equals(N.selection,K)||n.Transforms.select(N,K)}}}),[N,Z,c,X,le,f]),de=t.useCallback((function(e){null==e?(ae.cancel(),se.cancel(),et.delete(N),rt.delete(N),_.current&&$e&&_.current.removeEventListener("beforeinput",ce)):$e&&e.addEventListener("beforeinput",ce),_.current=e,"function"==typeof r?r(e):r&&(r.current=e)}),[ae,se,N,ce,r]);Nn((function(){var e=Sn.getWindow(N),t=function(e){var t=e.target,n=t instanceof HTMLElement?t:null,r=null==n?void 0:n.tagName;"INPUT"!==r&&"TEXTAREA"!==r&&(oe.pendingSelection=function(){var e=ie.current;if(oe.isUpdatingSelection||oe.isDraggingInternally||Sn.isComposing(N)||null!=e&&e.hasPendingChanges()||null!=e&&e.isFlushing()||Ye.get(N))return null;var t=Te(Sn.findDocumentOrShadowRoot(N));if(!t||!Sn.hasEditableTarget(N,t.anchorNode)&&!Sn.isTargetInsideNonReadonlyVoid(N,t.anchorNode)||!Sn.hasTarget(N,t.focusNode))return null;var n=Sn.toSlateRange(N,t,{exactMatch:!1,suppressThrow:!0});return n?{range:n,basedOn:N.selection}:null}(),se())};e.document.addEventListener("selectionchange",t);var n=function(e){oe.isTabbing="Tab"===e.key},r=function(){oe.isTabbing=!1};e.document.addEventListener("keydown",n,!0),e.document.addEventListener("keyup",r,!0),e.document.addEventListener("pointerdown",r,!0);var o=function(){oe.isDraggingInternally=!1};return e.document.addEventListener("dragend",o),e.document.addEventListener("drop",o),function(){e.document.removeEventListener("selectionchange",t),e.document.removeEventListener("keydown",n,!0),e.document.removeEventListener("keyup",r,!0),e.document.removeEventListener("pointerdown",r,!0),e.document.removeEventListener("dragend",o),e.document.removeEventListener("drop",o)}}),[N,se,oe]);var fe=s([N,[]]),he=function(e){var n=t.useReducer((function(e){return e+1}),0),r=w(n,2)[1],o=t.useRef(new Set),i=t.useRef(!1),a=t.useRef(e);Nn((function(){a.current=e,o.current.forEach((function(e){return e()})),i.current?r():i.current=!0}),[e]);var s=t.useCallback((function(e){return a.current(e)}),[]),l=t.useCallback((function(e){return o.current.add(e),function(){o.current.delete(e)}}),[]);return t.useMemo((function(){return{decorate:s,addEventListener:l}}),[s,l])}(s),pe=u&&1===N.children.length&&1===Array.from(n.Node.texts(N)).length&&""===n.Node.string(N)&&!B,ve=t.useCallback((function(e){var t;e&&pe?H(null===(t=e.getBoundingClientRect())||void 0===t?void 0:t.height):H(void 0)}),[pe]);if(pe){var ge=n.Editor.start(N,[]);fe.push(h(h(h(h(h({},yt,!0),"placeholder",u),"onPlaceholderResize",ve),"anchor",ge),"focus",ge))}var me,Ee=N.marks;if(oe.hasMarkPlaceholder=!1,N.selection&&n.Range.isCollapsed(N.selection)&&Ee){var xe=N.selection.anchor,Oe=n.Node.leaf(N,xe.path);Oe.text;var ke=l(Oe,li);if(!n.Text.equals(Oe,Ee,{loose:!0})){oe.hasMarkPlaceholder=!0;var Ce=Object.fromEntries(Object.keys(ke).map((function(e){return[e,null]})));fe.push(fi(fi(fi(h({},bt,!0),Ce),Ee),{},{anchor:xe,focus:xe}))}}return t.useEffect((function(){setTimeout((function(){var e=N.selection;if(e){var t=e.anchor,r=n.Node.leaf(N,t.path);if(Ee&&!n.Text.equals(r,Ee,{loose:!0}))return void ft.set(N,Ee)}ft.delete(N)}))})),me=t.useContext(Ro).flushDeferred,Nn(me),t.createElement(Po.Provider,{value:f},t.createElement(ai.Provider,{value:B},t.createElement(qr.Provider,{value:he},t.createElement(oi,{node:_,receivedUserInput:Q},t.createElement(T,fi(fi({role:f?void 0:"textbox","aria-multiline":!f||void 0,"aria-placeholder":pe?u:void 0,translate:"no"},R),{},{spellCheck:!(!$e&&He)&&R.spellCheck,autoCorrect:$e||!He?R.autoCorrect:"false",autoCapitalize:$e||!He?R.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!f,zindex:-1,suppressContentEditableWarning:!0,ref:de,style:fi(fi({},D?{}:fi({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},K?{minHeight:K}:{})),C),onBeforeInput:t.useCallback((function(e){if(f)Oi(e,R.onBeforeInput);else if(!$e&&!Oi(e,R.onBeforeInput)&&Sn.hasSelectableTarget(N,e.target)&&(e.preventDefault(),!Sn.isComposing(N))){var t=e.data;n.Editor.insertText(N,t)}}),[R.onBeforeInput,N,f]),onInput:t.useCallback((function(e){var t;if(f)Oi(e,R.onInput);else if(Sn.hasEditableTarget(N,e.target)&&(X.pause(),!Oi(e,R.onInput)))if(ie.current)ie.current.handleInput();else{if(null!==(t=e.nativeEvent.inputType)&&void 0!==t&&t.startsWith("format")){var r=Te(Sn.findDocumentOrShadowRoot(N)),o=r&&Sn.resolveSlateRange(N,r);return G.revert(),void(r&&o&&(n.Transforms.select(N,o),yi(N,r,oe)))}var i,a=ci(z.current);try{for(a.s();!(i=a.n()).done;){(0,i.value)()}}catch(e){a.e(e)}finally{a.f()}z.current=[];var s=U.current;if(U.current=null,s){var l,c=s.point,u=s.text,d=s.domNode,h=s.domOffset,p=s.domText,v=s.char,g=n.Node.getIf(N,c.path);if(n.Text.isText(g)&&g.text===u&&d.isConnected&&d.data===p.slice(0,h)+v+p.slice(h))if(d.deleteData(h,v.length),N.selection&&n.Range.isCollapsed(N.selection)&&n.Point.equals(N.selection.anchor,c))null===(l=Te(Sn.findDocumentOrShadowRoot(N)))||void 0===l||l.collapse(d,h)}Sn.isFocused(N)||Si(N,e.nativeEvent)}}),[f,R.onInput,N,X,G]),onBlur:t.useCallback((function(e){if(f)Oi(e,R.onBlur);else if(!oe.isUpdatingSelection&&Sn.hasSelectableTarget(N,e.target)&&!Oi(e,R.onBlur)){var t=Sn.findDocumentOrShadowRoot(N);if(oe.latestElement!==t.activeElement){var r=e.relatedTarget;if(!(r===Sn.toDOMNode(N,N)||be(r)&&r.hasAttribute("data-slate-spacer"))){if(null!=r&&we(r)&&Sn.hasDOMNode(N,r)){var o=Sn.toSlateNode(N,r);if(n.Node.isElement(o)&&!N.isVoid(o))return}oe.isBlurring=!0;try{le()}finally{oe.isBlurring=!1}if(Ie){var i=Te(t);null==i||i.removeAllRanges()}st.delete(N)}}}}),[f,oe,N,R.onBlur,le]),onClick:t.useCallback((function(e){if(Sn.hasTarget(N,e.target)&&le(),Sn.hasTarget(N,e.target)&&!Oi(e,R.onClick)&&we(e.target)){var t,r=Sn.toSlateNode(N,e.target);try{t=Sn.findPath(N,r)}catch(e){return}if(!n.Editor.hasPath(N,t)||n.Node.get(N,t)!==r)return;if(3===e.detail&&t.length>=1){var o=t;if(!n.Node.isElement(r)||!n.Editor.isBlock(N,r)){var i,a=n.Editor.above(N,{match:function(e){return n.Node.isElement(e)&&n.Editor.isBlock(N,e)},at:t});o=null!==(i=null==a?void 0:a[1])&&void 0!==i?i:t.slice(0,1)}var s=n.Editor.above(N,{at:n.Editor.start(N,o),match:function(e){var t;return n.Node.isElement(e)&&!(null===(t=N.isIsolated)||void 0===t||!t.call(N,e))}});if(o.length>1||s){var l=n.Editor.range(N,o);return void n.Transforms.select(N,l)}}if(f)return;var c=n.Editor.start(N,t),u=n.Editor.end(N,t),d=n.Editor.void(N,{at:c}),h=n.Editor.void(N,{at:u}),p=N.selection&&n.Range.isCollapsed(N.selection)&&n.Editor.void(N,{at:N.selection.anchor});if(e.shiftKey&&p&&!n.Path.isAncestor(p[1],t)&&(!d||!n.Path.equals(d[1],p[1]))){var v=Sn.resolveEventRange(N,e);if(!v)return;var g=n.Editor.start(N,p[1]),m=n.Editor.end(N,p[1]),y=n.Point.isBefore(v.anchor,g)?m:g;return void n.Transforms.select(N,{anchor:y,focus:v.anchor})}if(d&&h&&n.Path.equals(d[1],h[1])){if(e.shiftKey&&N.selection){var b=N.selection.anchor,w=n.Point.isBefore(b,c)?u:c;return void n.Transforms.select(N,{anchor:b,focus:w})}var E=n.Editor.range(N,c);n.Transforms.select(N,E)}}}),[N,R.onClick,f,le]),onCompositionEnd:t.useCallback((function(e){if(f)Oi(e,R.onCompositionEnd);else if(!ki(e)&&Sn.hasSelectableTarget(N,e.target)){var t;Promise.resolve().then((function(){A(!1),lt.set(N,!1)})),null===(t=ie.current)||void 0===t||t.handleCompositionEnd(e);var r=Y.current;if(Y.current=!1,Oi(e,R.onCompositionEnd)||_e)return void X.clear();if(r&&!e.data&&(X.restore(),n.Editor.deleteFragment(N)),!Ie&&!qe&&!Be&&!Ke&&!Ve&&e.data){var o=ft.get(N);ft.delete(N),void 0!==o&&(ht.set(N,N.marks),N.marks=o),X.restore(),Wo(N,e.data),n.Editor.insertText(N,e.data);var i=ht.get(N);ht.delete(N),void 0!==i&&(N.marks=i)}X.clear()}}),[f,R.onCompositionEnd,N,X]),onCompositionUpdate:t.useCallback((function(e){f?Oi(e,R.onCompositionUpdate):!Sn.hasSelectableTarget(N,e.target)||Oi(e,R.onCompositionUpdate)||ki(e)||Sn.isComposing(N)||(A(!0),lt.set(N,!0))}),[f,R.onCompositionUpdate,N]),onCompositionStart:t.useCallback((function(e){if(f)Oi(e,R.onCompositionStart);else if(!ki(e)&&Sn.hasSelectableTarget(N,e.target)){var t;if(null===(t=ie.current)||void 0===t||t.handleCompositionStart(e),Oi(e,R.onCompositionStart)||_e)return;X.clear(),A(!0),le();var r=N.selection;if(r&&n.Range.isExpanded(r))return Fe&&!qe?(X.observe(),void(Y.current=!0)):void n.Editor.deleteFragment(N)}}),[f,R.onCompositionStart,N,X,le]),onCopy:t.useCallback((function(e){!Sn.hasSelectableTarget(N,e.target)||Oi(e,R.onCopy)||ki(e)||(e.preventDefault(),Sn.setFragmentData(N,e.clipboardData,"copy"))}),[R.onCopy,N]),onCut:t.useCallback((function(e){if(f)Oi(e,R.onCut);else if(Sn.hasSelectableTarget(N,e.target)&&!Oi(e,R.onCut)&&!ki(e)){e.preventDefault(),bi(N),Sn.setFragmentData(N,e.clipboardData,"cut");var t=N.selection;if(t)if(n.Range.isExpanded(t))Ko(N,t);else{var r=n.Node.parent(N,t.anchor.path);n.Editor.isVoid(N,r)&&n.Transforms.delete(N)}}}),[f,N,R.onCut]),onDragOver:t.useCallback((function(e){if(f)Oi(e,R.onDragOver);else if(Sn.hasTarget(N,e.target)&&!Oi(e,R.onDragOver)){var t=Sn.toSlateNode(N,e.target);n.Node.isElement(t)&&n.Editor.isVoid(N,t)&&e.preventDefault()}}),[f,R.onDragOver,N]),onDragStart:t.useCallback((function(e){if(f)Oi(e,R.onDragStart);else if(Sn.hasTarget(N,e.target)&&!Oi(e,R.onDragStart)){var t=Sn.toSlateNode(N,e.target),r=Sn.findPath(N,t);if(n.Node.isElement(t)&&n.Editor.isVoid(N,t)||n.Editor.void(N,{at:r,voids:!0})){var o=n.Editor.range(N,r);n.Transforms.select(N,o)}bi(N),oe.isDraggingInternally=!0,Sn.setFragmentData(N,e.dataTransfer,"drag")}}),[f,N,R.onDragStart,oe]),onDrop:t.useCallback((function(e){if(f)Oi(e,R.onDrop);else if(Sn.hasTarget(N,e.target)&&!Oi(e,R.onDrop)){e.preventDefault();var t=N.selection,r=Sn.findEventRange(N,e,{suppressThrow:!0}),o=e.dataTransfer;if(!r&&oe.isDraggingInternally)return;if(r){if(n.Transforms.select(N,r),oe.isDraggingInternally&&t){if(n.Range.includes(t,r.anchor))return;if(!n.Editor.void(N,{at:r,voids:!0})){var i=n.Editor.rangeRef(N,r);Ko(N,t);var a=i.unref();a&&n.Transforms.select(N,a)}}}else!N.selection&&N.children.length>0&&n.Transforms.select(N,n.Editor.end(N,[]));Sn.insertData(N,o),Sn.isFocused(N)||Sn.focus(N)}}),[f,N,R.onDrop,oe]),onDragEnd:t.useCallback((function(e){f?Oi(e,R.onDragEnd):oe.isDraggingInternally&&R.onDragEnd&&Sn.hasTarget(N,e.target)&&R.onDragEnd(e)}),[f,oe,R,N]),onFocus:t.useCallback((function(e){if(f)Oi(e,R.onFocus);else if(!oe.isUpdatingSelection&&Sn.hasEditableTarget(N,e.target)&&!Oi(e,R.onFocus)){var t=Sn.toDOMNode(N,N),n=Sn.findDocumentOrShadowRoot(N);if(oe.latestElement=n.activeElement,Fe&&e.target!==t)return void t.focus();if(st.set(N,!0),oe.isTabbing&&e.target===t){var r=Te(n);r&&N.selection&&(oe.pendingSelection=null,yi(N,r,oe)),oe.isTabbing=!1}}}),[f,oe,N,R.onFocus]),onKeyDown:t.useCallback((function(e){if(f)Oi(e,R.onKeyDown);else if(Sn.hasEditableTarget(N,e.target)){var t;null===(t=ie.current)||void 0===t||t.handleKeyDown(e);var r=e.nativeEvent;if(Sn.isComposing(N)&&(!1===r.isComposing||gi(N,r))&&(lt.set(N,!1),A(!1)),Oi(e,R.onKeyDown)||Sn.isComposing(N))return;W.current=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"].includes(r.key);var o=N.selection,i=N.children[null!==o?o.focus.path[0]:0],a="rtl"===E(n.Node.string(i));if(ln.isRedo(r)){e.preventDefault();var s=N;return void("function"==typeof s.redo&&s.redo())}if(ln.isUndo(r)){e.preventDefault();var l=N;return void("function"==typeof l.undo&&l.undo())}if((We||Ie)&&"ArrowUp"===r.key&&!r.altKey&&!r.ctrlKey&&!r.metaKey&&o&&(r.shiftKey||n.Range.isCollapsed(o))){var c=function(e,t){var r=n.Editor.above(e,{at:t,match:function(t){return n.Node.isElement(t)&&n.Editor.isBlock(e,t)}});if(!r)return null;var o=n.Editor.start(e,r[1]),i=n.Editor.before(e,o);if(!i||!n.Editor.leaf(e,i)[0].text.endsWith("\n"))return null;if(n.Point.equals(t,o))return i;var a=Io(e,t),s=Io(e,o);return null===a||null===s||Math.abs(a-s)>2?null:i}(N,o.focus);if(c)return e.preventDefault(),void n.Transforms.select(N,r.shiftKey?{anchor:o.anchor,focus:c}:c)}if(ln.isMoveLineBackward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line",reverse:!0});if(ln.isMoveLineForward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line"});if(ln.isExtendLineBackward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line",edge:"focus",reverse:!0});if(ln.isExtendLineForward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line",edge:"focus"});if(ln.isMoveBackward(r))return e.preventDefault(),void(o&&n.Range.isCollapsed(o)?n.Transforms.move(N,{reverse:!a,unit:Lo(N,o.focus,!a)}):n.Transforms.collapse(N,{edge:a?"end":"start"}));if(ln.isMoveForward(r))return e.preventDefault(),void(o&&n.Range.isCollapsed(o)?n.Transforms.move(N,{reverse:a,unit:Lo(N,o.focus,a)}):n.Transforms.collapse(N,{edge:a?"start":"end"}));var u=ln.isMoveWordBackward(r);if(u||ln.isMoveWordForward(r)){e.preventDefault();var d=Sn.findDocumentOrShadowRoot(N),h=Te(d);if(null!=h&&h.modify){h.modify("move",u?"left":"right","word");var p=Sn.toSlateRange(N,h,{exactMatch:!1,suppressThrow:!0});if(p)return void n.Transforms.select(N,p)}return o&&n.Range.isExpanded(o)&&n.Transforms.collapse(N,{edge:"focus"}),void n.Transforms.move(N,{unit:"word",reverse:u?!a:a})}if($e){if((We||Ie)&&o&&(ln.isDeleteBackward(r)||ln.isDeleteForward(r))&&n.Range.isCollapsed(o)){var v=n.Node.parent(N,o.anchor.path);if(n.Node.isElement(v)&&n.Editor.isVoid(N,v)&&(n.Editor.isInline(N,v)||n.Editor.isBlock(N,v)))return e.preventDefault(),void(ln.isDeleteForward(r)?n.Editor.deleteForward(N,{unit:"block"}):n.Editor.deleteBackward(N,{unit:"block"}))}if(Ie&&o&&n.Range.isCollapsed(o)){if(ln.isDeleteBackward(r)&&n.Editor.isStart(N,o.anchor,[]))return e.preventDefault(),void n.Editor.deleteBackward(N);if(ln.isDeleteForward(r)&&n.Editor.isEnd(N,o.anchor,[]))return e.preventDefault(),void n.Editor.deleteForward(N)}}else{if(ln.isBold(r)||ln.isItalic(r)||ln.isTransposeCharacter(r))return void e.preventDefault();if(ln.isSoftBreak(r))return e.preventDefault(),void n.Editor.insertSoftBreak(N);if(ln.isSplitBlock(r))return e.preventDefault(),void n.Editor.insertBreak(N);if(ln.isDeleteBackward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"backward"}):n.Editor.deleteBackward(N));if(ln.isDeleteForward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"forward"}):n.Editor.deleteForward(N));if(ln.isDeleteLineBackward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"backward"}):n.Editor.deleteBackward(N,{unit:"line"}));if(ln.isDeleteLineForward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"forward"}):n.Editor.deleteForward(N,{unit:"line"}));if(ln.isDeleteWordBackward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"backward"}):n.Editor.deleteBackward(N,{unit:"word"}));if(ln.isDeleteWordForward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"forward"}):n.Editor.deleteForward(N,{unit:"word"}))}}}),[f,N,R.onKeyDown]),onPaste:t.useCallback((function(e){f?Oi(e,R.onPaste):Sn.hasEditableTarget(N,e.target)&&!Oi(e,R.onPaste)&&(!$e||(e=>e.clipboardData&&""!==e.clipboardData.getData("text/plain")&&1===e.clipboardData.types.length)(e.nativeEvent)||Ie)&&(e.preventDefault(),Sn.insertData(N,e.clipboardData))}),[f,N,R.onPaste])}),t.createElement(pi,{decorations:fe,node:N,renderElement:p,renderChunk:v,renderPlaceholder:b,renderLeaf:g,renderText:m}))))))})),gi=function(e,t){var r=e.selection;return!!r&&n.Range.isCollapsed(r)&&(ln.isDeleteBackward(t)||ln.isDeleteForward(t))&&!!n.Editor.void(e,{at:r})},mi=function(e){var t;return we(e)&&e.nodeType===e.TEXT_NODE&&!(null===(t=e.parentElement)||void 0===t||!t.closest("[data-slate-string], [data-slate-zero-width]"))},yi=function(e,t,r){if(e.selection){var o=Sn.resolveDOMRange(e,e.selection);if(o){var i=n.Range.isBackward(e.selection);r.isUpdatingSelection=!0,t.setBaseAndExtent(i?o.endContainer:o.startContainer,i?o.endOffset:o.startOffset,i?o.startContainer:o.endContainer,i?o.startOffset:o.endOffset),setTimeout((function(){r.isUpdatingSelection=!1}))}}},bi=function(e){var t=e.selection;if(t&&n.Range.isExpanded(t)){var r=function(e,t){return Vo(e,t)?t:n.Editor.unhangRange(e,t)}(e,t);n.Range.equals(r,t)||n.Transforms.select(e,r)}},wi=function(e){var n=e.attributes,r=e.children;return t.createElement("span",fi({},n),r,_e&&t.createElement("br",null))},Ei=function(){return[]},xi=function(e,t){var r,o=e.selection,i=!!o&&n.Range.isBackward(o),a=o&&!i&&n.Range.isExpanded(o)?n.Editor.unhangRange(e,o):o,s=a&&o&&!n.Range.equals(a,o)&&null!==(r=Sn.resolveDOMRange(e,a))&&void 0!==r?r:t.cloneRange();if(s.collapse(i),s.getBoundingClientRect){var l=s.startContainer.parentElement,c=s.getBoundingClientRect();if(0===c.width&&0===c.height&&0===c.x&&0===c.y){var u=l.getBoundingClientRect();if(u.width>0||u.height>0)return}l.getBoundingClientRect=s.getBoundingClientRect.bind(s),le(l,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}),delete l.getBoundingClientRect}},Oi=function(e,t){if(!t)return!1;var n=t(e);return null!=n?n:e.isDefaultPrevented()||e.isPropagationStopped()},ki=function(e){return we(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)},Ci=function(e,t){if(!t)return!1;var n=t(e);return null!=n?n:e.defaultPrevented},Si=function(e,t){var n=e;"historyUndo"!==t.inputType||"function"!=typeof n.undo?"historyRedo"!==t.inputType||"function"!=typeof n.redo||n.redo():n.undo()},Ti=t.createContext(!1),Pi=parseInt(t.version.split(".")[0],10),Di=["editor","children","onChange","onSelectionChange","onValueChange","initialValue","value"],Ri=function(e,t){return!e&&!t||!(!e||!t)&&n.Range.equals(e,t)},Ni=new Set(["insert_node","move_node","remove_node","set_node"]);e.DefaultElement=ao,e.DefaultLeaf=_r,e.DefaultPlaceholder=wi,e.DefaultText=Yr,e.Editable=vi,e.NODE_TO_INDEX=Je,e.NODE_TO_PARENT=Ze,e.ReactEditor=Sn,e.Slate=function(e){var r=e.editor,o=e.children,i=e.onChange,a=e.onSelectionChange,s=e.onValueChange,c=e.initialValue,u=e.value,d=l(e,Di),f=t.useRef(null),h=t.useRef(void 0),p=t.useRef(void 0),v=t.useRef(void 0);if(void 0!==u&&void 0!==c)throw new Error("[Slate] value and initialValue cannot be used together.");if(void 0!==u&&!n.Node.isNodeList(u))throw new Error("[Slate] value is invalid! Expected a list of elements but got: ".concat(n.Scrubber.stringify(u)));if(f.current!==r){var g;if(!n.Editor.isEditor(r))throw new Error("[Slate] editor is invalid! You passed: ".concat(n.Scrubber.stringify(r)));if(void 0===c&&void 0===u&&0===r.children.length)throw new Error("[Slate] editor.children is empty and no initialValue was provided. If this is intentional, pass initialValue={[]} to the Slate component.");var m=null!==(g=null!=c?c:u)&&void 0!==g?g:r.children;if(!n.Node.isNodeList(m))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(n.Scrubber.stringify(m)));var y=void 0===c&&void 0===u?m:m.map(Ht),b=y.every((function(e,t){return e===m[t]}))?m:y;r.children=b.length>0?b:[{children:[{text:""}]}],Object.assign(r,d),f.current=r,h.current=void 0,p.current=u}var E=function(){var e=t.useRef(new Set),n=t.useRef(new Set),r=t.useCallback((function(){e.current.forEach((function(e){return e()}))}),[]),o=t.useCallback((function(){n.current.forEach((function(e){return e()})),n.current.clear()}),[]),i=t.useCallback((function(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).deferred,o=void 0!==r&&r?function(){return n.current.add(t)}:t;return e.current.add(o),function(){e.current.delete(o)}}),[]);return{selectorContext:t.useMemo((function(){return{addEventListener:i,flushDeferred:o}}),[i,o]),onChange:r}}(),x=E.selectorContext,O=E.onChange,k=t.useCallback((function(){var e=r.operations.some((function(e){return"set_selection"!==e.type})),t=e&&r.children===v.current;v.current=void 0,e&&!t&&(h.current=r.children),i&&i(r.children),a&&r.operations.find((function(e){return"set_selection"===e.type}))&&a(r.selection),s&&e&&!t&&s(r.children),O()}),[r,O,i,a,s]),C=void 0!==u,S=t.useCallback((function(){var e=function(){return k()};return ut.set(r,e),function(){ut.get(r)===e&&ut.delete(r)}}),[r,k]);t.useEffect((function(){if(!C)return S()}),[C,S]),Nn((function(){if(C)return S()}),[C,S]),Nn((function(){var e,t=function(){var o;if(void 0!==u)if(u!==h.current){if(u!==p.current)if(Sn.isComposing(r)||ii.get(r)||vt.get(r)||null!==(o=pt.get(r))&&void 0!==o&&o.length)e=window.requestAnimationFrame(t);else{var i=r.children;p.current=u,n.Transforms.setChildren(r,u),i!==r.children&&(v.current=r.children,O())}}else p.current=u};return t(),function(){void 0!==e&&window.cancelAnimationFrame(e)}}),[r,u,O]);var T=t.useState(Sn.isFocused(r)),P=w(T,2),D=P[0],R=P[1];return t.useEffect((function(){R(Sn.isFocused(r))}),[r]),Nn((function(){var e=function(){return R(Sn.isFocused(r))};return Pi>=17?(document.addEventListener("focusin",e),document.addEventListener("focusout",e),function(){document.removeEventListener("focusin",e),document.removeEventListener("focusout",e)}):(document.addEventListener("focus",e,!0),document.addEventListener("blur",e,!0),function(){document.removeEventListener("focus",e,!0),document.removeEventListener("blur",e,!0)})}),[r]),t.createElement(Ro.Provider,{value:x},t.createElement(ce.Provider,{value:r},t.createElement(Ti.Provider,{value:D},o)))},e.defaultScrollSelectionIntoView=xi,e.useComposing=function(){return t.useContext(ai)},e.useEditor=function(){var e=t.useContext(ce);if(!e)throw new Error("The `useEditor` hook must be used inside the <Slate> component's context.");return e},e.useElement=function(){var e=t.useContext(ko);if(!e)throw new Error("The `useElement` hook must be used inside `renderElement`.");return e},e.useElementIf=Co,e.useFocused=function(){return t.useContext(Ti)},e.useReadOnly=Do,e.useSelected=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.suppressThrow,o=void 0!==r&&r,i=Co();if(!i)return!1;var a=t.useCallback((function(e){if(!e.selection)return!1;try{var t=Sn.findPath(e,i),r=n.Editor.range(e,t);return!!n.Range.intersection(r,e.selection)}catch(e){if(o)return!1;throw e}}),[i,o]);return Mo(a,void 0,{deferred:!0})},e.useSlate=jo,e.useSlateSelection=function(){return Mo((function(e){return e.selection}),Ri)},e.useSlateSelector=Mo,e.useSlateStatic=ue,e.useSlateWithV=function(){var e=jo(),n=t.useMemo((function(){return function(e){var t=Bo.get(e);if(t)return t;t={current:0},Bo.set(e,t);var n=e.onChange;return e.onChange=function(e){t.current++,n(e)},t}(e)}),[e]);return{editor:e,v:n.current}},e.withReact=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x-slate-fragment",r=e,o=r=Zt(r,t),i=o.onChange,a=o.apply,s=o.insertText;return r.getChunkSize=function(){return null},_e&&(r.insertText=function(e,t){return gt.delete(r),s(e,t)}),r.onChange=function(e){(Pi<18?Cn.unstable_batchedUpdates:function(e){return e()})((function(){i(e)}))},r.apply=function(e){var t;_e&&Ni.has(e.type)&&(null===(t=Dn.get(r))||void 0===t||t());if("move_node"===e.type){var o=n.Node.parent(r,e.path);if(!!r.getChunkSize(o)){var i=n.Node.get(r,e.path),s=yo(r,o),l=Sn.findKey(r,i);s.movedNodeKeys.add(l)}}a(e)},r}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("slate")):"function"==typeof define&&define.amd?define(["exports","react","slate"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SlateReact={},e.React,e.Slate)}(this,(function(e,t,n){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}var a=i((function(e){e.exports=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n},e.exports.__esModule=!0,e.exports.default=e.exports}));o(a);var s=i((function(e){e.exports=function(e,t){if(null==e)return{};var n,r,o=a(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports})),l=o(s),c=i((function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));o(c);var u=i((function(e){var t=c.default;e.exports=function(e,n){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,n||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));o(u);var d=i((function(e){var t=c.default;e.exports=function(e){var n=u(e,"string");return"symbol"==t(n)?n:n+""},e.exports.__esModule=!0,e.exports.default=e.exports}));o(d);var f=i((function(e){e.exports=function(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports})),h=o(f),p=i((function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}));o(p);var v=i((function(e){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,o=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports}));o(v);var g=i((function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}));o(g);var m=i((function(e){e.exports=function(e,t){if(e){if("string"==typeof e)return g(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}));o(m);var y=i((function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}));o(y);var b=i((function(e){e.exports=function(e,t){return p(e)||v(e,t)||m(e,t)||y()},e.exports.__esModule=!0,e.exports.default=e.exports})),w=o(b),E=function(e){if(e=String(e||""),k.test(e))return"rtl";if(C.test(e))return"ltr";return"neutral"},x="֑-߿יִ-﷽ﹰ-ﻼ",O="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",k=new RegExp("^[^"+O+"]*["+x+"]"),C=new RegExp("^[^"+x+"]*["+O+"]");var S=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},T="object"==typeof r&&r&&r.Object===Object&&r,P="object"==typeof self&&self&&self.Object===Object&&self,D=T||P||Function("return this")(),R=function(){return D.Date.now()},N=/\s/;var M=function(e){for(var t=e.length;t--&&N.test(e.charAt(t)););return t},j=/^\s+/;var B=function(e){return e?e.slice(0,M(e)+1).replace(j,""):e},A=D.Symbol,_=Object.prototype,F=_.hasOwnProperty,I=_.toString,L=A?A.toStringTag:void 0;var W=function(e){var t=F.call(e,L),n=e[L];try{e[L]=void 0;var r=!0}catch(e){}var o=I.call(e);return r&&(t?e[L]=n:delete e[L]),o},z=Object.prototype.toString;var U=function(e){return z.call(e)},q=A?A.toStringTag:void 0;var V=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":q&&q in Object(e)?W(e):U(e)};var K=function(e){return null!=e&&"object"==typeof e};var H=function(e){return"symbol"==typeof e||K(e)&&"[object Symbol]"==V(e)},$=/^[-+]0x[0-9a-f]+$/i,X=/^0b[01]+$/i,G=/^0o[0-7]+$/i,Y=parseInt;var J=function(e){if("number"==typeof e)return e;if(H(e))return NaN;if(S(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=S(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=B(e);var n=X.test(e);return n||G.test(e)?Y(e.slice(2),n?2:8):$.test(e)?NaN:+e},Z=Math.max,Q=Math.min;var ee=function(e,t,n){var r,o,i,a,s,l,c=0,u=!1,d=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=r,i=o;return r=o=void 0,c=t,a=e.apply(i,n)}function p(e){return c=e,s=setTimeout(g,t),u?h(e):a}function v(e){var n=e-l;return void 0===l||n>=t||n<0||d&&e-c>=i}function g(){var e=R();if(v(e))return m(e);s=setTimeout(g,function(e){var n=t-(e-l);return d?Q(n,i-(e-c)):n}(e))}function m(e){return s=void 0,f&&r?h(e):(r=o=void 0,a)}function y(){var e=R(),n=v(e);if(r=arguments,o=this,l=e,n){if(void 0===s)return p(l);if(d)return clearTimeout(s),s=setTimeout(g,t),h(l)}return void 0===s&&(s=setTimeout(g,t)),a}return t=J(t)||0,S(n)&&(u=!!n.leading,i=(d="maxWait"in n)?Z(J(n.maxWait)||0,t):i,f="trailing"in n?!!n.trailing:f),y.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=o=s=void 0},y.flush=function(){return void 0===s?a:m(R())},y};var te=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return S(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),ee(e,t,{leading:r,maxWait:t,trailing:o})};const ne=e=>"object"==typeof e&&null!=e&&1===e.nodeType,re=(e,t)=>(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e,oe=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return re(n.overflowY,t)||re(n.overflowX,t)||(e=>{const t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},ie=(e,t,n,r,o,i,a,s)=>i<e&&a>t||i>e&&a<t?0:i<=e&&s<=n||a>=t&&s>=n?i-e-r:a>t&&s<n||i<e&&s>n?a-t+o:0,ae=e=>{const t=e.parentElement;return null==t?e.getRootNode().host||null:t},se=(e,t)=>{var n,r,o,i;if("undefined"==typeof document)return[];const{scrollMode:a,block:s,inline:l,boundary:c,skipOverflowHiddenElements:u}=t,d="function"==typeof c?c:e=>e!==c;if(!ne(e))throw new TypeError("Invalid target");const f=document.scrollingElement||document.documentElement,h=[];let p=e;for(;ne(p)&&d(p);){if(p=ae(p),p===f){h.push(p);break}null!=p&&p===document.body&&oe(p)&&!oe(document.documentElement)||null!=p&&oe(p,u)&&h.push(p)}const v=null!=(r=null==(n=window.visualViewport)?void 0:n.width)?r:innerWidth,g=null!=(i=null==(o=window.visualViewport)?void 0:o.height)?i:innerHeight,{scrollX:m,scrollY:y}=window,{height:b,width:w,top:E,right:x,bottom:O,left:k}=e.getBoundingClientRect(),{top:C,right:S,bottom:T,left:P}=(e=>{const t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);let D="start"===s||"nearest"===s?E-C:"end"===s?O+T:E+b/2-C+T,R="center"===l?k+w/2-P+S:"end"===l?x+S:k-P;const N=[];for(let e=0;e<h.length;e++){const t=h[e],{height:n,width:r,top:o,right:i,bottom:c,left:u}=t.getBoundingClientRect();if("if-needed"===a&&E>=0&&k>=0&&O<=g&&x<=v&&E>=o&&O<=c&&k>=u&&x<=i)return N;const d=getComputedStyle(t),p=parseInt(d.borderLeftWidth,10),C=parseInt(d.borderTopWidth,10),S=parseInt(d.borderRightWidth,10),T=parseInt(d.borderBottomWidth,10);let P=0,M=0;const j="offsetWidth"in t?t.offsetWidth-t.clientWidth-p-S:0,B="offsetHeight"in t?t.offsetHeight-t.clientHeight-C-T:0,A="offsetWidth"in t?0===t.offsetWidth?0:r/t.offsetWidth:0,_="offsetHeight"in t?0===t.offsetHeight?0:n/t.offsetHeight:0;if(f===t)P="start"===s?D:"end"===s?D-g:"nearest"===s?ie(y,y+g,g,C,T,y+D,y+D+b,b):D-g/2,M="start"===l?R:"center"===l?R-v/2:"end"===l?R-v:ie(m,m+v,v,p,S,m+R,m+R+w,w),P=Math.max(0,P+y),M=Math.max(0,M+m);else{P="start"===s?D-o-C:"end"===s?D-c+T+B:"nearest"===s?ie(o,c,n,C,T+B,D,D+b,b):D-(o+n/2)+B/2,M="start"===l?R-u-p:"center"===l?R-(u+r/2)+j/2:"end"===l?R-i+S+j:ie(u,i,r,p,S+j,R,R+w,w);const{scrollLeft:e,scrollTop:a}=t;P=0===_?0:Math.max(0,Math.min(a+P/_,t.scrollHeight-n/_+B)),M=0===A?0:Math.max(0,Math.min(e+M/A,t.scrollWidth-r/A+j)),D+=a-P,R+=e-M}N.push({el:t,top:P,left:M})}return N};function le(e,t){if(!e.isConnected||!(e=>{let t=e;for(;t&&t.parentNode;){if(t.parentNode===document)return!0;t=t.parentNode instanceof ShadowRoot?t.parentNode.host:t.parentNode}return!1})(e))return;const n=(e=>{const t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);if((e=>"object"==typeof e&&"function"==typeof e.behavior)(t))return t.behavior(se(e,t));const r="boolean"==typeof t||null==t?void 0:t.behavior;for(const{el:o,top:i,left:a}of se(e,(e=>!1===e?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&0!==Object.keys(e).length)(e)?e:{block:"start",inline:"nearest"})(t))){const e=i-n.top+n.bottom,t=a-n.left+n.right;o.scroll({top:e,left:t,behavior:r})}}var ce=t.createContext(null),ue=function(){var e=t.useContext(ce);if(!e)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return e},de=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});for(var n="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),r={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},o={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:n?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},i={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},a=1;a<20;a++)i["f"+a]=111+a;function s(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map((function(e){return l(e,t)})),o=function(e){return r.some((function(t){return c(t,e)}))};return null==n?o:o(n)}function l(e,t){var n=t&&t.byKey,a={},s=(e=e.replace("++","+add")).split("+"),l=s.length;for(var c in r)a[r[c]]=!1;var f=!0,h=!1,p=void 0;try{for(var v,g=s[Symbol.iterator]();!(f=(v=g.next()).done);f=!0){var m=v.value,y=m.endsWith("?")&&m.length>1;y&&(m=m.slice(0,-1));var b=d(m),w=r[b];if(m.length>1&&!w&&!o[m]&&!i[b])throw new TypeError('Unknown modifier: "'+m+'"');1!==l&&w||(n?a.key=b:a.which=u(m)),w&&(a[w]=!y||null)}}catch(e){h=!0,p=e}finally{try{!f&&g.return&&g.return()}finally{if(h)throw p}}return a}function c(e,t){for(var n in e){var r=e[n],o=void 0;if(null!=r&&((null!=(o="key"===n&&null!=t.key?t.key.toLowerCase():"which"===n?91===r&&93===t.which?91:t.which:t[n])||!1!==r)&&o!==r))return!1}return!0}function u(e){return e=d(e),i[e]||e.toUpperCase().charCodeAt(0)}function d(e){return e=e.toLowerCase(),e=o[e]||e}t.default=s,t.isHotkey=s,t.isCodeHotkey=function(e,t){return s(e,t)},t.isKeyHotkey=function(e,t){return s(e,{byKey:!0},t)},t.parseHotkey=l,t.compareHotkey=c,t.toKeyCode=u,t.toKeyName=d}));o(de);var fe=de.isHotkey;function he(e){return he="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},he(e)}function pe(e){var t=function(e,t){if("object"!=he(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=he(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==he(t)?t:t+""}function ve(e,t,n){return(t=pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}de.isCodeHotkey,de.isKeyHotkey,de.parseHotkey,de.compareHotkey,de.toKeyCode,de.toKeyName;var ge=globalThis.Node,me=globalThis.Text;const ye=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,be=e=>we(e)&&1===e.nodeType,we=e=>{const t=ye(e);return!!t&&e instanceof t.Node},Ee=e=>{const t=e&&e.anchorNode&&ye(e.anchorNode);return!!t&&e instanceof t.Selection},xe=e=>we(e)&&3===e.nodeType,Oe=(e,t,n)=>{if("number"!=typeof t)throw new Error("Expected index to be a number");const{childNodes:r}=e;let o=r[t],i=t,a=!1,s=!1;for(;(we(l=o)&&8===l.nodeType||be(o)&&0===o.childNodes.length||be(o)&&"false"===o.getAttribute("contenteditable"))&&(!a||!s);)i>=r.length?(a=!0,i=t-1,n="backward"):i<0?(s=!0,i=t+1,n="forward"):(o=r[i],t=i,i+="forward"===n?1:-1);var l;return[o,t]},ke=(e,t,n)=>{const[r]=Oe(e,t,n);return r},Ce=e=>{let t="";if(xe(e)&&e.nodeValue)return e.nodeValue;if(be(e)){var n;if(e.hasAttribute("data-slate-spacer"))return t;if("BR"===e.tagName&&"n"===(null===(n=e.parentElement)||void 0===n?void 0:n.getAttribute("data-slate-zero-width")))return t;for(const n of Array.from(e.childNodes))t+=Ce(n);const r=getComputedStyle(e).getPropertyValue("display"),o="block"===r||"list"===r,i=!!e.closest('[data-slate-inline="true"]');("BR"===e.tagName||o&&!i)&&(t+="\n")}return t},Se=/<[^>]*\sdata-slate-fragment="([^"]+)"/m,Te=e=>null!=e.getSelection?e.getSelection():document.getSelection(),Pe=(e,t,n)=>{const{target:r}=t;if(be(r)&&r.matches('[contentEditable="false"]'))return!1;const{document:o}=xt.getWindow(e);if(Ne(o,r))return xt.hasDOMNode(e,r,{editable:!0});const i=n.find((({addedNodes:e,removedNodes:t})=>{for(const t of e)if(t===r||Ne(t,r))return!0;for(const e of t)if(e===r||Ne(e,r))return!0}));return!(!i||i===t)&&Pe(e,i,n)},De=(e,t)=>Boolean(e.compareDocumentPosition(t)&ge.DOCUMENT_POSITION_PRECEDING),Re=(e,t)=>{if(!e)return null;let n=e;for(;n;){if(n.matches&&n.matches(t))return n;if(n.parentElement)n=n.parentElement;else{if(!n.parentNode||!("host"in n.parentNode))return null;n=n.parentNode.host}}return null},Ne=(e,t)=>{if(!e||!t)return!1;if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;if(!n.parentNode)return!1;n="host"in n.parentNode?n.parentNode.host:n.parentNode}return!1};var Me,je;const Be="undefined"!=typeof navigator&&"undefined"!=typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ae="undefined"!=typeof navigator&&/Mac OS X/.test(navigator.userAgent),_e="undefined"!=typeof navigator&&/Android/.test(navigator.userAgent),Fe="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Ie="undefined"!=typeof navigator&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),Le="undefined"!=typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),We="undefined"!=typeof navigator&&/Chrome/i.test(navigator.userAgent),ze="undefined"!=typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),Ue=_e&&"undefined"!=typeof navigator&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),qe="undefined"!=typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),Ve="undefined"!=typeof navigator&&/.*UCBrowser/.test(navigator.userAgent),Ke="undefined"!=typeof navigator&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent)&&(!We||ze),He=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement);"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&null!==(Me=navigator.userAgent.match(/Version\/(\d+)/))&&void 0!==Me&&Me[1]&&parseInt(null===(je=navigator.userAgent.match(/Version\/(\d+)/))||void 0===je?void 0:je[1],10);const $e=!ze&&!Ue&&!Le&&"undefined"!=typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges;let Xe=0;class Ge{constructor(){ve(this,"id",void 0),this.id=""+Xe++}}const Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakMap,rt=new WeakMap,ot=new WeakMap,it=new WeakMap,at=new WeakMap,st=new WeakMap,lt=new WeakMap,ct=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,ht=new WeakMap,pt=new WeakMap,vt=new WeakMap,gt=new WeakMap,mt=new WeakMap,yt=Symbol("placeholder"),bt=Symbol("mark-placeholder");function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const xt={androidPendingDiffs:e=>pt.get(e),androidScheduleFlush:e=>{var t;null===(t=dt.get(e))||void 0===t||t()},blur:e=>{const t=xt.toDOMNode(e,e),n=xt.findDocumentOrShadowRoot(e);st.set(e,!1),n.activeElement===t&&t.blur()},deselect:e=>{const{selection:t}=e,r=xt.findDocumentOrShadowRoot(e),o=Te(r);o&&o.rangeCount>0&&o.removeAllRanges(),t&&n.Transforms.deselect(e)},findDocumentOrShadowRoot:e=>{const t=xt.toDOMNode(e,e),n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},findEventRange:(e,t,r={})=>{const{suppressThrow:o=!1}=r;"nativeEvent"in t&&(t=t.nativeEvent);const{clientX:i,clientY:a,target:s}=t;if(null==i||null==a){if(o)return null;throw new Error(`Cannot resolve a Slate range from a DOM event: ${t}`)}let l,c,u;try{l=xt.toSlateNode(e,t.target)}catch(e){if(o)return null;throw e}try{c=xt.findPath(e,l)}catch(e){if(o)return null;throw e}if(n.Node.isElement(l)&&n.Editor.isVoid(e,l)){const t=s.getBoundingClientRect(),r=e.isInline(l)?i-t.left<t.left+t.width-i:a-t.top<t.top+t.height-a,o=n.Editor.point(e,c,{edge:r?"start":"end"}),u=r?n.Editor.before(e,o):n.Editor.after(e,o);if(u){return n.Editor.range(e,u)}}const{document:d}=xt.getWindow(e),f=xt.findDocumentOrShadowRoot(e),h=f===d?null:f,p=e=>{if(!e)return null;const t=d.createRange();return t.setStart(e.offsetNode,e.offset),t.setEnd(e.offsetNode,e.offset),t};if(u=h&&d.caretPositionFromPoint?p(d.caretPositionFromPoint(i,a,{shadowRoots:[h]})):d.caretRangeFromPoint?d.caretRangeFromPoint(i,a):p(d.caretPositionFromPoint(i,a)),!u){if(o)return null;throw new Error(`Cannot resolve a Slate range from a DOM event: ${t}`)}return xt.toSlateRange(e,u,{exactMatch:!1,suppressThrow:o})},findKey:(e,t)=>{let n=ot.get(t);return n||(n=new Ge,ot.set(t,n)),n},findPath:(e,t)=>{const r=[];let o=t;for(;;){const t=Ze.get(o);if(null==t){if(o===e)return r;break}const n=Je.get(o);if(null==n||t.children[n]!==o)break;r.unshift(n),o=t}const i=n.Node.findPath(e,t);if(i)return i;throw new Error(`Unable to find the path for Slate node: ${n.Scrubber.stringify(t)}`)},focus:(e,t={retries:5})=>{if(st.get(e))return;if(!xt.isMounted(e))return;if(t.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(e.operations.length>0)return void setTimeout((()=>{xt.focus(e,{retries:t.retries-1})}),10);const r=xt.toDOMNode(e,e),o=xt.findDocumentOrShadowRoot(e);if(o.activeElement!==r){const t=e.selection&&o instanceof Document?xt.toDOMRange(e,e.selection):null;if(e.selection||n.Transforms.select(e,n.Editor.start(e,[])),st.set(e,!0),r.focus({preventScroll:!0}),t){const e=Te(o);null==e||e.removeAllRanges(),null==e||e.addRange(t)}}},getWindow:e=>{const t=Qe.get(e);if(!t)throw new Error("Unable to find a host window element for this editor");return t},hasDOMNode:(e,t,n={})=>{const{editable:r=!1}=n;if(!xt.isMounted(e))return!1;const o=xt.toDOMNode(e,e);let i;try{i=be(t)?t:t.parentElement}catch(e){if(e instanceof Error&&!e.message.includes('Permission denied to access property "nodeType"'))throw e}if(!i||Re(i,"[data-slate-editor]")!==o)return!1;const a=Re(i,'[contenteditable="true" i], [contenteditable=""], [contenteditable="plaintext-only" i]'),s=a&&a!==o?Re(a,'[contenteditable="false" i]'):null;if(s&&s!==o&&Re(s,"[data-slate-editor]")===o){var l;const e=null!==(l=Re(i,'[data-slate-node="text"]'))&&void 0!==l?l:null==a?void 0:a.querySelector('[data-slate-node="text"]');if(!e||null==a||!a.contains(e)||Re(e,"[data-slate-editor]")!==o)return!1}return!(r&&!i.isContentEditable)||("boolean"==typeof i.isContentEditable&&Re(i,'[contenteditable="false"]')===o||!!i.getAttribute("data-slate-zero-width"))},hasEditableTarget:(e,t)=>we(t)&&xt.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>{if("function"==typeof e.hasRange)return e.hasRange(t);const{anchor:r,focus:o}=t;return n.Editor.hasPath(e,r.path)&&n.Editor.hasPath(e,o.path)},hasSelectableTarget:(e,t)=>xt.hasEditableTarget(e,t)||xt.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>we(t)&&xt.hasDOMNode(e,t),insertData:(e,t)=>{e.insertData(t)},insertFragmentData:(e,t)=>e.insertFragmentData(t),insertTextData:(e,t)=>e.insertTextData(t),isComposing:e=>!!lt.get(e),getWord:(e,t={})=>{var r,o;if("function"!=typeof n.Editor.word)throw new Error("DOMEditor.getWord needs slate 0.136.0 or later");const i=xt.isComposing(e)?kt(e):void 0,a=null!==(r=null==i?void 0:i.view)&&void 0!==r?r:e,s=n.Editor.word(a,Et(Et({},t),{},{at:null!==(o=t.at)&&void 0!==o?o:null==i?void 0:i.point}));return s&&{range:s,text:n.Editor.string(a,s)}},isFocused:e=>!!st.get(e),isMounted:e=>!!et.get(e),isReadOnly:e=>!!at.get(e),isTargetInsideNonReadonlyVoid:(e,t)=>{if(at.get(e))return!1;if(!xt.hasTarget(e,t))return!1;const r=xt.toSlateNode(e,t);return n.Node.isElement(r)&&n.Editor.isVoid(e,r)},setFragmentData:(e,t,n)=>e.setFragmentData(t,n),toDOMNode:(e,t)=>{const r=xt.resolveDOMNode(e,t);if(!r)throw new Error(`Cannot resolve a DOM node from Slate node: ${n.Scrubber.stringify(t)}`);return r},resolveDOMPoint:(e,t)=>{var r;if(!n.Node.has(e,t.path))return null;const o=null===(r=it.get(e))||void 0===r?void 0:r.get(xt.findKey(e,n.Node.get(e,t.path)));return o?Tt(e,o,t):null},resolveDOMRange:(e,t)=>{var r,o;const i=xt.resolveDOMPoint(e,t.anchor);if(!i)return null;const a=n.Range.isCollapsed(t)?i:xt.resolveDOMPoint(e,t.focus),s=null!==(r=Qe.get(e))&&void 0!==r?r:null===(o=i[0].ownerDocument)||void 0===o?void 0:o.defaultView;if(!a||!s)return null;try{return Pt(s,i,a,n.Range.isBackward(t))}catch(e){return null}},resolveEventRange:(e,t)=>xt.findEventRange(e,t,{suppressThrow:!0}),resolveDOMNode:(e,t)=>{var n,r;return null!==(n=t===e?et.get(e):null===(r=it.get(e))||void 0===r?void 0:r.get(xt.findKey(e,t)))&&void 0!==n?n:null},resolveSlateNode:(e,t)=>{var n;const r=Ct(t);return null!==(n=r&&nt.get(r))&&void 0!==n?n:null},resolveSlatePoint:(e,t,n={})=>{try{var r;return xt.toSlatePoint(e,t,{exactMatch:null!==(r=n.exactMatch)&&void 0!==r&&r,searchDirection:n.searchDirection,suppressThrow:!0})}catch(e){return null}},resolveSlateRange:(e,t,n={})=>{try{var r;return xt.toSlateRange(e,t,{exactMatch:null!==(r=n.exactMatch)&&void 0!==r&&r,suppressThrow:!0})}catch(e){return null}},toDOMPoint:(e,t)=>{const[r]=n.Editor.node(e,t.path),o=xt.toDOMNode(e,r),i=Tt(e,o,t);if(!i)throw new Error(St(t));return i},toDOMRange:(e,t)=>{const{anchor:r,focus:o}=t,i=xt.toDOMPoint(e,r),a=n.Range.isCollapsed(t)?i:xt.toDOMPoint(e,o);return Pt(xt.getWindow(e),i,a,n.Range.isBackward(t))},toSlateNode:(e,t)=>{const n=Ct(t),r=n?nt.get(n):null;if(!r)throw new Error(`Cannot resolve a Slate node from DOM node: ${n}`);return r},toSlatePoint:(e,t,r)=>{const{exactMatch:o,suppressThrow:i}=r,[a,s]=o?t:(e=>{let[t,n]=e;if(be(t)&&t.childNodes.length){let e=n===t.childNodes.length,r=e?n-1:n;for([t,r]=Oe(t,r,e?"backward":"forward"),e=r<n;be(t)&&t.childNodes.length;){const n=e?t.childNodes.length-1:0;t=ke(t,n,e?"backward":"forward")}n=e&&null!=t.textContent?t.textContent.length:0}return[t,n]})(t),l=a.parentNode;let c,u,d=r.searchDirection,f=null,h=0;if(l){var p,v;const t=xt.toDOMNode(e,e),n=l.closest('[data-slate-void="true"]'),r=n&&Ne(t,n)?n:null,i=l.closest('[contenteditable="false"]'),c=i&&Ne(t,i)?i:null;let u=l.closest("[data-slate-leaf]"),y=null;if(u){if(f=u.closest('[data-slate-node="text"]'),f){const t=xt.getWindow(e).document.createRange();t.setStart(f,0),t.setEnd(a,l.hasAttribute("data-slate-trailing")&&a===l.lastChild&&"\n"===a.textContent?0:s);const n=t.cloneContents();[...Array.prototype.slice.call(n.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(n.querySelectorAll("[contenteditable=false]"))].forEach((e=>{_e&&!o&&e.hasAttribute("data-slate-zero-width")&&e.textContent.length>0&&"\ufeff"!==e.textContext?e.textContent.startsWith("\ufeff")&&(e.textContent=e.textContent.slice(1)):e.parentNode.removeChild(e)})),h=n.textContent.length,y=f}}else if(r){const t=r.querySelectorAll("[data-slate-leaf]");for(let n=0;n<t.length;n++){const r=t[n];if(xt.hasDOMNode(e,r)){u=r;break}}u?(f=u.closest('[data-slate-node="text"]'),y=u,h=y.textContent.length,y.querySelectorAll("[data-slate-zero-width]").forEach((e=>{h-=e.textContent.length}))):h=1}else if(c){const e=e=>e?e.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],t=c.closest('[data-slate-node="element"]');if("backward"===d||!d){var g;u=null!==(g=[...e(null==t?void 0:t.previousElementSibling),...e(t)].findLast((e=>De(c,e))))&&void 0!==g?g:null,u&&(d="backward")}if("forward"===d||!d){var m;u=null!==(m=[...e(t),...e(null==t?void 0:t.nextElementSibling)].find((e=>{return t=e,Boolean(c.compareDocumentPosition(t)&ge.DOCUMENT_POSITION_FOLLOWING);var t})))&&void 0!==m?m:null,u&&(d="forward")}u&&(f=u.closest('[data-slate-node="text"]'),y=u,"forward"===d?h=0:(h=y.textContent.length,y.querySelectorAll("[data-slate-zero-width]").forEach((e=>{h-=e.textContent.length}))))}y&&h===y.textContent.length&&_e&&"z"===y.getAttribute("data-slate-zero-width")&&null!==(p=y.textContent)&&void 0!==p&&p.startsWith("\ufeff")&&(l.hasAttribute("data-slate-zero-width")||Fe&&null!==(v=y.textContent)&&void 0!==v&&v.endsWith("\n\n"))&&h--}if(_e&&l&&!f&&!o){const t=l.hasAttribute("data-slate-node")?l:l.closest("[data-slate-node]");if(t&&xt.hasDOMNode(e,t,{editable:!0})){const r=xt.toSlateNode(e,t);let o;try{o=xt.findPath(e,r)}catch(e){if(i)return null;throw e}let{path:a,offset:l}=n.Editor.start(e,o);return t.querySelector("[data-slate-leaf]")||(l=s),{path:a,offset:l}}}if(!f){if(i)return null;throw new Error(`Cannot resolve a Slate point from DOM point: ${t}`)}try{c=xt.toSlateNode(e,f)}catch(e){if(i)return null;throw e}try{u=xt.findPath(e,c)}catch(e){if(i)return null;throw e}return{path:u,offset:h}},toSlateRange:(e,t,r)=>{var o,i;const{exactMatch:a,suppressThrow:s}=r;let l,c,u,d,f;if(Ee(t)?t.anchorNode:t.startContainer)if(Ee(t)){if(Fe&&t.rangeCount>1){u=t.focusNode;const m=t.getRangeAt(0),y=t.getRangeAt(t.rangeCount-1);if(u instanceof HTMLTableRowElement&&m.startContainer instanceof HTMLTableRowElement&&y.startContainer instanceof HTMLTableRowElement){function b(e){return e.childElementCount>0?b(e.children[0]):e}const w=m.startContainer,E=y.startContainer,x=b(w.children[m.startOffset]),O=b(E.children[y.startOffset]);d=0,l=O.childNodes.length>0?O.childNodes[0]:O,u=x.childNodes.length>0?x.childNodes[0]:x,c=O instanceof HTMLElement?O.innerHTML.length:0}else m.startContainer===u?(l=y.endContainer,c=y.endOffset,d=m.startOffset):(l=m.startContainer,c=m.endOffset,d=y.startOffset)}else l=t.anchorNode,c=t.anchorOffset,u=t.focusNode,d=t.focusOffset;f=We&&(e=>{let t=e&&e.parentNode;for(;t;){if("[object ShadowRoot]"===t.toString())return!0;t=t.parentNode}return!1})(l)||Fe?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed}else l=t.startContainer,c=t.startOffset,u=t.endContainer,d=t.endOffset,f=t.collapsed;if(null==l||null==u||null==c||null==d)throw new Error(`Cannot resolve a Slate range from DOM range: ${t}`);!Fe||null!==(o=u.parentElement)&&void 0!==o&&o.hasAttribute("data-slate-trailing")||null===(i=u.textContent)||void 0===i||!i.endsWith("\n\n")||d!==u.textContent.length||d--;const h=xt.toSlatePoint(e,[l,c],{exactMatch:a,suppressThrow:s});if(!h)return null;const p=De(l,u)||l===u&&d<c,v=f?h:xt.toSlatePoint(e,[u,d],{exactMatch:a,suppressThrow:s,searchDirection:p?"forward":"backward"});if(!v)return null;let g={anchor:h,focus:v};return n.Range.isExpanded(g)&&n.Range.isForward(g)&&be(u)&&!u.closest('[data-slate-void="true"]')&&n.Editor.void(e,{at:g.focus,mode:"highest"})&&(g=n.Editor.unhangRange(e,g,{voids:!0})),g}},Ot=(e,t,n)=>e.map(((e,r)=>r!==t[0]?e:1===t.length?Et(Et({},e),{},{text:n}):Et(Et({},e),{},{children:Ot(e.children,t.slice(1),n)}))),kt=e=>{var t;const r=xt.getWindow(e).getSelection();if(null==r||!r.focusNode)return;const o=xt.toSlatePoint(e,[r.focusNode,r.focusOffset],{exactMatch:!1,suppressThrow:!0});if(!o)return;const i=(null!==(t=xt.toDOMNode(e,n.Node.get(e,o.path)).textContent)&&void 0!==t?t:"").replace(/\uFEFF/g,""),a=n.createEditor();return a.isInline=e.isInline,a.isVoid=e.isVoid,a.children=Ot(e.children,o.path,i),{view:a,point:o}},Ct=e=>{var t;const n=be(e)?e:e.parentElement;return null!=n&&n.hasAttribute("data-slate-node")?n:null!==(t=null==n?void 0:n.closest("[data-slate-node]"))&&void 0!==t?t:null},St=e=>`Cannot resolve a DOM point from Slate point: ${n.Scrubber.stringify(e)}`,Tt=(e,t,r)=>{let o=null;n.Editor.void(e,{at:r})&&(r={path:r.path,offset:0});const i=Array.from(t.querySelectorAll("[data-slate-string], [data-slate-zero-width]"));let a=0;for(let e=0;e<i.length;e++){const t=i[e],n=t.childNodes[0];if(null==n||null==n.textContent)continue;const{length:l}=n.textContent,c=t.getAttribute("data-slate-length"),u=a+(null==c?l:parseInt(c,10)),d=i[e+1];if(r.offset===u&&null!=d&&d.hasAttribute("data-slate-mark-placeholder")){var s;const e=d.childNodes[0];o=[e instanceof me?e:d,null!==(s=d.textContent)&&void 0!==s&&s.startsWith("\ufeff")?1:0];break}if(r.offset<=u){const e=Math.min(l,Math.max(0,r.offset-a));o=e===l&&t.hasAttribute("data-slate-trailing")?[t.lastChild,0]:[n,e];break}a=u}return o},Pt=(e,t,n,r)=>{const o=e.document.createRange(),[i,a]=r?n:t,[s,l]=r?t:n,c=!!(be(i)?i:i.parentElement).getAttribute("data-slate-zero-width"),u=!!(be(s)?s:s.parentElement).getAttribute("data-slate-zero-width");return o.setStart(i,c?1:a),o.setEnd(s,u?1:l),o};function Dt(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Rt(e,t){const{path:r,diff:o}=t;if(!n.Editor.hasPath(e,r))return!1;const i=n.Node.get(e,r);if(!n.Node.isText(i))return!1;if(o.start!==i.text.length||0===o.text.length)return i.text.slice(o.start,o.start+o.text.length)===o.text;const a=n.Path.next(r);if(!n.Editor.hasPath(e,a))return!1;const s=n.Node.get(e,a);return n.Node.isText(s)&&s.text.startsWith(o.text)}function Nt(e,...t){return t.reduce(((e,t)=>e.slice(0,t.start)+t.text+e.slice(t.end)),e)}function Mt(e,t){const{start:n,end:r,text:o}=t,i=e.slice(n,r),a=function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e.charAt(r)!==t.charAt(r))return r;return n}(i,o),s=function(e,t,n){const r=Math.min(e.length,t.length,n);for(let n=0;n<r;n++)if(e.charAt(e.length-n-1)!==t.charAt(t.length-n-1))return n;return r}(i,o,Math.min(i.length-a,o.length-a)),l={start:n+a,end:r-s,text:o.slice(a,o.length-s)};return l.start===l.end&&0===l.text.length?null:l}function jt(e){const{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}function Bt(e,t){let{path:r,offset:o}=t;if(!n.Editor.hasPath(e,r))return null;let i=n.Node.get(e,r);if(!n.Node.isText(i))return null;const a=n.Editor.above(e,{match:t=>n.Node.isElement(t)&&n.Editor.isBlock(e,t),at:r});if(!a)return null;for(;o>i.text.length;){const t=n.Editor.next(e,{at:r,match:n.Node.isText});if(!t||!n.Path.isDescendant(t[1],a[1]))return null;o-=i.text.length,i=t[0],r=t[1]}return{path:r,offset:o}}function At(e,t){const r=Bt(e,t.anchor);if(!r)return null;if(n.Range.isCollapsed(t))return{anchor:r,focus:r};const o=Bt(e,t.focus);return o?{anchor:r,focus:o}:null}function _t(e,t,r){const o=pt.get(e),i=null==o?void 0:o.find((({path:e})=>n.Path.equals(e,t.path)));if(!i||t.offset<=i.diff.start)return n.Point.transform(t,r,{affinity:"backward"});const{diff:a}=i;if("insert_node"===r.type&&n.Text.isText(r.node)&&r.node.text===a.text&&a.start===a.end&&n.Path.equals(r.path,n.Path.next(t.path))&&t.offset<=a.start+a.text.length&&n.Node.leaf(e,t.path).text.length===a.start)return{path:r.path,offset:t.offset-a.start};if(t.offset<=a.start+a.text.length){const e={path:t.path,offset:a.start},o=n.Point.transform(e,r,{affinity:"backward"});return o?{path:o.path,offset:o.offset+t.offset-a.start}:null}const s={path:t.path,offset:t.offset-a.text.length+a.end-a.start},l=n.Point.transform(s,r,{affinity:"backward"});return l?"split_node"===r.type&&n.Path.equals(r.path,t.path)&&s.offset<r.position&&a.start<r.position?l:{path:l.path,offset:l.offset+a.text.length-a.end+a.start}:null}function Ft(e,t,r){const o=_t(e,t.anchor,r);if(!o)return null;if(n.Range.isCollapsed(t))return{anchor:o,focus:o};const i=_t(e,t.focus,r);return i?{anchor:o,focus:i}:null}const It=(e,t)=>{const n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n},Lt=(e,t,n)=>{try{const r=xt.toDOMRange(e,t),o=xt.toDOMRange(e,n),i=r.getBoundingClientRect(),a=o.getBoundingClientRect();return It(i,a)&&It(a,i)}catch(e){return!1}};function Wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wt(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ut=new WeakSet,qt=e=>Ze.has(e)||Ut.has(e)||n.Node.isElement(e)&&e.children.some(qt),Vt=e=>n.Node.isElement(e)?zt(zt({},e),{},{children:e.children.map(Vt)}):zt({},e),Kt=e=>{Ut.add(e),n.Node.isElement(e)&&e.children.forEach(Kt)},Ht=e=>{const t=qt(e)?Vt(e):e;return Kt(t),t},$t=["children"],Xt=["children"],Gt=["children"];function Yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Jt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yt(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Zt=(e,t="x-slate-fragment")=>{const r=e,{apply:o,onChange:i,deleteBackward:a,addMark:s,removeMark:l,insertNodes:c}=r;return r.insertNodes=(e,t)=>{c(n.Node.isNode(e)?Ht(e):e.map(Ht),t)},it.set(r,new WeakMap),r.addMark=(e,t)=>{var n,o;null===(n=dt.get(r))||void 0===n||n(),!ft.get(r)&&null!==(o=pt.get(r))&&void 0!==o&&o.length&&ft.set(r,null),ht.delete(r),s(e,t)},r.removeMark=e=>{var t;!ft.get(r)&&null!==(t=pt.get(r))&&void 0!==t&&t.length&&ft.set(r,null),ht.delete(r),l(e)},r.deleteBackward=e=>{if("line"!==e)return a(e);if(r.selection&&n.Range.isCollapsed(r.selection)){const e=n.Editor.above(r,{match:e=>n.Node.isElement(e)&&n.Editor.isBlock(r,e),at:r.selection});if(e){const[,t]=e,o=n.Editor.range(r,t,r.selection.anchor),i=((e,t)=>{const r=n.Editor.range(e,n.Range.end(t)),o=Array.from(n.Editor.positions(e,{at:t}));let i=0,a=o.length,s=Math.floor(a/2);if(Lt(e,n.Editor.range(e,o[i]),r))return n.Editor.range(e,o[i],r);if(o.length<2)return n.Editor.range(e,o[o.length-1],r);for(;s!==o.length&&s!==i;)Lt(e,n.Editor.range(e,o[s]),r)?a=s:i=s,s=Math.floor((i+a)/2);return n.Editor.range(e,o[i],r)})(r,o);n.Range.isCollapsed(i)?a("character"):n.Transforms.delete(r,{at:i})}}},r.apply=t=>{const i=[],a=[],s=pt.get(r);if(null!=s&&s.length){const e=s.map((e=>function(e,t){const{path:r,diff:o,id:i}=e;switch(t.type){case"insert_text":return!n.Path.equals(t.path,r)||t.offset>=o.end?e:t.offset<=o.start?{diff:{start:t.text.length+o.start,end:t.text.length+o.end,text:o.text},id:i,path:r}:{diff:{start:o.start,end:o.end+t.text.length,text:o.text},id:i,path:r};case"remove_text":return!n.Path.equals(t.path,r)||t.offset>=o.end?e:t.offset+t.text.length<=o.start?{diff:{start:o.start-t.text.length,end:o.end-t.text.length,text:o.text},id:i,path:r}:{diff:{start:o.start,end:o.end-t.text.length,text:o.text},id:i,path:r};case"split_node":return!n.Path.equals(t.path,r)||t.position>=o.end?{diff:o,id:i,path:n.Path.transform(r,t,{affinity:"backward"})}:t.position>o.start?{diff:{start:o.start,end:Math.min(t.position,o.end),text:o.text},id:i,path:r}:{diff:{start:o.start-t.position,end:o.end-t.position,text:o.text},id:i,path:n.Path.transform(r,t,{affinity:"forward"})};case"merge_node":return n.Path.equals(t.path,r)?{diff:{start:o.start+t.position,end:o.end+t.position,text:o.text},id:i,path:n.Path.transform(r,t)}:{diff:o,id:i,path:n.Path.transform(r,t)}}const a=n.Path.transform(r,t);return a?{diff:o,path:a,id:i}:null}(e,t))).filter(Boolean);pt.set(r,e)}const l=gt.get(r);l&>.set(r,Ft(r,l,t));const c=vt.get(r);if(null!=c&&c.at){const e=n.Location.isPoint(null==c?void 0:c.at)?_t(r,c.at,t):Ft(r,c.at,t);vt.set(r,e?Jt(Jt({},c),{},{at:e}):null)}switch(t.type){case"insert_text":case"remove_text":case"set_node":case"split_node":i.push(...Qt(r,t.path));break;case"set_selection":var u;null===(u=ct.get(r))||void 0===u||u.unref(),ct.delete(r);break;case"insert_node":case"remove_node":i.push(...Qt(r,n.Path.parent(t.path)));break;case"merge_node":{const e=n.Path.previous(t.path);i.push(...Qt(r,e));break}case"move_node":{const o=n.Path.common(n.Path.parent(t.path),n.Path.parent(t.newPath));let s;i.push(...Qt(r,o)),n.Path.isBefore(t.path,t.newPath)?(i.push(...Qt(r,n.Path.parent(t.path))),s=t.newPath):(i.push(...Qt(r,n.Path.parent(t.newPath))),s=t.path);const l=n.Node.get(e,n.Path.parent(s)),c=xt.findKey(r,l),u=n.Editor.pathRef(r,n.Path.parent(s));a.push([u,c]);break}}switch(o(t),t.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":case"insert_text":case"remove_text":case"set_selection":Ye.set(r,!0)}for(const[e,t]of i){const[o]=n.Editor.node(r,e);ot.set(o,t)}for(const[e,t]of a){if(e.current){const[o]=n.Editor.node(r,e.current);ot.set(o,t)}e.unref()}},r.onDOMError=e=>{"function"==typeof globalThis.reportError?globalThis.reportError(e):setTimeout((()=>{throw e}))},r.setFragmentData=e=>{const{selection:o}=r;if(!o)return;const[i,a]=n.Range.edges(o),s=n.Editor.void(r,{at:i.path}),l=n.Editor.void(r,{at:a.path});if(n.Range.isCollapsed(o)&&!s)return;const c=xt.toDOMRange(r,o);let u=c.cloneContents(),d=c.commonAncestorContainer,f=u.childNodes[0];if(u.childNodes.forEach((e=>{e.textContent&&""!==e.textContent.trim()&&(f=e)})),l){const[e]=l,t=c.cloneRange(),n=xt.toDOMNode(r,e);t.setEndAfter(n),u=t.cloneContents(),d=t.commonAncestorContainer}if(s&&(f=u.querySelector("[data-slate-spacer]")),Array.from(u.querySelectorAll("[data-slate-zero-width]")).forEach((e=>{const t="n"===e.getAttribute("data-slate-zero-width");e.textContent="",t&&e.appendChild(e.ownerDocument.createElement("br"))})),xe(f)){const e=f.ownerDocument.createElement("span");e.style.whiteSpace="pre",e.appendChild(f),u.appendChild(e),f=e}const h=r.getFragment(),p=JSON.stringify(h),v=window.btoa(encodeURIComponent(p));f.setAttribute("data-slate-fragment",v),e.setData(`application/${t}`,v),u=((e,t,n,r)=>{const o=null!==e.querySelector("li");let i=e;for(let e=be(t)?t:t.parentElement;e&&e!==n;e=e.parentElement)if(o&&["OL","UL","LI"].includes(e.nodeName)||r&&"true"===e.getAttribute("data-slate-inline")&&!e.hasAttribute("data-slate-void")){const t=e.cloneNode(!1);t.appendChild(i),i=e.ownerDocument.createDocumentFragment(),i.appendChild(t)}return i})(u,d,xt.toDOMNode(r,r),!s&&!l);const g=u.ownerDocument.createElement("div");return g.appendChild(u),g.setAttribute("hidden","true"),u.ownerDocument.body.appendChild(g),e.setData("text/html",g.innerHTML),e.setData("text/plain",Ce(g)),u.ownerDocument.body.removeChild(g),e},r.insertData=e=>{r.insertFragmentData(e)||r.insertTextData(e)},r.insertFragmentData=e=>{const n=e.getData(`application/${t}`)||(e=>{const t=e.getData("text/html"),[,n]=t.match(Se)||[];return n})(e);if(n){const e=decodeURIComponent(window.atob(n)),t=JSON.parse(e);return r.insertFragment(t),!0}return!1},r.insertTextData=e=>{const t=e.getData("text/plain");if(!t)return!1;const n=t.split(/\r\n|\r|\n/);if(1===n.length)return r.insertText(t),!0;if(en(r))return tn(r,n),!0;const o=nn(r,n);return o&&r.insertFragment(o),!0},r.onChange=e=>{const t=ut.get(r);t&&t(e),i(e)},r},Qt=(e,t)=>{const r=[];for(const[o,i]of n.Editor.levels(e,{at:t})){const t=xt.findKey(e,o);r.push([i,t])}return r},en=e=>!!e.selection&&!!n.Editor.above(e,{at:n.Range.start(e.selection),match:t=>n.Element.isElement(t)&&n.Editor.isInline(e,t)}),tn=(e,t)=>{var r;const o=null!==(r=n.Editor.marks(e))&&void 0!==r?r:{},i=t.slice(1,-1);if(e.insertText(t[0]),n.Transforms.splitNodes(e,{always:!0}),i.length&&e.selection){const{anchor:t}=e.selection,[[r,a]]=n.Editor.nodes(e,{at:t,match:t=>n.Element.isElement(t)&&n.Editor.isBlock(e,t),mode:"lowest"}),{children:s}=r,l=Dt(r,$t),c=Array.from(n.Editor.nodes(e,{at:t,match:t=>n.Element.isElement(t)&&n.Editor.isInline(e,t)}),(([e])=>{let{children:t}=e;return Dt(e,Xt)})),u=e=>c.reduceRight(((e,t)=>Jt(Jt({},t),{},{children:[e]})),Jt(Jt({},o),{},{text:e}));n.Transforms.insertNodes(e,i.map((e=>Jt(Jt({},l),{},{children:[u(e)]}))),{at:a,select:!1})}e.insertText(t[t.length-1])},nn=(e,t)=>{var r;if(!e.selection)return null;const o=n.Editor.above(e,{at:n.Range.start(e.selection),match:t=>n.Element.isElement(t)&&n.Editor.isBlock(e,t),mode:"lowest"});if(!o)return null;const[i]=o,{children:a}=i,s=Dt(i,Gt),l=null!==(r=n.Editor.marks(e))&&void 0!==r?r:{};return t.map((e=>Jt(Jt({},s),{},{children:[Jt(Jt({},l),{},{text:e})]})))},rn={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"},on={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"},an={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},sn=e=>{const t=rn[e],n=on[e],r=an[e],o=t&&fe(t),i=n&&fe(n),a=r&&fe(r);return e=>!(!o||!o(e))||(!!(Ae&&i&&i(e))||!(Ae||!a||!a(e)))};var ln={isBold:sn("bold"),isCompose:sn("compose"),isMoveBackward:sn("moveBackward"),isMoveForward:sn("moveForward"),isDeleteBackward:sn("deleteBackward"),isDeleteForward:sn("deleteForward"),isDeleteLineBackward:sn("deleteLineBackward"),isDeleteLineForward:sn("deleteLineForward"),isDeleteWordBackward:sn("deleteWordBackward"),isDeleteWordForward:sn("deleteWordForward"),isExtendBackward:sn("extendBackward"),isExtendForward:sn("extendForward"),isExtendLineBackward:sn("extendLineBackward"),isExtendLineForward:sn("extendLineForward"),isItalic:sn("italic"),isMoveLineBackward:sn("moveLineBackward"),isMoveLineForward:sn("moveLineForward"),isMoveWordBackward:sn("moveWordBackward"),isMoveWordForward:sn("moveWordForward"),isRedo:sn("redo"),isSoftBreak:sn("insertSoftBreak"),isSplitBlock:sn("splitBlock"),isTransposeCharacter:sn("transposeCharacter"),isUndo:sn("undo")};const cn=["anchor","focus"],un=["anchor","focus"];function dn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dn(Object(n),!0).forEach((function(t){ve(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const hn=(e,t)=>{const{anchor:n,focus:r}=e,o=Dt(e,cn),{anchor:i,focus:a}=t,s=Dt(t,un);return e[yt]===t[yt]&&(l=o,c=s,Object.keys(l).length===Object.keys(c).length&&Object.keys(l).every((e=>c.hasOwnProperty(e)&&l[e]===c[e])));var l,c},pn=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const o=e[r],i=t[r];if(!n.Range.equals(o,i)||!hn(o,i))return!1}return!0},vn=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],o=t[n];if(r.anchor.offset!==o.anchor.offset||r.focus.offset!==o.focus.offset||!hn(r,o))return!1}return!0};function gn(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function mn(){}var yn={d:{f:mn,r:function(){throw Error(gn(522))},D:mn,C:mn,L:mn,m:mn,X:mn,S:mn,M:mn},p:0,findDOMNode:null},bn=Symbol.for("react.portal");function wn(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:bn,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}var En=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function xn(e,t){return"font"===e?"":"string"==typeof t?"use-credentials"===t?t:"":void 0}var On={__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:yn,createPortal:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!t||1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType)throw Error(gn(299));return wn(e,t,null,n)},flushSync:function(e){var t=En.T,n=yn.p;try{if(En.T=null,yn.p=2,e)return e()}finally{En.T=t,yn.p=n,yn.d.f()}},preconnect:function(e,t){"string"==typeof e&&(t?t="string"==typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,yn.d.C(e,t))},prefetchDNS:function(e){"string"==typeof e&&yn.d.D(e)},preinit:function(e,t){if("string"==typeof e&&t&&"string"==typeof t.as){var n=t.as,r=xn(n,t.crossOrigin),o="string"==typeof t.integrity?t.integrity:void 0,i="string"==typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?yn.d.S(e,"string"==typeof t.precedence?t.precedence:void 0,{crossOrigin:r,integrity:o,fetchPriority:i}):"script"===n&&yn.d.X(e,{crossOrigin:r,integrity:o,fetchPriority:i,nonce:"string"==typeof t.nonce?t.nonce:void 0})}},preinitModule:function(e,t){if("string"==typeof e)if("object"==typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=xn(t.as,t.crossOrigin);yn.d.M(e,{crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0})}}else null==t&&yn.d.M(e)},preload:function(e,t){if("string"==typeof e&&"object"==typeof t&&null!==t&&"string"==typeof t.as){var n=t.as,r=xn(n,t.crossOrigin);yn.d.L(e,n,{crossOrigin:r,integrity:"string"==typeof t.integrity?t.integrity:void 0,nonce:"string"==typeof t.nonce?t.nonce:void 0,type:"string"==typeof t.type?t.type:void 0,fetchPriority:"string"==typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"string"==typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"==typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"==typeof t.imageSizes?t.imageSizes:void 0,media:"string"==typeof t.media?t.media:void 0})}},preloadModule:function(e,t){if("string"==typeof e)if(t){var n=xn(t.as,t.crossOrigin);yn.d.m(e,{as:"string"==typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"==typeof t.integrity?t.integrity:void 0})}else yn.d.m(e)},requestFormReset:function(e){yn.d.r(e)},unstable_batchedUpdates:function(e,t){return e(t)},useFormState:function(e,t,n){return En.H.useFormState(e,t,n)},useFormStatus:function(){return En.H.useHostTransitionStatus()},version:"19.2.8"},kn=i((function(e,t){}));kn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,kn.createPortal,kn.flushSync,kn.preconnect,kn.prefetchDNS,kn.preinit,kn.preinitModule,kn.preload,kn.preloadModule,kn.requestFormReset,kn.unstable_batchedUpdates,kn.useFormState,kn.useFormStatus,kn.version;var Cn=i((function(e){!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}(),e.exports=On}));Cn.findDOMNode;var Sn=xt;function Tn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Pn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Tn(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Dn=new WeakMap;function Rn(e){var t=e.editor,r=e.scheduleOnDOMSelectionChange,o=e.onDOMSelectionChange,i=!1,a=!1,s=null,l=null,c=null,u=0,d=0,f=!1,h=!1,p=0,v=!1,g=function(){var e=gt.get(t);if(gt.delete(t),e){var r=t.selection,o=At(t,e);!o||r&&n.Range.equals(o,r)||n.Transforms.select(t,o)}},m=function(){var e=vt.get(t);if(vt.delete(t),e){if(e.at){var r=n.Location.isPoint(e.at)?Bt(t,e.at):At(t,e.at);if(!r)return;var o=n.Editor.range(t,r);t.selection&&n.Range.equals(t.selection,o)||n.Transforms.select(t,r)}e.run()}},y=function(){if(!lt.get(t)||f)return!1;try{var e=Sn.toDOMNode(t,t),n=Sn.getWindow(t).document.activeElement;if(n!==e&&!e.contains(n))return!1}catch(e){}return Date.now()-u<5e3},b=function(){return!(null===(e=pt.get(t))||void 0===e||!e.some((function(e){var r=e.path;try{return 0===n.Node.leaf(t,r).text.length}catch(e){return!1}})))||S()&&void 0!==ft.get(t);var e},E=function(){if(l&&(clearTimeout(l),l=null),c&&(clearTimeout(c),c=null),!a&&y()&&b())l=setTimeout(E,50);else if(S()||C()){i||(i=!0,setTimeout((function(){return i=!1}))),C()&&(i="action");var e=t.selection&&n.Editor.rangeRef(t,t.selection,{affinity:"forward"});ht.set(t,t.marks),vt.get(t),pt.get(t);for(var s,u=S();s=null===(d=pt.get(t))||void 0===d?void 0:d[0];){var d,f,p=ft.get(t);void 0!==p&&(ft.delete(t),t.marks=p),p&&!1===v&&(v=null);var w=jt(s);t.selection&&n.Range.equals(t.selection,w)||n.Transforms.select(t,w),s.diff.text?n.Editor.insertText(t,s.diff.text):n.Editor.deleteFragment(t),pt.set(t,null===(f=pt.get(t))||void 0===f?void 0:f.filter((function(e){return e.id!==s.id}))),Rt(t,s)||(u=!1,vt.delete(t),ht.delete(t),i="action",gt.delete(t),r.cancel(),o.cancel(),null==e||e.unref())}var x,O,k=null==e?void 0:e.unref();if(!k||gt.get(t)||t.selection&&n.Range.equals(k,t.selection)||n.Transforms.select(t,k),C())return O=t.children,m(),h&&t.children===O&&(null===(x=mt.get(t))||void 0===x||x()),void(h=!1);u&&r(),r.flush(),o.flush(),g();var T=ht.get(t);ht.delete(t),void 0!==T&&T!==t.marks&&(t.marks=T,t.onChange())}else g()},x=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=tt.get(t);n&&(S()||e?n.style.display="none":n.style.removeProperty("display"))},O=function(e,r){var o,i=null!==(o=pt.get(t))&&void 0!==o?o:[];pt.set(t,i);var a=n.Node.leaf(t,e),s=i.findIndex((function(t){return n.Path.equals(t.path,e)}));if(s<0)return Mt(a.text,r)&&i.push({path:e,diff:r,id:p++}),void x();var l=function(e,t,n){const r=Math.min(t.start,n.start),o=Math.max(0,Math.min(t.start+t.text.length,n.end)-n.start),i=Nt(e,t,n),a=Math.max(n.start+n.text.length,t.start+t.text.length+(t.start+t.text.length>n.start?n.text.length:0)-o),s=i.slice(r,a);return Mt(e,{start:r,end:Math.max(t.end,n.end-t.text.length+(t.end-t.start)),text:s})}(a.text,i[s].diff,r);if(!l)return i.splice(s,1),void x();i[s]=Pn(Pn({},i[s]),{},{diff:l})},k=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.at;v=!1,gt.delete(t),r.cancel(),o.cancel(),C()&&E(),c&&clearTimeout(c),vt.set(t,{at:i,run:e}),c=setTimeout(E)},C=function(){return!!vt.get(t)},S=function(){var e;return!(null===(e=pt.get(t))||void 0===e||!e.length)},T=function(e){gt.set(t,e),l&&(clearTimeout(l),l=null);var r=t.selection;if(e){var o=!r||!n.Path.equals(r.anchor.path,e.anchor.path),i=!r||!n.Path.equals(r.anchor.path.slice(0,-1),e.anchor.path.slice(0,-1));(o&&v||i)&&(v=!1),(o||S())&&(l=setTimeout(E,200))}},P=function(){C()||(c&&clearTimeout(c),c=setTimeout(E))};return{flush:E,flushDeferredDiffs:function(){if(!i&&y()&&b()){a=!0;try{E()}finally{a=!1}}},scheduleFlush:P,hasPendingDiffs:S,hasPendingAction:C,hasPendingChanges:function(){return C()||S()},isFlushing:function(){return i},handleUserSelect:T,handleCompositionEnd:function(e){if(s&&clearTimeout(s),b()&&!i)return Cn.flushSync((function(){lt.set(t,!1),E()})),void x();s=setTimeout((function(){var e;(lt.set(t,!1),E(),f)&&(null===(e=mt.get(t))||void 0===e||e());x()}),25)},handleCompositionStart:function(e){lt.set(t,!0),u=Date.now(),f=!1,s&&(clearTimeout(s),s=null)},handleDOMBeforeInput:function(e){l&&(clearTimeout(l),l=null);var r=Ye.get(t),o=e.inputType,i=Fe&&"insertText"===o&&Date.now()-d<25;if("insertText"===o&&(d=Date.now()),"insertCompositionText"===o||"deleteCompositionText"===o)if(u=Date.now(),e.data)f=!1;else{f=!0;var a=pt.get(t);if(null!=a&&a.length){var s=a.every((function(e){var r=e.path;try{return 0===n.Node.leaf(t,r).text.length}catch(e){return!1}}));s&&(pt.set(t,[]),gt.delete(t))}}var c=null,h=e.dataTransfer||e.data||void 0;!1!==v&&"insertText"!==o&&"insertCompositionText"!==o&&(v=!1);var p=e.getTargetRanges(),g=w(p,1)[0];g&&!r&&(c=Sn.toSlateRange(t,g,{exactMatch:!1,suppressThrow:!0}));var m=Sn.getWindow(t).getSelection();if(c||!m||r||(g=m,c=Sn.toSlateRange(t,m,{exactMatch:!1,suppressThrow:!0})),c=null!=c?c:t.selection){var y,b=!0;if(o.startsWith("delete")){var E=o.endsWith("Backward")?"backward":"forward",x=n.Range.edges(c),C=w(x,2),S=C[0],D=C[1],R=n.Editor.leaf(t,S.path),N=w(R,2),M=N[0],j=N[1];if(n.Range.isExpanded(c)&&M.text.length===S.offset&&0===D.offset){var B=n.Editor.next(t,{at:S.path,match:n.Node.isText});if(B&&n.Path.equals(B[1],D.path))if("backward"===E){c={anchor:D,focus:D},S=D;var A=w(B,2);M=A[0],j=A[1]}else c={anchor:S,focus:S},D=S}var _={text:"",start:S.offset,end:D.offset},F=pt.get(t),I=null==F?void 0:F.find((function(e){return n.Path.equals(e.path,j)})),L=I?[I.diff,_]:[_];if(0===Nt.apply(void 0,[M.text].concat(L)).length&&(b=!1),n.Range.isExpanded(c)){if(b&&n.Path.equals(c.anchor.path,c.focus.path)){var W={path:c.anchor.path,offset:S.offset},z=n.Editor.range(t,W,W);return T(z),O(c.anchor.path,{text:"",end:D.offset,start:S.offset}),void("deleteContentBackward"===o&&P())}return k((function(){return n.Editor.deleteFragment(t,{direction:E})}),{at:c})}}switch(o){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return k((function(){return n.Editor.deleteFragment(t)}),{at:c});case"deleteContent":case"deleteContentForward":var U=c.anchor;if(b&&n.Range.isCollapsed(c)){var q=n.Node.leaf(t,U.path);if(U.offset<q.text.length)return O(U.path,{text:"",start:U.offset,end:U.offset+1})}return k((function(){return n.Editor.deleteForward(t)}),{at:c});case"deleteContentBackward":var V,K=c.anchor,H=Ee(g)?g.isCollapsed:!(null===(V=g)||void 0===V||!V.collapsed);return b&&H&&n.Range.isCollapsed(c)&&K.offset>0?(O(K.path,{text:"",start:K.offset-1,end:K.offset}),void P()):k((function(){return n.Editor.deleteBackward(t)}),{at:c});case"deleteEntireSoftLine":return k((function(){n.Editor.deleteBackward(t,{unit:"line"}),n.Editor.deleteForward(t,{unit:"line"})}),{at:c});case"deleteHardLineBackward":return k((function(){return n.Editor.deleteBackward(t,{unit:"block"})}),{at:c});case"deleteSoftLineBackward":return k((function(){return n.Editor.deleteBackward(t,{unit:"line"})}),{at:c});case"deleteHardLineForward":return k((function(){return n.Editor.deleteForward(t,{unit:"block"})}),{at:c});case"deleteSoftLineForward":return k((function(){return n.Editor.deleteForward(t,{unit:"line"})}),{at:c});case"deleteWordBackward":return k((function(){return n.Editor.deleteBackward(t,{unit:"word"})}),{at:c});case"deleteWordForward":return k((function(){return n.Editor.deleteForward(t,{unit:"word"})}),{at:c});case"insertLineBreak":return k((function(){return n.Editor.insertSoftBreak(t)}),{at:c});case"insertParagraph":return k((function(){return n.Editor.insertBreak(t)}),{at:c});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if("DataTransfer"===(null==(y=h)?void 0:y.constructor.name))return k((function(){return Sn.insertData(t,h)}),{at:c});var $=null!=h?h:"";if(ft.get(t)&&($=$.replace("\ufeff","")),i&&t.selection&&!n.Range.equals(c,t.selection))return e.preventDefault(),k((function(){return n.Editor.insertText(t,$)}));if("insertText"===o&&/.*\n.*\n$/.test($)&&($=$.slice(0,-1)),$.includes("\n"))return k((function(){var e=$.split("\n");e.forEach((function(r,o){r&&n.Editor.insertText(t,r),o!==e.length-1&&n.Editor.insertSoftBreak(t)}))}),{at:c});if("insertText"===o&&!Sn.isComposing(t)&&n.Range.isCollapsed(c)&&"function"==typeof n.Editor.insertionPoint&&!n.Point.equals(n.Editor.insertionPoint(t,c.anchor),c.anchor)){var X,G=Ee(g)?g.anchorNode:null===(X=g)||void 0===X?void 0:X.startContainer,Y=we(G)&&3===G.nodeType?{node:G,text:G.textContent}:null;return e.preventDefault(),k((function(){Y&&Y.node.isConnected&&Y.node.textContent!==Y.text&&(Y.node.textContent=Y.text),n.Editor.insertText(t,$)}),{at:c})}if(n.Path.equals(c.anchor.path,c.focus.path)){var J=n.Range.edges(c),Z=w(J,2),Q=Z[0],ee=Z[1],te={start:Q.offset,end:ee.offset,text:$};if($&&v&&"insertCompositionText"===o){var ne=v.start+v.text.search(/\S|$/);te.start+te.text.search(/\S|$/)===ne+1&&te.end===v.start+v.text.length?(te.start-=1,v=null,P()):v=!1}else v="insertText"===o&&(null===v?te:!(!v||!n.Range.isCollapsed(c)||v.end+v.text.length!==Q.offset)&&Pn(Pn({},v),{},{text:v.text+$}));if(b){var re=t.selection;if(O(Q.path,te),re){var oe={path:Q.path,offset:Q.offset+$.length};k((function(){}),{at:oe})}return}}return k((function(){return n.Editor.insertText(t,$)}),{at:c})}}},handleKeyDown:function(e){S()||(x(!0),setTimeout(x))},handleDomMutations:function(e){var n;S()||e.some((function(n){return Pe(t,n,e)}))&&(C()?h=!0:null===(n=mt.get(t))||void 0===n||n())},handleInput:function(){!C()&&S()||E()}}}var Nn=He?t.useLayoutEffect:t.useEffect;var Mn=["node"];function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Bn,An={subtree:!0,childList:!0,characterData:!0},_n=_e?function(e){var n=e.node,r=l(e,Mn);if(!_e)return null;var o,i=ue(),a=(o=t.useRef(!1),t.useEffect((function(){return o.current=!0,function(){o.current=!1}}),[]),o.current),s=t.useState((function(){return Rn(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({editor:i},r))})),c=w(s,1)[0];return function(e,n,r){var o=t.useState((function(){return new MutationObserver(n)})),i=w(o,1)[0];Nn((function(){i.takeRecords()})),t.useEffect((function(){if(!e.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");return i.observe(e.current,r),function(){return i.disconnect()}}),[i,e,r])}(n,c.handleDomMutations,An),dt.set(i,c.scheduleFlush),Dn.set(i,c.flushDeferredDiffs),a&&c.flush(),c}:function(){return null},Fn=[],In="ResizeObserver loop completed with undelivered notifications.";!function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(Bn||(Bn={}));var Ln,Wn=function(e){return Object.freeze(e)},zn=function(e,t){this.inlineSize=e,this.blockSize=t,Wn(this)},Un=function(){function e(e,t,n,r){return this.x=e,this.y=t,this.width=n,this.height=r,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,Wn(this)}return e.prototype.toJSON=function(){var e=this;return{x:e.x,y:e.y,top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.width,height:e.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),qn=function(e){return e instanceof SVGElement&&"getBBox"in e},Vn=function(e){if(qn(e)){var t=e.getBBox(),n=t.width,r=t.height;return!n&&!r}var o=e,i=o.offsetWidth,a=o.offsetHeight;return!(i||a||e.getClientRects().length)},Kn=function(e){var t;if(e instanceof Element)return!0;var n=null===(t=null==e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView;return!!(n&&e instanceof n.Element)},Hn="undefined"!=typeof window?window:{},$n=new WeakMap,Xn=/auto|scroll/,Gn=/^tb|vertical/,Yn=/msie|trident/i.test(Hn.navigator&&Hn.navigator.userAgent),Jn=function(e){return parseFloat(e||"0")},Zn=function(e,t,n){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=!1),new zn((n?t:e)||0,(n?e:t)||0)},Qn=Wn({devicePixelContentBoxSize:Zn(),borderBoxSize:Zn(),contentBoxSize:Zn(),contentRect:new Un(0,0,0,0)}),er=function(e,t){if(void 0===t&&(t=!1),$n.has(e)&&!t)return $n.get(e);if(Vn(e))return $n.set(e,Qn),Qn;var n=getComputedStyle(e),r=qn(e)&&e.ownerSVGElement&&e.getBBox(),o=!Yn&&"border-box"===n.boxSizing,i=Gn.test(n.writingMode||""),a=!r&&Xn.test(n.overflowY||""),s=!r&&Xn.test(n.overflowX||""),l=r?0:Jn(n.paddingTop),c=r?0:Jn(n.paddingRight),u=r?0:Jn(n.paddingBottom),d=r?0:Jn(n.paddingLeft),f=r?0:Jn(n.borderTopWidth),h=r?0:Jn(n.borderRightWidth),p=r?0:Jn(n.borderBottomWidth),v=d+c,g=l+u,m=(r?0:Jn(n.borderLeftWidth))+h,y=f+p,b=s?e.offsetHeight-y-e.clientHeight:0,w=a?e.offsetWidth-m-e.clientWidth:0,E=o?v+m:0,x=o?g+y:0,O=r?r.width:Jn(n.width)-E-w,k=r?r.height:Jn(n.height)-x-b,C=O+v+w+m,S=k+g+b+y,T=Wn({devicePixelContentBoxSize:Zn(Math.round(O*devicePixelRatio),Math.round(k*devicePixelRatio),i),borderBoxSize:Zn(C,S,i),contentBoxSize:Zn(O,k,i),contentRect:new Un(d,l,O,k)});return $n.set(e,T),T},tr=function(e,t,n){var r=er(e,n),o=r.borderBoxSize,i=r.contentBoxSize,a=r.devicePixelContentBoxSize;switch(t){case Bn.DEVICE_PIXEL_CONTENT_BOX:return a;case Bn.BORDER_BOX:return o;default:return i}},nr=function(e){var t=er(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=Wn([t.borderBoxSize]),this.contentBoxSize=Wn([t.contentBoxSize]),this.devicePixelContentBoxSize=Wn([t.devicePixelContentBoxSize])},rr=function(e){if(Vn(e))return 1/0;for(var t=0,n=e.parentNode;n;)t+=1,n=n.parentNode;return t},or=function(){var e=1/0,t=[];Fn.forEach((function(n){if(0!==n.activeTargets.length){var r=[];n.activeTargets.forEach((function(t){var n=new nr(t.target),o=rr(t.target);r.push(n),t.lastReportedSize=tr(t.target,t.observedBox),o<e&&(e=o)})),t.push((function(){n.callback.call(n.observer,r,n.observer)})),n.activeTargets.splice(0,n.activeTargets.length)}}));for(var n=0,r=t;n<r.length;n++){(0,r[n])()}return e},ir=function(e){Fn.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(n){n.isActive()&&(rr(n.target)>e?t.activeTargets.push(n):t.skippedTargets.push(n))}))}))},ar=function(){var e,t=0;for(ir(t);Fn.some((function(e){return e.activeTargets.length>0}));)t=or(),ir(t);return Fn.some((function(e){return e.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?e=new ErrorEvent("error",{message:In}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=In),window.dispatchEvent(e)),t>0},sr=[],lr=function(e){if(!Ln){var t=0,n=document.createTextNode("");new MutationObserver((function(){return sr.splice(0).forEach((function(e){return e()}))})).observe(n,{characterData:!0}),Ln=function(){n.textContent="".concat(t?t--:t++)}}sr.push(e),Ln()},cr=0,ur={attributes:!0,characterData:!0,childList:!0,subtree:!0},dr=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],fr=function(e){return void 0===e&&(e=0),Date.now()+e},hr=!1,pr=new(function(){function e(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return e.prototype.run=function(e){var t=this;if(void 0===e&&(e=250),!hr){hr=!0;var n,r=fr(e);n=function(){var n=!1;try{n=ar()}finally{if(hr=!1,e=r-fr(),!cr)return;n?t.run(1e3):e>0?t.run(e):t.start()}},lr((function(){requestAnimationFrame(n)}))}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var e=this,t=function(){return e.observer&&e.observer.observe(document.body,ur)};document.body?t():Hn.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),dr.forEach((function(t){return Hn.addEventListener(t,e.listener,!0)})))},e.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),dr.forEach((function(t){return Hn.removeEventListener(t,e.listener,!0)})),this.stopped=!0)},e}()),vr=function(e){!cr&&e>0&&pr.start(),!(cr+=e)&&pr.stop()},gr=function(){function e(e,t){this.target=e,this.observedBox=t||Bn.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var e,t=tr(this.target,this.observedBox,!0);return e=this.target,qn(e)||function(e){switch(e.tagName){case"INPUT":if("image"!==e.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(e)||"inline"!==getComputedStyle(e).display||(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),mr=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},yr=new WeakMap,br=function(e,t){for(var n=0;n<e.length;n+=1)if(e[n].target===t)return n;return-1},wr=function(){function e(){}return e.connect=function(e,t){var n=new mr(e,t);yr.set(e,n)},e.observe=function(e,t,n){var r=yr.get(e),o=0===r.observationTargets.length;br(r.observationTargets,t)<0&&(o&&Fn.push(r),r.observationTargets.push(new gr(t,n&&n.box)),vr(1),pr.schedule())},e.unobserve=function(e,t){var n=yr.get(e),r=br(n.observationTargets,t),o=1===n.observationTargets.length;r>=0&&(o&&Fn.splice(Fn.indexOf(n),1),n.observationTargets.splice(r,1),vr(-1))},e.disconnect=function(e){var t=this,n=yr.get(e);n.observationTargets.slice().forEach((function(n){return t.unobserve(e,n.target)})),n.activeTargets.splice(0,n.activeTargets.length)},e}(),Er=function(){function e(e){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof e)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");wr.connect(this,e)}return e.prototype.observe=function(e,t){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Kn(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");wr.observe(this,e,t)},e.prototype.unobserve=function(e){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!Kn(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");wr.unobserve(this,e)},e.prototype.disconnect=function(){wr.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}();function xr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var Or=function(e){var r=e.isLast,o=e.leaf,i=e.parent,a=e.text,s=ue(),l=Sn.findPath(s,a),c=n.Path.parent(l),u=Boolean(o[bt]);return s.isVoid(i)?t.createElement(Sr,{length:n.Node.string(i).length}):""!==o.text||i.children[i.children.length-1]!==a||s.isInline(i)||""!==n.Editor.string(s,c)?""===o.text?t.createElement(Sr,{isMarkPlaceholder:u}):r&&"\n"===o.text.slice(-1)?t.createElement(kr,{isTrailing:!0,text:o.text}):t.createElement(kr,{text:o.text}):t.createElement(Sr,{isLineBreak:!0,isMarkPlaceholder:u})},kr=function(e){var n=e.text,r=e.isTrailing,o=void 0!==r&&r,i=ue(),a=t.useRef(null),s=function(){return"".concat(null!=n?n:"").concat(o?"\n":"")},l=t.useState(s),c=w(l,1)[0];return Nn((function(){var e,t,r,l=s();if(a.current&&a.current.textContent!==l){if(_e&<.get(i)){var c,u=null===(c=Sn.getWindow(i).getSelection())||void 0===c?void 0:c.anchorNode;if(u&&a.current.contains(u))return}a.current.textContent=l}Fe&&(null===(r=a.current)||void 0===r||r.toggleAttribute("data-slate-trailing",o));var d=null===(e=a.current)||void 0===e?void 0:e.firstChild;Fe&&o&&1===(null===(t=a.current)||void 0===t?void 0:t.childNodes.length)&&3===(null==d?void 0:d.nodeType)&&d.splitText(n.length)})),t.createElement(Cr,{ref:a},c)},Cr=t.memo(t.forwardRef((function(e,n){return t.createElement("span",{"data-slate-string":!0,ref:n},e.children)}))),Sr=function(e){var n=e.length,r=void 0===n?0:n,o=e.isLineBreak,i=void 0!==o&&o,a=e.isMarkPlaceholder,s={"data-slate-zero-width":i?"n":"z","data-slate-length":r};return void 0!==a&&a&&(s["data-slate-mark-placeholder"]=!0),t.createElement("span",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},s),"\ufeff",i?t.createElement("br",null):null)},Tr=function(e,t){return e.children[e.children.length-1]===t},Pr=function(e,t,r,o){return e===t||(i=e,a=t,s=Object.keys(i).filter((function(e){return"children"!==e})),l=Object.keys(a).filter((function(e){return"children"!==e})),s.length===l.length&&s.every((function(e){return e in a&&i[e]===a[e]}))&&Tr(e,r)===Tr(t,o)&&(""!==o.text||""===n.Node.string(e)==(""===n.Node.string(t))));var i,a,s,l};function Dr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Rr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Dr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Nr=_e?300:0;function Mr(e){e.current&&(clearTimeout(e.current),e.current=null)}var jr=function(e){return t.createElement(_r,Rr({},e))},Br=function(e){var n=e.leaf,r=e.isLast,o=e.text,i=e.parent,a=e.renderPlaceholder,s=e.renderLeaf,l=void 0===s?jr:s,c=e.leafPosition,u=ue(),d=t.useRef(null),f=t.useRef(null),h=t.useState(!1),p=w(h,2),v=p[0],g=p[1],m=t.useRef(null),y=t.useCallback((function(e){if(function(e,t){e.current&&(e.current.disconnect(),t&&(e.current=null))}(d,null==e),null==e){var t;tt.delete(u),null===(t=n.onPlaceholderResize)||void 0===t||t.call(n,null)}else{if(tt.set(u,e),!d.current){var r=window.ResizeObserver||Er;d.current=new r((function(){var t;null===(t=n.onPlaceholderResize)||void 0===t||t.call(n,e)}))}d.current.observe(e),f.current=e}}),[f,n,u]),b=t.createElement(Or,{isLast:r,leaf:n,parent:i,text:o}),E=Boolean(n[yt]);if(t.useEffect((function(){return E?m.current||(m.current=setTimeout((function(){g(!0),m.current=null}),Nr)):(Mr(m),g(!1)),function(){return Mr(m)}}),[E,g]),E&&v){var x={children:n.placeholder,attributes:{"data-slate-placeholder":!0,"aria-hidden":!0,style:{position:"absolute",top:0,pointerEvents:"none",width:"100%",maxWidth:"100%",display:"block",opacity:"0.333",userSelect:"none",WebkitUserSelect:"none",textDecoration:"none",WebkitUserModify:Ie?"inherit":void 0},contentEditable:!1,ref:y}};b=t.createElement(t.Fragment,null,b,a(x))}return l({attributes:{"data-slate-leaf":!0},children:b,leaf:n,text:o,leafPosition:c})},Ar=t.memo(Br,(function(e,t){return Pr(e.parent,t.parent,e.text,t.text)&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&n.Text.equals(t.leaf,e.leaf)&&t.leaf[yt]===e.leaf[yt]})),_r=function(e){var n=e.attributes,r=e.children;return t.createElement("span",Rr({},n),r)},Fr=i((function(e){e.exports=function(e){if(Array.isArray(e))return g(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Fr);var Ir=i((function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Ir);var Lr=i((function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Lr);var Wr=i((function(e){e.exports=function(e){return Fr(e)||Ir(e)||m(e)||Lr()},e.exports.__esModule=!0,e.exports.default=e.exports})),zr=o(Wr);function Ur(e,n){var r,o=t.useReducer((function(e){return e+1}),0),i=w(o,2)[1],a=t.useRef(void 0),s=t.useRef((function(){return null})),l=t.useRef(null);try{if(e!==s.current||a.current){var c=e();r=n(l.current,c)?l.current:c}else r=l.current}catch(e){throw a.current&&e instanceof Error&&(e.message+="\nThe error may be correlated with this previous error:\n".concat(a.current.stack,"\n\n")),e}return s.current=e,l.current=r,a.current=void 0,[r,t.useCallback((function(){try{var e=s.current();if(n(l.current,e))return;l.current=e}catch(e){e instanceof Error?a.current=e:a.current=new Error(String(e))}i()}),[])]}var qr=t.createContext({}),Vr=function(e,r){var o=ue(),i=t.useContext(qr),a=i.decorate,s=i.addEventListener,l=Ur((function(){var t=Sn.findPath(o,e),r=a([e,t]);if(n.Node.isText(e)){var i=n.Editor.range(o,t);return r.flatMap((function(e){var t=n.Range.intersection(e,i);return t?[t]:[]}))}return r}),n.Node.isText(e)?vn:pn),c=w(l,2),u=c[0],d=c[1];return Nn((function(){var e=s(d);return d(),e}),[s,d]),t.useMemo((function(){return[].concat(zr(u),zr(r))}),[u,r])};function Kr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Hr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Kr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $r=function(e){return t.createElement(Yr,Hr({},e))},Xr=function(e){for(var r=e.decorations,o=e.isLast,i=e.parent,a=e.renderPlaceholder,s=e.renderLeaf,l=e.renderText,c=void 0===l?$r:l,u=e.text,d=ue(),f=t.useRef(null),h=Vr(u,r),p=n.Text.decorations(u,h),v=Sn.findKey(d,u),g=[],m=0;m<p.length;m++){var y=p[m],b=y.leaf,w=y.position;g.push(t.createElement(Ar,{isLast:o&&m===p.length-1,key:"".concat(v.id,"-").concat(m),renderPlaceholder:a,leaf:b,leafPosition:w,text:u,parent:i,renderLeaf:s}))}var E=t.useCallback((function(e){var t=it.get(d);e?(null==t||t.set(v,e),rt.set(u,e),nt.set(e,u)):(null==t||t.delete(v),rt.delete(u),f.current&&nt.delete(f.current)),f.current=e}),[f,d,v,u]);return c({text:u,children:g,attributes:{"data-slate-node":"text",ref:E}})},Gr=t.memo(Xr,(function(e,t){return Pr(e.parent,t.parent,e.text,t.text)&&t.isLast===e.isLast&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&t.text===e.text&&vn(t.decorations,e.decorations)})),Yr=function(e){var n=e.attributes,r=e.children;return t.createElement("span",Hr({},n),r)};function Jr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Zr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jr(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Qr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return eo(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?eo(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function eo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var to=function(e){var t,r=Qr(e);try{for(r.s();!(t=r.n()).done;){var o=t.value,i=E(n.Node.string(o));if("neutral"!==i)return i}}catch(e){r.e(e)}finally{r.f()}},no=function(e,t){return function(e,t){return n.Editor.isVoid(e,t)?[n.Node.texts(t).next().value[0]]:t.children}(e,t).findIndex((function(e){return!rt.has(e)}))},ro=function(e){return t.createElement(ao,Zr({},e))},oo=function(e){var r=e.decorations,o=e.element,i=e.renderElement,a=void 0===i?ro:i,s=e.renderChunk,l=e.renderPlaceholder,c=e.renderLeaf,u=e.renderText,d=ue(),f=Do(),h=d.isInline(o),p=Vr(o,r),v=Sn.findKey(d,o),g=t.useCallback((function(e){var t=it.get(d);e?(null==t||t.set(v,e),rt.set(o,e),nt.set(e,o)):(null==t||t.delete(v),rt.delete(o))}),[d,v,o]);Nn((function(){var e=no(d,o);if(-1!==e){var t=o.type,n=Sn.findPath(d,o);d.onDOMError(new Error("renderElement didn't render the children of the ".concat("string"==typeof t?'"'.concat(t,'" '):"","element at path ").concat(JSON.stringify(n),": child ").concat(e," has no DOM node. Render the `children` prop inside the element.")))}}),[d,o]);var m=So({decorations:p,node:o,renderElement:a,renderChunk:s,renderPlaceholder:l,renderLeaf:c,renderText:u}),y={"data-slate-node":"element",ref:g};if(h&&(y["data-slate-inline"]=!0),!h&&n.Editor.hasInlines(d,o)){var b=n.Node.string(o),x=""===b?function(e){var t,n=Ze.get(e),r=Je.get(e);if(n&&void 0!==r){var o=n.children.slice(0,r).reverse(),i=n.children.slice(r+1);return null!==(t=to(o))&&void 0!==t?t:to(i)}}(o):E(b);"rtl"===x&&(y.dir=x)}if(n.Editor.isVoid(d,o)){y["data-slate-void"]=!0,!f&&h&&(y.contentEditable=!1);var O=h?"span":"div",k=n.Node.texts(o),C=w(k,1),S=w(C[0],1)[0];m=t.createElement(O,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute",userSelect:"none",WebkitUserSelect:"none"}},t.createElement(Gr,{renderPlaceholder:l,decorations:[],isLast:!1,parent:o,text:S})),Je.set(S,0),Ze.set(S,o)}return a({attributes:y,children:m,element:o})},io=t.memo(oo,(function(e,t){return e.element===t.element&&e.renderElement===t.renderElement&&e.renderChunk===t.renderChunk&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&pn(e.decorations,t.decorations)})),ao=function(e){var n=e.attributes,r=e.children,o=e.element,i=ue().isInline(o)?"span":"div";return t.createElement(i,Zr(Zr({},n),{},{style:{position:"relative"}}),r)},so=i((function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports})),lo=o(so),co=i((function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports})),uo=o(co),fo=function(){return uo((function e(t,n){var r=n.chunkSize,o=n.debug;lo(this,e),h(this,"root",void 0),h(this,"chunkSize",void 0),h(this,"debug",void 0),h(this,"reachedEnd",void 0),h(this,"pointerChunk",void 0),h(this,"pointerIndex",void 0),h(this,"pointerIndexStack",void 0),h(this,"cachedPointerNode",void 0),this.root=t,this.chunkSize=r,this.debug=null!=o&&o,this.pointerChunk=t,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.validateState()}),[{key:"readLeaf",value:function(){if(this.reachedEnd)return null;for(;;){if(this.pointerIndex+1<this.pointerSiblings.length){this.pointerIndex++,this.cachedPointerNode=void 0;break}if("root"===this.pointerChunk.type)return this.reachedEnd=!0,null;this.exitChunk()}return this.validateState(),this.enterChunkUntilLeaf(!1),this.pointerNode}},{key:"returnToPreviousLeaf",value:function(){if(this.reachedEnd)return this.reachedEnd=!1,void this.enterChunkUntilLeaf(!0);for(;;){if(this.pointerIndex>=1){this.pointerIndex--,this.cachedPointerNode=void 0;break}if("root"===this.pointerChunk.type)return void(this.pointerIndex=-1);this.exitChunk()}this.validateState(),this.enterChunkUntilLeaf(!0)}},{key:"insertBefore",value:function(e){this.returnToPreviousLeaf(),this.insertAfter(e),this.readLeaf()}},{key:"insertAfter",value:function(e){if(0!==e.length){for(var t=0,n=0;"chunk"===this.pointerChunk.type&&this.pointerIndex===this.pointerSiblings.length-1;){var r=this.chunkSize-this.pointerSiblings.length,o=Math.min(r,e.length);if(o>0){var i=e.splice(0,o);this.rawInsertAfter(i,t)}this.exitChunk(),t++}if(0!==e.length){var a=this.savePointer(),s=null;if(this.readLeaf())for(;"chunk"===this.pointerChunk.type&&0===this.pointerIndex;){var l=this.chunkSize-this.pointerSiblings.length,c=Math.min(l,e.length);if(c>0){var u=e.splice(-c,c);this.pointerIndex=-1,this.cachedPointerNode=void 0,this.rawInsertAfter(u,n),s||(s=this.savePointer())}this.exitChunk(),n++}this.restorePointer(a);var d=Math.max(t,n);this.rawInsertAfter(e,d),s&&this.restorePointer(s),this.validateState()}}}},{key:"remove",value:function(){this.pointerSiblings.splice(this.pointerIndex--,1),this.cachedPointerNode=void 0,0===this.pointerSiblings.length&&"chunk"===this.pointerChunk.type?(this.exitChunk(),this.remove()):this.invalidateChunk(),this.validateState()}},{key:"invalidateChunk",value:function(){for(var e=this.pointerChunk;"chunk"===e.type;e=e.parent)this.root.modifiedChunks.add(e)}},{key:"atStart",get:function(){return"root"===this.pointerChunk.type&&-1===this.pointerIndex}},{key:"pointerSiblings",get:function(){return this.pointerChunk.children}},{key:"getPointerNode",value:function(){return this.reachedEnd||-1===this.pointerIndex?null:this.pointerSiblings[this.pointerIndex]}},{key:"pointerNode",get:function(){if(void 0!==this.cachedPointerNode)return this.cachedPointerNode;var e=this.getPointerNode();return this.cachedPointerNode=e,e}},{key:"getChunkPath",value:function(e){for(var t=[],n=e;"chunk"===n.type;n=n.parent){var r=n.parent.children.indexOf(n);if(-1===r)return null;t.unshift(r)}return t}},{key:"savePointer",value:function(){if(this.atStart)return"start";if(!this.pointerNode)throw new Error("Cannot save pointer when pointerNode is null");return{chunk:this.pointerChunk,node:this.pointerNode}}},{key:"restorePointer",value:function(e){if("start"===e)return this.pointerChunk=this.root,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,void(this.cachedPointerNode=void 0);var t=e.chunk,n=e.node,r=t.children.indexOf(n);if(-1===r)throw new Error("Cannot restore point because saved node is no longer in saved chunk");var o=this.getChunkPath(t);if(!o)throw new Error("Cannot restore point because saved chunk is no longer connected to root");this.pointerChunk=t,this.pointerIndex=r,this.pointerIndexStack=o,this.reachedEnd=!1,this.cachedPointerNode=n,this.validateState()}},{key:"enterChunk",value:function(e){var t;if("chunk"!==(null===(t=this.pointerNode)||void 0===t?void 0:t.type))throw new Error("Cannot enter non-chunk");if(this.pointerIndexStack.push(this.pointerIndex),this.pointerChunk=this.pointerNode,this.pointerIndex=e?this.pointerSiblings.length-1:0,this.cachedPointerNode=void 0,this.validateState(),0===this.pointerChunk.children.length)throw new Error("Cannot enter empty chunk")}},{key:"enterChunkUntilLeaf",value:function(e){for(;"chunk"===(null===(t=this.pointerNode)||void 0===t?void 0:t.type);){var t;this.enterChunk(e)}}},{key:"exitChunk",value:function(){if("root"===this.pointerChunk.type)throw new Error("Cannot exit root");var e=this.pointerChunk;this.pointerChunk=e.parent,this.pointerIndex=this.pointerIndexStack.pop(),this.cachedPointerNode=void 0,this.validateState()}},{key:"rawInsertAfter",value:function(e,t){var n,r=this;if(0!==e.length){for(var o=function(e,t,n){if(1===n)return e;for(var i=[],a=0;a<r.chunkSize;a++){var s=e.slice(a*n,(a+1)*n);if(0===s.length)break;var l={type:"chunk",key:new Ge,parent:t,children:[]};l.children=o(s,l,n/r.chunkSize),i.push(l)}return i},i=this.pointerSiblings.length+e.length,a=0,s=this.chunkSize;s<i;s*=this.chunkSize)a++;var l=Math.max(a,t),c=Math.pow(this.chunkSize,l),u=o(e,this.pointerChunk,c);(n=this.pointerSiblings).splice.apply(n,[this.pointerIndex+1,0].concat(zr(u))),this.pointerIndex+=u.length,this.cachedPointerNode=void 0,this.invalidateChunk(),this.validateState()}}},{key:"validateState",value:function(){if(this.debug){var e=function(t){if("chunk"===t.type){var n=t.parent,r=t.children;if(!n.children.includes(t))throw new Error("Debug: Chunk ".concat(t.key.id," has an incorrect parent property"));r.forEach(e)}};if(this.root.children.forEach(e),void 0!==this.cachedPointerNode&&this.cachedPointerNode!==this.getPointerNode())throw new Error("Debug: The cached pointer is incorrect and has not been invalidated");var t=this.getChunkPath(this.pointerChunk);if(!t)throw new Error("Debug: The pointer chunk is not connected to the root");if(!n.Path.equals(this.pointerIndexStack,t))throw new Error("Debug: The cached index stack [".concat(this.pointerIndexStack.join(", "),"] does not match the path of the pointer chunk [").concat(t.join(", "),"]"))}}}])}(),ho=function(){return uo((function e(t,n){lo(this,e),h(this,"editor",void 0),h(this,"children",void 0),h(this,"cachedKeys",void 0),h(this,"pointerIndex",void 0),this.editor=t,this.children=n,this.cachedKeys=new Array(n.length),this.pointerIndex=0}),[{key:"read",value:function(e){if(1===e)return[this.children[this.pointerIndex++]];var t=this.remaining(e);return this.pointerIndex+=e,t}},{key:"remaining",value:function(e){return void 0===e?this.children.slice(this.pointerIndex):this.children.slice(this.pointerIndex,this.pointerIndex+e)}},{key:"reachedEnd",get:function(){return this.pointerIndex>=this.children.length}},{key:"lookAhead",value:function(e,t){var n=this.children.indexOf(e,this.pointerIndex);if(n>-1)return n-this.pointerIndex;for(var r=this.pointerIndex;r<this.children.length;r++){var o=this.children[r];if(this.findKey(o,r)===t)return r-this.pointerIndex}return-1}},{key:"toChunkLeaves",value:function(e,t){var n=this;return e.map((function(e,r){return{type:"leaf",node:e,key:n.findKey(e,t+r),index:t+r}}))}},{key:"findKey",value:function(e,t){var n=this.cachedKeys[t];if(n)return n;var r=Sn.findKey(this.editor,e);return this.cachedKeys[t]=r,r}}])}(),po=function(e,t){for(var n,r=t.chunkTree,o=t.children,i=t.chunkSize,a=t.rerenderChildren,s=void 0===a?[]:a,l=t.onInsert,c=t.onUpdate,u=t.onIndexChange,d=t.debug,f=new fo(r,{chunkSize:i,debug:d}),h=new ho(e,o),p=function(){var e=h.lookAhead(n.node,n.key),t=e>0&&r.movedNodeKeys.has(n.key);if(-1===e||t)return f.remove(),1;var o=h.pointerIndex,i=h.read(e+1),a=i.pop();if(i.length){var d=h.toChunkLeaves(i,o);f.insertBefore(d),i.forEach((function(e,t){null==l||l(e,o+t)}))}var p=h.pointerIndex-1;n.node!==a&&(n.node=a,f.invalidateChunk(),null==c||c(a,p)),n.index!==p&&(n.index=p,null==u||u(a,p)),s.includes(p)&&f.invalidateChunk()};n=f.readLeaf();)p();if(!h.reachedEnd){var v=h.remaining(),g=h.toChunkLeaves(v,h.pointerIndex);f.returnToPreviousLeaf(),f.insertAfter(g),v.forEach((function(e,t){null==l||l(e,h.pointerIndex+t)}))}r.movedNodeKeys.clear()};function vo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function go(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vo(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var mo=new WeakMap,yo=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=Sn.findKey(e,t),o=mo.get(r);return o||(o={type:"root",movedNodeKeys:new Set,modifiedChunks:new Set,children:[]},mo.set(r,o)),n.reconcile&&po(e,go({chunkTree:o,children:t.children},n.reconcile)),o};function bo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var wo=function(e){return e.children},Eo=function(e){var n=e.root,r=e.ancestor,o=e.renderElement,i=e.renderChunk,a=void 0===i?wo:i;return r.children.map((function(e){if("chunk"===e.type){var i=e.key.id,s=a({highest:r===n,lowest:e.children.some((function(e){return"leaf"===e.type})),attributes:{"data-slate-chunk":!0},children:t.createElement(Oo,{root:n,ancestor:e,renderElement:o,renderChunk:a})});return t.createElement(t.Fragment,{key:i},s)}var l=e.node;return o(l,e.index,e.key)}))},xo=function(e){return t.useEffect((function(){e.root.modifiedChunks.clear()})),t.createElement(Eo,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?bo(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},e))},Oo=t.memo(Eo,(function(e,t){return e.root===t.root&&e.renderElement===t.renderElement&&e.renderChunk===t.renderChunk&&!t.root.modifiedChunks.has(t.ancestor)})),ko=t.createContext(null),Co=function(){return t.useContext(ko)},So=function(e){var r=e.decorations,o=e.node,i=e.renderElement,a=e.renderChunk,s=e.renderPlaceholder,l=e.renderText,c=e.renderLeaf,u=ue();Ye.set(u,!1);var d=n.Node.isElement(o)&&!u.isInline(o)&&n.Editor.hasInlines(u,o)?null:u.getChunkSize(o),f=!!d,h=To(u,o,r),p=h.decorationsByChild,v=h.childrenToRedecorate;f||o.children.forEach((function(e,t){Je.set(e,t),Ze.set(e,o)}));var g=t.useCallback((function(e,n,r){var o=null!=r?r:Sn.findKey(u,e);return t.createElement(ko.Provider,{key:"provider-".concat(o.id),value:e},t.createElement(io,{decorations:p[n],element:e,key:o.id,renderElement:i,renderChunk:a,renderPlaceholder:s,renderLeaf:c,renderText:l}))}),[u,p,i,a,s,c,l]);if(!f)return o.children.map((function(e,r){return n.Node.isText(e)?function(e,n){var r=Sn.findKey(u,e);return t.createElement(Gr,{decorations:p[n],key:r.id,isLast:n===o.children.length-1,parent:o,renderPlaceholder:s,renderLeaf:c,renderText:l,text:e})}(e,r):g(e,r)}));var m=yo(u,o,{reconcile:{chunkSize:d,rerenderChildren:v,onInsert:function(e,t){Je.set(e,t),Ze.set(e,o)},onUpdate:function(e,t){Je.set(e,t),Ze.set(e,o)},onIndexChange:function(e,t){Je.set(e,t)}}});return t.createElement(xo,{root:m,ancestor:m,renderElement:g,renderChunk:a})},To=function(e,r,o){var i=((e,t,r)=>{const o=Array.from(t.children,(()=>[]));if(0===r.length)return o;const i=xt.findPath(e,t),a=i.length,s=n.Editor.range(e,i),l=new Array(t.children.length),c=t=>{const r=l[t];if(r)return r;const o=n.Editor.range(e,[...i,t]);return l[t]=o,o};for(const e of r){const t=n.Range.intersection(s,e);if(!t)continue;const[r,i]=n.Range.edges(t),l=r.path[a],u=i.path[a];for(let t=l;t<=u;t++){const r=o[t];if(!r)continue;const i=c(t),a=n.Range.intersection(i,e);a&&r.push(fn(fn({},e),a))}}return o})(e,r,o),a=t.useRef(i).current,s=[];a.length=i.length;for(var l=0;l<i.length;l++){var c,u=i[l],d=null!==(c=a[l])&&void 0!==c?c:null;pn(d,u)||(a[l]=u,s.push(l))}return{decorationsByChild:a,childrenToRedecorate:s}},Po=t.createContext(!1),Do=function(){return t.useContext(Po)},Ro=t.createContext({}),No=function(e,t){return e===t};function Mo(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:No,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.deferred,i=t.useContext(Ro);if(!i)throw new Error("The `useSlateSelector` hook must be used inside the <Slate> component's context.");var a=i.addEventListener,s=ue(),l=t.useCallback((function(){return e(s)}),[s,e]),c=Ur(l,n),u=w(c,2),d=u[0],f=u[1];return Nn((function(){var e=a(f,{deferred:o});return f(),e}),[a,f,o]),d}var jo=function(){var e=t.useContext(Ro).addEventListener,n=t.useReducer((function(e){return e+1}),0),r=w(n,2)[1];if(!e)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");return Nn((function(){return e(r)}),[e]),ue()},Bo=new WeakMap;var Ao=function(e){return be(e)&&e.hasAttribute("data-slate-placeholder")},_o=function(e,t){var n=[],r=function(){n=[]};return{registerMutations:function(r){var o;if(t.current){var i=r.filter((function(t){return o=(n=t).addedNodes,i=n.removedNodes,!((a=[].concat(zr(Array.from(o)),zr(Array.from(i)))).length>0&&a.every(Ao))&&Pe(e,t,r);var n,o,i,a}));(o=n).push.apply(o,zr(i))}},restoreDOM:function(){n.length>0&&(n.reverse().forEach((function(e){"characterData"!==e.type&&(e.removedNodes.forEach((function(t){e.target.insertBefore(t,e.nextSibling)})),e.addedNodes.forEach((function(t){e.target.removeChild(t)})))})),r())},clear:r}},Fo=function(e){var t=e.target;if("characterData"===e.type)t.nodeValue=e.oldValue;else if("attributes"===e.type&&be(t)){var n=e.attributeName;null===e.oldValue?t.removeAttribute(n):t.setAttribute(n,e.oldValue)}else e.addedNodes.forEach((function(e){var t;return null===(t=e.parentNode)||void 0===t?void 0:t.removeChild(e)})),e.removedNodes.forEach((function(n){return t.insertBefore(n,e.nextSibling)}))},Io=function(e,t){var n=Sn.resolveDOMRange(e,{anchor:t,focus:t});if(!n)return null;var r=Array.from(n.getClientRects()),o=w(r,1)[0];return(null!=o?o:n.getBoundingClientRect()).top},Lo=function(e,t,r){var o=n.Editor.above(e,{at:t,match:function(t){return n.Node.isElement(t)&&e.isInline(t)}});if(!o||e.isVoid(o[0])||e.isElementReadOnly(o[0])||!(r?n.Editor.isStart(e,t,o[1]):n.Editor.isEnd(e,t,o[1])))return"character";if(r&&!n.Path.hasPrevious(o[1]))return"character";var i=r?n.Path.previous(o[1]):n.Path.next(o[1]);if(!n.Editor.hasPath(e,i))return"character";var a=n.Node.get(e,i);return n.Node.isText(a)&&""===a.text?"offset":"character"},Wo=function(e,t){var r=e.selection;if(r&&n.Range.isCollapsed(r)){var o=Te(Sn.findDocumentOrShadowRoot(e)),i=null==o?void 0:o.anchorNode;if(o&&function(e){return we(e)&&e.nodeType===e.TEXT_NODE}(i)){var a=o.anchorOffset,s=a-t.length;if(!(s<0||i.data.slice(s,a)!==t)&&Sn.hasDOMNode(e,i,{editable:!0})){var l=Sn.findPath(e,Sn.toSlateNode(e,i));n.Path.equals(l,r.anchor.path)&&!n.Editor.void(e,{at:r})||i.deleteData(s,t.length)}}}};function zo(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Uo(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Uo(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function Uo(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var qo=function(e,t){var r;return null===(r=n.Editor.above(e,{at:t,match:function(t){return n.Node.isElement(t)&&n.Editor.isBlock(e,t)}}))||void 0===r?void 0:r[1]},Vo=function(e,t){var r=n.Range.edges(t),o=w(r,2),i=o[0],a=o[1],s=qo(e,i),l=qo(e,a);return s&&l&&1===s.length&&1===l.length&&!(s[0]>=l[0])&&n.Editor.isStart(e,i,s)&&n.Editor.isStart(e,a,l)?Array.from({length:l[0]-s[0]},(function(e,t){return[s[0]+t]})):null},Ko=function(e,t){if(n.Range.isCollapsed(t)){var r=n.Editor.void(e,{at:t});r&&n.Transforms.removeNodes(e,{at:r[1],voids:!0})}else{var o=Vo(e,t);if(!o)return n.Transforms.select(e,t),void n.Editor.deleteFragment(e);var i=n.Editor.pathRef(e,n.Path.next(o[o.length-1]));n.Editor.withoutNormalizing(e,(function(){var t,r=zo(zr(o).reverse());try{for(r.s();!(t=r.n()).done;){var i=t.value;n.Transforms.removeNodes(e,{at:i})}}catch(e){r.e(e)}finally{r.f()}}));var a=i.unref();a&&n.Transforms.select(e,n.Editor.start(e,a))}},Ho=i((function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}));o(Ho);var $o=i((function(e){var t=c.default;e.exports=function(e,n){if(n&&("object"==t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return Ho(e)},e.exports.__esModule=!0,e.exports.default=e.exports})),Xo=o($o),Go=i((function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})),Yo=o(Go),Jo=i((function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}));o(Jo);var Zo=i((function(e){e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Jo(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports})),Qo=o(Zo);function ei(e,t,n){return t=Yo(t),Xo(e,ti()?Reflect.construct(t,n||[],Yo(e).constructor):t.apply(e,n))}function ti(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(ti=function(){return!!e})()}var ni={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0},ri=function(e){function t(){var e;lo(this,t);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e=ei(this,t,[].concat(r)),h(e,"context",null),h(e,"manager",null),h(e,"mutationObserver",null),e}return Qo(t,e),uo(t,[{key:"observe",value:function(){var e,t=this.props.node;if(!t.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");null===(e=this.mutationObserver)||void 0===e||e.observe(t.current,ni)}},{key:"componentDidMount",value:function(){var e=this.props.receivedUserInput,t=this.context;this.manager=_o(t,e),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}},{key:"getSnapshotBeforeUpdate",value:function(){var e,t,n,r,o=null===(e=this.mutationObserver)||void 0===e?void 0:e.takeRecords();null!=o&&o.length&&(null===(r=this.manager)||void 0===r||r.registerMutations(o));return null===(t=this.mutationObserver)||void 0===t||t.disconnect(),null===(n=this.manager)||void 0===n||n.restoreDOM(),null}},{key:"componentDidUpdate",value:function(){var e;null===(e=this.manager)||void 0===e||e.clear(),this.observe()}},{key:"componentWillUnmount",value:function(){var e;null===(e=this.mutationObserver)||void 0===e||e.disconnect()}},{key:"render",value:function(){return this.props.children}}])}(t.Component);h(ri,"contextType",ce);var oi=_e?ri:function(e){var n=e.children;return t.createElement(t.Fragment,null,n)},ii=new WeakMap,ai=t.createContext(!1),si=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderChunk","renderLeaf","renderText","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],li=["text"];function ci(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return ui(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ui(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function ui(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function di(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?di(Object(n),!0).forEach((function(t){h(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):di(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var hi=function(e){return we(e)&&3===e.nodeType},pi=function(e){return t.createElement(t.Fragment,null,So(e))},vi=t.forwardRef((function(e,r){var o=t.useCallback((function(e){return t.createElement(wi,fi({},e))}),[]),i=e.autoFocus,a=e.decorate,s=void 0===a?Ei:a,c=e.onDOMBeforeInput,u=e.placeholder,d=e.readOnly,f=void 0!==d&&d,p=e.renderElement,v=e.renderChunk,g=e.renderLeaf,m=e.renderText,y=e.renderPlaceholder,b=void 0===y?o:y,x=e.scrollSelectionIntoView,O=void 0===x?xi:x,k=e.style,C=void 0===k?{}:k,S=e.as,T=void 0===S?"div":S,P=e.disableDefaultStyles,D=void 0!==P&&P,R=l(e,si),N=jo(),M=t.useState(!1),j=w(M,2),B=j[0],A=j[1];Nn((function(){return ii.set(N,B),function(){ii.delete(N)}}),[N,B]);var _=t.useRef(null),F=t.useRef(N.children),I=t.useRef(N.selection),L=t.useRef(!1),W=t.useRef(!1),z=t.useRef([]),U=t.useRef(null),q=t.useState(),V=w(q,2),K=V[0],H=V[1],$=t.useRef(!1),X=function(e){var n=t.useMemo((function(){var t=_o(e,{current:!0}),n=null,r=function(){null!=n||(n=new MutationObserver(t.registerMutations)),n.observe(Sn.toDOMNode(e,e),{childList:!0,subtree:!0})},o=function(){n&&(t.registerMutations(n.takeRecords()),n.disconnect())};return{observe:r,track:function(e){(n||null!=e&&e.includes("\n"))&&r()},pause:o,restore:function(){o(),t.restoreDOM()},clear:function(){var e;null===(e=n)||void 0===e||e.disconnect(),n=null,t.clear()}}}),[e]);return t.useEffect((function(){return function(){return n.clear()}}),[n]),n}(N),G=function(e){var n=t.useMemo((function(){var t=[],n=null,r=function(e){var n;0===t.length&&setTimeout((function(){t=[]})),(n=t).push.apply(n,zr(e))};return{observe:function(){null!=n||(n=new MutationObserver(r)),n.observe(Sn.toDOMNode(e,e),{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},disconnect:function(){var e;null===(e=n)||void 0===e||e.disconnect(),t=[]},revert:function(){var e,r,o=[].concat(zr(t),zr(null!==(e=null===(r=n)||void 0===r?void 0:r.takeRecords())&&void 0!==e?e:[]));t=[],o.reverse().forEach(Fo)}}}),[e]);return t.useEffect((function(){return n.observe(),n.disconnect}),[n]),n}(N),Y=t.useRef(!1),J=function(){var e=ue(),n=t.useRef(!1),r=t.useRef(0),o=t.useCallback((function(){if(!n.current){n.current=!0;var t=Sn.getWindow(e);t.cancelAnimationFrame(r.current),r.current=t.requestAnimationFrame((function(){n.current=!1}))}}),[e]);return t.useEffect((function(){return function(){return cancelAnimationFrame(r.current)}}),[]),{receivedUserInput:n,onUserInput:o}}(),Z=J.onUserInput,Q=J.receivedUserInput,ne=t.useReducer((function(e){return e+1}),0),re=w(ne,2)[1];mt.set(N,re),at.set(N,f);var oe=t.useMemo((function(){return{isBlurring:!1,isDraggingInternally:!1,isTabbing:!1,pendingSelection:null,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}}),[]);t.useEffect((function(){_.current&&i&&(N.children.length>0?Sn.focus(N):_.current.focus())}),[i,N]);var ie=t.useRef(void 0),ae=t.useMemo((function(){return te((function(){if(Ye.get(N))ae();else{oe.pendingSelection=null;var e=Sn.toDOMNode(N,N).getRootNode();if(!$.current&&Ie&&e instanceof ShadowRoot){$.current=!0;var t=(()=>{let e=document.activeElement;for(;null!==(t=e)&&void 0!==t&&t.shadowRoot&&null!==(n=e.shadowRoot)&&void 0!==n&&n.activeElement;){var t,n,r;e=null===(r=e)||void 0===r||null===(r=r.shadowRoot)||void 0===r?void 0:r.activeElement}return e})();return t?document.execCommand("indent"):n.Transforms.deselect(N),void($.current=!1)}var r=ie.current;if((_e||!Sn.isComposing(N))&&(!oe.isUpdatingSelection||null!=r&&r.isFlushing())&&!oe.isDraggingInternally){var o=Sn.findDocumentOrShadowRoot(N),i=o.activeElement,a=Sn.toDOMNode(N,N),s=Te(o);if(i===a?(oe.latestElement=i,st.set(N,!0)):st.delete(N),!s)return n.Transforms.deselect(N);var l=s.anchorNode,c=s.focusNode,u=Sn.hasEditableTarget(N,l)||Sn.isTargetInsideNonReadonlyVoid(N,l),d=Sn.hasTarget(N,c),h=we(i)&&a.contains(i);if(u&&d&&(f||h||oe.isBlurring)){var p=Sn.toSlateRange(N,s,{exactMatch:!1,suppressThrow:!0});if(p)if(Sn.isComposing(N)||null!=r&&r.hasPendingChanges()||null!=r&&r.isFlushing())null==r||r.handleUserSelect(p);else s.isCollapsed&&!mi(l)&&N.selection&&n.Range.equals(p,N.selection)?yi(N,s,oe):n.Transforms.select(N,p)}!f||u&&d||n.Transforms.deselect(N)}}}),100)}),[N,f,oe]),se=t.useMemo((function(){return ee(ae,0)}),[ae]),le=t.useCallback((function(){var e=Sn.toDOMNode(N,N).getRootNode();se.flush(),Ie&&e instanceof ShadowRoot||ae(),ae.flush()}),[N,ae,se]);ie.current=_n({node:_,onDOMSelectionChange:ae,scheduleOnDOMSelectionChange:se}),Nn((function(){var e,t,r;_.current&&(r=ye(_.current))?(Qe.set(N,r),et.set(N,_.current),rt.set(N,_.current),nt.set(_.current,N)):rt.delete(N);var o=N.selection,i=L.current;L.current=!1;var a=W.current;W.current=!1;var s=(i&&F.current!==N.children||a)&&!!o&&(!I.current||!n.Range.equals(I.current,o));F.current=N.children,I.current=o;var l=Sn.findDocumentOrShadowRoot(N),c=Te(l);if(c&&Sn.isFocused(N)&&(null===(e=ie.current)||void 0===e||!e.hasPendingAction())){var u=function(e){var t="None"!==c.type;if(o||t){var r,i=c.focusNode;if(Fe&&c.rangeCount>1){var a=c.getRangeAt(0),l=c.getRangeAt(c.rangeCount-1);r=a.startContainer===i?l.endContainer:a.startContainer}else r=c.anchorNode;var u=et.get(N),d=!1;if(Ne(u,r)&&Ne(u,i)&&(d=!0),t&&d&&o&&!e){var f,h=Sn.toSlateRange(N,c,{exactMatch:!0,suppressThrow:!0});if(h&&n.Range.equals(h,o)&&(!oe.hasMarkPlaceholder||null!==(f=r)&&void 0!==f&&null!==(f=f.parentElement)&&void 0!==f&&f.hasAttribute("data-slate-mark-placeholder")))return void(s&&O(N,c.getRangeAt(0)))}if(!o||Sn.hasRange(N,o)){var p=oe.pendingSelection;if(oe.pendingSelection=null,!p||e||p.basedOn!==o||o&&n.Range.equals(p.range,o)){oe.isUpdatingSelection=!0;var v=o&&Sn.resolveDOMRange(N,o);return v?(Sn.isComposing(N)&&!_e?c.rangeCount>0&&c.collapseToEnd():n.Range.isBackward(o)?c.setBaseAndExtent(v.endContainer,v.endOffset,v.startContainer,v.startOffset):c.setBaseAndExtent(v.startContainer,v.startOffset,v.endContainer,v.endOffset),O(N,v)):c.removeAllRanges(),v}n.Transforms.select(N,p.range)}else N.selection=Sn.toSlateRange(N,c,{exactMatch:!1,suppressThrow:!0})}};c.rangeCount<=1&&u();var d="action"===(null===(t=ie.current)||void 0===t?void 0:t.isFlushing());if(_e&&d){var f=null,h=requestAnimationFrame((function(){if(d){var e=function(e){var t=et.get(N);t&&(t.focus(),u(e))};e(),f=setTimeout((function(){e(!0),oe.isUpdatingSelection=!1}))}}));return function(){cancelAnimationFrame(h),f&&clearTimeout(f)}}setTimeout((function(){oe.isUpdatingSelection=!1}))}}));var ce=t.useCallback((function(e){if(f)Ci(e,c);else if(Sn.hasEditableTarget(N,e.target)){Si(N,e);var t=Sn.toDOMNode(N,N).getRootNode();if(null!=$&&$.current&&Ie&&t instanceof ShadowRoot){var r=e.getTargetRanges()[0],o=new window.Range;o.setStart(r.startContainer,r.startOffset),o.setEnd(r.endContainer,r.endOffset);var i=Sn.toSlateRange(N,o,{exactMatch:!1,suppressThrow:!0});return i&&n.Transforms.select(N,i),e.preventDefault(),void e.stopImmediatePropagation()}if(Z(),L.current=!0,!Ci(e,c)){var a;if(ie.current)return ie.current.handleDOMBeforeInput(e);le();var s=N.selection,l=e.inputType,u=e.dataTransfer||e.data||void 0,d="insertCompositionText"===l||"deleteCompositionText"===l;if(d&&Sn.isComposing(N))return void((We||Y.current)&&X.track(e.data));var h=!1,p=null;if("insertText"===l&&s&&n.Range.isCollapsed(s)&&e.data&&1===e.data.length&&/[a-z ]/i.test(e.data)&&0!==s.anchor.offset){h=!0,(N.marks||"function"==typeof n.Editor.insertionPoint&&!n.Point.equals(n.Editor.insertionPoint(N,s.anchor),s.anchor))&&(h=!1);var v=Te(Sn.findDocumentOrShadowRoot(N)),g=null==v?void 0:v.anchorNode;if(mi(g)||(h=!1),!Ye.get(N)){var m=s.anchor,y=Sn.resolveDOMPoint(N,m);if(y){var b,E,x=w(y,2),O=x[0],k=x[1],C=null===(b=O.parentElement)||void 0===b?void 0:b.closest("a"),S=Sn.getWindow(N);if(h&&C&&Sn.hasDOMNode(N,C)){var T,P=null==S?void 0:S.document.createTreeWalker(C,NodeFilter.SHOW_TEXT).lastChild();P===O&&(null===(T=P.textContent)||void 0===T?void 0:T.length)===k&&(h=!1)}if(h&&O.parentElement&&"pre"===(null==S||null===(E=S.getComputedStyle(O.parentElement))||void 0===E?void 0:E.whiteSpace)){var D=n.Editor.above(N,{at:m.path,match:function(e){return n.Node.isElement(e)&&n.Editor.isBlock(N,e)}});D&&n.Node.string(D[0]).includes("\t")&&(h=!1)}h&&hi(O)&&(p=null!=v&&v.isCollapsed&&hi(g)?[g,v.anchorOffset]:[O,k])}else h=!1}}if((!l.startsWith("delete")||l.startsWith("deleteBy"))&&!Ye.get(N)){var R=e.getTargetRanges(),M=w(R,1)[0];if(M){var j=Sn.toSlateRange(N,M,{exactMatch:!1,suppressThrow:!0});if(j){if(!s||!n.Range.equals(s,j)){h=!1;var B=!d&&N.selection&&!function(e,t,r){if(!n.Range.isCollapsed(t)||!n.Range.isCollapsed(r))return!1;var o=n.Path.isBefore(t.anchor.path,r.anchor.path)?[t.anchor,r.anchor]:[r.anchor,t.anchor],i=w(o,2),a=i[0],s=i[1];if(0!==s.offset||!n.Path.equals(n.Path.next(a.path),s.path))return!1;var l=n.Node.get(e,a.path);return n.Node.isText(l)&&a.offset===l.text.length}(N,N.selection,j)&&n.Editor.rangeRef(N,N.selection);n.Transforms.select(N,j),B&&ct.set(N,B)}}else h=!1;h&&hi(M.startContainer)&&(p=[M.startContainer,M.startOffset])}}if(d)return;if(h||(U.current=null,e.preventDefault()),s&&n.Range.isExpanded(s)&&l.startsWith("delete")){var _=l.endsWith("Backward")?"backward":"forward";return void n.Editor.deleteFragment(N,{direction:_})}switch(l){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":n.Editor.deleteFragment(N);break;case"deleteContent":case"deleteContentForward":n.Editor.deleteForward(N);break;case"deleteContentBackward":n.Editor.deleteBackward(N);break;case"deleteEntireSoftLine":n.Editor.deleteBackward(N,{unit:"line"}),n.Editor.deleteForward(N,{unit:"line"});break;case"deleteHardLineBackward":n.Editor.deleteBackward(N,{unit:"block"});break;case"deleteSoftLineBackward":n.Editor.deleteBackward(N,{unit:"line"});break;case"deleteHardLineForward":n.Editor.deleteForward(N,{unit:"block"});break;case"deleteSoftLineForward":n.Editor.deleteForward(N,{unit:"line"});break;case"deleteWordBackward":n.Editor.deleteBackward(N,{unit:"word"});break;case"deleteWordForward":n.Editor.deleteForward(N,{unit:"word"});break;case"insertLineBreak":n.Editor.insertSoftBreak(N);break;case"insertParagraph":n.Editor.insertBreak(N);break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":if("insertFromComposition"===l&&Sn.isComposing(N)&&(A(!1),lt.set(N,!1)),"DataTransfer"===(null==u?void 0:u.constructor.name))Sn.insertData(N,u);else if("string"==typeof u)if(h){if(U.current=null,p&&s){var F=n.Editor.leaf(N,s.anchor),I=w(F,1)[0],W=w(p,2),q=W[0],V=W[1];U.current={point:s.anchor,text:I.text,domNode:q,domOffset:V,domText:q.data,char:u}}z.current.push((function(){return n.Editor.insertText(N,u)}))}else n.Editor.insertText(N,u)}var K=null===(a=ct.get(N))||void 0===a?void 0:a.unref();ct.delete(N),!K||N.selection&&n.Range.equals(N.selection,K)||n.Transforms.select(N,K)}}}),[N,Z,c,X,le,f]),de=t.useCallback((function(e){null==e?(ae.cancel(),se.cancel(),et.delete(N),rt.delete(N),_.current&&$e&&_.current.removeEventListener("beforeinput",ce)):$e&&e.addEventListener("beforeinput",ce),_.current=e,"function"==typeof r?r(e):r&&(r.current=e)}),[ae,se,N,ce,r]);Nn((function(){var e=Sn.getWindow(N),t=function(e){var t=e.target,n=t instanceof HTMLElement?t:null,r=null==n?void 0:n.tagName;"INPUT"!==r&&"TEXTAREA"!==r&&(oe.pendingSelection=function(){var e=ie.current;if(oe.isUpdatingSelection||oe.isDraggingInternally||Sn.isComposing(N)||null!=e&&e.hasPendingChanges()||null!=e&&e.isFlushing()||Ye.get(N))return null;var t=Te(Sn.findDocumentOrShadowRoot(N));if(!t||!Sn.hasEditableTarget(N,t.anchorNode)&&!Sn.isTargetInsideNonReadonlyVoid(N,t.anchorNode)||!Sn.hasTarget(N,t.focusNode))return null;var n=Sn.toSlateRange(N,t,{exactMatch:!1,suppressThrow:!0});return n?{range:n,basedOn:N.selection}:null}(),se())};e.document.addEventListener("selectionchange",t);var n=function(e){oe.isTabbing="Tab"===e.key},r=function(){oe.isTabbing=!1};e.document.addEventListener("keydown",n,!0),e.document.addEventListener("keyup",r,!0),e.document.addEventListener("pointerdown",r,!0);var o=function(){oe.isDraggingInternally=!1};return e.document.addEventListener("dragend",o),e.document.addEventListener("drop",o),function(){e.document.removeEventListener("selectionchange",t),e.document.removeEventListener("keydown",n,!0),e.document.removeEventListener("keyup",r,!0),e.document.removeEventListener("pointerdown",r,!0),e.document.removeEventListener("dragend",o),e.document.removeEventListener("drop",o)}}),[N,se,oe]);var fe=s([N,[]]),he=function(e){var n=t.useReducer((function(e){return e+1}),0),r=w(n,2)[1],o=t.useRef(new Set),i=t.useRef(!1),a=t.useRef(e);Nn((function(){a.current=e,o.current.forEach((function(e){return e()})),i.current?r():i.current=!0}),[e]);var s=t.useCallback((function(e){return a.current(e)}),[]),l=t.useCallback((function(e){return o.current.add(e),function(){o.current.delete(e)}}),[]);return t.useMemo((function(){return{decorate:s,addEventListener:l}}),[s,l])}(s),pe=u&&1===N.children.length&&1===Array.from(n.Node.texts(N)).length&&""===n.Node.string(N)&&!B,ve=t.useCallback((function(e){var t;e&&pe?H(null===(t=e.getBoundingClientRect())||void 0===t?void 0:t.height):H(void 0)}),[pe]);if(pe){var ge=n.Editor.start(N,[]);fe.push(h(h(h(h(h({},yt,!0),"placeholder",u),"onPlaceholderResize",ve),"anchor",ge),"focus",ge))}var me,Ee=N.marks;if(oe.hasMarkPlaceholder=!1,N.selection&&n.Range.isCollapsed(N.selection)&&Ee){var xe=N.selection.anchor,Oe=n.Node.leaf(N,xe.path);Oe.text;var ke=l(Oe,li);if(!n.Text.equals(Oe,Ee,{loose:!0})){oe.hasMarkPlaceholder=!0;var Ce=Object.fromEntries(Object.keys(ke).map((function(e){return[e,null]})));fe.push(fi(fi(fi(h({},bt,!0),Ce),Ee),{},{anchor:xe,focus:xe}))}}return t.useEffect((function(){setTimeout((function(){var e=N.selection;if(e){var t=e.anchor,r=n.Node.leaf(N,t.path);if(Ee&&!n.Text.equals(r,Ee,{loose:!0}))return void ft.set(N,Ee)}ft.delete(N)}))})),me=t.useContext(Ro).flushDeferred,Nn(me),t.createElement(Po.Provider,{value:f},t.createElement(ai.Provider,{value:B},t.createElement(qr.Provider,{value:he},t.createElement(oi,{node:_,receivedUserInput:Q},t.createElement(T,fi(fi({role:f?void 0:"textbox","aria-multiline":!f||void 0,"aria-placeholder":pe?u:void 0,translate:"no"},R),{},{spellCheck:!(!$e&&He)&&R.spellCheck,autoCorrect:$e||!He?R.autoCorrect:"false",autoCapitalize:$e||!He?R.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!f,zindex:-1,suppressContentEditableWarning:!0,ref:de,style:fi(fi({},D?{}:fi({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},K?{minHeight:K}:{})),C),onBeforeInput:t.useCallback((function(e){if(f)Oi(e,R.onBeforeInput);else if(!$e&&!Oi(e,R.onBeforeInput)&&Sn.hasSelectableTarget(N,e.target)&&(e.preventDefault(),!Sn.isComposing(N))){var t=e.data;n.Editor.insertText(N,t)}}),[R.onBeforeInput,N,f]),onInput:t.useCallback((function(e){var t;if(f)Oi(e,R.onInput);else if(Sn.hasEditableTarget(N,e.target)&&(X.pause(),!Oi(e,R.onInput)))if(ie.current)ie.current.handleInput();else{if(null!==(t=e.nativeEvent.inputType)&&void 0!==t&&t.startsWith("format")){var r=Te(Sn.findDocumentOrShadowRoot(N)),o=r&&Sn.resolveSlateRange(N,r);return G.revert(),void(r&&o&&(n.Transforms.select(N,o),yi(N,r,oe)))}var i,a=ci(z.current);try{for(a.s();!(i=a.n()).done;){(0,i.value)()}}catch(e){a.e(e)}finally{a.f()}z.current=[];var s=U.current;if(U.current=null,s){var l,c=s.point,u=s.text,d=s.domNode,h=s.domOffset,p=s.domText,v=s.char,g=n.Node.getIf(N,c.path);if(n.Text.isText(g)&&g.text===u&&d.isConnected&&d.data===p.slice(0,h)+v+p.slice(h))if(d.deleteData(h,v.length),N.selection&&n.Range.isCollapsed(N.selection)&&n.Point.equals(N.selection.anchor,c))null===(l=Te(Sn.findDocumentOrShadowRoot(N)))||void 0===l||l.collapse(d,h)}Sn.isFocused(N)||Si(N,e.nativeEvent)}}),[f,R.onInput,N,X,G]),onBlur:t.useCallback((function(e){if(f)Oi(e,R.onBlur);else if(!oe.isUpdatingSelection&&Sn.hasSelectableTarget(N,e.target)&&!Oi(e,R.onBlur)){var t=Sn.findDocumentOrShadowRoot(N);if(oe.latestElement!==t.activeElement){var r=e.relatedTarget;if(!(r===Sn.toDOMNode(N,N)||be(r)&&r.hasAttribute("data-slate-spacer"))){if(null!=r&&we(r)&&Sn.hasDOMNode(N,r)){var o=Sn.toSlateNode(N,r);if(n.Node.isElement(o)&&!N.isVoid(o))return}oe.isBlurring=!0;try{le()}finally{oe.isBlurring=!1}if(Ie){var i=Te(t);null==i||i.removeAllRanges()}st.delete(N)}}}}),[f,oe,N,R.onBlur,le]),onClick:t.useCallback((function(e){if(Sn.hasTarget(N,e.target)&&le(),Sn.hasTarget(N,e.target)&&!Oi(e,R.onClick)&&we(e.target)){var t,r=Sn.toSlateNode(N,e.target);try{t=Sn.findPath(N,r)}catch(e){return}if(!n.Editor.hasPath(N,t)||n.Node.get(N,t)!==r)return;if(3===e.detail&&t.length>=1){var o=t;if(!n.Node.isElement(r)||!n.Editor.isBlock(N,r)){var i,a=n.Editor.above(N,{match:function(e){return n.Node.isElement(e)&&n.Editor.isBlock(N,e)},at:t});o=null!==(i=null==a?void 0:a[1])&&void 0!==i?i:t.slice(0,1)}var s=n.Editor.above(N,{at:n.Editor.start(N,o),match:function(e){var t;return n.Node.isElement(e)&&!(null===(t=N.isIsolated)||void 0===t||!t.call(N,e))}});if(o.length>1||s){var l=n.Editor.range(N,o);return void n.Transforms.select(N,l)}}if(f)return;var c=n.Editor.start(N,t),u=n.Editor.end(N,t),d=n.Editor.void(N,{at:c}),h=n.Editor.void(N,{at:u}),p=N.selection&&n.Range.isCollapsed(N.selection)&&n.Editor.void(N,{at:N.selection.anchor});if(e.shiftKey&&p&&!n.Path.isAncestor(p[1],t)&&(!d||!n.Path.equals(d[1],p[1]))){var v=Sn.resolveEventRange(N,e);if(!v)return;var g=n.Editor.start(N,p[1]),m=n.Editor.end(N,p[1]),y=n.Point.isBefore(v.anchor,g)?m:g;return void n.Transforms.select(N,{anchor:y,focus:v.anchor})}if(d&&h&&n.Path.equals(d[1],h[1])){if(e.shiftKey&&N.selection){var b=N.selection.anchor,w=n.Point.isBefore(b,c)?u:c;return void n.Transforms.select(N,{anchor:b,focus:w})}var E=n.Editor.range(N,c);n.Transforms.select(N,E)}}}),[N,R.onClick,f,le]),onCompositionEnd:t.useCallback((function(e){if(f)Oi(e,R.onCompositionEnd);else if(!ki(e)&&Sn.hasSelectableTarget(N,e.target)){var t;Promise.resolve().then((function(){A(!1),lt.set(N,!1)})),null===(t=ie.current)||void 0===t||t.handleCompositionEnd(e);var r=Y.current;if(Y.current=!1,Oi(e,R.onCompositionEnd)||_e)return void X.clear();if(r&&!e.data&&(X.restore(),n.Editor.deleteFragment(N)),!Ie&&!qe&&!Be&&!Ke&&!Ve&&e.data){var o=ft.get(N);ft.delete(N),void 0!==o&&(ht.set(N,N.marks),N.marks=o),X.restore(),Wo(N,e.data),n.Editor.insertText(N,e.data);var i=ht.get(N);ht.delete(N),void 0!==i&&(N.marks=i)}X.clear()}}),[f,R.onCompositionEnd,N,X]),onCompositionUpdate:t.useCallback((function(e){f?Oi(e,R.onCompositionUpdate):!Sn.hasSelectableTarget(N,e.target)||Oi(e,R.onCompositionUpdate)||ki(e)||Sn.isComposing(N)||(A(!0),lt.set(N,!0))}),[f,R.onCompositionUpdate,N]),onCompositionStart:t.useCallback((function(e){if(f)Oi(e,R.onCompositionStart);else if(!ki(e)&&Sn.hasSelectableTarget(N,e.target)){var t;if(null===(t=ie.current)||void 0===t||t.handleCompositionStart(e),Oi(e,R.onCompositionStart)||_e)return;X.clear(),A(!0),le();var r=N.selection;if(r&&n.Range.isExpanded(r))return Fe&&!qe?(X.observe(),void(Y.current=!0)):void n.Editor.deleteFragment(N)}}),[f,R.onCompositionStart,N,X,le]),onCopy:t.useCallback((function(e){!Sn.hasSelectableTarget(N,e.target)||Oi(e,R.onCopy)||ki(e)||(e.preventDefault(),Sn.setFragmentData(N,e.clipboardData,"copy"))}),[R.onCopy,N]),onCut:t.useCallback((function(e){if(f)Oi(e,R.onCut);else if(Sn.hasSelectableTarget(N,e.target)&&!Oi(e,R.onCut)&&!ki(e)){e.preventDefault(),bi(N),Sn.setFragmentData(N,e.clipboardData,"cut");var t=N.selection;if(t)if(n.Range.isExpanded(t))Ko(N,t);else{var r=n.Node.parent(N,t.anchor.path);n.Editor.isVoid(N,r)&&n.Transforms.delete(N)}}}),[f,N,R.onCut]),onDragOver:t.useCallback((function(e){if(f)Oi(e,R.onDragOver);else if(Sn.hasTarget(N,e.target)&&!Oi(e,R.onDragOver)){var t=Sn.toSlateNode(N,e.target);n.Node.isElement(t)&&n.Editor.isVoid(N,t)&&e.preventDefault()}}),[f,R.onDragOver,N]),onDragStart:t.useCallback((function(e){if(f)Oi(e,R.onDragStart);else if(Sn.hasTarget(N,e.target)&&!Oi(e,R.onDragStart)){var t=Sn.toSlateNode(N,e.target),r=Sn.findPath(N,t);if(n.Node.isElement(t)&&n.Editor.isVoid(N,t)||n.Editor.void(N,{at:r,voids:!0})){var o=n.Editor.range(N,r);n.Transforms.select(N,o)}bi(N),oe.isDraggingInternally=!0,Sn.setFragmentData(N,e.dataTransfer,"drag")}}),[f,N,R.onDragStart,oe]),onDrop:t.useCallback((function(e){if(f)Oi(e,R.onDrop);else if(Sn.hasTarget(N,e.target)&&!Oi(e,R.onDrop)){e.preventDefault();var t=N.selection,r=Sn.findEventRange(N,e,{suppressThrow:!0}),o=e.dataTransfer;if(!r&&oe.isDraggingInternally)return;if(r){if(n.Transforms.select(N,r),oe.isDraggingInternally&&t){if(n.Range.includes(t,r.anchor))return;if(!n.Editor.void(N,{at:r,voids:!0})){var i=n.Editor.rangeRef(N,r);Ko(N,t);var a=i.unref();a&&n.Transforms.select(N,a)}}}else!N.selection&&N.children.length>0&&n.Transforms.select(N,n.Editor.end(N,[]));Sn.insertData(N,o),Sn.isFocused(N)||Sn.focus(N)}}),[f,N,R.onDrop,oe]),onDragEnd:t.useCallback((function(e){f?Oi(e,R.onDragEnd):oe.isDraggingInternally&&R.onDragEnd&&Sn.hasTarget(N,e.target)&&R.onDragEnd(e)}),[f,oe,R,N]),onFocus:t.useCallback((function(e){if(f)Oi(e,R.onFocus);else if(!oe.isUpdatingSelection&&Sn.hasEditableTarget(N,e.target)&&!Oi(e,R.onFocus)){var t=Sn.toDOMNode(N,N),n=Sn.findDocumentOrShadowRoot(N);if(oe.latestElement=n.activeElement,Fe&&e.target!==t)return void t.focus();if(st.set(N,!0),oe.isTabbing&&e.target===t){var r=Te(n);r&&N.selection&&(oe.pendingSelection=null,yi(N,r,oe)),oe.isTabbing=!1}}}),[f,oe,N,R.onFocus]),onKeyDown:t.useCallback((function(e){if(f)Oi(e,R.onKeyDown);else if(Sn.hasEditableTarget(N,e.target)){var t;null===(t=ie.current)||void 0===t||t.handleKeyDown(e);var r=e.nativeEvent;if(Sn.isComposing(N)&&(!1===r.isComposing||gi(N,r))&&(lt.set(N,!1),A(!1)),Oi(e,R.onKeyDown)||Sn.isComposing(N))return;W.current=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"].includes(r.key);var o=N.selection,i=N.children[null!==o?o.focus.path[0]:0],a="rtl"===E(n.Node.string(i));if(ln.isRedo(r)){e.preventDefault();var s=N;return void("function"==typeof s.redo&&s.redo())}if(ln.isUndo(r)){e.preventDefault();var l=N;return void("function"==typeof l.undo&&l.undo())}if((We||Ie)&&"ArrowUp"===r.key&&!r.altKey&&!r.ctrlKey&&!r.metaKey&&o&&(r.shiftKey||n.Range.isCollapsed(o))){var c=function(e,t){var r=n.Editor.above(e,{at:t,match:function(t){return n.Node.isElement(t)&&n.Editor.isBlock(e,t)}});if(!r)return null;var o=n.Editor.start(e,r[1]),i=n.Editor.before(e,o);if(!i||!n.Editor.leaf(e,i)[0].text.endsWith("\n"))return null;if(n.Point.equals(t,o))return i;var a=Io(e,t),s=Io(e,o);return null===a||null===s||Math.abs(a-s)>2?null:i}(N,o.focus);if(c)return e.preventDefault(),void n.Transforms.select(N,r.shiftKey?{anchor:o.anchor,focus:c}:c)}if(ln.isMoveLineBackward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line",reverse:!0});if(ln.isMoveLineForward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line"});if(ln.isExtendLineBackward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line",edge:"focus",reverse:!0});if(ln.isExtendLineForward(r))return e.preventDefault(),void n.Transforms.move(N,{unit:"line",edge:"focus"});if(ln.isMoveBackward(r))return e.preventDefault(),void(o&&n.Range.isCollapsed(o)?n.Transforms.move(N,{reverse:!a,unit:Lo(N,o.focus,!a)}):n.Transforms.collapse(N,{edge:a?"end":"start"}));if(ln.isMoveForward(r))return e.preventDefault(),void(o&&n.Range.isCollapsed(o)?n.Transforms.move(N,{reverse:a,unit:Lo(N,o.focus,a)}):n.Transforms.collapse(N,{edge:a?"start":"end"}));var u=ln.isMoveWordBackward(r);if(u||ln.isMoveWordForward(r)){e.preventDefault();var d=Sn.findDocumentOrShadowRoot(N),h=Te(d);if(null!=h&&h.modify){h.modify("move",u?"left":"right","word");var p=Sn.toSlateRange(N,h,{exactMatch:!1,suppressThrow:!0});if(p)return void n.Transforms.select(N,p)}return o&&n.Range.isExpanded(o)&&n.Transforms.collapse(N,{edge:"focus"}),void n.Transforms.move(N,{unit:"word",reverse:u?!a:a})}if($e){if((We||Ie)&&o&&(ln.isDeleteBackward(r)||ln.isDeleteForward(r))&&n.Range.isCollapsed(o)){var v=n.Node.parent(N,o.anchor.path);if(n.Node.isElement(v)&&n.Editor.isVoid(N,v)&&(n.Editor.isInline(N,v)||n.Editor.isBlock(N,v)))return e.preventDefault(),void(ln.isDeleteForward(r)?n.Editor.deleteForward(N,{unit:"block"}):n.Editor.deleteBackward(N,{unit:"block"}))}if(Ie&&o&&n.Range.isCollapsed(o)){if(ln.isDeleteBackward(r)&&n.Editor.isStart(N,o.anchor,[]))return e.preventDefault(),void n.Editor.deleteBackward(N);if(ln.isDeleteForward(r)&&n.Editor.isEnd(N,o.anchor,[]))return e.preventDefault(),void n.Editor.deleteForward(N)}}else{if(ln.isBold(r)||ln.isItalic(r)||ln.isTransposeCharacter(r))return void e.preventDefault();if(ln.isSoftBreak(r))return e.preventDefault(),void n.Editor.insertSoftBreak(N);if(ln.isSplitBlock(r))return e.preventDefault(),void n.Editor.insertBreak(N);if(ln.isDeleteBackward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"backward"}):n.Editor.deleteBackward(N));if(ln.isDeleteForward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"forward"}):n.Editor.deleteForward(N));if(ln.isDeleteLineBackward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"backward"}):n.Editor.deleteBackward(N,{unit:"line"}));if(ln.isDeleteLineForward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"forward"}):n.Editor.deleteForward(N,{unit:"line"}));if(ln.isDeleteWordBackward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"backward"}):n.Editor.deleteBackward(N,{unit:"word"}));if(ln.isDeleteWordForward(r))return e.preventDefault(),void(o&&n.Range.isExpanded(o)?n.Editor.deleteFragment(N,{direction:"forward"}):n.Editor.deleteForward(N,{unit:"word"}))}}}),[f,N,R.onKeyDown]),onPaste:t.useCallback((function(e){f?Oi(e,R.onPaste):Sn.hasEditableTarget(N,e.target)&&!Oi(e,R.onPaste)&&(!$e||(e=>e.clipboardData&&""!==e.clipboardData.getData("text/plain")&&1===e.clipboardData.types.length)(e.nativeEvent)||Ie)&&(e.preventDefault(),Sn.insertData(N,e.clipboardData))}),[f,N,R.onPaste])}),t.createElement(pi,{decorations:fe,node:N,renderElement:p,renderChunk:v,renderPlaceholder:b,renderLeaf:g,renderText:m}))))))})),gi=function(e,t){var r=e.selection;return!!r&&n.Range.isCollapsed(r)&&(ln.isDeleteBackward(t)||ln.isDeleteForward(t))&&!!n.Editor.void(e,{at:r})},mi=function(e){var t;return we(e)&&e.nodeType===e.TEXT_NODE&&!(null===(t=e.parentElement)||void 0===t||!t.closest("[data-slate-string], [data-slate-zero-width]"))},yi=function(e,t,r){if(e.selection){var o=Sn.resolveDOMRange(e,e.selection);if(o){var i=n.Range.isBackward(e.selection);r.isUpdatingSelection=!0,t.setBaseAndExtent(i?o.endContainer:o.startContainer,i?o.endOffset:o.startOffset,i?o.startContainer:o.endContainer,i?o.startOffset:o.endOffset),setTimeout((function(){r.isUpdatingSelection=!1}))}}},bi=function(e){var t=e.selection;if(t&&n.Range.isExpanded(t)){var r=function(e,t){return Vo(e,t)?t:n.Editor.unhangRange(e,t)}(e,t);n.Range.equals(r,t)||n.Transforms.select(e,r)}},wi=function(e){var n=e.attributes,r=e.children;return t.createElement("span",fi({},n),r,_e&&t.createElement("br",null))},Ei=function(){return[]},xi=function(e,t){var r,o=e.selection,i=!!o&&n.Range.isBackward(o),a=o&&!i&&n.Range.isExpanded(o)?n.Editor.unhangRange(e,o):o,s=a&&o&&!n.Range.equals(a,o)&&null!==(r=Sn.resolveDOMRange(e,a))&&void 0!==r?r:t.cloneRange();if(s.collapse(i),s.getBoundingClientRect){var l=s.startContainer.parentElement,c=s.getBoundingClientRect();if(0===c.width&&0===c.height&&0===c.x&&0===c.y){var u=l.getBoundingClientRect();if(u.width>0||u.height>0)return}l.getBoundingClientRect=s.getBoundingClientRect.bind(s),le(l,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}),delete l.getBoundingClientRect}},Oi=function(e,t){if(!t)return!1;var n=t(e);return null!=n?n:e.isDefaultPrevented()||e.isPropagationStopped()},ki=function(e){return we(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)},Ci=function(e,t){if(!t)return!1;var n=t(e);return null!=n?n:e.defaultPrevented},Si=function(e,t){var n=e;"historyUndo"!==t.inputType||"function"!=typeof n.undo?"historyRedo"!==t.inputType||"function"!=typeof n.redo||n.redo():n.undo()},Ti=t.createContext(!1),Pi=parseInt(t.version.split(".")[0],10),Di=["editor","children","onChange","onSelectionChange","onValueChange","initialValue","value"],Ri=function(e,t){return!e&&!t||!(!e||!t)&&n.Range.equals(e,t)},Ni=new Set(["insert_node","move_node","remove_node","set_node"]);e.DefaultElement=ao,e.DefaultLeaf=_r,e.DefaultPlaceholder=wi,e.DefaultText=Yr,e.Editable=vi,e.NODE_TO_INDEX=Je,e.NODE_TO_PARENT=Ze,e.ReactEditor=Sn,e.Slate=function(e){var r=e.editor,o=e.children,i=e.onChange,a=e.onSelectionChange,s=e.onValueChange,c=e.initialValue,u=e.value,d=l(e,Di),f=t.useRef(null),h=t.useRef(void 0),p=t.useRef(void 0),v=t.useRef(void 0);if(void 0!==u&&void 0!==c)throw new Error("[Slate] value and initialValue cannot be used together.");if(void 0!==u&&!n.Node.isNodeList(u))throw new Error("[Slate] value is invalid! Expected a list of elements but got: ".concat(n.Scrubber.stringify(u)));if(f.current!==r){var g;if(!n.Editor.isEditor(r))throw new Error("[Slate] editor is invalid! You passed: ".concat(n.Scrubber.stringify(r)));if(void 0===c&&void 0===u&&0===r.children.length)throw new Error("[Slate] editor.children is empty and no initialValue was provided. If this is intentional, pass initialValue={[]} to the Slate component.");var m=null!==(g=null!=c?c:u)&&void 0!==g?g:r.children;if(!n.Node.isNodeList(m))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(n.Scrubber.stringify(m)));var y=void 0===c&&void 0===u?m:m.map(Ht),b=y.every((function(e,t){return e===m[t]}))?m:y;r.children=b.length>0?b:[{children:[{text:""}]}],Object.assign(r,d),f.current=r,h.current=void 0,p.current=u}var E=function(){var e=t.useRef(new Set),n=t.useRef(new Set),r=t.useCallback((function(){e.current.forEach((function(e){return e()}))}),[]),o=t.useCallback((function(){n.current.forEach((function(e){return e()})),n.current.clear()}),[]),i=t.useCallback((function(t){var r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).deferred,o=void 0!==r&&r?function(){return n.current.add(t)}:t;return e.current.add(o),function(){e.current.delete(o)}}),[]);return{selectorContext:t.useMemo((function(){return{addEventListener:i,flushDeferred:o}}),[i,o]),onChange:r}}(),x=E.selectorContext,O=E.onChange,k=t.useCallback((function(){var e=r.operations.some((function(e){return"set_selection"!==e.type})),t=e&&r.children===v.current;v.current=void 0,e&&!t&&(h.current=r.children),i&&i(r.children),a&&r.operations.find((function(e){return"set_selection"===e.type}))&&a(r.selection),s&&e&&!t&&s(r.children),O()}),[r,O,i,a,s]),C=void 0!==u,S=t.useCallback((function(){var e=function(){return k()};return ut.set(r,e),function(){ut.get(r)===e&&ut.delete(r)}}),[r,k]);t.useEffect((function(){if(!C)return S()}),[C,S]),Nn((function(){if(C)return S()}),[C,S]),Nn((function(){var e,t=function(){var o;if(void 0!==u)if(u!==h.current){if(u!==p.current)if(Sn.isComposing(r)||ii.get(r)||vt.get(r)||null!==(o=pt.get(r))&&void 0!==o&&o.length)e=window.requestAnimationFrame(t);else{var i=r.children;p.current=u,n.Transforms.setChildren(r,u),i!==r.children&&(v.current=r.children,O())}}else p.current=u};return t(),function(){void 0!==e&&window.cancelAnimationFrame(e)}}),[r,u,O]);var T=t.useState(Sn.isFocused(r)),P=w(T,2),D=P[0],R=P[1];return t.useEffect((function(){R(Sn.isFocused(r))}),[r]),Nn((function(){var e=function(){return R(Sn.isFocused(r))};return Pi>=17?(document.addEventListener("focusin",e),document.addEventListener("focusout",e),function(){document.removeEventListener("focusin",e),document.removeEventListener("focusout",e)}):(document.addEventListener("focus",e,!0),document.addEventListener("blur",e,!0),function(){document.removeEventListener("focus",e,!0),document.removeEventListener("blur",e,!0)})}),[r]),t.createElement(Ro.Provider,{value:x},t.createElement(ce.Provider,{value:r},t.createElement(Ti.Provider,{value:D},o)))},e.defaultScrollSelectionIntoView=xi,e.useComposing=function(){return t.useContext(ai)},e.useEditor=function(){var e=t.useContext(ce);if(!e)throw new Error("The `useEditor` hook must be used inside the <Slate> component's context.");return e},e.useElement=function(){var e=t.useContext(ko);if(!e)throw new Error("The `useElement` hook must be used inside `renderElement`.");return e},e.useElementIf=Co,e.useFocused=function(){return t.useContext(Ti)},e.useReadOnly=Do,e.useSelected=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.suppressThrow,o=void 0!==r&&r,i=Co();if(!i)return!1;var a=t.useCallback((function(e){if(!e.selection)return!1;try{var t=Sn.findPath(e,i),r=n.Editor.range(e,t);return!!n.Range.intersection(r,e.selection)}catch(e){if(o)return!1;throw e}}),[i,o]);return Mo(a,void 0,{deferred:!0})},e.useSlate=jo,e.useSlateSelection=function(){return Mo((function(e){return e.selection}),Ri)},e.useSlateSelector=Mo,e.useSlateStatic=ue,e.useSlateWithV=function(){var e=jo(),n=t.useMemo((function(){return function(e){var t=Bo.get(e);if(t)return t;t={current:0},Bo.set(e,t);var n=e.onChange;return e.onChange=function(e){t.current++,n(e)},t}(e)}),[e]);return{editor:e,v:n.current}},e.withReact=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x-slate-fragment",r=e,o=r=Zt(r,t),i=o.onChange,a=o.apply,s=o.insertText;return r.getChunkSize=function(){return null},_e&&(r.insertText=function(e,t){return gt.delete(r),s(e,t)}),r.onChange=function(e){(Pi<18?Cn.unstable_batchedUpdates:function(e){return e()})((function(){i(e)}))},r.apply=function(e){var t;_e&&Ni.has(e.type)&&(null===(t=Dn.get(r))||void 0===t||t());if("move_node"===e.type){var o=n.Node.parent(r,e.path);if(!!r.getChunkSize(o)){var i=n.Node.get(r,e.path),s=yo(r,o),l=Sn.findKey(r,i);s.movedNodeKeys.add(l)}}a(e)},r}}));
|