"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[53966],{19478(e,t,n){n.r(t),n.d(t,{RadiosSidePanel:()=>R,default:()=>$});var i=n(274934),a=n(977872),o=n(602086),s=n(843871),r=n(179102),d=n(950804),l=n(571829),m=n(630849),c=n(761801),p=n(115114),u=n(835655),_=n(250820),b=n(900891),h=n(535322),A=n(561614),f=n(795206),g=n(781663),v=n(875922),x=n(801820),C=n(483064),w=n(855554);const k=({device:e,radio:t})=>`${e._id}-${t.name}`,y=e=>{const[t,n]=e.split("-");return{device_id:t,radio_name:n}},O=({deviceRadios:e,radios:t,onRemoveDeviceRadio:n,onSelectMeshingParents:u})=>{const g=(0,a.wA)(),x=(0,m.I)(),C=(0,o.useMemo)(()=>l.I.reduce((e,n)=>(t[n]&&e.radios.push(t[n]),e),{radios:[]}),[t]),w=(0,o.useMemo)(()=>d.A.object().shape({...(0,_.m)(e.filter(v.A.tx_power).flatMap(({radio:e})=>e),!0)}),[e]);return(0,i.jsx)(s.l1,{initialValues:C,onSubmit:async(t,{resetForm:n})=>{try{await(e=>{if(!e.length||!t.radios?.length)return Promise.resolve();const n=t.radios.reduce((t,n,i)=>{const a=n.type,o=(({type:e,name:t,...n},i)=>({radio:e,...Object.entries(n).reduce((e,[t,a])=>{let o=a;return void 0===o||"tx_power"===t&&n.tx_power_mode!==A.PB.CUSTOM||"tx_power_mode"===t&&o===A.PB.CUSTOM&&void 0===n.tx_power||i[t]===o||("ht"===t&&(o=a.toString()),e[t]=o),e},{})}))(n,C.radios[i]);return t[a]=((e,t)=>Object.entries(e).reduce((e,[n,i])=>{if(void 0===i)return e;const a=t.filter(e=>!v.A[n]||v.A[n](e));if(!a.length)return e;const o=a.map(k).sort().join(" ");return e[o]={...e[o],[n]:i},e},{}))(o,e.filter(({radio:{radio:e}})=>e===a)),t},{}),i={},a=(e,t,n,i)=>({id:e,data:{radio_table:[{radio_identifiers:t,...i,radio:n}]}});return l.I.forEach(e=>{const t=n[e];t&&Object.entries(t).forEach(([t,n])=>{const o=t.split(" ").map(y),s=[...new Set(o.map(({device_id:e})=>e).sort())],r=s.join(" ");if(i[r]&&!i[r]?.data?.radio_table.some(t=>t.radio===e)){const t=a(s,o,e,n);i[r]={...t,data:{radio_table:[...i[r]?.data?.radio_table||[],...t.data.radio_table]}}}else i[r]=a(s,o,e,n)})}),Promise.all(Object.values(i).map(e=>g((0,f.Nc)(e))))})(e)}catch(e){x(e)}finally{n({values:t})}},enableReinitialize:!0,validationSchema:w,children:({handleSubmit:a,handleReset:o,dirty:s,isValid:d})=>(0,i.jsxs)(i.Fragment,{children:[l.I.filter(e=>!!t[e]).map((t,a)=>(0,i.jsx)(h.A,{type:h.I.ACCORDION,items:[{id:t,label:(0,i.jsx)(r.A,{weight:"bold",size:"medium",children:(0,i.jsx)(c.A,{radio:t})}),openByDefault:!0,renderContent:()=>(0,i.jsx)(b.sG,{radioType:t,radioIdx:a,deviceRadios:e.filter(({radio:e})=>e.radio===t),onRemoveDeviceRadio:n,onSelectMeshingParents:u,hideTitle:!0,showDeviceList:!0,mode:b.Hm.ONLY_RADIO,showKeyRadioMetrics:!0,defaultKeyRadioMetricsExpanded:e.length<=1})}]},t)),(0,i.jsx)(p.A,{isDirty:s,isInvalid:!d,onFormSubmit:a,onFormCancel:o})]})})},R=()=>{const e=(0,a.wA)(),t=(0,a.d4)(x.mK),n=(0,a.d4)(x.If),s=n.map(e=>Object.fromEntries(Object.entries((0,u.S)(e.radio)).map(([t,n])=>!v.A[t]||v.A[t](e)?[t,n]:[t,C.Q]))).reduce((e,t)=>{return{...e,[t.type]:e[t.type]?(n=e[t.type],i=t,[...new Set([...Object.keys(n),...Object.keys(i)])].reduce((e,t)=>{if(b.eu.includes(t))return e;const a=n[t]!==C.Q?n[t]:i[t],o=a===(i[t]!==C.Q?i[t]:a)?a:void 0;return o===C.Q?e:{...e,[t]:o}},{})):t};var n,i},{}),r=(0,o.useCallback)(t=>{const i=t.map(g.R);e((0,w.V)(n.filter(({id:e})=>!i.includes(e)).map(({id:e})=>e)))},[e,n]),d=(0,o.useCallback)(()=>{e((0,w.V)([...new Set([...n.filter(({parentId:e})=>!e).map(({id:e})=>e),...n.flatMap(({parentId:e})=>Object.values(t).filter(t=>!t.parentId&&t.id===e).map(({id:e})=>e))])]))},[e,n,t]);return(0,o.useEffect)(()=>()=>{e((0,w.V)([]))},[e]),(0,i.jsx)(O,{deviceRadios:n,radios:s,onRemoveDeviceRadio:r,onSelectMeshingParents:d})},$=R},535322(e,t,n){n.d(t,{A:()=>_,I:()=>i});var i,a=n(274934),o=n(505817),s=n(753583),r=n(247816),d=n(565527),l=n(309130),m=n(100978),c=n(291508);!function(e){e.ACCORDION="accordion",e.BUTTON_LIST="buttonList"}(i||(i={}));const p=(0,r.A)(m.A,(0,c.A)("marginBottom","isButtonList","margin","flex","width","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===d.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${d.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${d.S.LIGHT}`]};
  ${({nested:e,theme:{themeName:t}})=>e?`border: ${o.Ay[`desktop-border-divider-${t}`]};`:""}
  padding: ${({isButtonList:e,padding:t})=>t||(e?`0 ${l.Ln}`:l.Ln)};
  margin-bottom: ${({marginBottom:e})=>e||l.Ln};
  ${({margin:e})=>e?`margin: ${e};`:""}
  border-radius: 8px;
  flex-direction: column;
  width: ${({width:e="100%"})=>e};
  flex: ${({flex:e=0})=>e};
  > :last-child {
    margin-bottom: 0;
  }
  thead {
    tr {
      height: 32px !important;
    }
    th {
      text-transform: none;
    }
  }
  ${({isButtonList:e})=>e?`\n    > div {\n      display: flex;\n      height: 48px;\n      border-bottom: ${({theme:{themeName:e}})=>o.Ay[`desktop-border-divider-${e}`]};\n      &:last-child {\n        border-bottom: none;\n      }\n    }\n  `:""}
`,u=(0,r.A)(s.A,(0,c.A)("marginBottom","margin","flex","padding","nested","background"))`
  background-color: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===d.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${d.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${d.S.LIGHT}`]};
  ${({nested:e,theme:{themeName:t}})=>e?`border: ${o.Ay[`desktop-border-divider-${t}`]};`:""}
  margin-bottom: ${({theme:e,marginBottom:t})=>t||e.spacing["spacing-l"]};
  ${({margin:e})=>e?`margin: ${e};`:""}
  ${({padding:e})=>e?`padding: ${e};`:""}
  border-radius: 8px;
  flex-direction: column;
  flex: ${({flex:e=0})=>e};
  > :last-child {
    margin-bottom: 0;
  }
  thead {
    tr {
      height: 32px !important;
    }
    th {
      text-transform: none;
    }
  }
  > li {
    > div:first-child {
      background: ${({background:e,nested:t,theme:{themeName:n}})=>e||o.Ay[n===d.S.DARK?`desktop-color-neutral-${t?"00":"01"}-${d.S.DARK}`:`desktop-color-neutral-${t?"01":"00"}-${d.S.LIGHT}`]};
      height: 48px;
      padding: 0 ${l.Ln};
    }
    > div:nth-child(2) {
      margin-bottom: 0;
      padding: 0;
      > div {
        padding: 0 ${l.Ln} ${l.Ln};
      }
    }
  }
