import{u as b,b9 as L,ed as R,g4 as q,c9 as B,ek as M,jn as $,ax as A,r as V,q as d,j as e,bS as H,cp as T,jo as z,fB as J,aV as K,$ as j,c as U,b1 as I,o as W}from"./index-46ma1THH.js";import{P as X}from"./Panel-CnxQ3Lqy.js";import{u as Y}from"./useUserPermissions-DiAMkzC6.js";import{L as P}from"./LabelValue-BwjawF6m.js";const ae=({path:a=d.project.featureView.overview,showDelete:f=!1,header:h,children:p})=>{const{id:o,fsId:s,fvName:t,fvVersion:n}=b(),i=L(),{data:m}=R(),{currentData:c}=q(),w=(c==null?void 0:c.featurestoreId)===+s,{isObserver:y}=B(),{data:r,isError:D,isFetching:C,refetch:k,error:x}=M({pId:+o,fsId:+s,id:t,version:+n,params:{expand:["keywords","tags","features","query_string","tag_schemas"].filter(u=>m?!0:!["keywords","tags","tag_schemas"].includes(u))}}),{currentData:l={items:[]},refetch:S}=$({pId:+o,fsId:+s,id:t},{refetchOnFocus:!0}),E=()=>{k(),S()},{isDataScientist:N}=Y(),{data:v}=A(),F=N&&(v==null?void 0:v.username)!==(r==null?void 0:r.creator.username),[O,g]=V.useState(!1),G=V.useCallback(u=>{i(a,{fsId:s,fvName:t,fvVersion:u})},[s,t,i,a]),Q=()=>{if(g(!1),l.items.length>1){const u=l.items.find(_=>_.version!==+n);i(a,{fsId:s,fvName:t,fvVersion:u.version})}else i(d.project.featureView.list,{fsId:s})};return D&&(x==null?void 0:x.response.status)===400?e.jsx(H,{mainText:x.response.data.errorMsg}):D||!C&&!r?e.jsx(T,{}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{isOpen:O,onClose:()=>g(!1),onDeleteSuccess:Q}),e.jsx(X,{title:String((r==null?void 0:r.name)??t),versions:(l==null?void 0:l.items)??[{version:+n}],version:+n,onVersionChange:G,idColor:"labels.purple",onClickRefresh:E,onClickDelete:w&&!F?()=>g(!0):void 0,showDelete:f&&!y,data:r,pathnamePostFix:a.replace(d.project.featureView.overview,""),children:h}),p({fv:r,isOwnFeatureView:w,isNotOwnedByDataScientist:F})]})},Z=({isOpen:a,onClose:f,onDeleteSuccess:h})=>{const{id:p,fsId:o,fvName:s,fvVersion:t}=b(),[n,{isLoading:i}]=z(),{handleDelete:m}=V.useContext(J),c=()=>{n({pId:+p,fsId:+o,id:s,version:+t}).unwrap().then(()=>{m(W(d.project.featureView.overview,d.project.value,{id:p,fsId:o,fvName:s,fvVersion:t}))}).then(h)};return e.jsx(K,{isOpen:a,onClose:f,title:"Delete feature view",footer:e.jsxs(j,{sx:{gap:"12px"},children:[e.jsx(I,{intent:"secondary",onClick:f,children:"Cancel"}),e.jsx(I,{intent:"alert",isLoading:i,onClick:c,children:"Delete feature view"})]}),children:e.jsxs(j,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsxs(j,{sx:{gap:"20px"},children:[e.jsx(P,{label:"Feature View",value:s}),e.jsx(P,{label:"Feature View Version",value:t})]}),e.jsx(U,{width:"350px",children:"Once you delete a file or a folder, there is no going back. Please be certain."})]})})};export{ae as F};
