GIF89a=( õ' 7IAXKgNgYvYx\%wh…hŽth%ˆs%—x¨}9®Œ©€&©‰%¶†(¹–.¹5·œD¹&Çš)ÇŸ5ǘ;Í£*È¡&Õ²)ׯ7×µ<Ñ»4ï°3ø‘HÖ§KͯT÷¨Yÿšqÿ»qÿÔFØ !ù ' !ÿ NETSCAPE2.0 , =( þÀ“pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§gª«ªE¯°¨¬ª±²Œ¹º¹E¾­”´ÂB¶¯ §Åȸ»ÑD¾¿Á•ÄÅ®° ÝH¾ÒLÀÆDÙ«D¶BÝïðÀ¾DÑÑÔTÌÍíH òGö¨A RÎڐ |¥ ٭&ºìE8œ¹kGÔAÞpx­a¶­ã R2XB®åE8I€Õ6Xî:vT)äžþÀq¦è³¥ì仕F~%xñ  4#ZÔ‰O|-4Bs‘X:= QÉ œš lºÒyXJŠGȦ|s hÏíK–3l7·B|¥$'7Jީܪ‰‡àá”Dæn=Pƒ ¤Òëí‰`䌨ljóá¯Éüv>á–Á¼5 ½.69ûϸd«­ºÀûnlv©‹ªîf{¬ÜãPbŸ  l5‘ޝpß ´ ˜3aÅùäI«O’ý·‘áÞ‡˜¾Æ‚ÙÏiÇÿ‹Àƒ #öó)pâš Þ½ ‘Ý{ó)vmÞü%D~ 6f s}ŃƒDØW Eþ`‡þ À…L8xá†ç˜{)x`X/> Ì}mø‚–RØ‘*|`D=‚Ø_ ^ð5 !_…'aä“OÚ—7âcð`D”Cx`ÝÂ¥ä‹éY¹—F¼¤¥Š?¡Õ™ n@`} lď’ÄÉ@4>ñd œ à‘vÒxNÃ×™@žd=ˆgsžG±æ ´²æud &p8Qñ)ˆ«lXD©øÜéAžHìySun jª×k*D¤LH] †¦§C™Jä–´Xb~ʪwStŽ6K,°£qÁœ:9ت:¨þªl¨@¡`‚ûÚ ».Û¬¯t‹ÆSÉ[:°=Š‹„‘Nåû”Ìî{¿ÂA ‡Rà›ÀÙ6úë°Ÿð0Ä_ ½;ÃϱîÉì^ÇÛÇ#Ëë¼ôº!±Ä˜íUîÅÇ;0L1óÁµö«p% AÀºU̬ݵ¼á%霼€‡¯Á~`ÏG¯»À× ­²± =4ªnpð3¾¤³¯­ü¾¦îuÙuµÙ®|%2ÊIÿür¦#0·ÔJ``8È@S@5ê¢ ö×Þ^`8EÜ]ý.뜃Âç 7 ú ȉÞj œ½Dç zý¸iþœÑÙûÄë!ˆÞÀl§Ïw‹*DçI€nEX¯¬¼ &A¬Go¼QföõFç°¯;é¦÷îŽêJ°îúôF5¡ÌQ|îúöXªæ»TÁÏyñêï]ê² o óÎC=öõ›ÒÓPB@ D×½œä(>èCÂxŽ`±«Ÿ–JЀ»Û á¤±p+eE0`ëŽ`A Ú/NE€Ø†À9‚@¤à H½7”à‡%B‰`Àl*ƒó‘–‡8 2ñ%¸ —€:Ù1Á‰E¸àux%nP1ð!‘ðC)¾P81lÑɸF#ˆ€{´âé°ÈB„0>±û °b¡Š´±O‚3È–Ù()yRpbµ¨E.Z‘D8ÊH@% òŒx+%Ù˜Æcü »¸˜fõ¬b·d`Fê™8èXH"ÉÈ-±|1Ô6iI, 2““¬$+](A*jÐ QTÂo‰.ÛU슬Œã„Ž`¯SN¡–¶Äåyše¯ª’­¬‚´b¦Éož œ)åyâ@Ì®3 ÎtT̉°&Ø+žLÀf"Ø-|žçÔ>‡Ðv¦Ðžì\‚ Q1)Ž@Žh#aP72”ˆ™¨$‚ !ù " , =( …7IAXG]KgNgYvYxR"k\%w]'}hŽth%ˆg+ˆs%—r.—m3šx3˜x¨}9®€&©€+¨‡7§‰%¶†(¹–.¹œD¹&ǘ;Í•&ײ)×»4ïÌ6ò§KÍ þ@‘pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g «¬ E ±± ¨­¶°ººE Á´”·®C¬²§Ç¶Œ»ÓDÃÕƷ¯Ê±H½ºM×ÁGÚ¬D¶BËÁ½î½DÓôTÏÛßîG»ôõC×CÌ l&âž:'òtU³6ɹ#·Ø)€'Ü.6±&ëÍÈ» K(8p0N?!æ2"ÛˆNIJX>R¼ÐO‚M '¡¨2¸*Ÿþ>#n↠å@‚<[:¡Iïf’ ¤TÚ˘CdbÜÙ“[«ŽEú5MBo¤×@€`@„€Êt W-3 ¶Ÿ¡BíêäjIÝ…Eò9[T…$íêﯧ„…•s»Óȳ¹€ÅÚdc®UUρ#±Ùïldj?´í¼²`\ŽÁðÞu|3'ÖŒ]ë6 ¶S#²‡˜FKLÈ *N E´‘áäŠ$˜›eÄYD„ºq«.è촁ƒs \-ÔjA 9²õ÷å- üúM[Âx(ís÷ì®x€|í¡Ù’p¦‚ ŽkÛTÇDpE@WÜ ²Ç]kŠ1¨ þ€·Yb ÓÁ‰l°*n0 ç™—žzBdОu¾7ĉBl€â‰-ºx~|UåU‰  h*Hœ|e"#"?vpÄiŠe6^ˆ„+qâŠm8 #VÇá ‘å–ÄV„œ|Аè•m"сœn|@›U¶ÆÎž—Špb¥G¨ED”€±Úê2FÌIç? >Éxå Œ± ¡¤„%‘žjŸ‘ꄯ<Ìaà9ijÐ2˜D¦È&›†Z`‚å]wþ¼Â:ç6àB¤7eFJ|õÒ§Õ,¨äàFÇ®cS·Ê¶+B°,‘Þ˜ºNûãØ>PADÌHD¹æž«ÄÀnÌ¥}­#Ë’ë QÀÉSÌÂÇ2ÌXÀ{æk²lQÁ2«ÊðÀ¯w|2Í h‹ÄÂG€,m¾¶ë3ÐÙ6-´ÅE¬L°ÆIij*K½ÀÇqï`DwVÍQXœÚÔpeœ±¬Ñ q˜§Tœ½µƒ°Œìu Â<¶aØ*At¯lmEØ ü ôÛN[P1ÔÛ¦­±$ÜÆ@`ùåDpy¶yXvCAyåB`ŽD¶ 0QwG#¯ æš[^Äþ $ÀÓÝǦ{„L™[±úKÄgÌ;ï£S~¹ìGX.ôgoT.»åˆ°ùŸûù¡?1zö¦Ÿž:ÅgÁ|ìL¹ „®£œŠ‚à0œ]PÁ^p F<"•ç?!,ñ‡N4—…PÄ Á„ö¨Û:Tè@hÀ‹%táÿ:ø-žI<`þ‹p I….)^ 40D#p@ƒj4–؀:²‰1Øâr˜¼F2oW¼#Z†;$Q q” ‘ ÂK¦ñNl#29 !’F@¥Bh·ᏀL!—XFóLH‘Kh¤.«hE&JòG¨¥<™WN!€ÑÙÚˆY„@†>Œž19J" 2,/ &.GXB%ÌRÈ9B6¹W]’î×ÔW¥’IÎ$ ñ‹ÓŒE8YÆ ¼³™ñA5“à®Q.aŸB€&Ø©³ JÁ—! ¦t)K%tœ-¦JF bòNMxLôþ)ÐR¸Ð™‘ èÝ6‘O!THÌ„HÛ ‰ !ù ) , =( …AXKgNgYvYxR"k\%wh…hŽh%ˆg+ˆs%—r.—x3˜x¨}9®€&©€+¨Œ,©‡7§‰%¶†(¹–.¹5·&Çš)ǘ;Í•&×£*Ȳ)ׯ7×»4ï°3øÌ6ò‘HÖ§KÍ»Hó¯T÷¨Yÿ»qÿÇhÿ þÀ”pH,È¤rÉl:ŸÐ¨tJ­Z¯Ø¬vËíz¿à°xL.›Ïè´zÍn»ßð¸|N¯Ûïø¼~Ïïûÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§g ª« E$±²¨ª­ · °²½$E$ÂÕ««D· Í ¿¦Ç¶¸ÌŒ¾³CÃÅÆ E ééH½MÛÂGâªD­ çBêêϾD²ÒaÀà€Š1r­ðÓ¤ ÔožzU!L˜C'¾yW½UGtäÇïÙllê0×àÂuGþ)AÀs[þ·xì ÁxO%ƒûX2ó—  P£n›R/¡ÑšHše+êDm?# —‘Ç£6¡8íJ¡ŸâDiäªM¥Ö„ôj“¬¹£5oQ7°- <‡ *´lãÓŒ2r/a!l)dÈ A™ÈE¢ôÔ͆…ð ;Ö˜c ¡%ß‚’Ùˆâ¸b½—pe~C"BíëÚHïeF2§æŠ8qb t_`urŠeü wÅu3êæPv§h•"ß`íÍxçLĹÜÖ3á  ~Öº“®›¸ÏMDfJÙ °„ÛµáWõ%§œ‚à©–‚X ÓØ)@®Ñ›Eþ´wëuÅSxb8y\mÖzœ¥§ZbºE—ÂLªÌw!y(>¡™wú=Ç|ÅÝs¢d €CÁW)HÜcC$€L Ä7„r.á\{)@ð` @ äXÈ$PD” `šaG:§æˆOˆ72EÐamn]ù"ŒcÊxÑŒ° &dR8`g«iÙŸLR!¦P …d’ä¡“¦ðÎTƒ¦ià|À _ ¥ Qi#¦Šg›Æ ›noMµ ›V ã£)p ç£ÎW…š=Âeªk§†j„ ´®1ß²sÉxéW«jšl|0¯B0Û, \jÛ´›6±¬¶C ÛíWþï|ëÙ‹¸ñzĸV {ì;Ýñn¼òVˆm³I¼³.Ðã¤PN¥ ²µ¼„µCã+¹ÍByî£Ñ¾HŸ›ëê 7ìYÆFTk¨SaoaY$Dµœìï¿Ã29RÈkt Çïfñ ÇÒ:ÀÐSp¹3ÇI¨â¥DZÄ ü9Ïýögñ½­uÔ*3)O‘˜Ö[_hv ,àî×Et Ÿé¶BH€ Õ[ü±64M@ÔSÌM7dÐl5-ÄÙU܍´©zߌ3Ô€3ž„ „ ¶ÛPô½5×g› êÚ˜kN„Ý…0Îj4€Ìë°“#{þÕ3S2çKÜ'ợlø¼Ú2K{° {Û¶?žm𸧠ËI¼nEò='êüóºè^üæÃ_Û=°óž‚ì#Oý¿Í'¡½áo..ÏYìnüñCœO±Áa¿¢Kô½o,üÄËbö²çºíï{ËC Ú— "”Ï{ËK ÍÒw„õ±Oz dÕ¨à:$ ƒô—«v»] A#ð «€¿šéz)Rx׿ˆ¥‚d``èw-îyÏf×K!ð€þ­Ð|ìPľ„=Ì`ý(f” 'Pa ¥ÐBJa%Ðâf§„%Š¡}FàáÝ×6>ÉäŠG"éŽè=ø!oа^FP¼Ø©Q„ÀCÙÁ`(Ž\ÄÝ® ©Â$<n@dÄ E#ììUÒI! ‚#lù‹`k¦ÐÇ'Rró’ZýNBÈMF Í[¤+‹ðɈ-áwj¨¥þ8¾rá ,VÂh„"|½œ=×G_¦Ñ™EØ 0i*%̲˜Æda0mV‚k¾)›;„&6 p>ÓjK “¦Ç# âDÂ:ûc?:R Ó¬fÞéI-Ì“•Ã<ä=™Ï7˜3œ¨˜c2ŒW ,ˆ”8(T™P‰F¡Jhç"‚ ; 403WebShell
403Webshell
Server IP : 143.110.188.43  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.57 (Ubuntu)
System : Linux Client-Droplet 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.2.10-2ubuntu2.2
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /snap/lxd/current/share/lxd-ui/assets/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /snap/lxd/current/share/lxd-ui/assets/NetworkDevicePanel-D9XqFCT2.js
import{j as e,d as a,L as vt,R as fe,B as Ut,W as He,ar as kt,S as Ae,r as E,J as mt,D as R,q as $,bo as Kt,w as qt,T as Gt,bp as bt,bq as Ht,br as zt,ap as Yt,o as xt,s as Xt,K as Qt,b as Wt,e as Be,f as ce,h as gt,t as Oe,a2 as Jt,bs as Zt,bt as Le,b7 as Me,bu as We,v as es,O as ts,P as ss,H as Je,bv as as,bw as ns,bx as Ze,a6 as is,be as os}from"./index-C5moRkRM.js";import{u as ls,P as cs}from"./PlacementGroupExplanationTooltip-CDsyUuy1.js";import{u as H,w as rs,x as ae,q as xe,y as ge,s as ds,t as Ue,z as Ce,I as us,A as hs,e as ps,j as ye,B as yt,C as jt,v as ke,D as re,o as et,E as vs,F as ms,G as bs}from"./devices-DziiOcJy.js";import{e as I}from"./FormMenuItem-C57SBRlg.js";import{n as xs,o as gs,q as ys,t as je,v as q,w as we,x as ue,r as js,y as tt,z as he,A as Ne,B as st}from"./instanceAndProfilePayloads-OWzzIEo8.js";import{A as Ns}from"./AutoExpandingTextArea-BtMcH1Et.js";import{E as fs}from"./ExplanationTooltip-AfbgOckm.js";import{a as Cs}from"./scroll-BSkJfxH1.js";import{P as pe}from"./ProfileRichChip-DiaW3-Ut.js";import{f as X,o as L}from"./FormFooterLayout-CeiFxYRr.js";import{a as ws,b as Is,c as Ss,h as at,d as nt}from"./userKeys-DCvuKatN.js";import{a as B,b as Y,c as Rs}from"./options-DGWNjuoa.js";import{g as V,a as D,b as _s,c as Nt,C as k,d as Ds,e as ft,f as Ps,h as Fs,i as Vs,j as it}from"./ConfigurationTable-CbP4ksvx.js";import{S as ne}from"./ScrollableConfigurationTable-Co066DBV.js";import{B as Es,c as Ct}from"./YamlSwitch-BMEQ02g-.js";import{S as $s,a as Ts,g as As,R as wt,D as Bs,b as Os,v as Ls,h as ot,c as Ms}from"./StorageVolumeForm-CGooyDb1.js";import{i as Us}from"./snapshots-DbU7kFr9.js";import{R as It}from"./ResourceLink-CSSa-WON.js";import{R as ks}from"./ResourceLabel-5vQU6ndJ.js";import{l as Ks,M as W,B as Ke,C as J,D as qs}from"./DiskSizeSelector-T95OK-_Q.js";import{u as Gs}from"./useResources-5hLrDJjf.js";import{S as Hs}from"./StoragePoolSelector-B2DFQOGf.js";import{i as Q}from"./formChangeCount-DmPjPAAr.js";import{u as ze}from"./useConfigOptions-BxC1oiVQ.js";import{t as Ye,g as se,C as Ie,a as St}from"./ConfigFieldDescription-qFQi1Efr.js";import{S as Rt}from"./StoragePoolRichChip-DkAfThM9.js";import{r as zs,t as Ys}from"./storageVolume-D_kSLHXQ.js";import{u as Xs}from"./projects-BYXh-TO0.js";import{u as Qs,a as Ws}from"./useVolumes-B6TAUFFs.js";import{u as _t}from"./useStoragePools-Crzn42fh.js";import{c as Js}from"./storage-volumes-tZVWU3jH.js";import{B as de,F as Ve}from"./BackLink-CIO3yW-G.js";import{U as Zs,C as ea}from"./CustomIsoExplanationTooltip-D4c8NHJP.js";import{S as ve}from"./ScrollableForm-B4FKGNcE.js";import{h as Dt}from"./useNetworks-CeA2QAgG.js";import{u as Xe,a as ta,p as lt}from"./useEscCallback-CiLQokzn.js";import{E as sa}from"./ExpandableList-Z2D161-q.js";import{N as aa}from"./NetworkRichChip-C-nl3r3p.js";import{a as na,N as ia,b as oa}from"./NetworkDefaultACLSelector-CRhN8t5d.js";import{N as la}from"./NetworkSelector-C5MLjtvJ.js";import{a as ca}from"./useNetworkAcls-B32adf6l.js";const Pn=({value:t,setValue:s,project:n,ref:i,hasNoneOption:o=!1,isCreateInstance:c=!1,disabled:r=!1,profileNames:v=[]})=>{const{data:u=[]}=H(n),{data:l=[]}=ls(n),y=l.map(p=>({label:e.jsxs("div",{className:"label",children:[e.jsx("span",{className:"name u-truncate",title:p.name,children:p.name}),e.jsx("span",{className:"policy",children:p.config.policy}),e.jsx("span",{className:"rigor",children:p.config.rigor}),e.jsx("span",{className:"used_by",children:p.used_by.length})]}),text:p.name,selectedLabel:e.jsxs(e.Fragment,{children:[p.name," ",e.jsxs("span",{className:"u-text--muted",children:["(",p.config.policy,", ",p.config.rigor,")"]})]}),value:p.name})),b=()=>{let p=null;for(const g of v){const f=u.find(h=>h.name===g);f?.config["placement.group"]&&(p=e.jsxs(e.Fragment,{children:[f.config["placement.group"]," ",e.jsxs("span",{className:"u-text--muted",children:["(from profile ",e.jsx("code",{children:f.name}),")"]})]}))}return p};if(o){const p=b();y.push({label:e.jsx("div",{className:"label",children:e.jsx("span",{className:"name",children:p??"None"})}),selectedLabel:p??void 0,text:"None",value:""})}const N=p=>e.jsx(vt,{to:`${fe}/ui/project/${n}/placement-groups`,target:"_blank",children:Ut("placement group",p)}),m=()=>l.length===0?e.jsxs(e.Fragment,{children:[!c&&"No placement groups found for this project. ",e.jsxs(e.Fragment,{children:["Create your first ",N(1),"."]})]}):e.jsxs(e.Fragment,{children:[!c&&"Update does not move the instance. Changed placement policy applies only to future LXD scheduling events such as evacuation. ",e.jsxs(e.Fragment,{children:["Manage ",N(2)," for this project."]})]});return e.jsx(a.CustomSelect,{id:"placementGroup",label:e.jsx(cs,{children:"Placement group"}),wrapperClassName:"select-input",dropdownClassName:"placement-group-dropdown",selectRef:i,onChange:s,value:t??"",header:e.jsxs("div",{className:"header",children:[e.jsx("span",{className:"name",children:"Name"}),e.jsx("span",{className:"policy",children:"Policy"}),e.jsx("span",{className:"rigor",children:"Rigor"}),e.jsx("span",{className:"used_by",children:"Used by"})]}),help:m(),options:y,disabled:r||l.length===0})},ra=({primaryImage:t,onSelect:s,onUpload:n,onCancel:i,cancelButtonText:o="Cancel"})=>{const{project:c}=He(),r=c?.name??"",{data:v=[],isLoading:u}=Qs(r),l=[{content:"Name",sortKey:"name"},{content:"Storage pool",sortKey:"storagePool"},{content:"Upload date",sortKey:"uploadedAt"},{content:"Size",sortKey:"size"},{"aria-label":"Actions",className:"actions"}],y=v.map(b=>{const N=()=>{s(b,"virtual-machine")};return{key:b.fingerprint,className:"u-row",columns:[{content:e.jsx("div",{className:"u-truncate iso-name",title:b.aliases,children:b.aliases}),role:"rowheader","aria-label":"Name",onClick:N},{content:b.pool,role:"cell","aria-label":"Storage pool",onClick:N},{content:kt(new Date(b.created_at).toISOString()),role:"cell","aria-label":"Uploaded at",onClick:N},{content:b.volume?.config.size&&Ae(+b.volume.config.size),role:"cell","aria-label":"Size",onClick:N},{content:e.jsx(a.Button,{appearance:t?.name===b.aliases&&t?.pool===b.pool?"positive":"",onClick:m=>{m.stopPropagation(),N()},dense:!0,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:N}],sortData:{name:b.aliases.toLowerCase(),storagePool:b.pool?.toLowerCase(),size:+(b.volume?.config.size??0),uploadedAt:b.created_at}}});return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"iso-table",children:e.jsx(a.MainTable,{headers:l,rows:y,sortable:!0,className:"u-selectable-table-rows u-table-layout--auto",emptyStateMsg:u?e.jsx(a.Spinner,{className:"u-loader",text:"Loading images..."}):"No custom ISOs found"})}),e.jsxs("footer",{className:"p-modal__footer",children:[e.jsx(a.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:i,children:o}),e.jsx(a.Button,{appearance:y.length===0?"positive":"",onClick:n,type:"button",className:"iso-btn u-no-margin--bottom",children:e.jsx("span",{children:"Upload custom ISO"})})]})]})},te="selectIso",Ee="uploadIso",da=({onClose:t,onSelect:s,onCancel:n,cancelButtonText:i,backLinkText:o})=>{const[c,r]=E.useState(te),[v,u]=E.useState(null),l="Select custom ISO",y=()=>{switch(c){case te:return o?e.jsx(de,{title:l,onClick:n??t,linkText:o}):e.jsx(ea,{children:l});case Ee:return e.jsx(de,{title:"Upload custom ISO",onClick:()=>{r(te)},linkText:l});default:return""}};return e.jsxs(a.Modal,{close:t,title:y(),className:"custom-iso-modal",children:[c===te&&e.jsx(ra,{primaryImage:v,onSelect:s,onUpload:()=>{r(Ee)},onCancel:n??t,cancelButtonText:i}),c===Ee&&e.jsx(Zs,{onCancel:()=>{r(te)},onFinish:(b,N)=>{r(te),u({name:b,pool:N})}})]})},ua=({keyName:t,setSSHPublicKey:s})=>{const[n,i]=E.useState(),[o,c]=E.useState(),[r,v]=E.useState(!1),u=async()=>{s("");const m=await window.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-384"},!0,["sign","verify"]);i(m.privateKey),c(m.publicKey)};E.useEffect(()=>{u()},[]);const l=m=>{const p=new Uint8Array(m),g="nistp384",f="ecdsa-sha2-nistp384",h=x=>{const C=typeof x=="string"?new TextEncoder().encode(x):x,w=new Uint8Array(4);return new DataView(w.buffer).setUint32(0,C.length,!1),new Uint8Array([...w,...C])},d=new Uint8Array([...h(f),...h(g),...h(p)]),j=btoa(String.fromCharCode(...d));return`${f} ${j}`},y=(m,p)=>{const g=window.btoa(String.fromCharCode(...new Uint8Array(m))),f=g.match(/.{1,64}/g)?.join(`
`)??g;return`-----BEGIN ${p}-----
${f}
-----END ${p}-----`},b=(m,p)=>{const g=new Blob([m],{type:"application/x-pem-file"}),f=URL.createObjectURL(g),h=document.createElement("a");h.href=f,h.download=p,h.click(),URL.revokeObjectURL(f),v(!0)},N=async()=>{if(!n||!o)return;const m=await window.crypto.subtle.exportKey("pkcs8",n),p=y(m,"EC PRIVATE KEY");b(p,`lxd-${location.hostname}-${t}`);const g=await window.crypto.subtle.exportKey("raw",o),f=l(g);s(f)};return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"u-text--muted",children:r?"Your private key was downloaded successfully.":"Your key pair was generated successfully."}),e.jsx(a.Button,{disabled:!n,type:"button",onClick:N,children:"Download private key"})]})},ha=({initialName:t,onSelect:s,onClose:n})=>{const[i,o]=E.useState(t),[c,r]=E.useState("root"),[v,u]=E.useState("clipboard"),[l,y]=E.useState({github:"",launchpad:"",fileUpload:"",clipboard:"",generate:""}),b=()=>{switch(v){case"github":return`gh:${l.github}`;case"launchpad":return`lp:${l.launchpad}`;case"fileUpload":return l.fileUpload;case"clipboard":return l.clipboard;case"generate":return l.generate}},N=h=>{h.preventDefault(),h.stopPropagation();const d=b();s(i,c,d)},m=(h,d)=>e.jsx("button",{className:"p-segmented-control__button",role:"tab",type:"button","aria-selected":v===h?"true":"false","aria-controls":`${h}-tab`,id:h,onClick:()=>{u(h),h==="fileUpload"&&setTimeout(g,0)},children:d}),p=(h,d)=>h!==v?null:e.jsx("div",{role:"tabpanel",id:`${h}-tab`,"aria-labelledby":h,children:d}),g=()=>{document.getElementById("ssh-file-upload")?.click()},f=h=>{y({...l,generate:h})};return e.jsxs(a.Modal,{close:n,title:"Add SSH key",className:"ssh-key-add-modal",children:[e.jsxs(a.Form,{onSubmit:N,children:[e.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(a.Input,{label:"Name",type:"text",placeholder:"Enter name",value:i,onChange:h=>{o(h.target.value)}}),e.jsx(a.Input,{label:"Linux User",type:"text",placeholder:"ubuntu",value:c,onChange:h=>{r(h.target.value)}}),e.jsx(a.Label,{forId:"source",children:"Source"}),e.jsx("div",{className:"p-segmented-control",children:e.jsxs("div",{className:"p-segmented-control__list",id:"source",role:"tablist","aria-label":"Source",children:[m("clipboard","Clipboard"),m("generate","Generate key"),m("fileUpload","File upload"),m("github","Github"),m("launchpad","Launchpad")]})}),e.jsxs("div",{className:"source-input",children:[p("clipboard",e.jsx(Ns,{placeholder:"ecdsa-sha2-nistp384 ...",help:"Paste the contents of the public key file (.pub)",className:"u-break-all",autoFocus:!0,cols:50,value:l.clipboard,onChange:h=>{y({...l,clipboard:h.target.value})}})),p("generate",e.jsx(ua,{keyName:i,setSSHPublicKey:f})),p("fileUpload",e.jsxs("div",{className:"u-flex",children:[e.jsx(a.Button,{type:"button",onClick:g,children:"Choose file"}),e.jsx(a.Input,{id:"ssh-file-upload",className:"ssh-file-upload",type:"file",accept:".pub",autoFocus:!0,onChange:h=>{if(!h.target.files){y({...l,fileUpload:""});return}const d=h.target.files[0];if(!d){y({...l,fileUpload:""});return}const j=new FileReader;j.onload=x=>{const C=x.target?.result;C&&y({...l,fileUpload:C})},j.readAsText(d)}})]})),p("github",e.jsx(a.Input,{type:"text",placeholder:"Enter GitHub username",help:"Instance must have internet access to import SSH keys from GitHub.",autoFocus:!0,value:l.github,onChange:h=>{y({...l,github:h.target.value})}})),p("launchpad",e.jsx(a.Input,{type:"text",placeholder:"Enter launchpad username",help:"Instance must have internet access to import SSH keys from Launchpad.",autoFocus:!0,value:l.launchpad,onChange:h=>{y({...l,launchpad:h.target.value})}}))]})]}),e.jsxs("footer",{className:"p-modal__footer",id:"modal-footer",children:[e.jsx(a.Button,{appearance:"",className:"u-no-margin--bottom",onClick:n,children:"Cancel"}),e.jsx(a.Button,{appearance:"positive",className:"u-no-margin--bottom",onClick:N,disabled:i.length===0||c.length===0||l[v].length===0,children:"Add key"})]})]})},pa=({children:t})=>e.jsx(fs,{className:"explanation-tooltip-wrapper--inline",explanation:"Cloud init must be enabled on the instance to apply the keys. Additional keys get applied on instance creation or restart. SSH keys are not removed automatically.",docPath:"/reference/instance_options/#instance-cloud-init:cloud-init.ssh-keys.KEYNAME",docLabel:"Learn more about SSH keys",children:t}),va=(t,s)=>{const n=[];if(t.entityType==="instance"){const i=rs(t,s);for(const o of i)xs(o).forEach(r=>n.push({sshKey:r,source:o.name}))}return n},Fn=({formik:t,disabledReason:s})=>{const{project:n}=mt(),{data:i=[]}=H(n??""),{openPortal:o,closePortal:c,isOpen:r,Portal:v}=a.usePortal(),u=t.values.cloud_init_ssh_keys??[],l=va(t.values,i),y=()=>{const f=u.map(x=>x.id),h=l.map(x=>x.sshKey.id),d=new Set(f.concat(h)),j=t.values.entityType==="profile"?"profile":"ssh";for(let x=1;x<1e3;x++){const C=`${j}-key-${x}`;if(!d.has(C))return C}return`${j}-key-1`},b=(f,h,d)=>{t.setFieldValue("cloud_init_ssh_keys",[...u,{id:y(),name:f,user:h,fingerprint:d}]),c(),setTimeout(()=>{Cs("add-ssh-key-btn")},100)},N=[{content:"Name",className:"name"},{content:"User",className:"user"},{content:"Key",className:"key"},...l.length>0?[{content:"Profile",className:"profile"}]:[],{"aria-label":"Actions",className:"actions"}],m=l.map(f=>{const h=u.some(x=>x.id===f.sshKey.id),d=()=>{I(t),t.setFieldValue("cloud_init_ssh_keys",[...u,{id:f.sshKey.id,name:f.sshKey.id,user:"nouser",fingerprint:"nokey"}])},j=()=>{I(t),t.setFieldValue("cloud_init_ssh_keys",u.filter(x=>x.id!==f.sshKey.id))};return{key:`inherited-${f.sshKey.id}`,className:h?"u-text--muted u-text--line-through":"",columns:[{content:f.sshKey.name,role:"rowheader","aria-label":"Name",className:"name"},{content:f.sshKey.user,role:"cell","aria-label":"User",className:"user"},{content:f.sshKey.fingerprint,title:f.sshKey.fingerprint,role:"cell","aria-label":"Key",className:"key u-truncate"},...l.length>0?[{content:e.jsx(pe,{profileName:f.source,projectName:n??"",className:"force-truncate",disabled:h}),role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:h?e.jsxs(a.Button,{onClick:j,dense:!0,type:"button",hasIcon:!0,appearance:"base",disabled:!!s,title:s,children:[e.jsx(R,{icon:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(a.Button,{onClick:d,dense:!0,type:"button",hasIcon:!0,appearance:"base",disabled:!!s,title:s,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]}),role:"cell","aria-label":"Actions",className:"actions u-align--right"}]}}),p=u?.filter(f=>!l.some(h=>h.sshKey.id===f.id)).map(f=>{const h=()=>{I(t),t.setFieldValue("cloud_init_ssh_keys",u.filter(d=>d.id!==f.id))};return{key:`local-${f.id}`,columns:[{content:f.name,role:"cell","aria-label":"Name",className:"name"},{content:f.user,role:"cell","aria-label":"User",className:"user"},{content:f.fingerprint,title:f.fingerprint,role:"cell","aria-label":"Key",className:"key u-truncate"},...l.length>0?[{content:"",role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:e.jsxs(a.Button,{onClick:h,dense:!0,type:"button",hasIcon:!0,appearance:"base",disabled:!!s,title:s,children:[e.jsx(R,{icon:"delete"}),e.jsx("span",{children:"Delete"})]}),role:"cell","aria-label":"Actions",className:"actions u-align--right"}]}}),g=m.concat(p);return e.jsxs("div",{className:"ssh-key-form",children:[e.jsx("p",{className:"p-form__label u-sv-1",children:e.jsx(pa,{children:"SSH keys"})}),g.length>0&&e.jsx(a.MainTable,{id:"ssh-keys-table",headers:N,rows:g,sortable:!0,className:"ssh-key-table"}),e.jsxs(a.Button,{id:"add-ssh-key-btn",type:"button",onClick:f=>{I(t),o(f)},hasIcon:!0,disabled:!!s,title:s,children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"New SSH key"})]}),r&&e.jsx(v,{children:e.jsx(ha,{initialName:y(),onClose:c,onSelect:b})})]})},Vn=({formik:t,disabledReason:s})=>{const{project:n}=mt(),{data:i=[]}=H(n??""),o=t.values.user_keys??[],c=ws(o),r=Is(t.values,i),v=r.length>0,u=t.values.readOnly,l=x=>{I(t),t.setFieldValue("user_keys",x)},y=(x,C)=>{l(o.map((w,F)=>F===x?{...w,...C}:w))},b=x=>{l(o.filter((C,w)=>w!==x))},N=(x,C)=>{const w=o.findIndex(_=>_.sortKey===void 0||_.sortKey>=x),F=w<0?o.length:w;l(o.slice(0,F).concat({key:x,value:C,sortKey:x}).concat(o.slice(F))),X(`user-key-value-${F}`)},m=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"u-hide--large",children:"Profile"}),e.jsx("span",{className:"u-hide--small u-hide--medium",children:"Inherited from profile"})]}),p=[{content:"Key",className:"key"},{content:"Value",className:"value"},...v?[{content:m,className:"profile"}]:[],{"aria-label":"Actions",className:"actions"}],g=(x,C,w,F)=>e.jsxs(a.Button,{onClick:w,type:"button",hasIcon:!0,appearance:"base",disabled:!!s,title:s??x,"aria-label":`${x} ${F}`,className:"u-no-margin--bottom",children:[e.jsx(R,{icon:C}),e.jsx("span",{className:"u-hide--small u-hide--medium",children:x})]}),f=(x,C,w)=>{const F=o.findIndex(T=>T.key===x),_=F>=0;return{key:`inherited-${x}`,className:_?"u-text--muted u-text--line-through":"",columns:[{content:x,role:"rowheader","aria-label":"Key",className:"key u-truncate",title:x},{content:C,title:C,role:"cell","aria-label":"Value",className:"value u-truncate"},{content:e.jsx(pe,{profileName:w,projectName:n??"",className:"force-truncate",disabled:_}),role:"cell","aria-label":"Profile",className:"profile"},{content:_?g("Revert","restart",()=>{b(F)},x):g("Override","edit",()=>{N(x,C)},x),role:"cell","aria-label":"Actions",className:"actions"}]}},h=(x,C)=>({key:`local-${C}`,columns:[{content:x.key,role:"rowheader","aria-label":"Key",className:"key u-truncate",title:x.key},{content:x.value,title:x.value,role:"cell","aria-label":"Value",className:"value u-truncate"},...v?[{content:"",role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:g("Edit","edit",()=>{I(t),X(`user-key-value-${C}`)},x.key),role:"cell","aria-label":"Actions",className:"actions"}]}),d=(x,C)=>({key:`local-${C}`,columns:[{content:e.jsx(a.Input,{id:`user-key-name-${C}`,"aria-label":`User key ${C+1}`,placeholder:"Key",type:"text",value:x.key,error:c[C],caution:at(x)&&!nt(x)?"Key is required, this entry will not be saved":void 0,disabled:!!s,title:s,onChange:w=>{y(C,{key:w.target.value})}}),role:"rowheader","aria-label":"Key",className:"key"},{content:e.jsx(a.Input,{id:`user-key-value-${C}`,"aria-label":`User key value ${C+1}`,placeholder:"Value",type:"text",value:x.value,caution:nt(x)&&!at(x)?"Value is required, this entry will not be saved":void 0,disabled:!!s,title:s,onChange:w=>{y(C,{value:w.target.value})}}),role:"cell","aria-label":"Value",className:"value"},...v?[{content:"",role:"cell","aria-label":"Profile",className:"profile"}]:[],{content:g("Remove","delete",()=>{b(C)},`user key ${C+1}`),role:"cell","aria-label":"Actions",className:"actions"}]}),j=Ss(o,r).map(x=>x.type==="inherited"?f(x.userKey.key,x.userKey.value,x.source):u?h(x.userKey,x.index):d(x.userKey,x.index));return e.jsxs("div",{className:"user-keys-form",children:[e.jsxs("p",{className:"p-form__label u-sv-1",children:["User keys"," ",e.jsx(a.Tooltip,{message:"Custom user.* configuration keys, used to tag an instance.",children:e.jsx(R,{icon:"information"})})]}),j.length>0&&e.jsx(a.MainTable,{id:"user-keys-table",headers:p,rows:j,className:"user-keys-table"}),e.jsxs(a.Button,{id:"add-user-key-btn",type:"button",onClick:()=>{l(o.concat({key:"",value:""})),X(`user-key-name-${o.length}`)},hasIcon:!0,disabled:!!s,title:s,children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"Add user key"})]})]})},En=({formik:t,setSection:s})=>{const i=t.values.entityType==="instance"&&t.values.instanceType!=="container";return e.jsx(ne,{rows:[V({formik:t,label:"Protect deletion",name:"security_protection_delete",defaultValue:"",readOnlyRenderer:o=>L(o,B),children:e.jsx(a.Select,{options:B})}),V({formik:t,label:"Privileged (Containers only)",name:"security_privileged",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>L(o,Y),children:e.jsx(a.Select,{options:Y,disabled:i})}),V({formik:t,label:"Nesting (Containers only)",name:"security_nesting",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>L(o,Y),children:e.jsx(a.Select,{options:Y,disabled:i})}),V({formik:t,label:"Protect UID/GID shift (Containers only)",name:"security_protection_shift",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>L(o,B),children:e.jsx(a.Select,{options:B,disabled:i})}),V({formik:t,label:"Base host id (Containers only)",name:"security_idmap_base",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,children:e.jsx(a.Input,{placeholder:"Enter ID",type:"text",disabled:i,labelClassName:$({"is-disabled":i})})}),V({formik:t,label:"Idmap size (Containers only)",name:"security_idmap_size",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,children:e.jsx(a.Input,{placeholder:"Enter number",type:"number",min:0,disabled:i,labelClassName:$({"is-disabled":i})})}),V({formik:t,label:"Unique idmap (Containers only)",name:"security_idmap_isolated",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>L(o,B),children:e.jsx(a.Select,{options:B,disabled:i})}),V({formik:t,label:"Allow /dev/lxd in the instance (Containers only)",name:"security_devlxd",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>L(o,B),children:e.jsx(a.Select,{options:B,disabled:i})}),V({formik:t,label:"Make /1.0/images API available over /dev/lxd (Containers only)",name:"security_devlxd_images",defaultValue:"",disabled:i,disabledReason:i?"Only available for containers":void 0,readOnlyRenderer:o=>L(o,B),children:e.jsx(a.Select,{options:B,disabled:i})}),D({className:"u-text--muted",configuration:e.jsxs(e.Fragment,{children:[e.jsx("b",{children:"Enable secureboot (VMs only)"})," and"," ",e.jsx("b",{children:"Enable CSM (VMs only)"})]}),inherited:"",override:e.jsx(a.Button,{appearance:"link",type:"button",onClick:()=>{s(Es)},children:"See boot mode"})})]})},$n=({formik:t})=>{const{project:s}=He(),n=Us(s);return e.jsxs(e.Fragment,{children:[n&&e.jsx(a.Notification,{severity:"caution",title:`Snapshot creation has been disabled for instances in the project ${s?.name}`,children:e.jsx($s,{project:s})}),e.jsx(ne,{rows:[V({formik:t,label:"Snapshot name pattern",name:"snapshots_pattern",defaultValue:"",children:e.jsx(a.Input,{placeholder:"Enter name pattern",type:"text"})}),V({formik:t,label:"Expire after",name:"snapshots_expiry",defaultValue:"",children:e.jsx(a.Input,{placeholder:"Enter expiry expression",type:"text"})}),V({formik:t,label:"Snapshot stopped instances",name:"snapshots_schedule_stopped",defaultValue:"",readOnlyRenderer:i=>L(i,B),children:e.jsx(a.Select,{options:B})}),V({formik:t,label:"Schedule",name:"snapshots_schedule",defaultValue:"",children:e.jsx(Ts,{value:t.values.snapshots_schedule,setValue:i=>{t.setFieldValue("snapshots_schedule",i)}})})]})]})},ct=({config:t,setConfig:s})=>e.jsx("div",{className:"cloud-init-config",children:e.jsx(Ct,{yaml:t,setYaml:s,readOnly:!s,readOnlyMessage:"Read only editor for inherited value. Create an override to modify."})}),ma=({title:t,onClose:s,applyChanges:n,readOnly:i,readOnlyMessage:o,initialValue:c})=>{const[r,v]=E.useState(c??"");E.useEffect(()=>{v(c??"")},[c]);const u=()=>{i||n(r),s()};return e.jsx(a.Modal,{close:u,title:t,className:"cloud-init-full-editor-modal",closeOnOutsideClick:!1,children:e.jsx("div",{className:"cloud-init-modal-content",children:e.jsx(Ct,{yaml:r,setYaml:v,readOnly:i,readOnlyMessage:o,autoResize:!0})})})},ba={cloud_init_network_config:"cloud-init network config",cloud_init_user_data:"cloud-init user data",cloud_init_vendor_data:"cloud-init vendor data"},rt=({formik:t,project:s,name:n,initialValue:i,source:o,onApplyChanges:c,isReadOnly:r,className:v})=>{const{showModal:u,hideModal:l}=Kt(),y=qt(),b=Gt(),N=()=>{const g=ba[n],f=t.values.name||"",h=t.values.entityType,j=b.pathname.includes("/create")||!f,x=o&&o!==f;let C=null;return!j&&f?C=e.jsx(It,{type:h,value:f,to:`${fe}/ui/project/${encodeURIComponent(s)}/${h}/${encodeURIComponent(f)}`}):j&&f&&(C=e.jsx(ks,{type:h,value:f})),e.jsxs("div",{className:"u-no-margin",onClick:w=>{w.target.closest("a")&&(w.ctrlKey||w.metaKey||w.shiftKey||l())},children:[e.jsxs("h4",{className:"p-heading--4 u-no-margin--bottom",children:[r?"View":"Edit"," ",g]}),e.jsxs("p",{className:"p-heading--6 u-text--muted u-no-margin--top u-no-margin--bottom font-weight-normal",children:["For ",j&&"new ",h," ",C,y&&e.jsx("br",{}),x&&e.jsxs(e.Fragment,{children:[" inherited from ",o]})]})]})},m=g=>{I(t),t.setFieldValue(n,g),c?.()},p=g=>{u(e.jsx(ma,{title:N(),onClose:l,applyChanges:m,readOnly:r||!!t.values.editRestriction,readOnlyMessage:r?"Read only editor for inherited value. Create an override to modify.":t.values.editRestriction,initialValue:t.values[n]||i}),g)};return e.jsx(a.Button,{onClick:p,type:"button",appearance:"base",title:r?"Expand view":"Expand editor",hasIcon:!0,className:$("u-no-margin--bottom",v),children:e.jsx(R,{icon:"fullscreen",className:"full-screen-icon"})})},Tn=({formik:t,project:s})=>{const n=(i,o,c)=>{const[r,v]=E.useState(0),u=_s(t.values,o),l=c!==void 0,y=()=>{v(g=>g+1)},b=u?.source||"",m=b&&b!==t.values.name?ae(b):null,p=m?e.jsxs(e.Fragment,{children:["profile"," ",e.jsx(pe,{profileName:m,projectName:s,className:$({"u-text--line-through":l})})]}):b;return D({configuration:e.jsx("strong",{children:i}),inherited:e.jsxs("div",{className:$({"u-text--muted":l,"u-text--line-through":l}),children:[e.jsx("div",{className:"mono-font",children:e.jsx(ct,{config:u.value},`cloud-init-${o}-${u.value}`)}),u&&e.jsxs("div",{className:"u-d-flex u-margin-top--small",children:[e.jsxs("span",{className:"p-text--small u-text--muted",children:["From ",p]}),u.value&&e.jsx(rt,{formik:t,project:s,name:o,source:p,initialValue:u.value,isReadOnly:!0,className:"u-no-margin--top u-margin-left--small"})]})]}),override:l?e.jsxs(e.Fragment,{children:[e.jsx(ct,{config:c??"",setConfig:g=>{I(t),t.setFieldValue(o,g)}},`cloud-init-override-${o}-${r}`),e.jsx(a.Button,{onClick:()=>{I(t),t.setFieldValue(o,void 0)},type:"button",appearance:"base",title:t.values.editRestriction??"Clear override",disabled:!!t.values.editRestriction,hasIcon:!0,className:"u-no-margin--bottom u-no-margin--right",children:e.jsx(R,{icon:"close"})}),e.jsx(rt,{formik:t,project:s,name:o,initialValue:c??"",onApplyChanges:y,isReadOnly:!!t.values.editRestriction})]}):e.jsx(a.Button,{onClick:()=>{I(t),t.setFieldValue(o,`

`)},className:"u-no-margin--bottom",type:"button",appearance:"base",title:t.values.editRestriction??"Create override",hasIcon:!0,disabled:!!t.values.editRestriction,children:e.jsx(R,{icon:"edit"})})})};return e.jsx("div",{className:"cloud-init",children:e.jsx(ne,{configurationExtra:e.jsx(a.Tooltip,{message:"Applied only to images that have the cloud-init package installed.",className:"configuration-extra",children:e.jsx(R,{icon:"warning"})}),rows:[n("Network config","cloud_init_network_config",t.values.cloud_init_network_config),n("User data","cloud_init_user_data",t.values.cloud_init_user_data),n("Vendor data","cloud_init_vendor_data",t.values.cloud_init_vendor_data)]})})},Pt=(t,s)=>{const n=a.useNotify(),i=bt(s),{data:o,error:c,isLoading:r}=Gs(i),{project:v}=He(),u=t==="memory"?"limits.memory":"limits.cpu",l=v?.config[u]?Ks(v?.config[u]):void 0;if(c)return n.failure("Loading resources failed",c),null;if(r||!o)return null;const b=Ht(o).map(N=>t==="cpu"?N.cpu.total:N.memory.total);return As(b,i,v,l)},dt=({formik:t})=>{const s=Pt("memory",t);if(!s)return null;const{min:n,max:i,sourceType:o,sourceName:c}=s,r=n!==i;return e.jsxs(e.Fragment,{children:["Total memory:"," ",e.jsxs("b",{children:[Ae(n),n!==i&&` - ${Ae(i)}`,r&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{title:'The available memory depends on the cluster member that the instance will be created on.  To determine the available memory exactly, go to the "Main configuration" section, and from  the "Target" dropdown, select the "Cluster Member" option, then choose a member.',children:e.jsx(R,{icon:"information"})})]})]}),e.jsx("br",{}),c&&o&&e.jsx(wt,{source:c,sourceType:o})]})},qe=t=>{if(t==="")return;const s=Number(t);if(!isNaN(s))return s},xa=({formik:t,memoryLimit:s,setMemoryLimit:n})=>{if(!s)return null;const i=()=>Object.values(Ke).map(o=>({label:o,value:o}));return e.jsxs("div",{children:[e.jsxs("div",{className:"memory-limit-label",children:[e.jsx(a.RadioInput,{label:"absolute",checked:s.selectedType===W.FIXED,onChange:()=>{n({unit:Ke.GIB,selectedType:W.FIXED})}}),e.jsx(a.RadioInput,{label:"percentage",checked:s.selectedType===W.PERCENT,onChange:()=>{n({unit:"%",selectedType:W.PERCENT})}})]}),s.selectedType===W.PERCENT&&e.jsx(a.Input,{id:"limits_memory",name:"limits_memory",type:"number",min:"0",max:"100",step:"Any",placeholder:"Enter percentage",onChange:o=>{n({...s,value:qe(o.target.value)})},value:s.value??"",help:e.jsx(dt,{formik:t}),error:t.errors.limits_memory}),s.selectedType===W.FIXED&&e.jsxs("div",{className:"memory-limit-with-unit",children:[e.jsx(a.Input,{id:"limits_memory",name:"limits_memory",type:"number",min:"0",step:"Any",placeholder:"Enter value",onChange:o=>{n({...s,value:qe(o.target.value)})},value:s.value??"",help:e.jsx(dt,{formik:t}),error:t.errors.limits_memory}),e.jsx(a.Select,{id:"memUnitSelect",name:"memUnitSelect",label:"Select memory size unit",labelClassName:"u-off-screen",options:i(),onChange:o=>{n({...s,unit:o.target.value})},value:s.unit})]})]})},ga=({formik:t})=>{const s=Pt("cpu",t);if(!s)return null;const{min:n,max:i,sourceType:o,sourceName:c}=s,r=n!==i;return e.jsxs(e.Fragment,{children:["Total number of CPU cores:"," ",e.jsxs("b",{children:[n,n!==i&&` - ${i}`,r&&e.jsxs(e.Fragment,{children:[" ",e.jsx("span",{title:'The total number of CPU cores depends on the cluster member that the instance will be created on.      To determine the number of cores exactly, go to the "Main configuration" section, and from      the "Target" dropdown, select the "Cluster Member" option, then choose a member.',children:e.jsx(R,{icon:"information"})})]})]}),e.jsx("br",{}),o&&c&&e.jsx(wt,{source:c,sourceType:o})]})},ut=({help:t,formik:s,...n})=>{const i=e.jsx(ga,{formik:s});return e.jsx(a.Input,{...n,help:e.jsxs(e.Fragment,{children:[t,t&&i&&e.jsx("br",{}),i]})})},ya=({cpuLimit:t,setCpuLimit:s,help:n,formik:i})=>t?e.jsxs("div",{children:[e.jsxs("div",{className:"cpu-limit-label",children:[e.jsx(a.RadioInput,{label:"number",checked:t.selectedType===J.DYNAMIC,onChange:()=>{s({selectedType:J.DYNAMIC})}}),e.jsx(a.RadioInput,{label:"fixed",checked:t.selectedType===J.FIXED,onChange:()=>{s({selectedType:J.FIXED})}})]}),t.selectedType===J.DYNAMIC&&e.jsx(ut,{id:"limits_cpu",name:"limits_cpu",type:"number",min:"1",step:"1",placeholder:"Number of exposed cores",onChange:o=>{s({...t,dynamicValue:qe(o.target.value)})},value:t.dynamicValue??"",help:n,formik:i}),t.selectedType===J.FIXED&&e.jsx(ut,{id:"limits_cpu",name:"limits_cpu",type:"text",placeholder:"Comma-separated core numbers",onChange:o=>{s({...t,fixedValue:o.target.value})},value:t.fixedValue??"",help:n,formik:i})]}):null,ja={selectedType:J.DYNAMIC},Na={unit:Ke.GIB,selectedType:W.FIXED},An=({formik:t})=>{const n=t.values.entityType==="instance"&&t.values.instanceType!=="container";return e.jsx(ne,{rows:[V({formik:t,name:"limits_cpu",label:"Exposed CPU limit",defaultValue:ja,readOnlyRenderer:i=>gs(i),children:e.jsx(ya,{formik:t,cpuLimit:t.values.limits_cpu,setCpuLimit:i=>{t.setFieldValue("limits_cpu",i)}})}),V({formik:t,name:"limits_memory",label:"Memory limit",defaultValue:Na,readOnlyRenderer:i=>ys(i)??"",children:e.jsx(xa,{formik:t,memoryLimit:t.values.limits_memory,setMemoryLimit:i=>{t.setFieldValue("limits_memory",i)}})}),V({formik:t,name:"limits_memory_swap",label:"Memory swap (Containers only)",defaultValue:"",disabled:n,disabledReason:n?"Only available for containers":void 0,readOnlyRenderer:i=>L(i,Y),children:e.jsx(a.Select,{options:Y,disabled:n})}),V({formik:t,name:"limits_disk_priority",label:"Disk priority",defaultValue:"",children:e.jsx(a.Select,{options:zt})}),V({formik:t,name:"limits_processes",label:"Max number of processes (Containers only)",defaultValue:"",disabled:n,disabledReason:n?"Only available for containers":void 0,children:e.jsx(a.Input,{placeholder:"Enter number",min:1,type:"number",disabled:n})})]})},O=({id:t,label:s,inheritValue:n,inheritSource:i,readOnly:o,overrideValue:c,overrideForm:r,addOverride:v,clearOverride:u,isDeactivated:l,className:y,disabledReason:b,monoFont:N=!0})=>D({className:$("no-border-top",y),configuration:t?!o&&c?e.jsx(a.Label,{forId:t,children:s}):e.jsx("p",{className:"p-form__label u-no-margin--bottom u-no-padding--top",children:s}):e.jsx("div",{children:s}),inherited:n&&e.jsxs("div",{className:$({"u-text--muted":c||l,"u-text--line-through":c||l}),children:[e.jsx("div",{className:$({"mono-font":N}),children:N?e.jsx("b",{children:n}):n}),i&&e.jsxs("div",{className:"p-text--small u-text--muted u-no-margin--bottom",children:["From: ",i]})]}),override:o?c?e.jsx("div",{className:"mono-font",children:e.jsx("b",{children:c})}):"":c?e.jsxs("div",{className:"override-form",children:[e.jsx("div",{children:r}),u&&e.jsx("div",{children:e.jsx(a.Button,{onClick:u,type:"button",appearance:"base",title:b??"Clear override",hasIcon:!0,className:"u-no-margin--bottom",disabled:!!b,children:e.jsx(R,{icon:"close"})})})]}):v&&e.jsx(a.Button,{onClick:v,type:"button",appearance:"base",title:b??"Create override",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!b,children:e.jsx(R,{icon:"edit"})})}),me=({project:t,profile:s,hasLocalOverride:n,isDetached:i,className:o})=>O({className:o,label:"From profile",inheritValue:e.jsxs(e.Fragment,{children:[e.jsx(pe,{profileName:s,projectName:t,className:$({"u-text--line-through":n||i})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"with local override"})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"detached"})]})]}),readOnly:!0,monoFont:!1}),fa=(t,s)=>t.entityType!=="instance"?!1:Ca(t.devices)&&!wa(t,s),Ca=t=>!t.some(xe),wa=(t,s)=>{const[n]=Nt(t,s);return!!n},Bn=t=>!t.values.yaml&&t.values.devices.some((s,n)=>Ft(t,n)),Ft=(t,s)=>{const n=t.values.devices[s];return n.path===void 0||n.type!=="disk"?!1:!!(t.touched.devices&&t.touched.devices[s]&&t.touched.devices[s].path)&&n.path.length<1},On=t=>!t.values.yaml&&t.values.devices.some((s,n)=>Ia(t,n)),Ia=(t,s)=>{const n=t.values.devices[s];return n.name||n.type!=="nic"?!1:!!(t.touched.devices&&t.touched.devices[s]&&t.touched.devices[s].name)},Sa=({formik:t,pools:s,profiles:n,project:i})=>{const o=t.values.readOnly,c=t.values.devices.findIndex(xe),r=c!==-1,v=t.values.devices[c],u=t.values.entityType==="instance"&&!je(t),l=t.values.entityType==="instance"&&t.values.instanceType==="virtual-machine",y=l?"10GiB":"not specified",b=s.find(w=>w.name===v?.pool),N=b?.driver,[m,p]=Nt(t.values,n),g=bt(t),f=()=>{const w=[...t.values.devices];w.push({type:"disk",name:m?.name??"root",path:"/",pool:m?.pool??s[0]?.name}),t.setFieldValue("devices",w)},h=v?.name||(m?.name?m.name:"root"),d=Q(t,h),x=t.initialValues.devices.some(xe)&&!r,C=d||x;return e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"disk-device-root-configuration-table",rows:[D({className:"override-with-form disk-device-root-header-row",configuration:e.jsxs("div",{className:"disk-device-root-header u-flex u-gap--small",children:[e.jsx("h2",{className:"p-heading--4 u-no-margin--bottom",children:"Root storage"}),C&&e.jsx(a.Icon,{name:"status-in-progress-small",title:"This device has unsaved changes"})]}),inherited:"",override:e.jsx("div",{children:r?e.jsxs(a.Button,{onClick:()=>{I(t),q(c,t)},type:"button",appearance:"base",title:t.values.editRestriction??"Clear override",hasIcon:!0,className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,dense:!0,children:[e.jsx(R,{icon:"close"}),e.jsx("span",{children:"Clear"})]}):e.jsxs(a.Button,{onClick:()=>{I(t),f()},type:"button",appearance:"base",title:t.values.editRestriction??"Create override",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!t.values.editRestriction,children:[e.jsx(R,{icon:"edit"}),e.jsx("span",{children:"Edit"})]})})}),...p&&p!=="LXD"?[me({project:i,profile:ae(p),hasLocalOverride:r,className:"has-margin-left"})]:[],O({label:"Pool",id:"storage-pool-selector-disk",className:"override-with-form has-margin-left",inheritValue:m?.pool??"",readOnly:o,disabledReason:t.values.editRestriction,overrideValue:r&&e.jsxs(e.Fragment,{children:[v?.pool,t.values.entityType==="profile"&&e.jsx(a.Button,{onClick:()=>{I(t),X("storage-pool-selector")},type:"button",appearance:"base",title:t.values.editRestriction??"Edit",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!t.values.editRestriction,children:e.jsx(R,{icon:"edit"})})]}),overrideForm:e.jsx(e.Fragment,{children:e.jsx(Hs,{value:v?.pool??"",setValue:w=>{t.setFieldValue(`devices.${c}.pool`,w)},selectProps:{id:"storage-pool-selector-disk",className:u?"":"u-no-margin--bottom",disabled:u,help:u?"Use the migrate button in the header to change root storage.":""}})})}),O({label:"Size",id:"limits_disk",className:"override-with-form has-margin-left",inheritValue:m?.size??(m?y:""),readOnly:o,disabledReason:t.values.editRestriction,overrideValue:r&&e.jsxs(e.Fragment,{children:[v?.size??"unlimited",e.jsx(a.Button,{onClick:()=>{I(t),X("limits_disk")},type:"button",appearance:"base",title:t.values.editRestriction??"Edit",className:"u-no-margin--bottom",hasIcon:!0,disabled:!!t.values.editRestriction,children:e.jsx(R,{icon:"edit"})})]}),overrideForm:r&&e.jsxs(e.Fragment,{children:[e.jsx(qs,{value:v?.size??"GiB",setMemoryLimit:w=>{t.setFieldValue(`devices.${c}.size`,w)}}),e.jsxs("p",{className:"p-form-help-text",children:[e.jsx(Bs,{driver:N}),"If empty, root storage will"," ",l?"be limited at 10GiB.":"not have a size limit.",e.jsx("br",{}),e.jsx(Os,{pool:b,clusterMember:g})]})]})})]}),fa(t.values,n)&&e.jsx("div",{className:"is-error ",children:e.jsxs("p",{className:"p-form-validation__message",children:[e.jsx("strong",{children:"Error:"})," Missing root storage. Create an override, or add a profile with root storage."]})})]})},Ge=({onDetach:t,disabledReason:s,isInstanceCreation:n})=>n?e.jsxs(a.Button,{appearance:"base",type:"button",title:s??"Detach disk",className:"has-icon u-no-margin--bottom is-dense",onClick:t,disabled:!!s,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]}):e.jsxs(a.ConfirmationButton,{appearance:"base",type:"button",title:s??"Detach disk",className:"has-icon u-no-margin--bottom is-dense",confirmationModalProps:{title:"Confirm disk detachment",children:e.jsxs("p",{children:["Are you sure you want to clear this disk attachment?",e.jsx("br",{}),"This action may result in data loss if the disk is still mounted."]}),confirmButtonLabel:"Detach",onConfirm:t},shiftClickEnabled:!0,showShiftClickHint:!0,disabled:!!s,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]}),Z=({name:t,hasChanges:s,isDetached:n=!1})=>e.jsxs("div",{className:"device-header device-name u-gap--small u-flex",children:[e.jsx("b",{className:$("device-header-name",{"u-text--muted u-text--line-through":n,"has-changes":s}),children:t}),s&&e.jsx(a.Icon,{name:"status-in-progress-small",title:"This device has unsaved changes"})]}),Ra=({formik:t,inheritedDiskDevices:s,project:n})=>{const i=t.values.readOnly,{data:o}=ze(),c=o?.configs?.["device-disk"],r=c?Ye(c):[],v=(l,y)=>e.jsxs("div",{className:"configuration-label-with-help",children:[e.jsx("span",{children:l}),e.jsx("span",{className:"configuration-help",children:e.jsx(Ie,{description:St(r,y)})})]}),u=[];return s.forEach(l=>{const y=we(l.key,t),b=y!==-1;if(u.push(D({className:"override-with-form device-first-row",configuration:e.jsx(Z,{name:l.key,hasChanges:Q(t,l.key),isDetached:b}),inherited:null,override:b?e.jsx("div",{children:e.jsxs(a.Button,{appearance:"base",type:"button",title:t.values.editRestriction??"Reattach device",onClick:()=>{I(t),q(y,t)},className:"has-icon u-no-margin--bottom",disabled:!!t.values.editRestriction,children:[e.jsx(R,{icon:"connected"}),e.jsx("span",{children:"Reattach"})]})}):e.jsx("div",{children:e.jsx(Ge,{onDetach:()=>{I(t),ue(l.key,t)},disabledReason:t.values.editRestriction,isInstanceCreation:je(t)})})})),u.push(me({project:n,profile:ae(l.source),isDetached:b})),ge(l))u.push(O({label:v("Source","source"),inheritValue:l.disk.source,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction})),u.push(O({label:v("Pool","pool"),inheritValue:e.jsx(Rt,{poolName:l.disk.pool??"",projectName:n,className:$({"u-text--line-through":b})}),readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,monoFont:!1}));else{ds(l.disk)?u.push(O({label:"Host path",inheritValue:l.disk.source,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction})):u.push(O({label:"Pool / volume",inheritValue:e.jsxs(e.Fragment,{children:[l.disk.pool," / ",l.disk.source]}),readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction}));const N=t.values.entityType==="profile"||t.values.instanceType==="container",m=Ue(l.disk),p=!m||l.disk.path!==void 0,g=!m,f=N&&!m,h=l.disk.readonly??se(r,"readonly"),d=g?l.disk.recursive??se(r,"recursive"):void 0,j=l.disk.required??se(r,"required"),x=f?l.disk.shift??se(r,"shift"):void 0,C=h!==void 0,w=d!==void 0,F=j!==void 0,_=x!==void 0;p&&u.push(O({label:"Mount point",inheritValue:l.disk.path,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:!C&&!w&&!F&&!_?"device-last-row":void 0})),C&&u.push(O({label:v("Read-only","readonly"),inheritValue:h,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:!w&&!F&&!_?"device-last-row":void 0})),w&&u.push(O({label:v("Recursive","recursive"),inheritValue:d,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:!F&&!_?"device-last-row":void 0})),F&&u.push(O({label:v("Required","required"),inheritValue:j,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:_?void 0:"device-last-row"})),_&&u.push(O({label:v("Shift","shift"),inheritValue:x,readOnly:i,isDeactivated:b,disabledReason:t.values.editRestriction,className:"device-last-row"}))}}),s.length>0?e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited disk devices"}),e.jsx(k,{rows:u,className:"inherited-disk-device-configuration-table"})]}):null},_a=({project:t,primaryVolume:s,instanceLocation:n,onFinish:i,onCancel:o,onCreate:c,hasPrevStep:r})=>{const v=a.useNotify(),{canCreateStorageVolumes:u}=Xs(),{data:l}=Yt(t),{data:y=[],error:b,isLoading:N,isFetching:m}=Ws(t,{refetchOnMount:h=>h.state.isInvalidated});b&&v.failure("Loading storage volumes failed",b);const p=h=>{v.clear(),i(h)},g=[{content:"Name"},{content:"Pool"},...n?[{content:"Location"}]:[],{content:"Content type"},{content:"Used by"},{"aria-label":"Actions",className:"actions"}],f=m?[]:y.sort((h,d)=>h.created_at>d.created_at?-1:1).map(h=>{const d=!!h.location,j=n!==void 0&&d&&n!==h.location,x=j?`Instance location (${n}) does not match local volume location (${h.location}). `:void 0,C=()=>{x||p(h)};return{key:h.name,className:$("u-row",{"u-text--muted":j,"u-row--disabled":j}),columns:[{content:e.jsx("div",{className:"u-truncate iso-name",title:`Volume ${h.name}`,children:h.name}),role:"rowheader","aria-label":"Name",onClick:C},{content:h.pool,role:"cell","aria-label":"Storage pool",onClick:C},...n?[{content:h.location,role:"cell","aria-label":"Location",onClick:C}]:[],{content:zs(h),role:"cell","aria-label":"Content type",onClick:C},{content:h.used_by?.length,role:"cell","aria-label":"Used by",onClick:C},{content:e.jsx(a.Button,{onClick:()=>{p(h)},dense:!0,appearance:s?.name===h.name&&s?.type===h.type&&s?.pool==h.pool?"positive":"",title:j?x:`Select ${h.name}`,disabled:j,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:C}]}});return e.jsxs(e.Fragment,{children:[e.jsx(xt,{}),e.jsx(a.ScrollableTable,{dependencies:[y,f,v.notification],belowIds:["modal-footer"],tableId:"volume-select-table",children:e.jsx(a.MainTable,{id:"volume-select-table",headers:g,rows:f,sortable:!0,className:"u-selectable-table-rows u-table-layout--auto",emptyStateMsg:N||m?e.jsx(a.Spinner,{className:"u-loader",text:"Loading volumes..."}):"No custom volumes found"})}),!N&&e.jsxs("footer",{className:"p-modal__footer create-volume-modal-footer",id:"modal-footer",children:[e.jsx(a.Button,{className:"u-no-margin--bottom",onClick:o,appearance:"base",children:r?"Back":"Cancel"}),e.jsx(a.Button,{className:"u-no-margin--bottom",appearance:y.length===0?"positive":"",onClick:c,disabled:!u(l),title:u(l)?"":"You do not have permission to create storage volumes in this project",children:"Create volume"})]})]})},Da=({project:t,instanceLocation:s,onCancel:n,onFinish:i})=>{const o=a.useNotify(),c=Xt(),r=E.useState(null),v=Qt(),{data:u}=Wt(),{data:l=[]}=_t(),y=Be().shape({name:ce().test(...Ys(t,"custom",r)).required("This field is required")}),b=d=>{c.invalidateQueries({queryKey:[Oe.storage]}),c.invalidateQueries({queryKey:[Oe.customVolumes,t]}),o.success(`Storage volume ${d.name} created.`),i(d)},N=d=>{o.failure("Storage volume creation failed",d)},m=()=>{p.setSubmitting(!1)},p=gt({initialValues:{content_type:"filesystem",name:"",project:t,pool:"",clusterMember:s,size:"GiB",volumeType:"custom",readOnly:!1,isCreating:!0,isClusterMemberLocked:!0,entityType:"storageVolume"},validationSchema:y,onSubmit:d=>{const j=Ls(d,t),x=ot(d.pool,l,u)?s:void 0;Js(d.pool,t,j,x).then(C=>{v.set(C.metadata.id,()=>{b(j)},w=>{N(new Error(w))},m)}).catch(N)}}),g=!ot(p.values.pool,l,u)||s!=="any",f=g?void 0:"Please select a remote storage pool, or set a cluster member for the instance",h=()=>{Jt("volume-create-form","p-modal__footer",32,void 0,[])};return E.useEffect(h,[o.notification?.message]),a.useListener(window,h,"resize",!0),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"volume-create-form",children:e.jsx(Ms,{formik:p,poolError:f,pools:l,settings:u,clusterMembers:s?[{server_name:s}]:[]})}),e.jsxs("footer",{className:"p-modal__footer",children:[e.jsx(a.Button,{appearance:"base",className:"u-no-margin--bottom",onClick:n,children:"Back"}),e.jsx(a.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>{p.submitForm()},disabled:!p.isValid||p.isSubmitting||!g,loading:p.isSubmitting,children:"Create volume"})]})]})},$e="selectVolume",Te="createVolume",Vt=({formik:t,project:s,onFinish:n,onCancel:i,onClose:o,title:c})=>{const[r,v]=E.useState($e),[u,l]=E.useState(void 0),y=Zt(t),b=p=>{l(p),n(p)},N=()=>{v($e)};let m=c??"Choose custom volume";return r===Te&&(m=c?e.jsx(de,{title:"Create volume",onClick:N,linkText:"Attach custom volume"}):"Create volume"),e.jsxs(a.Modal,{className:"custom-volume-modal",close:o,title:m,children:[r===$e&&e.jsx(_a,{project:s,primaryVolume:u,instanceLocation:y,onFinish:n,onCancel:i,onCreate:()=>{v(Te)},hasPrevStep:!!c}),r===Te&&e.jsx(Da,{project:s,instanceLocation:y,onCancel:N,onFinish:b})]})},Pa=({formik:t,children:s,buttonProps:n,project:i,setValue:o})=>{const{openPortal:c,closePortal:r,isOpen:v,Portal:u}=a.usePortal(),l=y=>{o(y),r()};return e.jsxs(e.Fragment,{children:[e.jsx(a.Button,{onClick:c,type:"button",hasIcon:!0,...n,children:s}),v&&e.jsx(u,{children:e.jsx(Vt,{formik:t,project:i,onFinish:l,onCancel:r,onClose:r})})]})},Se=({name:t,index:s,setName:n,disableReason:i,formik:o})=>{const[c,r]=E.useState(!1);return e.jsx("div",{className:"rename-device device-name",children:c?e.jsx(a.Input,{autoFocus:!0,className:"u-no-margin--bottom",type:"text",value:t,onChange:v=>{n(v.target.value)},onBlur:()=>{r(!1)}}):e.jsxs(e.Fragment,{children:[e.jsx(a.Label,{forId:`device-${s}-name`,children:e.jsx(Z,{name:t,hasChanges:Q(o,t)})}),e.jsx(a.Button,{id:`device-${s}-name`,hasIcon:!0,dense:!0,onClick:()=>{r(!0)},appearance:"base",className:"u-no-margin--bottom","aria-label":"Rename device",disabled:!!i,title:i,children:e.jsx(R,{icon:"edit"})})]})})},Fa=({formik:t,onFinish:s,onCancel:n,onClose:i,title:o})=>{const[c,r]=E.useState(""),[v,u]=E.useState(""),l=E.useRef({source:!1,path:!1});E.useEffect(()=>{X("host-path")},[]);const y=()=>{s({type:"disk",source:c,path:v})},b=!!c&&!!v&&!t.isSubmitting,N=m=>{m.key==="Enter"&&(m.preventDefault(),l.current.source=!0,l.current.path=!0,b&&y())};return e.jsxs(a.Modal,{className:"host-path-device-modal",close:i,title:o,buttonRow:e.jsxs(e.Fragment,{children:[e.jsx(a.Button,{appearance:"base",className:"u-no-margin--bottom",type:"button",onClick:n,children:"Back"}),e.jsx(a.Button,{appearance:"positive",className:"u-no-margin--bottom",type:"button",loading:t.isSubmitting,disabled:!b,onClick:y,children:"Attach"})]}),children:[e.jsx(a.Input,{id:"host-path",value:c,onChange:m=>{l.current.source=!0,r(m.target.value)},onKeyDown:N,type:"text",label:"Host path",required:!0,error:!c&&l.current.source?"Host path is required":void 0,placeholder:"Enter full path (e.g. /home)"}),e.jsx(a.Input,{value:v,onChange:m=>{l.current.path=!0,u(m.target.value)},onKeyDown:N,type:"text",label:"Mount point",required:!0,error:!v&&l.current.path?"Mount point is required":void 0,placeholder:"Enter full path (e.g. /data)"})]})},Va=({close:t,formik:s,project:n,onFinish:i})=>{const[o,c]=E.useState("choose type"),r=()=>{c("choose type")},v=p=>{const g={type:"disk",pool:p.pool,source:p.name,path:p.content_type==="filesystem"?"":void 0};i(g)},u=p=>{const g=js(p);i(g)},l="Choose disk type",b=(()=>{switch(o){case"custom volume":return e.jsx(de,{title:"Attach custom volume",onClick:r,linkText:l});case"host path":return e.jsx(de,{title:"Mount host path",onClick:r,linkText:l});default:return l}})(),N=s.values.devices.some(ge),m=s.values.entityType==="profile"||s.values.entityType==="instance"&&s.values.instanceType==="virtual-machine";return e.jsxs(e.Fragment,{children:[o==="choose type"&&e.jsx(a.Modal,{close:t,className:"migrate-instance-modal",title:b,children:e.jsxs("div",{className:"choose-migration-type",children:[e.jsx(Ve,{icon:"add-logical-volume",title:"Attach custom volume",onClick:()=>{c("custom volume")}}),e.jsx(Ve,{icon:"mount",title:"Mount host path",onClick:()=>{c("host path")}}),m&&e.jsx(Ve,{icon:"iso",title:"Attach ISO",onClick:()=>{c("iso")},disabled:N,onHoverText:N?"Only one ISO volume can be attached at a time":void 0})]})}),o==="custom volume"&&e.jsx(Vt,{formik:s,project:n,onFinish:v,onCancel:r,onClose:t,title:b}),o==="host path"&&e.jsx(Fa,{formik:s,onFinish:i,onCancel:r,onClose:t,title:b}),o==="iso"&&e.jsx(da,{onClose:t,onSelect:u,onCancel:r,cancelButtonText:"Back",backLinkText:l})]})},Ea=({formik:t,children:s,buttonProps:n,project:i,setValue:o})=>{const{openPortal:c,closePortal:r,isOpen:v,Portal:u}=a.usePortal(),l=y=>{o(y),r()};return e.jsxs(e.Fragment,{children:[e.jsx(a.Button,{onClick:c,type:"button",hasIcon:!0,...n,disabled:!!t.values.editRestriction,title:t.values.editRestriction,children:s}),v&&e.jsx(u,{children:e.jsx(Va,{formik:t,project:i,onFinish:l,close:r})})]})},$a=({formik:t,project:s,profiles:n})=>{const i=t.values.readOnly,o=Ce(t.values,n),c=t.values.entityType==="profile",{data:r}=ze(),v=r?.configs?.["device-disk"],u=v?Ye(v):[],l=({id:d,label:j,key:x,required:C=!1})=>e.jsxs("div",{className:"configuration-label-with-help",children:[e.jsx(a.Label,{forId:d,required:C,children:j}),e.jsx("span",{className:"configuration-help",children:e.jsx(Ie,{description:St(u,x)})})]}),y=(d,j)=>d===us?j?hs:ps:he("disk-device",1,o),b=d=>{const j=[...t.values.devices],x={...d,name:y(d.type,c)};j.push(x),t.setFieldValue("devices",j);const C=`devices.${j.length-1}.path`;X(C)},N=(d,j,x)=>{t.setFieldValue(`devices.${x}.pool`,d.pool),t.setFieldValue(`devices.${x}.source`,d.name),d.content_type==="filesystem"&&j.path===void 0&&t.setFieldValue(`devices.${x}.path`,""),d.content_type==="block"&&t.setFieldValue(`devices.${x}.path`,void 0)},m=d=>e.jsx(a.Button,{appearance:"base",className:"u-no-margin--bottom",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Edit",onClick:()=>{I(t),X(d)},disabled:!!t.values.editRestriction,children:e.jsx(R,{icon:"edit"})}),p=(d,j,x)=>{const C=j??se(u,x);return e.jsxs("div",{className:"custom-disk-read-mode",children:[e.jsx("div",{className:"custom-disk-value",children:e.jsx("b",{children:L(C,B)||"-"})}),m(d)]})},g=d=>{const j=se(u,d),x=L(j,B),C=x?`LXD default (${x})`:"LXD default";return B.map((w,F)=>F===0?{...w,label:C}:w)},f=[];let h=0;for(let d=0;d<t.values.devices.length;d++){const j=t.values.devices[d];if(!(!(tt(j)||ge(j))||xe(j))){if(ge(j)){const C=!t.initialValues.devices.some(w=>w.name===j.name);f.push(D({className:"device-first-row",configuration:e.jsx(Z,{name:j.name,hasChanges:C}),inherited:null,override:e.jsx("div",{children:e.jsx(Ge,{onDetach:()=>{I(t),q(d,t)},disabledReason:t.values.editRestriction,isInstanceCreation:je(t)})})})),f.push(D({className:"no-border-top has-margin-left",configuration:e.jsx("div",{children:"Source"}),inherited:e.jsx("b",{className:"mono-font",children:j.source}),override:null})),f.push(D({className:"no-border-top has-margin-left",configuration:e.jsx("div",{children:"Pool"}),inherited:e.jsx(Rt,{poolName:j.pool,projectName:s}),override:null}))}else{if(!tt(j))continue;f.push(D({className:"custom-device-name device-first-row",configuration:e.jsx(Se,{name:j.name,index:d,setName:A=>{I(t),t.setFieldValue(`devices.${d}.name`,A)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsx("div",{children:e.jsx(Ge,{onDetach:()=>{I(t),q(d,t)},disabledReason:t.values.editRestriction,isInstanceCreation:je(t)})})}));const C=()=>D({className:$("no-border-top inherited-with-form"),configuration:e.jsx(a.Label,{forId:`devices.${d}.pool`,className:"u-text--muted",children:"Pool / volume"}),inherited:e.jsxs("div",{className:"custom-disk-volume-source",children:[e.jsx("div",{className:$("mono-font","u-truncate"),title:`${j.pool} / ${j.source??""}`,children:e.jsxs("b",{children:[j.pool," / ",j.source]})}),e.jsx(Pa,{formik:t,project:s,setValue:A=>{I(t),N(A,j,d)},buttonProps:{id:`devices.${d}.pool`,appearance:"base",className:"u-no-margin--bottom",title:t.values.editRestriction??"Select storage volume",dense:!0,disabled:!!t.values.editRestriction},children:e.jsx(R,{icon:"edit"})})]}),override:""}),w=()=>D({className:$("no-border-top inherited-with-form"),configuration:e.jsx(a.Label,{forId:`devices.${d}.source`,className:"u-text--muted",children:"Host path"}),inherited:i?e.jsxs("div",{className:"custom-disk-read-mode",children:[e.jsx("div",{className:"mono-font custom-disk-value u-truncate",children:e.jsx("b",{children:j.source})}),m(`devices.${d}.source`)]}):e.jsx(a.Input,{id:`devices.${d}.source`,name:`devices.${d}.source`,onBlur:t.handleBlur,onChange:A=>{t.setFieldValue(`devices.${d}.source`,A.target.value)},value:j.source,type:"text",placeholder:"Enter full host path (e.g. /data)",className:j.source?"u-no-margin--bottom":void 0,error:j.source?void 0:"Host path is required"}),override:""}),F=c||t.values.instanceType==="container",_=Ue(j),T=j.readonly==="true",K=j.recursive==="true",ie=!_||j.path!==void 0,Re=!_,_e=F&&!_,P=!_e;if(f.push(Ue(j)?C():w()),ie){const A=Ft(t,d);f.push(D({className:"no-border-top inherited-with-form",configuration:e.jsx(a.Label,{forId:`devices.${d}.path`,className:"u-text--muted",required:!0,children:"Mount point"}),inherited:i?e.jsxs("div",{className:"custom-disk-read-mode",children:[e.jsx("div",{className:"mono-font custom-disk-value",children:e.jsx("b",{children:j.path})}),m(`devices.${d}.path`)]}):e.jsx(a.Input,{id:`devices.${d}.path`,name:`devices.${d}.path`,onBlur:t.handleBlur,onChange:G=>{t.setFieldValue(`devices.${d}.path`,G.target.value)},value:j.path,type:"text",placeholder:"Enter full path (e.g. /data)",className:A?void 0:"u-no-margin--bottom",error:A?"Path is required":void 0}),override:""}))}f.push(D({className:"no-border-top inherited-with-form",configuration:l({id:`devices.${d}.readonly`,label:"Read-only",key:"readonly"}),inherited:i?p(`devices.${d}.readonly`,j.readonly,"readonly"):e.jsx(a.Select,{id:`devices.${d}.readonly`,name:`devices.${d}.readonly`,onBlur:t.handleBlur,onChange:A=>{I(t);const G=A.target.value||void 0;t.setFieldValue(`devices.${d}.readonly`,G),G==="true"&&t.setFieldValue(`devices.${d}.recursive`,void 0)},value:j.readonly??"",options:g("readonly"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction||K,title:t.values.editRestriction??(K?"Cannot set read-only with recursive bind mounts":void 0)}),override:""})),Re&&f.push(D({className:"no-border-top inherited-with-form",configuration:l({id:`devices.${d}.recursive`,label:"Recursive",key:"recursive"}),inherited:i?p(`devices.${d}.recursive`,j.recursive,"recursive"):e.jsx(a.Select,{id:`devices.${d}.recursive`,name:`devices.${d}.recursive`,onBlur:t.handleBlur,onChange:A=>{I(t);const G=A.target.value||void 0;t.setFieldValue(`devices.${d}.recursive`,G),G==="true"&&t.setFieldValue(`devices.${d}.readonly`,void 0)},value:j.recursive??"",options:g("recursive"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction||T,title:t.values.editRestriction??(T?"Recursive read-only bind mounts are not supported":void 0)}),override:""})),f.push(D({className:$("no-border-top inherited-with-form",{"device-last-row":P}),configuration:l({id:`devices.${d}.required`,label:"Required",key:"required"}),inherited:i?p(`devices.${d}.required`,j.required,"required"):e.jsx(a.Select,{id:`devices.${d}.required`,name:`devices.${d}.required`,onBlur:t.handleBlur,onChange:A=>{I(t),t.setFieldValue(`devices.${d}.required`,A.target.value||void 0)},value:j.required??"",options:g("required"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,title:t.values.editRestriction}),override:""})),_e&&f.push(D({className:"no-border-top inherited-with-form device-last-row",configuration:l({id:`devices.${d}.shift`,label:"Shift",key:"shift"}),inherited:i?p(`devices.${d}.shift`,j.shift,"shift"):e.jsx(a.Select,{id:`devices.${d}.shift`,name:`devices.${d}.shift`,onBlur:t.handleBlur,onChange:A=>{I(t),t.setFieldValue(`devices.${d}.shift`,A.target.value||void 0)},value:j.shift??"",options:g("shift"),className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,title:t.values.editRestriction}),override:""}))}h++}}return e.jsxs("div",{className:"custom-devices",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"p-heading--4",children:"Custom disk devices"}),e.jsx(k,{rows:f,className:"custom-disk-device-configuration-table"})]}),e.jsxs(Ea,{formik:t,project:s,setValue:d=>{I(t),b(d)},children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"Attach disk device"})]})]})},Ln=({formik:t,project:s})=>{const n=a.useNotify(),{data:i=[],isLoading:o,error:c}=H(s);c&&n.failure("Loading profiles failed",c);const{data:r=[],isLoading:v,error:u}=_t();if(u&&n.failure("Loading storage pools failed",u),o||v)return e.jsx(a.Spinner,{className:"u-loader",text:"Loading..."});const l=Ds(t.values,i);return e.jsx("div",{className:$("disk-device-form","device-form",{"disk-device-form--edit":!t.values.readOnly}),children:e.jsxs(ve,{children:[e.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsx(Sa,{formik:t,pools:r,profiles:i,project:s}),e.jsx(Ra,{formik:t,inheritedDiskDevices:l,project:s}),e.jsx($a,{formik:t,project:s,profiles:i})]})})},Et=({formik:t,device:s,inheritedDevice:n})=>{const i=Xe(),o=n&&!s,c=n&&s&&ye(s),r=n&&s&&yt(s),v=n&&s&&Ne(s),u=!n&&s,l=!!(u&&Ne(s)||o&&n?.network&&jt(n.network)||v),y=!!t.values.editRestriction,N=t.values.editRestriction?t.values.editRestriction:l?"Use the YAML configuration to edit a custom network":o||r?"Create override":c?"Edit override":"Edit network",m=()=>{o||r?i.openEditNetworkDevice(n.key):s&&ye(s)&&i.openEditNetworkDevice(s.name||"")},p=()=>{I(t),st({formik:t,deviceName:s?.name||""})},g=()=>{I(t),ue(n?.key||"",t)},f=()=>{I(t),st({formik:t,deviceName:s?.name||""})},h=()=>{const d=[];return(o||u||c||v)&&d.push(e.jsxs(a.Button,{onClick:m,type:"button",appearance:"base",title:N,className:"p-segmented-control__button p-action-button p-button",hasIcon:!0,dense:!0,disabled:y||l,children:[e.jsx(R,{icon:"edit"}),e.jsx("span",{children:"Edit"})]},"edit-button")),o&&d.push(e.jsxs(a.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:g,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Detach network",disabled:y,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]},"detach-inherited-button")),(c||v)&&d.push(e.jsxs(a.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:g,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Detach network",disabled:y,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]},"detach-overridden-button")),r&&d.push(e.jsxs(a.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:p,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Reattach inherited network",disabled:y,children:[e.jsx(R,{icon:"connected"}),e.jsx("span",{children:"Reattach"})]},"reattach-button")),u&&d.push(e.jsxs(a.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:f,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Detach network",disabled:y,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]},"detach-local-button")),(c||v)&&d.push(e.jsxs(a.Button,{className:"p-segmented-control__button p-action-button p-button",onClick:p,type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction||"Clear override",disabled:y,children:[e.jsx(R,{icon:"close"}),e.jsx("span",{children:"Clear"})]},"clear-override-button")),d};return e.jsx("div",{className:"network-device-actions p-segmented-control",children:e.jsx("div",{className:"p-segmented-control__list",children:h()})})},Ta=({network:t,device:s,family:n})=>{if(!t||!t.config)return null;const i=n==="IPv4"?"ipv4.address":"ipv6.address",o=t.config[i],c=s[i];return o!=="none"?c||"dynamic":null},$t=({project:t,managedNetworks:s,device:n,showIpAddresses:i,isDetached:o,hasChanges:c,actions:r,sourceProfile:v})=>{const u=[];if(!n)return u;if(u.push(D({className:"device-first-row",configuration:e.jsx(Z,{name:n.name||"",hasChanges:c,isDetached:o}),inherited:null,override:r})),v&&u.push(D({className:"no-border-top",configuration:e.jsx("div",{children:"From profile"}),inherited:v,override:null})),n.type==="custom-nic")return u.push(D({className:"no-border-top device-last-row",configuration:e.jsxs("div",{className:$({"u-text--line-through":o}),children:["custom network"," ",e.jsx(a.Tooltip,{message:"A custom network can be viewed and edited only from the YAML configuration",children:e.jsx(R,{icon:"information"})})]}),inherited:null,override:null})),u;const l=s.find(y=>y.name===n.network);if(l){u.push(D({className:"no-border-top",configuration:e.jsx("div",{children:"Network"}),inherited:e.jsx("div",{children:e.jsx(aa,{networkName:n.network,projectName:t||"default",className:$({"u-text--line-through":o})})}),override:null}));const y=Le(Me(l),ke(n));if(i){const N=["IPv4","IPv6"].map(m=>({family:m,ip:Ta({network:l,device:n,family:m})})).filter(m=>!!m.ip);N.forEach(({family:m,ip:p},g)=>{u.push(D({className:$("no-border-top",{"device-last-row":y.length===0&&g===N.length-1}),configuration:e.jsx("div",{children:m}),inherited:e.jsx("div",{children:e.jsx("b",{className:$("mono-font ip-address",{"u-text--line-through":o}),children:p})}),override:null}))})}if(y.length>0&&u.push(D({className:"no-border-top",configuration:e.jsx("div",{children:"Access control lists"}),inherited:e.jsx("div",{children:e.jsx(sa,{items:y.map(b=>e.jsx(It,{type:"network-acl",value:b,to:`${fe}/ui/project/${encodeURIComponent(t||"default")}/network-acl/${encodeURIComponent(b)}`,className:$("acl-chip",{"u-text--line-through":o})},b))})}),override:null})),y.length>0){const b=()=>({Egress:n["security.acls.default.egress.action"]??l.config["security.acls.default.egress.action"]??"",Ingress:n["security.acls.default.ingress.action"]??l.config["security.acls.default.ingress.action"]??""});u.push(D({className:$("no-border-top device-last-row acl-defaults",{"u-text--line-through":o}),configuration:e.jsx("div",{}),inherited:e.jsx("div",{children:e.jsx(na,{values:b()})}),override:null}))}}return u},Aa=({formik:t,inheritedNetworkDevices:s,project:n,managedNetworks:i})=>{if(s.length===0)return null;const o=s.flatMap(c=>{const r=t.values.devices.find(f=>f.name===c.key),v=r!==void 0,u=r&&yt(r),l=c&&r&&ye(r),y=c&&r&&Ne(r),N=r&&ye(r)||r&&Ne(r)?r:c.network?jt(c.network)?{name:c.key,type:"custom-nic",bare:c.network}:{...c.network,name:c.key}:null,m=r&&Q(t,c.key),g=t.initialValues.devices.find(f=>f.name===c.key)&&!r;return $t({project:n,managedNetworks:i,device:N,isDetached:!!u,hasChanges:m||g,showIpAddresses:t.values.entityType==="instance",sourceProfile:e.jsxs(e.Fragment,{children:[e.jsx(pe,{profileName:c.sourceProfile,projectName:n,className:$({"u-text--line-through":v})}),(l||y)&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"with local override"})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("i",{className:"u-text--muted p-text--small",children:"detached"})]})]}),actions:e.jsx(Et,{formik:t,device:r,inheritedDevice:c})})});return e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited network devices"}),e.jsx(k,{className:"inherited-network-device-configuration-table",rows:o})]})},Ba=({formik:t,inheritedNetworkDevices:s,project:n,managedNetworks:i})=>{const o=t.values.devices.filter(r=>{const v=r.type?.includes("nic")||r.type?.includes("custom-nic"),u=s.map(l=>l.key).includes(r.name);return v&&!u});if(o.length===0)return null;const c=o.flatMap(r=>{const v=r.name||"",u=r,l=s.find(y=>y.key===v);return $t({project:n,managedNetworks:i,device:u,hasChanges:Q(t,v),showIpAddresses:t.values.entityType==="instance",actions:u.type?.includes("nic")?e.jsx(Et,{formik:t,device:u,inheritedDevice:l}):null})});return e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Custom network devices"}),e.jsx(k,{className:"custom-network-device-configuration-table",rows:c})]})},Mn=({formik:t,project:s})=>{const n=a.useNotify(),i=Xe(),{data:o=[],isLoading:c,error:r}=H(s);r&&n.failure("Loading profiles failed",r);const{data:v=[],isLoading:u,error:l}=Dt(s);if(E.useEffect(()=>{l&&n.failure("Loading networks failed",l)},[l]),c||u)return e.jsx(a.Spinner,{className:"u-loader",text:"Loading..."});const y=v.filter(N=>N.managed),b=ft(t.values,o);return e.jsx("div",{className:"network-device-form device-form",children:e.jsxs(ve,{children:[e.jsx(Aa,{formik:t,inheritedNetworkDevices:b,project:s,managedNetworks:y}),e.jsx(Ba,{formik:t,inheritedNetworkDevices:b,project:s,managedNetworks:y}),e.jsxs(a.Button,{onClick:i.openCreateNetworkDevice,type:"button",hasIcon:!0,disabled:!!t.values.editRestriction,title:t.values.editRestriction,children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"Attach network"})]})]})})},Un=({formik:t})=>{const n=t.values.entityType==="instance"&&t.values.instanceType!=="virtual-machine";return e.jsx(ne,{rows:[V({formik:t,label:"Stateful migration (VMs only)",name:"migration_stateful",defaultValue:"",disabled:n,disabledReason:n?"Only available for virtual machines":void 0,readOnlyRenderer:i=>L(i,Y),children:e.jsx(a.Select,{options:Y,disabled:n})}),V({formik:t,label:"Cluster evacuation",name:"cluster_evacuate",defaultValue:"auto",readOnlyRenderer:i=>L(i,We),children:e.jsx(a.Select,{options:We})})]})},Oa=({onSelect:t,onClose:s})=>{const{canViewResources:n}=es(),{data:i,isLoading:o}=ts({queryKey:[Oe.resources],queryFn:async()=>ss(),enabled:n()}),c=[{content:"Vendor"},{content:"Driver"},{content:"PCI address"},{content:"ID"},{"aria-label":"Actions",className:"actions"}],r=o?[]:i?.gpu?.cards?.map(u=>{const l=()=>{t(u)};return{key:u.pci_address,className:"u-row",columns:[{content:u.vendor,role:"rowheader","aria-label":"Vendor",onClick:l},{content:e.jsxs(e.Fragment,{children:[u.driver," ",e.jsx("span",{className:"u-text--muted",children:u.driver_version})]}),role:"cell","aria-label":"Driver",onClick:l},{content:u.pci_address,role:"cell","aria-label":"PCI Address",onClick:l},{content:u.drm?.id??"-",role:"cell","aria-label":"ID",onClick:l},{content:e.jsx(a.Button,{onClick:l,dense:!0,"aria-label":`Select ${u.pci_address}`,children:"Select"}),role:"cell","aria-label":"Actions",className:"u-align--right",onClick:l}]}}),v=()=>n()?e.jsx(a.ScrollableTable,{dependencies:[i,r],belowIds:["modal-footer"],tableId:"gpu-select-table",children:e.jsx(a.MainTable,{id:"gpu-select-table",headers:c,rows:r,sortable:!0,className:"u-selectable-table-rows u-table-layout--auto",emptyStateMsg:o?e.jsx(a.Spinner,{className:"u-loader",text:"Loading GPUs..."}):"No GPUs found"})}):e.jsx(a.Notification,{severity:"caution",title:"Restricted permissions",children:"You do not have permission to view available GPUs on the server."});return e.jsxs(a.Modal,{close:s,title:"Select GPU",children:[v(),e.jsx("footer",{className:"p-modal__footer",id:"modal-footer",children:e.jsx(a.Button,{className:"u-no-margin--bottom",onClick:()=>{t({pci_address:""})},children:"Enter details manually"})})]})},La=({onSelect:t,disabledReason:s})=>{const{openPortal:n,closePortal:i,isOpen:o,Portal:c}=a.usePortal(),r=v=>{i(),t(v)};return e.jsxs(e.Fragment,{children:[e.jsxs(a.Button,{onClick:n,type:"button",hasIcon:!0,disabled:!!s,title:s,children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"Attach GPU"})]}),o&&e.jsx(c,{children:e.jsx(Oa,{onClose:i,onSelect:r})})]})},Ma=({device:t,onChange:s,disableReason:n})=>{const[i,o]=E.useState(t.pci?"pci":"id"),c=i==="pci",r=`device.${t.name}.${c?"pci":"id"}`;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"u-sv1",children:[e.jsx(a.RadioInput,{inline:!0,className:"margin-right--large",label:"ID",checked:!c,onClick:()=>{o("id")},disabled:!!n}),e.jsx(a.RadioInput,{inline:!0,label:"PCI",checked:c,onClick:()=>{o("pci")},disabled:!!n})]}),e.jsx(a.Input,{type:"text",label:c?"PCI Address":"ID",value:c?t.pci:t.id,onChange:v=>s?.(c?v.target.value:void 0,c?void 0:v.target.value),disabled:!!n},r)]})},kn=({formik:t,project:s})=>{const n=a.useNotify(),{data:i=[],isLoading:o,error:c}=H(s);c&&n.failure("Loading profiles failed",c);const r=Ps(t.values,i),v=Ce(t.values,i),u=N=>{const m=N.drm?.id?N.drm.id.toString():void 0,p=[...t.values.devices];p.push({type:"gpu",gputype:"physical",pci:N.pci_address,id:N.pci_address===void 0?m:void 0,name:he("gpu",1,v)}),t.setFieldValue("devices",p)},l=t.values.devices.some(N=>N.type==="gpu"),y=[];r.forEach(N=>{const m=we(N.key,t),p=m!==-1;y.push(D({className:"no-border-top override-with-form",configuration:e.jsx(Z,{name:N.key,hasChanges:Q(t,N.key),isDetached:p}),inherited:null,override:p?e.jsxs(a.Button,{appearance:"base",type:"button",title:"Reattach GPU",onClick:()=>{I(t),q(m,t)},className:"has-icon u-no-margin--bottom",children:[e.jsx(R,{icon:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(a.Button,{appearance:"base",type:"button",onClick:()=>{I(t),ue(N.key,t)},className:"has-icon u-no-margin--bottom",title:t.values.editRestriction??"Detach GPU",disabled:!!t.values.editRestriction,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]})})),y.push(me({project:s,profile:ae(N.source),isDetached:p})),Object.keys(N.gpu).forEach(g=>{g==="name"||g==="type"||y.push(O({label:re(g),inheritValue:N.gpu[g],readOnly:!1,isDeactivated:p}))})});const b=[];return t.values.devices.forEach((N,m)=>{if(N.type!=="gpu")return;const p=t.values.devices[m];b.push(D({className:"no-border-top custom-device-name",configuration:e.jsx(Se,{name:p.name,index:m,setName:g=>{I(t),t.setFieldValue(`devices.${m}.name`,g)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsxs(a.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{I(t),q(m,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Detach GPU",disabled:!!t.values.editRestriction,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]})})),Object.keys(p).forEach(g=>{g==="name"||g==="type"||g==="pci"||g==="id"||b.push(O({label:re(g),inheritValue:p[g],readOnly:!1}))}),b.push(O({label:"Identify by",inheritValue:e.jsx(Ma,{device:p,onChange:(g,f)=>{I(t),t.setFieldValue(`devices.${m}.pci`,g),t.setFieldValue(`devices.${m}.id`,f)},disableReason:t.values.editRestriction}),readOnly:!1}))}),o?e.jsx(a.Spinner,{className:"u-loader",text:"Loading..."}):e.jsxs(ve,{className:"device-form",children:[e.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),e.jsxs(a.Notification,{severity:"information",title:"GPU passthrough",children:["Learn more about"," ",e.jsx(Je,{docPath:"/reference/devices_gpu/#devices-gpu",children:"GPU devices"})," ","and"," ",e.jsx(Je,{docPath:"/howto/container_gpu_passthrough_with_docker/#container-gpu-passthrough-with-docker",children:"container GPU passthrough with Docker"})]}),y.length>0&&e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited GPU devices"}),e.jsx(k,{rows:y})]}),l&&e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4 custom-devices-heading",children:"Custom GPU devices"}),e.jsx(k,{rows:b})]}),e.jsx(La,{onSelect:N=>{I(t),u(N)},disabledReason:t.values.editRestriction})]})},Kn=({formik:t,project:s})=>{const n=a.useNotify(),i=t.values.entityType==="instance",o=i&&t.values.instanceType==="container",c=i&&t.values.instanceType==="virtual-machine",{data:r,isLoading:v}=ze(),{data:u=[],isLoading:l,error:y}=H(s);y&&n.failure("Loading profiles failed",y);const b=Fs(t.values,u),N=Ce(t.values,u),m=()=>{const h=[...t.values.devices];h.push({type:"usb",name:he("custom-device",1,N)}),t.setFieldValue("devices",h)};if(l||v)return e.jsx(a.Spinner,{className:"u-loader",text:"Loading..."});const p=t.values.devices.some(et),g=[];b.forEach(h=>{const d=we(h.key,t),j=d!==-1,x=t.initialValues.devices.some(_=>_.name===h.key),C=t.values.devices.some(_=>_.name===h.key),w=x&&!C,F=Q(t,h.key)||w;g.push(D({className:"no-border-top override-with-form",configuration:e.jsx(Z,{name:h.key,hasChanges:F,isDetached:j}),inherited:null,override:j?e.jsxs(a.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{I(t),q(d,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:"Attach device",children:[e.jsx(R,{icon:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(a.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{I(t),ue(h.key,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Detach device",disabled:!!t.values.editRestriction,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]})})),g.push(me({project:s,profile:ae(h.source),isDetached:j})),Object.keys(h.device).forEach(_=>{_!=="name"&&g.push(O({label:re(_),inheritValue:h.device[_],readOnly:!1,isDeactivated:j}))})});const f=[];return t.values.devices.forEach((h,d)=>{if(!et(h))return;const j=t.values.devices[d],x=j.type==="usb"?"unix-usb":j.type,C=`device-${x}`,w=r?.configs[C],F=w?Ye(w):[];f.push(D({className:"no-border-top custom-device-name",configuration:e.jsx(Se,{name:j.name,index:d,setName:_=>{I(t),t.setFieldValue(`devices.${d}.name`,_)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsxs(a.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{I(t),q(d,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,title:t.values.editRestriction??"Detach device",disabled:!!t.values.editRestriction,children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]})})),f.push(D({className:"no-border-top inherited-with-form",configuration:e.jsx(a.Label,{forId:`devices.${d}.type`,children:"Type"}),inherited:e.jsx(a.Select,{name:`devices.${d}.type`,id:`devices.${d}.type`,className:"u-no-margin--bottom",onBlur:t.handleBlur,onChange:_=>{I(t),t.setFieldValue(`devices.${d}`,{type:_.target.value,name:j.name})},value:j.type,options:[{label:"Infiniband (Containers only)",value:"infiniband",disabled:c},{label:"PCI (VMs only)",value:"pci",disabled:o},{label:"TPM",value:"tpm"},{label:"Unix Block (Containers only)",value:"unix-block",disabled:c},{label:"Unix Char (Containers only)",value:"unix-char",disabled:c},{label:"Unix Hotplug (Containers only)",value:"unix-hotplug",disabled:c},{label:"USB",value:"usb"}],disabled:!!t.values.editRestriction,title:t.values.editRestriction}),override:""})),F.forEach(_=>{const T=`devices.${d}.${_.key}`,K=j[_.key];_.key!=="name"&&f.push(D({className:"no-border-top inherited-with-form",configuration:e.jsx(a.Label,{forId:T,children:re(_.key)}),inherited:e.jsx(a.Input,{name:T,id:T,onBlur:t.handleBlur,onChange:ie=>{I(t),t.handleChange(ie)},value:K,type:"text",placeholder:_.default,help:e.jsx(Ie,{description:_.shortdesc}),helpClassName:"configuration-help",className:"u-no-margin--bottom",disabled:!!t.values.editRestriction,title:t.values.editRestriction},`${T}-${x}`),override:""}))})}),e.jsxs(ve,{className:"device-form",children:[e.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),g.length>0&&e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited devices"}),e.jsx(k,{rows:g})]}),p&&e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4 custom-devices-heading",children:"Custom devices"}),e.jsx(k,{rows:f})]}),e.jsxs(a.Button,{onClick:()=>{I(t),m()},type:"button",hasIcon:!0,disabled:!!t.values.editRestriction,title:t.values.editRestriction,children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"Attach custom device"})]})]})},Ua=({onSelect:t,disabledReason:s})=>e.jsxs(a.Button,{onClick:t,type:"button",hasIcon:!0,disabled:!!s,title:s,children:[e.jsx(R,{icon:"plus"}),e.jsx("span",{children:"New Proxy Device"})]}),ht=(t,s,n,i,o,c)=>{const r=s[i]?.split(":")||[],v=r.length>0?r[0]:"tcp",u=r.length>1?r[1]:"",l=r.length>2?r[2]:"";t.push(D({className:"no-border-top inherited-with-form p-heading--6",configuration:c,inherited:"",override:""})),t.push(D({className:"no-border-top inherited-with-form",configuration:e.jsx(a.Label,{forId:`devices.${n}.${i}`,children:"Type"}),inherited:e.jsx(a.Select,{id:`devices.${n}.${i}`,onChange:y=>{I(o);const b=y.target.value;if(o.setFieldValue(`devices.${n}.${i}`,`${b}:${u}:${l}`),s.nat==="true"){const N=s.connect?.split(":")||[],m=N.length>1?N[1]:"",p=N.length>2?N[2]:"";o.setFieldValue(`devices.${n}.connect`,`${b}:${m}:${p}`)}},value:v,options:as,className:"u-no-margin--bottom",disabled:!!o.values.editRestriction||i==="connect"&&s.nat==="true",title:o.values.editRestriction??(s.nat?"This is determined by the listen type when nat mode is enabled":void 0)}),override:""})),t.push(D({className:"no-border-top inherited-with-form",configuration:v==="unix"?e.jsx(a.Label,{forId:`devices.${n}.${i}.unixsocket`,required:!0,children:"Socket path"}):e.jsx(a.Label,{forId:`devices.${n}.${i}.address`,required:!0,children:"Address"}),inherited:v==="unix"?e.jsx(a.Input,{id:`devices.${n}.${i}.unixsocket`,onChange:y=>{I(o);const b=y.target.value;o.setFieldValue(`devices.${n}.${i}`,`unix:${b}`)},value:u,placeholder:"/<socket_path>",type:"text",className:"u-no-margin--bottom",disabled:!!o.values.editRestriction,title:o.values.editRestriction}):e.jsx(a.Input,{id:`devices.${n}.${i}.address`,onChange:y=>{I(o);const b=y.target.value;o.setFieldValue(`devices.${n}.${i}`,`${v}:${b}:${l}`)},value:u,placeholder:"127.0.0.1",type:"text",className:"u-no-margin--bottom",disabled:!!o.values.editRestriction,title:o.values.editRestriction}),override:""})),v!=="unix"&&t.push(D({className:"no-border-top inherited-with-form",configuration:e.jsx(a.Label,{forId:`devices.${n}.${i}.port`,required:!0,children:"Port"}),inherited:e.jsx(a.Input,{id:`devices.${n}.${i}.port`,onChange:y=>{I(o);const b=y.target.value;o.setFieldValue(`devices.${n}.${i}`,`${v}:${u}:${b}`)},value:l,placeholder:"00[-00]",type:"text",className:"u-no-margin--bottom",disabled:!!o.values.editRestriction,title:o.values.editRestriction}),override:""}))},qn=({formik:t,project:s})=>{const n=a.useNotify(),{data:i=[],isLoading:o,error:c}=H(s);c&&n.failure("Loading profiles failed",c);const r=Vs(t.values,i),v=[];v.push(...r.map(m=>m.key)),v.push(...t.values.devices.map(m=>m.name));const u=()=>{const m=[...t.values.devices],p=t.values.entityType!=="profile"&&t.values.instanceType!=="container";m.push({type:"proxy",name:he("proxy",1,v),nat:String(p)}),t.setFieldValue("devices",m)},l=t.values.devices.some(m=>m.type==="proxy"),y=(m,p,g,f,h,d,j,x)=>{const C=`devices.${g}.${p}`;return D({className:"no-border-top inherited-with-form",configuration:e.jsx(a.Label,{forId:C,children:m}),inherited:e.jsx(a.Select,{name:C,id:C,onBlur:t.handleBlur,onChange:w=>{I(t),t.setFieldValue(C,w.target.value),j?.(w.target.value)},value:h??"",options:f,help:e.jsx(Ie,{description:d}),helpClassName:"configuration-help",className:"u-no-margin--bottom",disabled:!!x||!!t.values.editRestriction,title:t.values.editRestriction??x},C),override:""})},b=[];r.forEach(m=>{const p=we(m.key,t),g=p!==-1,f=t.initialValues.devices.some(x=>x.name===m.key),h=t.values.devices.some(x=>x.name===m.key),d=f&&!h,j=Q(t,m.key)||d;b.push(D({className:"no-border-top override-with-form",configuration:e.jsx(Z,{name:m.key,hasChanges:j,isDetached:g}),inherited:null,override:g?e.jsxs(a.Button,{appearance:"base",type:"button",title:"Reattach volume",onClick:()=>{I(t),q(p,t)},className:"has-icon u-no-margin--bottom",children:[e.jsx(R,{icon:"connected"}),e.jsx("span",{children:"Reattach"})]}):e.jsxs(a.Button,{disabled:!!t.values.editRestriction,title:t.values.editRestriction,appearance:"base",type:"button",onClick:()=>{I(t),ue(m.key,t)},className:"has-icon u-no-margin--bottom",children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]})})),b.push(me({project:s,profile:ae(m.source),isDetached:g})),Object.keys(m.proxy).forEach(x=>{x==="name"||x==="type"||b.push(O({label:re(x),inheritValue:m.proxy[x],readOnly:!1,isDeactivated:g}))})});const N=[];return t.values.devices.forEach((m,p)=>{if(m.type!=="proxy")return;const g=t.values.devices[p],f=g.listen?.split(":")||[],h=f.length>0?f[0]:"tcp",d=g.connect?.split(":")||[],j=d.length>1?d[1]:"",x=d.length>2?d[2]:"";N.push(D({className:"no-border-top custom-device-name",configuration:e.jsx(Se,{name:g.name,index:p,setName:C=>{I(t),t.setFieldValue(`devices.${p}.name`,C)},disableReason:t.values.editRestriction,formik:t}),inherited:"",override:e.jsxs(a.Button,{className:"u-no-margin--top u-no-margin--bottom",onClick:()=>{I(t),q(p,t)},type:"button",appearance:"base",hasIcon:!0,dense:!0,disabled:!!t.values.editRestriction,title:t.values.editRestriction??"Detach Proxy",children:[e.jsx(R,{icon:"disconnected"}),e.jsx("span",{children:"Detach"})]})})),N.push(y("Bind","bind",p,[{label:"Select option",value:"",disabled:!0},{label:"Host",value:"host"},{label:"Instance",value:"instance"}],g.bind,"Whether to bind the listen address to the instance or host",C=>{C==="instance"&&t.setFieldValue(`devices.${p}.nat`,void 0)})),N.push(y("NAT mode","nat",p,Rs,g.nat,void 0,C=>{C==="true"&&t.setFieldValue(`devices.${p}.connect`,`${h}:${j}:${x}`)},g.bind==="instance"?"Only host-bound proxies can use NAT":void 0)),ht(N,g,p,"listen",t,"Listen"),ht(N,g,p,"connect",t,"Connect")}),o?e.jsx(a.Spinner,{className:"u-loader",text:"Loading..."}):e.jsxs(ve,{className:"device-form",children:[e.jsx(a.Input,{type:"submit",hidden:!0,value:"Hidden input"}),b.length>0&&e.jsxs("div",{className:"inherited-devices",children:[e.jsx("h2",{className:"p-heading--4",children:"Inherited Proxy devices"}),e.jsx(k,{rows:b})]}),l&&e.jsxs("div",{className:"custom-devices",children:[e.jsx("h2",{className:"p-heading--4 custom-devices-heading",children:"Custom Proxy devices"}),e.jsx(k,{rows:N})]}),e.jsx(Ua,{onSelect:()=>{I(t),u()},disabledReason:t.values.editRestriction})]})},Gn=({formik:t})=>{const n=t.values.entityType==="instance"&&t.values.instanceType!=="virtual-machine";return e.jsx(ne,{rows:[V({formik:t,label:"Autostart",name:"boot_autostart",defaultValue:"",readOnlyRenderer:i=>i==="-"?"-":L(i,B),children:e.jsx(a.Select,{options:B})}),V({formik:t,label:"Autostart delay",name:"boot_autostart_delay",defaultValue:"",children:e.jsx(a.Input,{placeholder:"Enter number",type:"number"})}),V({formik:t,label:"Autostart priority",name:"boot_autostart_priority",defaultValue:"",children:e.jsx(a.Input,{placeholder:"Enter number",type:"number"})}),V({formik:t,label:"Host shutdown timeout",name:"boot_host_shutdown_timeout",defaultValue:"",children:e.jsx(a.Input,{placeholder:"Enter number",type:"number"})}),V({formik:t,label:"Boot mode (VMs only)",name:"boot_mode",defaultValue:"",disabled:n,disabledReason:n?"Only available for virtual machines":void 0,children:e.jsx(a.Select,{options:ns,disabled:n})}),V({formik:t,label:"Stop priority",name:"boot_stop_priority",defaultValue:"",children:e.jsx(a.Input,{placeholder:"Enter number",type:"number"})})]})},pt=({formik:t,network:s,family:n})=>{if(!s||!s.config)return null;const i=n==="IPv4"?"ipv4.address":"ipv6.address",o=n.toLowerCase(),c=s.config?.[i],r=t.values[o],v=it(s.type,n==="IPv4"?"ipv4_dhcp":"ipv6_dhcp"),u=it(s.type,"ipv6_dhcp_stateful"),l=vs(t.values,s,n,v.value,u.value);return l?e.jsx(a.Input,{id:i,label:`${n} address reservation`,type:"text",disabled:!0,help:l,value:"-"}):e.jsx(a.PrefixedIpInput,{id:i,name:i,cidr:c||"",ip:r||"",label:`${n} address reservation`,onIpChange:y=>{t.setFieldValue(o,y)},onBlur:()=>{t.setFieldTouched(o,!0)},error:t.touched[o]?t.errors[o]:void 0,help:n==="IPv6"&&e.jsx(e.Fragment,{})})},Hn=({project:t,formik:s,onSave:n})=>{const i=a.useNotify(),o=Xe(),{data:c=[],isLoading:r}=H(t),{data:v=[],isLoading:u}=Dt(t),{data:l=[],isLoading:y}=ca(t),b=r||u||y,N=Ce(s.values,c),m=s.values.entityType==="instance",p=o?.deviceName,g=s.values.devices.find(S=>S.name===p&&S.type==="nic"),f=ft(s.values,c),h=f.find(S=>S.key===p),d=o?.panel===lt.createNetworkDevice,j=h&&!g,x=h&&g,C=!!(j||x),w=o.panel===lt.editNetworkDevice,F=ms(s.values,f),_=S=>{if(!S.managed)return!1;const U=w&&(g?.network===S.name||h?.network?.network===S.name),z=F.includes(S.name),ee=s.values.entityType==="profile",oe=S.config["dns.mode"]==="none"||ee;return U||!z||oe},T=v.filter(_),K=S=>{const U=T.find(z=>z.name===S);return Me(U)},ie=N.filter(S=>S!==g?.name),Re=b?Be({}):Be({ipv4:ce().test("is-valid-ipv4","Please enter a valid IPv4 address",S=>!S||a.isIPv4(S)),ipv6:ce().test("is-valid-ipv6","Please enter a valid IPv6 address",S=>!S||bs(S)),...!C&&{name:ce().required("Device name is required").min(1,"Name must be at least 1 character long").max(63,"Name must be at most 63 characters long").matches(/^[A-Za-z0-9/\-:_.]+$/,{message:"Name can only contain alphanumeric, forward slash, hyphen, colon, underscore and full stop characters"}).notOneOf(ie,"A device with this name already exists")},network:ce().required("Network is required")}),P=gt({enableReinitialize:!0,initialValues:(()=>{const S=T[0]?.name??"",U=K(S).join(",");if(d)return{name:he("eth",1,N),network:S,acls:U,ipv4:"",ipv6:""};if(j)return{name:h.key,network:h.network?.network||S,acls:Le(K(h.network?.name||""),ke(h.network)).join(","),ipv4:"",ipv6:""};const z=g?.network||S,ee=Le(K(z),ke(g)).join(",");return{name:g?.name||"",network:z,acls:ee,ipv4:g?.["ipv4.address"]||"",ipv6:g?.["ipv6.address"]||"",security_acls_default_egress_action:g?.["security.acls.default.egress.action"]||"",security_acls_default_ingress_action:g?.["security.acls.default.ingress.action"]||""}})(),validationSchema:Re,onSubmit:S=>{const U=S.acls?S.acls.split(","):[],z=Me(T.find(le=>le.name===S.network)),ee=U.filter(le=>!z.includes(le)),oe={name:S.name,type:"nic",network:S.network,"security.acls":ee.length>0?ee.join(","):void 0,"ipv4.address":S.ipv4||void 0,"ipv6.address":S.ipv6||void 0,"security.acls.default.egress.action":S.security_acls_default_egress_action||void 0,"security.acls.default.ingress.action":S.security_acls_default_ingress_action||void 0},Mt=p,{devices:Fe}=s.values,Qe=Fe.findIndex(le=>le.name===Mt);let be;Qe!==-1?(be=[...Fe],be[Qe]=oe):be=[...Fe,oe],s.setFieldValue("devices",be),n?.(),o.clear()}}),A=()=>{if(T.length===0)return"No available networks found.";if(P.touched.network)return P.errors.network},G=()=>d?"Create network device":j?"Create override":x?"Edit override":"Edit network device",M=T.find(S=>S.name===P.values.network),De=K(P.values.network),Tt=P.values.acls?P.values.acls.split(","):[],At=Array.from(new Set(De.concat(Tt))),Bt=()=>{if(Ze(M))return De.length>0?"Some ACLs are inherited from the network. They cannot be deselected here.":void 0;if(!M||!os.includes(M.type))return"ACLs require an OVN or a bridge network.";const S=e.jsx(vt,{to:`${fe}/ui/project/${t}/network/${M.name}`,children:"detail page"});return M.type==="bridge"?e.jsxs(e.Fragment,{children:["Instance device ACLs require an OVN network. Manage ACLs for all instances using this network in the ",S,"."]}):e.jsxs(e.Fragment,{children:["Instance device ACLs can be customized. Manage ACLs for all instances using this network in the ",S,"."]})},Pe=()=>{P.resetForm(),i.clear(),o.clear()};if(ta(Pe),!b&&!d&&!g&&!h)return e.jsxs(a.SidePanel,{children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{children:"Device not found"})}),e.jsx(a.SidePanel.Content,{className:"padding--medium",children:e.jsx(a.ScrollableContainer,{dependencies:[i.notification],belowIds:["panel-footer"],children:e.jsxs(a.Notification,{severity:"negative",children:["The device ",p&&e.jsx("strong",{children:p})," could not be found. It may have been deleted or the URL is incorrect."]})})}),e.jsx(a.SidePanel.Footer,{className:"u-align--right",children:e.jsx(a.Button,{appearance:"base",onClick:Pe,children:"Close"})})]});const Ot=()=>({Egress:P.values.security_acls_default_egress_action??M?.config["security.acls.default.egress.action"]??"",Ingress:P.values.security_acls_default_ingress_action??M?.config["security.acls.default.ingress.action"]??""}),Lt={Egress:"security_acls_default_egress_action",Ingress:"security_acls_default_ingress_action"};return e.jsxs(a.SidePanel,{children:[e.jsx(a.SidePanel.Header,{children:e.jsx(a.SidePanel.HeaderTitle,{children:G()})}),e.jsx(xt,{className:"u-no-padding"}),e.jsx(a.SidePanel.Content,{className:"u-no-padding",children:e.jsx(a.ScrollableContainer,{dependencies:[i.notification],belowIds:["panel-footer"],children:e.jsxs(a.Form,{onSubmit:P.handleSubmit,stacked:!0,children:[e.jsx(a.Input,{label:"Device name",required:!0,id:"name",...P.getFieldProps("name"),type:"text",placeholder:"Enter device name",error:P.touched.name&&P.errors.name,disabled:C}),e.jsx(la,{value:P.values.network,setValue:S=>{P.setFieldValue("network",S);const U=K(S);P.setFieldValue("acls",U.join(",")),P.setFieldValue("ipv4",""),P.setFieldValue("ipv6","")},networkList:T,disabled:T.length===0,id:"network",label:"Network",required:!0,error:A()}),m&&M&&e.jsxs(e.Fragment,{children:[e.jsx(pt,{formik:P,network:M,family:"IPv4"}),e.jsx(pt,{formik:P,network:M,family:"IPv6"})]}),e.jsx(ia,{project:t,selectedAcls:At,setSelectedAcls:S=>{P.setFieldValue("acls",S.join(","))},inheritedAcls:De,canSelectManualAcls:Ze(M),help:Bt(),label:"Access Control Lists",availableAcls:l}),e.jsx(oa,{onChange:(S,U)=>{P.setFieldValue(S,U)},values:Ot(),disabled:P.values.acls?.length===0||M?.type!==is,directionField:Lt})]})})}),e.jsxs(a.SidePanel.Footer,{className:"u-align--right",children:[e.jsx(a.Button,{appearance:"base",onClick:Pe,type:"button",children:"Cancel"}),e.jsx(a.ActionButton,{appearance:"positive",loading:P.isSubmitting,disabled:b||!P.isValid,onClick:()=>{P.submitForm()},type:"submit",children:"Apply changes"})]})]})};export{Gn as B,da as C,Ln as D,kn as G,$n as I,Un as M,Mn as N,Kn as O,Pn as P,An as R,Fn as S,Vn as U,On as a,fa as b,qn as c,En as d,Tn as e,Hn as f,Bn as h};

Youez - 2016 - github.com/yon3zu
LinuXploit