"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[5595],{785595:(e,t,a)=>{a.r(t),a.d(t,{default:()=>k});var n=a(296540),i=a(469733),l=a(673582),r=a(927099),c=a(951272),m=a(71479),s=a(459449),E=a(126457),A=a(768195),o=a(84909),u=a(6510),_=a(171073),C=a(742920),d=a(837612),I=a(566723),p=a(602197),N=a(388151),D=a(144813),O=a(813040),S=a(294303),T=a(532419),g=a(776309),R=a(734707);const f=(0,m.A)(R.Ay)`
  padding: 0;
  white-space: nowrap;
`,v=({device:e})=>{const t=(0,i.useDispatch)(),a=(0,i.useSelector)(T.qD);return n.createElement(f,{variant:"link",onClick:()=>{t((0,E.to)({modalType:g.A.ASSIGN_SMART_BATTERY,modalProps:{activeMacs:[e.mac]}}))},disabled:a.length<2},n.createElement(s.sA,{id:"DEVICE_ACTIONS_REASSIGN"}))};var h=a(252093),b=a(705426);const w=(0,m.A)(b.A)`
  width: 415px;
`,M=(0,m.A)(S.A)`
  background-color: ${({theme:{motifPalette:{neutral02:e}}})=>e};
  border-radius: 8px;
  height: 44px;
  padding: 9px;
`,y=({activeItem:e,isDirty:t})=>{const a=(0,i.useDispatch)(),{handleSubmit:m}=(0,c.j7)(),_=(0,n.useCallback)(()=>{a((0,E.AS)())},[a]),C=(0,d.S9)(e),T=(0,n.useMemo)(()=>C===p.g.UPGRADING||e.batteryState===A.Rv.POWER_DELIVER,[C,e.batteryState]);return n.createElement(w,{allowOverflow:!0,title:n.createElement(r.A,{weight:"bold",size:"header-xs"},n.createElement(s.sA,{id:"COMMON_ACTION_MANAGE_BATTERY"})),actions:[{text:n.createElement(s.sA,{id:"COMMON_ACTION_CANCEL"}),type:"button",onClick:_},{text:n.createElement(s.sA,{id:"COMMON_ACTION_SAVE"}),type:"submit",disabled:!t,variant:"primary",onClick:()=>{m(),_()}}],size:"small",onRequestClose:_},n.createElement(n.Fragment,null,n.createElement(N.A,{label:"COMMON_DEVICE_NAME",variant:"secondary",name:"name",full:!0}),T||(0,d.g8)(e)?n.createElement(M,{flexDirection:"row",justifyContent:"left",alignItems:"center",height:"36px"},n.createElement(S.A,{marginRight:I.kc},n.createElement(l.A,{size:"medium",isActive:!0})),n.createElement(r.A,{size:"caption"},n.createElement(s.sA,{id:T?"DEVICE_ACTIONS_UPDATE_IN_PROGRESS":e.upgrade_to_firmware?"DEVICE_ACTIONS_UPDATE_READY_DETAILED":"DEVICE_ACTIONS_UPDATE_READY",values:{deviceName:(0,u.Q)(e),version:e.upgrade_to_firmware}})),T?null:n.createElement(S.A,{marginLeft:"auto",justifyContent:"center",alignItems:"center",gap:15},n.createElement(o.A,{device:e,label:"COMMON_ACTION_UPDATE"}))):null,n.createElement(O.R,{flexDirection:"column"},n.createElement(S.A,{justifyContent:"space-between",alignItems:"center"},n.createElement(v,{device:e}),n.createElement(h.A,{messageId:"DEVICE_ACTIONS_REASSIGN_DEVICE_DESCRIPTION",tooltipClassName:"tooltip-position-fixer"})))),n.createElement(D.A,{activeItem:e}))},k=({activeItem:e})=>{const t=(0,i.useDispatch)(),a=(0,n.useMemo)(()=>({name:e.name}),[e.name]);return n.createElement(c.l1,{initialValues:a,onSubmit:async n=>{n.name!==a.name&&(await t((0,_.c8)({name:n.name},e._id,{failureToast:{icon:C.C.danger,message:"DEVICE_NOTICE_SAVE_ERROR"}})),await t((0,_.pI)(e.mac)))}},({dirty:t})=>n.createElement(y,{isDirty:t,activeItem:e}))}}}]);