WordPress/wp-includes/js/dist/rich-text.min.js

2 lines
36 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.richText=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./node_modules/@wordpress/rich-text/build-module/index.js")}({"./node_modules/@wordpress/rich-text/build-module/index.js":function(e,t,n){"use strict";n.r(t),n.d(t,"store",(function(){return g})),n.d(t,"applyFormat",(function(){return v})),n.d(t,"concat",(function(){return L})),n.d(t,"create",(function(){return w})),n.d(t,"getActiveFormat",(function(){return P})),n.d(t,"getActiveObject",(function(){return W})),n.d(t,"getTextContent",(function(){return k})),n.d(t,"__unstableIsListRootSelected",(function(){return $})),n.d(t,"__unstableIsActiveListType",(function(){return H})),n.d(t,"isCollapsed",(function(){return V})),n.d(t,"isEmpty",(function(){return K})),n.d(t,"__unstableIsEmptyLine",(function(){return B})),n.d(t,"join",(function(){return z})),n.d(t,"registerFormatType",(function(){return U})),n.d(t,"removeFormat",(function(){return G})),n.d(t,"remove",(function(){return Y})),n.d(t,"replace",(function(){return Z})),n.d(t,"insert",(function(){return X})),n.d(t,"__unstableInsertLineSeparator",(function(){return J})),n.d(t,"__unstableRemoveLineSeparator",(function(){return Q})),n.d(t,"insertObject",(function(){return ee})),n.d(t,"slice",(function(){return te})),n.d(t,"split",(function(){return ne})),n.d(t,"__unstableToDom",(function(){return he})),n.d(t,"toHTMLString",(function(){return ve})),n.d(t,"toggleFormat",(function(){return Ae})),n.d(t,"__UNSTABLE_LINE_SEPARATOR",(function(){return T})),n.d(t,"unregisterFormatType",(function(){return Ne})),n.d(t,"__unstableCanIndentListItems",(function(){return Se})),n.d(t,"__unstableCanOutdentListItems",(function(){return De})),n.d(t,"__unstableIndentListItems",(function(){return Re})),n.d(t,"__unstableOutdentListItems",(function(){return Ie})),n.d(t,"__unstableChangeListType",(function(){return Pe})),n.d(t,"__unstableCreateElement",(function(){return x})),n.d(t,"useAnchorRef",(function(){return ke})),n.d(t,"__experimentalRichText",(function(){return Qe})),n.d(t,"__unstableFormatEdit",(function(){return Ve}));var r={};n.r(r),n.d(r,"getFormatTypes",(function(){return l})),n.d(r,"getFormatType",(function(){return u})),n.d(r,"getFormatTypeForBareElement",(function(){return f})),n.d(r,"getFormatTypeForClassName",(function(){return d}));var a={};n.r(a),n.d(a,"addFormatTypes",(function(){return m})),n.d(a,"removeFormatTypes",(function(){return p}));var o=n("@wordpress/data"),i=n("lodash");var s=Object(o.combineReducers)({formatTypes:function(e={},t){switch(t.type){case"ADD_FORMAT_TYPES":return{...e,...Object(i.keyBy)(t.formatTypes,"name")};case"REMOVE_FORMAT_TYPES":return Object(i.omit)(e,t.names)}return e}}),c=n("./node_modules/rememo/es/rememo.js");const l=Object(c.a)(e=>Object.values(e.formatTypes),e=>[e.formatTypes]);function u(e,t){return e.formatTypes[t]}function f(e,t){return Object(i.find)(l(e),({className:e,tagName:n})=>null===e&&t===n)}function d(e,t){return Object(i.find)(l(e),({className:e})=>null!==e&&` ${t} `.indexOf(` ${e} `)>=0)}function m(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Object(i.castArray)(e)}}function p(e){return{type:"REMOVE_FORMAT_TYPES",names:Object(i.castArray)(e)}}const g=Object(o.createReduxStore)("core/rich-text",{reducer:s,selectors:r,actions:a});function h(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.type!==t.type)return!1;const n=e.attributes,r=t.attributes;if(n===r)return!0;if(!n||!r)return!1;const a=Object.keys(n),o=Object.keys(r);if(a.length!==o.length)return!1;const i=a.length;for(let e=0;e<i;e++){const t=a[e];if(n[t]!==r[t])return!1}return!0}function b(e){const t=e.formats.slice();return t.forEach((e,n)=>{const r=t[n-1];if(r){const a=e.slice();a.forEach((e,t)=>{const n=r[t];h(e,n)&&(a[t]=n)}),t[n]=a}}),{...e,formats:t}}function y(e,t,n){return(e=e.slice())[t]=n,e}function v(e,t,n=e.start,r=e.end){const{formats:a,activeFormats:o}=e,s=a.slice();if(n===r){const e=Object(i.find)(s[n],{type:t.type});if(e){const a=s[n].indexOf(e);for(;s[n]&&s[n][a]===e;)s[n]=y(s[n],a,t),n--;for(r++;s[r]&&s[r][a]===e;)s[r]=y(s[r],a,t),r++}}else{let e=1/0;for(let a=n;a<r;a++)if(s[a]){s[a]=s[a].filter(({type:e})=>e!==t.type);const n=s[a].length;n<e&&(e=n)}else s[a]=[],e=0;for(let a=n;a<r;a++)s[a].splice(e,0,t)}return b({...e,formats:s,activeFormats:[...Object(i.reject)(o,{type:t.type}),t]})}function x({implementation:e},t){return x.body||(x.body=e.createHTMLDocument("").body),x.body.innerHTML=t,x.body}Object(o.register)(g);const T="\u2028";function E(e,t){for(const n in e)if(e[n]===t)return n}function O({type:e,attributes:t}){let n;if(t&&t.class&&(n=Object(o.select)("core/rich-text").getFormatTypeForClassName(t.class),n&&(t.class=` ${t.class} `.replace(` ${n.className} `," ").trim(),t.class||delete t.class)),n||(n=Object(o.select)("core/rich-text").getFormatTypeForBareElement(e)),!n)return t?{type:e,attributes:t}:{type:e};if(n.__experimentalCreatePrepareEditableTree&&!n.__experimentalCreateOnChangeEditableValue)return null;if(!t)return{type:n.name};const r={},a={};for(const e in t){const o=E(n.attributes,e);o?r[o]=t[e]:a[e]=t[e]}return{type:n.name,attributes:r,unregisteredAttributes:a}}function w({element:e,text:t,html:n,range:r,multilineTag:a,multilineWrapperTags:o,__unstableIsEditableTree:i,preserveWhiteSpace:s}={}){return"string"==typeof t&&t.length>0?{formats:Array(t.length),replacements:Array(t.length),text:t}:("string"==typeof n&&n.length>0&&(e=x(document,n)),"object"!=typeof e?{formats:[],replacements:[],text:""}:a?S({element:e,range:r,multilineTag:a,multilineWrapperTags:o,isEditableTree:i,preserveWhiteSpace:s}):N({element:e,range:r,isEditableTree:i,preserveWhiteSpace:s}))}function _(e,t,n,r){if(!n)return;const{parentNode:a}=t,{startContainer:o,startOffset:i,endContainer:s,endOffset:c}=n,l=e.text.length;void 0!==r.start?e.start=l+r.start:t===o&&t.nodeType===t.TEXT_NODE?e.start=l+i:a===o&&t===o.childNodes[i]?e.start=l:a===o&&t===o.childNodes[i-1]?e.start=l+r.text.length:t===o&&(e.start=l),void 0!==r.end?e.end=l+r.end:t===s&&t.nodeType===t.TEXT_NODE?e.end=l+c:a===s&&t===s.childNodes[c-1]?e.end=l+r.text.length:a===s&&t===s.childNodes[c]?e.end=l:t===s&&(e.end=l+c)}function j(e,t,n){if(!t)return;const{startContainer:r,endContainer:a}=t;let{startOffset:o,endOffset:i}=t;return e===r&&(o=n(e.nodeValue.slice(0,o)).length),e===a&&(i=n(e.nodeValue.slice(0,i)).length),{startContainer:r,startOffset:o,endContainer:a,endOffset:i}}function F(e){return e.replace(/[\n\r\t]+/g," ")}const C=new RegExp("\ufeff","g");function A(e){return e.replace(C,"")}function N({element:e,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a=[],isEditableTree:o,preserveWhiteSpace:i}){const s={formats:[],replacements:[],text:""};if(!e)return s;if(!e.hasChildNodes())return _(s,e,t,{formats:[],replacements:[],text:""}),s;const c=e.childNodes.length;for(let u=0;u<c;u++){const c=e.childNodes[u],f=c.nodeName.toLowerCase();if(c.nodeType===c.TEXT_NODE){let e=A;i||(e=e=>A(F(e)));const n=e(c.nodeValue);_(s,c,t=j(c,t,e),{text:n}),s.formats.length+=n.length,s.replacements.length+=n.length,s.text+=n;continue}if(c.nodeType!==c.ELEMENT_NODE)continue;if(o&&(c.getAttribute("data-rich-text-placeholder")||"br"===f&&!c.getAttribute("data-rich-text-line-break"))){_(s,c,t,{formats:[],replacements:[],text:""});continue}if("br"===f){_(s,c,t,{formats:[],replacements:[],text:""}),R(s,w({text:"\n"}));continue}const d=s.formats[s.formats.length-1],m=d&&d[d.length-1],p=O({type:f,attributes:D({element:c})}),g=h(p,m)?m:p;if(r&&-1!==r.indexOf(f)){const e=S({element:c,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:[...a,g],isEditableTree:o,preserveWhiteSpace:i});_(s,c,t,e),R(s,e);continue}const b=N({element:c,range:t,multilineTag:n,multilineWrapperTags:r,isEditableTree:o,preserveWhiteSpace:i});if(_(s,c,t,b),g)if(0===b.text.length)g.attributes&&R(s,{formats:[,],replacements:[g],text:""});else{function l(e){if(l.formats===e)return l.newFormats;const t=e?[g,...e]:[g];return l.formats=e,l.newFormats=t,t}l.newFormats=[g],R(s,{...b,formats:Array.from(b.formats,l)})}else R(s,b)}return s}function S({element:e,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a=[],isEditableTree:o,preserveWhiteSpace:i}){const s={formats:[],replacements:[],text:""};if(!e||!e.hasChildNodes())return s;const c=e.children.length;for(let l=0;l<c;l++){const c=e.children[l];if(c.nodeName.toLowerCase()!==n)continue;const u=N({element:c,range:t,multilineTag:n,multilineWrapperTags:r,currentWrapperTags:a,isEditableTree:o,preserveWhiteSpace:i});(0!==l||a.length>0)&&R(s,{formats:[,],replacements:a.length>0?[a]:[,],text:T}),_(s,c,t,u),R(s,u)}return s}function D({element:e}){if(!e.hasAttributes())return;const t=e.attributes.length;let n;for(let r=0;r<t;r++){const{name:t,value:a}=e.attributes[r];0!==t.indexOf("data-rich-text-")&&(n=n||{},n[t]=a)}return n}function R(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function L(...e){return b(e.reduce(R,w()))}function I({formats:e,start:t,end:n,activeFormats:r},a=[]){if(void 0===t)return a;if(t===n){if(r)return r;const n=e[t-1]||a,o=e[t]||a;return n.length<o.length?n:o}return e[t]||a}function P(e,t){return Object(i.find)(I(e),{type:t})}function W({start:e,end:t,replacements:n,text:r}){if(e+1===t&&""===r[e])return n[e]}function k({text:e}){return e.replace(new RegExp("","g"),"").replace(new RegExp(T,"g"),"\n")}function M({start:e,text:t},n=e){let r=n;for(;r--;)if(t[r]===T)return r}function $(e){const{replacements:t,start:n}=e,r=t[M(e,n)];return!r||r.length<1}function H(e,t,n){const{replacements:r,start:a}=e,o=r[M(e,a)];if(!o||0===o.length)return t===n;return o[o.length-1].type===t}function V({start:e,end:t}){if(void 0!==e&&void 0!==t)return e===t}function K({text:e}){return 0===e.length}function B({text:e,start:t,end:n}){return t===n&&(0===e.length||(0===t&&e.slice(0,1)===T||(t===e.length&&e.slice(-1)===T||e.slice(t-1,n+1)===`${T}${T}`)))}function z(e,t=""){return"string"==typeof t&&(t=w({text:t})),b(e.reduce((e,{formats:n,replacements:r,text:a})=>({formats:e.formats.concat(t.formats,n),replacements:e.replacements.concat(t.replacements,r),text:e.text+t.text+a})))}function U(e,t){if("string"==typeof(t={name:e,...t}).name)if(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(t.name))if(Object(o.select)(g).getFormatType(t.name))window.console.error('Format "'+t.name+'" is already registered.');else if("string"==typeof t.tagName&&""!==t.tagName)if("string"==typeof t.className&&""!==t.className||null===t.className)if(/^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test(t.className)){if(null===t.className){const e=Object(o.select)(g).getFormatTypeForBareElement(t.tagName);if(e)return void window.console.error(`Format "${e.name}" is already registered to handle bare tag name "${t.tagName}".`)}else{const e=Object(o.select)(g).getFormatTypeForClassName(t.className);if(e)return void window.console.error(`Format "${e.name}" is already registered to handle class name "${t.className}".`)}if("title"in t&&""!==t.title)if("keywords"in t&&t.keywords.length>3)window.console.error('The format "'+t.name+'" can have a maximum of 3 keywords.');else{if("string"==typeof t.title)return Object(o.dispatch)(g).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 G(e,t,n=e.start,r=e.end){const{formats:a,activeFormats:o}=e,s=a.slice();if(n===r){const e=Object(i.find)(s[n],{type:t});if(e){for(;Object(i.find)(s[n],e);)q(s,n,t),n--;for(r++;Object(i.find)(s[r],e);)q(s,r,t),r++}}else for(let e=n;e<r;e++)s[e]&&q(s,e,t);return b({...e,formats:s,activeFormats:Object(i.reject)(o,{type:t})})}function q(e,t,n){const r=e[t].filter(({type:e})=>e!==n);r.length?e[t]=r:delete e[t]}function X(e,t,n=e.start,r=e.end){const{formats:a,replacements:o,text:i}=e;"string"==typeof t&&(t=w({text:t}));const s=n+t.text.length;return b({formats:a.slice(0,n).concat(t.formats,a.slice(r)),replacements:o.slice(0,n).concat(t.replacements,o.slice(r)),text:i.slice(0,n)+t.text+i.slice(r),start:s,end:s})}function Y(e,t,n){return X(e,w(),t,n)}function Z({formats:e,replacements:t,text:n,start:r,end:a},o,i){return n=n.replace(o,(n,...o)=>{const s=o[o.length-2];let c,l,u=i;return"function"==typeof u&&(u=i(n,...o)),"object"==typeof u?(c=u.formats,l=u.replacements,u=u.text):(c=Array(u.length),l=Array(u.length),e[s]&&(c=c.fill(e[s]))),e=e.slice(0,s).concat(c,e.slice(s+n.length)),t=t.slice(0,s).concat(l,t.slice(s+n.length)),r&&(r=a=s+u.length),u}),b({formats:e,replacements:t,text:n,start:r,end:a})}function J(e,t=e.start,n=e.end){const r=e.text.slice(0,t).lastIndexOf(T),a=e.replacements[r];let o=[,];a&&(o=[a]);return X(e,{formats:[,],replacements:o,text:T},t,n)}function Q(e,t=!0){const{replacements:n,text:r,start:a,end:o}=e,i=V(e);let s,c=a-1,l=i?a-1:a,u=o;if(t||(c=o,l=a,u=i?o+1:o),r[c]===T){if(i&&n[c]&&n[c].length){const t=n.slice();t[c]=n[c].slice(0,-1),s={...e,replacements:t}}else s=Y(e,l,u);return s}}function ee(e,t,n,r){return X(e,{formats:[,],replacements:[t],text:""},n,r)}function te(e,t=e.start,n=e.end){const{formats:r,replacements:a,text:o}=e;return void 0===t||void 0===n?{...e}:{formats:r.slice(t,n),replacements:a.slice(t,n),text:o.slice(t,n)}}function ne({formats:e,replacements:t,text:n,start:r,end:a},o){if("string"!=typeof o)return re(...arguments);let i=0;return n.split(o).map(n=>{const s=i,c={formats:e.slice(s,s+n.length),replacements:t.slice(s,s+n.length),text:n};return i+=o.length+n.length,void 0!==r&&void 0!==a&&(r>=s&&r<i?c.start=r-s:r<s&&a>s&&(c.start=0),a>=s&&a<i?c.end=a-s:r<i&&a>i&&(c.end=n.length)),c})}function re({formats:e,replacements:t,text:n,start:r,end:a},o=r,i=a){const s={formats:e.slice(0,o),replacements:t.slice(0,o),text:n.slice(0,o)},c={formats:e.slice(i),replacements:t.slice(i),text:n.slice(i),start:0,end:0};return[Z(s,/\u2028+$/,""),Z(c,/^\u2028+/,"")]}function ae({type:e,attributes:t,unregisteredAttributes:n,object:r,boundaryClass:a}){const i=(s=e,Object(o.select)(g).getFormatType(s));var s;let c={};if(a&&(c["data-rich-text-format-boundary"]="true"),!i)return t&&(c={...t,...c}),{type:e,attributes:c,object:r};c={...n,...c};for(const e in t){const n=!!i.attributes&&i.attributes[e];n?c[n]=t[e]:c[e]=t[e]}return i.className&&(c.class?c.class=`${i.className} ${c.class}`:c.class=i.className),{type:i.tagName,object:i.object,attributes:c}}function oe(e,t,n){do{if(e[n]!==t[n])return!1}while(n--);return!0}function ie({value:e,multilineTag:t,preserveWhiteSpace:n,createEmpty:r,append:a,getLastChild:o,getParent:i,isText:s,getText:c,remove:l,appendText:u,onStartIndex:f,onEndIndex:d,isEditableTree:m,placeholder:p}){const{formats:g,replacements:h,text:b,start:y,end:v}=e,x=g.length+1,E=r(),O={type:t},w=I(e),_=w[w.length-1];let j,F,C;t?(a(a(E,{type:t}),""),F=j=[O]):a(E,"");for(let e=0;e<x;e++){const r=b.charAt(e),x=m&&(!C||C===T||"\n"===C);let w=g[e];t&&(w=r===T?j=(h[e]||[]).reduce((e,t)=>(e.push(t,O),e),[O]):[...j,...w||[]]);let A=o(E);if(x&&r===T){let e=A;for(;!s(e);)e=o(e);a(i(e),"\ufeff")}if(C===T){let t=A;for(;!s(t);)t=o(t);f&&y===e&&f(E,t),d&&v===e&&d(E,t)}w&&w.forEach((e,t)=>{if(A&&F&&oe(w,F,t)&&(r!==T||w.length-1!==t))return void(A=o(A));const{type:n,attributes:u,unregisteredAttributes:f}=e,d=m&&r!==T&&e===_,p=i(A),g=a(p,ae({type:n,attributes:u,unregisteredAttributes:f,boundaryClass:d}));s(A)&&0===c(A).length&&l(A),A=a(g,"")}),r!==T?(0===e&&(f&&0===y&&f(E,A),d&&0===v&&d(E,A)),""===r?(A=a(i(A),ae({...h[e],object:!0})),A=a(i(A),"")):n||"\n"!==r?s(A)?u(A,r):A=a(i(A),r):(A=a(i(A),{type:"br",attributes:m?{"data-rich-text-line-break":"true"}:void 0,object:!0}),A=a(i(A),"")),f&&y===e+1&&f(E,A),d&&v===e+1&&d(E,A),x&&e===b.length&&(a(i(A),"\ufeff"),p&&0===b.length&&a(i(A),{type:"span",attributes:{"data-rich-text-placeholder":p,contenteditable:"false",style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),F=w,C=r):(F=w,C=r)}return E}function se(e,t,n){const r=e.parentNode;let a=0;for(;e=e.previousSibling;)a++;return n=[a,...n],r!==t&&(n=se(r,t,n)),n}function ce(e,t){for(t=[...t];e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}function le(e,t){"string"==typeof t&&(t=e.ownerDocument.createTextNode(t));const{type:n,attributes:r}=t;if(n){t=e.ownerDocument.createElement(n);for(const e in r)t.setAttribute(e,r[e])}return e.appendChild(t)}function ue(e,t){e.appendData(t)}function fe({lastChild:e}){return e}function de({parentNode:e}){return e}function me(e){return e.nodeType===e.TEXT_NODE}function pe({nodeValue:e}){return e}function ge(e){return e.parentNode.removeChild(e)}function he({value:e,multilineTag:t,prepareEditableTree:n,isEditableTree:r=!0,placeholder:a,doc:o=document}){let i=[],s=[];n&&(e={...e,formats:n(e)});return{body:ie({value:e,multilineTag:t,createEmpty:()=>x(o,""),append:le,getLastChild:fe,getParent:de,isText:me,getText:pe,remove:ge,appendText:ue,onStartIndex(e,t){i=se(t,e,[t.nodeValue.length])},onEndIndex(e,t){s=se(t,e,[t.nodeValue.length])},isEditableTree:r,placeholder:a}),selection:{startPath:i,endPath:s}}}function be({value:e,current:t,multilineTag:n,prepareEditableTree:r,__unstableDomOnly:a,placeholder:o}){const{body:i,selection:s}=he({value:e,multilineTag:n,prepareEditableTree:r,placeholder:o,doc:t.ownerDocument});!function e(t,n){let r,a=0;for(;r=t.firstChild;){const o=n.childNodes[a];if(o)if(o.isEqualNode(r))t.removeChild(r);else if(o.nodeName!==r.nodeName||o.nodeType===o.TEXT_NODE&&o.data!==r.data)n.replaceChild(r,o);else{const n=o.attributes,a=r.attributes;if(n){let e=n.length;for(;e--;){const{name:t}=n[e];r.getAttribute(t)||o.removeAttribute(t)}}if(a)for(let e=0;e<a.length;e++){const{name:t,value:n}=a[e];o.getAttribute(t)!==n&&o.setAttribute(t,n)}e(r,o),t.removeChild(r)}else n.appendChild(r);a++}for(;n.childNodes[a];)n.removeChild(n.childNodes[a])}(i,t),void 0===e.start||a||function({startPath:e,endPath:t},n){const{node:r,offset:a}=ce(n,e),{node:o,offset:i}=ce(n,t),{ownerDocument:s}=n,{defaultView:c}=s,l=c.getSelection(),u=s.createRange();u.setStart(r,a),u.setEnd(o,i);const{activeElement:f}=s;if(l.rangeCount>0){if(d=u,m=l.getRangeAt(0),d.startContainer===m.startContainer&&d.startOffset===m.startOffset&&d.endContainer===m.endContainer&&d.endOffset===m.endOffset)return;l.removeAllRanges()}var d,m;l.addRange(u),f!==s.activeElement&&f instanceof c.HTMLElement&&f.focus()}(s,t)}var ye=n("@wordpress/escape-html");function ve({value:e,multilineTag:t,preserveWhiteSpace:n}){return Ce(ie({value:e,multilineTag:t,preserveWhiteSpace:n,createEmpty:xe,append:Ee,getLastChild:Te,getParent:we,isText:_e,getText:je,remove:Fe,appendText:Oe}).children)}function xe(){return{}}function Te({children:e}){return e&&e[e.length-1]}function Ee(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Oe(e,t){e.text+=t}function we({parent:e}){return e}function _e({text:e}){return"string"==typeof e}function je({text:e}){return e}function Fe(e){const t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function Ce(e=[]){return e.map(e=>void 0===e.text?function({type:e,attributes:t,object:n,children:r}){let a="";for(const e in t)Object(ye.isValidAttributeName)(e)&&(a+=` ${e}="${Object(ye.escapeAttribute)(t[e])}"`);return n?`<${e}${a}>`:`<${e}${a}>${Ce(r)}</${e}>`}(e):Object(ye.escapeEditableHTML)(e.text)).join("")}function Ae(e,t){return P(e,t.type)?G(e,t.type):v(e,t)}function Ne(e){const t=Object(o.select)(g).getFormatType(e);if(t)return Object(o.dispatch)(g).removeFormatTypes(e),t;window.console.error(`Format ${e} is not registered.`)}function Se(e){const t=M(e);if(void 0===t)return!1;const{replacements:n}=e,r=M(e,t),a=n[t]||[],o=n[r]||[];return a.length<=o.length}function De(e){const{replacements:t,start:n}=e;return void 0!==t[M(e,n)]}function Re(e,t){if(!Se(e))return e;const n=M(e),r=M(e,n),{text:a,replacements:o,end:i}=e,s=o.slice(),c=function({text:e,replacements:t},n){const r=t[n]||[];let a=n;for(;a-- >=0;){if(e[a]!==T)continue;const n=t[a]||[];if(n.length===r.length+1)return a;if(n.length<=r.length)return}}(e,n);for(let e=n;e<i;e++)if(a[e]===T)if(c){const t=o[c]||[];s[e]=t.concat((s[e]||[]).slice(t.length-1))}else{const n=o[r]||[],a=n[n.length-1]||t;s[e]=n.concat([a],(s[e]||[]).slice(n.length))}return{...e,replacements:s}}function Le({text:e,replacements:t},n){const r=t[n]||[];let a=n;for(;a-- >=0;){if(e[a]!==T)continue;if((t[a]||[]).length===r.length-1)return a}}function Ie(e){if(!De(e))return e;const{text:t,replacements:n,start:r,end:a}=e,o=M(e,r),i=n.slice(0),s=n[Le(e,o)]||[],c=function({text:e,replacements:t},n){const r=t[n]||[];let a=n;for(let o=n||0;o<e.length;o++){if(e[o]!==T)continue;if(!((t[o]||[]).length>=r.length))return a;a=o}return a}(e,M(e,a));for(let e=o;e<=c;e++){if(t[e]!==T)continue;const n=i[e]||[];i[e]=s.concat(n.slice(s.length+1)),0===i[e].length&&delete i[e]}return{...e,replacements:i}}function Pe(e,t){const{text:n,replacements:r,start:a,end:o}=e,i=M(e,a),s=r[i]||[],c=r[M(e,o)]||[],l=Le(e,i),u=r.slice(),f=s.length-1,d=c.length-1;let m;for(let e=l+1||0;e<n.length;e++)if(n[e]===T){if((u[e]||[]).length<=f)break;u[e]&&(m=!0,u[e]=u[e].map((e,n)=>n<f||n>d?e:t))}return m?{...e,replacements:u}:e}var We=n("@wordpress/element");function ke({ref:e,value:t,settings:n={}}){const{tagName:r,className:a,name:o}=n,i=o?P(t,o):void 0;return Object(We.useMemo)(()=>{if(!e.current)return;const{ownerDocument:{defaultView:t}}=e.current,n=t.getSelection();if(!n.rangeCount)return;const o=n.getRangeAt(0);if(!i)return o;let s=o.startContainer;for(s=s.nextElementSibling||s;s.nodeType!==s.ELEMENT_NODE;)s=s.parentNode;return s.closest(r+(a?"."+a:""))},[i,t.start,t.end,r,a])}var Me=n("@wordpress/keycodes"),$e=n("@wordpress/dom"),He=n("@wordpress/compose");function Ve({formatTypes:e,onChange:t,onFocus:n,value:r,forwardedRef:a}){return e.map(e=>{const{name:o,edit:i}=e;if(!i)return null;const s=P(r,o),c=void 0!==s,l=W(r),u=void 0!==l&&l.type===o;return Object(We.createElement)(i,{key:o,isActive:c,activeAttributes:c&&s.attributes||{},isObjectActive:u,activeObjectAttributes:u&&l.attributes||{},value:r,onChange:t,onFocus:n,contentRef:a})})}function Ke(e){return e(g).getFormatTypes()}const Be=new Set(["a","audio","button","details","embed","iframe","input","label","select","textarea","video"]);function ze(e){const t=Object(We.useRef)(e);return t.current=e,Object(He.useRefEffect)(e=>{function n(n){const{record:r,multilineTag:a,preserveWhiteSpace:o}=t.current;if(V(r.current)||!e.contains(e.ownerDocument.activeElement))return;const i=te(r.current),s=k(i),c=ve({value:i,multilineTag:a,preserveWhiteSpace:o});n.clipboardData.setData("text/plain",s),n.clipboardData.setData("text/html",c),n.clipboardData.setData("rich-text","true"),n.preventDefault()}return e.addEventListener("copy",n),()=>{e.removeEventListener("copy",n)}},[])}const Ue=[];function Ge(e){const t=Object(We.useRef)(e);return t.current=e,Object(He.useRefEffect)(e=>{function n(n){const{keyCode:r,shiftKey:a,altKey:o,metaKey:i,ctrlKey:s}=n;if(a||o||i||s||r!==Me.LEFT&&r!==Me.RIGHT)return;const{record:c,applyRecord:l,setActiveFormats:u}=t.current,{text:f,formats:d,start:m,end:p,activeFormats:g=[]}=c.current,h=V(c.current),{ownerDocument:b}=e,{defaultView:y}=b,{direction:v}=y.getComputedStyle(e),x="rtl"===v?Me.RIGHT:Me.LEFT,T=n.keyCode===x;if(h&&0===g.length){if(0===m&&T)return;if(p===f.length&&!T)return}if(!h)return;const E=d[m-1]||Ue,O=d[m]||Ue;let w=g.length,_=O;if(E.length>O.length&&(_=E),E.length<O.length?(!T&&g.length<O.length&&w++,T&&g.length>E.length&&w--):E.length>O.length&&(!T&&g.length>O.length&&w--,T&&g.length<E.length&&w++),w===g.length)return void(c.current._newActiveFormats=T?E:O);n.preventDefault();const j=_.slice(0,w),F={...c.current,activeFormats:j};c.current=F,l(F),u(j)}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}function qe(e){const t=Object(We.useRef)(e);return t.current=e,Object(He.useRefEffect)(e=>{function n(e){const{keyCode:n}=e,{didAutomaticChange:r,undo:a}=t.current;r&&a&&(n!==Me.DELETE&&n!==Me.BACKSPACE&&n!==Me.ESCAPE||(e.preventDefault(),a()))}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}},[])}const Xe=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),Ye={whiteSpace:"pre-wrap",minWidth:"1px"},Ze=[];function Je(e){return t=>e.reduce((e,n)=>n(e,t.text),t.formats)}var Qe=Object(We.forwardRef)((function({tagName:e="div",value:t="",selectionStart:n,selectionEnd:r,children:a,allowedFormats:i,withoutInteractiveFormatting:s,placeholder:c,disabled:l,preserveWhiteSpace:u,onPaste:f,format:d="string",onDelete:m,onEnter:p,onSelectionChange:g,onChange:b,unstableOnFocus:y,clientId:v,identifier:x,__unstableMultilineTag:E,__unstableMultilineRootTag:O,__unstableDisableFormats:_,__unstableDidAutomaticChange:j,__unstableInputRule:F,__unstableMarkAutomaticChange:C,__unstableAllowPrefixTransformations:A,__unstableUndo:N,__unstableIsCaretWithinFormattedText:S,__unstableOnEnterFormattedText:D,__unstableOnExitFormattedText:R,__unstableOnCreateUndoLevel:L,__unstableIsSelected:P},W){const k=Object(We.useRef)(),[M=[],$]=Object(We.useState)(),{formatTypes:H,prepareHandlers:K,valueHandlers:z,changeHandlers:U,dependencies:q}=function({clientId:e,identifier:t,withoutInteractiveFormatting:n,allowedFormats:r}){const a=Object(o.useSelect)(Ke,[]),i=Object(We.useMemo)(()=>a.filter(({name:e,tagName:t})=>!(r&&!r.includes(e))&&(!n||!Be.has(t))),[a,r,Be]),s=Object(o.useSelect)(n=>i.reduce((r,a)=>(a.__experimentalGetPropsForEditableTreePreparation&&(r[a.name]=a.__experimentalGetPropsForEditableTreePreparation(n,{richTextIdentifier:t,blockClientId:e})),r),{}),[i,e,t]),c=Object(o.useDispatch)(),l=[],u=[],f=[],d=[];return i.forEach(n=>{if(n.__experimentalCreatePrepareEditableTree){const r=s[n.name],a=n.__experimentalCreatePrepareEditableTree(r,{richTextIdentifier:t,blockClientId:e});n.__experimentalCreateOnChangeEditableValue?u.push(a):l.push(a);for(const e in r)d.push(r[e])}if(n.__experimentalCreateOnChangeEditableValue){let r={};n.__experimentalGetPropsForEditableTreeChangeHandler&&(r=n.__experimentalGetPropsForEditableTreeChangeHandler(c,{richTextIdentifier:t,blockClientId:e})),f.push(n.__experimentalCreateOnChangeEditableValue({...s[n.name]||{},...r},{richTextIdentifier:t,blockClientId:e}))}}),{formatTypes:i,prepareHandlers:l,valueHandlers:u,changeHandlers:f,dependencies:d}}({clientId:v,identifier:x,withoutInteractiveFormatting:s,allowedFormats:i});function Z(){return k.current.ownerDocument}function J(){return Z().defaultView}function ee(e){if(_)return{text:e,formats:Array(e.length),replacements:Array(e.length)};if("string"!==d)return e;const t=Je(z),n=w({html:e,multilineTag:E,multilineWrapperTags:"li"===E?["ul","ol"]:void 0,preserveWhiteSpace:u});return n.formats=t(n),n}function te(e){return H.forEach(t=>{t.__experimentalCreatePrepareEditableTree&&(e=G(e,t.name,0,e.text.length))}),e}function ne(e){return _?e.text:(e=te(e),"string"===d?ve({value:e,multilineTag:E,preserveWhiteSpace:u}):void 0)}O||"string"!=typeof e||(O=e);const re=Object(We.useRef)(t),ae=Object(We.useRef)(Object(We.useMemo)(()=>{const e=ee(t);return e.start=n,e.end=r,e},[]));function oe(){const e=J().getSelection(),t=e.rangeCount>0?e.getRangeAt(0):null;return w({element:k.current,range:t,multilineTag:E,multilineWrapperTags:"li"===E?["ul","ol"]:void 0,__unstableIsEditableTree:!0,preserveWhiteSpace:u})}function ie(e,{domOnly:t}={}){be({value:e,current:k.current,multilineTag:E,multilineWrapperTags:"li"===E?["ul","ol"]:void 0,prepareEditableTree:Je(K),__unstableDomOnly:t,placeholder:c})}const se=Object(We.useRef)(t);function ce(){se.current!==re.current&&(L(),se.current=re.current)}const le=Object(We.useRef)(!1),ue=Object(We.useRef)();function fe(e){if(le.current)return;let t;if(e&&(t=e.inputType),!t&&e&&e.nativeEvent&&(t=e.nativeEvent.inputType),t&&(0===t.indexOf("format")||Xe.has(t)))return void ie(ae.current);const n=oe(),{start:r,activeFormats:a=[]}=ae.current,o=function({value:e,start:t,end:n,formats:r}){const a=e.formats[t-1]||[],o=e.formats[n]||[];for(e.activeFormats=r.map((e,t)=>{if(a[t]){if(h(e,a[t]))return a[t]}else if(o[t]&&h(e,o[t]))return o[t];return e});--n>=t;)e.activeFormats.length>0?e.formats[n]=e.activeFormats:delete e.formats[n];return e}({value:n,start:r,end:n.start,formats:a});if(pe(o,{withoutHistory:!0}),J().clearTimeout(ue.current),ue.current=J().setTimeout(ce,1e3),"insertText"!==t)return;A&&F&&F(o,ne);const i=H.reduce((e,{__unstableInputRule:t})=>(t&&(e=t(e)),e),o);i!==o&&(ce(),pe({...i,activeFormats:a}),C())}const de=Object(We.useRef)(!1);function me(e){if(!k.current)return;if(k.current.ownerDocument.activeElement!==k.current)return;if("selectionchange"!==e.type&&!P)return;if(l)return;if(le.current)return;const{start:t,end:n,text:r}=oe(),a=ae.current;if(r!==a.text)return void fe();if(t===a.start&&n===a.end)return void(0===a.text.length&&0===t&&function(e){const t=e.getSelection(),{anchorNode:n,anchorOffset:r}=t;if(n.nodeType!==n.ELEMENT_NODE)return;const a=n.childNodes[r];a&&a.nodeType===a.ELEMENT_NODE&&a.getAttribute("data-rich-text-placeholder")&&t.collapseToStart()}(J()));const o={...a,start:t,end:n,activeFormats:a._newActiveFormats,_newActiveFormats:void 0},i=I(o,Ze);o.activeFormats=i,!S&&i.length?D():S&&!i.length&&R(),ae.current=o,ie(o,{domOnly:!0}),g(t,n),$(i)}function pe(e,{withoutHistory:t}={}){_&&(e.formats=Array(e.text.length),e.replacements=Array(e.text.length)),ie(e);const{start:n,end:r,activeFormats:a=[]}=e;Object.values(U).forEach(t=>{t(e.formats,e.text)}),re.current=ne(e),ae.current=e,g(n,r),b(re.current),$(a),t||ce()}function ge(e){const{target:t}=e;if(t===k.current||t.textContent)return;const{parentNode:n}=t,r=Array.from(n.childNodes).indexOf(t),a=Z().createRange(),o=J().getSelection();a.setStart(t.parentNode,r),a.setEnd(t.parentNode,r+1),o.removeAllRanges(),o.addRange(a)}const he=Object(We.useRef)();function ye(){re.current=t,ae.current=ee(t),ae.current.start=n,ae.current.end=r,ie(ae.current)}function xe(){k.current.focus(),ie(ae.current)}Object(We.useEffect)(()=>{de.current&&ye()},[e,c]),Object(We.useEffect)(()=>{de.current&&t!==re.current&&ye()},[t]),Object(We.useEffect)(()=>{de.current&&(!P||n===ae.current.start&&r===ae.current.end?ae.current={...ae.current,start:n,end:r}:ye())},[n,r,P]),Object(We.useEffect)(()=>{de.current&&ye()},q),Object(We.useLayoutEffect)(()=>(ie(ae.current,{domOnly:!0}),de.current=!0,()=>{Z().removeEventListener("selectionchange",me),J().cancelAnimationFrame(he.current),J().clearTimeout(ue.current)}),[]);const Te={role:"textbox","aria-multiline":!0,"aria-label":c,ref:Object(He.useMergeRefs)([W,k,ze({record:ae,multilineTag:E,preserveWhiteSpace:u}),Ge({record:ae,applyRecord:ie,setActiveFormats:$}),qe({didAutomaticChange:j,undo:N})]),style:Ye,className:"rich-text",onPaste:function(e){if(!P)return void e.preventDefault();const{clipboardData:t}=e;let n="",r="";try{n=t.getData("text/plain"),r=t.getData("text/html")}catch(e){try{r=t.getData("Text")}catch(e){return}}if(e.preventDefault(),window.console.log("Received HTML:\n\n",r),window.console.log("Received plain text:\n\n",n),_)return void pe(X(ae.current,n));const a=H.reduce((e,{__unstablePasteRule:t})=>(t&&e===ae.current&&(e=t(ae.current,{html:r,plainText:n})),e),ae.current);if(a===ae.current){if(f){const e=Object($e.getFilesFromDataTransfer)(t),a="true"===t.getData("rich-text");f({value:te(ae.current),onChange:pe,html:r,plainText:n,isInternal:a,files:[...e],activeFormats:M})}}else pe(a)},onInput:fe,onCompositionStart:function(){le.current=!0,Z().removeEventListener("selectionchange",me)},onCompositionEnd:function(){le.current=!1,fe({inputType:"insertText"}),Z().addEventListener("selectionchange",me)},onKeyDown:function(e){e.defaultPrevented||(function(e){const{keyCode:t}=e;if(e.defaultPrevented)return;if(t!==Me.DELETE&&t!==Me.BACKSPACE)return;const n=oe(),{start:r,end:a,text:o}=n,i=t===Me.BACKSPACE;if(0===r&&0!==a&&a===o.length)return pe(Y(n)),void e.preventDefault();if(E){let t;if(t=i&&0===n.start&&0===n.end&&B(n)?Q(n,!i):Q(n,i),t)return pe(t),void e.preventDefault()}!m||!V(n)||M.length||i&&0!==r||!i&&a!==o.length||(m({isReverse:i,value:n}),e.preventDefault())}(e),function(e){e.keyCode===Me.ENTER&&(e.preventDefault(),p&&p({value:te(oe()),onChange:pe,shiftKey:e.shiftKey}))}(e),function(e){const{keyCode:t,shiftKey:n,altKey:r,metaKey:a,ctrlKey:o}=e;if(n||r||a||o||t!==Me.SPACE||"li"!==E)return;const i=oe();if(!V(i))return;const{text:s,start:c}=i,l=s[c-1];l&&l!==T||(pe(Re(i,{type:O})),e.preventDefault())}(e))},onFocus:function(){if(y&&y(),P)g(ae.current.start,ae.current.end),$(I({...ae.current,activeFormats:void 0},Ze));else{const e=void 0;ae.current={...ae.current,start:e,end:e,activeFormats:Ze},g(e,e),$(Ze)}he.current=J().requestAnimationFrame(me),Z().addEventListener("selectionchange",me)},onBlur:function(){Z().removeEventListener("selectionchange",me)},onMouseDown:ge,onTouchStart:ge,onKeyUp:me,onMouseUp:me,onTouchEnd:me,contentEditable:!l||void 0,suppressContentEditableWarning:!l};return function({activeFormats:e,ref:t}){Object(We.useEffect)(()=>{if(!e||!e.length)return;const n=t.current.querySelector("*[data-rich-text-format-boundary]");if(!n)return;const{ownerDocument:r}=n,{defaultView:a}=r,o=`.rich-text:focus *[data-rich-text-format-boundary] {${"background-color: "+a.getComputedStyle(n).color.replace(")",", 0.2)").replace("rgb","rgba")}}`;let i=r.getElementById("rich-text-boundary-style");i||(i=r.createElement("style"),i.id="rich-text-boundary-style",r.head.appendChild(i)),i.innerHTML!==o&&(i.innerHTML=o)},[e])}({ref:k,activeFormats:M}),function({ref:e}){Object(We.useEffect)(()=>{0},[])}({ref:k}),Object(We.createElement)(We.Fragment,null,P&&Object(We.createElement)(Ve,{value:ae.current,onChange:pe,onFocus:xe,formatTypes:H,forwardedRef:k}),a&&a({isSelected:P,value:ae.current,onChange:pe,onFocus:xe,editableProps:Te,editableTagName:e}),!a&&Object(We.createElement)(e,Te))}))},"./node_modules/rememo/es/rememo.js":function(e,t,n){"use strict";var r,a;function o(e){return[e]}function i(){var e={clear:function(){e.head=null}};return e}function s(e,t,n){var r;if(e.length!==t.length)return!1;for(r=n;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}r={},a="undefined"!=typeof WeakMap,t.a=function(e,t){var n,c;function l(){n=a?new WeakMap:i()}function u(){var n,r,a,o,i,l=arguments.length;for(o=new Array(l),a=0;a<l;a++)o[a]=arguments[a];for(i=t.apply(null,o),(n=c(i)).isUniqueByDependants||(n.lastDependants&&!s(i,n.lastDependants,0)&&n.clear(),n.lastDependants=i),r=n.head;r;){if(s(r.args,o,1))return r!==n.head&&(r.prev.next=r.next,r.next&&(r.next.prev=r.prev),r.next=n.head,r.prev=null,n.head.prev=r,n.head=r),r.val;r=r.next}return r={val:e.apply(null,o)},o[0]=null,r.args=o,n.head&&(n.head.prev=r,r.next=n.head),n.head=r,r.val}return t||(t=o),c=a?function(e){var t,a,o,s,c,l=n,u=!0;for(t=0;t<e.length;t++){if(a=e[t],!(c=a)||"object"!=typeof c){u=!1;break}l.has(a)?l=l.get(a):(o=new WeakMap,l.set(a,o),l=o)}return l.has(r)||((s=i()).isUniqueByDependants=u,l.set(r,s)),l.get(r)}:function(){return n},u.getDependants=t,u.clear=l,l(),u}},"@wordpress/compose":function(e,t){e.exports=window.wp.compose},"@wordpress/data":function(e,t){e.exports=window.wp.data},"@wordpress/dom":function(e,t){e.exports=window.wp.dom},"@wordpress/element":function(e,t){e.exports=window.wp.element},"@wordpress/escape-html":function(e,t){e.exports=window.wp.escapeHtml},"@wordpress/keycodes":function(e,t){e.exports=window.wp.keycodes},lodash:function(e,t){e.exports=window.lodash}});