WordPress/wp-includes/js/dist/rich-text.min.js
audrasjb 4935678150 Editor: Update block editor packages to the latest patch releases.
This updates the block editor related npm dependencies to their latest patch versions ahead of WordPress 6.2.1 RC1.

Updated packages:
 - @wordpress/annotations@2.26.4
 - @wordpress/block-directory@4.3.12
 - @wordpress/block-editor@11.3.10
 - @wordpress/block-library@8.3.12
 - @wordpress/components@23.3.7
 - @wordpress/customize-widgets@4.3.12
 - @wordpress/edit-post@7.3.12
 - @wordpress/edit-site@5.3.12
 - @wordpress/edit-widgets@5.3.12
 - @wordpress/editor@13.3.10
 - @wordpress/format-library@4.3.10
 - @wordpress/interface@5.3.8
 - @wordpress/list-reusable-blocks@4.3.7
 - @wordpress/preferences@3.3.7
 - @wordpress/reusable-blocks@4.3.10
 - @wordpress/rich-text@6.3.4
 - @wordpress/server-side-render@4.3.7
 - @wordpress/widgets@3.3.10

This changeset includes the following fixes:
- i18n: Add context to labels related to CSS position properties gutenberg#49135
- Comments: Fix 'sprintf requires more than 1 params' error gutenberg#49054
- Fix the site editor loading in multi-site installs gutenberg#49861
- Fix quick inserter going off-screen in some situations gutenberg#49881
- Site Editor: Decode the site title properly gutenberg#49685
- Firefox: fix input rules (React async state issue) gutenberg#48210
- Only show alignment info when parent layout is constrained. gutenberg#49703
- [Inserter]: Fix onHover error on patterns tab in mobile gutenberg#49450
- Fix site editor redirection after creating new template or template part gutenberg#49364

Props mamaduka, audrasjb, wildworks, ocean90, aristath, costdev, hellofromtonya, youknowriad, mdxfr, oandregal, mattwiebe, bph, ndiego, talldanwp, joen, ellatrix, kevin940726, isabel_brison, andrewserong, ntsekouras, welcher.
Fixes #58274.

Built from https://develop.svn.wordpress.org/trunk@55737


git-svn-id: http://core.svn.wordpress.org/trunk@55249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-09 14:13:25 +00:00