`,_=({type:e,marginBottom:t,margin:n,padding:o,flex:s,width:r,nested:d,...l})=>"items"in l?(0,a.jsx)(u,{marginBottom:t,margin:n,padding:o,flex:s,nested:d,...l}):(0,a.jsx)(p,{nested:d,width:r,marginBottom:t,margin:n,padding:o,flex:s,isButtonList:e===i.BUTTON_LIST,...l,children:l.children})},796091(e,t,n){n.d(t,{A:()=>r});var i=n(274934),a=n(833466),o=n(309130),s=n(100978);const r=e=>(0,i.jsx)(s.A,{paddingTop:o.YC,paddingBottom:o.YC,gap:o.Ln,rowGap:o.YC,flexWrap:"wrap",minHeight:a.b,alignItems:"center",...e})},250266(e,t,n){n.d(t,{A:()=>m});var i=n(274934),a=n(602086),o=n(13790),s=n(409844),r=n(521376),d=n(309130),l=n(470070);const m=({children:e=null,title:t,titleValues:n,message:m,messageValues:c,handleConfirm:p=()=>null,handleClose:u=()=>null,handleCancel:_,isOpen:b,buttonVariant:h="primary",cancelButtonVariant:A="tertiary",cancelButtonMessage:f="COMMON_ACTION_CANCEL",buttonMessage:g="COMMON_ACTION_CONFIRM",buttonDisabled:v=!1,position:x="top",offset:C,showHeaderClose:w=!1,contentClassName:k="",body:y,titleBody:O,className:R,rootClose:$=!1,footerActions:I})=>{const S=(0,a.useCallback)(e=>{b&&(e.stopPropagation(),e.key===r.U.ENTER?p():e.key===r.U.ESCAPE&&u(!1))},[b,p,u]);(0,a.useEffect)(()=>(window.addEventListener("keydown",S,!0),()=>{window.removeEventListener("keydown",S,!0)}),[S]);const j=(0,a.useCallback)(()=>{u(!1),_?.()},[u,_]),N=(0,a.useCallback)(()=>{u(!1),p()},[u,p]),E=(0,a.useMemo)(()=>[{text:(0,i.jsx)(l.sA,{id:f}),variant:A,onClick:j},{text:(0,i.jsx)(l.sA,{id:g}),disabled:v,variant:h,onClick:N}],[g,h,f,A,j,N,v]),M=(0,a.useCallback)(()=>{u(!1)},[u]),D=s.AH`
    ${t?"":`margin-top: ${d.xO}`}
  `;return(0,i.jsx)(o.A,{title:t?(0,i.jsx)(l.sA,{id:t,values:n}):O||null,...m?{body:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l.sA,{id:m,values:c}),y]})}:{body:y},position:x,portal:!0,offset:C,actions:I||E,showHeaderClose:w,contentClassName:s.AH`
        ${D}
        ${k}
      `,onRequestClose:M,isOpen:b,allowOverflow:!0,rootClose:$,className:R,children:e})}},115114(e,t,n){n.d(t,{A:()=>m});var i=n(274934),a=n(388294),o=n(247816),s=n(409844),r=n(751636);const d=(0,o.A)("div")`
  height: 66px;
