"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[3776],{151360:(e,t,i)=>{i.d(t,{A:()=>n});const n=(0,i(71479).A)("div",{shouldForwardProp:e=>"hidden"!==e&&"height"!==e})`
  /* 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  "}
`},923776:(e,t,i)=>{i.r(t),i.d(t,{default:()=>T});var n=i(296540),a=i(469733),s=i(617147),c=i(927099),l=i(162420),r=i(459449),o=i(845030),d=i(126457),u=i(323572),h=i(87485),m=i(171073),E=i(83344),_=i(675359),C=i(742920),p=i(224948),A=i(602021),g=i(151360),O=i(71479),f=i(822336),v=i(892145),I=i(238761);const b="site-radio",S=(0,O.A)(I.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;
  }

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