/*! This file is auto-generated */ this.wp=this.wp||{},this.wp.richText=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=424)}({0:function(e,t){!function(){e.exports=this.wp.element}()},11:function(e,t,r){var n; /*! Copyright (c) 2017 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */!function(){"use strict";var r={}.hasOwnProperty;function o(){for(var e=[],t=0;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ADD_FORMAT_TYPES":return u({},e,{},Object(c.keyBy)(t.formatTypes,"name"));case"REMOVE_FORMAT_TYPES":return Object(c.omit)(e,t.names)}return e}}),f=r(40),p=Object(f.a)((function(e){return Object.values(e.formatTypes)}),(function(e){return[e.formatTypes]}));function d(e,t){return e.formatTypes[t]}function h(e,t){return Object(c.find)(p(e),(function(e){var r=e.className,n=e.tagName;return null===r&&t===n}))}function b(e,t){return Object(c.find)(p(e),(function(e){var r=e.className;return null!==r&&" ".concat(t," ").indexOf(" ".concat(r," "))>=0}))}function m(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Object(c.castArray)(e)}}function v(e){return{type:"REMOVE_FORMAT_TYPES",names:Object(c.castArray)(e)}}Object(a.registerStore)("core/rich-text",{reducer:l,selectors:n,actions:o});var g=r(18);function y(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.type!==t.type)return!1;var r=e.attributes,n=t.attributes;if(r===n)return!0;if(!r||!n)return!1;var o=Object.keys(r),a=Object.keys(n);if(o.length!==a.length)return!1;for(var i=o.length,c=0;c2&&void 0!==arguments[2]?arguments[2]:e.start,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,o=e.formats,a=e.activeFormats,i=o.slice();if(r===n){var s=Object(c.find)(i[r],{type:t.type});if(s){for(var u=i[r].indexOf(s);i[r]&&i[r][u]===s;)i[r]=E(i[r],u,t),r--;for(n++;i[n]&&i[n][u]===s;)i[n]=E(i[n],u,t),n++}}else{for(var l=1/0,f=r;f0&&void 0!==arguments[0]?arguments[0]:{},t=e.element,r=e.text,n=e.html,o=e.range,a=e.multilineTag,i=e.multilineWrapperTags,c=e.__unstableIsEditableTree,s=e.preserveWhiteSpace;return"string"==typeof r&&r.length>0?{formats:Array(r.length),replacements:Array(r.length),text:r}:("string"==typeof n&&n.length>0&&(t=_(document,n)),"object"!==Object(P.a)(t)?{formats:[],replacements:[],text:""}:a?W({element:t,range:o,multilineTag:a,multilineWrapperTags:i,isEditableTree:c,preserveWhiteSpace:s}):L({element:t,range:o,isEditableTree:c,preserveWhiteSpace:s}))}function k(e,t,r,n){if(r){var o=t.parentNode,a=r.startContainer,i=r.startOffset,c=r.endContainer,s=r.endOffset,u=e.text.length;void 0!==n.start?e.start=u+n.start:t===a&&t.nodeType===D?e.start=u+i:o===a&&t===a.childNodes[i]?e.start=u:o===a&&t===a.childNodes[i-1]?e.start=u+n.text.length:t===a&&(e.start=u),void 0!==n.end?e.end=u+n.end:t===c&&t.nodeType===D?e.end=u+s:o===c&&t===c.childNodes[s-1]?e.end=u+n.text.length:o===c&&t===c.childNodes[s]?e.end=u:t===c&&(e.end=u+s)}}var R=new RegExp("\ufeff","g");function I(e){return e.replace(R,"")}function L(e){var t=e.element,r=e.range,n=e.multilineTag,o=e.multilineWrapperTags,c=e.currentWrapperTags,s=void 0===c?[]:c,u=e.isEditableTree,l=e.preserveWhiteSpace,f={formats:[],replacements:[],text:""};if(!t)return f;if(!t.hasChildNodes())return k(f,t,r,{formats:[],replacements:[],text:""}),f;for(var p=t.childNodes.length,d=function(e){var c=t.childNodes[e],p=c.nodeName.toLowerCase();if(c.nodeType===D){var d=I;l||(d=function(e){return I(function(e){return e.replace(/[\n\r\t]+/g," ")}(e))});var h=d(c.nodeValue);return r=function(e,t,r){if(t){var n=t.startContainer,o=t.endContainer,a=t.startOffset,i=t.endOffset;return e===n&&(a=r(e.nodeValue.slice(0,a)).length),e===o&&(i=r(e.nodeValue.slice(0,i)).length),{startContainer:n,startOffset:a,endContainer:o,endOffset:i}}}(c,r,d),k(f,c,r,{text:h}),f.formats.length+=h.length,f.replacements.length+=h.length,f.text+=h,"continue"}if(c.nodeType!==F)return"continue";if(u&&(c.getAttribute("data-rich-text-placeholder")||"br"===p&&!c.getAttribute("data-rich-text-line-break")))return k(f,c,r,{formats:[],replacements:[],text:""}),"continue";if("br"===p)return k(f,c,r,{formats:[],replacements:[],text:""}),H(f,A({text:"\n"})),"continue";var b=f.formats[f.formats.length-1],m=b&&b[b.length-1],v=function(e){var t,r=e.type,n=e.attributes;if(n&&n.class&&(t=Object(a.select)("core/rich-text").getFormatTypeForClassName(n.class))&&(n.class=" ".concat(n.class," ").replace(" ".concat(t.className," ")," ").trim(),n.class||delete n.class),t||(t=Object(a.select)("core/rich-text").getFormatTypeForBareElement(r)),!t)return n?{type:r,attributes:n}:{type:r};if(t.__experimentalCreatePrepareEditableTree&&!t.__experimentalCreateOnChangeEditableValue)return null;if(!n)return{type:t.name};var o={},i={};for(var c in n){var s=N(t.attributes,c);s?o[s]=n[c]:i[c]=n[c]}return{type:t.name,attributes:o,unregisteredAttributes:i}}({type:p,attributes:M({element:c})}),O=y(v,m)?m:v;if(o&&-1!==o.indexOf(p)){var j=W({element:c,range:r,multilineTag:n,multilineWrapperTags:o,currentWrapperTags:[].concat(Object(g.a)(s),[O]),isEditableTree:u,preserveWhiteSpace:l});return k(f,c,r,j),H(f,j),"continue"}var w=L({element:c,range:r,multilineTag:n,multilineWrapperTags:o,isEditableTree:u,preserveWhiteSpace:l});if(k(f,c,r,w),O)if(0===w.text.length)O.attributes&&H(f,{formats:[,],replacements:[O],text:""});else{function T(e){if(T.formats===e)return T.newFormats;var t=e?[O].concat(Object(g.a)(e)):[O];return T.formats=e,T.newFormats=t,t}T.newFormats=[O],H(f,function(e){for(var t=1;t0)&&H(u,{formats:[,],replacements:i.length>0?[i]:[,],text:"\u2028"}),k(u,p,r,d),H(u,d)}}return u}function M(e){var t=e.element;if(t.hasAttributes()){for(var r,n=t.attributes.length,o=0;o1&&void 0!==arguments[1]?arguments[1]:[];if(void 0===r)return a;if(r===n){if(o)return o;var i=t[r-1]||a,c=t[r]||a;return i.length1&&void 0!==arguments[1]?arguments[1]:t,o=n;o--;)if("\u2028"===r[o])return o}function G(e){var t=e.replacements[q(e,e.start)];return!t||t.length<1}function Y(e,t,r){var n=e.replacements[q(e,e.start)];return n&&0!==n.length?n[n.length-1].type===t:t===r}function $(e){var t=e.start,r=e.end;if(void 0!==t&&void 0!==r)return t===r}function X(e){return 0===e.text.length}function Z(e){var t=e.text,r=e.start,n=e.end;return r===n&&(0===t.length||(0===r&&"\u2028"===t.slice(0,1)||(r===t.length&&"\u2028"===t.slice(-1)||t.slice(r-1,n+1)==="".concat("\u2028").concat("\u2028"))))}function J(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof t&&(t=A({text:t})),j(e.reduce((function(e,r){var n=r.formats,o=r.replacements,a=r.text;return{formats:e.formats.concat(t.formats,n),replacements:e.replacements.concat(t.replacements,o),text:e.text+t.text+a}})))}function Q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ee(e,t){if("string"==typeof(t=function(e){for(var t=1;t3)window.console.error('The format "'+t.name+'" can have a maximum of 3 keywords.');else{if("string"==typeof t.title)return Object(a.dispatch)("core/rich-text").addFormatTypes(t),t;window.console.error("Format titles must be strings.")}else window.console.error('The format "'+t.name+'" must have a title.')}else window.console.error("A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.");else window.console.error("Format class names must be a string, or null to handle bare elements.");else window.console.error("Format tag names must be a string.");else window.console.error("Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format");else window.console.error("Format names must be strings.")}function te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function re(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:e.start,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,o=e.formats,a=e.activeFormats,i=o.slice();if(r===n){var s=Object(c.find)(i[r],{type:t});if(s){for(;Object(c.find)(i[r],s);)oe(i,r,t),r--;for(n++;Object(c.find)(i[n],s);)oe(i,n,t),n++}}else for(var u=r;u2&&void 0!==arguments[2]?arguments[2]:e.start,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,o=e.formats,a=e.replacements,i=e.text;"string"==typeof t&&(t=A({text:t}));var c=r+t.text.length;return j({formats:o.slice(0,r).concat(t.formats,o.slice(n)),replacements:a.slice(0,r).concat(t.replacements,a.slice(n)),text:i.slice(0,r)+t.text+i.slice(n),start:c,end:c})}function ie(e,t,r){return ae(e,A(),t,r)}function ce(e,t,r){var n=e.formats,o=e.replacements,a=e.text,i=e.start,c=e.end;return a=a.replace(t,(function(e){for(var t=arguments.length,a=new Array(t>1?t-1:0),s=1;s1&&void 0!==arguments[1]?arguments[1]:e.start,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,n=z(e).slice(0,t),o=n.lastIndexOf("\u2028"),a=e.replacements[o],i=[,];a&&(i=[a]);var c={formats:[,],replacements:i,text:"\u2028"};return ae(e,c,t,r)}function ue(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function le(e){for(var t=1;t1&&void 0!==arguments[1])||arguments[1],r=e.replacements,n=e.text,o=e.start,a=e.end,i=$(e),c=o-1,s=i?o-1:o,u=a;if(t||(c=a,s=o,u=i?a+1:a),"\u2028"===n[c]){var l;if(i&&r[c]&&r[c].length){var f=r.slice();f[c]=r[c].slice(0,-1),l=le({},e,{replacements:f})}else l=ie(e,s,u);return l}}function pe(e,t,r,n){return ae(e,{formats:[,],replacements:[t],text:""},r,n)}function de(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function he(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:e.start,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,n=e.formats,o=e.replacements,a=e.text;return void 0===t||void 0===r?he({},e):{formats:n.slice(t,r),replacements:o.slice(t,r),text:a.slice(t,r)}}function me(e,t){var r=e.formats,n=e.replacements,o=e.text,a=e.start,i=e.end;if("string"!=typeof t)return ve.apply(void 0,arguments);var c=0;return o.split(t).map((function(e){var o=c,s={formats:r.slice(o,o+e.length),replacements:n.slice(o,o+e.length),text:e};return c+=t.length+e.length,void 0!==a&&void 0!==i&&(a>=o&&ao&&(s.start=0),i>=o&&ic&&(s.end=e.length)),s}))}function ve(e){var t=e.formats,r=e.replacements,n=e.text,o=e.start,a=e.end,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,s={formats:t.slice(0,i),replacements:r.slice(0,i),text:n.slice(0,i)},u={formats:t.slice(c),replacements:r.slice(c),text:n.slice(c),start:0,end:0};return[ce(s,/\u2028+$/,""),ce(u,/^\u2028+/,"")]}function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ye(e){for(var t=1;t1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}var Pe=function(){return _(document,"")};function _e(e,t){"string"==typeof t&&(t=e.ownerDocument.createTextNode(t));var r=t,n=r.type,o=r.attributes;if(n)for(var a in t=e.ownerDocument.createElement(n),o)t.setAttribute(a,o[a]);return e.appendChild(t)}function Se(e,t){e.appendData(t)}function Ce(e){return e.lastChild}function De(e){return e.parentNode}function Fe(e){return e.nodeType===Te}function Ne(e){return e.nodeValue}function Ae(e){return e.parentNode.removeChild(e)}function ke(e){var t=e.value,r=e.multilineTag,n=e.prepareEditableTree,o=e.isEditableTree,a=void 0===o||o,c=e.placeholder,s=[],u=[];return n&&(t=function(e){for(var t=1;t0){if(h=p,b=l.getRangeAt(0),h.startContainer===b.startContainer&&h.startOffset===b.startOffset&&h.endContainer===b.endContainer&&h.endOffset===b.endOffset)return;l.removeAllRanges()}var h,b;l.addRange(p),d!==document.activeElement&&d instanceof window.HTMLElement&&d.focus()}(s,r)}var Ie=r(68);function Le(e){return Ge(je({value:e.value,multilineTag:e.multilineTag,preserveWhiteSpace:e.preserveWhiteSpace,createEmpty:We,append:He,getLastChild:Me,getParent:Ve,isText:Be,getText:Ue,remove:ze,appendText:Ke}).children)}function We(){return{}}function Me(e){var t=e.children;return t&&t[t.length-1]}function He(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Ke(e,t){e.text+=t}function Ve(e){return e.parent}function Be(e){return"string"==typeof e.text}function Ue(e){return e.text}function ze(e){var t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function qe(e){var t=e.type,r=e.attributes,n=e.object,o=e.children,a="";for(var i in r)Object(Ie.isValidAttributeName)(i)&&(a+=" ".concat(i,'="').concat(Object(Ie.escapeAttribute)(r[i]),'"'));return n?"<".concat(t).concat(a,">"):"<".concat(t).concat(a,">").concat(Ge(o),"")}function Ge(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map((function(e){return void 0===e.text?qe(e):Object(Ie.escapeEditableHTML)(e.text)})).join("")}function Ye(e,t){return B(e,t.type)?ne(e,t.type):x(e,t)}function $e(e){var t=Object(a.select)("core/rich-text").getFormatType(e);if(t)return Object(a.dispatch)("core/rich-text").removeFormatTypes(e),t;window.console.error("Format ".concat(e," is not registered."))}function Xe(e){var t=q(e);if(void 0===t)return!1;var r=e.replacements,n=q(e,t),o=r[t]||[],a=r[n]||[];return o.length<=a.length}function Ze(e){return void 0!==e.replacements[q(e,e.start)]}function Je(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Qe(e,t){if(!Xe(e))return e;for(var r=q(e),n=q(e,r),o=e.text,a=e.replacements,c=e.end,s=a.slice(),u=function(e,t){for(var r=e.text,n=e.replacements,o=n[t]||[],a=t;a-- >=0;)if("\u2028"===r[a]){var i=n[a]||[];if(i.length===o.length+1)return a;if(i.length<=o.length)return}}(e,r),l=r;l=0;){if("\u2028"===r[a])if((n[a]||[]).length===o.length-1)return a}}function tt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function rt(e){if(!Ze(e))return e;for(var t=e.text,r=e.replacements,n=e.start,o=e.end,a=q(e,n),c=r.slice(0),s=r[et(e,a)]||[],u=function(e,t){for(var r=e.text,n=e.replacements,o=n[t]||[],a=t,i=t||0;i=o.length))return a;a=i}return a}(e,q(e,o)),l=a;l<=u;l++)if("\u2028"===t[l]){var f=c[l]||[];c[l]=s.concat(f.slice(s.length+1)),0===c[l].length&&delete c[l]}return function(e){for(var t=1;th?e:t})))}return r?function(e){for(var t=1;t0?o.getRangeAt(0):null;return A({element:r.current,range:a,multilineTag:t,multilineWrapperTags:"li"===t?["ul","ol"]:void 0,__unstableIsEditableTree:!0,preserveWhiteSpace:n})}},{key:"applyRecord",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.domOnly,n=this.props,o=n.__unstableMultilineTag,a=n.forwardedRef;Re({value:e,current:a.current,multilineTag:o,multilineWrapperTags:"li"===o?["ul","ol"]:void 0,prepareEditableTree:Lt(this.props,"format_prepare_functions"),__unstableDomOnly:r,placeholder:this.props.placeholder})}},{key:"onPaste",value:function(e){var t=this.props,r=t.formatTypes,n=t.onPaste,o=t.__unstableIsSelected,a=this.state.activeFormats,i=void 0===a?[]:a;if(o){var s=e.clipboardData,u=s.items,l=s.files;u=Object(c.isNil)(u)?[]:u,l=Object(c.isNil)(l)?[]:l;var f="",p="";try{f=s.getData("text/plain"),p=s.getData("text/html")}catch(e){try{p=s.getData("Text")}catch(e){return}}e.preventDefault(),window.console.log("Received HTML:\n\n",p),window.console.log("Received plain text:\n\n",f);var d=this.record,h=r.reduce((function(e,t){var r=t.__unstablePasteRule;return r&&e===d&&(e=r(d,{html:p,plainText:f})),e}),d);h===d?n&&(l=Array.from(l),Array.from(u).forEach((function(e){if(e.getAsFile){var t=e.getAsFile();if(t){var r=t.name,n=t.type,o=t.size;Object(c.find)(l,{name:r,type:n,size:o})||l.push(t)}}})),n({value:this.removeEditorOnlyFormats(d),onChange:this.onChange,html:p,plainText:f,files:l,activeFormats:i})):this.onChange(h)}else e.preventDefault()}},{key:"onFocus",value:function(){var e=this.props.unstableOnFocus;if(e&&e(),this.props.__unstableIsSelected)this.props.onSelectionChange(this.record.start,this.record.end),this.setState({activeFormats:V(Dt({},this.record,{activeFormats:void 0}),It)});else{var t=It;this.record=Dt({},this.record,{start:void 0,end:void 0,activeFormats:t}),this.props.onSelectionChange(void 0,void 0),this.setState({activeFormats:t})}this.rafId=window.requestAnimationFrame(this.onSelectionChange),document.addEventListener("selectionchange",this.onSelectionChange),this.props.setFocusedElement&&(Ot()("wp.blockEditor.RichText setFocusedElement prop",{alternative:"selection state from the block editor store."}),this.props.setFocusedElement(this.props.instanceId))}},{key:"onBlur",value:function(){document.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"onInput",value:function(e){var t;if(!this.isComposing)if(e&&(t=e.inputType),!t&&e&&e.nativeEvent&&(t=e.nativeEvent.inputType),!t||0!==t.indexOf("format")&&!kt.has(t)){var r=this.createRecord(),n=this.record,o=n.start,a=n.activeFormats,i=void 0===a?[]:a,c=function(e){var t=e.value,r=e.start,n=e.end,o=e.formats,a=t.formats[r-1]||[],i=t.formats[n]||[];for(t.activeFormats=o.map((function(e,t){if(a[t]){if(y(e,a[t]))return a[t]}else if(i[t]&&y(e,i[t]))return i[t];return e}));--n>=r;)t.activeFormats.length>0?t.formats[n]=t.activeFormats:delete t.formats[n];return t}({value:r,start:o,end:r.start,formats:i});this.onChange(c,{withoutHistory:!0});var s=this.props,u=s.__unstableInputRule,l=s.__unstableMarkAutomaticChange,f=s.__unstableAllowPrefixTransformations,p=s.formatTypes,d=s.setTimeout;if((0,s.clearTimeout)(this.onInput.timeout),this.onInput.timeout=d(this.onCreateUndoLevel,1e3),"insertText"===t){f&&u&&u(c,this.valueToFormat);var h=p.reduce((function(e,t){var r=t.__unstableInputRule;return r&&(e=r(e)),e}),c);h!==c&&(this.onCreateUndoLevel(),this.onChange(Dt({},h,{activeFormats:i})),l())}}else this.applyRecord(this.record)}},{key:"onCompositionStart",value:function(){this.isComposing=!0,document.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"onCompositionEnd",value:function(){this.isComposing=!1,this.onInput({inputType:"insertText"}),document.addEventListener("selectionchange",this.onSelectionChange)}},{key:"onSelectionChange",value:function(e){if(("selectionchange"===e.type||this.props.__unstableIsSelected)&&!this.props.disabled&&!this.isComposing){var t=this.createRecord(),r=t.start,n=t.end,o=t.text,a=this.record;if(o===a.text)if(r!==a.start||n!==a.end){var i=this.props,c=i.__unstableIsCaretWithinFormattedText,s=i.__unstableOnEnterFormattedText,u=i.__unstableOnExitFormattedText,l=Dt({},a,{start:r,end:n,activeFormats:void 0}),f=V(l,It);l.activeFormats=f,!c&&f.length?s():c&&!f.length&&u(),this.record=l,this.applyRecord(l,{domOnly:!0}),this.props.onSelectionChange(r,n),this.setState({activeFormats:f})}else 0===a.text.length&&0===r&&function(){var e=window.getSelection(),t=e.anchorNode,r=e.anchorOffset;if(t.nodeType===t.ELEMENT_NODE){var n=t.childNodes[r];n&&n.nodeType===n.ELEMENT_NODE&&n.getAttribute("data-rich-text-placeholder")&&e.collapseToStart()}}();else this.onInput()}}},{key:"onChange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.withoutHistory;this.applyRecord(e);var n=e.start,o=e.end,a=e.activeFormats,i=void 0===a?[]:a,s=Object(c.pickBy)(this.props,(function(e,t){return t.startsWith("format_on_change_functions_")}));Object.values(s).forEach((function(t){t(e.formats,e.text)})),this.value=this.valueToFormat(e),this.record=e,this.props.onSelectionChange(n,o),this.props.onChange(this.value),this.setState({activeFormats:i}),r||this.onCreateUndoLevel()}},{key:"onCreateUndoLevel",value:function(){this.lastHistoryValue!==this.value&&(this.props.__unstableOnCreateUndoLevel(),this.lastHistoryValue=this.value)}},{key:"handleDelete",value:function(e){var t=e.keyCode;if(t===bt.DELETE||t===bt.BACKSPACE||t===bt.ESCAPE){if(this.props.__unstableDidAutomaticChange)return e.preventDefault(),void this.props.__unstableUndo();if(t!==bt.ESCAPE){var r,n=this.props,o=n.onDelete,a=n.__unstableMultilineTag,i=this.state.activeFormats,c=void 0===i?[]:i,s=this.createRecord(),u=s.start,l=s.end,f=s.text,p=t===bt.BACKSPACE;if(0===u&&0!==l&&l===f.length)return this.onChange(ie(s)),void e.preventDefault();if(a)if(r=p&&0===s.start&&0===s.end&&Z(s)?fe(s,!p):fe(s,p))return this.onChange(r),void e.preventDefault();!o||!$(s)||c.length||p&&0!==u||!p&&l!==f.length||(o({isReverse:p,value:s}),e.preventDefault())}}}},{key:"handleEnter",value:function(e){if(e.keyCode===bt.ENTER){e.preventDefault();var t=this.props.onEnter;t&&t({value:this.removeEditorOnlyFormats(this.createRecord()),onChange:this.onChange,shiftKey:e.shiftKey})}}},{key:"handleSpace",value:function(e){var t=e.keyCode,r=e.shiftKey,n=e.altKey,o=e.metaKey,a=e.ctrlKey,i=this.props,c=i.tagName,s=i.__unstableMultilineTag;if(!(r||n||o||a||t!==bt.SPACE||"li"!==s)){var u=this.createRecord();if($(u)){var l=u.text[u.start-1];l&&"\u2028"!==l||(this.onChange(Qe(u,{type:c})),e.preventDefault())}}}},{key:"handleHorizontalNavigation",value:function(e){var t=e.keyCode,r=e.shiftKey,n=e.altKey,o=e.metaKey,a=e.ctrlKey;if(!(r||n||o||a||t!==bt.LEFT&&t!==bt.RIGHT)){var i=this.record,c=i.text,s=i.formats,u=i.start,l=i.end,f=i.activeFormats,p=void 0===f?[]:f,d=$(i),h="rtl"===At(this.props.forwardedRef.current).direction?bt.RIGHT:bt.LEFT,b=e.keyCode===h;if(d&&0===p.length){if(0===u&&b)return;if(l===c.length&&!b)return}if(d){e.preventDefault();var m=s[u-1]||It,v=s[u]||It,g=p.length,y=v;if(m.length>v.length&&(y=m),m.lengthm.length&&g--):m.length>v.length&&(!b&&p.length>v.length&&g--,b&&p.length