const b={"analyze.apply":"Apply changes","apply.run":"Apply changes","search.ask":"Ask query","ask.run":"Ask query","search.sync":"Catalog sync","sync.run":"Catalog sync","code.scan":"Code scan","doc.scan":"Doc scan","docs.scan":"Doc scan","doc.ingest":"Doc ingest","docs.ingest":"Doc ingest","generate.database":"Database description","generate.schema":"Schema description","generate.table":"Table description","generate.column":"Column description"};function d(e){if(!e||typeof e!="object")return"Database description";const n=Object.entries(e);if(n.length===0)return"Database description";let t=0,r=!0;for(const[,a]of n)Array.isArray(a)&&a.length>0&&(t+=a.length,r=!1);return r?"Schema description":t===1?"Table description":"Tables description"}function p(e,n){if(!e)return"Run";if(e==="analyze.run")return n===void 0?"Analyze run":d(n);if(b[e])return b[e];const t=e.split(".")[0]??e;return t.charAt(0).toUpperCase()+t.slice(1)}function g(e){if(!e)return null;const{schemas:n,tables:t,columns:r,sample:a}=e;if(t===0&&r===0)return null;if(t===1&&r===1){const s=a[0];if(s)return s.column?`${s.schema}.${s.table}.${s.column}`:`${s.schema}.${s.table}`}if(t===1){const s=a[0];if(s)return r>0?`${s.schema}.${s.table} (${r} column${r===1?"":"s"})`:`${s.schema}.${s.table}`}if(n===1){const s=a[0],f=s?s.schema:"",l=[];for(const o of a)if(l.includes(o.table)||l.push(o.table),l.length>=2)break;const h=l.map(o=>`${f}.${o}`).join(", "),m=t-l.length;return m>0?`${h}, +${m} more (${t} tables in ${f})`:`${h} (${t} tables)`}const i=[];for(const s of a)if(i.includes(s.schema)||i.push(s.schema),i.length>=2)break;const c=n-i.length,u=i.join(", ");return c>0?`${u}, +${c} more (${n} schemas · ${t} tables)`:`${u} · ${t} tables`}function y(e){if(!e||e.sample.length===0)return;const n=e.sample.map(r=>r.column?`${r.schema}.${r.table}.${r.column}`:`${r.schema}.${r.table}`),t=Math.max(0,e.tables+e.columns-n.length);return t>0&&n.push(`… +${t} more`),n.join(`
`)}function A(e){if(!e||typeof e!="object")return"All schemas";const n=Object.entries(e);if(n.length===0)return"All schemas";let t=0,r=!0;for(const[,a]of n)Array.isArray(a)&&a.length>0&&(t+=a.length,r=!1);if(n.length===1){const[a,i]=n[0];return Array.isArray(i)&&i.length>0?`${a} · ${i.length} ${i.length===1?"table":"tables"}`:`${a} (all tables)`}return r?`${n.length} schemas`:`${n.length} schemas · ${t} ${t===1?"table":"tables"}`}function D(e){return e==="success"?"positive":e==="failed"?"critical":e==="cancelled"?"warning":e==="running"||e==="queued"?"accent":e==="applied_partial"?"warning":"neutral"}function z(e){return e?e==="ready_for_review"?"ready":e==="applied_partial"?"partial":e:"—"}function $(e){if(e==null)return NaN;if(typeof e=="number")return e<1e12?e*1e3:e;const n=Date.parse(e);return Number.isFinite(n)?n:NaN}function j(e){const n=$(e);if(!Number.isFinite(n))return"—";const t=Date.now()-n;if(t<0)return"just now";const r=Math.floor(t/1e3);if(r<45)return"just now";const a=Math.floor(r/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);if(i<24)return`${i}h ago`;const c=Math.floor(i/24);return c<30?`${c}d ago`:new Date(n).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function k(e){if(!e)return"";const n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e}function M(e){const n=(e??"").toLowerCase();return n==="analyze.run"||n==="analyze.apply"?"analyze":n==="rerun"?"rerun":n.startsWith("generate.")?"generate":n==="search.ask"||n==="ask.run"?"ask":n==="schedule"?"schedule":"other"}export{A as a,z as b,D as c,M as d,g as e,p as h,y as p,j as r,k as s};
