!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.i18n,n=window.wp.element,r=window.wp.compose,i=window.wp.data,o=window.wp.components,s=window.wp.plugins;function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}function c(e,t,n){return(t=u(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,u(r.key),r)}}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}var f=window.wp.a11y,g=window.wp.apiFetch,b=e.n(g),y=window.lodash,m=window.ReactJSXRuntime;function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}var w=function(e){function n(e){var t,r,i,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),r=this,o=[e],i=l(i=n),(t=function(e,t){if(t&&("object"==a(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(r,h()?Reflect.construct(i,o||[],l(r).constructor):i.apply(r,o))).updateSingularImagesSetting=t.updateSingularImagesSetting.bind(t),t.state={typesWithSingularImagesEnabled:[],currentUserCanEditThemeOptions:!1,updating:!1},t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(n,e),r=n,(i=[{key:"componentDidMount",value:function(){var e=this;b()({path:"/genesis/v1/singular-images"}).then((function(t){e.setState({typesWithSingularImagesEnabled:t})})),b()({path:"/wp/v2/users/me?context=edit"}).then((function(t){t.capabilities.edit_theme_options&&e.setState({currentUserCanEditThemeOptions:t.capabilities.edit_theme_options})}))}},{key:"postTypeHasSingularImagesDisabled",value:function(){return!this.state.typesWithSingularImagesEnabled.includes(this.props.currentPostType)}},{key:"updateSingularImagesSetting",value:function(e){var n=this;this.setState({updating:!0});var r={path:"/genesis/v1/singular-images",method:"PUT",data:c({},this.props.currentPostType,e)};return b()(r).then((function(e){n.setState({updating:!1,typesWithSingularImagesEnabled:e});
/* translators: %s: the current page type, such as “Pages” or “Posts”. */
var r=(0,t.sprintf)((0,t.__)("Featured images now enabled on %s.","genesis"),n.props.currentPostTypeLabel);n.postTypeHasSingularImagesDisabled()&&(
/* translators: %s: the current page type, such as “Pages” or “Posts”. */
r=(0,t.sprintf)((0,t.__)("Featured images now disabled on %s.","genesis"),n.props.currentPostTypeLabel)),(0,f.speak)(r,"assertive")})),!1}},{key:"render",value:function(){var e=this;if(!this.state.currentUserCanEditThemeOptions)return"";if(this.state.updating){
/* translators: %s: the current page type, such as “Pages” or “Posts”. */
var n=(0,t.sprintf)((0,t.__)("Disabling images on %s...","genesis"),this.props.currentPostTypeLabel);return this.postTypeHasSingularImagesDisabled()&&(
/* translators: %s: the current page type, such as “Pages” or “Posts”. */
n=(0,t.sprintf)((0,t.__)("Enabling images on %s...","genesis"),this.props.currentPostTypeLabel)),(0,m.jsxs)("p",{children:[(0,m.jsx)("span",{children:n}),(0,m.jsx)(o.Spinner,{})]})}var r="genesis-sidebar-label-enabled",i=(0,t.sprintf)((0,t.__)("Featured images are enabled on %s. ","genesis"),this.props.currentPostTypeLabel),s=(0,t.sprintf)((0,t.__)("Disable featured images on all %s?"),this.props.currentPostTypeLabel),a=(0,t.__)("Disable images.","genesis"),u=0;
/* translators: %s: the current page type, such as “Pages” or “Posts”. */return this.postTypeHasSingularImagesDisabled()&&(r="genesis-sidebar-label-disabled",
/* translators: %s: the current page type, such as “Pages” or “Posts”. */
i=(0,t.sprintf)((0,t.__)("Featured images are disabled on %s.","genesis"),this.props.currentPostTypeLabel),
/* translators: %s: the current page type, such as “Pages” or “Posts”. */
s=(0,t.sprintf)((0,t.__)("Enable featured images on all %s"),this.props.currentPostTypeLabel),a=(0,t.__)("Enable images.","genesis"),u=1),(0,m.jsxs)("p",{className:r,children:[i+" ",(0,m.jsx)("button",{className:"genesis-sidebar-text-button",onClick:function(){return e.updateSingularImagesSetting(u)},"aria-label":s,children:a})]})}}])&&p(r.prototype,i),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,i}(n.Component),v=(0,r.compose)([(0,i.withSelect)((function(){var e=(0,i.select)("core/editor").getCurrentPostType(),n=(0,i.select)("core").getPostType(e);return{currentPostType:e,currentPostTypeLabel:(0,y.get)(n,"name",(0,t.__)("Entries","genesis"))}}))])(w);function _(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var O=(0,r.compose)([(0,i.withSelect)((function(){return{hideFeaturedImage:(0,i.select)("core/editor").getEditedPostAttribute("meta")._genesis_hide_singular_image}})),(0,i.withDispatch)((function(e){return{onUpdate:function(t){var n,r;e("core/editor").editPost({meta:(n=!!t,r=(0,i.select)("core/editor").getEditedPostAttribute("meta"),P(P({},Object.keys(r).filter((function(e){return e.startsWith("_genesis")})).reduce((function(e,t){return e[t]=r[t],null===e[t]&&(e[t]=!1),e}),{})),{},c({},"_genesis_hide_singular_image",n)))})}}}))])((function(e){var r=e.hideFeaturedImage,i=void 0!==r&&r,s=e.onUpdate;return(0,m.jsx)(n.Fragment,{children:(0,m.jsx)(o.Fill,{name:"GenesisSidebar",children:(0,m.jsxs)(o.PanelBody,{initialOpen:!0,title:(0,t.__)("Images","genesis"),children:[(0,m.jsx)(o.PanelRow,{children:(0,m.jsx)(o.CheckboxControl,{label:(0,t.__)("Hide Featured Image","genesis"),checked:!!i,onChange:function(){return s(!i)}})}),(0,m.jsx)(o.PanelRow,{children:(0,m.jsx)(v,{})})]})})})}));(0,s.registerPlugin)("genesis-image-toggle",{render:O})}();