mirror of
https://github.com/WordPress/WordPress.git
synced 2024-08-31 01:59:47 +02:00
The following dependencies are being updated: - `copy-webpack-plugin` from `10.2.4` to `11.0.0`. - `dotenv` from `16.0.1` to `16.0.2`. - `dotenv-expand` from `8.0.3` to `9.0.0`. - `sass` from `1.53.0` to `1.55.0`. - `sinon-test` from `3.1.3` to `3.1.4`. - `source-map-loader` from `3.0.1` to `4.0.0`. - `terser-webpack-plugin` from `5.3.1` to `5.3.6`. - `uglify-js` from `3.16.1` to `3.17.1`. - `uuid` from `8.3.2` to `9.0.0`. - `webpack` from `5.72.0` to `5.74.0`. This also contains changes after running `npm audit fix`. Fixes #56641. Built from https://develop.svn.wordpress.org/trunk@54296 git-svn-id: http://core.svn.wordpress.org/trunk@53855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
21 KiB
JavaScript
2 lines
21 KiB
JavaScript
/*! This file is auto-generated */
|
||
!function(){"use strict";var e={n:function(t){var l=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(l,{a:l}),l},d:function(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: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,{store:function(){return W}});var l={};e.r(l),e.d(l,{getDownloadableBlocks:function(){return k},getErrorNoticeForBlock:function(){return h},getErrorNotices:function(){return E},getInstalledBlockTypes:function(){return g},getNewBlockTypes:function(){return _},getUnusedBlockTypes:function(){return f},isInstalling:function(){return w},isRequestingDownloadableBlocks:function(){return b}});var n={};e.r(n),e.d(n,{addInstalledBlockType:function(){return R},clearErrorNotice:function(){return F},fetchDownloadableBlocks:function(){return O},installBlockType:function(){return A},receiveDownloadableBlocks:function(){return C},removeInstalledBlockType:function(){return P},setErrorNotice:function(){return x},setIsInstalling:function(){return M},uninstallBlockType:function(){return D}});var r={};e.r(r),e.d(r,{getDownloadableBlocks:function(){return q}});var o=window.wp.element,a=window.wp.plugins,i=window.wp.hooks,s=window.wp.blocks,c=window.wp.data,d=window.wp.editor;var u=(0,c.combineReducers)({downloadableBlocks:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;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:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{installedBlockTypes:[],isInstalling:{}},t=arguments.length>1?arguments[1]:void 0;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:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;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}}),m=window.wp.blockEditor;function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t.length)return!1;if(t.some((t=>{let{name:l}=t;return l===e.name})))return!0;for(let l=0;l<t.length;l++)if(p(e,t[l].innerBlocks))return!0;return!1}function b(e,t){var l,n;return null!==(l=null===(n=e.downloadableBlocks[t])||void 0===n?void 0:n.isRequesting)&&void 0!==l&&l}function k(e,t){var l,n;return null!==(l=null===(n=e.downloadableBlocks[t])||void 0===n?void 0:n.results)&&void 0!==l?l:[]}function g(e){return e.blockManagement.installedBlockTypes}const _=(0,c.createRegistrySelector)((e=>t=>{const l=e(m.store).getBlocks();return g(t).filter((e=>p(e,l)))})),f=(0,c.createRegistrySelector)((e=>t=>{const l=e(m.store).getBlocks();return g(t).filter((e=>!p(e,l)))}));function w(e,t){return e.blockManagement.isInstalling[t]||!1}function E(e){return e.errorNotices}function h(e,t){return e.errorNotices[t]}var y=window.lodash,v=window.wp.i18n,B=window.wp.apiFetch,N=e.n(B),I=window.wp.notices,T=window.wp.url;const 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 t=>{let{registry:l,dispatch:n}=t;const{id:r,name:o}=e;let a=!1;n.clearErrorNotice(r);try{n.setIsInstalling(r,!0);const t=S(e);let i={};if(t)await N()({method:"PUT",url:t,data:{status:"active"}});else{i=(await N()({method:"POST",path:"wp/v2/plugins",data:{slug:r,status:"active"}}))._links}n.addInstalledBlockType({...e,links:{...e.links,...i}});const c=["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:c})}).catch((()=>{})).then((e=>{e&&(0,s.unstable__bootstrapServerSideBlockDefinitions)({[o]:(0,y.pick)(e,c)})})),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(!l.select(s.store).getBlockTypes().some((e=>e.name===o)))throw new Error((0,v.__)("Error registering block. Try reloading the page."));l.dispatch(I.store).createInfoNotice((0,v.sprintf)((0,v.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),a=!0}catch(e){let t=e.message||(0,v.__)("An error occurred."),o=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]&&(o=!0,t=a[e.code]),n.setErrorNotice(r,t,o),l.dispatch(I.store).createErrorNotice(t,{speak:!0,isDismissible:!0})}return n.setIsInstalling(r,!1),a},D=e=>async t=>{let{registry:l,dispatch:n}=t;try{const t=S(e);await N()({method:"PUT",url:t,data:{status:"inactive"}}),await N()({method:"DELETE",url:t}),n.removeInstalledBlockType(e)}catch(e){l.dispatch(I.store).createErrorNotice(e.message||(0,v.__)("An error occurred."))}};function R(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){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];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 r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},V.apply(this,arguments)};Object.create;Object.create;function H(e){return e.toLowerCase()}var j=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],$=/[^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?j:l,r=t.stripRegexp,o=void 0===r?$:r,a=t.transform,i=void 0===a?H:a,s=t.delimiter,c=void 0===s?" ":s,d=z(z(e,n,"$1\0$2"),o,"\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(i).join(c)}(e,V({delimiter:"",transform:K},t))}function Y(e,t){return 0===t?e.toLowerCase():K(e,t)}const q=e=>async t=>{let{dispatch:l}=t;if(e)try{l(O(e));const t=await N()({path:`wp/v2/block-directory/search?term=${e}`});l(C(t.map((e=>Object.fromEntries(Object.entries(e).map((e=>{let[t,l]=e;return[(n=t,void 0===r&&(r={}),U(n,V({transform:Y},r))),l];var n,r}))))),e))}catch{}},G={reducer:u,selectors:l,actions:n,resolvers:r},W=(0,c.createReduxStore)("core/block-directory",G);function Z(){const{uninstallBlockType:e}=(0,c.useDispatch)(W),t=(0,c.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(d.store);return l()&&!t()}),[]),l=(0,c.useSelect)((e=>e(W).getUnusedBlockTypes()),[]);return(0,o.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,s.unregisterBlockType)(t.name)}))}),[t]),null}(0,c.register)(W);var Q=window.wp.components,J=window.wp.compose,X=window.wp.coreData;function ee(){return ee=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var l=arguments[t];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e},ee.apply(this,arguments)}var te=window.wp.htmlEntities;var le=function(e){let{icon:t,size:l=24,...n}=e;return(0,o.cloneElement)(t,{width:l,height:l,...n})},ne=window.wp.primitives;var re=(0,o.createElement)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(ne.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"}));var oe=(0,o.createElement)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(ne.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"}));var ae=(0,o.createElement)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(ne.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"}));var ie=function(e){let{rating:t}=e;const l=.5*Math.round(t/.5),n=Math.floor(t),r=Math.ceil(t-n),a=5-(n+r);return(0,o.createElement)("span",{"aria-label":(0,v.sprintf)((0,v.__)("%s out of 5 stars"),l)},Array.from({length:n}).map(((e,t)=>(0,o.createElement)(le,{key:`full_stars_${t}`,className:"block-directory-block-ratings__star-full",icon:re,size:16}))),Array.from({length:r}).map(((e,t)=>(0,o.createElement)(le,{key:`half_stars_${t}`,className:"block-directory-block-ratings__star-half-full",icon:oe,size:16}))),Array.from({length:a}).map(((e,t)=>(0,o.createElement)(le,{key:`empty_stars_${t}`,className:"block-directory-block-ratings__star-empty",icon:ae,size:16}))))};var se=e=>{let{rating:t}=e;return(0,o.createElement)("span",{className:"block-directory-block-ratings"},(0,o.createElement)(ie,{rating:t}))};var ce=function(e){let{icon:t}=e;const l="block-directory-downloadable-block-icon";return null!==t.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/)?(0,o.createElement)("img",{className:l,src:t,alt:""}):(0,o.createElement)(m.BlockIcon,{className:l,icon:t,showColors:!0})};var de=e=>{let{block:t}=e;const l=(0,c.useSelect)((e=>e(W).getErrorNoticeForBlock(t.id)),[t]);return l?(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice"},(0,o.createElement)("div",{className:"block-directory-downloadable-block-notice__content"},l.message,l.isFatal?" "+(0,v.__)("Try reloading the page."):null)):null};function ue(e,t){let{title:l,rating:n,ratingCount:r}=e,{hasNotice:o,isInstalled:a,isInstalling:i}=t;const s=.5*Math.round(n/.5);return!a&&o?(0,v.sprintf)("Retry installing %s.",(0,te.decodeEntities)(l)):a?(0,v.sprintf)("Add %s.",(0,te.decodeEntities)(l)):i?(0,v.sprintf)("Installing %s.",(0,te.decodeEntities)(l)):r<1?(0,v.sprintf)("Install %s.",(0,te.decodeEntities)(l)):(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.",r),(0,te.decodeEntities)(l),s,r)}var me=function(e){let{composite:t,item:l,onClick:n}=e;const{author:r,description:a,icon:i,rating:d,title:u}=l,m=!!(0,s.getBlockType)(l.name),{hasNotice:p,isInstalling:b,isInstallable:k}=(0,c.useSelect)((e=>{const{getErrorNoticeForBlock:t,isInstalling:n}=e(W),r=t(l.id),o=r&&r.isFatal;return{hasNotice:!!r,isInstalling:n(l.id),isInstallable:!o}}),[l]);let g="";return m?g=(0,v.__)("Installed!"):b&&(g=(0,v.__)("Installing…")),(0,o.createElement)(Q.__unstableCompositeItem,ee({__experimentalIsFocusable:!0,role:"option",as:Q.Button},t,{className:"block-directory-downloadable-block-list-item",onClick:e=>{e.preventDefault(),n()},isBusy:b,disabled:b||!k,label:ue(l,{hasNotice:p,isInstalled:m,isInstalling:b}),showTooltip:!0,tooltipPosition:"top center"}),(0,o.createElement)("div",{className:"block-directory-downloadable-block-list-item__icon"},(0,o.createElement)(ce,{icon:i,title:u}),b?(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__spinner"},(0,o.createElement)(Q.Spinner,null)):(0,o.createElement)(se,{rating:d})),(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__details"},(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__title"},(0,o.createInterpolateElement)((0,v.sprintf)((0,v.__)("%1$s <span>by %2$s</span>"),(0,te.decodeEntities)(u),r),{span:(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__author"})})),p?(0,o.createElement)(de,{block:l}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__desc"},g||(0,te.decodeEntities)(a)),k&&!(m||b)&&(0,o.createElement)(Q.VisuallyHidden,null,(0,v.__)("Install block")))))};const pe=()=>{};var be=function(e){let{items:t,onHover:l=pe,onSelect:n}=e;const r=(0,Q.__unstableUseCompositeState)(),{installBlockType:a}=(0,c.useDispatch)(W);return t.length?(0,o.createElement)(Q.__unstableComposite,ee({},r,{role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":(0,v.__)("Blocks available for install")}),t.map((e=>(0,o.createElement)(me,{key:e.id,composite:r,onClick:()=>{(0,s.getBlockType)(e.name)?n(e):a(e).then((t=>{t&&n(e)})),l(null)},onHover:l,item:e})))):null},ke=window.wp.a11y;var ge=function(e){let{children:t,downloadableItems:l,hasLocalBlocks:n}=e;const r=l.length;return(0,o.useEffect)((()=>{(0,ke.speak)((0,v.sprintf)((0,v._n)("%d additional block is available to install.","%d additional blocks are available to install.",r),r))}),[r]),(0,o.createElement)(o.Fragment,null,!n&&(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,v.__)("No results available from your installed blocks.")),(0,o.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"}),(0,o.createElement)("div",{className:"block-directory-downloadable-blocks-panel"},(0,o.createElement)("div",{className:"block-directory-downloadable-blocks-panel__header"},(0,o.createElement)("h2",{className:"block-directory-downloadable-blocks-panel__title"},(0,v.__)("Available to install")),(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},(0,v.__)("Select a block to install and add it to your post."))),t))};var _e=(0,o.createElement)(ne.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(ne.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"}));var fe=function(){return(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:"block-editor-inserter__no-results"},(0,o.createElement)(le,{className:"block-editor-inserter__no-results-icon",icon:_e}),(0,o.createElement)("p",null,(0,v.__)("No results found."))),(0,o.createElement)("div",{className:"block-editor-inserter__tips"},(0,o.createElement)(Q.Tip,null,(0,v.__)("Interested in creating your own block?"),(0,o.createElement)("br",null),(0,o.createElement)(Q.ExternalLink,{href:"https://developer.wordpress.org/block-editor/"},(0,v.__)("Get started here"),"."))))};var we=(0,J.compose)([(0,c.withSelect)(((e,t)=>{let{filterValue:l,rootClientId:n=null}=t;const{getDownloadableBlocks:r,isRequestingDownloadableBlocks:o}=e(W),{canInsertBlockType:a}=e(m.store),i=e(X.store).canUser("read","block-directory/search");return{downloadableItems:i?r(l).filter((e=>a(e,n,!0))):[],hasPermission:i,isLoading:o(l)}}))])((function(e){let{downloadableItems:t,onSelect:l,onHover:n,hasLocalBlocks:r,hasPermission:a,isLoading:i,isTyping:s}=e;return void 0===a||i||s?(0,o.createElement)(o.Fragment,null,a&&!r&&(0,o.createElement)(o.Fragment,null,(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__no-local"},(0,v.__)("No results available from your installed blocks.")),(0,o.createElement)("div",{className:"block-editor-inserter__quick-inserter-separator"})),(0,o.createElement)("div",{className:"block-directory-downloadable-blocks-panel has-blocks-loading"},(0,o.createElement)(Q.Spinner,null))):!1===a?r?null:(0,o.createElement)(fe,null):t.length?(0,o.createElement)(ge,{downloadableItems:t,hasLocalBlocks:r},(0,o.createElement)(be,{items:t,onSelect:l,onHover:n})):!r&&(0,o.createElement)(fe,null)}));var Ee=function(){const[e,t]=(0,o.useState)(""),l=(0,y.debounce)(t,400);return(0,o.createElement)(m.__unstableInserterMenuExtension,null,(t=>{let{onSelect:n,onHover:r,filterValue:a,hasItems:i,rootClientId:s}=t;return e!==a&&l(a),e?(0,o.createElement)(we,{onSelect:n,onHover:r,rootClientId:s,filterValue:e,hasLocalBlocks:i,isTyping:a!==e}):null}))},he=window.wp.editPost;function ye(e){let{items:t}=e;return t.length?(0,o.createElement)("ul",{className:"block-directory-compact-list"},t.map((e=>{let{icon:t,id:l,title:n,author:r}=e;return(0,o.createElement)("li",{key:l,className:"block-directory-compact-list__item"},(0,o.createElement)(ce,{icon:t,title:n}),(0,o.createElement)("div",{className:"block-directory-compact-list__item-details"},(0,o.createElement)("div",{className:"block-directory-compact-list__item-title"},n),(0,o.createElement)("div",{className:"block-directory-compact-list__item-author"},(0,v.sprintf)((0,v.__)("By %s"),r))))}))):null}function ve(){const e=(0,c.useSelect)((e=>e(W).getNewBlockTypes()),[]);return e.length?(0,o.createElement)(he.PluginPrePublishPanel,{icon:_e,title:(0,v.sprintf)((0,v._n)("Added: %d block","Added: %d blocks",e.length),e.length),initialOpen:!0},(0,o.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,o.createElement)(ye,{items:e})):null}function Be(e){let{attributes:t,block:l,clientId:n}=e;const r=(0,c.useSelect)((e=>e(W).isInstalling(l.id)),[l.id]),{installBlockType:a}=(0,c.useDispatch)(W),{replaceBlock:i}=(0,c.useDispatch)(m.store);return(0,o.createElement)(Q.Button,{onClick:()=>a(l).then((e=>{if(e){const e=(0,s.getBlockType)(l.name),[r]=(0,s.parse)(t.originalContent);r&&e&&i(n,(0,s.createBlock)(e.name,r.attributes,r.innerBlocks))}})),disabled:r,isBusy:r,variant:"primary"},(0,v.sprintf)((0,v.__)("Install %s"),l.title))}const Ne=e=>{let{originalBlock:t,...l}=e;const{originalName:n,originalUndelimitedContent:r}=l.attributes,{replaceBlock:a}=(0,c.useDispatch)(m.store),i=()=>{a(l.clientId,(0,s.createBlock)("core/html",{content:r}))},d=!!r,u=(0,s.getBlockType)("core/html");let p=(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."),t.title||n);const b=[(0,o.createElement)(Be,{key:"install",block:t,attributes:l.attributes,clientId:l.clientId})];return d&&u&&(p=(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."),t.title||n),b.push((0,o.createElement)(Q.Button,{key:"convert",onClick:i,variant:"link"},(0,v.__)("Keep as HTML")))),(0,o.createElement)("div",(0,m.useBlockProps)(),(0,o.createElement)(m.Warning,{actions:b},p),(0,o.createElement)(o.RawHTML,null,r))};var Ie=e=>t=>{const{originalName:l}=t.attributes,{block:n,hasPermission:r}=(0,c.useSelect)((e=>{const{getDownloadableBlocks:t}=e(W),n=t("block:"+l).filter((e=>{let{name:t}=e;return l===t}));return{hasPermission:e(X.store).canUser("read","block-directory/search"),block:n.length&&n[0]}}),[l]);return r&&n?(0,o.createElement)(Ne,ee({},t,{originalBlock:n})):(0,o.createElement)(e,t)};(0,a.registerPlugin)("block-directory",{render(){return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(Z,null),(0,o.createElement)(Ee,null),(0,o.createElement)(ve,null))}}),(0,i.addFilter)("blocks.registerBlockType","block-directory/fallback",((e,t)=>("core/missing"!==t||(e.edit=Ie(e.edit)),e))),(window.wp=window.wp||{}).blockDirectory=t}(); |