!function(){"use strict";var e={n:function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,{a:r}),r},d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=window.wp.i18n,r=window.wp.element,n=window.wp.compose,s=window.wp.data,i=window.wp.components,o=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 c(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}function u(e,t,r){return(t=c(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}var l=window.wp.a11y,f=window.wp.apiFetch,g=e.n(f),m=window.lodash,h=window.ReactJSXRuntime;function y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(y=function(){return!!e})()}var _=function(e){function r(e){var t,n,s,i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),n=this,i=[e],s=b(s=r),(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)}(n,y()?Reflect.construct(s,i||[],b(n).constructor):s.apply(n,i))).updateBreadcrumbsSetting=t.updateBreadcrumbsSetting.bind(t),t.state={typesWithBreadcrumbsEnabled:[],isStaticHomepage:!1,isPostsPage:!1,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)}(r,e),n=r,(s=[{key:"componentDidMount",value:function(){var e=this;g()({path:"/genesis/v1/breadcrumbs"}).then((function(t){e.setState({typesWithBreadcrumbsEnabled:t})})),g()({path:"/wp/v2/users/me?context=edit"}).then((function(t){t.capabilities.edit_theme_options&&e.setState({currentUserCanEditThemeOptions:t.capabilities.edit_theme_options})})),g()({path:"/genesis/v1/reading-settings"}).then((function(t){"page"===t.show_on_front&&t.page_on_front===e.props.currentPostID&&e.setState({isStaticHomepage:!0}),"posts"===t.show_on_front&&t.page_for_posts===e.props.currentPostID&&e.setState({isPostsPage:!0})}))}},{key:"getPageLabel",value:function(){return this.state.isStaticHomepage?(0,t.__)("the Homepage","genesis"):this.state.isPostsPage?(0,t.__)("the Posts Page","genesis"):this.props.currentPostTypeLabel}},{key:"breadcrumbStatusTextIsNotSupported",value:function(){return!(this.state.currentUserCanEditThemeOptions||this.state.isStaticHomepage||this.state.isPostsPage||["post","page"].includes(this.props.currentPostType))}},{key:"postTypeHasBreadcrumbsDisabled",value:function(){return this.state.isStaticHomepage?!this.state.typesWithBreadcrumbsEnabled.includes("breadcrumb_front_page"):this.state.isPostsPage?!this.state.typesWithBreadcrumbsEnabled.includes("breadcrumb_posts_page"):"post"===this.props.currentPostType?!this.state.typesWithBreadcrumbsEnabled.includes("breadcrumb_single"):"page"===this.props.currentPostType?!this.state.typesWithBreadcrumbsEnabled.includes("breadcrumb_page"):""}},{key:"breadcrumbsValueToUpdate",value:function(){return this.state.isStaticHomepage?"breadcrumb_front_page":this.state.isPostsPage?"breadcrumb_posts_page":"post"===this.props.currentPostType?"breadcrumb_single":"page"===this.props.currentPostType?"breadcrumb_page":""}},{key:"updateBreadcrumbsSetting",value:function(e){var r=this;this.setState({updating:!0});var n={path:"/genesis/v1/breadcrumbs",method:"PUT",data:u({},this.breadcrumbsValueToUpdate(),e)};return g()(n).then((function(e){r.setState({updating:!1,typesWithBreadcrumbsEnabled:e});var n=r.getPageLabel(),s=(0,t.sprintf)((0,t.__)("Breadcrumbs now enabled on %s.","genesis"),n);
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */r.postTypeHasBreadcrumbsDisabled()&&(
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */
s=(0,t.sprintf)((0,t.__)("Breadcrumbs now disabled on %s.","genesis"),n)),(0,l.speak)(s,"assertive")})),!1}},{key:"render",value:function(){var e=this;if(this.breadcrumbStatusTextIsNotSupported())return"";var r=this.getPageLabel();if(this.state.updating){
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */
var n=(0,t.sprintf)((0,t.__)("Disabling breadcrumbs on %s...","genesis"),r);return this.postTypeHasBreadcrumbsDisabled()&&(
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */
n=(0,t.sprintf)((0,t.__)("Enabling breadcrumbs on %s...","genesis"),r)),(0,h.jsxs)("p",{children:[(0,h.jsx)("span",{children:n}),(0,h.jsx)(i.Spinner,{})]})}var s="genesis-sidebar-label-enabled",o=(0,t.sprintf)((0,t.__)("Breadcrumbs are enabled on %s. ","genesis"),r),a=(0,t.sprintf)((0,t.__)("Disable breadcrumbs on %s?"),r),c=(0,t.__)("Disable breadcrumbs.","genesis"),u=0;
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */return this.postTypeHasBreadcrumbsDisabled()&&(s="genesis-sidebar-label-disabled",
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */
o=(0,t.sprintf)((0,t.__)("Breadcrumbs are disabled on %s.","genesis"),r),
/* translators: %s: the current page label, such as “Pages” or “the Homepage”. */
a=(0,t.sprintf)((0,t.__)("Enable breadcrumbs on %s"),r),c=(0,t.__)("Enable breadcrumbs.","genesis"),u=1),(0,h.jsxs)("p",{className:s,children:[o+" ",(0,h.jsx)("button",{className:"genesis-sidebar-text-button",onClick:function(){return e.updateBreadcrumbsSetting(u)},"aria-label":a,children:c})]})}}])&&p(n.prototype,s),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,s}(r.Component),w=(0,n.compose)([(0,s.withSelect)((function(){var e=(0,s.select)("core/editor").getCurrentPostType(),r=(0,s.select)("core").getPostType(e);return{currentPostType:e,currentPostTypeLabel:(0,m.get)(r,"name",(0,t.__)("Entries","genesis")),currentPostID:(0,s.select)("core/editor").getCurrentPostId()}}))])(_);function P(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?P(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):P(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var O=(0,n.compose)([(0,s.withSelect)((function(){return{hideBreadcrumbs:(0,s.select)("core/editor").getEditedPostAttribute("meta")._genesis_hide_breadcrumbs}})),(0,s.withDispatch)((function(e){return{onUpdate:function(t){var r,n;e("core/editor").editPost({meta:(r=!!t,n=(0,s.select)("core/editor").getEditedPostAttribute("meta"),v(v({},Object.keys(n).filter((function(e){return e.startsWith("_genesis")})).reduce((function(e,t){return e[t]=n[t],null===e[t]&&(e[t]=!1),e}),{})),{},u({},"_genesis_hide_breadcrumbs",r)))})}}}))])((function(e){var n=e.hideBreadcrumbs,s=void 0!==n&&n,o=e.onUpdate;return(0,h.jsx)(r.Fragment,{children:(0,h.jsx)(i.Fill,{name:"GenesisSidebar",children:(0,h.jsxs)(i.PanelBody,{initialOpen:!0,title:(0,t.__)("Breadcrumbs","genesis"),children:[(0,h.jsx)(i.PanelRow,{children:(0,h.jsx)(i.CheckboxControl,{label:(0,t.__)("Hide Breadcrumbs","genesis"),checked:!!s,onChange:function(){return o(!s)}})}),(0,h.jsx)(i.PanelRow,{children:(0,h.jsx)(w,{})})]})})})}));(0,o.registerPlugin)("genesis-breadcrumbs-toggle",{render:O})}();