"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[3300],{497157(e,t,a){a.d(t,{A:()=>f});var l=a(602086),i=a(831721),s=a(515115),n=a(733707),o=a(999803),c=a(34591),r=a(43009),d=a(238369);const h=(0,o.c)(n.A),m=e=>{const{className:t,forwardedRef:a,motif:i,style:s,...n}=(0,c.b)(e),{motif:o}=(0,r.A)(i),m=(0,d.p)(e);return l.createElement("span",{className:h.concat(t)("settingsGridBadge",`settingsGridBadge-${o}`),ref:a,style:{...s,...m},...n})};var g=l.forwardRef((e,t)=>l.createElement(m,{forwardedRef:t,...e})),p=a(406112),A=a(196710),b=a(125799);const u=(0,o.c)(n.A),T=e=>{const{alignWith:t,badge:a,badgeClassName:n,children:o,className:h,disableHover:m=!1,forwardedRef:T,highlight:f=!1,highlightDelay:C,highlightNoAutoScroll:_,highlightOutlineClassName:w,highlightOutlineColor:N,highlightType:v="none",htmlFor:E,icon:S,iconClassName:x,label:y,labelClassName:I,labelSize:O="body",labelWeight:M="normal",motif:R,style:j,textWrapperClassName:L,unlimitedWidth:k=!1,tooltip:D,tooltipWidth:G,tooltipProps:B,...W}=(0,c.b)(e),{motif:Y}=(0,r.A)(R),z=(0,d.p)(e),H=(0,l.useRef)(null),P=(0,l.useRef)(null);(0,s.iz)(!_&&f,C,H,v,T||P);const V=(0,s.gH)(f,C,v,E,T||P),F=!!f&&("auto"===v&&!1===V||"outline"===v);return l.createElement("div",{className:u.concat(h)("settingsGridLabelContainer",`settingsGridLabelContainer-${Y}`,"spotlight"===v&&f&&"settingsGridLabelContainer-selected",!k&&"settingsGridLabelContainer-limitedWidth","withLabel"===t&&"settingsGridLabelContainer-withLabel"),style:{..."number"==typeof t&&{paddingTop:t},...j,...z}},o||l.createElement(l.Fragment,null,"function"==typeof S?l.createElement(S,{className:u.concat(x)("labelIcon",`labelIcon-${Y}`)}):S,l.createElement("label",{className:u.concat(L)("label",!m&&"label-hover",F&&"label-highlighted"),htmlFor:E,ref:T||P,...W},("auto"===v||"outline"===v)&&l.createElement(p.A,{className:w,color:N,ref:H,show:F}),l.createElement(A.A,{color:"secondary",className:u.concat(I)("labelText",`labelText-${Y}`,S&&"labelText-alignWithIcon","spotlight"===v&&f&&"label-spotlightHighlight","spotlight"===v&&f&&`label-spotlightHighlight-${Y}`),size:O,weight:M,motif:Y},y,a&&l.createElement(g,{className:n},a)))),D&&l.createElement(b.A,{...B,description:D,className:u("labelTooltip"),width:G,motif:Y,onClick:e=>e.stopPropagation(),portal:!0},l.createElement(i.A,{isActive:!0,size:"original",className:u("labelTooltipSvg"),motif:Y,onClick:e=>e.preventDefault()})))},f=l.forwardRef((e,t)=>l.createElement(T,{forwardedRef:t,...e}));f.displayName="SettingsGridLabel"},421291(e,t,a){a.d(t,{A:()=>s});var l=a(133530),i=a(715320);const s=()=>(0,l.Y)(i.mv)[0]||null},1943(e,t,a){a.d(t,{A:()=>p});var l=a(274934),i=a(602086),s=a(977872),n=a(247816),o=a(470070),c=a(956978),r=a(434521),d=a(45978),h=a(795206),m=a(648576);const g=(0,n.A)(m.Ay)`
  padding: 0;
  white-space: nowrap;