2 lines
33 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 */
!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{__UNSTABLE_LINE_SEPARATOR:function(){return E},__experimentalRichText:function(){return Ge},__unstableCreateElement:function(){return T},__unstableFormatEdit:function(){return Ze},__unstableInsertLineSeparator:function(){return Y},__unstableIsEmptyLine:function(){return I},__unstableToDom:function(){return me},__unstableUseRichText:function(){return Ye},applyFormat:function(){return b},concat:function(){return O},create:function(){return _},getActiveFormat:function(){return k},getActiveFormats:function(){return W},getActiveObject:function(){return M},getTextContent:function(){return j},insert:function(){return q},insertObject:function(){return G},isCollapsed:function(){return P},isEmpty:function(){return V},join:function(){return B},registerFormatType:function(){return H},remove:function(){return K},removeFormat:function(){return z},replace:function(){return X},slice:function(){return Z},split:function(){return J},store:function(){return g},toHTMLString:function(){return ve},toggleFormat:function(){return Se},unregisterFormatType:function(){return Le},useAnchor:function(){return Me},useAnchorRef:function(){return ke}});var n={};e.r(n),e.d(n,{getFormatType:function(){return u},getFormatTypeForBareElement:function(){return f},getFormatTypeForClassName:function(){return d},getFormatTypes:function(){return l}});var r={};e.r(r),e.d(r,{addFormatTypes:function(){return m},removeFormatTypes:function(){return p}});var a=window.wp.data;var o=(0,a.combineReducers)({formatTypes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ADD_FORMAT_TYPES":return{...e,...t.formatTypes.reduce(((e,t)=>({...e,[t.name]:t})),{})};case"REMOVE_FORMAT_TYPES":return Object.fromEntries(Object.entries(e).filter((e=>{let[n]=e;return!t.names.includes(n)})))}return e}}),i={};function s(e){return[e]}function c(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}const l=function(e,t){var n,r=t||s;function a(e){var t,r,a,o,s,c=n,l=!0;for(t=0;t<e.length;t++){if(r=e[t],!(s=r)||"object"!=typeof s){l=!1;break}c.has(r)?c=c.get(r):(a=new WeakMap,c.set(r,a),c=a)}return c.has(i)||((o=function(){var e={clear:function(){e.head=null}};return e}()).isUniqueByDependants=l,c.set(i,o)),c.get(i)}function o(){n=new WeakMap}function l(){var t,n,o,i,s,l=arguments.length;for(i=new Array(l),o=0;o<l;o++)i[o]=arguments[o];for((t=a(s=r.apply(null,i))).isUniqueByDependants||(t.lastDependants&&!c(s,t.lastDependants,0)&&t.clear(),t.lastDependants=s),n=t.head;n;){if(c(n.args,i,1))return n!==t.head&&(n.prev.next=n.next,n.next&&(n.next.prev=n.prev),n.next=t.head,n.prev=null,t.head.prev=n,t.head=n),n.val;n=n.next}return n={val:e.apply(null,i)},i[0]=null,n.args=i,t.head&&(t.head.prev=n,n.next=t.head),t.head=n,n.val}return l.getDependants=r,l.clear=o,o(),l}((e=>Object.values(e.formatTypes)),(e=>[e.formatTypes]));function u(e,t){return e.formatTypes[t]}function f(e,t){const n=l(e);return n.find((e=>{let{className:n,tagName:r}=e;return null===n&&t===r}))||n.find((e=>{let{className:t,tagName:n}=e;return null===t&&"*"===n}))}function d(e,t){return l(e).find((e=>{let{className:n}=e;return null!==n&&` ${t} `.indexOf(` ${n} `)>=0}))}function m(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Array.isArray(e)?e:[e]}}function p(e){return{type:"REMOVE_FORMAT_TYPES",names:Array.isArray(e)?e:[e]}}const g=(0,a.createReduxStore)("core/rich-text",{reducer:o,selectors:n,actions:r});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 v(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 b(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end;const{formats:a,activeFormats:o}=e,i=a.slice();if(n===r){var s;const e=null===(s=i[n])||void 0===s?void 0:s.find((e=>{let{type:n}=e;return n===t.type}));if(e){const a=i[n].indexOf(e);for(;i[n]&&i[n][a]===e;)i[n]=y(i[n],a,t),n--;for(r++;i[r]&&i[r][a]===e;)i[r]=y(i[r],a,t),r++}}else{let e=1/0;for(let a=n;a<r;a++)if(i[a]){i[a]=i[a].filter((e=>{let{type:n}=e;return n!==t.type}));const n=i[a].length;n<e&&(e=n)}else i[a]=[],e=0;for(let a=n;a<r;a++)i[a].splice(e,0,t)}return v({...e,formats:i,activeFormats:[...(null==o?void 0:o.filter((e=>{let{type:n}=e;return n!==t.type})))||[],t]})}function T(e,t){let{implementation:n}=e;return T.body||(T.body=n.createHTMLDocument("").body),T.body.innerHTML=t,T.body}(0,a.register)(g);const E="\u2028",x="";function w(e){let t,{tagName:n,attributes:r}=e;if(r&&r.class&&(t=(0,a.select)(g).getFormatTypeForClassName(r.class),t&&(r.class=` ${r.class} `.replace(` ${t.className} `," ").trim(),r.class||delete r.class)),t||(t=(0,a.select)(g).getFormatTypeForBareElement(n)),!t)return r?{type:n,attributes:r}:{type:n};if(t.__experimentalCreatePrepareEditableTree&&!t.__experimentalCreateOnChangeEditableValue)return null;if(!r)return{type:t.name,tagName:n};const o={},i={},s={...r};for(const e in t.attributes){const n=t.attributes[e];o[e]=s[n],t.__unstableFilterAttributeValue&&(o[e]=t.__unstableFilterAttributeValue(e,o[e])),delete s[n],void 0===o[e]&&delete o[e]}for(const e in s)i[e]=r[e];return{type:t.name,tagName:n,attributes:o,unregisteredAttributes:i}}function _(){let{element:e,text:t,html:n,range:r,multilineTag:a,multilineWrapperTags:o,__unstableIsEditableTree:i,preserveWhiteSpace:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return"string"==typeof t&&t.length>0?{formats:Array(t.length),replacements:Array(t.length),text:t}:("string"==typeof n&&n.length>0&&(e=T(document,n)),"object"!=typeof e?{formats:[],replacements:[],text:""}:a?S({element:e,range:r,multilineTag:a,multilineWrapperTags:o,isEditableTree:i,preserveWhiteSpace:s}):R({element:e,range:r,isEditableTree:i,preserveWhiteSpace:s}))}function N(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 F(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 C(e){return e.replace(/[\n\r\t]+/g," ")}function A(e){return e.replace(new RegExp("[\ufeff]","gu"),"")}function R(e){let{element:t,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:o=[],isEditableTree:i,preserveWhiteSpace:s}=e;const c={formats:[],replacements:[],text:""};if(!t)return c;if(!t.hasChildNodes())return N(c,t,n,{formats:[],replacements:[],text:""}),c;const l=t.childNodes.length;for(let u=0;u<l;u++){const f=t.childNodes[u],d=f.nodeName.toLowerCase();if(f.nodeType===f.TEXT_NODE){let g=A;s||(g=e=>A(C(e)));const h=g(f.nodeValue);n=F(f,n,g),N(c,f,n,{text:h}),c.formats.length+=h.length,c.replacements.length+=h.length,c.text+=h;continue}if(f.nodeType!==f.ELEMENT_NODE)continue;if(i&&(f.getAttribute("data-rich-text-placeholder")||"br"===d&&!f.getAttribute("data-rich-text-line-break"))){N(c,f,n,{formats:[],replacements:[],text:""});continue}if("script"===d){const v={formats:[,],replacements:[{type:d,attributes:{"data-rich-text-script":f.getAttribute("data-rich-text-script")||encodeURIComponent(f.innerHTML)}}],text:x};N(c,f,n,v),D(c,v);continue}if("br"===d){N(c,f,n,{formats:[],replacements:[],text:""}),D(c,_({text:"\n"}));continue}const m=w({tagName:d,attributes:L({element:f})});if(a&&-1!==a.indexOf(d)){const y=S({element:f,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:[...o,m],isEditableTree:i,preserveWhiteSpace:s});N(c,f,n,y),D(c,y);continue}const p=R({element:f,range:n,multilineTag:r,multilineWrapperTags:a,isEditableTree:i,preserveWhiteSpace:s});if(N(c,f,n,p),m)if(0===p.text.length)m.attributes&&D(c,{formats:[,],replacements:[m],text:x});else{function b(e){if(b.formats===e)return b.newFormats;const t=e?[m,...e]:[m];return b.formats=e,b.newFormats=t,t}b.newFormats=[m],D(c,{...p,formats:Array.from(p.formats,b)})}else D(c,p)}return c}function S(e){let{element:t,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:o=[],isEditableTree:i,preserveWhiteSpace:s}=e;const c={formats:[],replacements:[],text:""};if(!t||!t.hasChildNodes())return c;const l=t.children.length;for(let e=0;e<l;e++){const l=t.children[e];if(l.nodeName.toLowerCase()!==r)continue;const u=R({element:l,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:o,isEditableTree:i,preserveWhiteSpace:s});(0!==e||o.length>0)&&D(c,{formats:[,],replacements:o.length>0?[o]:[,],text:E}),N(c,l,n,u),D(c,u)}return c}function L(e){let{element:t}=e;if(!t.hasAttributes())return;const n=t.attributes.length;let r;for(let e=0;e<n;e++){const{name:n,value:a}=t.attributes[e];if(0===n.indexOf("data-rich-text-"))continue;r=r||{},r[/^on/i.test(n)?"data-disable-rich-text-"+n:n]=a}return r}function D(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function O(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return v(t.reduce(D,_()))}function W(e){let{formats:t,start:n,end:r,activeFormats:a}=e,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(void 0===n)return o;if(n===r){if(a)return a;const e=t[n-1]||o,r=t[n]||o;return e.length<r.length?e:r}return t[n]||o}function k(e,t){var n;return null===(n=W(e))||void 0===n?void 0:n.find((e=>{let{type:n}=e;return n===t}))}function M(e){let{start:t,end:n,replacements:r,text:a}=e;if(t+1===n&&a[t]===x)return r[t]}const $=new RegExp(`[${E}]`,"g");function j(e){let{text:t}=e;return t.replace($,(e=>e===x?"":"\n"))}function P(e){let{start:t,end:n}=e;if(void 0!==t&&void 0!==n)return t===n}function V(e){let{text:t}=e;return 0===t.length}function I(e){let{text:t,start:n,end:r}=e;return n===r&&(0===t.length||(0===n&&t.slice(0,1)===E||(n===t.length&&t.slice(-1)===E||t.slice(n-1,r+1)===`${E}${E}`)))}function B(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof t&&(t=_({text:t})),v(e.reduce(((e,n)=>{let{formats:r,replacements:a,text:o}=n;return{formats:e.formats.concat(t.formats,r),replacements:e.replacements.concat(t.replacements,a),text:e.text+t.text+o}})))}function H(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((0,a.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=(0,a.select)(g).getFormatTypeForBareElement(t.tagName);if(e&&"core/unknown"!==e.name)return void window.console.error(`Format "${e.name}" is already registered to handle bare tag name "${t.tagName}".`)}else{const e=(0,a.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(0,a.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 z(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end;const{formats:a,activeFormats:o}=e,i=a.slice();if(n===r){var s;const e=null===(s=i[n])||void 0===s?void 0:s.find((e=>{let{type:n}=e;return n===t}));if(e){for(;null!==(c=i[n])&&void 0!==c&&c.find((t=>t===e));){var c;U(i,n,t),n--}for(r++;null!==(l=i[r])&&void 0!==l&&l.find((t=>t===e));){var l;U(i,r,t),r++}}}else for(let e=n;e<r;e++)i[e]&&U(i,e,t);return v({...e,formats:i,activeFormats:(null==o?void 0:o.filter((e=>{let{type:n}=e;return n!==t})))||[]})}function U(e,t,n){const r=e[t].filter((e=>{let{type:t}=e;return t!==n}));r.length?e[t]=r:delete e[t]}function q(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end;const{formats:a,replacements:o,text:i}=e;"string"==typeof t&&(t=_({text:t}));const s=n+t.text.length;return v({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 K(e,t,n){return q(e,_(),t,n)}function X(e,t,n){let{formats:r,replacements:a,text:o,start:i,end:s}=e;return o=o.replace(t,(function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),c=1;c<t;c++)o[c-1]=arguments[c];const l=o[o.length-2];let u,f,d=n;return"function"==typeof d&&(d=n(e,...o)),"object"==typeof d?(u=d.formats,f=d.replacements,d=d.text):(u=Array(d.length),f=Array(d.length),r[l]&&(u=u.fill(r[l]))),r=r.slice(0,l).concat(u,r.slice(l+e.length)),a=a.slice(0,l).concat(f,a.slice(l+e.length)),i&&(i=s=l+d.length),d})),v({formats:r,replacements:a,text:o,start:i,end:s})}function Y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end;const r=e.text.slice(0,t),a=r.lastIndexOf(E),o=e.replacements[a];let i=[,];o&&(i=[o]);const s={formats:[,],replacements:i,text:E};return q(e,s,t,n)}function G(e,t,n,r){return q(e,{formats:[,],replacements:[t],text:x},n,r)}function Z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]: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 J(e,t){let{formats:n,replacements:r,text:a,start:o,end:i}=e;if("string"!=typeof t)return Q(...arguments);let s=0;return a.split(t).map((e=>{const a=s,c={formats:n.slice(a,a+e.length),replacements:r.slice(a,a+e.length),text:e};return s+=t.length+e.length,void 0!==o&&void 0!==i&&(o>=a&&o<s?c.start=o-a:o<a&&i>a&&(c.start=0),i>=a&&i<s?c.end=i-a:o<s&&i>s&&(c.end=e.length)),c}))}function Q(e){let{formats:t,replacements:n,text:r,start:a,end:o}=e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;if(void 0===a||void 0===o)return;const c={formats:t.slice(0,i),replacements:n.slice(0,i),text:r.slice(0,i)},l={formats:t.slice(s),replacements:n.slice(s),text:r.slice(s),start:0,end:0};return[X(c,/\u2028+$/,""),X(l,/^\u2028+/,"")]}function ee(e,t){if(t)return e;const n={};for(const t in e){let r=t;t.startsWith("data-disable-rich-text-")&&(r=t.slice("data-disable-rich-text-".length)),n[r]=e[t]}return n}function te(e){let{type:t,tagName:n,attributes:r,unregisteredAttributes:o,object:i,boundaryClass:s,isEditableTree:c}=e;const l=(u=t,(0,a.select)(g).getFormatType(u));var u;let f={};if(s&&(f["data-rich-text-format-boundary"]="true"),!l)return r&&(f={...r,...f}),{type:t,attributes:ee(f,c),object:i};f={...o,...f};for(const e in r){const t=!!l.attributes&&l.attributes[e];t?f[t]=r[e]:f[e]=r[e]}return l.className&&(f.class?f.class=`${l.className} ${f.class}`:f.class=l.className),{type:"*"===l.tagName?n:l.tagName,object:l.object,attributes:ee(f,c)}}function ne(e,t,n){do{if(e[n]!==t[n])return!1}while(n--);return!0}function re(e){let{value:t,multilineTag:n,preserveWhiteSpace:r,createEmpty:a,append:o,getLastChild:i,getParent:s,isText:c,getText:l,remove:u,appendText:f,onStartIndex:d,onEndIndex:m,isEditableTree:p,placeholder:g}=e;const{formats:h,replacements:v,text:y,start:b,end:T}=t,w=h.length+1,_=a(),N={type:n},F=W(t),C=F[F.length-1];let A,R,S;n?(o(o(_,{type:n}),""),R=A=[N]):o(_,"");for(let e=0;e<w;e++){const t=y.charAt(e),a=p&&(!S||S===E||"\n"===S);let w=h[e];n&&(w=t===E?A=(v[e]||[]).reduce(((e,t)=>(e.push(t,N),e)),[N]):[...A,...w||[]]);let F=i(_);if(a&&t===E){let e=F;for(;!c(e);)e=i(e);o(s(e),"\ufeff")}if(S===E){let t=F;for(;!c(t);)t=i(t);d&&b===e&&d(_,t),m&&T===e&&m(_,t)}if(w&&w.forEach(((e,n)=>{if(F&&R&&ne(w,R,n)&&(t!==E||w.length-1!==n))return void(F=i(F));const{type:r,tagName:a,attributes:f,unregisteredAttributes:d}=e,m=p&&t!==E&&e===C,g=s(F),h=o(g,te({type:r,tagName:a,attributes:f,unregisteredAttributes:d,boundaryClass:m,isEditableTree:p}));c(F)&&0===l(F).length&&u(F),F=o(h,"")})),t!==E){var L;if(0===e&&(d&&0===b&&d(_,F),m&&0===T&&m(_,F)),t===x)p||"script"!==(null===(L=v[e])||void 0===L?void 0:L.type)?F=o(s(F),te({...v[e],object:!0,isEditableTree:p})):(F=o(s(F),te({type:"script",isEditableTree:p})),o(F,{html:decodeURIComponent(v[e].attributes["data-rich-text-script"])})),F=o(s(F),"");else r||"\n"!==t?c(F)?f(F,t):F=o(s(F),t):(F=o(s(F),{type:"br",attributes:p?{"data-rich-text-line-break":"true"}:void 0,object:!0}),F=o(s(F),""));d&&b===e+1&&d(_,F),m&&T===e+1&&m(_,F),a&&e===y.length&&(o(s(F),"\ufeff"),g&&0===y.length&&o(s(F),{type:"span",attributes:{"data-rich-text-placeholder":g,contenteditable:"false",style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),R=w,S=t}else R=w,S=t}return _}function ae(e,t,n){const r=e.parentNode;let a=0;for(;e=e.previousSibling;)a++;return n=[a,...n],r!==t&&(n=ae(r,t,n)),n}function oe(e,t){for(t=[...t];e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}function ie(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 se(e,t){e.appendData(t)}function ce(e){let{lastChild:t}=e;return t}function le(e){let{parentNode:t}=e;return t}function ue(e){return e.nodeType===e.TEXT_NODE}function fe(e){let{nodeValue:t}=e;return t}function de(e){return e.parentNode.removeChild(e)}function me(e){let{value:t,multilineTag:n,prepareEditableTree:r,isEditableTree:a=!0,placeholder:o,doc:i=document}=e,s=[],c=[];r&&(t={...t,formats:r(t)});return{body:re({value:t,multilineTag:n,createEmpty:()=>T(i,""),append:ie,getLastChild:ce,getParent:le,isText:ue,getText:fe,remove:de,appendText:se,onStartIndex(e,t){s=ae(t,e,[t.nodeValue.length])},onEndIndex(e,t){c=ae(t,e,[t.nodeValue.length])},isEditableTree:a,placeholder:o}),selection:{startPath:s,endPath:c}}}function pe(e){let{value:t,current:n,multilineTag:r,prepareEditableTree:a,__unstableDomOnly:o,placeholder:i}=e;const{body:s,selection:c}=me({value:t,multilineTag:r,prepareEditableTree:a,placeholder:i,doc:n.ownerDocument});ge(s,n),void 0===t.start||o||function(e,t){let{startPath:n,endPath:r}=e;const{node:a,offset:o}=oe(t,n),{node:i,offset:s}=oe(t,r),{ownerDocument:c}=t,{defaultView:l}=c,u=l.getSelection(),f=c.createRange();f.setStart(a,o),f.setEnd(i,s);const{activeElement:d}=c;if(u.rangeCount>0){if(m=f,p=u.getRangeAt(0),m.startContainer===p.startContainer&&m.startOffset===p.startOffset&&m.endContainer===p.endContainer&&m.endOffset===p.endOffset)return;u.removeAllRanges()}var m,p;u.addRange(f),d!==c.activeElement&&d instanceof l.HTMLElement&&d.focus()}(c,n)}function ge(e,t){let n,r=0;for(;n=e.firstChild;){const a=t.childNodes[r];if(a)if(a.isEqualNode(n))e.removeChild(n);else if(a.nodeName!==n.nodeName||a.nodeType===a.TEXT_NODE&&a.data!==n.data)t.replaceChild(n,a);else{const t=a.attributes,r=n.attributes;if(t){let e=t.length;for(;e--;){const{name:r}=t[e];n.getAttribute(r)||a.removeAttribute(r)}}if(r)for(let e=0;e<r.length;e++){const{name:t,value:n}=r[e];a.getAttribute(t)!==n&&a.setAttribute(t,n)}ge(n,a),e.removeChild(n)}else t.appendChild(n);r++}for(;t.childNodes[r];)t.removeChild(t.childNodes[r])}var he=window.wp.escapeHtml;function ve(e){let{value:t,multilineTag:n,preserveWhiteSpace:r}=e;return Ce(re({value:t,multilineTag:n,preserveWhiteSpace:r,createEmpty:ye,append:Te,getLastChild:be,getParent:xe,isText:we,getText:_e,remove:Ne,appendText:Ee}).children)}function ye(){return{}}function be(e){let{children:t}=e;return t&&t[t.length-1]}function Te(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Ee(e,t){e.text+=t}function xe(e){let{parent:t}=e;return t}function we(e){let{text:t}=e;return"string"==typeof t}function _e(e){let{text:t}=e;return t}function Ne(e){const t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function Fe(e){let{type:t,attributes:n,object:r,children:a}=e,o="";for(const e in n)(0,he.isValidAttributeName)(e)&&(o+=` ${e}="${(0,he.escapeAttribute)(n[e])}"`);return r?`<${t}${o}>`:`<${t}${o}>${Ce(a)}</${t}>`}function Ce(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map((e=>void 0!==e.html?e.html:void 0===e.text?Fe(e):(0,he.escapeEditableHTML)(e.text))).join("")}var Ae=window.wp.a11y,Re=window.wp.i18n;function Se(e,t){return k(e,t.type)?(t.title&&(0,Ae.speak)((0,Re.sprintf)((0,Re.__)("%s removed."),t.title),"assertive"),z(e,t.type)):(t.title&&(0,Ae.speak)((0,Re.sprintf)((0,Re.__)("%s applied."),t.title),"assertive"),b(e,t))}function Le(e){const t=(0,a.select)(g).getFormatType(e);if(t)return(0,a.dispatch)(g).removeFormatTypes(e),t;window.console.error(`Format ${e} is not registered.`)}var De=window.wp.element,Oe=window.wp.deprecated,We=e.n(Oe);function ke(e){let{ref:t,value:n,settings:r={}}=e;We()("`useAnchorRef` hook",{since:"6.1",alternative:"`useAnchor` hook"});const{tagName:a,className:o,name:i}=r,s=i?k(n,i):void 0;return(0,De.useMemo)((()=>{if(!t.current)return;const{ownerDocument:{defaultView:e}}=t.current,n=e.getSelection();if(!n.rangeCount)return;const r=n.getRangeAt(0);if(!s)return r;let i=r.startContainer;for(i=i.nextElementSibling||i;i.nodeType!==i.ELEMENT_NODE;)i=i.parentNode;return i.closest(a+(o?"."+o:""))}),[s,n.start,n.end,a,o])}function Me(e){let{editableContentElement:t,value:n,settings:r={}}=e;const{tagName:a,className:o,name:i}=r,s=i?k(n,i):void 0;return(0,De.useMemo)((()=>{if(!t)return;const{ownerDocument:{defaultView:e}}=t,n=e.getSelection();if(!n.rangeCount)return;const r=null==t?void 0:t.contains(null==n?void 0:n.anchorNode),i=n.getRangeAt(0);if(!s)return{ownerDocument:i.startContainer.ownerDocument,getBoundingClientRect(){return r?i.getBoundingClientRect():t.getBoundingClientRect()}};let c=i.startContainer;for(c=c.nextElementSibling||c;c.nodeType!==c.ELEMENT_NODE;)c=c.parentNode;return c.closest(a+(o?"."+o:""))}),[t,s,n.start,n.end,a,o])}var $e=window.wp.compose;function je(e){let{record:t}=e;const n=(0,De.useRef)(),{activeFormats:r=[]}=t.current;return(0,De.useEffect)((()=>{if(!r||!r.length)return;const e="*[data-rich-text-format-boundary]",t=n.current.querySelector(e);if(!t)return;const{ownerDocument:a}=t,{defaultView:o}=a,i=`${`.rich-text:focus ${e}`} {${`background-color: ${o.getComputedStyle(t).color.replace(")",", 0.2)").replace("rgb","rgba")}`}}`,s="rich-text-boundary-style";let c=a.getElementById(s);c||(c=a.createElement("style"),c.id=s,a.head.appendChild(c)),c.innerHTML!==i&&(c.innerHTML=i)}),[r]),n}function Pe(e){const t=(0,De.useRef)(e);return t.current=e,(0,$e.useRefEffect)((e=>{function n(n){const{record:r,multilineTag:a,preserveWhiteSpace:o}=t.current;if(P(r.current)||!e.contains(e.ownerDocument.activeElement))return;const i=Z(r.current),s=j(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.clipboardData.setData("rich-text-multi-line-tag",a||""),n.preventDefault()}return e.addEventListener("copy",n),()=>{e.removeEventListener("copy",n)}}),[])}var Ve=window.wp.keycodes;const Ie=[];function Be(e){const[,t]=(0,De.useReducer)((()=>({}))),n=(0,De.useRef)(e);return n.current=e,(0,$e.useRefEffect)((e=>{function r(r){const{keyCode:a,shiftKey:o,altKey:i,metaKey:s,ctrlKey:c}=r;if(o||i||s||c||a!==Ve.LEFT&&a!==Ve.RIGHT)return;const{record:l,applyRecord:u}=n.current,{text:f,formats:d,start:m,end:p,activeFormats:g=[]}=l.current,h=P(l.current),{ownerDocument:v}=e,{defaultView:y}=v,{direction:b}=y.getComputedStyle(e),T="rtl"===b?Ve.RIGHT:Ve.LEFT,E=r.keyCode===T;if(h&&0===g.length){if(0===m&&E)return;if(p===f.length&&!E)return}if(!h)return;const x=d[m-1]||Ie,w=d[m]||Ie,_=E?x:w,N=g.every(((e,t)=>e===_[t]));let F=g.length;if(N?F<_.length&&F++:F--,F===g.length)return void(l.current._newActiveFormats=_);r.preventDefault();const C=(N?_:E?w:x).slice(0,F),A={...l.current,activeFormats:C};l.current=A,u(A),t()}return e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r)}}),[])}const He=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),ze=[],Ue="data-rich-text-placeholder";function qe(e){const t=(0,De.useRef)(e);return t.current=e,(0,$e.useRefEffect)((e=>{const{ownerDocument:n}=e,{defaultView:r}=n;let a,o=!1;function i(e){if(o)return;let n;e&&(n=e.inputType);const{record:r,applyRecord:a,createRecord:i,handleChange:s}=t.current;if(n&&(0===n.indexOf("format")||He.has(n)))return void a(r.current);const c=i(),{start:l,activeFormats:u=[]}=r.current,f=function(e){let{value:t,start:n,end:r,formats:a}=e;const o=Math.min(n,r),i=Math.max(n,r),s=t.formats[o-1]||[],c=t.formats[i]||[];for(t.activeFormats=a.map(((e,t)=>{if(s[t]){if(h(e,s[t]))return s[t]}else if(c[t]&&h(e,c[t]))return c[t];return e}));--r>=n;)t.activeFormats.length>0?t.formats[r]=t.activeFormats:delete t.formats[r];return t}({value:c,start:l,end:c.start,formats:u});s(f)}function s(a){const{record:s,applyRecord:c,createRecord:l,isSelected:u,onSelectionChange:f}=t.current;if("true"!==e.contentEditable)return;if(n.activeElement!==e){if("true"!==n.activeElement.contentEditable)return;if(!n.activeElement.contains(e))return;const t=r.getSelection(),{anchorNode:a,focusNode:o}=t;if(e.contains(a)&&e!==a&&e.contains(o)&&e!==o){const{start:e,end:t}=l();s.current.activeFormats=ze,f(e,t)}else if(e.contains(a)&&e!==a){const{start:e,end:t=e}=l();s.current.activeFormats=ze,f(t)}else if(e.contains(o)){const{start:e,end:t=e}=l();s.current.activeFormats=ze,f(void 0,t)}return}if("selectionchange"!==a.type&&!u)return;if(o)return;const{start:d,end:m,text:p}=l(),g=s.current;if(p!==g.text)return void i();if(d===g.start&&m===g.end)return void(0===g.text.length&&0===d&&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.hasAttribute(Ue)&&t.collapseToStart()}(r));const h={...g,start:d,end:m,activeFormats:g._newActiveFormats,_newActiveFormats:void 0},v=W(h,ze);h.activeFormats=v,s.current=h,c(h,{domOnly:!0}),f(d,m)}function c(){var t;o=!0,n.removeEventListener("selectionchange",s),null===(t=e.querySelector(`[${Ue}]`))||void 0===t||t.remove()}function l(){o=!1,i({inputType:"insertText"}),n.addEventListener("selectionchange",s)}function u(){const{record:n,isSelected:o,onSelectionChange:i,applyRecord:c}=t.current;if(!e.parentElement.closest('[contenteditable="true"]')){if(o)c(n.current),i(n.current.start,n.current.end);else{const e=void 0;n.current={...n.current,start:e,end:e,activeFormats:ze},i(e,e)}a=r.requestAnimationFrame(s)}}return e.addEventListener("input",i),e.addEventListener("compositionstart",c),e.addEventListener("compositionend",l),e.addEventListener("focus",u),e.addEventListener("keyup",s),e.addEventListener("mouseup",s),e.addEventListener("touchend",s),n.addEventListener("selectionchange",s),()=>{e.removeEventListener("input",i),e.removeEventListener("compositionstart",c),e.removeEventListener("compositionend",l),e.removeEventListener("focus",u),e.removeEventListener("keyup",s),e.removeEventListener("mouseup",s),e.removeEventListener("touchend",s),n.removeEventListener("selectionchange",s),r.cancelAnimationFrame(a)}}),[])}function Ke(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{replacements:n,text:r,start:a,end:o}=e,i=P(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]===E){if(i&&n[c]&&n[c].length){const t=n.slice();t[c]=n[c].slice(0,-1),s={...e,replacements:t}}else s=K(e,l,u);return s}}function Xe(e){const t=(0,De.useRef)(e);return t.current=e,(0,$e.useRefEffect)((e=>{function n(e){const{keyCode:n}=e,{createRecord:r,handleChange:a,multilineTag:o}=t.current;if(e.defaultPrevented)return;if(n!==Ve.DELETE&&n!==Ve.BACKSPACE)return;const i=r(),{start:s,end:c,text:l}=i,u=n===Ve.BACKSPACE;if(0===s&&0!==c&&c===l.length)return a(K(i)),void e.preventDefault();if(o){let t;t=u&&0===i.start&&0===i.end&&I(i)?Ke(i,!u):Ke(i,u),t&&(a(t),e.preventDefault())}}return e.addEventListener("keydown",n),()=>{e.removeEventListener("keydown",n)}}),[])}function Ye(e){let{value:t="",selectionStart:n,selectionEnd:r,placeholder:o,preserveWhiteSpace:i,onSelectionChange:s,onChange:c,__unstableMultilineTag:l,__unstableDisableFormats:u,__unstableIsSelected:f,__unstableDependencies:d=[],__unstableAfterParse:m,__unstableBeforeSerialize:p,__unstableAddInvisibleFormats:g}=e;const h=(0,a.useRegistry)(),[,v]=(0,De.useReducer)((()=>({}))),y=(0,De.useRef)();function b(){const{ownerDocument:{defaultView:e}}=y.current,t=e.getSelection(),n=t.rangeCount>0?t.getRangeAt(0):null;return _({element:y.current,range:n,multilineTag:l,multilineWrapperTags:"li"===l?["ul","ol"]:void 0,__unstableIsEditableTree:!0,preserveWhiteSpace:i})}function T(e){let{domOnly:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};pe({value:e,current:y.current,multilineTag:l,multilineWrapperTags:"li"===l?["ul","ol"]:void 0,prepareEditableTree:g,__unstableDomOnly:t,placeholder:o})}const E=(0,De.useRef)(t),x=(0,De.useRef)();function w(){E.current=t,x.current=_({html:t,multilineTag:l,multilineWrapperTags:"li"===l?["ul","ol"]:void 0,preserveWhiteSpace:i}),u&&(x.current.formats=Array(t.length),x.current.replacements=Array(t.length)),m&&(x.current.formats=m(x.current)),x.current.start=n,x.current.end=r}const N=(0,De.useRef)(!1);if(x.current)n===x.current.start&&r===x.current.end||(N.current=f,x.current={...x.current,start:n,end:r});else{var F,C,A;w();"core/text-color"===(null===(F=x.current)||void 0===F||null===(C=F.formats[0])||void 0===C||null===(A=C[0])||void 0===A?void 0:A.type)&&function(e){x.current=e,E.current=ve({value:p?{...e,formats:p(e)}:e,multilineTag:l,preserveWhiteSpace:i});const{formats:t,text:n}=e;h.batch((()=>{c(E.current,{__unstableFormats:t,__unstableText:n})})),v()}(x.current)}function R(e){x.current=e,T(e),E.current=u?e.text:ve({value:p?{...e,formats:p(e)}:e,multilineTag:l,preserveWhiteSpace:i});const{start:t,end:n,formats:r,text:a}=e;h.batch((()=>{s(t,n),c(E.current,{__unstableFormats:r,__unstableText:a})})),v()}function S(){w(),T(x.current)}const L=(0,De.useRef)(!1);(0,De.useLayoutEffect)((()=>{L.current&&t!==E.current&&(S(),v())}),[t]),(0,De.useLayoutEffect)((()=>{N.current&&(y.current.ownerDocument.activeElement!==y.current&&y.current.focus(),S(),N.current=!1)}),[N.current]);const D=(0,$e.useMergeRefs)([y,(0,De.useCallback)((e=>{e&&(e.style.whiteSpace="pre-wrap",e.style.minWidth="1px")}),[]),je({record:x}),Pe({record:x,multilineTag:l,preserveWhiteSpace:i}),(0,$e.useRefEffect)((e=>{function t(t){const{target:n}=t;if(n===e||n.textContent)return;const{ownerDocument:r}=n,{defaultView:a}=r,o=r.createRange(),i=a.getSelection();o.selectNode(n),i.removeAllRanges(),i.addRange(o)}return e.addEventListener("click",t),()=>{e.removeEventListener("click",t)}}),[]),Be({record:x,applyRecord:T}),Xe({createRecord:b,handleChange:R,multilineTag:l}),qe({record:x,applyRecord:T,createRecord:b,handleChange:R,isSelected:f,onSelectionChange:s}),(0,$e.useRefEffect)((()=>{S(),L.current=!0}),[o,...d])]);return{value:x.current,getValue:()=>x.current,onChange:R,ref:D}}function Ge(){}function Ze(e){let{formatTypes:t,onChange:n,onFocus:r,value:a,forwardedRef:o}=e;return t.map((e=>{const{name:t,edit:i}=e;if(!i)return null;const s=k(a,t),c=void 0!==s,l=M(a),u=void 0!==l&&l.type===t;return(0,De.createElement)(i,{key:t,isActive:c,activeAttributes:c&&s.attributes||{},isObjectActive:u,activeObjectAttributes:u&&l.attributes||{},value:a,onChange:n,onFocus:r,contentRef:o})}))}(window.wp=window.wp||{}).richText=t}();