summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/dist/block-directory.min.js
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes/js/dist/block-directory.min.js')
-rw-r--r--wp-includes/js/dist/block-directory.min.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/wp-includes/js/dist/block-directory.min.js b/wp-includes/js/dist/block-directory.min.js
index a35abd6..34bd649 100644
--- a/wp-includes/js/dist/block-directory.min.js
+++ b/wp-includes/js/dist/block-directory.min.js
@@ -1,2 +1,2 @@
/*! This file is auto-generated */
-(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var n in l)e.o(l,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:l[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{store:()=>W});var l={};e.r(l),e.d(l,{getDownloadableBlocks:()=>g,getErrorNoticeForBlock:()=>h,getErrorNotices:()=>f,getInstalledBlockTypes:()=>w,getNewBlockTypes:()=>_,getUnusedBlockTypes:()=>E,isInstalling:()=>y,isRequestingDownloadableBlocks:()=>b});var n={};e.r(n),e.d(n,{addInstalledBlockType:()=>D,clearErrorNotice:()=>F,fetchDownloadableBlocks:()=>O,installBlockType:()=>A,receiveDownloadableBlocks:()=>C,removeInstalledBlockType:()=>P,setErrorNotice:()=>x,setIsInstalling:()=>M,uninstallBlockType:()=>R});var o={};e.r(o),e.d(o,{getDownloadableBlocks:()=>q});const r=window.React,a=window.wp.plugins,s=window.wp.hooks,c=window.wp.blocks,i=window.wp.data,d=window.wp.element,u=window.wp.editor,m=(0,i.combineReducers)({downloadableBlocks:(e={},t)=>{switch(t.type){case"FETCH_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{isRequesting:!0}};case"RECEIVE_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{results:t.downloadableBlocks,isRequesting:!1}}}return e},blockManagement:(e={installedBlockTypes:[],isInstalling:{}},t)=>{switch(t.type){case"ADD_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:[...e.installedBlockTypes,t.item]};case"REMOVE_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:e.installedBlockTypes.filter((e=>e.name!==t.item.name))};case"SET_INSTALLING_BLOCK":return{...e,isInstalling:{...e.isInstalling,[t.blockId]:t.isInstalling}}}return e},errorNotices:(e={},t)=>{switch(t.type){case"SET_ERROR_NOTICE":return{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":const{[t.blockId]:l,...n}=e;return n}return e}}),p=window.wp.blockEditor;function k(e,t=[]){if(!t.length)return!1;if(t.some((({name:t})=>t===e.name)))return!0;for(let l=0;l<t.length;l++)if(k(e,t[l].innerBlocks))return!0;return!1}function b(e,t){var l;return null!==(l=e.downloadableBlocks[t]?.isRequesting)&&void 0!==l&&l}function g(e,t){var l;return null!==(l=e.downloadableBlocks[t]?.results)&&void 0!==l?l:[]}function w(e){return e.blockManagement.installedBlockTypes}const _=(0,i.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return w(t).filter((e=>k(e,l)))})),E=(0,i.createRegistrySelector)((e=>t=>{const l=e(p.store).getBlocks();return w(t).filter((e=>!k(e,l)))}));function y(e,t){return e.blockManagement.isInstalling[t]||!1}function f(e){return e.errorNotices}function h(e,t){return e.errorNotices[t]}const v=window.wp.i18n,B=window.wp.apiFetch;var N=e.n(B);const I=window.wp.notices,T=window.wp.url,L=e=>new Promise(((t,l)=>{const n=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(n[t]=e[t])})),e.innerHTML&&n.appendChild(document.createTextNode(e.innerHTML)),n.onload=()=>t(!0),n.onerror=()=>l(new Error("Error loading asset.")),document.body.appendChild(n),("link"===n.nodeName.toLowerCase()||"script"===n.nodeName.toLowerCase()&&!n.src)&&t()}));function S(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function O(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function C(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const A=e=>async({registry:t,dispatch:l})=>{const{id:n,name:o}=e;let r=!1;l.clearErrorNotice(n);try{l.setIsInstalling(n,!0);const a=S(e);let s={};if(a)await N()({method:"PUT",url:a,data:{status:"active"}});else{s=(await N()({method:"POST",path:"wp/v2/plugins",data:{slug:n,status:"active"}}))._links}l.addInstalledBlockType({...e,links:{...e.links,...s}});const i=["api_version","title","category","parent","icon","description","keywords","attributes","provides_context","uses_context","supports","styles","example","variations"];await N()({path:(0,T.addQueryArgs)(`/wp/v2/block-types/${o}`,{_fields:i})}).catch((()=>{})).then((e=>{e&&(0,c.unstable__bootstrapServerSideBlockDefinitions)({[o]:Object.fromEntries(Object.entries(e).filter((([e])=>i.includes(e))))})})),await async function(){const e=await N()({url:document.location.href,parse:!1}),t=await e.text(),l=(new window.DOMParser).parseFromString(t,"text/html"),n=Array.from(l.querySelectorAll('link[rel="stylesheet"],script')).filter((e=>e.id&&!document.getElementById(e.id)));for(const e of n)await L(e)}();if(!t.select(c.store).getBlockTypes().some((e=>e.name===o)))throw new Error((0,v.__)("Error registering block. Try reloading the page."));t.dispatch(I.store).createInfoNotice((0,v.sprintf)((0,v.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),r=!0}catch(e){let o=e.message||(0,v.__)("An error occurred."),r=e instanceof Error;const a={folder_exists:(0,v.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,v.__)("Error installing block. You can reload the page and try again.")};a[e.code]&&(r=!0,o=a[e.code]),l.setErrorNotice(n,o,r),t.dispatch(I.store).createErrorNotice(o,{speak:!0,isDismissible:!0})}return l.setIsInstalling(n,!1),r},R=e=>async({registry:t,dispatch:l})=>{try{const t=S(e);await N()({method:"PUT",url:t,data:{status:"inactive"}}),await N()({method:"DELETE",url:t}),l.removeInstalledBlockType(e)}catch(e){t.dispatch(I.store).createErrorNotice(e.message||(0,v.__)("An error occurred."))}};function D(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function P(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function M(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function x(e,t,l=!1){return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:l}}function F(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var V=function(){return V=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var o in t=arguments[l])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},V.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function H(e){return e.toLowerCase()}var $=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],j=/[^A-Z0-9]+/gi;function z(e,t,l){return t instanceof RegExp?e.replace(t,l):t.reduce((function(e,t){return e.replace(t,l)}),e)}function K(e,t){var l=e.charAt(0),n=e.substr(1).toLowerCase();return t>0&&l>="0"&&l<="9"?"_"+l+n:""+l.toUpperCase()+n}function U(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var l=t.splitRegexp,n=void 0===l?$:l,o=t.stripRegexp,r=void 0===o?j:o,a=t.transform,s=void 0===a?H:a,c=t.delimiter,i=void 0===c?" ":c,d=z(z(e,n,"$1\0$2"),r,"\0"),u=0,m=d.length;"\0"===d.charAt(u);)u++;for(;"\0"===d.charAt(m-1);)m--;return d.slice(u,m).split("\0").map(s).join(i)}(e,V({delimiter:"",transform:K},t))}function Y(e,t){return 0===t?e.toLowerCase():K(e,t)}const q=e=>async({dispatch:t})=>{if(e)try{t(O(e));const l=await N()({path:`wp/v2/block-directory/search?term=${e}`});t(C(l.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>{return[(l=e,void 0===n&&(n={}),U(l,V({transform:Y},n))),t];var l,n}))))),e))}catch{}},G={reducer:m,selectors:l,actions:n,resolvers:o},W=(0,i.createReduxStore)("core/block-directory",G);function Z(){const{uninstallBlockType:e}=(0,i.useDispatch)(W),t=(0,i.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(u.store);return l()&&!t()}),[]),l=(0,i.useSelect)((e=>e(W).getUnusedBlockTypes()),[]);return(0,d.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,c.unregisterBlockType)(t.name)}))}),[t]),null}(0,i.register)(W);const Q=window.wp.compose,J=window.wp.components,X=window.wp.coreData,ee=window.wp.htmlEntities;const te=(0,d.forwardRef)((function({icon:e,size:t=24,...l},n){return(0,d.cloneElement)(e,{width:t,height:t,...l,ref:n})})),le=window.wp.primitives,ne=(0,r.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(le.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})),oe=(0,r.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(le.Path,{d:"M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z"})),re=(0,r.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(le.Path,{fillRule:"evenodd",d:"M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",clipRule:"evenodd"}));const ae=function({rating:e}){const t=.5*Math.round(e/.5),l=Math.floor(e),n=Math.ceil(e-l),o=5-(l+n);return(0,r.createElement)("span",{"aria-label":(0,v.sprintf)((0,v.__)("%s out of 5 stars"),t)},Array.from({length:l}).map(((e,t)=>(0,r.createElement)(te,{key:`full_stars_${t}`,className:"block-directory-block-ratings__star-full",icon:ne,size:16}))),Array.from({length:n}).map(((e,t)=>(0,r.createElement)(te,{key:`half_stars_${t}`,className:"block-directory-block-ratings__star-half-full",icon:oe,size:16}))),Array.from({length:o}).map(((e,t)=>(0,r.createElement)(te,{key:`empty_stars_${t}`,className:"block-directory-block-ratings__star-empty",icon:re,size:16}))))},se=({rating:e})=>(0,r.createElement)("span",{className:"block-directory-block-ratings"},(0,r.createElement)(ae,{rating:e}));const ce=function({icon:e}){const t="block-directory-downloadable-block-icon";return null!==e.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,r.createElement)("img",{className:t,src:e,alt:""}):(0,r.createElement)(p.BlockIcon,{className:t,icon:e,showColors:!0})},ie=({block:e})=>{const t=(0,i.useSelect)((t=>t(W).getErrorNoticeForBlock(e.id)),[e]);return t?(0,r.createElement)("div",{className:"block-directory-downloadable-block-notice"},(0,r.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},t.message,t.isFatal?" "+(0,v.__)("Try reloading the page."):null)):null},de=window.wp.privateApis,{lock:ue,unlock:me}=(0,de.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/block-directory"),{CompositeItemV2:pe}=me(J.privateApis);function ke({title:e,rating:t,ratingCount:l},{hasNotice:n,isInstalled:o,isInstalling:r}){const a=.5*Math.round(t/.5);return!o&&n?(0,v.sprintf)("Retry installing %s.",(0,ee.decodeEntities)(e)):o?(0,v.sprintf)("Add %s.",(0,ee.decodeEntities)(e)):r?(0,v.sprintf)("Installing %s.",(0,ee.decodeEntities)(e)):l<1?(0,v.sprintf)("Install %s.",(0,ee.decodeEntities)(e)):(0,v.sprintf)((0,v._n)("Install %1$s. %2$s stars with %3$s review.","Install %1$s. %2$s stars with %3$s reviews.",l),(0,ee.decodeEntities)(e),a,l)}const be=function({composite:e,item:t,onClick:l}){const{author:n,description:o,icon:a,rating:s,title:u}=t,m=!!(0,c.getBlockType)(t.name),{hasNotice:p,isInstalling:k,isInstallable:b}=(0,i.useSelect)((e=>{const{getErrorNoticeForBlock:l,isInstalling:n}=e(W),o=l(t.id),r=o&&o.isFatal;return{hasNotice:!!o,isInstalling:n(t.id),isInstallable:!r}}),[t]);let g="";return m?g=(0,v.__)("Installed!"):k&&(g=(0,v.__)("Installing…")),(0,r.createElement)(pe,{render:(0,r.createElement)(J.Button,{__experimentalIsFocusable:!0,type:"button",role:"option",className:"block-directory-downloadable-block-list-item",isBusy:k,onClick:e=>{e.preventDefault(),l()},label:ke(t,{hasNotice:p,isInstalled:m,isInstalling:k}),showTooltip:!0,tooltipPosition:"top center"}),store:e,disabled:k||!b},(0,r.createElement)("div",{className:"block-directory-downloadable-block-list-item__icon"},(0,r.createElement)(ce,{icon:a,title:u}),k?(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__spinner"},(0,r.createElement)(J.Spinner,null)):(0,r.createElement)(se,{rating:s})),(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__details"},(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__title"},(0,d.createInterpolateElement)((0,v.sprintf)((0,v.__)("%1$s <span>by %2$s</span>"),(0,ee.decodeEntities)(u),n),{span:(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__author"})})),p?(0,r.createElement)(ie,{block:t}):(0,r.createElement)(r.Fragment,null,(0,r.createElement)("span",{className:"block-directory-downloadable-block-list-item__desc"},g||(0,ee.decodeEntities)(o)),b&&!(m||k)&&(0,r.createElement)(J.VisuallyHidden,null,(0,v.__)("Install block")))))},{CompositeV2:ge,useCompositeStoreV2:we}=me(J.privateApis),_e=()=>{};const Ee=function({items:e,onHover:t=_e,onSelect:l}){const n=we(),{installBlockType:o}=(0,i.useDispatch)(W);return e.length?(0,r.createElement)(ge,{store:n,role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":(0,v.__)("Blocks available for install")},e.map((e=>(0,r.createElement)(be,{key:e.id,composite:n,onClick:()=>{(0,c.getBlockType)(e.name)?l(e):o(e).then((t=>{t&&l(e)})),t(null)},onHover:t,item:e})))):null},ye=window.wp.a11y;const fe=function({children:e,downloadableItems:t,hasLocalBlocks:l}){const n=t.length;return(0,d.useEffect)((()=>{(0,ye.speak)((0,v.sprintf)((0,v._n)("%d additional block is available to install.","%d additional blocks are available to install.",n),n))}),[n]),(0,r.createElement)(r.Fragment,null,!l&&(0,r.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,v.__)("No results available from your installed blocks.")),(0,r.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"}),(0,r.createElement)("div",{className:"block-directory-downloadable-blocks-panel"},(0,r.createElement)("div",{className:"block-directory-downloadable-blocks-panel__header"},(0,r.createElement)("h2",{className:"block-directory-downloadable-blocks-panel__title"},(0,v.__)("Available to install")),(0,r.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},(0,v.__)("Select a block to install and add it to your post."))),e))},he=(0,r.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(le.Path,{d:"M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"}));const ve=function(){return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"block-editor-inserter__no-results"},(0,r.createElement)(te,{className:"block-editor-inserter__no-results-icon",icon:he}),(0,r.createElement)("p",null,(0,v.__)("No results found."))),(0,r.createElement)("div",{className:"block-editor-inserter__tips"},(0,r.createElement)(J.Tip,null,(0,v.__)("Interested in creating your own block?"),(0,r.createElement)("br",null),(0,r.createElement)(J.ExternalLink,{href:"https://developer.wordpress.org/block-editor/"},(0,v.__)("Get started here"),"."))))},Be=[],Ne=e=>(0,i.useSelect)((t=>{const{getDownloadableBlocks:l,isRequestingDownloadableBlocks:n,getInstalledBlockTypes:o}=t(W),r=t(X.store).canUser("read","block-directory/search");let a=Be;if(r){a=l(e);const t=o(),n=a.filter((({name:e})=>{const l=t.some((t=>t.name===e)),n=(0,c.getBlockType)(e);return l||!n}));n.length!==a.length&&(a=n),0===a.length&&(a=Be)}return{hasPermission:r,downloadableBlocks:a,isLoading:n(e)}}),[e]);function Ie({onSelect:e,onHover:t,hasLocalBlocks:l,isTyping:n,filterValue:o}){const{hasPermission:a,downloadableBlocks:s,isLoading:c}=Ne(o);return void 0===a||c||n?(0,r.createElement)(r.Fragment,null,a&&!l&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,v.__)("No results available from your installed blocks.")),(0,r.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"})),(0,r.createElement)("div",{className:"block-directory-downloadable-blocks-panel has-blocks-loading"},(0,r.createElement)(J.Spinner,null))):!1===a||0===s.length?l?null:(0,r.createElement)(ve,null):(0,r.createElement)(fe,{downloadableItems:s,hasLocalBlocks:l},(0,r.createElement)(Ee,{items:s,onSelect:e,onHover:t}))}const Te=function(){const[e,t]=(0,d.useState)(""),l=(0,Q.debounce)(t,400);return(0,r.createElement)(p.__unstableInserterMenuExtension,null,(({onSelect:t,onHover:n,filterValue:o,hasItems:a})=>(e!==o&&l(o),e?(0,r.createElement)(Ie,{onSelect:t,onHover:n,filterValue:e,hasLocalBlocks:a,isTyping:o!==e}):null)))};function Le({items:e}){return e.length?(0,r.createElement)("ul",{className:"block-directory-compact-list"},e.map((({icon:e,id:t,title:l,author:n})=>(0,r.createElement)("li",{key:t,className:"block-directory-compact-list__item"},(0,r.createElement)(ce,{icon:e,title:l}),(0,r.createElement)("div",{className:"block-directory-compact-list__item-details"},(0,r.createElement)("div",{className:"block-directory-compact-list__item-title"},l),(0,r.createElement)("div",{className:"block-directory-compact-list__item-author"},(0,v.sprintf)((0,v.__)("By %s"),n))))))):null}var Se;const{PluginPrePublishPanel:Oe}=null!==(Se=window?.wp?.editPost)&&void 0!==Se?Se:{};function Ce(){const e=(0,i.useSelect)((e=>e(W).getNewBlockTypes()),[]);return e.length?(0,r.createElement)(Oe,{icon:he,title:(0,v.sprintf)((0,v._n)("Added: %d block","Added: %d blocks",e.length),e.length),initialOpen:!0},(0,r.createElement)("p",{className:"installed-blocks-pre-publish-panel__copy"},(0,v._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)),(0,r.createElement)(Le,{items:e})):null}function Ae({attributes:e,block:t,clientId:l}){const n=(0,i.useSelect)((e=>e(W).isInstalling(t.id)),[t.id]),{installBlockType:o}=(0,i.useDispatch)(W),{replaceBlock:a}=(0,i.useDispatch)(p.store);return(0,r.createElement)(J.Button,{onClick:()=>o(t).then((n=>{if(n){const n=(0,c.getBlockType)(t.name),[o]=(0,c.parse)(e.originalContent);o&&n&&a(l,(0,c.createBlock)(n.name,o.attributes,o.innerBlocks))}})),disabled:n,isBusy:n,variant:"primary"},(0,v.sprintf)((0,v.__)("Install %s"),t.title))}const Re=({originalBlock:e,...t})=>{const{originalName:l,originalUndelimitedContent:n,clientId:o}=t.attributes,{replaceBlock:a}=(0,i.useDispatch)(p.store),s=()=>{a(t.clientId,(0,c.createBlock)("core/html",{content:n}))},u=!!n,m=(0,i.useSelect)((e=>{const{canInsertBlockType:t,getBlockRootClientId:l}=e(p.store);return t("core/html",l(o))}),[o]);let k=(0,v.sprintf)((0,v.__)("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),e.title||l);const b=[(0,r.createElement)(Ae,{key:"install",block:e,attributes:t.attributes,clientId:t.clientId})];return u&&m&&(k=(0,v.sprintf)((0,v.__)("Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."),e.title||l),b.push((0,r.createElement)(J.Button,{key:"convert",onClick:s,variant:"tertiary"},(0,v.__)("Keep as HTML")))),(0,r.createElement)("div",{...(0,p.useBlockProps)()},(0,r.createElement)(p.Warning,{actions:b},k),(0,r.createElement)(d.RawHTML,null,n))},De=e=>t=>{const{originalName:l}=t.attributes,{block:n,hasPermission:o}=(0,i.useSelect)((e=>{const{getDownloadableBlocks:t}=e(W),n=t("block:"+l).filter((({name:e})=>l===e));return{hasPermission:e(X.store).canUser("read","block-directory/search"),block:n.length&&n[0]}}),[l]);return o&&n?(0,r.createElement)(Re,{...t,originalBlock:n}):(0,r.createElement)(e,{...t})};(0,a.registerPlugin)("block-directory",{render:()=>(0,r.createElement)(r.Fragment,null,(0,r.createElement)(Z,null),(0,r.createElement)(Te,null),(0,r.createElement)(Ce,null))}),(0,s.addFilter)("blocks.registerBlockType","block-directory/fallback",((e,t)=>("core/missing"!==t||(e.edit=De(e.edit)),e))),(window.wp=window.wp||{}).blockDirectory=t})(); \ No newline at end of file
+(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var l in o)e.o(o,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:o[l]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r: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,{store:()=>G});var o={};e.r(o),e.d(o,{getDownloadableBlocks:()=>h,getErrorNoticeForBlock:()=>y,getErrorNotices:()=>f,getInstalledBlockTypes:()=>m,getNewBlockTypes:()=>g,getUnusedBlockTypes:()=>w,isInstalling:()=>_,isRequestingDownloadableBlocks:()=>k});var l={};e.r(l),e.d(l,{addInstalledBlockType:()=>C,clearErrorNotice:()=>P,fetchDownloadableBlocks:()=>T,installBlockType:()=>S,receiveDownloadableBlocks:()=>L,removeInstalledBlockType:()=>A,setErrorNotice:()=>D,setIsInstalling:()=>R,uninstallBlockType:()=>O});var s={};e.r(s),e.d(s,{getDownloadableBlocks:()=>Y});const n=window.wp.plugins,r=window.wp.hooks,i=window.wp.blocks,a=window.wp.data,c=window.wp.element,d=window.wp.editor,u=(0,a.combineReducers)({downloadableBlocks:(e={},t)=>{switch(t.type){case"FETCH_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{isRequesting:!0}};case"RECEIVE_DOWNLOADABLE_BLOCKS":return{...e,[t.filterValue]:{results:t.downloadableBlocks,isRequesting:!1}}}return e},blockManagement:(e={installedBlockTypes:[],isInstalling:{}},t)=>{switch(t.type){case"ADD_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:[...e.installedBlockTypes,t.item]};case"REMOVE_INSTALLED_BLOCK_TYPE":return{...e,installedBlockTypes:e.installedBlockTypes.filter((e=>e.name!==t.item.name))};case"SET_INSTALLING_BLOCK":return{...e,isInstalling:{...e.isInstalling,[t.blockId]:t.isInstalling}}}return e},errorNotices:(e={},t)=>{switch(t.type){case"SET_ERROR_NOTICE":return{...e,[t.blockId]:{message:t.message,isFatal:t.isFatal}};case"CLEAR_ERROR_NOTICE":const{[t.blockId]:o,...l}=e;return l}return e}}),p=window.wp.blockEditor;function b(e,t=[]){if(!t.length)return!1;if(t.some((({name:t})=>t===e.name)))return!0;for(let o=0;o<t.length;o++)if(b(e,t[o].innerBlocks))return!0;return!1}function k(e,t){var o;return null!==(o=e.downloadableBlocks[t]?.isRequesting)&&void 0!==o&&o}function h(e,t){var o;return null!==(o=e.downloadableBlocks[t]?.results)&&void 0!==o?o:[]}function m(e){return e.blockManagement.installedBlockTypes}const g=(0,a.createRegistrySelector)((e=>t=>{const o=e(p.store).getBlocks();return m(t).filter((e=>b(e,o)))})),w=(0,a.createRegistrySelector)((e=>t=>{const o=e(p.store).getBlocks();return m(t).filter((e=>!b(e,o)))}));function _(e,t){return e.blockManagement.isInstalling[t]||!1}function f(e){return e.errorNotices}function y(e,t){return e.errorNotices[t]}const v=window.wp.i18n,x=window.wp.apiFetch;var j=e.n(x);const B=window.wp.notices,E=window.wp.url,I=e=>new Promise(((t,o)=>{const l=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach((t=>{e[t]&&(l[t]=e[t])})),e.innerHTML&&l.appendChild(document.createTextNode(e.innerHTML)),l.onload=()=>t(!0),l.onerror=()=>o(new Error("Error loading asset.")),document.body.appendChild(l),("link"===l.nodeName.toLowerCase()||"script"===l.nodeName.toLowerCase()&&!l.src)&&t()}));function N(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function T(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function L(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const S=e=>async({registry:t,dispatch:o})=>{const{id:l,name:s}=e;let n=!1;o.clearErrorNotice(l);try{o.setIsInstalling(l,!0);const r=N(e);let a={};if(r)await j()({method:"PUT",url:r,data:{status:"active"}});else{a=(await j()({method:"POST",path:"wp/v2/plugins",data:{slug:l,status:"active"}}))._links}o.addInstalledBlockType({...e,links:{...e.links,...a}});const c=["api_version","title","category","parent","icon","description","keywords","attributes","provides_context","uses_context","supports","styles","example","variations"];await j()({path:(0,E.addQueryArgs)(`/wp/v2/block-types/${s}`,{_fields:c})}).catch((()=>{})).then((e=>{e&&(0,i.unstable__bootstrapServerSideBlockDefinitions)({[s]:Object.fromEntries(Object.entries(e).filter((([e])=>c.includes(e))))})})),await async function(){const e=await j()({url:document.location.href,parse:!1}),t=await e.text(),o=(new window.DOMParser).parseFromString(t,"text/html"),l=Array.from(o.querySelectorAll('link[rel="stylesheet"],script')).filter((e=>e.id&&!document.getElementById(e.id)));for(const e of l)await I(e)}();if(!t.select(i.store).getBlockTypes().some((e=>e.name===s)))throw new Error((0,v.__)("Error registering block. Try reloading the page."));t.dispatch(B.store).createInfoNotice((0,v.sprintf)((0,v.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),n=!0}catch(e){let s=e.message||(0,v.__)("An error occurred."),n=e instanceof Error;const r={folder_exists:(0,v.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,v.__)("Error installing block. You can reload the page and try again.")};r[e.code]&&(n=!0,s=r[e.code]),o.setErrorNotice(l,s,n),t.dispatch(B.store).createErrorNotice(s,{speak:!0,isDismissible:!0})}return o.setIsInstalling(l,!1),n},O=e=>async({registry:t,dispatch:o})=>{try{const t=N(e);await j()({method:"PUT",url:t,data:{status:"inactive"}}),await j()({method:"DELETE",url:t}),o.removeInstalledBlockType(e)}catch(e){t.dispatch(B.store).createErrorNotice(e.message||(0,v.__)("An error occurred."))}};function C(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function A(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function R(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function D(e,t,o=!1){return{type:"SET_ERROR_NOTICE",blockId:e,message:t,isFatal:o}}function P(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var M=function(){return M=Object.assign||function(e){for(var t,o=1,l=arguments.length;o<l;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},M.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function F(e){return e.toLowerCase()}var V=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],H=/[^A-Z0-9]+/gi;function $(e,t,o){return t instanceof RegExp?e.replace(t,o):t.reduce((function(e,t){return e.replace(t,o)}),e)}function z(e,t){var o=e.charAt(0),l=e.substr(1).toLowerCase();return t>0&&o>="0"&&o<="9"?"_"+o+l:""+o.toUpperCase()+l}function K(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var o=t.splitRegexp,l=void 0===o?V:o,s=t.stripRegexp,n=void 0===s?H:s,r=t.transform,i=void 0===r?F:r,a=t.delimiter,c=void 0===a?" ":a,d=$($(e,l,"$1\0$2"),n,"\0"),u=0,p=d.length;"\0"===d.charAt(u);)u++;for(;"\0"===d.charAt(p-1);)p--;return d.slice(u,p).split("\0").map(i).join(c)}(e,M({delimiter:"",transform:z},t))}function U(e,t){return 0===t?e.toLowerCase():z(e,t)}const Y=e=>async({dispatch:t})=>{if(e)try{t(T(e));const o=await j()({path:`wp/v2/block-directory/search?term=${e}`});t(L(o.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>{return[(o=e,void 0===l&&(l={}),K(o,M({transform:U},l))),t];var o,l}))))),e))}catch{}},q={reducer:u,selectors:o,actions:l,resolvers:s},G=(0,a.createReduxStore)("core/block-directory",q);function W(){const{uninstallBlockType:e}=(0,a.useDispatch)(G),t=(0,a.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:o}=e(d.store);return o()&&!t()}),[]),o=(0,a.useSelect)((e=>e(G).getUnusedBlockTypes()),[]);return(0,c.useEffect)((()=>{t&&o.length&&o.forEach((t=>{e(t),(0,i.unregisterBlockType)(t.name)}))}),[t]),null}(0,a.register)(G);const Z=window.wp.compose,J=window.wp.components,Q=window.wp.coreData,X=window.wp.htmlEntities;const ee=(0,c.forwardRef)((function({icon:e,size:t=24,...o},l){return(0,c.cloneElement)(e,{width:t,height:t,...o,ref:l})})),te=window.wp.primitives,oe=window.ReactJSXRuntime,le=(0,oe.jsx)(te.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,oe.jsx)(te.Path,{d:"M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"})}),se=(0,oe.jsx)(te.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,oe.jsx)(te.Path,{d:"M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z"})}),ne=(0,oe.jsx)(te.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,oe.jsx)(te.Path,{fillRule:"evenodd",d:"M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",clipRule:"evenodd"})});const re=function({rating:e}){const t=.5*Math.round(e/.5),o=Math.floor(e),l=Math.ceil(e-o),s=5-(o+l);return(0,oe.jsxs)("span",{"aria-label":(0,v.sprintf)((0,v.__)("%s out of 5 stars"),t),children:[Array.from({length:o}).map(((e,t)=>(0,oe.jsx)(ee,{className:"block-directory-block-ratings__star-full",icon:le,size:16},`full_stars_${t}`))),Array.from({length:l}).map(((e,t)=>(0,oe.jsx)(ee,{className:"block-directory-block-ratings__star-half-full",icon:se,size:16},`half_stars_${t}`))),Array.from({length:s}).map(((e,t)=>(0,oe.jsx)(ee,{className:"block-directory-block-ratings__star-empty",icon:ne,size:16},`empty_stars_${t}`)))]})},ie=({rating:e})=>(0,oe.jsx)("span",{className:"block-directory-block-ratings",children:(0,oe.jsx)(re,{rating:e})});const ae=function({icon:e}){const t="block-directory-downloadable-block-icon";return null!==e.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,oe.jsx)("img",{className:t,src:e,alt:""}):(0,oe.jsx)(p.BlockIcon,{className:t,icon:e,showColors:!0})},ce=({block:e})=>{const t=(0,a.useSelect)((t=>t(G).getErrorNoticeForBlock(e.id)),[e]);return t?(0,oe.jsx)("div",{className:"block-directory-downloadable-block-notice",children:(0,oe.jsxs)("div",{className:"block-directory-downloadable-block-notice__content",children:[t.message,t.isFatal?" "+(0,v.__)("Try reloading the page."):null]})}):null},de=window.wp.privateApis,{lock:ue,unlock:pe}=(0,de.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/block-directory"),{CompositeItemV2:be}=pe(J.privateApis);function ke({title:e,rating:t,ratingCount:o},{hasNotice:l,isInstalled:s,isInstalling:n}){const r=.5*Math.round(t/.5);return!s&&l?(0,v.sprintf)("Retry installing %s.",(0,X.decodeEntities)(e)):s?(0,v.sprintf)("Add %s.",(0,X.decodeEntities)(e)):n?(0,v.sprintf)("Installing %s.",(0,X.decodeEntities)(e)):o<1?(0,v.sprintf)("Install %s.",(0,X.decodeEntities)(e)):(0,v.sprintf)((0,v._n)("Install %1$s. %2$s stars with %3$s review.","Install %1$s. %2$s stars with %3$s reviews.",o),(0,X.decodeEntities)(e),r,o)}const he=function({composite:e,item:t,onClick:o}){const{author:l,description:s,icon:n,rating:r,title:d}=t,u=!!(0,i.getBlockType)(t.name),{hasNotice:p,isInstalling:b,isInstallable:k}=(0,a.useSelect)((e=>{const{getErrorNoticeForBlock:o,isInstalling:l}=e(G),s=o(t.id),n=s&&s.isFatal;return{hasNotice:!!s,isInstalling:l(t.id),isInstallable:!n}}),[t]);let h="";return u?h=(0,v.__)("Installed!"):b&&(h=(0,v.__)("Installing…")),(0,oe.jsxs)(be,{render:(0,oe.jsx)(J.Button,{__experimentalIsFocusable:!0,type:"button",role:"option",className:"block-directory-downloadable-block-list-item",isBusy:b,onClick:e=>{e.preventDefault(),o()},label:ke(t,{hasNotice:p,isInstalled:u,isInstalling:b}),showTooltip:!0,tooltipPosition:"top center"}),store:e,disabled:b||!k,children:[(0,oe.jsxs)("div",{className:"block-directory-downloadable-block-list-item__icon",children:[(0,oe.jsx)(ae,{icon:n,title:d}),b?(0,oe.jsx)("span",{className:"block-directory-downloadable-block-list-item__spinner",children:(0,oe.jsx)(J.Spinner,{})}):(0,oe.jsx)(ie,{rating:r})]}),(0,oe.jsxs)("span",{className:"block-directory-downloadable-block-list-item__details",children:[(0,oe.jsx)("span",{className:"block-directory-downloadable-block-list-item__title",children:(0,c.createInterpolateElement)((0,v.sprintf)((0,v.__)("%1$s <span>by %2$s</span>"),(0,X.decodeEntities)(d),l),{span:(0,oe.jsx)("span",{className:"block-directory-downloadable-block-list-item__author"})})}),p?(0,oe.jsx)(ce,{block:t}):(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)("span",{className:"block-directory-downloadable-block-list-item__desc",children:h||(0,X.decodeEntities)(s)}),k&&!(u||b)&&(0,oe.jsx)(J.VisuallyHidden,{children:(0,v.__)("Install block")})]})]})]})},{CompositeV2:me,useCompositeStoreV2:ge}=pe(J.privateApis),we=()=>{};const _e=function({items:e,onHover:t=we,onSelect:o}){const l=ge(),{installBlockType:s}=(0,a.useDispatch)(G);return e.length?(0,oe.jsx)(me,{store:l,role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":(0,v.__)("Blocks available for install"),children:e.map((e=>(0,oe.jsx)(he,{composite:l,onClick:()=>{(0,i.getBlockType)(e.name)?o(e):s(e).then((t=>{t&&o(e)})),t(null)},onHover:t,item:e},e.id)))}):null},fe=window.wp.a11y;const ye=function({children:e,downloadableItems:t,hasLocalBlocks:o}){const l=t.length;return(0,c.useEffect)((()=>{(0,fe.speak)((0,v.sprintf)((0,v._n)("%d additional block is available to install.","%d additional blocks are available to install.",l),l))}),[l]),(0,oe.jsxs)(oe.Fragment,{children:[!o&&(0,oe.jsx)("p",{className:"block-directory-downloadable-blocks-panel__no-local",children:(0,v.__)("No results available from your installed blocks.")}),(0,oe.jsx)("div",{className:"block-editor-inserter__quick-inserter-separator"}),(0,oe.jsxs)("div",{className:"block-directory-downloadable-blocks-panel",children:[(0,oe.jsxs)("div",{className:"block-directory-downloadable-blocks-panel__header",children:[(0,oe.jsx)("h2",{className:"block-directory-downloadable-blocks-panel__title",children:(0,v.__)("Available to install")}),(0,oe.jsx)("p",{className:"block-directory-downloadable-blocks-panel__description",children:(0,v.__)("Select a block to install and add it to your post.")})]}),e]})]})},ve=(0,oe.jsx)(te.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,oe.jsx)(te.Path,{d:"M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"})});const xe=function(){return(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsxs)("div",{className:"block-editor-inserter__no-results",children:[(0,oe.jsx)(ee,{className:"block-editor-inserter__no-results-icon",icon:ve}),(0,oe.jsx)("p",{children:(0,v.__)("No results found.")})]}),(0,oe.jsx)("div",{className:"block-editor-inserter__tips",children:(0,oe.jsxs)(J.Tip,{children:[(0,v.__)("Interested in creating your own block?"),(0,oe.jsx)("br",{}),(0,oe.jsxs)(J.ExternalLink,{href:"https://developer.wordpress.org/block-editor/",children:[(0,v.__)("Get started here"),"."]})]})})]})},je=[],Be=e=>(0,a.useSelect)((t=>{const{getDownloadableBlocks:o,isRequestingDownloadableBlocks:l,getInstalledBlockTypes:s}=t(G),n=t(Q.store).canUser("read","block-directory/search");let r=je;if(n){r=o(e);const t=s(),l=r.filter((({name:e})=>{const o=t.some((t=>t.name===e)),l=(0,i.getBlockType)(e);return o||!l}));l.length!==r.length&&(r=l),0===r.length&&(r=je)}return{hasPermission:n,downloadableBlocks:r,isLoading:l(e)}}),[e]);function Ee({onSelect:e,onHover:t,hasLocalBlocks:o,isTyping:l,filterValue:s}){const{hasPermission:n,downloadableBlocks:r,isLoading:i}=Be(s);return void 0===n||i||l?(0,oe.jsxs)(oe.Fragment,{children:[n&&!o&&(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)("p",{className:"block-directory-downloadable-blocks-panel__no-local",children:(0,v.__)("No results available from your installed blocks.")}),(0,oe.jsx)("div",{className:"block-editor-inserter__quick-inserter-separator"})]}),(0,oe.jsx)("div",{className:"block-directory-downloadable-blocks-panel has-blocks-loading",children:(0,oe.jsx)(J.Spinner,{})})]}):!1===n||0===r.length?o?null:(0,oe.jsx)(xe,{}):(0,oe.jsx)(ye,{downloadableItems:r,hasLocalBlocks:o,children:(0,oe.jsx)(_e,{items:r,onSelect:e,onHover:t})})}const Ie=function(){const[e,t]=(0,c.useState)(""),o=(0,Z.debounce)(t,400);return(0,oe.jsx)(p.__unstableInserterMenuExtension,{children:({onSelect:t,onHover:l,filterValue:s,hasItems:n})=>(e!==s&&o(s),e?(0,oe.jsx)(Ee,{onSelect:t,onHover:l,filterValue:e,hasLocalBlocks:n,isTyping:s!==e}):null)})};function Ne({items:e}){return e.length?(0,oe.jsx)("ul",{className:"block-directory-compact-list",children:e.map((({icon:e,id:t,title:o,author:l})=>(0,oe.jsxs)("li",{className:"block-directory-compact-list__item",children:[(0,oe.jsx)(ae,{icon:e,title:o}),(0,oe.jsxs)("div",{className:"block-directory-compact-list__item-details",children:[(0,oe.jsx)("div",{className:"block-directory-compact-list__item-title",children:o}),(0,oe.jsx)("div",{className:"block-directory-compact-list__item-author",children:(0,v.sprintf)((0,v.__)("By %s"),l)})]})]},t)))}):null}var Te;const{PluginPrePublishPanel:Le}=null!==(Te=window?.wp?.editor)&&void 0!==Te?Te:{};function Se(){const e=(0,a.useSelect)((e=>e(G).getNewBlockTypes()),[]);return e.length?(0,oe.jsxs)(Le,{icon:ve,title:(0,v.sprintf)((0,v._n)("Added: %d block","Added: %d blocks",e.length),e.length),initialOpen:!0,children:[(0,oe.jsx)("p",{className:"installed-blocks-pre-publish-panel__copy",children:(0,v._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)}),(0,oe.jsx)(Ne,{items:e})]}):null}function Oe({attributes:e,block:t,clientId:o}){const l=(0,a.useSelect)((e=>e(G).isInstalling(t.id)),[t.id]),{installBlockType:s}=(0,a.useDispatch)(G),{replaceBlock:n}=(0,a.useDispatch)(p.store);return(0,oe.jsx)(J.Button,{onClick:()=>s(t).then((l=>{if(l){const l=(0,i.getBlockType)(t.name),[s]=(0,i.parse)(e.originalContent);s&&l&&n(o,(0,i.createBlock)(l.name,s.attributes,s.innerBlocks))}})),__experimentalIsFocusable:!0,disabled:l,isBusy:l,variant:"primary",children:(0,v.sprintf)((0,v.__)("Install %s"),t.title)})}const Ce=({originalBlock:e,...t})=>{const{originalName:o,originalUndelimitedContent:l,clientId:s}=t.attributes,{replaceBlock:n}=(0,a.useDispatch)(p.store),r=()=>{n(t.clientId,(0,i.createBlock)("core/html",{content:l}))},d=!!l,u=(0,a.useSelect)((e=>{const{canInsertBlockType:t,getBlockRootClientId:o}=e(p.store);return t("core/html",o(s))}),[s]);let b=(0,v.sprintf)((0,v.__)("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),e.title||o);const k=[(0,oe.jsx)(Oe,{block:e,attributes:t.attributes,clientId:t.clientId},"install")];return d&&u&&(b=(0,v.sprintf)((0,v.__)("Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."),e.title||o),k.push((0,oe.jsx)(J.Button,{onClick:r,variant:"tertiary",children:(0,v.__)("Keep as HTML")},"convert"))),(0,oe.jsxs)("div",{...(0,p.useBlockProps)(),children:[(0,oe.jsx)(p.Warning,{actions:k,children:b}),(0,oe.jsx)(c.RawHTML,{children:l})]})},Ae=e=>t=>{const{originalName:o}=t.attributes,{block:l,hasPermission:s}=(0,a.useSelect)((e=>{const{getDownloadableBlocks:t}=e(G),l=t("block:"+o).filter((({name:e})=>o===e));return{hasPermission:e(Q.store).canUser("read","block-directory/search"),block:l.length&&l[0]}}),[o]);return s&&l?(0,oe.jsx)(Ce,{...t,originalBlock:l}):(0,oe.jsx)(e,{...t})};(0,n.registerPlugin)("block-directory",{render:()=>(0,oe.jsxs)(oe.Fragment,{children:[(0,oe.jsx)(W,{}),(0,oe.jsx)(Ie,{}),(0,oe.jsx)(Se,{})]})}),(0,r.addFilter)("blocks.registerBlockType","block-directory/fallback",((e,t)=>("core/missing"!==t||(e.edit=Ae(e.edit)),e))),(window.wp=window.wp||{}).blockDirectory=t})(); \ No newline at end of file