`,p=({device:e,labelId:t,disabled:a})=>{const n=(0,s.wA)(),m=(0,r.S9)(e),p=(0,i.useCallback)(t=>{t.preventDefault(),t.stopPropagation(),(0,c.YdF)({type:e.type})&&e.peer_ubb?.mac&&n((0,h.VO)({locating:e.peer_ubb.locating,mac:e.peer_ubb.mac,name:e.peer_ubb.name,model:e.peer_ubb.model})),n((0,h.VO)({locating:e.locating,mac:e.mac,name:e.name,model:e.model}))},[n,e.type,e.mac,e.name,e.model,e.locating,e.peer_ubb?.mac,e.peer_ubb?.name,e.peer_ubb?.model,e.peer_ubb?.locating]);return(0,l.jsx)(g,{variant:"link",onClick:p,disabled:a||m!==d.g.CONNECTED,children:(0,l.jsx)(o.sA,{id:e.locating?"DEVICE_ACTIONS_LOCATE_STOP":t||"DEVICE_ACTIONS_LOCATE"})})}},3300(e,t,a){a.r(t),a.d(t,{default:()=>k});var l=a(274934),i=a(602086),s=a(977872),n=a(843871),o=a(159469),c=a(700444),r=a(869332),d=a(988191),h=a(956978),m=a(754924),g=a(795206),p=a(815436),A=a(938984),b=a(713804),u=a(198273),T=a(601154),f=a(247816),C=a(347625),_=a(916704),w=a(309130),N=a(721398),v=a(120197),E=a(100978),S=a(1943),x=a(470070),y=a(384783);const I=(0,f.A)(y.A)`
  width: 415px;
  .contentClassName {
    > div span {
      line-height: 24px;
    }
  }
`,O=(0,f.A)(A.A)`
  margin: ${w.Ln} 0;
`,M=(0,f.A)(E.A)`
  gap: 6px;
`,R=(0,f.A)(u.A)`
  flex: 1;
