!function(){"use strict";vare={d:function(t,n){for(varrinn)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){returnObject.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeofSymbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{privateApis:function(){returnD},store:function(){returnh}});varn={};e.r(n),e.d(n,{convertSyncedPatternToStatic:function(){returnm},createPattern:function(){returnp},createPatternFromFile:function(){returnd},setEditingPattern:function(){return_}});varr={};e.r(r),e.d(r,{isEditingPattern:function(){returnw}});vara=window.wp.data;varo=(0,a.combineReducers)({isEditingPattern:function(e={},t){return"SET_EDITING_PATTERN"===t?.type?{...e,[t.clientId]:t.isEditing}:e}}),s=window.wp.blocks,c=window.wp.coreData,i=window.wp.blockEditor;constl="all-patterns",u={full:"fully",unsynced:"unsynced"},p=(e,t,n,r)=>async({registry:a})=>{consto=t===u.unsynced?{wp_pattern_sync_status:t}:void0,s={title:e,content:n,status:"publish",meta:o,wp_pattern_category:r};returnawaita.dispatch(c.store).saveEntityRecord("postType","wp_block",s)},d=(e,t)=>async({dispatch:n})=>{constr=awaite.text();leta;try{a=JSON.parse(r)}catch(e){thrownewError("Invalid JSON file")}if("wp_block"!==a.__file||!a.title||!a.content||"string"!=typeofa.title||"string"!=typeofa.content||a.syncStatus&&"string"!=typeofa.syncStatus)thrownewError("Invalid pattern JSON file");returnawaitn.createPattern(a.title,a.syncStatus,a.content,t)},m=e=>({registry:t})=>{constn=t.select(i.store).getBlock(e),r=t.select("core").getEditedEntityRecord("postType","wp_block",n.attributes.ref),a=(0,s.parse)("function"==typeofr.content?r.content(r):r.content);t.dispatch(i.store).replaceBlocks(n.clientId,a)};function_(e,t){return{type:"SET_EDITING_PATTERN",clientId:e,isEditing:t}}functionw(e,t){returne.isEditingPattern[t]}vary=window.wp.privateApis;const{lock:g,unlock:f}=(0,y.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/patterns"),E={reducer:o},h=(0,a.createReduxStore)("core/patterns",{...E});(0,a.register)(h),f(h).registerPrivateActions(n),f(h).registerPrivateSelectors(r);varb=window.wp.element,C=window.wp.components,v=window.wp.i18n,S=window.wp.notices,k=window.wp.compose,P=window.wp.htmlEntities;constT=e=>(0,P.decodeEntities)(e),I="wp_pattern_category";functionB({categoryTerms:e,onChange:t,categoryMap:n}){const[r,a]=(0,b.useState)(""),o=(0,k.useDebounce)(a,500),s=(0,b.useMemo)((()=>Array.from(n.values()).map((e=>T(e.label))).filter((e=>""===r||e.toLowerCase().includes(r.toLowerCase()))).sort(((e,t)=>e.localeCompare(t)))),[r,n]);return(0,b.createElement)(C.FormTokenField,{className:"patterns-menu-items__convert-modal-categories",value:e,suggestions:s,onChange:function(e){constn=e.reduce(((e,t)=>(e.some((e=>e.toLowerCase()===t.toLowerCase()))||e.push(t),e)),[]);t(n)},onInputChange:o,label:(0,v.__)("Categories"),tokenizeOnBlur:!0,__experimentalExpandOnFocus:!0,__next40pxDefaultSize:!0})}functionR({onSuccess:e,onError:t,content:n,onClose:r,className:o="patterns-menu-items__convert-modal"}){const[s,i]=(0,b.useState)(u.full),[p,d]=(0,b.useState)([]),[m,_]=(0,b.useState)(""),[w,y]=(0,b.useState)(!1),{createPattern:g}=f((0,a.useDispatch)(h)),{saveEntityRecord:E,invalidateResolution:k}=(0,a.useDispatch)(c.store),{createErrorNotice:P}=(0,a.useDispatch)(S.store),{corePatternCategories:T,userPatternCategories:R}=(0,a.useSelect)((e=>{const{getUserPatternCategories:t,getBlockPatternCategories:n}=e(c.store);return{corePatternCategories:n(),userPatternCategories:t()}})),N=(0,b.useMemo)((()=>{conste=newMap;return[...R,...T].forEach((t=>{e.has(t.label)||"query"===t.name||e.set(t.label,{label:t.label,value:t.label,name:t.name})})),e}),[R,T]);asyncfunctionM(r,a){if(m&&!w)try{y(!0);constt=awaitPromise.all(p.map((e=>asyncfunction(e){try{constt=N.get(e),n=t?{name:t