import{e_ as d,I as E,e$ as F,v as h,W as T,m as f,dl as j,G as P,w as y,x as p,di as q,dX as _,az as v,at as g,f0 as x,au as I}from"./index-d6499a22.js";import{g as l,a as O}from"./file-utils-b5704e1c.js";const R={[d.READ_ONLY]:"read-only",[d.EDITABLE_BY_OWNERS]:"data owner edit",[d.EDITABLE]:"full edit"},Q={[d.READ_ONLY]:"light",[d.EDITABLE_BY_OWNERS]:"default",[d.EDITABLE]:"label"},L=E(R),k={[F.FEATURESTORE]:"feature store"},D=o=>o.split("::")[0],B=o=>"featurestore",S=h.injectEndpoints({endpoints:o=>({getSharedFrom:o.query({query:e=>({url:`project/${e}/dataset?expand=users`}),transformResponse:T(P([],"items"),j(e=>e.shared&&e.name.includes("_featurestore")),f(e=>({...e,projectName:D(e.name)}))),keepUnusedDataFor:600,providesTags:y.providesList(p.ProjectTags.MultiStore)}),getArtifacts:o.query({query:({id:e,modelName:r,modelVersion:t})=>{const s=encodeURIComponent(`Models/${r}/${t}/Artifacts`);return{url:`project/${e}/dataset/${s}?action=listing&expand=inodes`}},transformResponse:e=>e.items??[],extraOptions:{skipError:!0},providesTags:y.providesList(p.ProjectTags.Artifacts)}),getArtifactVersion:o.query({query:({id:e,modelName:r,modelVersion:t,artifactVersion:s})=>{const a=encodeURIComponent(`Models/${r}/${t}/Artifacts/${s}`);return{url:`project/${e}/dataset/${a}?action=listing&expand=inodes`}},extraOptions:{skipError:!0},transformResponse:e=>{const r=e.items.map(a=>a.attributes),t=r.find(({name:a})=>a.startsWith("transformer-")),s=r.find(({name:a})=>a.startsWith("predictor-"));return{transformer:t==null?void 0:t.path,predictor:s==null?void 0:s.path}},providesTags:y.cacheByIdArgProperty(p.ProjectTags.Artifacts)}),getFileExplorerDataset:o.query({queryFn({id:e,path:r,fileType:t="DATASET",limit:s=1e3,skipError:a=!1},n,i,c){const u=t!==null?`&type=${t}`:"";return new q().rtkQuery({url:`project/${e}/dataset/${encodeURIComponent(r)}?action=listing&expand=inodes&offset=0&sort_by=name:asc&limit=${s}${u}`},n,{skipError:a})},providesTags:(e,r,t)=>[{id:t.path||"root",type:p.ProjectTags.FileExplorer}],keepUnusedDataFor:600}),getFile:o.query({query:({id:e,path:r})=>({url:`/project/${e}/dataset/${encodeURIComponent(r)}?action=blob&expand=inodes&mode=head`}),extraOptions:{skipError:!0}}),getFileStat:o.query({query:({id:e,path:r})=>({url:`/project/${e}/dataset/${encodeURIComponent(r)}`,params:{action:"stat",expand:"inodes"}}),providesTags:(e,r,t)=>[{id:t.path||"root",type:p.ProjectTags.FileStat}]}),PostActionOnFile:o.mutation({query:({id:e,path:r,params:t})=>{const s=_.stringify(t),a=encodeURIComponent(r);return{url:`/project/${e}/dataset/${a}?${s}`,method:"post"}},invalidatesTags:(e,r,{params:t,path:s})=>{const{action:a,destination_path:n}=t;if(v("zip",a))return[];const c=l(n??s),u=a==="create"?O(s):l(s),m=g([c,u]),$=p.ProjectTags.FileExplorer;return m.map(A=>({type:$,id:A}))}}),PostActionOnFiles:o.mutation({async queryFn({id:e,pathes:r,params:t},s,a,n){const i=r.map(({path:c,destination_path:u})=>{const m=_.stringify({...t,destination_path:u});return n({url:`/project/${e}/dataset/${encodeURIComponent(c)}?${m}`,method:"post"})});try{return await Promise.all(i),{data:void 0}}catch(c){return{error:c}}},invalidatesTags:(e,r,{pathes:t})=>{const s=T(x((n,{path:i,destination_path:c})=>I(n,[i,c]),[]),f(l),g)(t),a=p.ProjectTags.FileExplorer;return s.map(n=>({type:a,id:n}))}}),deleteFile:o.mutation({query:({id:e,path:r})=>({url:`/project/${e}/dataset/${encodeURIComponent(r)}`,method:"delete"}),invalidatesTags:(e,r,{path:t})=>{const s=l(t);return[{type:p.ProjectTags.FileExplorer,id:s}]}}),deleteFiles:o.mutation({async queryFn({id:e,pathes:r},t,s,a){const n=r.map(i=>a({url:`/project/${e}/dataset/${encodeURIComponent(i)}`,method:"delete"}));try{return await Promise.all(n),{data:void 0}}catch(i){return{error:i}}},invalidatesTags:(e,r,{pathes:t})=>{const s=g(t.map(l)),a=p.ProjectTags.FileExplorer;return s.map(n=>({type:a,id:n}))}})})}),{useGetSharedFromQuery:C,useGetArtifactsQuery:G,useGetArtifactVersionQuery:b,useGetFileExplorerDatasetQuery:N,useGetFileQuery:w,useGetFileStatQuery:W,usePostActionOnFileMutation:Y,usePostActionOnFilesMutation:V,useDeleteFileMutation:z,useDeleteFilesMutation:X,util:H,endpoints:J}=S;export{G as a,b,Y as c,H as d,V as e,J as f,w as g,Q as h,B as i,D as j,z as k,L as l,X as m,N as n,W as o,R as p,k as s,C as u};
