import{u as y,bJ as B,dW as L,eW as R,ca as q,e1 as M,j0 as W,az as z,r as w,j as e,cr as A,s as d,j1 as H,fs as J,aZ as T,B as V,b4 as I,c as Z,q as K}from"./index-C1DmWO_C.js";import{N as U}from"./NoData-Y_e6mfNf.js";import{P as X}from"./Panel-Z-sMb6LN.js";import{u as Y}from"./useUserPermissions-BiARnwL4.js";import{L as P}from"./LabelValue-BcFtbPW0.js";const ne=({path:a=d.featureView.overview,showDelete:f=!1,header:p,children:h})=>{const{id:o,fsId:s,fvName:t,fvVersion:n}=y(),i=B(),{data:x}=L(),{currentData:c}=R(),j=(c==null?void 0:c.featurestoreId)===+s,{isObserver:C}=q(),{data:r,isError:D,isFetching:b,refetch:k,error:m}=M({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:l={items:[]},refetch:N}=W({pId:+o,fsId:+s,id:t},{refetchOnFocus:!0}),S=()=>{k(),N()},{isDataScientist:E}=Y(),{data:v}=z(),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),l.items.length>1){const u=l.items.find(_=>_.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(A,{}):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:(l==null?void 0:l.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}]=H(),{handleDelete:x}=w.useContext(J),c=()=>{n({pId:+h,fsId:+o,id:s,version:+t}).unwrap().then(()=>{x(K(d.featureView.overview,d.project.value,{id:h,fsId:o,fvName:s,fvVersion:t}))}).then(p)};return e.jsx(T,{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:c,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{ne as F};
