import{r as c,j as e,aU as i,t as o,i as x,S as m}from"../index.js";import{s as p,a as h}from"./index-6cdecde9.js";import{h as r}from"./moment-8a59df1b.js";import"./truncate-352eb33b.js";import"./XCircle-edfe554c.js";import"./File-b92df2f3.js";import"./Eye-9f033dc0.js";import"./index-4fb4d421.js";import"./react-beautiful-dnd.esm-45ea8487.js";function u({queue:t}){const s=c.useRef(null),n=async()=>{var a;(a=s==null?void 0:s.current)==null||a.remove(),await o.experimentalFeatures.liveSync.setWatchStatusForDocument(t.workspaceDoc.workspace.slug,t.workspaceDoc.docpath,!1)};return e.jsx(e.Fragment,{children:e.jsxs("tr",{ref:s,className:"bg-transparent text-white text-opacity-80 text-sm font-medium",children:[e.jsx("td",{scope:"row",className:"px-6 py-4 whitespace-nowrap",children:p(t.workspaceDoc.filename)}),e.jsx("td",{className:"px-6 py-4",children:r(t.lastSyncedAt).fromNow()}),e.jsxs("td",{className:"px-6 py-4",children:[r(t.nextSyncAt).format("lll"),e.jsxs("i",{className:"text-xs px-2",children:["(",r(t.nextSyncAt).fromNow(),")"]})]}),e.jsx("td",{className:"px-6 py-4",children:r(t.createdAt).format("lll")}),e.jsx("td",{className:"px-6 py-4 flex items-center gap-x-6",children:e.jsx("button",{onClick:n,className:"border-none font-medium px-2 py-1 rounded-lg text-theme-text-primary hover:text-red-500",children:e.jsx(i,{className:"h-5 w-5"})})})]})})}function k(){return e.jsxs("div",{className:"w-screen h-screen overflow-hidden bg-theme-bg-container flex",children:[e.jsx(h,{}),e.jsx("div",{style:{height:x?"100%":"calc(100% - 32px)"},className:"relative md:ml-[2px] md:mr-[16px] md:my-[16px] md:rounded-[16px] bg-theme-bg-secondary w-full h-full overflow-y-scroll p-4 md:p-0",children:e.jsxs("div",{className:"flex flex-col w-full px-1 md:pl-6 md:pr-[50px] md:py-6 py-16",children:[e.jsxs("div",{className:"w-full flex flex-col gap-y-1 pb-6 border-white/10 border-b-2",children:[e.jsx("div",{className:"items-center flex gap-x-4",children:e.jsx("p",{className:"text-lg leading-6 font-bold text-theme-text-primary",children:"Watched documents"})}),e.jsx("p",{className:"text-xs leading-[18px] font-base text-theme-text-secondary",children:"These are all the documents that are currently being watched in your instance. The content of these documents will be periodically synced."})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(f,{})})]})})]})}function f(){const[t,s]=c.useState(!0),[n,a]=c.useState([]);return c.useEffect(()=>{async function l(){const d=await o.experimentalFeatures.liveSync.queues();a(d),s(!1)}l()},[]),t?e.jsx(m,{height:"80vh",width:"100%",highlightColor:"var(--theme-bg-primary)",baseColor:"var(--theme-bg-secondary)",count:1,className:"w-full p-4 rounded-b-2xl rounded-tr-2xl rounded-tl-sm mt-6",containerClassName:"flex w-full"}):e.jsxs("table",{className:"w-full text-sm text-left rounded-lg mt-6 min-w-[640px]",children:[e.jsx("thead",{className:"text-theme-text-secondary text-xs leading-[18px] font-bold uppercase border-white/10 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tl-lg",children:"Document Name"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Last Synced"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Time until next refresh"}),e.jsx("th",{scope:"col",className:"px-6 py-3",children:"Created On"}),e.jsx("th",{scope:"col",className:"px-6 py-3 rounded-tr-lg",children:" "})]})}),e.jsx("tbody",{children:n.map(l=>e.jsx(u,{queue:l},l.id))})]})}export{k as default};
