import{d as ue,h as me,N as _e,a4 as pe,R as he,J as fe,a5 as xe,ae as Ce,v as ge,au as we,o as i,e as _,a as l,k as a,c as f,p as k,w as o,b as r,F as K,z as P,q as ve,n as y,t as c,l as ke,B as ye,D as j,r as be,_ as Se,A as x,s as $e,S as H}from"./EJiqiqZX.js";import{_ as De}from"./CMk4p11g.js";import{_ as Te}from"./COaTHx-9.js";import{u as Ne,b as Ue,_ as ze}from"./DjV0gvgT.js";import{_ as Ae}from"./BfhOLfqp.js";import{_ as Re}from"./b6minSIt.js";import{_ as Be}from"./D7qtAg9b.js";import{_ as Ee}from"./BiEw5mdv.js";import{_ as Fe}from"./Bd9WPADb.js";import{_ as Ke}from"./gjzm6RoO.js";import{_ as Pe}from"./EjhM9UWu.js";import{l as je}from"./BonserMD.js";import{u as He}from"./558z3Na8.js";import"./nktVwxwq.js";import"./DPX3lXZf.js";import"./BdHYZYxo.js";import"./CC92fphK.js";import"./Cqd5VgjX.js";import"./NwK2Pm4d.js";import"./8R23gm1P.js";import"./CSwwpV8A.js";import"./B3XbUJXz.js";import"./BBOQFEVZ.js";import"./lBS7YjNH.js";import"./ByTKohwH.js";import"./C4BmrwDT.js";import"./DbaqFYix.js";import"./CB5_IlOE.js";import"./DTYT2AtJ.js";import"./qv9l9arW.js";import"./CASzI7RK.js";import"./88opOQSr.js";import"./iik6CYzq.js";import"./iLxCpTU2.js";const Ie={class:"flex items-center justify-between o_gap-3 o_px-4 o_py-3 flex-wrap border-b border-gray-100 min-h-4"},Le={class:"text-xl text-uiText-toned"},Oe={class:"o_w-12 text-center"},qe={class:"o_w-30"},Ve={class:"text-sm font-medium"},We={class:"text-sm text-uiText-dimmed"},Ge={class:"text-sm text-uiText-dimmed"},Qe={class:"o_w-56 flex items-center gap-1"},Ze={class:"o_w-44"},Je={key:0,class:"text-sm text-uiText-dimmed"},Me={key:1},Xe={class:"text-sm text-uiText-dimmed"},Ye={class:"flex gap-2"},et={class:"p-3 text-sm max-w-[40ch]"},tt={class:"text-uiText-toned font-medium mb-2"},at={class:"text-uiText-toned o_mb-2"},st={class:"text-xl text-uiText-toned"},Ht=ue({__name:"scheduled-[pid]-[sid]",async setup(ot){let C,$;const I=me(),{pid:d,sid:D}=I.params;if(!d)throw new Error("Project ID not found");const{kapi:L}=_e(),{addTimeToProcessedData:O,setCachedData:q}=pe(),V=he(),{t:m,locale:W}=fe(),{formatLocaleTimeAgo:T}=He(),{timeSlotStringGenerator:G,deleteScheduledCrawl:Q,triggerScheduledCrawl:Z,getFSCQuota:J}=Ne(),{data:b,status:M,error:N,refresh:U}=xe(`fsc-scheduledCrawls-${d}`,async()=>{const{crawl_schedules:e}=await L("Crawler").then(n=>n.listCrawlSchedulesByProject(Number(d)));return{scheduledCrawls:e}},{transform:e=>{const n={scheduled:e.scheduledCrawls.map(s=>({enabled:s.enabled,nextcheck:s.next_crawl_at,interval:s.interval,timeslot:s.timeslot,checks:s.integration_collections.length,extras:{id:s.id,dayOrWeek:s.day_of_month_or_week,timeSlotString:G(s),formatedNextCheckDate:je(new Date(s.next_crawl_at),W.value,V.timeZone),nextCheckDuration:T(new Date(s.next_crawl_at)),collections:s.integration_collections,timezone:s.timezone,crawlDepth:s.crawl_depth,recentCrawl:s.recent_crawl}}))};return O(n)},getCachedData:(e,n,s)=>{if(!(s.cause==="refresh:manual"||s.cause==="refresh:hook"))return q(e)}}),{data:g,error:z}=([C,$]=Ce(()=>J()),C=await C,$(),C);if(z.value)throw z.value;const w=x(!1),p=x(!1),h=ve,X=$e(()=>[{id:"enabled",accessorKey:"enabled",header:m("fsCrawler.Enabled"),meta:{class:{th:"o_w-16"}}},{id:"nextcheck",accessorKey:"nextcheck",header:m("fsCrawler.Nextcheck"),meta:{class:{th:"o_w-40"}}},{id:"timeslot",accessorKey:"timeslot",header:m("fsCrawler.Timeslot"),meta:{class:{th:"o_w-44"}}},{id:"checks",accessorKey:"checks",header:m("fsCrawler.Checks"),meta:{class:{th:"o_w-28"}}},{id:"lastRun",accessorKey:"lastRun",header:m("fsCrawler.LastRun"),meta:{class:{th:"o_w-44"}}},{id:"actions",header:m("Actions"),accessorKey:"actions"}]),A=x(0),R=x(null),Y=e=>{p.value=!0,A.value=e.original.extras.id,R.value={enabled:e.original.enabled,depth:e.original.extras.crawlDepth,options:e.original.extras.collections.map(n=>n.id.split("-")[1]),frequency:e.original.interval,dayOfMonth:e.original.extras.dayOrWeek,dayOfWeek:e.original.extras.dayOrWeek,timeSlot:e.original.timeslot,timeZone:e.original.extras.timezone}},S=x({}),v=()=>{U(),H(`fsc-quota-${d}`)},ee=async e=>{await Q(e),S.value[e]=!1,v()},te=async e=>{const{error:n}=await Z(e);n||(v(),H(`fsc-recentCrawls-${d}-0`))};return ge().projectAccess.skuLevel<300&&we(`/p/crawler/deadlinks-${d}-${D}`),(e,n)=>{const s=De,ae=Te,B=Ue,E=Ae,se=Re,oe=Se,ne=Be,re=ze,le=ye,F=Ee,ie=Fe,ce=Ke,de=Pe;return i(),_("div",null,[l(s,{"page-key":"pFSCScheduled"}),a(N)?(i(),f(ae,{key:0,error:a(N),refresh:a(U)},null,8,["error","refresh"])):k("",!0),l(de,{class:"o_overflow-hidden",variant:"subtle"},{default:o(()=>[r("div",Ie,[a(b)&&a(g)?(i(),_(K,{key:0},[a(g).hasScheduledCrawls?(i(),f(E,{key:0,open:a(w),"onUpdate:open":n[1]||(n[1]=t=>P(w)?w.value=t:null),ui:{content:"max-w-[500px]"}},{title:o(()=>[r("span",Le,c(e.$t("fsCrawler.scheduledCrawlSetup")),1)]),body:o(()=>[l(B,{"is-scheduled":!0,onClose:n[0]||(n[0]=t=>w.value=!1),onCrawlScheduled:v})]),default:o(()=>[l(a(h),{label:e.$t("fsCrawler.setupNewScheduledCrawl",{count:a(g).leftScheduledCrawls}),icon:a(y).icoSearching},null,8,["label","icon"])]),_:1},8,["open"])):(i(),f(se,{key:1,class:"w-full",color:"warning",variant:"subtle",title:e.$t("fsCrawler.currentlyNoScheduledCrawls"),ui:{root:"p-00 o_px-3 o_py-2"}},null,8,["title"]))],64)):k("",!0)]),a(b)?(i(),f(ce,{key:0,ref:"table",data:a(b).scheduled,columns:a(X),sticky:"",loading:a(M)==="pending","loading-color":"success","loading-animation":"carousel","loading-text":e.$t("loadingCrawls"),empty:e.$t("noCrawlsFound"),ui:{th:"border-t border-uiBorder-subtle"}},{"enabled-cell":o(({row:t})=>[r("div",Oe,[l(oe,{name:t.original.enabled?"i-lucide-check":"i-lucide-x",class:j([t.original.enabled?"text-green-500":"text-uiText-dimmed"])},null,8,["name","class"])])]),"nextcheck-cell":o(({row:t})=>[r("div",qe,[r("div",Ve,c(t.original.extras.nextCheckDuration),1),r("div",We,c(t.original.extras.formatedNextCheckDate),1)])]),"timeslot-cell":o(({row:t})=>[r("div",null,[l(ne,{text:t.original.extras.timeSlotString,class:"text-sm",markdown:""},null,8,["text"]),r("div",Ge,c(e.$t(`fsCrawler.${t.original.interval}Interval`)),1)])]),"checks-cell":o(({row:t})=>[r("div",Qe,[r("ul",{class:j(["list-disc list-inside",[t.original.extras.collections.length>2?"text-xs":"text-sm"]])},[(i(!0),_(K,null,be(t.original.extras.collections,u=>(i(),_("li",{key:u.id},c(u.name),1))),128))],2)])]),"lastRun-cell":o(({row:t})=>[r("div",Ze,[t.original.extras.recentCrawl?(i(),_("div",Me,[l(le,{to:`/p/crawler/d/${t.original.extras.recentCrawl.id}-${a(d)}-${a(D)}`},{default:o(()=>[l(re,{result:t.original.extras.recentCrawl.progress,"meta-status":{success:t.original.extras.recentCrawl.success,failure:t.original.extras.recentCrawl.failure,uncertain:t.original.extras.recentCrawl.uncertain,resultCount:t.original.extras.recentCrawl.result_count},status:t.original.extras.recentCrawl.status,"show-tooltip":!0},null,8,["result","meta-status","status"]),r("div",Xe,c(a(T)(new Date(t.original.extras.recentCrawl.start_date))),1)]),_:2},1032,["to"])])):(i(),_("div",Je,c(e.$t("fsCrawler.NotStarted")),1))])]),"actions-cell":o(({row:t})=>[r("div",Ye,[l(F,null,{default:o(()=>[a(g)?.hasConcurrentCrawls?(i(),f(a(h),{key:0,label:e.$t("fsCrawler.RunNow"),variant:"subtle",color:"neutral",icon:"i-lucide:play",size:"sm",onClick:u=>te(t.original.extras.id)},null,8,["label","onClick"])):k("",!0),l(a(h),{label:e.$t("fsCrawler.Edit"),variant:"subtle",color:"neutral",icon:a(y).icoEdit,size:"sm",onClick:u=>Y(t)},null,8,["label","icon","onClick"]),l(ie,{open:a(S)[t.original.extras.id],"onUpdate:open":u=>a(S)[t.original.extras.id]=u,arrow:"",content:{align:"end",side:"bottom"}},{content:o(()=>[r("div",et,[r("h3",tt,c(e.$t("fsCrawler.deleteScheduledCrawl")),1),r("p",at,c(e.$t("fsCrawler.deleteDescription")),1),l(F,null,{default:o(()=>[l(a(h),{variant:"solid",color:"error",icon:a(y).icoTrash,size:"sm",onClick:u=>ee(t.original.extras.id)},{default:o(()=>[ke(c(e.$t("fsCrawler.DeleteScheduledCrawl")),1)]),_:1},8,["icon","onClick"])]),_:2},1024)])]),default:o(()=>[l(a(h),{label:e.$t("fsCrawler.delete"),variant:"subtle",color:"neutral",icon:a(y).icoTrash,size:"sm"},null,8,["label","icon"])]),_:2},1032,["open","onUpdate:open"])]),_:2},1024)])]),_:1},8,["data","columns","loading","loading-text","empty"])):k("",!0)]),_:1}),l(E,{open:a(p),"onUpdate:open":n[3]||(n[3]=t=>P(p)?p.value=t:null),ui:{content:"max-w-[500px]"}},{title:o(()=>[r("span",st,c(e.$t("fsCrawler.EditScheduledCrawlSettings")),1)]),body:o(()=>[l(B,{"is-scheduled":!0,"edit-id":a(A),"edit-data":a(R),onClose:n[2]||(n[2]=t=>p.value=!1),onCrawlScheduledUpdated:v},null,8,["edit-id","edit-data"])]),_:1},8,["open"])])}}});export{Ht as default};