import{u as C,bL as B,d$ as R,fb as _,e4 as q,hF as M,av as A,r as w,j as e,ck as H,s as d,hG as T,fC as Z,b2 as $,B as V,aG as I,b as z,q as J}from"./index-dP1W1_bd.js";import{N as K}from"./NoData-DLZ_8GEo.js";import{P as U}from"./Panel-M9AVvYdm.js";import{u as W}from"./useUserPermissions-Olw8jjZn.js";import{L as b}from"./LabelValue-Dfx1zREE.js";import{u as X}from"./ButtonWithRole-CF64B_Or.js";const ie=({path:a=d.featureView.overview,showDelete:f=!1,header:p,children:h})=>{const{id:o,fsId:s,fvName:t,fvVersion:n}=C(),i=B(),{data:x}=R(),{currentData:l}=_(),j=(l==null?void 0:l.featurestoreId)===+s,{isObserver:P}=X(),{data:r,isError:D,isFetching:y,refetch:k,error:m}=q({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}=W(),{data:v}=A(),F=E&&(v==null?void 0:v.username)!==(r==null?void 0:r.creator.username),[G,g]=w.useState(!1),O=w.useCallback(u=>{i(a,{fsId:s,fvName:t,fvVersion:u})},[s,t,i,a]),L=()=>{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(K,{mainText:m.response.data.errorMsg}):D||!y&&!r?e.jsx(H,{}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{isOpen:G,onClose:()=>g(!1),onDeleteSuccess:L}),e.jsx(U,{title:String((r==null?void 0:r.name)??t),versions:(c==null?void 0:c.items)??[{version:+n}],version:+n,onVersionChange:O,idColor:"labels.purple",onClickRefresh:S,onClickDelete:j&&!F?()=>g(!0):void 0,showDelete:f&&!P,data:r,pathnamePostFix:a.replace(d.featureView.overview,""),children:p}),h({fv:r,isOwnFeatureView:j,isNotOwnedByDataScientist:F})]})},Y=({isOpen:a,onClose:f,onDeleteSuccess:p})=>{const{id:h,fsId:o,fvName:s,fvVersion:t}=C(),[n,{isLoading:i}]=T(),{handleDelete:x}=w.useContext(Z),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($,{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(b,{label:"Feature View",value:s}),e.jsx(b,{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};
