/*! 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 G}});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 f},getUnusedBlockTypes:function(){return _},isInstalling:function(){return w},isRequestingDownloadableBlocks:function(){return b}});var n={};e.r(n),e.d(n,{addInstalledBlockType:function(){return D},clearErrorNotice:function(){return x},fetchDownloadableBlocks:function(){return S},installBlockType:function(){return C},receiveDownloadableBlocks:function(){return O},removeInstalledBlockType:function(){return R},setErrorNotice:function(){return M},setIsInstalling:function(){return P},uninstallBlockType:function(){return A}});var r={};e.r(r),e.d(r,{getDownloadableBlocks:function(){return Y}});var o=window.wp.element,a=window.wp.plugins,i=window.wp.hooks,c=window.wp.blocks,s=window.wp.data,d=window.wp.editor;var u=(0,s.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;lt=>{const l=e(m.store).getBlocks();return g(t).filter((e=>p(e,l)))})),_=(0,s.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.wp.i18n,v=window.wp.apiFetch,B=e.n(v),I=window.wp.notices,N=window.wp.url;const T=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 L(e){if(!e)return!1;const t=e.links["wp:plugin"]||e.links.self;return!(!t||!t.length)&&t[0].href}function S(e){return{type:"FETCH_DOWNLOADABLE_BLOCKS",filterValue:e}}function O(e,t){return{type:"RECEIVE_DOWNLOADABLE_BLOCKS",downloadableBlocks:e,filterValue:t}}const C=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=L(e);let i={};if(t)await B()({method:"PUT",url:t,data:{status:"active"}});else{i=(await B()({method:"POST",path:"wp/v2/plugins",data:{slug:r,status:"active"}}))._links}n.addInstalledBlockType({...e,links:{...e.links,...i}});const s=["api_version","title","category","parent","icon","description","keywords","attributes","provides_context","uses_context","supports","styles","example","variations"];await B()({path:(0,N.addQueryArgs)(`/wp/v2/block-types/${o}`,{_fields:s})}).catch((()=>{})).then((e=>{e&&(0,c.unstable__bootstrapServerSideBlockDefinitions)({[o]:Object.fromEntries(Object.entries(e).filter((e=>{let[t]=e;return s.includes(t)})))})})),await async function(){const e=await B()({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 T(e)}();if(!l.select(c.store).getBlockTypes().some((e=>e.name===o)))throw new Error((0,y.__)("Error registering block. Try reloading the page."));l.dispatch(I.store).createInfoNotice((0,y.sprintf)((0,y.__)("Block %s installed and added."),e.title),{speak:!0,type:"snackbar"}),a=!0}catch(e){let t=e.message||(0,y.__)("An error occurred."),o=e instanceof Error;const a={folder_exists:(0,y.__)("This block is already installed. Try reloading the page."),unable_to_connect_to_filesystem:(0,y.__)("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},A=e=>async t=>{let{registry:l,dispatch:n}=t;try{const t=L(e);await B()({method:"PUT",url:t,data:{status:"inactive"}}),await B()({method:"DELETE",url:t}),n.removeInstalledBlockType(e)}catch(e){l.dispatch(I.store).createErrorNotice(e.message||(0,y.__)("An error occurred."))}};function D(e){return{type:"ADD_INSTALLED_BLOCK_TYPE",item:e}}function R(e){return{type:"REMOVE_INSTALLED_BLOCK_TYPE",item:e}}function P(e,t){return{type:"SET_INSTALLING_BLOCK",blockId:e,isInstalling:t}}function M(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 x(e){return{type:"CLEAR_ERROR_NOTICE",blockId:e}}var F=function(){return F=Object.assign||function(e){for(var t,l=1,n=arguments.length;l0&&l>="0"&&l<="9"?"_"+l+n:""+l.toUpperCase()+n}function K(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var l=t.splitRegexp,n=void 0===l?V:l,r=t.stripRegexp,o=void 0===r?H:r,a=t.transform,i=void 0===a?j:a,c=t.delimiter,s=void 0===c?" ":c,d=$($(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(s)}(e,F({delimiter:"",transform:z},t))}function U(e,t){return 0===t?e.toLowerCase():z(e,t)}const Y=e=>async t=>{let{dispatch:l}=t;if(e)try{l(S(e));const t=await B()({path:`wp/v2/block-directory/search?term=${e}`});l(O(t.map((e=>Object.fromEntries(Object.entries(e).map((e=>{let[t,l]=e;return[(n=t,void 0===r&&(r={}),K(n,F({transform:U},r))),l];var n,r}))))),e))}catch{}},q={reducer:u,selectors:l,actions:n,resolvers:r},G=(0,s.createReduxStore)("core/block-directory",q);function W(){const{uninstallBlockType:e}=(0,s.useDispatch)(G),t=(0,s.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:l}=e(d.store);return l()&&!t()}),[]),l=(0,s.useSelect)((e=>e(G).getUnusedBlockTypes()),[]);return(0,o.useEffect)((()=>{t&&l.length&&l.forEach((t=>{e(t),(0,c.unregisterBlockType)(t.name)}))}),[t]),null}(0,s.register)(G);var Z=window.wp.compose,Q=window.wp.components,J=window.wp.coreData;function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,o.createElement)(te,{key:`full_stars_${t}`,className:"block-directory-block-ratings__star-full",icon:ne,size:16}))),Array.from({length:r}).map(((e,t)=>(0,o.createElement)(te,{key:`half_stars_${t}`,className:"block-directory-block-ratings__star-half-full",icon:re,size:16}))),Array.from({length:a}).map(((e,t)=>(0,o.createElement)(te,{key:`empty_stars_${t}`,className:"block-directory-block-ratings__star-empty",icon:oe,size:16}))))};var ie=e=>{let{rating:t}=e;return(0,o.createElement)("span",{className:"block-directory-block-ratings"},(0,o.createElement)(ae,{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 se=e=>{let{block:t}=e;const l=(0,s.useSelect)((e=>e(G).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,y.__)("Try reloading the page."):null)):null};function de(e,t){let{title:l,rating:n,ratingCount:r}=e,{hasNotice:o,isInstalled:a,isInstalling:i}=t;const c=.5*Math.round(n/.5);return!a&&o?(0,y.sprintf)("Retry installing %s.",(0,ee.decodeEntities)(l)):a?(0,y.sprintf)("Add %s.",(0,ee.decodeEntities)(l)):i?(0,y.sprintf)("Installing %s.",(0,ee.decodeEntities)(l)):r<1?(0,y.sprintf)("Install %s.",(0,ee.decodeEntities)(l)):(0,y.sprintf)((0,y._n)("Install %1$s. %2$s stars with %3$s review.","Install %1$s. %2$s stars with %3$s reviews.",r),(0,ee.decodeEntities)(l),c,r)}var ue=function(e){let{composite:t,item:l,onClick:n}=e;const{author:r,description:a,icon:i,rating:d,title:u}=l,m=!!(0,c.getBlockType)(l.name),{hasNotice:p,isInstalling:b,isInstallable:k}=(0,s.useSelect)((e=>{const{getErrorNoticeForBlock:t,isInstalling:n}=e(G),r=t(l.id),o=r&&r.isFatal;return{hasNotice:!!r,isInstalling:n(l.id),isInstallable:!o}}),[l]);let g="";return m?g=(0,y.__)("Installed!"):b&&(g=(0,y.__)("Installing…")),(0,o.createElement)(Q.__unstableCompositeItem,X({__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:de(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)(ie,{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,y.sprintf)((0,y.__)("%1$s by %2$s"),(0,ee.decodeEntities)(u),r),{span:(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__author"})})),p?(0,o.createElement)(se,{block:l}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"block-directory-downloadable-block-list-item__desc"},g||(0,ee.decodeEntities)(a)),k&&!(m||b)&&(0,o.createElement)(Q.VisuallyHidden,null,(0,y.__)("Install block")))))};const me=()=>{};var pe=function(e){let{items:t,onHover:l=me,onSelect:n}=e;const r=(0,Q.__unstableUseCompositeState)(),{installBlockType:a}=(0,s.useDispatch)(G);return t.length?(0,o.createElement)(Q.__unstableComposite,X({},r,{role:"listbox",className:"block-directory-downloadable-blocks-list","aria-label":(0,y.__)("Blocks available for install")}),t.map((e=>(0,o.createElement)(ue,{key:e.id,composite:r,onClick:()=>{(0,c.getBlockType)(e.name)?n(e):a(e).then((t=>{t&&n(e)})),l(null)},onHover:l,item:e})))):null},be=window.wp.a11y;var ke=function(e){let{children:t,downloadableItems:l,hasLocalBlocks:n}=e;const r=l.length;return(0,o.useEffect)((()=>{(0,be.speak)((0,y.sprintf)((0,y._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,y.__)("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,y.__)("Available to install")),(0,o.createElement)("p",{className:"block-directory-downloadable-blocks-panel__description"},(0,y.__)("Select a block to install and add it to your post."))),t))};var ge=(0,o.createElement)(le.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.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"}));var fe=function(){return(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:"block-editor-inserter__no-results"},(0,o.createElement)(te,{className:"block-editor-inserter__no-results-icon",icon:ge}),(0,o.createElement)("p",null,(0,y.__)("No results found."))),(0,o.createElement)("div",{className:"block-editor-inserter__tips"},(0,o.createElement)(Q.Tip,null,(0,y.__)("Interested in creating your own block?"),(0,o.createElement)("br",null),(0,o.createElement)(Q.ExternalLink,{href:"https://developer.wordpress.org/block-editor/"},(0,y.__)("Get started here"),"."))))};var _e=(0,Z.compose)([(0,s.withSelect)(((e,t)=>{let{filterValue:l,rootClientId:n=null}=t;const{getDownloadableBlocks:r,isRequestingDownloadableBlocks:o}=e(G),{canInsertBlockType:a}=e(m.store),i=e(J.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:c}=e;return void 0===a||i||c?(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,y.__)("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)(ke,{downloadableItems:t,hasLocalBlocks:r},(0,o.createElement)(pe,{items:t,onSelect:l,onHover:n})):!r&&(0,o.createElement)(fe,null)}));var we,Ee,he,ye=function(){const[e,t]=(0,o.useState)(""),l=(0,Z.debounce)(t,400);return(0,o.createElement)(m.__unstableInserterMenuExtension,null,(t=>{let{onSelect:n,onHover:r,filterValue:a,hasItems:i,rootClientId:c}=t;return e!==a&&l(a),e?(0,o.createElement)(_e,{onSelect:n,onHover:r,rootClientId:c,filterValue:e,hasLocalBlocks:i,isTyping:a!==e}):null}))};function ve(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,y.sprintf)((0,y.__)("By %s"),r))))}))):null}const{PluginPrePublishPanel:Be}=null!==(we=null===(Ee=window)||void 0===Ee||null===(he=Ee.wp)||void 0===he?void 0:he.editPost)&&void 0!==we?we:{};function Ie(){const e=(0,s.useSelect)((e=>e(G).getNewBlockTypes()),[]);return e.length?(0,o.createElement)(Be,{icon:ge,title:(0,y.sprintf)((0,y._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,y._n)("The following block has been added to your site.","The following blocks have been added to your site.",e.length)),(0,o.createElement)(ve,{items:e})):null}function Ne(e){let{attributes:t,block:l,clientId:n}=e;const r=(0,s.useSelect)((e=>e(G).isInstalling(l.id)),[l.id]),{installBlockType:a}=(0,s.useDispatch)(G),{replaceBlock:i}=(0,s.useDispatch)(m.store);return(0,o.createElement)(Q.Button,{onClick:()=>a(l).then((e=>{if(e){const e=(0,c.getBlockType)(l.name),[r]=(0,c.parse)(t.originalContent);r&&e&&i(n,(0,c.createBlock)(e.name,r.attributes,r.innerBlocks))}})),disabled:r,isBusy:r,variant:"primary"},(0,y.sprintf)((0,y.__)("Install %s"),l.title))}const Te=e=>{let{originalBlock:t,...l}=e;const{originalName:n,originalUndelimitedContent:r,clientId:a}=l.attributes,{replaceBlock:i}=(0,s.useDispatch)(m.store),d=()=>{i(l.clientId,(0,c.createBlock)("core/html",{content:r}))},u=!!r,p=(0,s.useSelect)((e=>{const{canInsertBlockType:t,getBlockRootClientId:l}=e(m.store);return t("core/html",l(a))}),[a]);let b=(0,y.sprintf)((0,y.__)("Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely."),t.title||n);const k=[(0,o.createElement)(Ne,{key:"install",block:t,attributes:l.attributes,clientId:l.clientId})];return u&&p&&(b=(0,y.sprintf)((0,y.__)("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),k.push((0,o.createElement)(Q.Button,{key:"convert",onClick:d,variant:"tertiary"},(0,y.__)("Keep as HTML")))),(0,o.createElement)("div",(0,m.useBlockProps)(),(0,o.createElement)(m.Warning,{actions:k},b),(0,o.createElement)(o.RawHTML,null,r))};var Le=e=>t=>{const{originalName:l}=t.attributes,{block:n,hasPermission:r}=(0,s.useSelect)((e=>{const{getDownloadableBlocks:t}=e(G),n=t("block:"+l).filter((e=>{let{name:t}=e;return l===t}));return{hasPermission:e(J.store).canUser("read","block-directory/search"),block:n.length&&n[0]}}),[l]);return r&&n?(0,o.createElement)(Te,X({},t,{originalBlock:n})):(0,o.createElement)(e,t)};(0,a.registerPlugin)("block-directory",{render(){return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(W,null),(0,o.createElement)(ye,null),(0,o.createElement)(Ie,null))}}),(0,i.addFilter)("blocks.registerBlockType","block-directory/fallback",((e,t)=>("core/missing"!==t||(e.edit=Le(e.edit)),e))),(window.wp=window.wp||{}).blockDirectory=t}();