import{a5 as G,j as e,d as a,e_ as J,c as y,m as K,aY as Z,r as m,f as ee,U as E,as as te,bi as se,ey as ne,ai as oe,f2 as ae,f6 as re,dY as ie,a as le,am as M,bp as xe,p as pe,dq as A,dy as me,dz as ce,aQ as D,aV as c,an as de,T as i}from"./index-CK33qGU_.js";import{u as he,D as ue}from"./Deprecated-D5xZ0QMJ.js";import{C as d}from"./CardActionButton-DcsFpjJz.js";import{a as fe}from"./useDownload-hrjXceJg.js";const je=({children:n})=>{const o=document.getElementById("panel-portal");return o?G.createPortal(e.jsx(a,{sx:{position:"sticky",top:"0px",zIndex:10,width:"100%",flexDirection:"column"},children:n}),o):n},be=J`
  from { -moz-transform: rotate(0deg); }
  to { -moz-transform: rotate(360deg); }
`,ge=({children:n,...o})=>e.jsx(y,{sx:{animation:`${be} 1.5s ease infinite`},...o,children:n}),ye=n=>({bg:"white",boxShadow:"0px 4px 163px -99px rgba(0, 0, 0, 0.25)",borderBottomColor:"grayShade2",borderBottomWidth:"1px",borderBottomStyle:"solid",justifyContent:"center",":after":{content:'""',width:"100%",height:"10px",position:"absolute",top:"-10px"},...n&&{bg:"grayShade2"}}),we=({onClickEdit:n,onClickDelete:o,onClickRefresh:T,isEditDisabled:v,isVersionsLoading:_,title:r,id:I,idColor:h,versions:x=[],version:u,onVersionChange:k,hasCommits:F=!1,commits:f=[],commit:w,handleCommitChange:P,showDelete:H=!1,type:V=A.td,data:t,status:j,withoutPin:W=!1,pathnamePostFix:Y="",editRightText:L,children:U})=>{var S;const b=t==null?void 0:t.deprecated,g=K(Y,Z().pathname),{isActiveFeatures:$,handleBasket:q,isSwitch:N}=he(),B=m.useMemo(()=>Math.max(...x.map(({version:s})=>s)||[]),[x]),C=m.useMemo(()=>ee(se(ne(E("version"))),te(({version:s,deployments:z=0})=>({value:`${s}`,label:`${s} ${s===B?"(latest)":""}`,deployments:z?`${z} dep.`:""})),fe(E("value")))(x),[x,B]),l=m.useMemo(()=>f.map(s=>({label:`${oe(+s)}${s===f[0]?" (latest)":""}`,value:`${s}`})),[f]),{pinnedIds:O,handlePin:R,handleUnPin:Q}=m.useContext(ae),p=O.includes(g),X=()=>p?Q(g):R({id:g,name:t.name,entityVersion:t.version,entityId:t.id,color:h});return e.jsx(je,{children:e.jsx(a,{alignItems:"center",minHeight:"50px",sx:ye(b),children:e.jsxs(a,{width:"100%",maxWidth:re,alignItems:"flex-end",px:"10px",children:[e.jsxs(a,{alignItems:"center",children:[j&&e.jsx(ie,{mb:"5px",mr:"-5px",mainText:j.text,variant:j.variant}),b&&e.jsx(ue,{}),e.jsxs(le,{display:"inline-flex",m:"auto",ml:"10px",mr:"15px",fontSize:"22px",children:[e.jsx(M,{mainText:r,disabled:!r||(r==null?void 0:r.length)<55,children:e.jsx(y,{sx:{...xe,maxWidth:"650px"},children:r})}),I&&e.jsxs(pe,{mt:"auto",ml:"10px",mb:"1px",mr:"15px",sx:{color:h},as:"span",children:["#",I]})]}),N&&!!t&&V===A.fg&&e.jsx(y,{onClick:s=>s.stopPropagation(),my:"auto",mr:"15px",children:e.jsx(me,{possible:t.features.length>0,handleClick:q(t.features,t),mode:ce.bulk,tooltipMainText:$(t.features,t)?"Remove all features from basket":"Add all features to basket",tooltipSecondaryText:`${t.features.length} features`,inBasket:$(t.features,t)})}),e.jsxs(a,{alignItems:"center",m:"auto 0",children:[(u||t.version)&&(k&&C.length>1?e.jsx(D,{width:"143px",value:`${u}`,options:C,placeholder:"version",onChange:k}):e.jsxs(e.Fragment,{children:[e.jsx(c,{color:"gray",children:"version"}),e.jsx(c,{mx:"5px",color:h,children:u??t.version})]})),_&&e.jsx(ge,{children:e.jsx(de,{icon:i.loading})})]}),F&&P&&(l.length>1?e.jsx(D,{ml:"20px",my:"5px",width:"280px",value:w||l[0].value,options:l,placeholder:"commit time",onChange:P,maxListHeight:"400px"}):e.jsxs(a,{my:"5px",ml:"20px",alignItems:"flex-end",children:[e.jsx(c,{color:"gray",children:"commit"}),e.jsx(c,{mx:"5px",children:((S=l.find(s=>s.value===w))==null?void 0:S.label)||l[0].label})]}))]}),U,e.jsxs(a,{ml:"auto",mr:"8px",alignItems:"center",sx:{gap:"10px"},children:[H&&e.jsx(M,{mainText:"Your role is not allowed to perform this action",disabled:!!o,children:e.jsx(d,{"data-test":"delete-button",icon:i.bin,onClick:o,tooltipText:"Delete",borderless:!0})}),n&&!b&&e.jsx(d,{"data-test":"edit-button",icon:i.edit,onClick:n,tooltipText:v?L??"You have no edit right on the feature store":"",disabled:v,borderless:!0}),T&&e.jsx(d,{icon:i.refresh,onClick:T,tooltipText:"Refresh",borderless:!0}),!W&&e.jsx(d,{"data-test":p?"unpin-item":"pin-item",icon:p?i.pin_filled:i.pin_empty,onClick:X,tooltipText:p?"Unpin from shortcuts":"Pin to shortcuts",borderless:!0})]})]})})})};export{we as P};
