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