@yoopta/editor
Version:
<h2 align="center">Yoopta-Editor v1 🎉</h2> <p align="center">Yoopta-Editor - is an open source notion-like editor 💥</p> <div align="center"> <img width="574" alt="Screen Shot 2023-01-25 at 16 04 29" src="https://user-images.githubusercontent.com/2909311
1 lines • 128 kB
JavaScript
import{ReactEditor as e,useSelected as t,withReact as n,Slate as r,Editable as o,DefaultElement as i,useFocused as l}from"slate-react";import{jsx as c,jsxs as s}from"react/jsx-runtime";import a,{useMemo as u,createContext as d,useContext as p,useRef as f,memo as h,useState as y,useEffect as v,useCallback as m,isValidElement as g}from"react";import{Range as b,Transforms as k,Editor as _,Element as w,Text as O,Point as j,Path as E,Node as S,Operation as x,createEditor as P}from"slate";function B(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}"function"==typeof SuppressedError&&SuppressedError;var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function T(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var D,M,I={},N={get exports(){return I},set exports(e){I=e}},$={};D={get exports(){return $},set exports(e){$=e}},M=$,Object.defineProperty(M,"__esModule",{value:!0}),M.default=function(e){if(null==e)throw new TypeError("Expected a string but received a ".concat(e));if("String"!==e.constructor.name)throw new TypeError("Expected a string but received a ".concat(e.constructor.name))},D.exports=M.default,D.exports.default=M.default;var C={};!function(e,t){function n(e){return"[object RegExp]"===Object.prototype.toString.call(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){for(var r=0;r<t.length;r++){var o=t[r];if(e===o||n(o)&&o.test(e))return!0}return!1},e.exports=t.default,e.exports.default=t.default}({get exports(){return C},set exports(e){C=e}},C);var F={};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=function(e,t){return-1!==e.indexOf(t)},e.exports=t.default,e.exports.default=t.default}({get exports(){return F},set exports(e){F=e}},F);var L={},R={get exports(){return L},set exports(e){L=e}},z={};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var n in t)void 0===e[n]&&(e[n]=t[n]);return e},e.exports=t.default,e.exports.default=t.default}({get exports(){return z},set exports(e){z=e}},z),function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){(0,n.default)(e),(t=(0,r.default)(t,i)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));!0===t.allow_wildcard&&0===e.indexOf("*.")&&(e=e.substring(2));var o=e.split("."),l=o[o.length-1];if(t.require_tld){if(o.length<2)return!1;if(!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(l))return!1;if(/\s/.test(l))return!1}if(!t.allow_numeric_tld&&/^\d+$/.test(l))return!1;return o.every(function(e){return!(e.length>63&&!t.ignore_max_length)&&(!!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(e)&&(!/[\uff01-\uff5e]/.test(e)&&(!/^-|-$/.test(e)&&!(!t.allow_underscores&&/_/.test(e)))))})};var n=o($),r=o(z);function o(e){return e&&e.__esModule?e:{default:e}}var i={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};e.exports=t.default,e.exports.default=t.default}(R,L);var V={};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,r.default)(t);var i=("object"===o(n)?n.version:arguments[1])||"";if(!i)return e(t,{version:4})||e(t,{version:6});if("4"===i.toString())return c.test(t);if("6"===i.toString())return a.test(t);return!1};var n,r=(n=$)&&n.__esModule?n:{default:n};function o(e){return o="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},o(e)}var i="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",l="(".concat(i,"[.]){3}").concat(i),c=new RegExp("^".concat(l,"$")),s="(?:[0-9a-fA-F]{1,4})",a=new RegExp("^("+"(?:".concat(s,":){7}(?:").concat(s,"|:)|")+"(?:".concat(s,":){6}(?:").concat(l,"|:").concat(s,"|:)|")+"(?:".concat(s,":){5}(?::").concat(l,"|(:").concat(s,"){1,2}|:)|")+"(?:".concat(s,":){4}(?:(:").concat(s,"){0,1}:").concat(l,"|(:").concat(s,"){1,3}|:)|")+"(?:".concat(s,":){3}(?:(:").concat(s,"){0,2}:").concat(l,"|(:").concat(s,"){1,4}|:)|")+"(?:".concat(s,":){2}(?:(:").concat(s,"){0,3}:").concat(l,"|(:").concat(s,"){1,5}|:)|")+"(?:".concat(s,":){1}(?:(:").concat(s,"){0,4}:").concat(l,"|(:").concat(s,"){1,6}|:)|")+"(?::((?::".concat(s,"){0,5}:").concat(l,"|(?::").concat(s,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");e.exports=t.default,e.exports.default=t.default}({get exports(){return V},set exports(e){V=e}},V),function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if((0,n.default)(e),!e||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;if((t=(0,c.default)(t,u)).validate_length&&e.length>t.max_allowed_length)return!1;if(!t.allow_fragments&&(0,o.default)(e,"#"))return!1;if(!t.allow_query_components&&((0,o.default)(e,"?")||(0,o.default)(e,"&")))return!1;var s,p,f,h,y,v,m,g;m=e.split("#"),e=m.shift(),m=e.split("?");var b=(e=m.shift()).match(/^([a-z][a-z0-9+\-.]*):/i),k=!1,_=function(n){return k=!0,s=n.toLowerCase(),(!t.require_valid_protocol||-1!==t.protocols.indexOf(s))&&e.substring(b[0].length)};if(b){var w=b[1],O=e.substring(b[0].length);if("//"===O.slice(0,2)){if(!1===(e=_(w)))return!1}else{var j=O.indexOf("/"),E=-1===j?O:O.substring(0,j),S=E.indexOf("@");if(-1!==S){var x=E.substring(0,S),P=/^[a-zA-Z0-9\-_.%:]*$/.test(x),B=/%[0-9a-fA-F]{2}/.test(x);if(P&&!B){if(t.require_protocol)return!1}else if(!1===(e=_(w)))return!1}else{if(/^[0-9]/.test(O)){if(t.require_protocol)return!1}else if(!1===(e=_(w)))return!1}}}else if(t.require_protocol)return!1;if("//"===e.slice(0,2)){if(!k&&!t.allow_protocol_relative_urls)return!1;e=e.slice(2)}if(""===e)return!1;if(m=e.split("/"),""===(e=m.shift())&&!t.require_host)return!0;if((m=e.split("@")).length>1){if(t.disallow_auth)return!1;if(""===m[0])return!1;if((p=m.shift()).indexOf(":")>=0&&p.split(":").length>2)return!1;var A=p.split(":"),T=(N=2,function(e){if(Array.isArray(e))return e}(I=A)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,l,c=[],s=!0,a=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{if(!s&&null!=n.return&&(l=n.return(),Object(l)!==l))return}finally{if(a)throw o}}return c}}(I,N)||function(e,t){if(e){if("string"==typeof e)return a(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)?a(e,t):void 0}}(I,N)||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.")}()),D=T[0],M=T[1];if(""===D&&""===M)return!1}var I,N;h=m.join("@"),v=null,g=null;var $=h.match(d);$?(f="",g=$[1],v=$[2]||null):(f=(m=h.split(":")).shift(),m.length&&(v=m.join(":")));if(null!==v&&v.length>0){if(y=parseInt(v,10),!/^[0-9]+$/.test(v)||y<=0||y>65535)return!1}else if(t.require_port)return!1;if(t.host_whitelist)return(0,r.default)(f,t.host_whitelist);if(""===f&&!t.require_host)return!0;if(!((0,l.default)(f)||(0,i.default)(f,t)||g&&(0,l.default)(g,6)))return!1;if(f=f||g,t.host_blacklist&&(0,r.default)(f,t.host_blacklist))return!1;return!0};var n=s($),r=s(C),o=s(F),i=s(L),l=s(V),c=s(z);function s(e){return e&&e.__esModule?e:{default:e}}function a(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 u={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0,max_allowed_length:2084},d=/^\[([^\]]+)\](?::([0-9]+))?$/;e.exports=t.default,e.exports.default=t.default}(N,I);var U=T(I);function H(e){return!(!e||e.length>2048)&&U(e,{protocols:["http","https"],require_protocol:!0,require_valid_protocol:!0,require_host:!0,require_port:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,allow_underscores:!0,disallow_auth:!1})}const K=(e,t,n)=>{var r,o,i,l;(e=>{const[t]=_.nodes(e,{match:e=>!_.isEditor(e)&&w.isElement(e)&&"link"===e.type});return!!t})(t)&&(e=>{k.unwrapNodes(e,{match:e=>!_.isEditor(e)&&w.isElement(e)&&"link"===e.type})})(t);const{selection:c}=t,s=c&&b.isCollapsed(c),a=null===(l=null===(i=null===(o=null===(r=e.plugins)||void 0===r?void 0:r.Link)||void 0===o?void 0:o.elements)||void 0===i?void 0:i.link)||void 0===l?void 0:l.props,u={type:"link",children:s?[{text:n}]:[],props:{url:n,target:(null==a?void 0:a.target)||"_self",rel:(null==a?void 0:a.rel)||"noopener noreferrer"}};s?k.insertNodes(t,u):(k.wrapNodes(t,u,{split:!0}),k.collapse(t,{edge:"end"}))};function q(){const e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return`${e()+e()}-${e()}-${e()}-${e()}-${e()}${e()}${e()}`}const W=()=>{var e;return"undefined"==typeof window||"function"!=typeof(null===(e=window.crypto)||void 0===e?void 0:e.randomUUID)?q():window.crypto.randomUUID()};function J(e,t){var n,r;if(!(null==t?void 0:t.id)&&"number"!=typeof(null==t?void 0:t.at))return null;if(null==t?void 0:t.id)return null!==(n=e.children[null==t?void 0:t.id])&&void 0!==n?n:null;const o=Object.keys(e.children).find(n=>e.children[n].meta.order===(null==t?void 0:t.at));return o&&null!==(r=e.children[o])&&void 0!==r?r:null}function Y(e,t={}){const{at:n=e.path.current,blockId:r}=t,o=r?e.children[r]:J(e,{at:n});if(!o)return;const i=Math.max(0,o.meta.depth-1),l={type:"set_block_meta",id:o.id,properties:{depth:i},prevProperties:{depth:o.meta.depth}};e.applyTransforms([l])}function X(e,t){const n=null!=t?t:e.path.current;return"number"==typeof n&&0!==n?n-1:null}function G(e,t){e.applyTransforms([{type:"set_block_path",path:t}],{validatePaths:!1})}function Z(e){try{let t;const[n,r]=_.last(e,[]);if(w.isElement(n)&&!_.isEditor(n)){const[n,o]=_.last(e,r);O.isText(n)&&(t={path:o,offset:n.text.length})}else O.isText(n)&&(t={path:r,offset:n.text.length});return t}catch(e){return{path:[0,0],offset:0}}}function Q(e){try{let t;const[n,r]=_.first(e,[]);if(w.isElement(n)&&!_.isEditor(n)){const[n,o]=_.first(e,r);O.isText(n)&&(t={path:o,offset:0})}else O.isText(n)&&(t={path:r,offset:0});return t||(t={path:[0,0],offset:0}),t}catch(e){return{path:[0,0],offset:0}}}function ee(e,t){const n=Object.keys(e.children),{at:r=e.path.current}=t||{},o=n.find(t=>e.children[t].meta.order===r);if(o)return e.blockEditorsMap[o]}function te(e,t){const{at:n,blockId:r}=null!=t?t:{};let o;return o=r?He.getBlockSlate(e,{id:r}):"number"==typeof n?He.getBlockSlate(e,{at:n}):ee(e),o?Q(o):{path:[0,0],offset:0}}const ne={getBlockOrder:function(e){return e.path.current},getNextBlockOrder:function(e,t){const n=null!=t?t:e.path.current;return"number"==typeof n?n+1:null},getPreviousBlockOrder:X,isBlockSelected:function(e,t){const n=e.path.selected;return!!Array.isArray(n)&&n.includes(t.meta.order)},getSelectedPaths:function(e){return e.path.selected},isPathEmpty:function(e){return null===e.path.current},setPath:G,getLastNodePoint:Z,getFirstNodePoint:te};function re(e,t){var n;if(!(null==t?void 0:t.id)&&"number"!=typeof(null==t?void 0:t.at))return null;const r=null!==(n=null==t?void 0:t.id)&&void 0!==n?n:Object.keys(e.children).find(n=>e.children[n].meta.order===(null==t?void 0:t.at)),o=e.blockEditorsMap[null!=r?r:""];return o||null}function oe(e,t={}){var n;const{at:r,blockId:o,focus:i=!0,focusTarget:l="previous"}=t,c=J(e,{id:o,at:"number"==typeof r?r:e.path.current});if(!c)return;let s,a;if(i&&"none"!==l)if("previous"===l){const t=ne.getPreviousBlockOrder(e,c.meta.order);null!==t&&(s=J(e,{at:t}),a=s?re(e,{id:s.id}):void 0)}else if("next"===l){const t=ne.getNextBlockOrder(e,c.meta.order);null!==t&&(s=J(e,{at:t}),a=s?re(e,{id:s.id}):void 0)}const u=e.children[c.id],d=[],p=e.plugins[u.type],{onDestroy:f}=null!==(n=null==p?void 0:p.lifecycle)&&void 0!==n?n:{};if(null==f||f(e,u.id),d.push({type:"delete_block",block:u,path:e.path}),e.applyTransforms(d,{validatePaths:!1}),i&&"none"!==l&&s&&a){const t=ne.getLastNodePoint(a);e.focusBlock(s.id,{focusAt:t})}}var ie={};!function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,o="[object Arguments]",i="[object Boolean]",l="[object Date]",c="[object Function]",s="[object GeneratorFunction]",a="[object Map]",u="[object Number]",d="[object Object]",p="[object Promise]",f="[object RegExp]",h="[object Set]",y="[object String]",v="[object Symbol]",m="[object WeakMap]",g="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",_="[object Float64Array]",w="[object Int8Array]",O="[object Int16Array]",j="[object Int32Array]",E="[object Uint8Array]",S="[object Uint8ClampedArray]",x="[object Uint16Array]",P="[object Uint32Array]",B=/\w*$/,T=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,M={};M[o]=M["[object Array]"]=M[g]=M[b]=M[i]=M[l]=M[k]=M[_]=M[w]=M[O]=M[j]=M[a]=M[u]=M[d]=M[f]=M[h]=M[y]=M[v]=M[E]=M[S]=M[x]=M[P]=!0,M["[object Error]"]=M[c]=M[m]=!1;var I="object"==typeof A&&A&&A.Object===Object&&A,N="object"==typeof self&&self&&self.Object===Object&&self,$=I||N||Function("return this")(),C=t&&!t.nodeType&&t,F=C&&e&&!e.nodeType&&e,L=F&&F.exports===C;function R(e,t){return e.set(t[0],t[1]),e}function z(e,t){return e.add(t),e}function V(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function U(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function H(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function K(e,t){return function(n){return e(t(n))}}function q(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var W,J=Array.prototype,Y=Function.prototype,X=Object.prototype,G=$["__core-js_shared__"],Z=(W=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+W:"",Q=Y.toString,ee=X.hasOwnProperty,te=X.toString,ne=RegExp("^"+Q.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=L?$.Buffer:void 0,oe=$.Symbol,ie=$.Uint8Array,le=K(Object.getPrototypeOf,Object),ce=Object.create,se=X.propertyIsEnumerable,ae=J.splice,ue=Object.getOwnPropertySymbols,de=re?re.isBuffer:void 0,pe=K(Object.keys,Object),fe=Fe($,"DataView"),he=Fe($,"Map"),ye=Fe($,"Promise"),ve=Fe($,"Set"),me=Fe($,"WeakMap"),ge=Fe(Object,"create"),be=Ue(fe),ke=Ue(he),_e=Ue(ye),we=Ue(ve),Oe=Ue(me),je=oe?oe.prototype:void 0,Ee=je?je.valueOf:void 0;function Se(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function xe(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Pe(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Be(e){this.__data__=new xe(e)}function Ae(e,t){var n=Ke(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&qe(e)}(e)&&ee.call(e,"callee")&&(!se.call(e,"callee")||te.call(e)==o)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,i=!!r;for(var l in e)!t&&!ee.call(e,l)||i&&("length"==l||ze(l,r))||n.push(l);return n}function Te(e,t,n){var r=e[t];ee.call(e,t)&&He(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function De(e,t){for(var n=e.length;n--;)if(He(e[n][0],t))return n;return-1}function Me(e,t,n,r,p,m,A){var T;if(r&&(T=m?r(e,p,m,A):r(e)),void 0!==T)return T;if(!Ye(e))return e;var D=Ke(e);if(D){if(T=function(e){var t=e.length,n=e.constructor(t);t&&"string"==typeof e[0]&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!t)return function(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(e,T)}else{var I=Re(e),N=I==c||I==s;if(We(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(I==d||I==o||N&&!m){if(U(e))return m?e:{};if(T=function(e){return"function"!=typeof e.constructor||Ve(e)?{}:(t=le(e),Ye(t)?ce(t):{});var t}(N?{}:e),!t)return function(e,t){return $e(e,Le(e),t)}(e,function(e,t){return e&&$e(t,Xe(t),e)}(T,e))}else{if(!M[I])return m?e:{};T=function(e,t,n,r){var o=e.constructor;switch(t){case g:return Ne(e);case i:case l:return new o(+e);case b:return function(e,t){var n=t?Ne(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case k:case _:case w:case O:case j:case E:case S:case x:case P:return function(e,t){var n=t?Ne(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case a:return function(e,t,n){var r=t?n(H(e),!0):H(e);return V(r,R,new e.constructor)}(e,r,n);case u:case y:return new o(e);case f:return function(e){var t=new e.constructor(e.source,B.exec(e));return t.lastIndex=e.lastIndex,t}(e);case h:return function(e,t,n){var r=t?n(q(e),!0):q(e);return V(r,z,new e.constructor)}(e,r,n);case v:return c=e,Ee?Object(Ee.call(c)):{}}var c}(e,I,Me,t)}}A||(A=new Be);var $=A.get(e);if($)return $;if(A.set(e,T),!D)var C=n?function(e){return function(e,t,n){var r=t(e);return Ke(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Xe,Le)}(e):Xe(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););}(C||e,function(o,i){C&&(o=e[i=o]),Te(T,i,Me(o,t,n,r,i,e,A))}),T}function Ie(e){return!(!Ye(e)||(t=e,Z&&Z in t))&&(Je(e)||U(e)?ne:T).test(Ue(e));var t}function Ne(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function $e(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var l=t[o],c=r?r(n[l],e[l],l,n,e):void 0;Te(n,l,void 0===c?e[l]:c)}return n}function Ce(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Fe(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Ie(n)?n:void 0}Se.prototype.clear=function(){this.__data__=ge?ge(null):{}},Se.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Se.prototype.get=function(e){var t=this.__data__;if(ge){var r=t[e];return r===n?void 0:r}return ee.call(t,e)?t[e]:void 0},Se.prototype.has=function(e){var t=this.__data__;return ge?void 0!==t[e]:ee.call(t,e)},Se.prototype.set=function(e,t){return this.__data__[e]=ge&&void 0===t?n:t,this},xe.prototype.clear=function(){this.__data__=[]},xe.prototype.delete=function(e){var t=this.__data__,n=De(t,e);return!(n<0)&&(n==t.length-1?t.pop():ae.call(t,n,1),!0)},xe.prototype.get=function(e){var t=this.__data__,n=De(t,e);return n<0?void 0:t[n][1]},xe.prototype.has=function(e){return De(this.__data__,e)>-1},xe.prototype.set=function(e,t){var n=this.__data__,r=De(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Pe.prototype.clear=function(){this.__data__={hash:new Se,map:new(he||xe),string:new Se}},Pe.prototype.delete=function(e){return Ce(this,e).delete(e)},Pe.prototype.get=function(e){return Ce(this,e).get(e)},Pe.prototype.has=function(e){return Ce(this,e).has(e)},Pe.prototype.set=function(e,t){return Ce(this,e).set(e,t),this},Be.prototype.clear=function(){this.__data__=new xe},Be.prototype.delete=function(e){return this.__data__.delete(e)},Be.prototype.get=function(e){return this.__data__.get(e)},Be.prototype.has=function(e){return this.__data__.has(e)},Be.prototype.set=function(e,t){var n=this.__data__;if(n instanceof xe){var r=n.__data__;if(!he||r.length<199)return r.push([e,t]),this;n=this.__data__=new Pe(r)}return n.set(e,t),this};var Le=ue?K(ue,Object):function(){return[]},Re=function(e){return te.call(e)};function ze(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||D.test(e))&&e>-1&&e%1==0&&e<t}function Ve(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||X)}function Ue(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function He(e,t){return e===t||e!=e&&t!=t}(fe&&Re(new fe(new ArrayBuffer(1)))!=b||he&&Re(new he)!=a||ye&&Re(ye.resolve())!=p||ve&&Re(new ve)!=h||me&&Re(new me)!=m)&&(Re=function(e){var t=te.call(e),n=t==d?e.constructor:void 0,r=n?Ue(n):void 0;if(r)switch(r){case be:return b;case ke:return a;case _e:return p;case we:return h;case Oe:return m}return t});var Ke=Array.isArray;function qe(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}(e.length)&&!Je(e)}var We=de||function(){return!1};function Je(e){var t=Ye(e)?te.call(e):"";return t==c||t==s}function Ye(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Xe(e){return qe(e)?Ae(e):function(e){if(!Ve(e))return pe(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Me(e,!0,!0)}}({get exports(){return ie},set exports(e){ie=e}},ie);var le=ie;function ce(e,t={}){const{at:n,blockId:r,insertAt:o,focus:i=!0,elements:l}=t,c="number"==typeof n?n:e.path.current,s=r?e.children[r]:J(e,{at:c});if(!s)return;const a=[],u=le(s);return u.id=W(),u.meta.order="number"==typeof o?o:s.meta.order+1,l&&(u.value=[l]),a.push({type:"insert_block",path:{current:u.meta.order},block:u}),e.applyTransforms(a),i&&e.focusBlock(u.id,{waitExecution:!0}),u.id}const se=new WeakMap;function ae(t,n,r={}){const{focusAt:o,waitExecution:i=!0,waitExecutionMs:l=0,shouldUpdateBlockPath:c=!0}=r,s=()=>{const i=r.slate||t.blockEditorsMap[n],l=t.children[n];if(i&&l){try{const t=function(e,t){if(j.isPoint(t))return t;if(E.isPath(t))return{path:t,offset:0};const[,n]=_.first(e,[0]);return{path:n||[0,0],offset:0}}(i,o);k.select(i,t),e.focus(i)}catch(e){}requestAnimationFrame(()=>{try{if(i.selection){const t=e.toDOMRange(i,i.selection),n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}}catch(e){}}),c&&setTimeout(()=>{t.setPath({current:l.meta.order})},0)}};i?setTimeout(()=>s(),l):s(),se.set(t,!0)}function ue(e,t={}){const{at:n=e.path.current,blockId:r}=t,o=r?e.children[r]:J(e,{at:n});if(!o)return;const i=o.meta.depth+1,l={type:"set_block_meta",id:o.id,properties:{depth:i},prevProperties:{depth:o.meta.depth}};e.applyTransforms([l])}function de(e){const t={};return Object.values(e.plugins).forEach(e=>{var n;const r=ye(e.elements),o=null===(n=null==r?void 0:r.props)||void 0===n?void 0:n.nodeType;"inline"===o||"inlineVoid"===o||(t[e.type]=e)}),t}const pe=e=>({id:W(),type:(null==e?void 0:e.type)||"paragraph",children:(null==e?void 0:e.children)||[{text:""}],props:Object.assign({nodeType:"block"},null==e?void 0:e.props)}),fe=e=>({id:(null==e?void 0:e.id)||W(),value:(null==e?void 0:e.value)||[pe()],type:(null==e?void 0:e.type)||"Paragraph",meta:Object.assign({order:0,depth:0},null==e?void 0:e.meta)});function he(e){if(!e)return;const t=Object.keys(e);return 1===t.length?t[0]:t.find(t=>e[t].asRoot)}function ye(e){if(!e)return;const t=he(e);return t?e[t]:void 0}function ve(e,t={}){var n;const{at:r,elementType:o}=t,i=null!=r?r:null===(n=e.selection)||void 0===n?void 0:n.anchor.path;if(!i)return;let l=e=>!_.isEditor(e)&&w.isElement(e);o&&(l=e=>!_.isEditor(e)&&w.isElement(e)&&e.type===o);const c=E.parent(i),s=_.nodes(e,{at:c,match:l,mode:"lowest"});if(s){const[e]=s;return e}}function me(e,t={nodeType:"block"}){return{id:W(),type:e,children:[{text:""}],props:t}}function ge(e,t,n){var r;return(null===(r=e.children)||void 0===r?void 0:r.map(e=>{const r=t[e];if(!r)throw new Error(`Element definition for ${e} not found`);return pe({id:W(),type:e,props:r.props,children:r.children&&r.children.length>0?ge(r,t,n):[{text:(null==n?void 0:n[e])||""}]})}))||[]}function be(e,t,n){const r=de(e),o=r[t];if(!o){const e=Object.keys(r);throw new Error(`Plugin for block type "${t}" not found. Available plugins: ${e.join(", ")||"none"}`)}const i=o.elements,l=he(i);if(!l)throw new Error(`Root element type not found for block type ${t}`);const c=i[l];return{id:W(),type:l,props:c.props,children:c.children&&c.children.length>0?ge(c,i,n):[{text:""}]}}function ke(e,t){if(!t.selection)return null;const n=J(e,{at:e.path.current});if(!n)return null;const r=e.plugins[n.type],o=null==r?void 0:r.elements;if(!o)return null;let i=t.selection.anchor.path;for(;i.length>1;){const r=ve(t,{at:i});if(r){const[t]=r;if(w.isElement(t)&&"type"in t){const r=o[t.type];if(null==r?void 0:r.injectElementsFromPlugins){const o=r.injectElementsFromPlugins.filter(t=>{var n;return!(null===(n=e.plugins)||void 0===n?void 0:n[t])});if(o.length>0)throw new Error(`Some "injectElementsFromPlugins" in ${n.type}->${t.type} are not defined in editor.plugins: ${o.join(", ")}`);return r.injectElementsFromPlugins}}}i=i.slice(0,-1)}return null}function _e(e,t,n={}){var r,o;const{at:i=e.path.current,focus:l=!1,blockData:c,elements:s}=n,a=e.plugins[t];if(!a)throw new Error(`Plugin "${t}" not defined in plugins`);const{beforeCreate:u,onCreate:d}=a.lifecycle||{};let p;p=c&&Array.isArray(null==c?void 0:c.value)?c.value[0]:s||((null==u?void 0:u(e))||be(e,t));const f={id:(null==c?void 0:c.id)||W(),type:t,value:[p],meta:{align:(null===(r=null==c?void 0:c.meta)||void 0===r?void 0:r.align)||"left",depth:(null===(o=null==c?void 0:c.meta)||void 0===o?void 0:o.depth)||0,order:"number"==typeof i?i:Object.keys(e.children).length}},h=[];return h.push({type:"insert_block",path:{current:f.meta.order},block:f}),e.applyTransforms(h),null==d||d(e,f.id),l&&e.focusBlock(f.id),f.id}function we(e,t){const{blockId:n,type:r,path:o,match:i,mode:l="remove"}=t,c=e.children[n];if(!c)return void console.warn(`Block ${n} not found`);const s=ee(e,{at:c.meta.order});s?_.withoutNormalizing(s,()=>{const t=e.plugins[c.type];if(!t)return void console.warn(`Plugin ${c.type} not found`);if(!t.elements[r])return void console.warn(`Element type ${r} not found in plugin ${c.type}`);const n=function(e,t,n){var r;const o=e.plugins[t],i=null==o?void 0:o.elements[n];if(!i)return!1;const l=null===(r=i.props)||void 0===r?void 0:r.nodeType;return"inline"===l||"inlineVoid"===l}(e,c.type,r);let a=null,u=null;if(E.isPath(o)){a=o;try{const e=_.node(s,a);e&&w.isElement(e[0])&&(u=e[0])}catch(e){return void console.warn(`Element not found at path ${o}`)}}else{const e=function(e,t,n,r){const o=null!=r?r:e=>w.isElement(e)&&e.type===t;if(e.selection){const[t]=_.nodes(e,{at:e.selection,match:o,mode:n?"lowest":"highest"});if(t)return t}const[i]=_.nodes(e,{at:[],match:o,mode:n?"lowest":"highest"});return i||null}(s,r,n,i);if(!e)return void console.warn(`Element of type ${r} not found in current selection`);[u,a]=e}a&&u?n?function(e,t,n,r){"unwrap"===r?e.selection?k.unwrapNodes(e,{at:e.selection,match:e=>w.isElement(e)&&e.type===n.type,split:!0}):k.unwrapNodes(e,{at:t,match:e=>e===n}):k.removeNodes(e,{at:t,match:e=>e===n})}(s,a,u,l):function(e,t,n){k.removeNodes(e,{at:t,match:e=>e===n})}(s,a,u):console.warn("Could not resolve target element")}):console.warn(`Slate editor not found for block ${n}`)}function Oe(e,t){const{blockId:n,type:r,path:o,match:i}=t,l=e.children[n];if(!l)return null;const c=ee(e,{at:l.meta.order});if(!c)return null;let s;s=i?e=>w.isElement(e)&&i(e):r?e=>w.isElement(e)&&e.type===r:e=>w.isElement(e);const a=function(e,t,n){var r,o,i,l,c;if(!t)return null!==(r=e.selection)&&void 0!==r?r:[0];if(Array.isArray(t))return t;if("selection"===t)return null!==(o=e.selection)&&void 0!==o?o:[0];if("first"===t&&n){const[t]=_.nodes(e,{match:e=>w.isElement(e)&&e.type===n,mode:"lowest"});return null!==(i=null==t?void 0:t[1])&&void 0!==i?i:[0]}if("last"===t&&n){const t=Array.from(_.nodes(e,{match:e=>w.isElement(e)&&e.type===n,mode:"lowest"}));return null!==(c=null===(l=t[t.length-1])||void 0===l?void 0:l[1])&&void 0!==c?c:[0]}return[0]}(c,o,r);try{const[e]=_.nodes(c,{at:a,match:s,mode:"lowest"});return e?e[0]:null}catch(e){return null}}function je(e,t){const n=Oe(e,t);return n&&"children"in n?n.children:null}function Ee(e,t){const{blockId:n,type:r,path:o}=t,i=e.children[n];if(!i)return null;const l=ee(e,{at:i.meta.order});if(!l)return null;const c=r?e=>w.isElement(e)&&e.type===r:e=>w.isElement(e),s=function(e,t,n){var r,o,i,l,c;if(!t)return null!==(r=e.selection)&&void 0!==r?r:[0];if(Array.isArray(t))return t;if("selection"===t)return null!==(o=e.selection)&&void 0!==o?o:[0];if("first"===t&&n){const[t]=_.nodes(e,{match:e=>w.isElement(e)&&e.type===n,mode:"lowest"});return null!==(i=null==t?void 0:t[1])&&void 0!==i?i:[0]}if("last"===t&&n){const t=Array.from(_.nodes(e,{match:e=>w.isElement(e)&&e.type===n,mode:"lowest"}));return null!==(c=null===(l=t[t.length-1])||void 0===l?void 0:l[1])&&void 0!==c?c:[0]}return[0]}(l,o,r);try{const[e]=_.nodes(l,{at:s,match:c,mode:"lowest"});return e||null}catch(e){return null}}function Se(t,n){const{blockId:r,element:o}=n,i=t.children[r];if(!i)return null;const l=ee(t,{at:i.meta.order});if(!l)return null;try{return e.findPath(l,o)}catch(e){return null}}function xe(t,n){const{blockId:r,element:o}=n,i=t.children[r];if(!i)return null;const l=ee(t,{at:i.meta.order});if(!l)return null;try{const t=e.toDOMNode(l,o);return t?{domRect:t.getBoundingClientRect(),clientRects:t.getClientRects()}:null}catch(e){return null}}function Pe(e,t){const{blockId:n,type:r,match:o}=t,i=e.children[n];if(!i)return[];const l=ee(e,{at:i.meta.order});if(!l)return[];const c=o||(r?e=>w.isElement(e)&&e.type===r:e=>w.isElement(e));try{return Array.from(_.nodes(l,{at:[],match:c,mode:"all"})).map(([e])=>e)}catch(e){return[]}}function Be(t,n){const{blockId:r,element:o}=n,i=t.children[r];if(!i)return null;const l=ee(t,{at:i.meta.order});if(!l)return null;try{const t=e.findPath(l,o);return E.parent(t)}catch(e){return null}}function Ae(e,t){const{blockId:n,type:r,props:o,children:i,at:l,focus:c=!1,select:s=!1}=t,a=e.children[n];if(!a)return;const u=ee(e,{at:a.meta.order});u&&_.withoutNormalizing(u,()=>{const t=e.plugins[a.type];if(!t)return;const n=t.elements[r];if(!n)return;const d=function(e,t,n,r,o,i){const l=e.plugins[t.type],c=pe({type:n,props:Object.assign(Object.assign({},i.props),r)});if(o&&o.length>0)c.children=o;else{const e=[];Array.isArray(i.children)&&i.children.length>0&&i.children.forEach(t=>{const n=l.elements[t];n&&e.push(pe({type:t,props:n.props}))}),e.length>0&&(c.children=e)}return c}(e,a,r,o,i,n),p=function(e,t,n){var r;if(!t)return(null===(r=e.selection)||void 0===r?void 0:r.anchor.path)?e.selection.anchor.path:[0];if(Array.isArray(t))return t;if("start"===t)return[0];if("end"===t)return[e.children.length];if("next"===t||"prev"===t){if(!e.selection)return[e.children.length];const[r]=_.nodes(e,{at:e.selection,match:e=>w.isElement(e)&&e.type===n,mode:"lowest"});if(r){const[,e]=r;return"next"===t?E.next(e):E.previous(e)}return e.selection.anchor.path||[e.children.length]}}(u,l,r);if(!p)return;const f=s||c||!1;if(k.insertNodes(u,d,{at:p,select:f}),c&&!s){if((Array.isArray(d.children)?d.children.filter(e=>w.isElement(e)):[]).length>0){const e=[...p,0];try{k.select(u,e)}catch(e){}}}})}function Te(e,t){const{blockId:n,type:r,path:o}=t,i=e.children[n];if(!i)return!0;const l=ee(e,{at:i.meta.order});if(!l)return!0;const c=o||l.selection||[0];try{const[e]=_.nodes(l,{at:c,match:e=>w.isElement(e)&&e.type===r,mode:"lowest"});if(e){const[,t]=e;return 0===_.string(l,t).trim().length}return!0}catch(e){return!0}}function De(e,t){const{blockId:n,type:r,props:o,path:i,match:l,text:c}=t,s=e.children[n];if(!s)return void console.warn(`Block ${n} not found`);const a=ee(e,{at:s.meta.order});a?_.withoutNormalizing(a,()=>{const t=e.plugins[s.type];if(!t)return void console.warn(`Plugin ${s.type} not found`);if(!t.elements[r])return void console.warn(`Element type ${r} not found in plugin ${s.type}`);const n=function(e,t,n){var r;const o=e.plugins[t],i=null==o?void 0:o.elements[n];if(!i)return!1;const l=null===(r=i.props)||void 0===r?void 0:r.nodeType;return"inline"===l||"inlineVoid"===l}(e,s.type,r);let u=null,d=null;if(i){u=i;try{const e=_.node(a,u);e&&w.isElement(e[0])&&(d=e[0])}catch(e){return void console.warn(`Element not found at path ${i}`)}}else{const e=function(e,t,n,r){const o=r||(e=>w.isElement(e)&&e.type===t);if(e.selection){const[t]=_.nodes(e,{at:e.selection,match:o,mode:n?"lowest":"highest"});if(t)return t}const[i]=_.nodes(e,{at:[],match:o,mode:n?"lowest":"highest"});return i||null}(a,r,n,l);if(!e)return void console.warn(`Element of type ${r} not found in current selection`);[d,u]=e}if(u&&d){if(o){const e=Object.assign({},d.props),t=Object.assign(Object.assign({},e),o);k.setNodes(a,{props:t},{at:u})}void 0!==c&&n?function(e,t,n){const[r]=_.node(e,t);if(!w.isElement(r))return;const o=r.children.filter(e=>O.isText(e));if(o.length>0){k.insertText(e,n,{at:[...t,0]});for(let n=o.length-1;n>0;n-=1)try{k.removeNodes(e,{at:[...t,n]})}catch(e){}}else k.insertNodes(e,{text:n},{at:[...t,0]})}(a,u,c):void 0===c||n||console.warn("Text option is only supported for inline elements")}else console.warn("Could not resolve target element")}):console.warn(`Slate editor not found for block ${n}`)}const Me={insertElement:Ae,updateElement:De,deleteElement:we,getElement:Oe,getElements:Pe,getElementEntry:Ee,getElementPath:Se,getElementRect:xe,getParentElementPath:Be,getElementChildren:je,isElementEmpty:Te};function Ie(t,n={}){var r;const{at:o,blockId:i,targetAt:l,targetBlockId:c,focus:s=!0,preserveContent:a=!0}=n,u="number"==typeof o?o:t.path.current,d=J(t,{id:i,at:u});if(!d)return;const p=i?re(t,{id:i}):ee(t,{at:d.meta.order});if(!p)return;let f,h;if(c)f=J(t,{id:c}),h=re(t,{id:c});else if("number"==typeof l)f=J(t,{at:l}),h=ee(t,{at:l});else{const e=ne.getPreviousBlockOrder(t,d.meta.order);if(null===e)return;f=J(t,{at:e}),h=ee(t,{at:e})}if(!f||!h)return;if(!t.plugins[f.type])return;const y=Me.getElement(t,f.id);if("void"!==(null===(r=null==y?void 0:y.props)||void 0===r?void 0:r.nodeType)){try{const e=Z(h);k.select(h,e)}catch(e){k.select(h,_.start(h,[]))}_.withoutNormalizing(h,()=>{const n=[],r=function(e,t,n){if(!n)return e.children;const r=JSON.parse(JSON.stringify(e.children)),o=JSON.parse(JSON.stringify(t.children)),i=r[r.length-1],l=o[0];return O.isText(i)&&O.isText(l)?(i.text+=l.text,[...r.slice(0,-1),i,...o.slice(1)]):[...r,...o]}(h.children[0],p.children[0],a),o=[Object.assign(Object.assign({},h.children[0]),{children:r})],i=Object.assign(Object.assign({},f),{value:o});if(n.push({type:"merge_block",prevProperties:{sourceBlock:d,sourceSlateValue:p.children,targetBlock:f,targetSlateValue:h.children},properties:{mergedBlock:i,mergedSlateValue:o},path:t.path}),t.applyTransforms(n),t.setPath({current:f.meta.order}),s)try{setTimeout(()=>{e.focus(h)},0)}catch(e){}})}}function Ne(e,t,n){const r=n,o=e.children[t],i=Object.values(e.children).find(e=>e.meta.order===r);if(!o||!i)return;const l=[],c={type:"move_block",prevProperties:{id:t,order:o.meta.order},properties:{id:t,order:r}};l.push(c),e.applyTransforms(l),e.setPath({current:r})}function $e(t,n={}){const{at:r,blockId:o,splitAt:i,focus:l=!0,focusTarget:c="new",preserveContent:s=!0}=n,a="number"==typeof r?r:t.path.current,u=J(t,{id:o,at:a});if(!u)return;const d=o?re(t,{id:o}):ee(t,{at:u.meta.order});if(!d)return;const p=null!=i?i:d.selection;if(!p)return;const f=d.selection,h=i&&i!==d.selection;let y;h&&k.select(d,i);try{_.withoutNormalizing(d,()=>{const n=le(d.children),r=[];let o,i;s?[o,i]=function(e,t){const{path:n,offset:r}=t.focus,[,...o]=n,i=JSON.parse(JSON.stringify(e[0])),[l,c]=function e(t,n,r){if(0!==n.length){const[o,...i]=n,[l,c]=e(t.children[o],i,r),s=t.children.slice(0,o).concat(l?[l]:[]),a=(c?[c]:[]).concat(t.children.slice(o+1));return[Object.assign(Object.assign({},t),{children:s}),Object.assign(Object.assign({},t),{children:a})]}if(S.string(t).length<=r)return[t,null];if("text"in t)return[Object.assign(Object.assign({},t),{text:t.text.slice(0,r)}),Object.assign(Object.assign({},t),{text:t.text.slice(r)})];if("link"===t.type){const[n,o]=e(t.children[0],[],r);return[Object.assign(Object.assign({},t),{children:[n]}),Object.assign(Object.assign({},t),{children:[o]})]}return[t,null]}(i,o,r);function s(e){var t,n;if("children"in e){if("inlineVoid"===(null===(t=e.props)||void 0===t?void 0:t.nodeType)||"inline"===(null===(n=e.props)||void 0===n?void 0:n.nodeType))return 0===e.children.length?Object.assign(Object.assign({},e),{children:[{text:""}]}):e;const r=e.children.filter(e=>""!==e.text&&void 0!==e.text||e.children&&e.children.length>0).map(s);return Object.assign(Object.assign({},e),{children:r})}return e}return[s(l),s(c)].map(e=>[e]).filter(e=>e[0].children.length>0)}(d.children,p):(o=d.children,i=void 0);const a={id:W(),type:u.type,meta:{order:u.meta.order+1,depth:u.meta.depth,align:u.meta.align},value:[]};if(y=a.id,r.push({type:"split_block",prevProperties:{originalBlock:u,originalValue:n},properties:{nextBlock:a,nextSlateValue:i||[me("paragraph")],splitSlateValue:o},path:t.path}),t.applyTransforms(r),l&&"none"!==c)if("new"===c)t.focusBlock(a.id);else if("original"===c){const n=re(t,{id:u.id});if(n)try{e.focus(n),k.select(n,_.end(n,[]))}catch(e){}}})}finally{if(h&&f)try{k.select(d,f)}catch(e){}}return y}function Ce(e,t){var n;for(const r of Object.keys(e.plugins)){const o=e.plugins[r];if(null===(n=o.elements)||void 0===n?void 0:n[t])return o.elements[t]}return null}function Fe(e,t={}){return Object.assign({text:e},t)}function Le(e,t,n={}){const r=Ce(e,t);if(!r)throw new Error(`Element type "${t}" not found in any plugin. Make sure the plugin is registered in editor.plugins`);const{id:o,props:i,children:l}=n,c=Object.assign(Object.assign({},r.props),i);let s;return s=void 0!==l?l.length>0?l:[{text:""}]:r.children&&r.children.length>0?r.injectElementsFromPlugins&&r.injectElementsFromPlugins.length>0?[{text:""}]:r.children.map(t=>Le(e,t,{})):[{text:""}],{id:null!=o?o:W(),type:t,children:s,props:c}}function Re(e,t,n,r){return _.isEditor(t)?t.children.flatMap(t=>Re(e,t)):w.isElement(t)?_.isInline(e,t)?[t]:t.children.flatMap(t=>Re(e,t)):[t]}function ze(e,t){return w.isElement(e)?0===e.children.length||O.isText(e.children[0])?t?e:Object.assign(Object.assign({},e),{children:[{text:""}]}):ze(e.children[0],t):null}function Ve(t,n,r={}){const{scope:o="auto"}=r,i="number"==typeof r.at?r.at:t.path.current,l=J(t,{at:i});if(!l)throw new Error(`Block not found at current selection: ${i}`);const c=ee(t,{at:l.meta.order});if(!c)throw new Error(`Slate not found for block in position ${l.meta.order}`);const s=function(e,t,n){if("block"===n)return"block";const r=ke(e,t);return Array.isArray(r)&&r.length>0?"element":"block"}(t,c,o);return"element"===s?function(t,n,r,o,i){var l;const{preserveContent:c=!0,elements:s}=i;if(!r.selection)throw new Error("No selection found");const a=t.plugins[o];if(!a)throw new Error(`Plugin "${o}" not found`);const u=null!==(l=Object.keys(a.elements).find(e=>a.elements[e].asRoot))&&void 0!==l?l:Object.keys(a.elements)[0];if(!u)throw new Error(`No root element found for plugin "${o}"`);let d;d=s||Le(t,u);const p=_.above(r,{match:e=>w.isElement(e)&&_.isBlock(r,e),mode:"lowest"});if(!p)throw new Error("No block element found at selection");const[f,h]=p,y=t.plugins[n.type],v=f.type,m=null==y?void 0:y.elements[v],g=Array.isArray(null==m?void 0:m.injectElementsFromPlugins)&&m.injectElementsFromPlugins.length>0;if(c){const e=Re(r,f),t=ze(d,c);t&&(t.children=e)}if(g){for(let e=f.children.length-1;e>=0;e-=1)k.removeNodes(r,{at:[...h,e]});k.insertNodes(r,d,{at:[...h,0],select:!0})}else k.removeNodes(r,{at:h}),k.insertNodes(r,d,{at:h,select:!0});return i.focus&&(e.focus(r),k.select(r,h)),n.id}(t,l,c,n,r):function(e,t,n,r,o){var i;const{preserveContent:l=!0,elements:c}=o,s=t.type===r?"Paragraph":r,a=e.plugins[s];if(!a)throw new Error(`Plugin "${r}" not found`);const{beforeCreate:u}=null!==(i=a.lifecycle)&&void 0!==i?i:{};let d;if(d=c||(u?u(e):be(e,s)),l){const e=Re(n,n.children[0]),t=ze(d,l);t&&(t.children=e)}const p={id:W(),type:s,meta:Object.assign(Object.assign({},t.meta),{align:void 0}),value:[d]},f=[{type:"toggle_block",prevProperties:{sourceBlock:t,sourceSlateValue:n.children},properties:{toggledBlock:p,toggledSlateValue:p.value}}];return e.applyTransforms(f),o.focus&&e.focusBlock(p.id),p.id}(t,l,c,n,r)}function Ue(e,t,n){const r=e.children[t];if(!r)return void console.warn(`Block with id ${t} does not exist.`);const o={type:"set_block_meta",id:t,properties:{},prevProperties:{}},i={type:"set_block_value",id:t,value:[]};n.meta&&(o.prevProperties=r.meta,o.properties=Object.assign(Object.assign({},r.meta),n.meta)),n.value&&(i.value=n.value);const l=[];Object.keys(o.properties).length&&l.push(o),i.value.length&&l.push(i),l.length>0&&e.applyTransforms(l,{validatePaths:!1})}const He={insertBlock:_e,deleteBlock:oe,moveBlock:Ne,focusBlock:ae,splitBlock:$e,increaseBlockDepth:ue,decreaseBlockDepth:Y,duplicateBlock:ce,updateBlock:Ue,toggleBlock:Ve,getBlock:J,getBlockSlate:re,buildBlockData:function(e){var t,n,r;return{id:(null==e?void 0:e.id)||W(),value:(null==e?void 0:e.value)||[{id:W(),type:(null==r?void 0:r.type)||"paragraph",children:(null==r?void 0:r.children)||[{text:""}],props:Object.assign({nodeType:"block"},null==r?void 0:r.props)}],type:(null==e?void 0:e.type)||"Paragraph",meta:Object.assign({order:(null===(t=null==e?void 0:e.meta)||void 0===t?void 0:t.order)||0,depth:(null===(n=null==e?void 0:e.meta)||void 0===n?void 0:n.depth)||0},null==e?void 0:e.meta)}},mergeBlock:Ie};var Ke={};Object.defineProperty(Ke,"__esModule",{value:!0});for(var qe="undefined"!=typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),We={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},Je={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:qe?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},Ye={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},Xe=1;Xe<20;Xe++)Ye["f"+Xe]=111+Xe;function Ge(e,t,n){t&&!("byKey"in t)&&(n=t,t=null),Array.isArray(e)||(e=[e]);var r=e.map(function(e){return Ze(e,t)}),o=function(e){return r.some(function(t){return Qe(t,e)})};return null==n?o:o(n)}function Ze(e,t){var n=t&&t.byKey,r={},o=(e=e.replace("++","+add")).split("+"),i=o.length;for(var l in We)r[We[l]]=!1;var c=!0,s=!1,a=void 0;try{for(var u,d=o[Symbol.iterator]();!(c=(u=d.next()).done);c=!0){var p=u.value,f=p.endsWith("?")&&p.length>1;f&&(p=p.slice(0,-1));var h=tt(p),y=We[h];if(p.length>1&&!y&&!Je[p]&&!Ye[h])throw new TypeError('Unknown modifier: "'+p+'"');1!==i&&y||(n?r.key=h:r.which=et(p)),y&&(r[y]=!f||null)}}catch(e){s=!0,a=e}finally{try{!c&&d.return&&d.return()}finally{if(s)throw a}}return r}function Qe(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 et(e){return e=tt(e),Ye[e]||e.toUpperCase().charCodeAt(0)}function tt(e){return e=e.toLowerCase(),e=Je[e]||e}Ke.default=Ge,Ke.isHotkey=Ge,Ke.isCodeHotkey=function(e,t){return Ge(e,t)};var nt=Ke.isKeyHotkey=function(e,t){return Ge(e,{byKey:!0},t)};Ke.parseHotkey=Ze,Ke.compareHotkey=Qe,Ke.toKeyCode=et,Ke.toKeyName=tt;const rt={bold:"mod+b",italic:"mod+i",compose:["down","left","right","up","backspace","enter"],arrowLeft:"left",arrowUp:"up",arrowDown:"down",arrowRight:"right",ctrlLeft:"ctrl+left",escape:"esc",ctrlRight:"ctrl+right",deleteBackward:"shift?+backspace",backspace:"backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",shiftDelete:"shift+delete",extendForward:"shift+right",shiftEnter:"shift+enter",enter:"enter",space:"space",undo:"mod+z",select:"mod+a",shiftTab:"shift+tab",shiftArrowUp:"shift+up",shiftArrowDown:"shift+down",tab:"tab",cmd:"mod",cmdEnter:"mod+enter",cmdShiftEnter:"mod+shift+enter",slashCommand:"/",copy:"mod+c",cut:"mod+x",cmdShiftRight:"mod+shift+right",cmdShiftLeft:"mod+shift+left",cmdShiftDelete:"mod+shift+backspace",cmdShiftD:"mod+shift+d",cmdAltDelete:"mod+alt+backspace"},ot={moveLineBackward:"opt+up",moveLineForward:"opt+down",ctrlLeft:"opt+left",ctrlRight:"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"},it={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},lt=e=>{const t=rt[e],n=ot[e],r=it[e],o=t&&nt(t),i=n&&nt(n),l=r&&nt(r);return e=>!(!o||!o(e))||(!(!i||!i(e))||!(!l||!l(e)))},ct={isBold:lt("bold"),isCompose:lt("compose"),isArrowLeft:lt("arrowLeft"),isArrowRight:lt("arrowRight"),isArrowUp:lt("arrowUp"),isArrowDown:lt("arrowDown"),isDeleteBackward:lt("deleteBackward"),isDeleteForward:lt("deleteForward"),isDeleteLineBackward:lt("deleteLineBackward"),isDeleteLineForward:lt("deleteLineForward"),isDeleteWordBackward:lt("deleteWordBackward"),isDeleteWordForward:lt("deleteWordForward"),isExtendBackward:lt("extendBackward"),isExtendForward:lt("extendForward"),isExtendLineBackward:lt("extendLineBackward"),isExtendLineForward:lt("extendLineForward"),isItalic:lt("italic"),isMoveLineBackward:lt("moveLineBackward"),isMoveLineForward:lt("moveLineForward"),isCtrlLeft:lt("ctrlLeft"),isCtrlRight:lt("ctrlRight"),isRedo:lt("redo"),isShiftEnter:lt("shiftEnter"),isEnter:lt("enter"),isTransposeCharacter:lt("transposeCharacter"),isUndo:lt("undo"),isSpace:lt("space"),isSelect:lt("select"),isTab:lt("tab"),isShiftTab:lt("shiftTab"),isBackspace:lt("backspace"),isCmdEnter:lt("cmdEnter"),isCmd:lt("cmd"),isEscape:lt("escape"),isSlashCommand:lt("slashCommand"),isShiftArrowUp:lt("shiftArrowUp"),isShiftArrowDown:lt("shiftArrowDown"),isCopy:lt("copy"),isCut:lt("cut"),isShiftDelete:lt("shiftDelete"),isCmdShiftEnter:lt("cmdShiftEnter"),isCmdShiftRight:lt("cmdShiftRight"),isCmdShiftLeft:lt("cmdShiftLeft"),isCmdShiftDelete:lt("cmdShiftDelete"),isCmdAltDelete:lt("cmdAltDelete"),isCmdShiftD:lt("cmdShiftD")};function st(e,t,n){if(!t.selection)return!1;const r=e.plugins[n.type];if(!(null==r?void 0:r.elements))return!1;if(!Object.values(r.elements).some(e=>!e.rootPlugin&&(e.children&&e.children.length>0)))return!1;const o=_.above(t,{at:t.selection,match:e=>!_.isEditor(e)&&w.isElement(e),mode:"lowest"});if(!o)return!1;const[i]=o,l=i.type,c=r.elements[l];return!!(null==c?void 0:c.rootPlugin)&&c.rootPlugin!==n.type}const at=(e,t,n,r,o)=>u(()=>{let i=t.blockEditorsMap[e];const{normalizeNode:l,insertText:c,apply:s}=i,a=Object.keys(r);return a.forEach(e=>{var n;const o=null===(n=r[e].props)||void 0===n?void 0:n.nodeType,l="inline"===o,c="void"===o,s="inlineVoid"===o,{markableVoid:a,isVoid:u,isInline:d}=i;s&&(i.markableVoid=t=>t.type===e||a(t)),(c||s)&&(i.isVoid=t=>t.type===e||u(t)),(l||s)&&(i.isInline=t=>t.type===e||d(t),i=((e,t)=>{const{insertData:n,insertText:r}=t;return t.insertText=n=>{n&&H(n)?K(e,t,n):r(n)},t.insertData=r=>{const o=r.getData("text/plain");o&&H(o)?K(e,t,o):n(r)},t})(t,i))}),i.insertText=e=>{const n=ne.getSelectedPaths(t),r=ne.getBlockOrder(t);Array.isArray(n)&&n.length>0&&t.setPath({current:r}),c(e)},i.normalizeNode=e=>{const[r,o]=e,c=t.plugins[n.type].elements;if(Object.keys(c).length>1)return l(e);if(w.isElement(r)){const{type:e}=r,t=he(c);if(!a.includes(e))return void k.setNodes(i,{id:W(),type:t,props:Object.assign({},r.props)},{at:o});if(r.type===t)for(const[e,t]of S.children(i,o))if(w.isElement(e)&&!i.isInline(e))return void k.unwrapNodes(i,{at:t})}l(e)},i.apply=n=>{var r,o,l,c;if(null===(r=t.isRemoteSlateOp)||void 0===r?void 0:r.call(t,i))return void s(n);if(x.isSelectionOperation(n)){const e=ne.getSelectedPaths(t),n=ne.getBlockOrder(t);Array.isArray(e)&&i.selection&&b.isExpanded(i.selection)&&t.setPath({current:n})}let a=t.isSavingHistory();if(void 0===a&&(a=(e=>"set_selection"!==e.type)(n)),a){const r=t.historyStack.undos[t.historyStack.undos.length-1];if(!r||"set_slate"!==(null===(o=null==r?void 0:r.operations[0])||void 0===o?void 0:o.type)){const r={type:"set_slate",properties:{slateOps:[n],selectionBefore:i.selection},blockId:e,slate:i};return t.applyTransforms([r],{source:"api",validatePaths:!1}),void s(n)}const a=null===(c=null===(l=null==r?void 0:r.operations[0])||void 0===l?void 0:l.properties)||void 0===c?void 0:c.slateOps,u=a&&a[a.length-1];let d=((e,t)=>t===e||!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!E.equals(e.path,t.path))||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!E.equals(e.path,t.path)))(n,u);if(0!==i.operations.length&&(d=!0),d)u!==n&&a.push(n);else{const r={operations:[n],selectionBefore:i.selection},o={type:"set_slate",properties:{slateOps:r.operations,selectionBefore:r.selectionBefore},blockId:e,slate:i};t.applyTransforms([o],{source:"api",validatePaths:!1})}}s(n)},o&&(i=o(i,t,e)),i},[e,n.type,t,r,o]),ut=({children:e,attributes:n,placeholder:r})=>{const o=t(),i=Object.assign({},n);return o&&r&&(i["data-placeholder"]=r,i.className="yoopta-placeholder"),c("span",Object.assign({},i,{children:e}))};var dt={};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}functi