"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/defineProperty"),t=require("react/jsx-runtime"),n=require("react"),s=require("@material-ui/core"),o=require("../utils.js"),i=require("../TemplatesTreeTemplate/TemplatesTreeTemplate.js"),a=require("../TemplatesTreeNodeItem/TemplatesTreeNodeItem.js"),l=require("../icons/folder/index.js");require("uuid"),require("../../AppCommonsProvider/AppCommonsProvider.js");var u=require("../../AppCommonsProvider/AppCommonsContext.js");require("../../../constants/goals.js"),require("../../../constants/segment.js"),require("../../../constants/alerts.js"),require("../../../constants/apps.js"),require("../../../constants/drillstring.js"),require("../../../constants/completion.js"),require("../../../constants/appPackages.js"),require("../../../constants/notifications.js"),require("../../../constants/feed.js"),require("../../../constants/bha.js");var p=require("../../../constants/corvaCompanyId.js");require("lodash"),require("../../../components/GradientManager/configuration/constants.js");var c=require("../Store/Store.js");require("../Store/utils.js");var d=require("../types.js"),m=require("./TemplatesTreeFolder.scss.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q,T=j(e),f=j(r),v=(q={},f.default(q,d.FolderType.Company,"Company Templates"),f.default(q,d.FolderType.Preset,"Corva Templates"),f.default(q,d.FolderType.Shared,"Shared with me"),q);exports.TemplatesTreeFolder=function e(r){var j=r.folder,q=r.level,f=r.pathMap,C=c.storeApi.useOpenFolderMenu,y=c.storeApi.useFolderMenuData,h=c.storeApi.useSelectedTemplateId,A=C(),g=y(),x=h(),F=n.useRef(null),M=function(e){var r=e.type,t=e.name,n=e.entityId,s=u.useAppCommons().currentUser;return r===d.FolderType.Company&&null!=s&&s.company_name&&(null==s?void 0:s.company_id)!==p.CORVA_COMPANY_ID?"".concat(s.company_name," Templates"):r in v?v[r]:t||"N/A, ".concat(r,": ").concat(n)}(j),b=n.useMemo((function(){var e;return!!x&&(null===(e=f[x])||void 0===e?void 0:e.some((function(e){return e===j.id})))}),[x,j.id,f]),P=n.useState(!1),I=T.default(P,2),S=I[0],_=I[1],N=n.useCallback((function(){return _((function(e){return!e}))}),[]),k=n.useCallback((function(e){e.stopPropagation(),A({anchorEl:F.current,folder:j})}),[A,j]);return j.items.length?t.jsxs("div",{children:[t.jsx(a.TemplatesTreeNodeItem,{content:M,additionalContent:1===j.items.length?"1 item":"".concat(j.items.length," items"),iconComponent:l.getFolderIconComponent(j,S),onClick:N,level:q,isActive:b,onMenuClick:j.type===d.FolderType.Regular?k:void 0,ref:F,isMenuOpen:(null==g?void 0:g.folder.id)===j.id}),t.jsx(s.Collapse,{in:S,children:t.jsx("div",{className:m.items,children:j.items.map((function(r){return o.isFolder(r)?t.jsx(e,{folder:r,level:q+1,pathMap:f},r.id):t.jsx(i.TemplatesTreeTemplate,{template:r,level:q+1},r.id)}))})})]}):null};
//# sourceMappingURL=TemplatesTreeFolder.js.map
