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