Liferay.Loader.define("knowledge-base-web@5.0.98/admin/js/KBDropdownPropsTransformer",["module","exports","require","frontend-js-web","./utils/showSuccessMessage"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function propsTransformer(e){let{items:t,portletNamespace:r}=e;return _objectSpread(_objectSpread({},function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(e,["items","portletNamespace"])),{},{items:t.map((e=>{var t;return _objectSpread(_objectSpread({},e),{},{items:null===(t=e.items)||void 0===t?void 0:t.map((e=>_objectSpread(_objectSpread({},e),{},{onClick(t){var o;const n=null===(o=e.data)||void 0===o?void 0:o.action;n&&(t.preventDefault(),a[n](e.data,r))}})))})}))})};var o=r("frontend-js-web"),n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(r("./utils/showSuccessMessage"));function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e={article:"article",folder:"folder"},a={delete({deleteURL:e}){(0,o.openConfirmModal)({message:Liferay.Language.get("are-you-sure-you-want-to-delete-this"),onConfirm:t=>{t&&submitForm(document.hrefFm,e)}})},move({itemClassNameId:t,itemId:r,itemType:a,moveKBItemActionURL:i,moveKBItemModalURL:s},c){(0,o.openSelectionModal)({buttonAddLabel:Liferay.Language.get("move"),height:"50vh",multiple:!0,onSelect:({destinationItem:s,index:l})=>{var u;return a===e.folder&&s.type===e.article?((0,o.openToast)({message:Liferay.Language.get("folders-cannot-be-moved-into-articles"),type:"danger"}),!1):((0,o.fetch)(i,{body:(0,o.objectToFormData)({["".concat(c,"dragAndDrop")]:!0,["".concat(c,"position")]:null!==(u=null==l?void 0:l.next)&&void 0!==u?u:-1,["".concat(c,"resourceClassNameId")]:t,["".concat(c,"resourcePrimKey")]:r,["".concat(c,"parentResourceClassNameId")]:s.classNameId,["".concat(c,"parentResourcePrimKey")]:s.id}),method:"POST"}).then((e=>{if(!e.ok)throw new Error;return e.json()})).then((e=>{if(!e.success)throw new Error(e.errorMessage);(0,n.default)(c)})).catch((({message:e=Liferay.Language.get("an-unexpected-error-occurred")})=>{(0,o.openToast)({message:e,type:"danger"})})),!0)},selectEventName:"selectKBMoveFolder",size:"md",title:Liferay.Language.get("move"),url:s})},permissions({permissionsURL:e}){(0,o.openModal)({title:Liferay.Language.get("permissions"),url:e})},print({printURL:e}){(0,o.openModal)({title:Liferay.Language.get("print"),url:e})}}}}));
//# sourceMappingURL=KBDropdownPropsTransformer.js.map