(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[826],{94966:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]/[job]",function(){return t(50190)}])},27325:function(e,s,t){"use strict";t.d(s,{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,t(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,s,t){"use strict";t.d(s,{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,t(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,s,t){"use strict";t.d(s,{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,t(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"}]])},13626:function(e,s,t){"use strict";t.d(s,{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,t(60998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},28586:function(e,s,t){"use strict";t.d(s,{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,t(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,s,t){"use strict";t.d(s,{Cl:function(){return l},OE:function(){return d}});var r=t(85893);t(67294);var n=t(55739),c=t(470),a=t(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)(a.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":case"PREEMPTED":return(0,r.jsx)(a.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)(a.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,r.jsx)(a.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)(a.J$,{className:"w-3 h-3 mr-1"})}},u=e=>{let s=l(e),t=i(e);return(0,r.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(s),children:[t,e]})},d=e=>{let{status:s,statusTooltip:t}=e,n=t||s;return(0,r.jsx)(c.Md,{content:n,children:(0,r.jsx)("span",{children:u(s)})})}},20546:function(e,s,t){"use strict";t.d(s,{H:function(){return d}});var r=t(85893);t(67294);var n=t(41664),c=t.n(n),a=t(45697),l=t.n(a);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"}),d=e=>{let{username:s,userHash:t,className:n="flex items-center gap-1",linkClassName:a="text-gray-700 hover:text-blue-600 hover:underline",showBadge:l=!0}=e,d=i(t),o=i(t)?"/users?tab=service-accounts":"/users";return(0,r.jsxs)("div",{className:n,children:[(0,r.jsx)(c(),{href:o,className:a,children:s}),l&&d&&(0,r.jsx)(u,{})]})};d.propTypes={username:l().string.isRequired,userHash:l().string,className:l().string,linkClassName:l().string,showBadge:l().bool}},21494:function(e,s,t){"use strict";t.d(s,{V:function(){return c}});var r=t(67294),n=t(470);function c(e){let{streamFn:s,streamArgs:t,enabled:c=!0,refreshTrigger:a=0,maxLineChars:l=2e3,maxRenderLines:i=5e3,flushIntervalMs:u=100,onError:d=e=>{}}=e,[o,x]=(0,r.useState)([]),[m,h]=(0,r.useState)(!1),[N,f]=(0,r.useState)(!1),[j,g]=(0,r.useState)(0),b=(0,r.useRef)([]),E=(0,r.useRef)(""),y=(0,r.useRef)(new Map),p=(0,r.useRef)(null),v=(0,r.useRef)(null),I=(0,r.useRef)(!1),L=(0,r.useRef)(d);(0,r.useEffect)(()=>{L.current=d},[d]);let R=(0,r.useCallback)(()=>{b.current=[],E.current="",y.current=new Map,I.current=!1,x([]),f(!1)},[]),_=(0,r.useMemo)(()=>[...o,...Array.from(y.current.values())],[o,j]),D=(0,r.useCallback)(()=>{0!==b.current.length&&x(e=>{let s=[...e,...b.current];return b.current=[],s.length>i?s.slice(s.length-i):s})},[i]);return(0,r.useEffect)(()=>{let e=!0;if(R(),!c||!s)return h(!1),()=>{};let r=new AbortController;v.current=r;let a=()=>{p.current||(p.current=setTimeout(()=>{p.current=null,D()},u))},d=e=>{let s=e.match(/^\(([^)]+)\)/);if(s){y.current.set(s[1],e),g(e=>e+1);return}b.current.push(e),b.current.length>2*i&&(b.current=b.current.slice(b.current.length-i))},o=e=>{let s=e.split("\n");s[0]=E.current+s[0];let t=e.endsWith("\n");E.current=t?"":s.pop()||"";let r=s.filter(e=>e.trim());for(let e of(!I.current&&r.length>0&&(I.current=!0,f(!0)),r)){let s=(0,n.Zn)(e);!(0,n.Zt)(s)&&(s.length>l&&(s=s.slice(0,l)+" … [truncated]"),/\d+%\s*\|/.test(s)?d(s):(b.current.push(s),b.current.length>2*i&&(b.current=b.current.slice(b.current.length-i))))}a()};return h(!0),s({...t,onNewLog:s=>{e&&o(s)},signal:r.signal}).then(()=>{e&&(E.current&&(b.current.push(E.current),E.current=""),D(),h(!1))}).catch(s=>{if(!e||"AbortError"===s.name)return;let t=L.current;t&&t(s),x(e=>[...e,"Error fetching logs: ".concat(s.message)]),h(!1)}),()=>{e=!1,p.current&&(clearTimeout(p.current),p.current=null),v.current&&(v.current.abort(),v.current=null),b.current=[],E.current="",y.current.clear()}},[s,t,c,a,D,u,l,i,R]),{lines:_,isLoading:m,hasReceivedFirstChunk:N}}},23001:function(e,s,t){"use strict";t.d(s,{X:function(){return n}});var r=t(67294);function n(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[s,t]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{let s=()=>{t(window.innerWidth<e)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[e]),s}},50190:function(e,s,t){"use strict";t.r(s),t.d(s,{JobDetailPage:function(){return L}});var r=t(85893),n=t(67294),c=t(37673),a=t(41664),l=t.n(a),i=t(11163),u=t(23266),d=t(470),o=t(13626),x=t(16826),m=t(55739),h=t(99307),N=t(23001),f=t(9008),j=t.n(f),g=t(20546),b=t(70282),E=t(27325),y=t(45697),p=t.n(y),v=t(21494);function I(e){let{cluster:s,job:t,jobData:n,onRefresh:c,isRefreshing:a,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(s),className:"text-sky-blue hover:underline",children:s}),(0,r.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,r.jsxs)(l(),{href:"/clusters/".concat(s,"/").concat(t),className:"text-sky-blue hover:underline",children:[t,n.job&&"-"!=n.job?" (".concat(n.job,")"):""]})]}),(0,r.jsxs)("div",{className:"flex items-center",children:[(i||a)&&(0,r.jsxs)("div",{className:"flex items-center mr-2",children:[(0,r.jsx)(m.Z,{size:15,className:"mt-0"}),(0,r.jsx)("span",{className:"text-sm ml-2 text-gray-500",children:"Loading..."})]}),(0,r.jsx)(d.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,r.jsxs)("button",{onClick:c,disabled:i||a,className:"text-sm text-sky-blue hover:text-sky-blue-bright font-medium mx-2 flex items-center",children:[(0,r.jsx)(o.Z,{className:"w-4 h-4 mr-1.5"}),!u&&(0,r.jsx)("span",{children:"Refresh"})]})})]})]})}function L(){let e=(0,i.useRouter)(),{cluster:s,job:t}=e.query,{clusterData:a,clusterJobData:N,loading:f,refreshData:y}=(0,u.QL)({cluster:s}),[p,L]=(0,n.useState)(!1),[R,_]=(0,n.useState)(!0),[D,T]=(0,n.useState)(!1),[C,A]=(0,n.useState)(0),w=(0,n.useMemo)(()=>["INIT","PENDING","SETTING_UP"],[]),k=(0,n.useMemo)(()=>{if(!N||!t)return!0;let e=N.find(e=>e.id==t);return e&&w.includes(e.status)},[N,t,w]);(0,n.useEffect)(()=>{!f&&R&&_(!1)},[f,R]);let O=(0,n.useMemo)(()=>({clusterName:s,jobId:t,workspace:null==a?void 0:a.workspace}),[s,t,null==a?void 0:a.workspace]),S=(0,n.useCallback)(e=>{console.error("Error streaming cluster logs:",e)},[]),{lines:P,isLoading:U}=(0,v.V)({streamFn:u.Sl,streamArgs:O,enabled:!!(s&&t)&&!k,refreshTrigger:C,onError:S}),G=async()=>{L(!0),A(e=>e+1);try{y&&await y()}catch(e){console.error("Error refreshing data:",e)}finally{L(!1)}};if(!e.isReady)return(0,r.jsx)("div",{children:"Loading..."});let F={id:t};if(a&&N){let e=N.find(e=>e.id==t);e&&(F={...e,infra:a.infra,cluster:a.cluster,user:a.user,user_hash:a.user_hash})}let Z=s&&t?"Job: ".concat(t," @ ").concat(s," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(j(),{children:(0,r.jsx)("title",{children:Z})}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(I,{cluster:s,job:t,jobData:F,onRefresh:G,isRefreshing:p,loading:f}),f&&R?(0,r.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,r.jsx)(m.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)(c.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)(g.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,d.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)(d.WH,{content:D?"Copied!":"Copy commit",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:async()=>{await navigator.clipboard.writeText(F.git_commit),T(!0),setTimeout(()=>T(!1),2e3)},className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:D?(0,r.jsx)(b.Z,{className:"w-4 h-4 text-green-600"}):(0,r.jsx)(E.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)(c.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)(d.WH,{content:"Download full logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>(0,u.GH)({clusterName:s,jobIds:t?[t]:null,workspace:null==a?void 0:a.workspace}),className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(x.Z,{className:"w-4 h-4"})})}),(0,r.jsx)(d.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,r.jsx)("button",{onClick:()=>{A(e=>e+1)},disabled:U,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,r.jsx)(o.Z,{className:"w-4 h-4 ".concat(U?"animate-spin":"")})})})]})]}),(0,r.jsx)("div",{className:"p-4",children:k?(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)(m.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)(d.$B,{logs:P})})})]})})]})]})]})}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},s.default=L},9008:function(e,s,t){e.exports=t(37219)}},function(e){e.O(0,[739,850,888,774,179],function(){return e(e.s=94966)}),_N_E=e.O()}]);