1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5923],{24050:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/content/queue",function(){return n(94753)}])},94753:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__N_SSP:()=>c,default:()=>u});var l=n(66352),r=n(95132),a=n(13780),i=n.n(a),o=n(58982),s=n(42973);let d={queued:"Queued",running:"Running",done:"Done",failed:"Failed",canceled:"Canceled"};var c=!0;function u(){let[e,t]=(0,r.useState)([]),[n,a]=(0,r.useState)({queued:0,running:0,done:0,failed:0,canceled:0}),[d,c]=(0,r.useState)(!0),[u,x]=(0,r.useState)(!1),[p,y]=(0,r.useState)(null),[j,m]=(0,r.useState)(null),[b,A]=(0,r.useState)("all"),S=(0,r.useRef)(!1),k=(0,r.useRef)(!0);(0,r.useEffect)(()=>{k.current=d},[d]),(0,r.useEffect)(()=>{S.current=u},[u]);let w=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/admin/queue");if(!e.ok)return;let n=await e.json();t(n.jobs||[]),a(n.counts||{queued:0,running:0,done:0,failed:0,canceled:0})}catch(e){}},[]),v=(0,r.useCallback)(async()=>{if(!S.current){S.current=!0,x(!0);try{var e,t,n;let l=await fetch("/api/admin/queue/tick",{method:"POST"}),r=await l.json().catch(()=>({}));(null==r?void 0:r.job)&&(null==r||null==(n=r.job)||null==(t=n.status)||null==(e=t.includes)||e.call(t,"done"))}catch(e){}finally{S.current=!1,x(!1)}}},[]);async function C(e,t,n){if(!j){m(e),y(null);try{let l=await fetch("/api/admin/queue/actions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e,...t})}),r=await l.json();l.ok?y(n?"".concat(n," â done."):"Done."):y("Error: ".concat((null==r?void 0:r.error)||l.statusText)),await w()}catch(e){y("Error: ".concat((null==e?void 0:e.message)||"Network error"))}finally{m(null),setTimeout(()=>y(null),4e3)}}}(0,r.useEffect)(()=>{let e=!1,t=null;async function l(){if(e||(await w(),e))return;let r=n.queued>0||n.running>0;k.current&&r&&!S.current&&v(),t=setTimeout(l,3e3)}return l(),()=>{e=!0,t&&clearTimeout(t)}},[w,v,n.queued,n.running]),(0,r.useEffect)(()=>{w()},[w]);let F="all"===b?e:e.filter(e=>e.status===b);return(0,l.jsxs)(o.Ui,{title:"Content Queue",subtitle:"Background AI generation jobs â live status, controls, and history.",actions:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i(),{href:"/admin/content",style:{fontFamily:s.F.sans,fontSize:"0.82rem",color:s.A.textMuted,textDecoration:"none"},children:"â Content"}),(0,l.jsx)(i(),{href:"/admin/content/add",style:{fontFamily:s.F.sans,fontSize:"0.82rem",color:s.A.primary,textDecoration:"none"},children:"+ Add content"}),(0,l.jsx)(o.$n,{onClick:()=>c(e=>!e),variant:d?"primary":"default",size:"sm",children:d?"Auto-run: on":"Auto-run: off"}),(0,l.jsx)(o.$n,{onClick:v,size:"sm",disabled:u,children:u?"Tickingâ¦":"Run one"})]}),children:[(0,l.jsxs)(o.jP,{children:[(0,l.jsx)(o.hI,{label:"Queued",value:n.queued,tone:n.queued>0?"warn":"default"}),(0,l.jsx)(o.hI,{label:"Running",value:n.running,tone:n.running>0?"info":"default"}),(0,l.jsx)(o.hI,{label:"Done",value:n.done,tone:"ok"}),(0,l.jsx)(o.hI,{label:"Failed",value:n.failed,tone:n.failed>0?"bad":"default"}),(0,l.jsx)(o.hI,{label:"Canceled",value:n.canceled})]}),p&&(0,l.jsx)("div",{style:{marginBottom:"12px",padding:"10px 14px",borderRadius:"4px",backgroundColor:p.startsWith("Error")?s.A.badBg:s.A.okBg,color:p.startsWith("Error")?s.A.bad:s.A.ok,fontFamily:s.F.sans,fontSize:"0.84rem"},children:p}),(0,l.jsxs)(o.Zp,{children:[(0,l.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"14px",alignItems:"center"},children:[(0,l.jsxs)(o.$n,{size:"sm",variant:"danger",onClick:()=>C("stop-queued",void 0,"Stopped queued jobs"),disabled:"stop-queued"===j||0===n.queued,children:["Stop queued (",n.queued,")"]}),(0,l.jsxs)(o.$n,{size:"sm",onClick:()=>C("rerun-failed",void 0,"Re-queued failed jobs"),disabled:"rerun-failed"===j||0===n.failed,children:["Rerun failed (",n.failed,")"]}),(0,l.jsxs)(o.$n,{size:"sm",onClick:()=>C("clear-done",void 0,"Cleared done and canceled jobs"),disabled:"clear-done"===j||n.done+n.canceled===0,children:["Clear done (",n.done+n.canceled,")"]}),(0,l.jsx)("div",{style:{flex:1}}),(0,l.jsx)(f,{filter:b,setFilter:A,counts:n,total:e.length})]}),0===F.length?(0,l.jsx)("div",{style:{padding:"32px",textAlign:"center",fontFamily:s.F.sans,fontSize:"0.85rem",color:s.A.textMuted},children:0===e.length?"No jobs yet. Use the â+ Add contentâ page to enqueue work.":"No jobs match this filter."}):(0,l.jsx)("div",{style:{overflowX:"auto",marginLeft:"-20px",marginRight:"-20px"},children:(0,l.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{style:{backgroundColor:s.A.pageBg},children:[(0,l.jsx)(g,{children:"Status"}),(0,l.jsx)(g,{children:"Type"}),(0,l.jsx)(g,{children:"Target / Batch"}),(0,l.jsx)(g,{children:"Started"}),(0,l.jsx)(g,{children:"Elapsed"}),(0,l.jsx)(g,{children:"Attempts"}
1),(0,l.jsx)(g,{children:"Result / Error"}),(0,l.jsx)(g,{align:"right",children:" "})]})}),(0,l.jsx)("tbody",{children:F.map(e=>(0,l.jsx)(h,{job:e,busyAction:j,onCancel:()=>C("cancel",{id:e.id},"Canceled")},e.id))})]})})]})]})}function f(e){let{filter:t,setFilter:n,counts:r,total:a}=e,i=[{key:"all",label:"All",count:a},{key:"queued",label:"Queued",count:r.queued},{key:"running",label:"Running",count:r.running},{key:"done",label:"Done",count:r.done},{key:"failed",label:"Failed",count:r.failed},{key:"canceled",label:"Canceled",count:r.canceled}];return(0,l.jsx)("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap"},children:i.map(e=>{let r=t===e.key;return(0,l.jsxs)("button",{onClick:()=>n(e.key),style:{padding:"4px 10px",borderRadius:"3px",border:"1px solid ".concat(r?s.A.primary:s.A.border),backgroundColor:r?"".concat(s.A.primary,"14"):"white",color:r?s.A.primary:s.A.textMuted,fontFamily:s.F.sans,fontSize:"0.75rem",fontWeight:r?600:500,cursor:"pointer"},children:[e.label," (",e.count,")"]},e.key)})})}function g(e){let{children:t,align:n}=e;return(0,l.jsx)("th",{style:{padding:"9px 14px",textAlign:n||"left",fontFamily:s.F.sans,fontSize:"0.7rem",fontWeight:600,color:s.A.textMuted,textTransform:"uppercase",letterSpacing:"0.06em",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(s.A.border)},children:t})}function h(e){let{job:t,busyAction:n,onCancel:r}=e,a=function(e){if(!e.startedAt)return"â";let t=new Date(e.startedAt).getTime(),n=Math.max(0,Math.floor(((e.completedAt?new Date(e.completedAt).getTime():Date.now())-t)/1e3));if(n<60)return"".concat(n,"s");let l=Math.floor(n/60);return"".concat(l,"m ").concat(n%60,"s")}(t),i=function(e){if(!e)return null;try{return JSON.parse(e)}catch(e){return null}}(t.resultJson),d="done"===t.status?function(e,t){let n=function(e){if(!e)return{};try{return JSON.parse(e)}catch(e){return{}}}(e.targetMetaJson),l=String((null==t?void 0:t.slug)||e.targetSlug||"");switch(e.type){case"glossary":return l?"/glossary/".concat(l):null;case"guide":return l?"/buyer-guides/".concat(l):null;case"infocus-guide":{let l=String((null==t?void 0:t.slug)||n.guideSlug||e.targetSlug||"");return l?"/in-focus/".concat(l):null}case"infocus-article":{let l=String((null==t?void 0:t.guideSlug)||n.guideSlug||""),r=String((null==t?void 0:t.slug)||n.articleSlug||e.targetSlug||"");if(!l||!r)return null;return"/in-focus/".concat(l,"/").concat(r)}case"spotlight":{let e=String(n.series||"");if(!e||!l)return null;return"/spotlight/".concat(e,"/").concat(l)}case"notable":return"/spotlight/notable";default:return null}}(t,i):null,c="â";if("failed"===t.status&&t.error)c=(0,l.jsx)("span",{style:{color:s.A.bad},children:t.error});else if(i){let e=String(i.title||i.term||i.slug||"ok"),t=[];i.sizeKb&&t.push("".concat(i.sizeKb," KB")),i.wordCount&&t.push("".concat(i.wordCount," words")),i.itemCount&&t.push("".concat(i.itemCount," stories")),i.category&&t.push(String(i.category)),c=(0,l.jsxs)("span",{children:[(0,l.jsx)("span",{style:{fontWeight:500},children:e}),t.length>0&&(0,l.jsxs)("span",{style:{color:s.A.textMuted},children:[" \xb7 ",t.join(" \xb7 ")]}),d&&(0,l.jsxs)(l.Fragment,{children:[" ",(0,l.jsx)("a",{href:d,target:"_blank",rel:"noopener noreferrer",style:{marginLeft:6,color:s.A.primary,textDecoration:"none",fontWeight:500},title:"Open the live page",children:"View â"})]})]})}let u="queued"===t.status;return(0,l.jsxs)("tr",{style:{borderTop:"1px solid ".concat(s.A.border),fontFamily:s.F.sans,fontSize:"0.83rem",color:s.A.text,verticalAlign:"top"},children:[(0,l.jsx)("td",{style:x(),children:(0,l.jsx)(p,{status:t.status})}),(0,l.jsx)("td",{style:x(),children:(0,l.jsx)("code",{style:{fontFamily:s.F.mono,fontSize:"0.78rem",color:s.A.textMuted},children:t.type})}),(0,l.jsxs)("td",{style:x(),children:[(0,l.jsx)("div",{style:{fontWeight:500},children:t.targetSlug||(0,l.jsx)("span",{style:{color:s.A.textMuted},children:"â"})}),t.batchLabel&&(0,l.jsx)("div",{style:{fontSize:"0.74rem",color:s.A.textMuted,marginTop:2},children:t.batchLabel})]}),(0,l.jsx)("td",{style:x(),children:(0,l.jsx)("span",{style:{color:s.A.textMuted,fontSize:"0.78rem"},children:t.startedAt?(0,s.v7)(t.startedAt):(0,l.jsx)("span",{style:{color:s.A.textSubtle},children:"â"})})}),(0,l.jsx)("td",{style:x(),children:(0,l.jsx)("span",{style:{color:s.A.textMuted,fontSize:"0.78rem"},children:a})}),(0,l.jsx)("td",{style:x(),children:(0,l.jsx)("span",{style:{color:s.A.textMuted,fontSize:"0.78rem"},children:t.attempts})}),(0,l.jsx)("td",{style:x(),children:(0,l.jsx)("span",{style:{fontSize:"0.82rem",wordBreak:"break-word"},children:c})}),(0,l.jsx)("td",{style:{...x(),textAlign:"right"},children:u&&(0,l.jsx)(o.$n,{size:"sm",variant:"ghost",onClick:r,disabled:"cancel"===n,children:"Cancel"})})]})}function x(){return{padding:"11px 14px",verticalAlign:"top"}}function p(e){let{status:t}
1=e,n={queued:{bg:s.A.warnBg,fg:s.A.warn},running:{bg:s.A.infoBg,fg:s.A.info},done:{bg:s.A.okBg,fg:s.A.ok},failed:{bg:s.A.badBg,fg:s.A.bad},canceled:{bg:"oklch(0.94 0.005 250)",fg:s.A.textMuted}}[t];return(0,l.jsx)("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:"3px",fontFamily:s.F.sans,fontSize:"0.7rem",fontWeight:600,backgroundColor:n.bg,color:n.fg,textTransform:"capitalize"},children:d[t]})}}},e=>{e.O(0,[8982,636,6593,8792],()=>e(e.s=24050)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.