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