`,j=({onChange:e,onClose:t,withTest:a})=>{const{values:{batteryMac:i,targetMac:o},handleSubmit:c}=(0,n.j7)(),r=(0,s.d4)(m.qD),d=(0,s.d4)(m.ID).find(({mac:e})=>e===i),h=r.map(({name:e,model:t,mac:a})=>({value:a,label:(0,C.Q)({name:e,model:t,mac:a})}));return(0,l.jsxs)(I,{allowOverflow:!0,title:(0,l.jsx)(A.A,{weight:"bold",size:"large",children:(0,l.jsx)(x.sA,{id:"ASSIGN_BATTERY_MODAL_TITLE"})}),size:"small",contentClassName:"contentClassName",actions:[{variant:"tertiary",text:(0,l.jsx)(x.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:t,type:"button"},{variant:"primary",text:(0,l.jsx)(x.sA,{id:a?"ASSIGN_AND_TEST_BATTERY_ACTION":"ASSIGN_BATTERY_ACTION"}),onClick:()=>c(),type:"button",disabled:!o}],onRequestClose:t,children:[(0,l.jsx)(O,{size:"medium",children:(0,l.jsx)(x.sA,{id:"ASSIGN_BATTERY_MODAL_CONTENT"})}),(0,l.jsxs)(M,{alignItems:"center",children:[(0,l.jsx)(S.A,{device:d,labelId:"DEVICE_ACTIONS_LOCATE_BATTERY"}),(0,l.jsx)(N.A,{messageId:"DEVICE_ACTIONS_LOCATE_DEVICE_DESCRIPTION",tooltipClassName:"tooltip-position-fixer"})]}),(0,l.jsx)(T.A,{padding:"none",children:(0,l.jsxs)(b.A,{children:[(0,l.jsx)(_.A,{style:{flex:1},type:"input",label:(0,l.jsx)(x.sA,{id:"ASSIGN_BATTERY_ITEM",values:{id:(0,C.Q)(d)}})}),(0,l.jsx)(R,{column:!0,width:"50%",children:(0,l.jsx)(v.A,{name:"targetMac",type:"dropdown",variant:"secondary",translateLabel:!0,label:"COMMON_ASSIGN_TO",options:h,onChange:e,width:"100%"})})]})})]})},L=(e,t,a,l)=>{const i=new Set([...l||[],...t.connected_battery_overrides||[]].map(({mac:e})=>e));a&&i.add(a);const s=[...i].map(e=>({mac:e}));return e((0,g.ex)({connected_battery_overrides:s},t._id,t.mac,{extend:!0})),s},k=({activeMacs:e,selectedHost:t})=>{const a=(0,s.d4)((0,m.nH)(e)).filter(h.OFJ),A=(0,s.wA)(),b=(0,s.d4)(m.ID),u=(0,s.d4)(m.qD),T=t?[t]:u,[f,C]=(0,i.useState)({withTest:1===a.length,hostMac:void 0}),[_,w]=(0,i.useState)(void 0),[N,v]=(0,i.useState)(a.map(({mac:e})=>e)),E=(0,i.useCallback)(()=>{A((0,r.AS)())},[A]);(0,i.useEffect)(()=>{if(!T.length)return A((0,r.AS)()),void A((0,c.ox)({icon:o.C.warning,message:"ASSIGN_BATTERY_MODAL_NO_HOSTS_WARNING"}));const e={withTest:1===a.length,hostMac:T[0].mac};a.forEach(e=>{!e.adopted&&A((0,g.Hk)(e))});const t=a.filter(e=>!(0,d.rs)(e.mac,b)).map(({mac:e})=>({mac:e}));if(t.length){const l=L(A,T[0],void 0,t);e.withTest=e.withTest&&1===l.length,1===T.length?(A((0,r.AS)()),e.withTest&&A((0,r.to)({modalType:p.A.TEST_SMART_BATTERY,modalProps:{batteryMac:a[0].mac,hostMac:e.hostMac}}))):C(e)}},[]);const S={batteryMac:N[0],targetMac:_||(0,d.rs)(N[0],b)?.mac||T[0].mac};return T.length?(0,l.jsx)(n.l1,{enableReinitialize:!0,initialValues:S,onSubmit:({batteryMac:e,targetMac:t})=>{const l=(0,d.rs)(e,b),i={withTest:f.withTest,hostMac:t};if(l?.mac!==t){l&&(0,d.jq)(e,l,A);const a=b.find(({mac:e})=>e===t),s=L(A,a,e);i.withTest=i.withTest&&1===s.length}else i.withTest=i.withTest&&1===l.connected_battery_overrides.length;C(i),w(void 0),N.shift(),0===N.length?(A((0,r.AS)()),i.withTest&&A((0,r.to)({modalType:p.A.TEST_SMART_BATTERY,modalProps:{batteryMac:a[0].mac,hostMac:i.hostMac}}))):v(N)},children:(0,l.jsx)(j,{onClose:E,onChange:e=>{const t=b.find(({mac:t})=>t===e.value);C({...f,withTest:1===a.length&&0===(t.connected_battery_overrides||[]).filter(({mac:e})=>e!==N[0]).length}),w(e.value)},withTest:f.withTest})}):null}},721398(e,t,a){a.d(t,{A:()=>o});var l=a(274934),i=a(125799),s=a(853777),n=a(470070);const o=({messageId:e,tooltipClassName:t,values:a,isInteractive:o,portal:c,variant:r="twoTone",size:d="medium"})=>(0,l.jsx)(i.A,{description:(0,l.jsx)(n.sA,{id:e,values:a}),width:210,isInteractive:o,portal:c,tooltipClassName:t,children:(0,l.jsx)(s.A,{isActive:!0,omitSvgMargin:!0,variant:r,size:d})})},133530(e,t,a){a.d(t,{Y:()=>s});var l=a(602086),i=a(237725);function s(e){const t=(0,i.zy)(),a=(0,i.W6)(),s=(0,l.useMemo)(()=>new URLSearchParams(t.search),[t.search]),n=s.get(e),o=(0,l.useCallback)(l=>{const i=new URLSearchParams(s.toString());return l?i.set(e,l):i.delete(e),a.replace({...t,search:i.toString()})},[a,e,t,s]);return(0,l.useMemo)(()=>[n,o],[n,o])}},916704(e,t,a){a.d(t,{A:()=>c});var l=a(274934),i=a(184931),s=a(309130),n=a(14916);const o=e=>{if(e)switch(e){case"picklist":case"realCheckbox":case"radio":case"input":case"dropdown":case"tabs":case"button":case"link":case"table":case"label":case"text":default:return;case"dropdownWithLabel":case"inputWithLabel":return"withLabel"}},c=({type:e,...t})=>{const a=(0,i.iL)();return(0,l.jsx)(n.A,{alignWith:o(e),style:a?{opacity:s.xN,pointerEvents:"none",userSelect:"none"}:void 0,...t})}},14916(e,t,a){a.d(t,{A:()=>o});var l=a(274934),i=a(602086),s=a(497157),n=a(421291);const o=({htmlFor:e,searchHtmlFor:t,searchIgnore:a,searchIsApplicable:o,searchTags:c,searchText:r,...d})=>{const h=(0,n.A)(),m=(0,i.useRef)(null),g=h===e||h===t;return(0,i.useEffect)(()=>{if(g&&m.current){const{y:e}=m.current.getBoundingClientRect?.()||{y:0};(e<150||e+200>window.innerHeight)&&setTimeout(()=>{m.current?.scrollIntoView?.({behavior:"smooth",block:"center"})},50)}},[g]),(0,l.jsx)(s.A,{highlight:g,highlightType:"spotlight",htmlFor:t||e,forwardedRef:m,highlightNoAutoScroll:!0,...d})}}}]);