(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9826],{94966:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]/[job]",function(){return s(50190)}])},27325:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},16826:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},88507:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]])},28586:function(e,t,s){"use strict";s.d(t,{Z:function(){return r}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let r=(0,s(60998).Z)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},99307:function(e,t,s){"use strict";s.d(t,{Cl:function(){return l},OE:function(){return o}});var r=s(85893);s(67294);var n=s(55739),a=s(470),c=s(53850);let l=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":case"IN_USE":case"READY":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"AUTOSTOPPING":return"bg-purple-100 text-purple-800";case"TERMINATED":case"PENDING":case"UNKNOWN":default:return"bg-gray-100 text-gray-800";case"SUCCEEDED":case"PROVISIONING":case"CONTROLLER_INIT":case"REPLICA_INIT":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":case"FAILED_INITIAL_DELAY":case"FAILED_PROBING":case"FAILED_PROVISION":case"FAILED_CLEANUP":case"CONTROLLER_FAILED":return"bg-red-50 text-red-700";case"CANCELLED":case"CANCELLING":case"NOT_READY":return"bg-yellow-50 text-yellow-700";case"RECOVERING":case"SHUTTING_DOWN":return"bg-orange-50 text-orange-700";case"SUBMITTED":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700";case"PREEMPTED":case"NO_REPLICA":return"bg-purple-50 text-purple-700"}},i=e=>{switch(e){case"LAUNCHING":case"STARTING":case"AUTOSTOPPING":case"PROVISIONING":case"SHUTTING_DOWN":return(0,r.jsx)(n.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":case"IN_USE":default:return(0,r.jsx)(c.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":case"PREEMPTED":return(0,r.jsx)(c.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":case"FAILED_INITIAL_DELAY":case"FAILED_PROBING":case"FAILED_PROVISION":case"FAILED_CLEANUP":case"CONTROLLER_FAILED":case"UNKNOWN":return(0,r.jsx)(c.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,r.jsx)(c.Ye,{className:"w-3 h-3 mr-1"});case"PENDING":case"RECOVERING":case"SUBMITTED":case"CANCELLING":case"FAILED_SETUP":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":case"READY":case"NOT_READY":case"CONTROLLER_INIT":case"REPLICA_INIT":case"NO_REPLICA":return(0,r.jsx)(c.J$,{className:"w-3 h-3 mr-1"})}},u=e=>{let t=l(e),s=i(e);return(0,r.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(t),children:[s,e]})},o=e=>{let{status:t,statusTooltip:s}=e,n=s||t;return(0,r.jsx)(a.Md,{content:n,children:(0,r.jsx)("span",{children:u(t)})})}},20546:function(e,t,s){"use strict";s.d(t,{H:function(){return o}});var r=s(85893);s(67294);var n=s(41664),a=s.n(n),c=s(45697),l=s.n(c);function i(e){return!!e&&"string"==typeof e&&e.toLowerCase().startsWith("sa-")}let u=()=>(0,r.jsx)("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded font-medium ml-1",children:"SA"}),o=e=>{let{username:t,userHash:s,className:n="flex items-center gap-1",linkClassName:c="text-gray-700 hover:text-blue-600 hover:underline",showBadge:l=!0}=e,o=i(s),d=i(s)?"/users?tab=service-accounts":"/users";return(0,r.jsxs)("div",{className:n,children:[(0,r.jsx)(a(),{href:d,className:c,children:t}),l&&o&&(0,r.jsx)(u,{})]})};o.propTypes={username:l().string.isRequired,userHash:l().string,className:l().string,linkClassName:l().string,showBadge:l().bool}},15821:function(e,t,s){"use strict";function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,r=document.getElementById("toast-container");r||((r=document.createElement("div")).id="toast-container",r.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(r));let n=document.createElement("div");switch(n.className="rounded-md border-l-4 p-4 shadow-md flex items-center justify-between max-w-md w-full mb-2 pointer-events-auto",t){case"success":n.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":n.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":n.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:n.className+=" bg-blue-100 border-blue-500 text-blue-800"}return n.innerHTML='\n      <div class="flex-1 mr-2">\n        <p class="text-sm font-medium">'.concat(e,'</p>\n      </div>\n      <button class="text-gray-500 hover:text-gray-700 focus:outline-none" aria-label="Close toast">\n        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n          <line x1="18" y1="6" x2="6" y2="18"></line>\n          <line x1="6" y1="6" x2="18" y2="18"></line>\n        </svg>\n      </button>\n    '),r.appendChild(n),n.querySelector("button").addEventListener("click",()=>{r.removeChild(n)}),setTimeout(()=>{r.contains(n)&&r.removeChild(n)},s),n}s.d(t,{C:function(){return r}})},21494:function(e,t,s){"use strict";s.d(t,{V:function(){return a}});var r=s(67294),n=s(470);function a(e){let{streamFn:t,streamArgs:s,enabled:a=!0,refreshTrigger:c=0,maxLineChars:l=2e3,maxRenderLines:i=5e3,flushIntervalMs:u=100,onError:o=e=>{}}=e,[d,m]=(0,r.useState)([]),[x,h]=(0,r.useState)(!1),[N,f]=(0,r.useState)(!1),[g,b]=(0,r.useState)(0),j=(0,r.useRef)([]),y=(0,r.useRef)(""),E=(0,r.useRef)(new Map),p=(0,r.useRef)(null),v=(0,r.useRef)(null),I=(0,r.useRef)(!1),w=(0,r.useRef)(o);(0,r.useEffect)(()=>{w.current=o},[o]);let L=(0,r.useCallback)(()=>{j.current=[],y.current="",E.current=new Map,I.current=!1,m([]),f(!1)},[]),R=(0,r.useMemo)(()=>[...d,...Array.from(E.current.values())],[d,g]),C=(0,r.useCallback)(()=>{0!==j.current.length&&m(e=>{let t=[...e,...j.current];return j.current=[],t.length>i?t.slice(t.length-i):t})},[i]);return(0,r.useEffect)(()=>{let e=!0;if(L(),!a||!t)return h(!1),()=>{};let r=new AbortController;v.current=r;let c=()=>{p.current||(p.current=setTimeout(()=>{p.current=null,C()},u))},o=e=>{let t=e.match(/^\(([^)]+)\)/);if(t){E.current.set(t[1],e),b(e=>e+1);return}j.current.push(e),j.current.length>2*i&&(j.current=j.current.slice(j.current.length-i))},d=e=>{let t=e.split("\n");t[0]=y.current+t[0];let s=e.endsWith("\n");y.current=s?"":t.pop()||"";let r=t.filter(e=>e.trim());for(let e of(!I.current&&r.length>0&&(I.current=!0,f(!0)),r)){let t=(0,n.Zn)(e);!(0,n.Zt)(t)&&(t.length>l&&(t=t.slice(0,l)+" … [truncated]"),/\d+%\s*\|/.test(t)?o(t):(j.current.push(t),j.current.length>2*i&&(j.current=j.current.slice(j.current.length-i))))}c()};return h(!0),t({...s,onNewLog:t=>{e&&d(t)},signal:r.signal}).then(()=>{e&&(y.current&&(j.current.push(y.current),y.current=""),C(),h(!1))}).catch(t=>{if(!e||"AbortError"===t.name)return;let s=w.current;s&&s(t),m(e=>[...e,"Error fetching logs: ".concat(t.message)]),h(!1)}),()=>{e=!1,p.current&&(clearTimeout(p.current),p.current=null),v.current&&(v.current.abort(),v.current=null),j.current=[],y.current="",E.current.clear()}},[t,s,a,c,C,u,l,i,L]),{lines:R,isLoading:x,hasReceivedFirstChunk:N}}},50190:function(e,t,s){"use strict";s.r(t),s.d(t,{JobDetailPage:function(){return w}});var r=s(85893),n=s(67294),a=s(37673),c=s(41664),l=s.n(c),i=s(11163),u=s(23266),o=s(470),d=s(13626),m=s(16826),x=s(55739),h=s(99307),N=s(23001),f=s(9008),g=s.n(f),b=s(20546),j=s(70282),y=s(27325),E=s(45697),p=s.n(E),v=s(21494);function I(e){let{cluster:t,job:s,jobData:n,onRefresh:a,isRefreshing:c,loading:i}=e,u=(0,N.X)();return(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,r.jsxs)("div",{className:"text-base flex items-center",children:[(0,r.jsx)(l(),{href:"/clusters",className:"text-sky-blue hover:underline",children:"Sky Clusters"}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsx)(l(),{href:"/clusters/".concat(t),className:"text-sky-blue hover:underline",children:t}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsxs)(l(),{href:"/clusters/".concat(t,"/").concat(s),className:"text-sky-blue hover:underline",children:[s,n.job&&"-"!=n.job?" (".concat(n.job,")"):""]})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[(i||c)&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(x.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"text-sm ml-2 text-gray-500",children:"Loading..."})]}),(0,r.jsx)(o.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,r.jsxs)("button",{onClick:a,disabled:i||c,className:"text-sm text-sky-blue hover:text-sky-blue-bright font-medium mx-2 flex items-center",children:[(0,r.jsx)(d.Z,{className:"w-4 h-4 mr-1.5"}),!u&&(0,r.jsx)("span",{children:"Refresh"})]})})]})]})}function w(){let e=(0,i.useRouter)(),{cluster:t,job:s}=e.query,{clusterData:c,clusterJobData:N,loading:f,refreshData:E}=(0,u.QL)({cluster:t}),[p,w]=(0,n.useState)(!1),[L,R]=(0,n.useState)(!0),[C,D]=(0,n.useState)(!1),[T,_]=(0,n.useState)(0),k=(0,n.useMemo)(()=>["INIT","PENDING","SETTING_UP"],[]),A=(0,n.useMemo)(()=>{if(!N||!s)return!0;let e=N.find(e=>e.id==s);return e&&k.includes(e.status)},[N,s,k]);(0,n.useEffect)(()=>{!f&&L&&R(!1)},[f,L]);let O=(0,n.useMemo)(()=>({clusterName:t,jobId:s,workspace:null==c?void 0:c.workspace}),[t,s,null==c?void 0:c.workspace]),P=(0,n.useCallback)(e=>{console.error("Error streaming cluster logs:",e)},[]),{lines:S,isLoading:U}=(0,v.V)({streamFn:u.Sl,streamArgs:O,enabled:!!(t&&s)&&!A,refreshTrigger:T,onError:P}),G=async()=>{w(!0),_(e=>e+1);try{E&&await E()}catch(e){console.error("Error refreshing data:",e)}finally{w(!1)}};if(!e.isReady)return(0,r.jsx)("div",{children:"Loading..."});let F={id:s};if(c&&N){let e=N.find(e=>e.id==s);e&&(F={...e,infra:c.infra,cluster:c.cluster,user:c.user,user_hash:c.user_hash})}let M=t&&s?"Job: ".concat(s," @ ").concat(t," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g(),{children:(0,r.jsx)("title",{children:M})}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{cluster:t,job:s,jobData:F,onRefresh:G,isRefreshing:p,loading:f}),f&&L?(0,r.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,r.jsx)(x.Z,{size:24,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]}):(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsx)("div",{id:"details",children:(0,r.jsxs)(a.Zb,{children:[(0,r.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Details"})}),(0,r.jsx)("div",{className:"p-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job ID"}),(0,r.jsx)("div",{className:"text-base mt-1",children:F.id})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job Name"}),(0,r.jsx)("div",{className:"text-base mt-1",children:F.job})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,r.jsx)("div",{className:"text-base mt-1",children:(0,r.jsx)(h.OE,{status:F.status})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,r.jsx)("div",{className:"text-base mt-1",children:(0,r.jsx)(b.H,{username:F.user,userHash:F.user_hash})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Submitted"}),(0,r.jsx)("div",{className:"text-base mt-1",children:F.submitted_at?(0,o.xn)(F.submitted_at):"N/A"})]}),F.resources&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Requested Resources"}),(0,r.jsx)("div",{className:"text-base mt-1",children:F.resources||"N/A"})]}),F.cluster&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cluster"}),(0,r.jsx)("div",{className:"text-base mt-1",children:(0,r.jsx)(l(),{href:"/clusters/".concat(F.cluster),className:"text-sky-blue hover:underline",children:F.cluster})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Git Commit"}),(0,r.jsx)("div",{className:"text-base mt-1 flex items-center",children:F.git_commit&&"-"!==F.git_commit?(0,r.jsxs)("span",{className:"flex items-center mr-2",children:[F.git_commit,(0,r.jsx)(o.WH,{content:C?"Copied!":"Copy commit",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:async()=>{await navigator.clipboard.writeText(F.git_commit),D(!0),setTimeout(()=>D(!1),2e3)},className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:C?(0,r.jsx)(j.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(y.Z,{className:"w-4 h-4"})})})]}):(0,r.jsx)("span",{className:"text-gray-400",children:"-"})})]})]})})]})}),(0,r.jsx)("div",{id:"logs",className:"mt-6",children:(0,r.jsxs)(a.Zb,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Logs"}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,r.jsx)(o.WH,{content:"Download full logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>(0,u.GH)({clusterName:t,jobIds:s?[s]:null,workspace:null==c?void 0:c.workspace}),className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(m.Z,{className:"w-4 h-4"})})}),(0,r.jsx)(o.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{_(e=>e+1)},disabled:U,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(d.Z,{className:"w-4 h-4 ".concat(U?"animate-spin":"")})})})]})]}),(0,r.jsx)("div",{className:"p-4",children:A?(0,r.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,r.jsx)("span",{children:"Waiting for the job to start; refresh in a few moments."})}):U?(0,r.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,r.jsx)(x.Z,{size:20,className:"mr-2"}),(0,r.jsx)("span",{children:"Loading..."})]}):(0,r.jsx)("div",{className:"max-h-96 overflow-y-auto",children:(0,r.jsx)(o.$B,{logs:S})})})]})})]})]})]})}I.propTypes={cluster:p().oneOfType([p().string,p().number]),job:p().oneOfType([p().string,p().number]),jobData:p().shape({job:p().oneOfType([p().string,p().number])}),onRefresh:p().func,isRefreshing:p().bool,loading:p().bool},t.default=w},10410:function(e,t,s){"use strict";s.d(t,{M:function(){return a}});var r=s(23800),n=s(6378);async function a(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=(0,r.A_)(t);if(0===a.length)return e;let c={dashboardCache:s.dashboardCache||n.ZP,getOriginalData:()=>Promise.resolve(e),rawData:s.rawData||null,...s},l=e;for(let e of a){let t=l;try{let s=await e.enhance(t,c);if(!Array.isArray(s)){console.error("[Plugin] Data enhancement ".concat(e.id," did not return an array. Skipping."));continue}s.length!==t.length&&console.warn("[Plugin] Data enhancement ".concat(e.id," changed array length from ").concat(t.length," to ").concat(s.length,". This is not recommended.")),l=s}catch(t){console.error("[Plugin] Data enhancement ".concat(e.id," failed:"),t)}}return l}},9008:function(e,t,s){e.exports=s(37219)}},function(e){e.O(0,[5739,3850,3325,2888,9774,179],function(){return e(e.s=94966)}),_N_E=e.O()}]);