"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[63170],{63170(e,t,i){i.r(t),i.d(t,{default:()=>V});var a=i(274934),s=i(814557),n=i(602086),l=i(977872),r=i(843871),A=i(938984),c=i(343601),d=i(247816),o=i(347625),m=i(159469),E=i(309130),_=i(869332),I=i(470070),C=i(605076),u=i(434521),x=i(857780),N=i(45978),j=i(795206),h=i(721398),p=i(532635),D=i(956731),O=i(120197),T=i(100978),g=i(590979),S=i(815436),R=i(754924),v=i(648576);const w=(0,d.A)(v.Ay)`
  padding: 0;
  white-space: nowrap;
`,f=({device:e})=>{const t=(0,l.wA)(),i=(0,l.d4)(R.qD);return(0,a.jsx)(w,{variant:"link",onClick:()=>{t((0,_.to)({modalType:S.A.ASSIGN_SMART_BATTERY,modalProps:{activeMacs:[e.mac]}}))},disabled:i.length<2,...g.A.addDataTestId(g.A.TestId.MODAL_TRIGGER),children:(0,a.jsx)(I.sA,{id:"DEVICE_ACTIONS_REASSIGN"})})};var b=i(384783);const M=(0,d.A)(b.A)`
  width: 415px;
`,y=(0,d.A)(T.A)`
  background-color: ${({theme:{themeName:e}})=>s.Ay[`desktop-color-neutral-02-${e}`]};
  border-radius: 8px;
  height: 44px;
  padding: 9px;
`,k=({activeItem:e,isDirty:t})=>{const i=(0,l.wA)(),{handleSubmit:s}=(0,r.j7)(),d=(0,n.useCallback)(()=>{i((0,_.AS)())},[i]),m=(0,u.S9)(e),j=(0,n.useMemo)(()=>m===N.g.UPGRADING||e.batteryState===x.Rv.POWER_DELIVER,[m,e.batteryState]);return(0,a.jsxs)(M,{allowOverflow:!0,title:(0,a.jsx)(A.A,{weight:"bold",size:"large",children:(0,a.jsx)(I.sA,{id:"COMMON_ACTION_MANAGE_BATTERY"})}),actions:[{text:(0,a.jsx)(I.sA,{id:"COMMON_ACTION_CANCEL"}),type:"button",onClick:d},{text:(0,a.jsx)(I.sA,{id:"COMMON_ACTION_SAVE"}),type:"submit",disabled:!t,variant:"primary",onClick:()=>{s(),d()}}],size:"small",onRequestClose:d,children:[(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(O.A,{label:"COMMON_DEVICE_NAME",variant:"secondary",name:"name",full:!0}),j||(0,u.g8)(e)?(0,a.jsxs)(y,{flexDirection:"row",justifyContent:"left",alignItems:"center",height:"36px",children:[(0,a.jsx)(T.A,{marginRight:E.kc,children:(0,a.jsx)(c.A,{size:"medium",isActive:!0})}),(0,a.jsx)(A.A,{size:"small",children:(0,a.jsx)(I.sA,{id:j?"DEVICE_ACTIONS_UPDATE_IN_PROGRESS":e.upgrade_to_firmware?"DEVICE_ACTIONS_UPDATE_READY_DETAILED":"DEVICE_ACTIONS_UPDATE_READY",values:{deviceName:(0,o.Q)(e),version:e.upgrade_to_firmware}})}),j?null:(0,a.jsx)(T.A,{marginLeft:"auto",justifyContent:"center",alignItems:"center",gap:15,children:(0,a.jsx)(C.A,{device:e,label:"COMMON_ACTION_UPDATE"})})]}):null,(0,a.jsx)(D.R,{flexDirection:"column",children:(0,a.jsxs)(T.A,{justifyContent:"space-between",alignItems:"center",children:[(0,a.jsx)(f,{device:e}),(0,a.jsx)(h.A,{messageId:"DEVICE_ACTIONS_REASSIGN_DEVICE_DESCRIPTION",tooltipClassName:"tooltip-position-fixer"})]})})]}),(0,a.jsx)(p.A,{activeItem:e})]})},V=({activeItem:e})=>{const t=(0,l.wA)(),i=(0,n.useMemo)(()=>({name:e.name}),[e.name]);return(0,a.jsx)(r.l1,{initialValues:i,onSubmit:async a=>{a.name!==i.name&&(await t((0,j.c8)({name:a.name},e._id,{failureToast:{icon:m.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}})),await t((0,j.pI)(e.mac)))},children:({dirty:t})=>(0,a.jsx)(k,{isDirty:t,activeItem:e})})}}}]);