import{S as he,i as _e,s as me,e as B,b as R,$ as H,h as P,D as Y,E as N,F as pe,Q as y,k as V,l as x,m as G,I as F,H as v,K as S,O as te,P as ae,a0 as ge,p as J}from"./index.224851d7.js";import{r as h,O as _,h as ye,i as W,j as Se,k as be,p as ve,l as Ee,e as g,f as j,a as b,m as Pe,T as we,w as Te}from"./taskMonitoringStore.8317b9f1.js";function X(t,e,a){const s=t.slice();return s[2]=e[a].width,s}function Ae(t){let e,a,s,n,r=[t[4],{style:a="width: "+t[2]+";"+t[4].style}],o={};for(let l=0;l{e=N(N({},e),pe(c)),a(4,l=Y(e,o)),"lines"in c&&a(5,i=c.lines),"heading"in c&&a(0,d=c.heading),"paragraph"in c&&a(1,u=c.paragraph),"width"in c&&a(2,p=c.width)},t.$$.update=()=>{if(t.$$.dirty&4&&a(7,n=parseInt(p,10)),t.$$.dirty&4&&a(6,r=p.includes("px")),t.$$.dirty&238&&u)for(let c=0;ce.includes(".")?`"${e}"`:e).join(".")}function Ce(t){return t.dtype&&!["embedding","binary","string_span"].includes(t.dtype)}function Ke(t){return t.dtype&&!["embedding","binary"].includes(t.dtype)}function w(t){var a;return Array.isArray(t)?t:((a=t.match(/(?:"[^"]*"|[^.])+(?:\.+$)?/g))==null?void 0:a.map(s=>s.replace(/"/g,"")))||[]}function Ne(t,e){if(!t||!e||(t=w(t),e=w(e),t.length!==e.length))return!1;for(let a=0;aa.path.length>0)}function Ye(t){return t==null?[]:T(t).filter(e=>e.dtype!=null)}function Je(t,e){return e==null?[]:(e?T(e):[]).filter(s=>s.dtype==t)}function O(t){let e;if(Array.isArray(t))e=[...t,...t.flatMap(O)];else{const{[E]:a,[A]:s,[M]:n,...r}=t,o=Object.values(r||{});e=[];for(const l of o)if(Array.isArray(l)){e=[...e,l];for(const i of l)e=[...e,i,...O(i)]}else e=[...e,l,...O(l)]}return e}function We(t,e){return T(t).find(s=>K(s.path,e))}function Xe(t,e){return O(t).filter(s=>K(e,ne.path(s)))}function $(t,e,a=!1){return Ie(e)&&(a=!0),e===t?a:e.fields!=null?Object.values(e.fields).some(s=>$(t,s,a)):e.repeated_field!=null?$(t,e.repeated_field,a):!1}function Ie(t){return t.signal!=null}const ne={path:t=>{if(!t)return;const e=t[A];if(e==null)throw Error(`Item does not have a path defined: ${JSON.stringify(t)}`);return e},value:(t,e)=>{if(t)return t[E]},field:t=>{if(t)return t[M]},dtype:t=>{const e=ne.field(t);return e==null?void 0:e.dtype}};function q(t,e){const{fields:a,repeated_field:s,...n}=t,r={...n,path:[]};if(a!=null){r.fields={};for(const[o,l]of Object.entries(a)){const i=q(l,[...e,o]);i.path=[...e,o],r.fields[o]=i}}if(s!=null){const o=q(s,[...e,I]);o.path=[...e,I],r.repeated_field=o}return r}function L(t,e,a){const s=e.find(r=>K(r.path,a));let n={};if(Array.isArray(t))return n=t.map((r,o)=>L(r,e,[...a,o.toString()])),n[E]=null,n[A]=a,n[M]=s,n;if(t!=null&&typeof t=="object"){const{[E]:r,...o}=t;n=Object.entries(o).reduce((l,[i,d])=>(l[i]=L(d,e,[...a,i]),l),{}),n[E]=r}else n[E]=t;return n[A]=a,n[M]=s,n}class Re extends ye{constructor(e,a){super(e,a)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e,a){super.setOptions({...e,behavior:W()},a)}getOptimisticResult(e){return e.behavior=W(),super.getOptimisticResult(e)}fetchNextPage({pageParam:e,...a}={}){return this.fetch({...a,meta:{fetchMore:{direction:"forward",pageParam:e}}})}fetchPreviousPage({pageParam:e,...a}={}){return this.fetch({...a,meta:{fetchMore:{direction:"backward",pageParam:e}}})}createResult(e,a){var s,n,r,o,l,i;const{state:d}=e,u=super.createResult(e,a),{isFetching:p,isRefetching:Q}=u,k=p&&((s=d.fetchMeta)==null||(n=s.fetchMore)==null?void 0:n.direction)==="forward",D=p&&((r=d.fetchMeta)==null||(o=r.fetchMore)==null?void 0:o.direction)==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Se(a,(l=d.data)==null?void 0:l.pages),hasPreviousPage:be(a,(i=d.data)==null?void 0:i.pages),isFetchingNextPage:k,isFetchingPreviousPage:D,isRefetching:Q&&!k&&!D}}}function je(t,e,a){const s=ve(t,e,a);return Ee(s,Re)}const f="datasets",ee=20,Ze=g(m.getDatasets,f),$e=g(m.getManifest,f,{}),et=g(m.getManifest,f,{select:t=>se(t.dataset_manifest.data_schema)}),tt=g(C.getSources,f),at=g(C.getSourceSchema,f,{select:t=>t}),st=j(C.load),rt=j(m.computeSignal,{onSuccess:t=>{b.invalidateQueries([we]),Te(t.task_id,()=>{b.invalidateQueries([f,"getManifest"]),b.invalidateQueries([f,"selectRowsSchema"]),b.invalidateQueries([f,"selectRows"])})}}),nt=j(m.deleteDataset,{onSuccess:()=>{b.invalidateQueries([f])}}),it=j(m.deleteSignal,{onSuccess:()=>{b.invalidateQueries([f,"getManifest"]),b.invalidateQueries([f,"selectRowsSchema"]),b.invalidateQueries([f,"selectRows"])}}),ot=g(m.getStats,f),lt=Pe(m.getStats,f);g(function(e,a,s,n){return m.selectRows(e,a,s).then(r=>({rows:r.rows.map(o=>re(o,n)),total_num_rows:r.total_num_rows}))},f);const ct=g(m.selectRowsSchema,f,{select:t=>({schema:se(t.data_schema),...t})}),ut=g(m.selectGroups,f),dt=(t,e,a,s)=>je({queryKey:[f,"selectRows",t,e,a],queryFn:({pageParam:n=0})=>m.selectRows(t,e,{...a,limit:a.limit||ee,offset:n*(a.limit||ee)}),select:n=>({...n,pages:n.pages.map(r=>({rows:r.rows.map(o=>re(o,s)),total_num_rows:r.total_num_rows}))}),getNextPageParam:(n,r)=>r.length,enabled:!!s});function ft(t){return t!=null}function ht(t,e){return`/concepts#!/${t}/${e}`}function _t(t,e){return`/datasets#!/${t}/${e}`}export{Ke as A,ot as B,ut as C,lt as D,ct as E,f as F,Ue as G,He as H,xe as I,tt as J,st as K,ne as L,at as M,I as P,Le as S,Ve as U,E as V,_t as a,T as b,ht as c,nt as d,w as e,Ye as f,Je as g,We as h,K as i,Be as j,ze as k,Xe as l,O as m,ft as n,Ie as o,Ne as p,Ze as q,rt as r,Ge as s,$e as t,et as u,Fe as v,dt as w,it as x,$ as y,Ce as z};