"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[149],{4427:function(e,t,n){var r=n(5893),o=n(2429),i=n(9309),a=n(7169);function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var I=function(e){return(0,r.jsx)(f.Z,{in:!0,children:(0,r.jsx)(v.Z,S({},e))})},P=function(e){var t=e.componentsProps,n=e.extendRenderInput,o=e.label,i=e.messageBoxProps,s=e.renderInput,l=e.sx,u=j(e,["componentsProps","extendRenderInput","label","messageBoxProps","renderInput","sx"]),c=S({paper:{sx:{backgroundColor:p.lD}}},t),d=null!==s&&void 0!==s?s:function(e){var t=e.fullWidth,i=e.InputProps,a=e.InputLabelProps,s=e.inputProps,l={formControlProps:{fullWidth:t,ref:i.ref},inputLabelProps:a,inputProps:{className:i.className,endAdornment:i.endAdornment,inputProps:s,startAdornment:i.startAdornment},label:o};return null===n||void 0===n||n.call(null,l,e),(0,r.jsx)(y.Z,S({},l))},f=S(U({},"& .".concat(m.Z.root," .").concat(x.Z.endAdornment),U({right:"7px"},"& .".concat(g.Z.root),{color:p.s7})),l);return(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:[(0,r.jsx)(b.Z,S({PaperComponent:I},u,{componentsProps:c,renderInput:d,sx:f})),(0,r.jsx)(h.Z,S({},i))]})},D=n(157),O=n(4825),Z=n(4490),w=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.fromUnit,r=t.onFailure,o=t.onSuccess,i=t.precision,a=t.toUnit,s=(0,Z.gO)(e,{fromUnit:n,precision:i,toUnit:a});if(s){var l=s.value,u=s.unit;try{var c,p,d;null===o||void 0===o||null===(c=o.bigint)||void 0===c||c.call(null,BigInt(l),u),null===o||void 0===o||null===(p=o.number)||void 0===p||p.call(null,parseFloat(l),u),null===o||void 0===o||null===(d=o.string)||void 0===d||d.call(null,l,u)}catch(f){null===r||void 0===r||r.call(null,f,l,u)}}else null===r||void 0===r||r.call(null)},C=function(e,t,n,r){w(e,{fromUnit:t,onFailure:r,onSuccess:{bigint:n},precision:0,toUnit:"B"})},M=n(1706),k=n(8187),A=n(7120),G=n(7783);function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B(e){for(var t=1;t :first-child":{flexGrow:1},"& > :not(:last-child)":{marginRight:".5em"}},"&:hover\n .".concat(A.Z.root,"\n .").concat(m.Z.root,"\n .").concat(m.Z.notchedOutline),{borderColor:p.s7}),children:[(0,r.jsx)(y.Z,B({id:t,label:n},i)),(0,r.jsx)(G.Z,B({id:"".concat(t,"-nested-select"),selectItems:u},d))]}),(0,r.jsx)(h.Z,B({},l))]})};F.defaultProps=T;var N=F,L=n(3679),E=n(3640),V=n(6727),W=n(1184),R=n(9),Q=n(192),q=n(2416);function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function Y(e){return function(e){if(Array.isArray(e))return _(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"===typeof e)return _(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var K={inputLabelProps:{},isAllowTextInput:!1,labelId:"",messageBoxProps:{},sliderProps:{}},ee={root:"".concat("SliderInputLabelDecorator","-root")},te=function(e){var t=e.isFocused,n=e.label,o=p.s7,i="solid",s="0",l="0 .6em 0 .4em",u="1px 0 0 0",c="0.3";return t&&(s="-1px",l="0 1em 0 1em",u="2px 0 0 0",c="1"),(0,r.jsxs)(a.Z,{className:ee.root,sx:{display:"flex",flexDirection:"row",position:"absolute",top:s,width:"calc(100% - 6px)","> :last-child":{flexGrow:1}},children:[(0,r.jsx)(a.Z,{sx:{borderColor:o,borderStyle:i,borderWidth:u,content:'""',opacity:c,width:".6em"}}),(0,r.jsx)(q.Ac,{sx:{fontSize:".75em",margin:l,visibility:"hidden"},text:n}),(0,r.jsx)(a.Z,{sx:{borderColor:o,borderStyle:i,borderWidth:u,content:'""',opacity:c}})]})},ne=function(e,t){var n=Number.parseFloat(e);return Number.isNaN(n)?t:n},re=function(e){return J(e,Array)?e.map((function(e){return String(e)})):[String(e)]},oe=function(e){var t,n=e.messageBoxProps,i=void 0===n?K.messageBoxProps:n,s=e.isAllowTextInput,l=void 0===s?K.isAllowTextInput:s,u=e.label,c=e.labelId,d=void 0===c?K.labelId:c,f=e.inputLabelProps,v=void 0===f?K.inputLabelProps:f,x=e.sliderProps,g=void 0===x?K.sliderProps:x,b=e.value,y=g.max,U=g.min,S=g.onChange,j=g.sx,I=g.valueLabelDisplay,P=b,D=(0,o.useState)({range:re(b)}),O=D[0],Z=D[1],w=(0,o.useState)(!1),C=w[0],M=w[1],k=function(){M(!1)},A=function(){M(!0)},G=function(){P=function(e,t){return J(t,Array)?e.map((function(e,n){return ne(e,t[n])})):ne(e[0],t)}(O.range,P),null===S||void 0===S||S.call(null,P)};return(0,r.jsxs)(E.Z,{sx:{display:"flex",flexDirection:"column","&:hover":(t={},H(t,"& .".concat(ee.root," div"),{opacity:1}),H(t,"& .".concat(m.Z.notchedOutline),{borderColor:p.s7}),t)},children:[(0,r.jsx)(Q.Z,X({className:C?V.Z.focused:"",id:d,shrink:!0},v,{children:u})),te({isFocused:C,label:u}),(0,r.jsxs)(a.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row","> :first-child":{flexGrow:1}},children:[(0,r.jsx)(W.ZP,{"aria-labelledby":d,max:y,min:U,onBlur:k,onChange:function(e,t){Z({range:re(t)}),null===S||void 0===S||S.call(null,t)},onFocus:A,sx:X(H({color:p.s7,marginLeft:"1em",marginRight:"1em"},"& .".concat(W.TW.thumb),{borderRadius:p.n_,transform:"translate(-50%, -50%) rotate(45deg)"}),j),value:P,valueLabelDisplay:I}),O.range.map((function(e,t){return function(e){var t=e.key,n=e.isFocused,o=$(e,["key","isFocused"]);return(0,r.jsx)(R.Z,X({key:t,className:n?m.Z.focused:"",type:"number"},o))}({key:"slider-nested-text-input-".concat(t),inputProps:{max:y,min:U},isFocused:C,onBlur:k,onChange:function(){for(var e=arguments.length,n=new Array(e),r=0;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function me(e,t){return ue(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(l){s=!0,o=l}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}}(e,t)||be(e,t)||de()}function xe(e){return ue(e)||pe(e)||be(e,i)||de()}function ge(e){return function(e){if(Array.isArray(e))return le(e)}(e)||pe(e)||be(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function be(e,t){if(e){if("string"===typeof e)return le(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?le(e,t):void 0}}var he,ye,Ue=BigInt(0),Se=[{value:"B"},{value:"KiB"},{value:"MiB"},{value:"GiB"},{value:"TiB"}],je="GiB",Ie=BigInt(65536),Pe=BigInt(104857600),De={backgroundColor:p.Ej,color:p.lD,"&:hover":{backgroundColor:p.Ej}},Oe=function(e,t){var n=t.onButtonClick;return(0,r.jsx)(O.Z,{disabled:void 0===n,onClick:n,sx:{minWidth:"unset",whiteSpace:"nowrap"},children:"Max: ".concat(e)})},Ze=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.endAdornment,n=e.mainLabel,o=e.subLabel;return(0,r.jsxs)(a.Z,{sx:{alignItems:"center",display:"flex",flexDirection:"row",width:"100%","& > :first-child":{flexGrow:1}},children:[(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:[n&&(0,r.jsx)(q.Ac,{inverted:!0,text:n}),o&&(0,r.jsx)(q.Ac,{inverted:!0,text:o})]}),t]})},we=function(e,t,n,r,o,i,a){var s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},l=s.includeAnvilUUIDs,u=void 0===l?[]:l,c=s.includeFileUUIDs,p=void 0===c?[]:c,d=s.includeStorageGroupUUIDs,f=void 0===d?[]:d,v=function(){return!0},m=function(){return!0},x=function(){return!0};u.length>0&&(v=function(e){return u.includes(e)}),p.length>0&&(m=function(e){return p.includes(e)}),f.length>0&&(x=function(e){return f.includes(e)});var g={},b=i.reduce((function(e,t,n){var r,i=null!==(r=o[n])&&void 0!==r?r:Ue;return e.all+=i,""===t||(void 0===e[t]&&(e[t]=Ue),e[t]+=i),e}),{all:Ue}),h=e.reduce((function(e,s){var l=s.anvilUUID;if(v(l)){var u,c=s.anvilTotalCPUCores,p=s.anvilTotalAvailableMemory,d=s.files,f=s.fileUUIDs,h=s.storageGroups,y=[],U=Ue,S=Ue;if(h.forEach((function(e){var t=e.storageGroupUUID,n=e.storageGroupFree;x(t)&&(y.push(t),S+=n,n>U&&(U=n))})),[function(){return h.length>0},function(){return n<=c},function(){return r<=p},function(){return i.every((function(e,n){var r,i=null!==(r=o[n])&&void 0!==r?r:Ue,a=!0,s=i<=U;return""!==e&&(a=y.includes(e),s=i<=t[e].storageGroupFree),a&&s}))},function(){return Object.entries(b).every((function(e){var n=me(e,2),r=n[0],o=n[1];return"all"===r?o<=S:o<=t[r].storageGroupFree}))},function(){return a.every((function(e){return""===e||f.includes(e)}))}].every((function(e){return e()})))e.anvils.push(s),e.anvilUUIDs.push(l),e.maxCPUCores=Math.max(c,e.maxCPUCores),p>e.maxMemory&&(e.maxMemory=p),d.forEach((function(e){var t=e.fileUUID;m(t)&&(g[t]=!0)})),(u=e.storageGroupUUIDs).push.apply(u,ge(y)),e.maxVirtualDiskSizes.fill(U)}return e}),{anvils:[],anvilUUIDs:[],fileUUIDs:[],maxCPUCores:0,maxMemory:Ue,maxVirtualDiskSizes:i.map((function(){return Ue})),storageGroupUUIDs:[]});return h.fileUUIDs=Object.keys(g),i.forEach((function(e,n){""!==e&&(h.maxVirtualDiskSizes[n]=t[e].storageGroupFree)})),h},Ce=function(e){return e.filter((function(e){return""!==e}))},Me=function(e){return{fromUnit:"B",onSuccess:{string:e},precision:0,toUnit:"ibyte"}};w(Ie,Me((function(e,t){he="".concat(e," ").concat(t)}))),w(Pe,Me((function(e,t){ye="".concat(e," ").concat(t)})));var ke=function(e){var t=e.dialogProps.open,n=e.onClose,i=(0,o.useState)([]),f=i[0],v=i[1],m=(0,o.useState)({}),x=m[0],g=m[1],b=(0,o.useState)({}),h=b[0],U=b[1],S=(0,o.useState)({}),j=S[0],I=S[1],Z=(0,o.useState)({}),A=Z[0],z=Z[1],B=(0,o.useState)([]),T=B[0],F=B[1],E=(0,o.useState)([]),V=E[0],W=E[1],R=(0,o.useState)([]),Q=R[0],_=R[1],H=(0,o.useState)([]),J=H[0],X=H[1],$=(0,o.useState)(""),Y=$[0],K=$[1],ee=(0,o.useState)(),te=ee[0],ne=ee[1],re=(0,o.useState)(1),oe=re[0],le=re[1],ue=(0,o.useState)(0),pe=ue[0],de=ue[1],be=(0,o.useState)(),Me=be[0],ke=be[1],Ae=(0,o.useState)(Ue),Ge=Ae[0],ze=Ae[1],Be=(0,o.useState)(Ue),Te=Be[0],Fe=Be[1],Ne=(0,o.useState)(),Le=Ne[0],Ee=Ne[1],Ve=(0,o.useState)("0"),We=Ve[0],Re=Ve[1],Qe=(0,o.useState)(""),qe=Qe[0],_e=Qe[1],He=(0,o.useState)(je),Je=He[0],Xe=He[1],$e=(0,o.useState)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.existingVirtualDisks,n=void 0===t?{stateIds:[],inputMaxes:[],inputSizeMessages:[],inputSizes:[],inputStorageGroupUUIDMessages:[],inputStorageGroupUUIDs:[],inputUnits:[],maxes:[],sizes:[]}:t,r=e.stateId,o=void 0===r?(0,c.Z)():r,i=e.inputMax,a=void 0===i?"0":i,s=e.inputSize,l=void 0===s?"":s,u=e.inputSizeMessage,p=void 0===u?void 0:u,d=e.inputStorageGroupUUID,f=void 0===d?"":d,v=e.inputStorageGroupUUIDMessage,m=void 0===v?void 0:v,x=e.inputUnit,g=void 0===x?je:x,b=e.max,h=void 0===b?Ue:b,y=e.setVirtualDisks,U=e.size,S=void 0===U?Ue:U,j=n.stateIds,I=n.inputMaxes,P=n.inputSizeMessages,D=n.inputSizes,O=n.inputStorageGroupUUIDMessages,Z=n.inputStorageGroupUUIDs,w=n.inputUnits,C=n.maxes,M=n.sizes;return j.push(o),I.push(a),P.push(p),D.push(l),O.push(m),Z.push(f),w.push(g),C.push(h),M.push(S),null===y||void 0===y||y.call(null,fe({},n)),n}()),Ye=$e[0],Ke=$e[1],et=(0,o.useState)(""),tt=et[0],nt=et[1],rt=(0,o.useState)(),ot=rt[0],it=rt[1],at=(0,o.useState)(""),st=at[0],lt=at[1],ut=(0,o.useState)()[0],ct=(0,o.useState)(""),pt=ct[0],dt=ct[1],ft=(0,o.useState)(),vt=ft[0],mt=ft[1],xt=(0,o.useState)(null),gt=xt[0],bt=xt[1],ht=(0,o.useState)(),yt=ht[0],Ut=ht[1],St=(0,o.useState)([]),jt=St[0],It=St[1],Pt=(0,o.useState)([]),Dt=Pt[0],Ot=Pt[1],Zt=(0,o.useState)([]),wt=Zt[0],Ct=Zt[1],Mt=(0,o.useState)(!1),kt=Mt[0],At=Mt[1],Gt=(0,o.useState)(!1),zt=Gt[0],Bt=Gt[1],Tt=(0,o.useState)(!1),Ft=Tt[0],Nt=Tt[1],Lt=(0,o.useState)(0),Et=Lt[0],Vt=Lt[1],Wt={serverName:{defaults:{onSuccess:function(){ne(void 0)},value:Y},tests:[{onFailure:function(){ne({text:"The server name length must be 1 to 16 characters.",type:"warning"})},test:function(e){var t=e.value.length;return t>=1&&t<=16}},{onFailure:function(){ne({text:"The server name is expected to only contain alphanumeric, hyphen, or underscore characters.",type:"warning"})},test:function(e){var t=e.value;return/^[a-zA-Z0-9_-]+$/.test(t)}},{onFailure:function(){ne({text:"This server name already exists, please choose another name.",type:"warning"})},test:function(e){var t=e.value;return void 0===j[t]}}]},cpuCores:{defaults:{max:pe,min:1,onSuccess:function(){ke(void 0)},value:oe},tests:[{onFailure:function(){ke({text:"Non available.",type:"warning"})},test:se.X7},{onFailure:function(e){var t=e.displayMax,n=e.displayMin;ke({text:"The number of CPU cores is expected to be between ".concat(n," and ").concat(t,"."),type:"warning"})},test:se.SQ}]},memory:{defaults:{displayMax:"".concat(We," ").concat(Je),displayMin:he,max:Te,min:Ie,onSuccess:function(){Ee(void 0)},value:Ge},tests:[{onFailure:function(){Ee({text:"Non available.",type:"warning"})},test:se.X7},{onFailure:function(e){var t=e.displayMax,n=e.displayMin;Ee({text:"Memory is expected to be between ".concat(n," and ").concat(t,"."),type:"warning"})},test:se.SQ}]},installISO:{defaults:{onSuccess:function(){it(void 0)},value:tt},tests:[{test:se.HJ}]},anvil:{defaults:{onSuccess:function(){mt(void 0)},value:pt},tests:[{test:se.HJ}]},optimizeForOS:{defaults:{onSuccess:function(){Ut(void 0)},value:null===gt||void 0===gt?void 0:gt.key},tests:[{test:se.HJ}]}};Ye.inputSizeMessages.forEach((function(e,t){Wt["vd".concat(t,"Size")]={defaults:{displayMax:"".concat(Ye.inputMaxes[t]," ").concat(Ye.inputUnits[t]),displayMin:ye,max:Ye.maxes[t],min:Pe,onSuccess:function(){Ye.inputSizeMessages[t]=void 0},value:Ye.sizes[t]},onFinishBatch:function(){Ke(fe({},Ye))},tests:[{onFailure:function(){Ye.inputSizeMessages[t]={text:"Non available.",type:"warning"}},test:se.X7},{onFailure:function(e){var n=e.displayMax,r=e.displayMin;Ye.inputSizeMessages[t]={text:"Virtual disk ".concat(t," size is expected to be between ").concat(r," and ").concat(n,"."),type:"warning"}},test:se.SQ}]},Wt["vd".concat(t,"StorageGroup")]={defaults:{onSuccess:function(){Ye.inputStorageGroupUUIDMessages[t]=void 0},value:Ye.inputStorageGroupUUIDs[t]},onFinishBatch:function(){Ke(fe({},Ye))},tests:[{test:se.HJ}]}}));var Rt,Qt,qt,_t,Ht=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.allAnvils,n=void 0===t?f:t,r=e.cpuCores,o=void 0===r?oe:r,i=e.fileUUIDs,a=void 0===i?[tt,st]:i,s=e.includeAnvilUUIDs,l=void 0===s?Ce([pt]):s,u=e.includeFileUUIDs,c=e.includeStorageGroupUUIDs,p=e.inputMemoryUnit,d=void 0===p?Je:p,v=e.memory,m=void 0===v?Ge:v,x=e.storageGroupUUIDMapToData,g=void 0===x?A:x,b=e.virtualDisks,h=void 0===b?Ye:b,y=we(n,g,o,m,h.sizes,h.inputStorageGroupUUIDs,a,{includeAnvilUUIDs:l,includeFileUUIDs:u,includeStorageGroupUUIDs:c}),U=y.anvilUUIDs,S=y.fileUUIDs,j=y.maxCPUCores,I=y.maxMemory,P=y.maxVirtualDiskSizes,D=y.storageGroupUUIDs;de(j),Fe(I);var O=[];h.maxes=P,h.maxes.forEach((function(e,t){w(e,{fromUnit:"B",onSuccess:{string:function(e,n){h.inputMaxes[t]=e,O[t]="".concat(e," ").concat(n)}},toUnit:h.inputUnits[t]})})),Ke(fe({},h)),It(U),Ot(S),Ct(D);var Z="";return w(I,{fromUnit:"B",onSuccess:{string:function(e,t){Re(e),Z="".concat(e," ").concat(t)}},toUnit:d}),{formattedMaxMemory:Z,formattedMaxVDSizes:O,maxCPUCores:j,maxMemory:I,maxVirtualDiskSizes:P}},Jt=(0,o.useCallback)(Ht,[]),Xt=function(){for(var e=arguments.length,t=new Array(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.cmValue,n=void 0===t?Ue:t,r=e.cmUnit,o=void 0===r?Je:r;ze(n);var i=Ht({inputMemoryUnit:o,memory:n}),a=i.formattedMaxMemory,s=i.maxMemory;Xt({inputs:{memory:{displayMax:a,max:s,value:n}}})},Yt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.value,n=void 0===t?qe:t,r=e.unit,o=void 0===r?Je:r;n!==qe&&_e(n),o!==Je&&Xe(o),C(n,o,(function(e){return $t({cmValue:e,cmUnit:o})}),(function(){return $t({cmUnit:o})}))},Kt=function(e){nt(e),Ht({fileUUIDs:[e,st]})},en=function(e){lt(e),Ht({fileUUIDs:[tt,e]})},tn=function(e){var t=Ce([e]);dt(e),Ht({includeAnvilUUIDs:t})};return(0,o.useEffect)((function(){d.Z.get("/anvil",{params:{anvilUUIDs:"all",isForProvisionServer:!0}}).then((function(e){var t=e.data,n=function(e){var t={},n=e.reduce((function(e,n){var o=n.anvilUUID,i=n.anvilName,s=n.anvilTotalMemory,l=n.anvilTotalAllocatedMemory,u=n.anvilTotalAvailableMemory,c=n.hosts,p=n.servers,d=n.storageGroups,f=n.files,v=d.reduce((function(t,n){var a=fe({},n,{anvilUUID:o,anvilName:i,storageGroupSize:BigInt(n.storageGroupSize),storageGroupFree:BigInt(n.storageGroupFree),humanizedStorageGroupFree:""});return w(n.storageGroupFree,{fromUnit:"B",onSuccess:{string:function(e,t){a.humanizedStorageGroupFree="".concat(e," ").concat(t)}},precision:0,toUnit:"ibyte"}),t.anvilStorageGroupUUIDs.push(n.storageGroupUUID),t.anvilStorageGroups.push(a),e.storageGroups.push(a),e.storageGroupSelectItems.push({displayValue:Ze({endAdornment:(0,r.jsx)(q.Ac,{inverted:!0,text:"~".concat(a.humanizedStorageGroupFree," free")}),mainLabel:n.storageGroupName,subLabel:i}),value:n.storageGroupUUID}),e.storageGroupUUIDMapToData[n.storageGroupUUID]=a,t}),{anvilStorageGroups:[],anvilStorageGroupUUIDs:[]}),m=v.anvilStorageGroups,x=v.anvilStorageGroupUUIDs,g=[];f.forEach((function(e){var n=e.fileUUID;g.push(n),t[n]=e}));var b=fe({},n,{anvilTotalMemory:BigInt(s),anvilTotalAllocatedMemory:BigInt(l),anvilTotalAvailableMemory:BigInt(u),humanizedAnvilTotalAvailableMemory:"",hosts:c.map((function(e){return fe({},e,{hostMemory:BigInt(e.hostMemory)})})),servers:p.map((function(t){var n=t.serverMemory,r=t.serverName,o=fe({},ve(t,["serverMemory","serverName"]),{serverMemory:BigInt(n),serverName:r});return e.serverNameMapToData[r]=o,o})),storageGroupUUIDs:x,storageGroups:m,fileUUIDs:g});return w(u,{fromUnit:"B",onSuccess:{string:function(e,t){b.humanizedAnvilTotalAvailableMemory="".concat(e," ").concat(t)}},precision:0,toUnit:"ibyte"}),e.anvils.push(b),e.anvilSelectItems.push({displayValue:Ze({endAdornment:(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",width:"8rem"},children:[(0,r.jsx)(q.Ac,{inverted:!0,text:"CPU: ".concat(b.anvilTotalCPUCores," cores")}),(0,r.jsx)(q.Ac,{inverted:!0,text:"Memory: ~".concat(b.humanizedAnvilTotalAvailableMemory)})]}),mainLabel:b.anvilName,subLabel:b.anvilDescription}),value:o}),e.anvilUUIDMapToData[o]=b,e}),{anvils:[],anvilSelectItems:[],anvilUUIDMapToData:{},files:[],fileSelectItems:[],fileUUIDMapToData:{},serverNameMapToData:{},storageGroups:[],storageGroupSelectItems:[],storageGroupUUIDMapToData:{}});return Object.values(t).forEach((function(e){n.files.push(e),n.fileSelectItems.push({displayValue:e.fileName,value:e.fileUUID}),n.fileUUIDMapToData[e.fileUUID]=e})),n}(t.anvils),o=n.anvils,i=n.anvilSelectItems,s=n.anvilUUIDMapToData,l=n.fileSelectItems,u=n.fileUUIDMapToData,c=n.serverNameMapToData,p=n.storageGroupSelectItems,d=n.storageGroupUUIDMapToData;v(o),g(s),U(u),I(c),z(d),F(i),W(l),X(p),Jt({allAnvils:o,storageGroupUUIDMapToData:d}),_(t.osList.map((function(e){var t=me(e.split(","),2),n=t[0];return{label:t[1],key:n}}))),At(!0)}))}),[Jt]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.Z,{fullWidth:!0,maxWidth:"sm",open:t,PaperComponent:L.s_,PaperProps:{sx:{overflow:"visible"}},children:[(0,r.jsxs)(L.V9,{children:[(0,r.jsx)(q.z,{text:"Provision a Server"}),(0,r.jsx)(M.Z,{onClick:n,sx:{backgroundColor:p.hM,color:p.lD,"&:hover":{backgroundColor:p.hM}},children:(0,r.jsx)(u.Z,{})})]}),kt?(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",maxHeight:"50vh",overflowY:"scroll",paddingTop:".6em","& > :not(:first-child)":{marginTop:"1em"}},children:[(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(y.Z,{id:"ps-server-name",label:"Server name",inputProps:{onChange:function(e){var t=e.target.value;K(t),Xt({inputs:{serverName:{value:t}}})},value:Y},inputLabelProps:{isNotifyRequired:0===Y.length},messageBoxProps:te})}),(Rt="ps-cpu-cores",Qt="CPU cores",qt=oe,_t={messageBoxProps:Me,sliderProps:{onChange:function(e){var t=e;if(t!==oe){le(t);var n=Ht({cpuCores:t}).maxCPUCores;Xt({inputs:{cpuCores:{max:n,value:t}}})}},max:pe,min:1}},(0,r.jsx)(ie,fe({isAllowTextInput:!0,label:Qt,labelId:"".concat(Rt,"-label"),value:qt},_t))),(0,r.jsx)(N,{id:"ps-memory",label:"Memory",messageBoxProps:Le,inputWithLabelProps:{inputProps:{endAdornment:Oe("".concat(We," ").concat(Je),{onButtonClick:function(){_e(We),$t({cmValue:Te})}}),onChange:function(e){var t=e.target.value;Yt({value:t})},type:"number",value:qe},inputLabelProps:{isNotifyRequired:Ge===Ue}},selectItems:Se,selectWithLabelProps:{selectProps:{onChange:function(e){var t=e.target.value;Yt({unit:t})},value:Je}}}),Ye.stateIds.map((function(e,t){return function(e,t,n,o,i,s,l,u){var c=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return e[n][r]},p=function(r,o){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;e[r][i]=o,n(fe({},e))},d=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ue;p("sizes",n);var r=s({virtualDisks:e}),o=r.formattedMaxVDSizes,i=r.maxVirtualDiskSizes;u({inputs:ce({},"vd".concat(t,"Size"),{displayMax:"".concat(o[t]),max:i[t],value:n})})},f=function(e){var t=e.value,n=void 0===t?c("inputSizes"):t,r=e.unit,o=void 0===r?c("inputUnits"):r;n!==c("inputSizes")&&p("inputSizes",n),o!==c("inputUnits")&&p("inputUnits",o),C(n,o,(function(e){return d(e)}),(function(){return d()}))},v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:c("inputStorageGroupUUIDs");t!==c("inputStorageGroupUUIDs")&&p("inputStorageGroupUUIDs",t),s({virtualDisks:e})};return(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column","& > :not(:first-child)":{marginTop:"1em"}},children:[(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(N,{id:"ps-virtual-disk-size-".concat(t),label:"Virtual disk size",messageBoxProps:c("inputSizeMessages"),inputWithLabelProps:{inputProps:{endAdornment:Oe("".concat(c("inputMaxes")," ").concat(c("inputUnits")),{onButtonClick:function(){p("inputSizes",c("inputMaxes")),d(c("maxes"))}}),onChange:function(e){var t=e.target.value;f({value:t})},type:"number",value:c("inputSizes")},inputLabelProps:{isNotifyRequired:c("sizes")===Ue}},selectItems:Se,selectWithLabelProps:{selectProps:{onChange:function(e){var t=e.target.value;f({unit:t})},value:c("inputUnits")}}})}),(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"column"},children:(0,r.jsx)(G.Z,{id:"ps-storage-group-".concat(t),label:"Storage group",disableItem:function(e){return!(i.includes(e)&&c("sizes")<=l[e].storageGroupFree)},inputLabelProps:{isNotifyRequired:0===c("inputStorageGroupUUIDs").length},messageBoxProps:c("inputStorageGroupUUIDMessages"),selectItems:o,selectProps:{onChange:function(e){var t=e.target.value;v(t)},onClearIndicatorClick:function(){return v("")},renderValue:function(e){var t,n=null!==(t=l[e])&&void 0!==t?t:{},r=n.anvilName,o=void 0===r?"?":r,i=n.storageGroupName,a=void 0===i?"Unknown (".concat(e,")"):i;return"".concat(a," (").concat(o,")")},value:c("inputStorageGroupUUIDs")}})})]},"ps-virtual-disk-".concat(c("stateIds")))}(Ye,t,Ke,J,wt,Ht,A,Xt)})),(0,r.jsx)(G.Z,{disableItem:function(e){return e===st},hideItem:function(e){return!Dt.includes(e)},id:"ps-install-image",inputLabelProps:{isNotifyRequired:0===tt.length},label:"Install ISO",messageBoxProps:ot,selectItems:V,selectProps:{onChange:function(e){var t=e.target.value;Kt(t)},onClearIndicatorClick:function(){return Kt("")},value:tt}}),(0,r.jsx)(G.Z,{disableItem:function(e){return e===tt},hideItem:function(e){return!Dt.includes(e)},id:"ps-driver-image",label:"Driver ISO",messageBoxProps:ut,selectItems:V,selectProps:{onChange:function(e){var t=e.target.value;en(t)},onClearIndicatorClick:function(){return en("")},value:st}}),(0,r.jsx)(G.Z,{disableItem:function(e){return!jt.includes(e)},id:"ps-anvil",inputLabelProps:{isNotifyRequired:0===pt.length},label:"Anvil node pair",messageBoxProps:vt,selectItems:T,selectProps:{onChange:function(e){var t=e.target.value;tn(t)},onClearIndicatorClick:function(){return tn("")},renderValue:function(e){var t,n=(null!==(t=x[e])&&void 0!==t?t:{}).anvilName;return void 0===n?"Unknown ".concat(e):n},value:pt}}),(0,r.jsx)(P,{id:"ps-optimize-for-os",extendRenderInput:function(e){var t=e.inputLabelProps;(void 0===t?{}:t).isNotifyRequired=null===gt},isOptionEqualToValue:function(e,t){return e.key===t.key},label:"Optimize for OS",messageBoxProps:yt,noOptionsText:"No matching OS",onChange:function(e,t){bt(t)},openOnFocus:!0,options:Q,value:gt})]}):(0,r.jsx)(ae.Z,{}),(0,r.jsxs)(a.Z,{sx:{display:"flex",flexDirection:"column",marginTop:"1em","& > :not(:first-child)":{marginTop:"1em"}},children:[Et>0&&(0,r.jsx)(k.Z,{isAllowClose:!0,text:"Provision server job registered. You can provision another server, or exit; it won't affect the registered job."}),Ft?(0,r.jsx)(ae.Z,{mt:0}):(0,r.jsx)(a.Z,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",width:"100%"},children:(0,r.jsx)(O.Z,{disabled:!Xt({isIgnoreOnCallbacks:!0}),onClick:function(){Bt(!0)},sx:De,children:"Provision"})})]})]}),zt&&(0,r.jsx)(D.Z,{actionProceedText:"Provision",content:(0,r.jsxs)(s.ZP,{container:!0,columns:8,direction:"column",children:[(0,r.jsx)(s.ZP,{direction:"row",item:!0,xs:8,children:(0,r.jsxs)(q.Ac,{children:["Server ",(0,r.jsx)(q.Q0,{text:Y})," will be created on anvil node pair"," ",(0,r.jsx)(q.Q0,{text:x[pt].anvilName})," ","with the following properties:"]})}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(q.Ac,{text:"CPU"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(q.Ac,{children:[(0,r.jsx)(q.Q0,{text:oe})," core(s)"]})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(q.Ac,{children:[(0,r.jsx)(q.Q0,{text:pe})," core(s) available"]})})]}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(q.Ac,{text:"Memory"})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsx)(q.Q0,{text:"".concat(qe," ").concat(Je)})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(q.Ac,{children:[(0,r.jsx)(q.Q0,{text:"".concat(We," ").concat(Je)})," ","available"]})})]}),Ye.stateIds.map((function(e,t){var n=Ye.inputMaxes[t],o=Ye.inputSizes[t],i=Ye.inputUnits[t],a=A[Ye.inputStorageGroupUUIDs[t]].storageGroupName;return(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsxs)(q.Ac,{children:["Virtual disk ",(0,r.jsx)(q.Q0,{text:t})]})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(q.Ac,{children:[(0,r.jsx)(q.Q0,{text:"".concat(o," ").concat(i)})," on"," ",a]})}),(0,r.jsx)(s.ZP,{item:!0,xs:3,children:(0,r.jsxs)(q.Ac,{children:[(0,r.jsx)(q.Q0,{text:"".concat(n," ").concat(i)})," ","available"]})})]},"ps-virtual-disk-".concat(e,"-summary"))})),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(q.Ac,{text:"Install ISO"})}),(0,r.jsx)(s.ZP,{item:!0,xs:6,children:(0,r.jsx)(q.Q0,{text:h[tt].fileName})})]}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(q.Ac,{text:"Driver ISO"})}),(0,r.jsx)(s.ZP,{item:!0,xs:6,children:h[st]?(0,r.jsx)(q.Q0,{text:h[st].fileName}):(0,r.jsx)(q.Ac,{text:"none"})})]}),(0,r.jsxs)(s.ZP,{container:!0,direction:"row",item:!0,xs:8,children:[(0,r.jsx)(s.ZP,{item:!0,xs:2,children:(0,r.jsx)(q.Ac,{text:"Optimize for OS"})}),(0,r.jsx)(s.ZP,{item:!0,xs:6,children:(0,r.jsx)(q.Ac,{text:"".concat(null===gt||void 0===gt?void 0:gt.label)})})]})]}),dialogProps:{open:zt},onCancelAppend:function(){Bt(!1)},onProceedAppend:function(){var e={serverName:Y,cpuCores:oe,memory:Ge.toString(),virtualDisks:Ye.stateIds.map((function(e,t){return{storageSize:Ye.sizes[t].toString(),storageGroupUUID:Ye.inputStorageGroupUUIDs[t]}})),installISOFileUUID:tt,driverISOFileUUID:st,anvilUUID:pt,optimizeForOS:null===gt||void 0===gt?void 0:gt.key};Nt(!0),d.Z.post("/server",e).then((function(){Nt(!1),Vt(Et+1)})),Bt(!1)},proceedButtonProps:{sx:De},titleText:"Provision ".concat(Y,"?")})]})}},2879:function(e,t,n){var r=n(5893),o=n(1057),i=n(4799),a=n(5603),s=n(9558),l=n(6239),u=n(7021),c=n(3213),p=n(5537),d=n(7169);function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e){for(var t=1;t=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var x={onClearIndicatorClick:null},g=function(e){var t,n=e.onClearIndicatorClick,g=void 0===n?x.onClearIndicatorClick:n,b=m(e,["onClearIndicatorClick"]),h=b.children,y=b.sx,U=b.value,S=String(U).length>0&&g?(0,r.jsx)(o.Z,{position:"end",children:(0,r.jsx)(i.Z,{onClick:g,children:(0,r.jsx)(p.Z,{fontSize:"small"})})}):void 0,j=v((f(t={},"& .".concat(a.Z.icon),{color:d.s7}),f(t,"& .".concat(s.Z.root),{marginRight:".8em"}),f(t,"& .".concat(l.Z.root),{color:d.s7,visibility:"hidden"}),f(t,"&:hover .".concat(s.Z.root," .").concat(l.Z.root,",\n &.").concat(u.Z.focused," .").concat(s.Z.root," .").concat(l.Z.root),{visibility:"visible"}),t),y);return(0,r.jsx)(c.Z,v({endAdornment:S},b,{sx:j,children:h}))};g.defaultProps=x,t.Z=g},7783:function(e,t,n){var r=n(5893),o=n(3640),i=n(5603),a=n(8128),s=n(1363),l=n(4427),u=n(9),c=n(192),p=n(2879);function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){for(var t=1;t