Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/components/topper/TopperItemActions",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/icon","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../prop-types/index","../../config/constants/fragmentEntryTypes","../../config/constants/layoutDataItemTypes","../../contexts/ControlsContext","../../contexts/StoreContext","../../thunks/deleteItem","../../thunks/duplicateItem","../../utils/canBeDuplicated","../../utils/canBeRemoved","../../utils/canBeSaved","../../utils/getFormErrorDescription","../../utils/hideFragment","../../utils/useHasRequiredChild","../SaveFragmentCompositionModal","../layout-data-items/hasDropZoneChild"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({item:e}){const[t,a]=(0,i.useState)(!1),T=(0,d.useDispatch)(),w=(0,E.default)(e.itemId),v=(0,c.useSelectItem)(),L=(0,d.useSelector)((e=>e.widgets)),{fragmentEntryLinks:S,layoutData:D,selectedViewportSize:C}=(0,d.useSelector)((e=>e)),[j,k]=(0,i.useState)(!1),M=e.type===u.LAYOUT_DATA_ITEM_TYPES.fragment&&S[e.config.fragmentEntryLinkId].fragmentEntryType===s.FRAGMENT_ENTRY_TYPES.input,O=(0,i.useMemo)((()=>{const t=[];return e.type===u.LAYOUT_DATA_ITEM_TYPES.dropZone||(0,_.default)(e,D)||M||t.push({action:()=>{if((0,b.default)({dispatch:T,itemId:e.itemId,selectedViewportSize:C}),w()){const{message:e}=(0,h.getFormErrorDescription)({type:h.FORM_ERROR_TYPES.hiddenFragment});(0,l.openToast)({message:e,type:"warning"})}},icon:"hidden",label:Liferay.Language.get("hide-fragment")}),(0,g.default)(e,D)&&t.push({action:()=>k(!0),icon:"disk",label:Liferay.Language.get("save-composition")}),t.length&&t.push({type:"separator"}),(0,m.default)(S,e,D,L)&&(t.push({action:()=>T((0,f.default)({itemId:e.itemId,selectItem:v})),icon:"copy",label:Liferay.Language.get("duplicate")}),t.push({type:"separator"})),(0,y.default)(e,D)&&t.push({action:()=>T((0,p.default)({itemId:e.itemId,selectItem:v})),icon:"trash",label:Liferay.Language.get("delete")}),t}),[T,S,w,M,e,D,C,v,L]);if(!O.length)return null;return i.default.createElement(i.default.Fragment,null,i.default.createElement(o.default,{active:t,alignmentPosition:o.Align.BottomRight,menuElementAttrs:{containerProps:{className:"cadmin"}},onActiveChange:a,trigger:i.default.createElement(n.default,{displayType:"unstyled",small:!0,title:Liferay.Language.get("options")},i.default.createElement(r.default,{className:"page-editor__topper__icon",symbol:"ellipsis-v"}))},i.default.createElement(o.default.ItemList,null,O.map(((e,t,n)=>"separator"===e.type?t!==n.length-1&&i.default.createElement(o.default.Divider,{key:t}):i.default.createElement(i.default.Fragment,{key:t},i.default.createElement(o.default.Item,{onClick:()=>{a(!1),e.action()},symbolLeft:e.icon},i.default.createElement("p",{className:"d-inline-block m-0 ml-4"},e.label))))))),j&&i.default.createElement(I.default,{onCloseModal:()=>k(!1)}))};var n=v(a("@frontend-taglib-clay$clayui/button")),o=w(a("@frontend-taglib-clay$clayui/drop-down")),r=v(a("@frontend-taglib-clay$clayui/icon")),l=a("frontend-js-web"),i=(v(a("liferay!frontend-js-react-web$prop-types")),w(a("liferay!frontend-js-react-web$react"))),s=(a("../../../prop-types/index"),a("../../config/constants/fragmentEntryTypes")),u=a("../../config/constants/layoutDataItemTypes"),c=a("../../contexts/ControlsContext"),d=a("../../contexts/StoreContext"),p=v(a("../../thunks/deleteItem")),f=v(a("../../thunks/duplicateItem")),m=v(a("../../utils/canBeDuplicated")),y=v(a("../../utils/canBeRemoved")),g=v(a("../../utils/canBeSaved")),h=a("../../utils/getFormErrorDescription"),b=v(a("../../utils/hideFragment")),E=v(a("../../utils/useHasRequiredChild")),I=v(a("../SaveFragmentCompositionModal")),_=v(a("../layout-data-items/hasDropZoneChild"));function T(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return T=function(){return e},e}function w(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=T();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r=n?Object.getOwnPropertyDescriptor(e,o):null;r&&(r.get||r.set)?Object.defineProperty(a,o,r):a[o]=e[o]}return a.default=e,t&&t.set(e,a),a}function v(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=TopperItemActions.js.map