`,l=s.AH`
  padding: 0px !important;
`,m=({isDirty:e,onFormSubmit:t,onFormCancel:n,isInvalid:o,...s})=>e?(0,i.jsx)(a.A,{children:(0,i.jsx)(r.A,{isDirty:e,onFormCancel:n,onFormSubmit:t,isInvalid:o,className:l,...s})}):(0,i.jsx)(d,{})},835655(e,t,n){n.d(t,{J:()=>u,S:()=>p});var i=n(602086),a=n(345272),o=n(561614),s=n(175650),r=n(634268),d=n(432001),l=n(308833),m=n(250820),c=n(98334);const p=({antenna_id:e,antenna_gain:t,name:n,radio:i,ht:a,channel:s,tx_power_mode:d,tx_power:m,min_txpower:p,vwire_enabled:u,min_rssi_enabled:_,min_rssi:b,hard_noise_floor_enabled:h,sens_level_enabled:A,sens_level:f})=>({antenna_id:e,antenna_gain:t,name:n,type:i,ht:+a||r.L[i],channel:Number(s)||c.YQ,tx_power_mode:d||o.PB.AUTO,tx_power:m||p||0,vwire_enabled:u??!0,min_rssi_enabled:_||!1,min_rssi:+b||l.X.DEFAULT,hard_noise_floor_enabled:h||!1,sens_level_enabled:A,sens_level:f}),u=e=>{const t=(0,i.useMemo)(()=>({...(()=>{const t=(e.radio_table||[]).find(({radio:e})=>e===a.A.NA.type)?.vwire_enabled??!0,n=e.mesh_sta_vap_enabled??!0,i=t||n;return{radios:(e.support_wifi6e?e.radio_table:e.radio_table?.filter(({radio:e})=>e!==o.sx.RADIO_6E))?.map(p)?.sort(s.j3),atf_enabled:e.atf_enabled||!1,meshingEnabled:i,uplinkMeshEnabled:n,uplinkPriority1:e.mesh_uplink_1||"",uplinkPriority2:e.mesh_uplink_2||""}})()}),[e.radio_table,e.mesh_sta_vap_enabled,e.mesh_uplink_1,e.mesh_uplink_2,e.atf_enabled,e.support_wifi6e]),n=(0,i.useMemo)(()=>e.radio_table?.reduce((t,{radio:n})=>(t[n]=(0,d.k)({wifi_caps:e.wifi_caps,hide_ch_width:e.hide_ch_width},n),t),{}),[e.radio_table,e.wifi_caps,e.hide_ch_width]);return{initialValues:t,getSubmitData:(0,i.useCallback)(t=>{const{meshingEnabled:i,uplinkMeshEnabled:a,uplinkPriority1:o,uplinkPriority2:r,radios:d,...l}=t,m={...l};return o&&(m.mesh_uplink_1=o,r&&(m.mesh_uplink_2=r)),m.mesh_sta_vap_enabled=t.uplinkMeshEnabled,m.radio_table=d.map(t=>{const i=(e.radio_table||[]).find(({name:e})=>e===t.name),a=(0,s.kb)({model:e.model},i.antenna_id)?null:(0,s.Sb)(e.antenna_table||[],i.antenna_id);return(({isChannelWidthHidden:e,antenna:t,minRssiStrictModeSupported:n},i)=>{const{name:a,type:o,sens_level:r,sens_level_enabled:d,...l}=i,m={...l,sens_level_enabled:d,sens_level:r,radio:o,name:a};return"custom"!==l.tx_power_mode&&delete m.tx_power,m.antenna_id&&t?m.antenna_gain=(0,s.pK)(t,a):delete m.antenna_id,n||m.min_rssi_enabled||delete m.hard_noise_floor_enabled,m.min_rssi_enabled||delete m.min_rssi,m.sens_level_enabled||delete m.sens_level,e&&(delete m.channel,delete m.ht),m})({isChannelWidthHidden:n[t.type],antenna:a&&i&&(0,s.Jj)(a,i.name)?a:null,minRssiStrictModeSupported:i&&(0,s.Wg)(i)},t)}),m},[e.radio_table,e.model,e.antenna_table,n]),validationSchema:(0,m.m)(e.radio_table)}}},751636(e,t,n){n.d(t,{A:()=>m});var i=n(274934),a=n(526744),o=n(470070),s=n(247816),r=n(291508),d=n(309130);const l=(0,s.A)("footer",(0,r.A)("hasFormResetButton"))`
  display: flex;
  justify-content: ${({hasFormResetButton:e})=>e?"space-between":"flex-end"};
  padding: ${d.S2} ${d.fS};
  gap: ${d.kc};
