Liferay.Loader.define("product-navigation-control-menu-web@6.0.72/js/PageTypeSelector",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/core","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/link","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=void 0;var r=t("@frontend-taglib-clay$clayui/button"),l=t("@frontend-taglib-clay$clayui/core"),n=_interopRequireDefault(t("@frontend-taglib-clay$clayui/drop-down")),i=_interopRequireDefault(t("@frontend-taglib-clay$clayui/icon")),o=_interopRequireDefault(t("@frontend-taglib-clay$clayui/link")),c=t("frontend-js-web"),u=(_interopRequireDefault(t("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var a=_getRequireWildcardCache();if(a&&a.has(e))return a.get(e);var t={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=r?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(t,l,n):t[l]=e[l]}t.default=e,a&&a.set(e,t);return t}(t("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var d=function PageTypeSelector({addCollectionLayoutURL:e,addLayoutURL:a,configureLayoutSetURL:t,namespace:d,pageTypeOptions:g,pageTypeSelectedOption:f,pagesTreeURL:s,showAddIcon:y}){const[p,m]=(0,u.useState)(!1),L=(0,u.useCallback)((()=>{m(!1),(0,c.navigate)(e)}),[e]),b=(0,u.useCallback)((()=>{m(!1),(0,c.navigate)(a)}),[a]);return u.default.createElement("div",{className:"align-items-center d-flex page-type-selector"},u.default.createElement(l.Picker,{"aria-label":Liferay.Language.get("pages-type"),className:"form-control-sm w-auto",items:g.filter((e=>e.items.length)),onSelectionChange:e=>{(0,c.setSessionValue)("".concat(d,"PAGE_TYPE_SELECTED_OPTION"),e).then((()=>{Liferay.Portlet.destroy("#p_p_id".concat(d),!0),(0,c.fetch)(s).then((e=>{if(!e.ok)throw new Error;return e.text()})).then((e=>{const a=document.querySelector(".lfr-product-menu-sidebar .sidebar-body .pages-tree");a.innerHTML="";const t=document.createRange();t.selectNode(a),a.appendChild(t.createContextualFragment(e))})).catch((()=>{(0,c.openToast)({message:Liferay.Language.get("an-unexpected-error-occurred"),title:Liferay.Language.get("error"),type:"danger"})}))}))},selectedKey:f},(e=>u.default.createElement(n.default.Group,{header:e.label,items:e.items,key:e.label},(e=>u.default.createElement(l.Option,{className:"page-type-selector-option",id:e.value,key:e.value},e.label))))),u.default.createElement("div",{className:"flex-fill flex-grow-1 text-right"},y&&u.default.createElement(n.default,{active:p,menuElementAttrs:{containerProps:{className:"cadmin"}},onActiveChange:m,trigger:u.default.createElement(r.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("add-page"),className:"add-page-button",displayType:"unstyled",size:"sm",symbol:"plus",title:Liferay.Language.get("add-page")})},u.default.createElement(n.default.ItemList,null,a&&u.default.createElement(n.default.Item,{"data-value":Liferay.Language.get("add-page"),key:Liferay.Language.get("add-page"),onClick:b,title:Liferay.Language.get("add-page")},Liferay.Language.get("add-page")),e&&u.default.createElement(n.default.Item,{"data-value":Liferay.Language.get("add-collection-page"),key:Liferay.Language.get("add-collection-page"),onClick:L,title:Liferay.Language.get("add-collection-page")},Liferay.Language.get("add-collection-page"))))),u.default.createElement("div",{className:"autofit-col ml-2"},t&&u.default.createElement(o.default,{"aria-label":Liferay.Language.get("configure-pages"),borderless:!0,className:"configure-link",displayType:"unstyled",href:t,monospaced:!0,outline:!0,title:Liferay.Language.get("configure-pages")},u.default.createElement(i.default,{symbol:"cog"}))))};a.default=d}}));
//# sourceMappingURL=PageTypeSelector.js.map