7 lines
38 KiB
JavaScript
7 lines
38 KiB
JavaScript
/*! This file is auto-generated */
|
||
!function(){var e={4403:function(e,t){var n;
|
||
/*!
|
||
Copyright (c) 2018 Jed Watson.
|
||
Licensed under the MIT License (MIT), see
|
||
http://jedwatson.github.io/classnames
|
||
*/!function(){"use strict";var r={}.hasOwnProperty;function s(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var i=typeof n;if("string"===i||"number"===i)e.push(n);else if(Array.isArray(n)){if(n.length){var o=s.apply(null,n);o&&e.push(o)}}else if("object"===i)if(n.toString===Object.prototype.toString)for(var a in n)r.call(n,a)&&n[a]&&e.push(a);else e.push(n.toString())}}return e.join(" ")}e.exports?(s.default=s,e.exports=s):void 0===(n=function(){return s}.apply(t,[]))||(e.exports=n)}()}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};!function(){"use strict";n.r(r),n.d(r,{initialize:function(){return Qe}});var e={};n.r(e),n.d(e,{disableComplementaryArea:function(){return x},enableComplementaryArea:function(){return I},pinItem:function(){return W},setFeatureDefaults:function(){return N},setFeatureValue:function(){return A},toggleFeature:function(){return T},unpinItem:function(){return B}});var t={};n.r(t),n.d(t,{getActiveComplementaryArea:function(){return F},isFeatureActive:function(){return P},isItemPinned:function(){return M}});var s={};n.r(s),n.d(s,{__experimentalGetInsertionPoint:function(){return ne},isInserterOpened:function(){return te}});var i={};n.r(i),n.d(i,{setIsInserterOpened:function(){return re}});var o=window.wp.element,a=window.wp.blockLibrary,c=window.wp.widgets,l=window.wp.blocks,d=window.wp.data,u=n(4403),m=n.n(u),h=window.wp.components,p=window.wp.i18n,g=window.wp.primitives;var b=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"}));function w(e){let{as:t=h.DropdownMenu,className:n,label:r=(0,p.__)("Options"),popoverProps:s,toggleProps:i,children:a}=e;return(0,o.createElement)(t,{className:m()("interface-more-menu-dropdown",n),icon:b,label:r,popoverProps:{position:"bottom left",...s,className:m()("interface-more-menu-dropdown__content",null==s?void 0:s.className)},toggleProps:{tooltipPosition:"bottom",...i}},(e=>a(e)))}var f=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_=window.wp.a11y,v=window.lodash;const E=(0,d.combineReducers)({features(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if("SET_FEATURE_DEFAULTS"===t.type){const{scope:n,defaults:r}=t;return{...e,[n]:{...e[n],...r}}}return e}}),y=(0,d.combineReducers)({features(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if("SET_FEATURE_VALUE"===t.type){const{scope:n,featureName:r,value:s}=t;return{...e,[n]:{...e[n],[r]:s}}}return e}}),k=(0,d.combineReducers)({singleEnableItems:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{type:t,itemType:n,scope:r,item:s}=arguments.length>1?arguments[1]:void 0;return"SET_SINGLE_ENABLE_ITEM"===t&&n&&r?{...e,[n]:{...e[n],[r]:s||null}}:e},multipleEnableItems:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{type:t,itemType:n,scope:r,item:s,isEnable:i}=arguments.length>1?arguments[1]:void 0;if("SET_MULTIPLE_ENABLE_ITEM"!==t||!n||!r||!s||(0,v.get)(e,[n,r,s])===i)return e;const o=e[n]||{},a=o[r]||{};return{...e,[n]:{...o,[r]:{...a,[s]:i||!1}}}}});var C=(0,d.combineReducers)({enableItems:k,preferenceDefaults:E,preferences:y});function S(e,t,n){return{type:"SET_SINGLE_ENABLE_ITEM",itemType:e,scope:t,item:n}}function I(e,t){return S("complementaryArea",e,t)}function x(e){return S("complementaryArea",e,void 0)}function z(e,t,n,r){return{type:"SET_MULTIPLE_ENABLE_ITEM",itemType:e,scope:t,item:n,isEnable:r}}function W(e,t){return z("pinnedItems",e,t,!0)}function B(e,t){return z("pinnedItems",e,t,!1)}function T(e,t){return function(n){let{select:r,dispatch:s}=n;const i=r.isFeatureActive(e,t);s.setFeatureValue(e,t,!i)}}function A(e,t,n){return{type:"SET_FEATURE_VALUE",scope:e,featureName:t,value:!!n}}function N(e,t){return{type:"SET_FEATURE_DEFAULTS",scope:e,defaults:t}}function F(e,t){return function(e,t,n){return(0,v.get)(e.enableItems.singleEnableItems,[t,n])}(e,"complementaryArea",t)}function M(e,t,n){return!1!==function(e,t,n,r){return(0,v.get)(e.enableItems.multipleEnableItems,[t,n,r])}(e,"pinnedItems",t,n)}function P(e,t,n){var r,s;const i=null===(r=e.preferences.features[t])||void 0===r?void 0:r[n];return!!(void 0!==i?i:null===(s=e.preferenceDefaults.features[t])||void 0===s?void 0:s[n])}const L="core/interface",O=(0,d.createReduxStore)(L,{reducer:C,actions:e,selectors:t,persist:["enableItems","preferences"],__experimentalUseThunks:!0});function D(e){let{scope:t,label:n,info:r,messageActivated:s,messageDeactivated:i,shortcut:a,feature:c}=e;const l=(0,d.useSelect)((e=>e(O).isFeatureActive(t,c)),[c]),{toggleFeature:u}=(0,d.useDispatch)(O);return(0,o.createElement)(h.MenuItem,{icon:l&&f,isSelected:l,onClick:()=>{u(t,c),l?(0,_.speak)(i||(0,p.__)("Feature deactivated")):(0,_.speak)(s||(0,p.__)("Feature activated"))},role:"menuitemcheckbox",info:r,shortcut:a},n)}(0,d.registerStore)(L,{reducer:C,actions:e,selectors:t,persist:["enableItems","preferences"],__experimentalUseThunks:!0});var R=window.wp.keyboardShortcuts,G=window.wp.blockEditor,H=window.wp.compose;function U(e){let{text:t,children:n}=e;const r=(0,H.useCopyToClipboard)(t);return(0,o.createElement)(h.Button,{variant:"secondary",ref:r},n)}class V extends o.Component{constructor(){super(...arguments),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){const{error:e}=this.state;return e?(0,o.createElement)(G.Warning,{className:"customize-widgets-error-boundary",actions:[(0,o.createElement)(U,{key:"copy-error",text:e.stack},(0,p.__)("Copy Error"))]},(0,p.__)("The editor has encountered an unexpected error.")):this.props.children}}var $=window.wp.coreData,j=window.wp.mediaUtils;function q(){return q=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},q.apply(this,arguments)}var K=function(e){let{inspector:t,closeMenu:n,...r}=e;const s=(0,d.useSelect)((e=>e(G.store).getSelectedBlockClientId()),[]),i=(0,o.useMemo)((()=>document.getElementById(`block-${s}`)),[s]);return(0,o.createElement)(h.MenuItem,q({onClick:()=>{t.open({returnFocusWhenClose:i}),n()}},r),(0,p.__)("Show more settings"))},Y=window.wp.keycodes;var J=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"}));var Q=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"}));var X=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}));var Z=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"}));var ee=(0,d.combineReducers)({blockInserterPanel:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0;return"SET_IS_INSERTER_OPENED"===t.type?t.value:e}});function te(e){return!!e.blockInserterPanel}function ne(e){const{rootClientId:t,insertionIndex:n}=e.blockInserterPanel;return{rootClientId:t,insertionIndex:n}}function re(e){return{type:"SET_IS_INSERTER_OPENED",value:e}}const se="core/customize-widgets",ie={reducer:ee,selectors:s,actions:i},oe=(0,d.createReduxStore)(se,ie);(0,d.registerStore)(se,ie);var ae=function e(t){let{setIsOpened:n}=t;const r=(0,H.useInstanceId)(e,"customize-widget-layout__inserter-panel-title"),s=(0,d.useSelect)((e=>e(oe).__experimentalGetInsertionPoint()),[]);return(0,o.createElement)("div",{className:"customize-widgets-layout__inserter-panel","aria-labelledby":r},(0,o.createElement)("div",{className:"customize-widgets-layout__inserter-panel-header"},(0,o.createElement)("h2",{id:r,className:"customize-widgets-layout__inserter-panel-header-title"},(0,p.__)("Add a block")),(0,o.createElement)(h.Button,{className:"customize-widgets-layout__inserter-panel-header-close-button",icon:Z,onClick:()=>n(!1),"aria-label":(0,p.__)("Close inserter")})),(0,o.createElement)("div",{className:"customize-widgets-layout__inserter-panel-content"},(0,o.createElement)(G.__experimentalLibrary,{rootClientId:s.rootClientId,__experimentalInsertionIndex:s.insertionIndex,showInserterHelpPanel:!0,onSelect:()=>n(!1)})))};var ce=(0,o.createElement)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,o.createElement)(g.Path,{d:"M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"}));const le=[{keyCombination:{modifier:"primary",character:"b"},description:(0,p.__)("Make the selected text bold.")},{keyCombination:{modifier:"primary",character:"i"},description:(0,p.__)("Make the selected text italic.")},{keyCombination:{modifier:"primary",character:"k"},description:(0,p.__)("Convert the selected text into a link.")},{keyCombination:{modifier:"primaryShift",character:"k"},description:(0,p.__)("Remove a link.")},{keyCombination:{modifier:"primary",character:"u"},description:(0,p.__)("Underline the selected text.")}];function de(e){let{keyCombination:t,forceAriaLabel:n}=e;const r=t.modifier?Y.displayShortcutList[t.modifier](t.character):t.character,s=t.modifier?Y.shortcutAriaLabel[t.modifier](t.character):t.character;return(0,o.createElement)("kbd",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination","aria-label":n||s},(0,v.castArray)(r).map(((e,t)=>"+"===e?(0,o.createElement)(o.Fragment,{key:t},e):(0,o.createElement)("kbd",{key:t,className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-key"},e))))}var ue=function(e){let{description:t,keyCombination:n,aliases:r=[],ariaLabel:s}=e;return(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-description"},t),(0,o.createElement)("div",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-term"},(0,o.createElement)(de,{keyCombination:n,forceAriaLabel:s}),r.map(((e,t)=>(0,o.createElement)(de,{keyCombination:e,forceAriaLabel:s,key:t})))))};var me=function(e){let{name:t}=e;const{keyCombination:n,description:r,aliases:s}=(0,d.useSelect)((e=>{const{getShortcutKeyCombination:n,getShortcutDescription:r,getShortcutAliases:s}=e(R.store);return{keyCombination:n(t),aliases:s(t),description:r(t)}}),[t]);return n?(0,o.createElement)(ue,{keyCombination:n,description:r,aliases:s}):null};const he=e=>{let{shortcuts:t}=e;return(0,o.createElement)("ul",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut-list",role:"list"},t.map(((e,t)=>(0,o.createElement)("li",{className:"customize-widgets-keyboard-shortcut-help-modal__shortcut",key:t},(0,v.isString)(e)?(0,o.createElement)(me,{name:e}):(0,o.createElement)(ue,e)))))},pe=e=>{let{title:t,shortcuts:n,className:r}=e;return(0,o.createElement)("section",{className:m()("customize-widgets-keyboard-shortcut-help-modal__section",r)},!!t&&(0,o.createElement)("h2",{className:"customize-widgets-keyboard-shortcut-help-modal__section-title"},t),(0,o.createElement)(he,{shortcuts:n}))},ge=e=>{let{title:t,categoryName:n,additionalShortcuts:r=[]}=e;const s=(0,d.useSelect)((e=>e(R.store).getCategoryShortcuts(n)),[n]);return(0,o.createElement)(pe,{title:t,shortcuts:s.concat(r)})};function be(e){let{isModalActive:t,toggleModal:n}=e;const{registerShortcut:r}=(0,d.useDispatch)(R.store);return r({name:"core/customize-widgets/keyboard-shortcuts",category:"main",description:(0,p.__)("Display these keyboard shortcuts."),keyCombination:{modifier:"access",character:"h"}}),(0,R.useShortcut)("core/customize-widgets/keyboard-shortcuts",n),t?(0,o.createElement)(h.Modal,{className:"customize-widgets-keyboard-shortcut-help-modal",title:(0,p.__)("Keyboard shortcuts"),closeLabel:(0,p.__)("Close"),onRequestClose:n},(0,o.createElement)(pe,{className:"customize-widgets-keyboard-shortcut-help-modal__main-shortcuts",shortcuts:["core/customize-widgets/keyboard-shortcuts"]}),(0,o.createElement)(ge,{title:(0,p.__)("Global shortcuts"),categoryName:"global"}),(0,o.createElement)(ge,{title:(0,p.__)("Selection shortcuts"),categoryName:"selection"}),(0,o.createElement)(ge,{title:(0,p.__)("Block shortcuts"),categoryName:"block",additionalShortcuts:[{keyCombination:{character:"/"},description:(0,p.__)("Change the block type after adding a new paragraph."),ariaLabel:(0,p.__)("Forward-slash")}]}),(0,o.createElement)(pe,{title:(0,p.__)("Text formatting"),shortcuts:le})):null}const we={className:"customize-widgets-more-menu__content"};function fe(){const[e,t]=(0,o.useState)(!1),n=()=>t(!e);return(0,R.useShortcut)("core/customize-widgets/keyboard-shortcuts",n),(0,o.createElement)(o.Fragment,null,(0,o.createElement)(w,{as:h.ToolbarDropdownMenu,className:"customize-widgets-more-menu",popoverProps:we},(()=>(0,o.createElement)(o.Fragment,null,(0,o.createElement)(h.MenuGroup,{label:(0,p._x)("View","noun")},(0,o.createElement)(D,{scope:"core/customize-widgets",feature:"fixedToolbar",label:(0,p.__)("Top toolbar"),info:(0,p.__)("Access all block and document tools in a single place"),messageActivated:(0,p.__)("Top toolbar activated"),messageDeactivated:(0,p.__)("Top toolbar deactivated")})),(0,o.createElement)(h.MenuGroup,{label:(0,p.__)("Tools")},(0,o.createElement)(h.MenuItem,{onClick:()=>{t(!0)},shortcut:Y.displayShortcut.access("h")},(0,p.__)("Keyboard shortcuts")),(0,o.createElement)(D,{scope:"core/customize-widgets",feature:"welcomeGuide",label:(0,p.__)("Welcome Guide")}),(0,o.createElement)(h.MenuItem,{role:"menuitem",icon:ce,href:(0,p.__)("https://wordpress.org/support/article/block-based-widgets-editor/"),target:"_blank",rel:"noopener noreferrer"},(0,p.__)("Help"),(0,o.createElement)(h.VisuallyHidden,{as:"span"},(0,p.__)("(opens in a new tab)")))),(0,o.createElement)(h.MenuGroup,{label:(0,p.__)("Preferences")},(0,o.createElement)(D,{scope:"core/customize-widgets",feature:"keepCaretInsideBlock",label:(0,p.__)("Contain text cursor inside block"),info:(0,p.__)("Aids screen readers by stopping text caret from leaving blocks."),messageActivated:(0,p.__)("Contain text cursor inside block activated"),messageDeactivated:(0,p.__)("Contain text cursor inside block deactivated")}))))),(0,o.createElement)(be,{isModalActive:e,toggleModal:n}))}var _e=function(e){let{sidebar:t,inserter:n,isInserterOpened:r,setIsInserterOpened:s,isFixedToolbarActive:i}=e;const[[a,c],l]=(0,o.useState)([t.hasUndo(),t.hasRedo()]);return(0,o.useEffect)((()=>t.subscribeHistory((()=>{l([t.hasUndo(),t.hasRedo()])}))),[t]),(0,o.createElement)(o.Fragment,null,(0,o.createElement)("div",{className:m()("customize-widgets-header",{"is-fixed-toolbar-active":i})},(0,o.createElement)(G.NavigableToolbar,{className:"customize-widgets-header-toolbar","aria-label":(0,p.__)("Document tools")},(0,o.createElement)(h.ToolbarButton,{icon:(0,p.isRTL)()?Q:J,label:(0,p.__)("Undo"),shortcut:Y.displayShortcut.primary("z"),"aria-disabled":!a,onClick:t.undo,className:"customize-widgets-editor-history-button undo-button"}),(0,o.createElement)(h.ToolbarButton,{icon:(0,p.isRTL)()?J:Q,label:(0,p.__)("Redo"),shortcut:Y.displayShortcut.primaryShift("z"),"aria-disabled":!c,onClick:t.redo,className:"customize-widgets-editor-history-button redo-button"}),(0,o.createElement)(h.ToolbarButton,{className:"customize-widgets-header-toolbar__inserter-toggle",isPressed:r,variant:"primary",icon:X,label:(0,p._x)("Add block","Generic label for block inserter button"),onClick:()=>{s((e=>!e))}}),(0,o.createElement)(fe,null))),(0,o.createPortal)((0,o.createElement)(ae,{setIsOpened:s}),n.contentContainer[0]))};var ve=window.wp.isShallowEqual,Ee=n.n(ve);function ye(e){const t=e.match(/^widget_(.+)(?:\[(\d+)\])$/);if(t){return`${t[1]}-${parseInt(t[2],10)}`}return e}function ke(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const r="core/legacy-widget"===e.name&&(e.attributes.id||e.attributes.instance);if(r)if(e.attributes.id)t={id:e.attributes.id};else{const{encoded:r,hash:s,raw:i,...o}=e.attributes.instance;t={idBase:e.attributes.idBase,instance:{...null==n?void 0:n.instance,is_widget_customizer_js_value:!0,encoded_serialized_instance:r,instance_hash_key:s,raw_instance:i,...o}}}else{t={idBase:"block",widgetClass:"WP_Widget_Block",instance:{raw_instance:{content:(0,l.serialize)(e)}}}}return{...(0,v.omit)(n,["form","rendered"]),...t}}function Ce(e){let t,{id:n,idBase:r,number:s,instance:i}=e;const{encoded_serialized_instance:o,instance_hash_key:a,raw_instance:d,...u}=i;if("block"===r){const e=(0,l.parse)(d.content);t=e.length?e[0]:(0,l.createBlock)("core/paragraph",{})}else t=s?(0,l.createBlock)("core/legacy-widget",{idBase:r,instance:{encoded:o,hash:a,raw:d,...u}}):(0,l.createBlock)("core/legacy-widget",{id:n});return(0,c.addWidgetIdToBlock)(t,n)}function Se(e){const[t,n]=(0,o.useState)((()=>e.getWidgets().map((e=>Ce(e)))));(0,o.useEffect)((()=>e.subscribe(((e,t)=>{n((n=>{const r=new Map(e.map((e=>[e.id,e]))),s=new Map(n.map((e=>[(0,c.getWidgetIdFromBlock)(e),e]))),i=t.map((e=>{const t=r.get(e.id);return t&&t===e?s.get(e.id):Ce(e)}));return Ee()(n,i)?n:i}))}))),[e]);const r=(0,o.useCallback)((t=>{n((n=>{if(Ee()(n,t))return n;const r=new Map(n.map((e=>[(0,c.getWidgetIdFromBlock)(e),e]))),s=t.map((t=>{const n=(0,c.getWidgetIdFromBlock)(t);if(n&&r.has(n)){const s=r.get(n),i=e.getWidget(n);return(0,v.isEqual)(t,s)&&i?i:ke(t,i)}return ke(t)}));if(Ee()(e.getWidgets(),s))return n;const i=e.setWidgets(s);return t.reduce(((e,n,r)=>{const s=i[r];return null!==s&&(e===t&&(e=t.slice()),e[r]=(0,c.addWidgetIdToBlock)(n,s)),e}),t)}))}),[e]);return[t,r,r]}const Ie=(0,o.createContext)();function xe(e){let{api:t,sidebarControls:n,children:r}=e;const[s,i]=(0,o.useState)({current:null}),a=(0,o.useCallback)((e=>{for(const t of n){if(t.setting.get().includes(e)){t.sectionInstance.expand({completeCallback(){i({current:e})}});break}}}),[n]);(0,o.useEffect)((()=>{function e(e){const t=ye(e);a(t)}function n(){t.previewer.preview.bind("focus-control-for-setting",e)}return t.previewer.bind("ready",n),()=>{t.previewer.unbind("ready",n),t.previewer.preview.unbind("focus-control-for-setting",e)}}),[t,a]);const c=(0,o.useMemo)((()=>[s,a]),[s,a]);return(0,o.createElement)(Ie.Provider,{value:c},r)}const ze=()=>(0,o.useContext)(Ie);function We(e){let{sidebar:t,settings:n,children:r}=e;const[s,i,a]=Se(t);return function(e){const{selectBlock:t}=(0,d.useDispatch)(G.store),[n]=ze(),r=(0,o.useRef)(e);(0,o.useEffect)((()=>{r.current=e}),[e]),(0,o.useEffect)((()=>{if(n.current){const e=r.current.find((e=>(0,c.getWidgetIdFromBlock)(e)===n.current));if(e){t(e.clientId);const n=document.querySelector(`[data-block="${e.clientId}"]`);null==n||n.focus()}}}),[n,t])}(s),(0,o.createElement)(G.BlockEditorProvider,{value:s,onInput:i,onChange:a,settings:n,useSubRegistry:!1},r)}function Be(e){let{sidebar:t}=e;const{toggleFeature:n}=(0,d.useDispatch)(O),r=t.getWidgets().every((e=>e.id.startsWith("block-")));return(0,o.createElement)("div",{className:"customize-widgets-welcome-guide"},(0,o.createElement)("div",{className:"customize-widgets-welcome-guide__image__wrapper"},(0,o.createElement)("picture",null,(0,o.createElement)("source",{srcSet:"https://s.w.org/images/block-editor/welcome-editor.svg",media:"(prefers-reduced-motion: reduce)"}),(0,o.createElement)("img",{className:"customize-widgets-welcome-guide__image",src:"https://s.w.org/images/block-editor/welcome-editor.gif",width:"312",height:"240",alt:""}))),(0,o.createElement)("h1",{className:"customize-widgets-welcome-guide__heading"},(0,p.__)("Welcome to block Widgets")),(0,o.createElement)("p",{className:"customize-widgets-welcome-guide__text"},r?(0,p.__)("Your theme provides different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site."):(0,p.__)("You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.")),(0,o.createElement)(h.Button,{className:"customize-widgets-welcome-guide__button",variant:"primary",onClick:()=>n("core/customize-widgets","welcomeGuide")},(0,p.__)("Got it")),(0,o.createElement)("hr",{className:"customize-widgets-welcome-guide__separator"}),!r&&(0,o.createElement)("p",{className:"customize-widgets-welcome-guide__more-info"},(0,p.__)("Want to stick with the old widgets?"),(0,o.createElement)("br",null),(0,o.createElement)(h.ExternalLink,{href:(0,p.__)("https://wordpress.org/plugins/classic-widgets/")},(0,p.__)("Get the Classic Widgets plugin."))),(0,o.createElement)("p",{className:"customize-widgets-welcome-guide__more-info"},(0,p.__)("New to the block editor?"),(0,o.createElement)("br",null),(0,o.createElement)(h.ExternalLink,{href:(0,p.__)("https://wordpress.org/support/article/wordpress-editor/")},(0,p.__)("Here's a detailed guide."))))}function Te(e){let{undo:t,redo:n,save:r}=e;return(0,R.useShortcut)("core/customize-widgets/undo",(e=>{t(),e.preventDefault()})),(0,R.useShortcut)("core/customize-widgets/redo",(e=>{n(),e.preventDefault()})),(0,R.useShortcut)("core/customize-widgets/save",(e=>{e.preventDefault(),r()})),null}Te.Register=function(){const{registerShortcut:e,unregisterShortcut:t}=(0,d.useDispatch)(R.store);return(0,o.useEffect)((()=>(e({name:"core/customize-widgets/undo",category:"global",description:(0,p.__)("Undo your last changes."),keyCombination:{modifier:"primary",character:"z"}}),e({name:"core/customize-widgets/redo",category:"global",description:(0,p.__)("Redo your last undo."),keyCombination:{modifier:"primaryShift",character:"z"}}),e({name:"core/customize-widgets/save",category:"global",description:(0,p.__)("Save your changes."),keyCombination:{modifier:"primary",character:"s"}}),()=>{t("core/customize-widgets/undo"),t("core/customize-widgets/redo"),t("core/customize-widgets/save")})),[e]),null};var Ae=Te;function Ne(e){const t=(0,o.useRef)(),n=(0,d.useSelect)((e=>0===e(G.store).getBlockCount()));return(0,o.useEffect)((()=>{if(n&&t.current){const{ownerDocument:e}=t.current;e.activeElement&&e.activeElement!==e.body||t.current.focus()}}),[n]),(0,o.createElement)(G.ButtonBlockAppender,q({},e,{ref:t}))}function Fe(e){let{blockEditorSettings:t,sidebar:n,inserter:r,inspector:s}=e;const[i,a]=function(e){const t=(0,d.useSelect)((e=>e(oe).isInserterOpened()),[]),{setIsInserterOpened:n}=(0,d.useDispatch)(oe);return(0,o.useEffect)((()=>{t?e.open():e.close()}),[e,t]),[t,(0,o.useCallback)((e=>{let t=e;"function"==typeof e&&(t=e((0,d.select)(oe).isInserterOpened())),n(t)}),[n])]}(r),{hasUploadPermissions:c,isFixedToolbarActive:l,keepCaretInsideBlock:u,isWelcomeGuideActive:m}=(0,d.useSelect)((e=>{const{isFeatureActive:t}=e(O);return{hasUploadPermissions:(0,v.defaultTo)(e($.store).canUser("create","media"),!0),isFixedToolbarActive:t("core/customize-widgets","fixedToolbar"),keepCaretInsideBlock:t("core/customize-widgets","keepCaretInsideBlock"),isWelcomeGuideActive:t("core/customize-widgets","welcomeGuide")}}),[]),h=(0,o.useMemo)((()=>{let e;return c&&(e=e=>{let{onError:n,...r}=e;(0,j.uploadMedia)({wpAllowedMimeTypes:t.allowedMimeTypes,onError:e=>{let{message:t}=e;return n(t)},...r})}),{...t,__experimentalSetIsInserterOpened:a,mediaUpload:e,hasFixedToolbar:l,keepCaretInsideBlock:u,__unstableHasCustomAppender:!0}}),[c,t,l,u,a]);return m?(0,o.createElement)(Be,{sidebar:n}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)(G.BlockEditorKeyboardShortcuts.Register,null),(0,o.createElement)(Ae.Register,null),(0,o.createElement)(We,{sidebar:n,settings:h},(0,o.createElement)(Ae,{undo:n.undo,redo:n.redo,save:n.save}),(0,o.createElement)(_e,{sidebar:n,inserter:r,isInserterOpened:i,setIsInserterOpened:a,isFixedToolbarActive:l}),(0,o.createElement)(G.CopyHandler,null,(0,o.createElement)(G.BlockTools,null,(0,o.createElement)(G.__unstableEditorStyles,{styles:h.defaultEditorStyles}),(0,o.createElement)(G.BlockSelectionClearer,null,(0,o.createElement)(G.WritingFlow,{className:"editor-styles-wrapper"},(0,o.createElement)(G.ObserveTyping,null,(0,o.createElement)(G.BlockList,{renderAppender:Ne})))))),(0,o.createPortal)((0,o.createElement)("form",{onSubmit:e=>e.preventDefault()},(0,o.createElement)(G.BlockInspector,null)),s.contentContainer[0])),(0,o.createElement)(G.__unstableBlockSettingsMenuFirstItem,null,(e=>{let{onClose:t}=e;return(0,o.createElement)(K,{inspector:s,closeMenu:t})})))}const Me=(0,o.createContext)();function Pe(e){let{sidebarControls:t,activeSidebarControl:n,children:r}=e;const s=(0,o.useMemo)((()=>({sidebarControls:t,activeSidebarControl:n})),[t,n]);return(0,o.createElement)(Me.Provider,{value:s},r)}function Le(e){let{api:t,sidebarControls:n,blockEditorSettings:r}=e;const[s,i]=(0,o.useState)(null),a=document.getElementById("customize-theme-controls"),c=(0,o.useRef)();!function(e,t){const{hasSelectedBlock:n,hasMultiSelection:r}=(0,d.useSelect)(G.store),{clearSelectedBlock:s}=(0,d.useDispatch)(G.store);(0,o.useEffect)((()=>{if(t.current&&e){const i=e.inspector,o=e.container[0],a=o.ownerDocument,c=a.defaultView;function l(e){!n()&&!r()||!e||!a.contains(e)||o.contains(e)||t.current.contains(e)||e.closest('[role="dialog"]')||i.expanded()||s()}function d(e){l(e.target)}function u(){l(a.activeElement)}return a.addEventListener("mousedown",d),c.addEventListener("blur",u),()=>{a.removeEventListener("mousedown",d),c.removeEventListener("blur",u)}}}),[t,e,n,r,s])}(s,c),(0,o.useEffect)((()=>{const e=n.map((e=>e.subscribe((t=>{t&&i(e)}))));return()=>{e.forEach((e=>e()))}}),[n]);const l=s&&(0,o.createPortal)((0,o.createElement)(V,null,(0,o.createElement)(Fe,{key:s.id,blockEditorSettings:r,sidebar:s.sidebarAdapter,inserter:s.inserter,inspector:s.inspector})),s.container[0]),u=a&&(0,o.createPortal)((0,o.createElement)("div",{className:"customize-widgets-popover",ref:c},(0,o.createElement)(h.Popover.Slot,null)),a);return(0,o.createElement)(R.ShortcutProvider,null,(0,o.createElement)(h.SlotFillProvider,null,(0,o.createElement)(Pe,{sidebarControls:n,activeSidebarControl:s},(0,o.createElement)(xe,{api:t,sidebarControls:n},l,u))))}function Oe(){const{wp:{customize:e}}=window;return class extends e.Section{ready(){const t=function(){const{wp:{customize:e}}=window;return class extends e.Section{constructor(e,t){super(e,t),this.parentSection=t.parentSection,this.returnFocusWhenClose=null,this._isOpen=!1}get isOpen(){return this._isOpen}set isOpen(e){this._isOpen=e,this.triggerActiveCallbacks()}ready(){this.contentContainer[0].classList.add("customize-widgets-layout__inspector")}isContextuallyActive(){return this.isOpen}onChangeExpanded(e,t){super.onChangeExpanded(e,t),this.parentSection&&!t.unchanged&&(e?this.parentSection.collapse({manualTransition:!0}):this.parentSection.expand({manualTransition:!0,completeCallback:()=>{this.returnFocusWhenClose&&!this.contentContainer[0].contains(this.returnFocusWhenClose)&&this.returnFocusWhenClose.focus()}}))}open(){let{returnFocusWhenClose:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.isOpen=!0,this.returnFocusWhenClose=e,this.expand({allowMultiple:!0})}close(){this.collapse({allowMultiple:!0})}collapse(e){this.isOpen=!1,super.collapse(e)}triggerActiveCallbacks(){this.active.callbacks.fireWith(this.active,[!1,!0])}}}();this.inspector=new t(`widgets-inspector-${this.id}`,{title:(0,p.__)("Block Settings"),parentSection:this,customizeAction:[(0,p.__)("Customizing"),(0,p.__)("Widgets"),this.params.title].join(" ▸ ")}),e.section.add(this.inspector),this.contentContainer[0].classList.add("customize-widgets__sidebar-section")}hasSubSectionOpened(){return this.inspector.expanded()}onChangeExpanded(e,t){const n=this.controls(),r={...t,completeCallback(){var s;n.forEach((t=>{var n;null===(n=t.onChangeSectionExpanded)||void 0===n||n.call(t,e,r)})),null===(s=t.completeCallback)||void 0===s||s.call(t)}};r.manualTransition?e?(this.contentContainer.addClass(["busy","open"]),this.contentContainer.removeClass("is-sub-section-open"),this.contentContainer.closest(".wp-full-overlay").addClass("section-open"),this.contentContainer.one("transitionend",(()=>{this.contentContainer.removeClass("busy"),r.completeCallback()}))):(this.contentContainer.addClass(["busy","is-sub-section-open"]),this.contentContainer.closest(".wp-full-overlay").addClass("section-open"),this.contentContainer.removeClass("open"),this.contentContainer.one("transitionend",(()=>{this.contentContainer.removeClass("busy"),r.completeCallback()}))):super.onChangeExpanded(e,r)}}}const{wp:De}=window;function Re(e){const t=e.match(/^(.+)-(\d+)$/);return t?{idBase:t[1],number:parseInt(t[2],10)}:{idBase:e}}function Ge(e){const{idBase:t,number:n}=Re(e);return n?`widget_${t}[${n}]`:`widget_${t}`}class He{constructor(e,t){this.setting=e,this.api=t,this.locked=!1,this.widgetsCache=new WeakMap,this.subscribers=new Set,this.history=[this._getWidgetIds().map((e=>this.getWidget(e)))],this.historyIndex=0,this.historySubscribers=new Set,this._debounceSetHistory=function(e,t,n){let r,s=!1;function i(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];const c=(s?t:e).apply(this,o);return s=!0,clearTimeout(r),r=setTimeout((()=>{s=!1}),n),c}return i.cancel=()=>{s=!1,clearTimeout(r)},i}(this._pushHistory,this._replaceHistory,1e3),this.setting.bind(this._handleSettingChange.bind(this)),this.api.bind("change",this._handleAllSettingsChange.bind(this)),this.undo=this.undo.bind(this),this.redo=this.redo.bind(this),this.save=this.save.bind(this)}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}getWidgets(){return this.history[this.historyIndex]}_emit(){for(const e of this.subscribers)e(...arguments)}_getWidgetIds(){return this.setting.get()}_pushHistory(){this.history=[...this.history.slice(0,this.historyIndex+1),this._getWidgetIds().map((e=>this.getWidget(e)))],this.historyIndex+=1,this.historySubscribers.forEach((e=>e()))}_replaceHistory(){this.history[this.historyIndex]=this._getWidgetIds().map((e=>this.getWidget(e)))}_handleSettingChange(){if(this.locked)return;const e=this.getWidgets();this._pushHistory(),this._emit(e,this.getWidgets())}_handleAllSettingsChange(e){if(this.locked)return;if(!e.id.startsWith("widget_"))return;const t=ye(e.id);if(!this.setting.get().includes(t))return;const n=this.getWidgets();this._pushHistory(),this._emit(n,this.getWidgets())}_createWidget(e){const t=De.customize.Widgets.availableWidgets.findWhere({id_base:e.idBase});let n=e.number;t.get("is_multi")&&!n&&(t.set("multi_number",t.get("multi_number")+1),n=t.get("multi_number"));const r=n?`widget_${e.idBase}[${n}]`:`widget_${e.idBase}`,s={transport:De.customize.Widgets.data.selectiveRefreshableWidgets[t.get("id_base")]?"postMessage":"refresh",previewer:this.setting.previewer};this.api.create(r,r,"",s).set(e.instance);return ye(r)}_removeWidget(e){const t=Ge(e.id),n=this.api(t);if(n){const e=n.get();this.widgetsCache.delete(e)}this.api.remove(t)}_updateWidget(e){const t=this.getWidget(e.id);if(t===e)return e.id;if(t.idBase&&e.idBase&&t.idBase===e.idBase){const t=Ge(e.id);return this.api(t).set(e.instance),e.id}return this._removeWidget(e),this._createWidget(e)}getWidget(e){if(!e)return null;const{idBase:t,number:n}=Re(e),r=Ge(e),s=this.api(r);if(!s)return null;const i=s.get();if(this.widgetsCache.has(i))return this.widgetsCache.get(i);const o={id:e,idBase:t,number:n,instance:i};return this.widgetsCache.set(i,o),o}_updateWidgets(e){this.locked=!0;const t=[],n=e.map((e=>{if(e.id&&this.getWidget(e.id))return t.push(null),this._updateWidget(e);const n=this._createWidget(e);return t.push(n),n}));return this.getWidgets().filter((e=>!n.includes(e.id))).forEach((e=>this._removeWidget(e))),this.setting.set(n),this.locked=!1,t}setWidgets(e){const t=this._updateWidgets(e);return this._debounceSetHistory(),t}hasUndo(){return this.historyIndex>0}hasRedo(){return this.historyIndex<this.history.length-1}_seek(e){const t=this.getWidgets();this.historyIndex=e;const n=this.history[this.historyIndex];this._updateWidgets(n),this._emit(t,this.getWidgets()),this.historySubscribers.forEach((e=>e())),this._debounceSetHistory.cancel()}undo(){this.hasUndo()&&this._seek(this.historyIndex-1)}redo(){this.hasRedo()&&this._seek(this.historyIndex+1)}subscribeHistory(e){return this.historySubscribers.add(e),()=>{this.historySubscribers.delete(e)}}save(){this.api.previewer.save()}}var Ue=window.wp.dom;function Ve(){const{wp:{customize:e}}=window;return class extends e.Control{constructor(){super(...arguments),this.subscribers=new Set}ready(){const t=function(){const{wp:{customize:e}}=window,t=e.OuterSection;return e.OuterSection=class extends t{onChangeExpanded(t,n){return t&&e.section.each((e=>{"outer"===e.params.type&&e.id!==this.id&&e.expanded()&&e.collapse()})),super.onChangeExpanded(t,n)}},e.sectionConstructor.outer=e.OuterSection,class extends e.OuterSection{constructor(){super(...arguments),this.params.type="outer",this.activeElementBeforeExpanded=null,this.contentContainer[0].ownerDocument.defaultView.addEventListener("keydown",(e=>{!this.expanded()||e.keyCode!==Y.ESCAPE&&"Escape"!==e.code||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),(0,d.dispatch)(oe).setIsInserterOpened(!1))}),!0),this.contentContainer.addClass("widgets-inserter"),this.isFromInternalAction=!1,this.expanded.bind((()=>{this.isFromInternalAction||(0,d.dispatch)(oe).setIsInserterOpened(this.expanded()),this.isFromInternalAction=!1}))}open(){if(!this.expanded()){const e=this.contentContainer[0];this.activeElementBeforeExpanded=e.ownerDocument.activeElement,this.isFromInternalAction=!0,this.expand({completeCallback(){const t=Ue.focus.tabbable.find(e)[1];t&&t.focus()}})}}close(){if(this.expanded()){const e=this.contentContainer[0],t=e.ownerDocument.activeElement;this.isFromInternalAction=!0,this.collapse({completeCallback(){e.contains(t)&&this.activeElementBeforeExpanded&&this.activeElementBeforeExpanded.focus()}})}}}}();this.inserter=new t(`widgets-inserter-${this.id}`,{}),e.section.add(this.inserter),this.sectionInstance=e.section(this.section()),this.inspector=this.sectionInstance.inspector,this.sidebarAdapter=new He(this.setting,e)}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}onChangeSectionExpanded(e,t){t.unchanged||(e||(0,d.dispatch)(oe).setIsInserterOpened(!1),this.subscribers.forEach((n=>n(e,t))))}}}var $e=window.wp.hooks;const je=(0,H.createHigherOrderComponent)((e=>t=>{let n=(0,c.getWidgetIdFromBlock)(t);const r=function(){const{sidebarControls:e}=(0,o.useContext)(Me);return e}(),s=function(){const{activeSidebarControl:e}=(0,o.useContext)(Me);return e}(),i=(null==r?void 0:r.length)>1,a=t.name,l=t.clientId,u=(0,d.useSelect)((e=>e(G.store).canInsertBlockType(a,"")),[a]),m=(0,d.useSelect)((e=>e(G.store).getBlock(l)),[l]),{removeBlock:h}=(0,d.useDispatch)(G.store),[,p]=ze();return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(e,t),i&&u&&(0,o.createElement)(G.BlockControls,null,(0,o.createElement)(c.MoveToWidgetArea,{widgetAreas:r.map((e=>({id:e.id,name:e.params.label,description:e.params.description}))),currentWidgetAreaId:null==s?void 0:s.id,onSelect:function(e){const t=r.find((t=>t.id===e));if(n){const e=s.setting,r=t.setting;e((0,v.without)(e(),n)),r([...r(),n])}else{const e=t.sidebarAdapter;h(l);const r=e.setWidgets([...e.getWidgets(),ke(m)]);n=r.reverse().find((e=>!!e))}p(n)}})))}),"withMoveToSidebarToolbarItem");(0,$e.addFilter)("editor.BlockEdit","core/customize-widgets/block-edit",je);(0,$e.addFilter)("editor.MediaUpload","core/edit-widgets/replace-media-upload",(()=>j.MediaUpload));const{wp:qe}=window,Ke=(0,H.createHigherOrderComponent)((e=>t=>{var n,r;const{idBase:s}=t.attributes,i=null!==(n=null===(r=qe.customize.Widgets.data.availableWidgets.find((e=>e.id_base===s)))||void 0===r?void 0:r.is_wide)&&void 0!==n&&n;return(0,o.createElement)(e,q({},t,{isWide:i}))}),"withWideWidgetDisplay");(0,$e.addFilter)("editor.BlockEdit","core/customize-widgets/wide-widget-display",Ke);const{wp:Ye}=window,Je=["core/more","core/block","core/freeform","core/template-part"];function Qe(e,t){(0,d.dispatch)(O).setFeatureDefaults("core/customize-widgets",{fixedToolbar:!1,welcomeGuide:!0}),(0,d.dispatch)(l.store).__experimentalReapplyBlockTypeFilters();const n=(0,a.__experimentalGetCoreBlocks)().filter((e=>!(Je.includes(e.name)||e.name.startsWith("core/post")||e.name.startsWith("core/query")||e.name.startsWith("core/site")||e.name.startsWith("core/navigation"))));(0,a.registerCoreBlocks)(n),(0,c.registerLegacyWidgetBlock)(),(0,c.registerLegacyWidgetVariations)(t),(0,c.registerWidgetGroupBlock)(),(0,l.setFreeformContentHandlerName)("core/html");const r=Ve();Ye.customize.sectionConstructor.sidebar=Oe(),Ye.customize.controlConstructor.sidebar_block_editor=r;const s=document.createElement("div");document.body.appendChild(s),Ye.customize.bind("ready",(()=>{const e=[];Ye.customize.control.each((t=>{t instanceof r&&e.push(t)})),(0,o.render)((0,o.createElement)(Le,{api:Ye.customize,sidebarControls:e,blockEditorSettings:t}),s)}))}}(),(window.wp=window.wp||{}).customizeWidgets=r}(); |