Liferay.Loader.define("frontend-taglib-clay@12.1.4/management_toolbar/CreationMenu",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$react","../get_data_attributes","./FeatureFlagContext","./LinkOrButton","./CreationMenu.scss"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=y(a("@frontend-taglib-clay$clayui/button")),r=f(a("@frontend-taglib-clay$clayui/drop-down")),l=f(a("@frontend-taglib-clay$clayui/icon")),u=f(a("liferay!frontend-js-react-web$classnames")),o=a("frontend-js-web"),i=y(a("liferay!frontend-js-react-web$react")),c=f(a("../get_data_attributes")),d=f(a("./FeatureFlagContext")),s=f(a("./LinkOrButton"));function f(e){return e&&e.__esModule?e:{default:e}}function m(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return m=function(){return e},e}function y(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=m();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}a("./CreationMenu.scss");var b=({maxPrimaryItems:e,maxSecondaryItems:t,maxTotalItems:a=15,onCreateButtonClick:f,onCreationMenuItemClick:m,onShowMoreButtonClick:y,primaryItems:b,secondaryItems:g,viewMoreURL:v})=>{var w,E;const[h,C]=(0,i.useState)(!1),{showDesignImprovements:k}=(0,i.useContext)(d.default),I=(0,i.useRef)(null!==(w=null==g?void 0:g.reduce(((e,t)=>e+t.items.length),0))&&void 0!==w?w:0),L=(0,i.useRef)(b.length+I.current),j=(0,i.useRef)((null==b?void 0:b[0])||(null==g||null===(E=g[0].items)||void 0===E?void 0:E[0])||(null==g?void 0:g[0])),O=()=>{const e=1===L.current?j.current:null;return(null==e?void 0:e.label)||Liferay.Language.get("new")},[M,N]=(0,i.useState)((()=>{const n=b.length,r=I.current,l=e?n>e?e:n:n>8?8:n,u=t?r>t?t:r:r>7?7:r,o=u>a-l?a-l:u;return 0===r?n>a?a:n:n>l?r>o?l+o:l+r:r>o?n+o:n+r})()),_=({item:e})=>i.default.createElement(r.default.Item,p({href:e.href,onClick:t=>{m(t,{item:e})},symbolLeft:e.icon},(0,c.default)(e.data)),(0,o.unescapeHTML)(e.label)),$=()=>{let e=0;return i.default.createElement(r.default.ItemList,{className:(0,u.default)({"dropdown-menu-indicator-start":b.some((e=>e.icon))})},null==b?void 0:b.map(((t,a)=>(e++,!(e>M)&&i.default.createElement(_,{item:t,key:a})))),null==g?void 0:g.map(((t,a)=>i.default.createElement(r.default.Group,{header:t.label,key:a},t.items.map(((t,a)=>(e++,!(e>M)&&i.default.createElement(_,{item:t,key:a})))),t.separator&&i.default.createElement(r.default.Divider,null)))))};return i.default.createElement(i.default.Fragment,null,L.current>1?i.default.createElement(r.default,{active:h,className:"creation-menu",onActiveChange:C,trigger:k?i.default.createElement(n.default,{"aria-label":O(),className:"nav-btn",title:O()},i.default.createElement(l.default,{className:"d-md-none dropdown-icon",symbol:"plus"}),i.default.createElement("span",{className:"d-md-block d-none pl-3 pr-3"},O())):i.default.createElement(n.ClayButtonWithIcon,{"aria-label":O(),className:"nav-btn nav-btn-monospaced",symbol:"plus",title:O()})},M<L.current?i.default.createElement(i.default.Fragment,null,i.default.createElement("div",{className:"inline-scroller"},i.default.createElement($,{primaryItems:b,secondaryItems:g,visibleItemsCount:M})),i.default.createElement("div",{className:"dropdown-caption"},(0,o.sub)(Liferay.Language.get("showing-x-of-x-elements"),M,L.current)),i.default.createElement("div",{className:"dropdown-section"},i.default.createElement(s.default,{button:{block:!0},displayType:"secondary",href:v,onClick:()=>{y?y():N(L.current)}},Liferay.Language.get("more")))):i.default.createElement($,{onCreationMenuItemClick:m,primaryItems:b,secondaryItems:g,visibleItemsCount:L.current})):k?i.default.createElement(i.default.Fragment,null,i.default.createElement(s.default,{"aria-label":O(),button:!0,className:"nav-btn",displayType:"primary",href:j.current.href,onClick:e=>{f(e,{item:j.current})},symbol:"plus",title:O(),wide:!0},Liferay.Language.get("new"))):i.default.createElement(s.default,{"aria-label":O(),button:!0,className:"nav-btn nav-btn-monospaced",displayType:"primary",href:j.current.href,onClick:e=>{f(e,{item:j.current})},symbol:"plus",title:O()}))};t.default=b}}));
//# sourceMappingURL=CreationMenu.js.map