"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[84852],{952055(e,i,s){s.d(i,{A:()=>d});var t=s(247816),n=s(291508);const d=(0,t.A)("div",(0,n.A)("hidden","height"))`
  /* Height animation from UIC <Accordion/> */
  transition:
    height 300ms cubic-bezier(0.7, 0, 0.3, 1),
    opacity 100ms ease-in;
  height: ${e=>e.height}px; // cannot animate to height: auto
  opacity: 1;
  ${e=>e.hidden&&"\n    visibility: hidden;\n    height: 0;\n    min-height: unset;\n    opacity: 0;\n  "}
`},620627(e,i,s){s.d(i,{A:()=>h});var t=s(274934),n=s(938984),d=s(247816),a=s(309130),c=s(100978),l=s(535322);const r=(0,d.A)("div")`
  margin-right: ${a.kc};
`,o=(0,d.A)("div")`
  margin-left: ${a.kc};
`,h=({icon:e,closeIcon:i,nested:s,children:d,...a})=>(0,t.jsx)(l.A,{nested:s,...a,children:(0,t.jsxs)(c.A,{children:[(0,t.jsx)(r,{children:e}),(0,t.jsx)(n.A,{size:"medium",children:d}),i?(0,t.jsx)(o,{children:i}):null]})})},84852(e,i,s){s.r(i),s.d(i,{default:()=>S});var t=s(274934),n=s(602086),d=s(977872),a=s(938984),c=s(832162),l=s(853777),r=s(159469),o=s(620627),h=s(952055),u=s(205521),A=s(700444),m=s(869332),x=s(470070),_=s(401042),C=s(393629),g=s(561500),v=s(897166),E=s(795206),p=s(814557),f=s(860606),O=s(990330),I=s(247816);const j="site-radio",k=(0,I.A)(O.A)`
  margin: 10px 0;

  max-height: 192px;
  overflow-y: auto;

  &::-webkit-scrollbar-thumb {
    /* Workaround to fix missing scrollbar if too many entries (~100+) */
    min-height: 20px;
  }

  .${j} {
    border-radius: ${p.Ay["desktop-radius-base"]};
    padding-left: 6px;
    padding-right: 6px;
  }
`,b=({sites:e,selectedSiteId:i,onSelect:s})=>{const[d,a]=(0,n.useState)(),c=(0,n.useMemo)(()=>e.filter(({desc:e})=>!d||e?.toLowerCase().includes(d.toLowerCase())).map(({desc:e,_id:t})=>({children:e,id:t,onChange:()=>s(t),checked:t===i,className:j})),[s,d,i,e]);return(0,t.jsxs)(t.Fragment,{children:[e.length>6?(0,t.jsx)(f.A,{variant:"secondary",full:!0,value:d,onChange:(e,i)=>{a(i)},onClear:()=>{a(void 0)}}):null,(0,t.jsx)(k,{items:c,variant:"list",spacing:"flush"})]})},N=(e,i)=>i.find(({_id:i})=>e===i),S=({mac:e,deviceName:i})=>{const s=(0,d.wA)(),[p,f]=(0,n.useState)(null),O=(0,d.d4)(v.Gd),I=(0,d.d4)(v.n),j=(0,n.useCallback)(e=>{const i=N(e,I);i?e!==p?._id&&f(i):f(null)},[p,I]),k=(0,n.useCallback)(()=>{s((0,m.AS)())},[s]),S=(0,n.useCallback)(async()=>{if(!p)return;const t=N(p._id,I);if(!t)return s((0,A.ox)({type:r.C.danger,message:"DEVICE_ACTIONS_MOVE_ERROR_SITE_DOES_NOT_EXIST",values:{siteDesc:p.desc,deviceName:i}})),void k();const{failureToast:n}=(0,_.rk)("DEVICE_ACTIONS_MOVE_ERROR",{deviceName:i,siteDesc:t.desc});s((0,g.gM)(e,t._id)).then(()=>{s((0,E.XL)(e)),s((0,C.W)(e)),s((0,u.K5)()),k()}).catch(e=>s((0,A.ox)(n(null,e))))},[s,e,p,I,i,k]),T=(0,n.useMemo)(()=>[{type:"button",text:(0,t.jsx)(x.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:k},{type:"button",text:(0,t.jsx)(x.sA,{id:"DEVICE_MOVE_TO_SITE_ACTION"}),onClick:S,variant:"primary",disabled:!p}],[k,S,p]),y=(0,n.useMemo)(()=>I.filter(e=>{return!((i=e)._id===(s=O)._id&&i.desc===s.desc);var i,s}),[O,I]);return(0,t.jsxs)(c.A,{title:(0,t.jsx)(x.sA,{id:"DEVICE_ACTIONS_MOVE_TO_SITE"}),size:"small",onRequestClose:k,actions:T,isOpen:!0,allowOverflow:!0,children:[(0,t.jsx)(b,{sites:y,selectedSiteId:p?._id,onSelect:j}),(0,t.jsx)(h.A,{hidden:!p,height:76,children:(0,t.jsx)(o.A,{icon:(0,t.jsx)(l.A,{variant:"twoTone",isActive:!0}),nested:!0,children:(0,t.jsx)(a.A,{size:"small",children:p?(0,t.jsx)(x.sA,{id:"DEVICE_MOVE_WARNING",values:{siteDesc:p.desc}}):null})})})]})}}}]);