`,m=({allowCancel:e,isDirty:t,isInvalid:n,isSubmitting:s,onFormSubmit:r,onFormReset:d,onFormCancel:m,className:c,submitButtonText:p,customButton:u,applyButton:_,hideCancelButton:b,form:h,testConfigFooter:A})=>(0,i.jsx)(l,{className:c,hasFormResetButton:!!d,children:A||(0,i.jsxs)(i.Fragment,{children:[u,b?null:(0,i.jsx)(a.A,{name:"cancel",variant:"default",type:"button",onClick:m,disabled:!e&&!t,children:(0,i.jsx)(o.sA,{id:"COMMON_ACTION_CANCEL"})}),d?(0,i.jsx)(a.A,{name:"reset",variant:"default",type:"button",onClick:d,disabled:!t,children:(0,i.jsx)(o.sA,{id:"COMMON_ACTION_RESET_TO_DEFAULT"})}):null,_||(0,i.jsx)(a.A,{name:"submit",variant:"primary",type:"submit",onClick:r,disabled:!t||n||s,form:h,children:(0,i.jsx)(o.sA,{id:p||"COMMON_ACTION_APPLY_CHANGES"})})]})})},521376(e,t,n){var i;n.d(t,{U:()=>i}),function(e){e.ARROW_LEFT="ArrowLeft",e.ARROW_RIGHT="ArrowRight",e.ARROW_DOWN="ArrowDown",e.ARROW_UP="ArrowUp",e.ENTER="Enter",e.ESCAPE="Escape",e.BACKSPACE="Backspace",e.DELETE="Delete",e.TAB="Tab"}(i||(i={}))},877840(e,t,n){n.d(t,{A:()=>r});var i=n(274934),a=n(602086),o=n(184931),s=n(712642);const r=({isDisabled:e,isAdditive:t=!0,children:n})=>{const r=(0,o.pv)(),d=(0,a.useMemo)(()=>"boolean"==typeof e?{fields:e,labels:e,tooltipIcons:e,tooltipPopovers:!1}:e,[e]),l=(0,a.useMemo)(()=>({fields:t?d.fields||r.fields:d.fields,labels:t?d.labels||r.labels:d.labels,tooltipIcons:t?d.tooltipIcons||r.tooltipIcons:d.tooltipIcons,tooltipPopovers:t?d.tooltipPopovers||r.tooltipPopovers:d.tooltipPopovers}),[t,d.fields,d.labels,d.tooltipIcons,d.tooltipPopovers,r.fields,r.labels,r.tooltipIcons,r.tooltipPopovers]);return(0,i.jsx)(s.I.Provider,{value:l,children:n})}},571829(e,t,n){n.d(t,{I:()=>a});var i=n(561614);const a=[i.sx.RADIO_NG,i.sx.RADIO_NA,i.sx.RADIO_6E,i.sx.RADIO_AD]}}]);