(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[963],{5113:function(e,s,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/workspace/new",function(){return a(26)}])},26:function(e,s,a){"use strict";a.r(s),a.d(s,{default:function(){return g}});var t=a(5893),r=a(7294),n=a(1163),l=a(5843),i=a(7324),o=a(9470),c=a(1664),d=a.n(c),u=a(9008),f=a.n(u),m=a(803),x=a(2350);let p=r.forwardRef((e,s)=>{let{className:a,type:r,...n}=e;return(0,t.jsx)("input",{type:r,className:(0,x.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",a),ref:s,...n})});p.displayName="Input";var h=a(5320),b=r.forwardRef((e,s)=>(0,t.jsx)(h.WV.label,{...e,ref:s,onMouseDown:s=>{s.target.closest("button, input, select, textarea")||(e.onMouseDown?.(s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));b.displayName="Label";let w=(0,a(2003).j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),k=r.forwardRef((e,s)=>{let{className:a,...r}=e;return(0,t.jsx)(b,{ref:s,className:(0,x.cn)(w(),a),...r})});k.displayName=b.displayName;var N=a(7673);function g(){(0,n.useRouter)();let[e,s]=(0,r.useState)(""),[a,c]=(0,r.useState)(!1),[u,x]=(0,r.useState)({}),[h,b]=(0,r.useState)(!0);(0,r.useEffect)(()=>{w()},[]);let w=async()=>{try{let e=await (0,i.fX)();x(e)}catch(e){console.error("Failed to fetch existing workspaces:",e)}finally{b(!1)}},g=()=>{e.trim()&&!j&&c(!0)},j=e.trim()&&u.hasOwnProperty(e.trim()),y=e.trim()&&!j;return a?(0,t.jsx)(l.I,{workspaceName:e,isNewWorkspace:!0}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(f(),{children:(0,t.jsx)("title",{children:"Create New Workspace | SkyPilot Dashboard"})}),(0,t.jsxs)(o.A,{highlighted:"workspaces",children:[(0,t.jsx)("div",{className:"flex items-center justify-between mb-4 h-5",children:(0,t.jsxs)("div",{className:"text-base flex items-center",children:[(0,t.jsx)(d(),{href:"/workspaces",className:"text-sky-blue hover:underline",children:"Workspaces"}),(0,t.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,t.jsx)("span",{className:"text-sky-blue",children:"New Workspace"})]})}),(0,t.jsxs)(N.Zb,{className:"max-w-md",children:[(0,t.jsx)(N.Ol,{children:(0,t.jsx)(N.ll,{className:"text-base font-normal",children:"Create New Workspace"})}),(0,t.jsxs)(N.aY,{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(k,{htmlFor:"workspace-name",className:"text-sm font-normal",children:"Workspace name"}),(0,t.jsx)(p,{id:"workspace-name",value:e,onChange:e=>s(e.target.value),placeholder:"Enter workspace name",autoFocus:!0,onKeyPress:e=>{"Enter"===e.key&&y&&g()}}),j?(0,t.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:['Workspace "',e,'" already exists.'," ",(0,t.jsx)(d(),{href:"/workspaces/".concat(e),className:"text-blue-600 hover:underline",children:"View the workspace"})]}):(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Choose a unique name for your workspace"})]}),(0,t.jsx)(m.z,{onClick:g,disabled:!y||h,className:"w-full bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:h?"Loading...":"Next: Configure Workspace"})]})]})]})]})}}},function(e){e.O(0,[146,573,488,320,470,990,627,236,843,888,774,179],function(){return e(e.s=5113)}),_N_E=e.O()}]);