"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[2737],{542737:(e,t,n)=>{n.r(t),n.d(t,{default:()=>Ie});var a,l=n(296540),r=n(951272),i=n(469733),E=n(585702),c=n(727270);!function(e){e.EXPORT_SITE="export-site",e.MIGRATE_SITE="migrate-site",e.MIGRATE_DEVICES="migrate-devices"}(a||(a={}));const o="http://",m=":",s="/inform",d={inform_ip:"",inform_port:8080,macs:[]};var A=n(71479),I=n(459449),T=n(126457),_=n(532419),u=n(705426),C=n(758649),S=n(294303),O=n(566723),N=n(927099),M=n(323572),R=n(83344),h=n(675359),g=n(742920),p=n(171073);const b=({handleRemoveModalClose:e,handleExportModalClose:t})=>{const{values:n}=(0,r.j7)(),a=(0,i.useDispatch)(),E=(0,l.useCallback)(()=>{a((0,M.Yl)(n.macs)).then(()=>{n.macs.forEach(e=>{a((0,R.W)(e)),a((0,p.XL)(e))}),e(),t()}).catch(()=>{a((0,h.ox)({icon:g.C.danger,message:"API_ERROR_DEVICE_REMOVE"}))})},[a,t,e,n.macs]);return l.createElement(u.A,{title:l.createElement(I.sA,{id:"DEVICE_ACTIONS_REMOVE_LABEL_PLURAL"}),onRequestClose:e,actions:[{type:"button",text:l.createElement(I.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:e},{type:"button",text:l.createElement(I.sA,{id:"COMMON_ACTION_REMOVE"}),onClick:E,variant:"danger"}],size:"small"},l.createElement(N.A,{size:"body",color:"secondary"},l.createElement(I.sA,{id:"DEVICE_ACTIONS_REMOVE_CONFIRM_MESSAGE_PLURAL"})))},f=(0,A.A)("footer")`
  padding: ${O.S2} ${O.fS};
`,G=(0,A.A)("div")`
  margin-left: ${O.Ln};
`,v=({handleCancel:e,hasMigrationStarted:t,isMigrateActionEnabled:n})=>{const{handleSubmit:a}=(0,r.j7)(),[i,E]=(0,l.useState)();return l.createElement(l.Fragment,null,l.createElement(f,null,l.createElement(S.A,{alignItems:"center",justifyContent:"flex-end"},l.createElement(C.A,{type:"button",size:"medium",onClick:e},l.createElement(I.sA,{id:"COMMON_ACTION_SKIP"})),l.createElement(G,null,l.createElement(C.A,{type:"button",variant:t?"danger":"primary",onClick:t?()=>{E(!0)}:()=>{a()},disabled:!t&&!n},l.createElement(I.sA,{id:t?"DEVICE_ACTIONS_REMOVE_LABEL_PLURAL":"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES"}))))),i?l.createElement(b,{handleRemoveModalClose:()=>E(!1),handleExportModalClose:e}):null)},y=(0,A.A)("div")`
  margin-left: 16px;
`,x=(0,A.A)("footer")`
  padding: 24px 32px;
`,D=({handleNextStep:e,handleCancel:t})=>l.createElement(x,null,l.createElement(S.A,{alignItems:"center",justifyContent:"flex-end"},l.createElement(C.A,{type:"button",size:"medium",onClick:t},l.createElement(I.sA,{id:"COMMON_ACTION_CANCEL"})),l.createElement(y,null,l.createElement(C.A,{type:"button",size:"medium",variant:"primary",onClick:e},l.createElement(I.sA,{id:"COMMON_ACTION_CONTINUE"}))))),U=(0,A.A)(N.A)`
  margin: 32px 0 20px;
`;const L=function(){return l.createElement(S.A,null,l.createElement(U,{size:"body"},l.createElement(I.sA,{id:"SETTINGS_SITE_CONFIGURATION_MIGRATE_SITE_INSTRUCTION"})))};var V=n(332918),F=n(418562),P=n(441652),w=n(602021);const z=(0,A.A)(N.A)`
  margin: 32px 0 20px;
`,k=()=>{const{formatMessage:e}=(0,I.tz)(),t=(0,i.useDispatch)(),n=(0,i.useSelector)(w.Gd),[a,r]=(0,l.useState)(!1),E=n?.desc||"",c=(0,l.useCallback)(()=>{r(!0);const n=(0,F.A)();t((0,h.ox)({id:n,downloads:[{id:`file-${n}`,filename:e({id:"SETTINGS_SYSTEM_MAINTENANCE_SUPPORT_INFORMATION_PREPARING"}),status:e({id:"SETTINGS_SYSTEM_MAINTENANCE_SUPPORT_INFORMATION_FETCHING"}),progress:0,onCancel:()=>{t((0,h.uU)(n)),r(!1)}}],duration:0,notificationType:"DownloadsToast"})),t((0,M.p5)()).then(({data:e})=>{t((0,P.LV)(e?.[0]?.url,n,()=>r(!1)))}).catch(()=>{r(!1),(0,h.uU)(n),t((0,h.ox)({icon:g.C.danger,message:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE_ERROR",values:{siteName:E}}))})},[E,t,e]);return l.createElement(S.A,{flexDirection:"column"},l.createElement(z,{size:"body"},l.createElement(I.sA,{id:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE_INSTRUCTION"})),l.createElement(S.A,null,l.createElement(C.A,{name:"download-current-site",type:"button",variant:"inline",size:"medium",Icon:V.A,iconProps:{size:"original",isActive:!a},onClick:c,disabled:a},l.createElement(I.sA,{id:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE_DOWNLOAD_BUTTON"}))))};var H=n(162420),$=n(963070),W=n(822336);const j=(0,A.A)(S.A)`
  width: 100%;
  padding: 14px 16px;
  background: ${({theme:{motifPalette:{neutral02:e}}})=>e};
  border-radius: ${W.Ay["desktop-radius-base"]};

  > svg {
    margin-right: 12px !important;
  }
`,X=({children:e})=>l.createElement(j,null,e);var B=n(596441),Y=n(870443),q=n(559478),K=n(546391),J=n(243938),Q=n(6176),Z=n(6510),ee=n(602197);const te=[{id:"status",label:null,renderCell:({status:e,statusPulse:t})=>l.createElement(q.A,{status:e,pulsating:t,marginLeft:O.YC,marginRight:O.xO}),growthFactor:1,minWidth:30},{id:"name",label:l.createElement(I.sA,{id:"COMMON_NAME"}),renderCell:({name:e,model:t})=>l.createElement(S.A,{width:"100%"},l.createElement(Q.A,{model:t,width:"18px",height:"18px"}),l.createElement(N.A,{size:"body",truncate:!0,color:"inherit",style:{marginLeft:12}},e)),minWidth:60},{id:"state",label:l.createElement(I.sA,{id:"COMMON_STATUS"}),renderCell:({state:e})=>{let t="warning";return t=e===ee.g.CONNECTED?"success":e===ee.g.DISCONNECTED?"secondary":"warning",l.createElement(N.A,{color:t,size:"body"},l.createElement(I.sA,{id:J.A[e]}))},minWidth:50},{id:"model",label:l.createElement(I.sA,{id:"COMMON_MODEL"}),renderCell:({model:e})=>l.createElement(N.A,{truncate:!0,color:"inherit",size:"body"},(0,Z.Lm)(e)),minWidth:60},{id:"fw_version",label:l.createElement(I.sA,{id:"COMMON_VERSION"}),renderCell:({fw_version:e})=>l.createElement(N.A,{truncate:!0,color:"inherit",size:"body"},e?.length>0?e:l.createElement(I.sA,{id:"COMMON_FALLBACK"})),minWidth:60}],ne=Y.A.object().shape({inform_ip:Y.A.string().label("COMMON_LABEL_HOSTNAME_IP").matches(K.vz,{message:l.createElement(I.sA,{id:"COMMON_VALIDATION_VALID_IP"})}).required(),inform_port:Y.A.number().label("COMMON_PORT").required()}),ae=(0,A.A)("div")`
  margin: 32px 0 20px;
`,le=({removeTableItems:e})=>l.createElement(S.A,{flexDirection:"column"},l.createElement(ae,null,l.createElement($.A,{idField:"mac",columns:te,items:e,headerHeight:32,rowHeight:B.I.ROW_HEIGHT,disableColumnFilters:!0,truncateHeaderCells:!0})),l.createElement(X,null,l.createElement(H.A,{size:"original",isActive:!0,variant:"fill"}),l.createElement(N.A,{size:"body"},l.createElement(I.sA,{id:"SETTINGS_SITE_CONFIGURATION_REMOVE_MIGRATED_DEVICES",values:{b:I.b,br:I.br}}))));var re=n(388151);const ie=(0,A.A)("div")`
  margin: ${O.fS} 0 ${O.Er};
`,Ee=(0,A.A)(N.A)`
  margin: ${O.fS} 0 ${O.Er};
`,ce=(0,A.A)(N.A)`
  margin: 0 ${O.kc};
`,oe=(0,A.A)("div")`
  width: 50%;
`,me=[],se=({migrateTableItems:e})=>{const{setFieldValue:t}=(0,r.j7)();return l.createElement(S.A,{flexDirection:"column"},l.createElement(Ee,{size:"body"},l.createElement(I.sA,{id:"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES_INSTRUCTION"})),l.createElement(S.A,{alignItems:"baseline"},l.createElement(ce,{size:"body",color:"tertiary"},o),l.createElement(re.A,{name:"inform_ip",variant:"secondary",label:"COMMON_LABEL_HOSTNAME_IP",helperMessage:"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES_INPUT_HELPER",full:!0}),l.createElement(ce,{size:"body",color:"tertiary"},m),l.createElement(oe,null,l.createElement(re.A,{name:"inform_port",variant:"secondary",label:"COMMON_PORT",full:!0})),l.createElement(ce,{size:"body",color:"tertiary"},s)),l.createElement(ie,null,e.length>0?l.createElement($.A,{idField:"mac",columns:te,items:e,initialSelectedIds:me,onChangeSelection:e=>{t("macs",e)},headerHeight:32,rowHeight:B.I.ROW_HEIGHT,multiSelectMode:!0,truncateHeaderCells:!0,disableColumnFilters:!0}):l.createElement(X,null,l.createElement(H.A,{size:"original",isActive:!0,variant:"fill"}),l.createElement(N.A,{size:"body"},l.createElement(I.sA,{id:"SETTINGS_SITE_CONFIGURATION_MIGRATE_NO_DEVICES"})))))},de=(0,A.A)(u.A)`
  width: 600px !important;
`,Ae=({hasMigrationStarted:e})=>{const t=(0,i.useDispatch)(),{values:{inform_ip:n,inform_port:E,macs:c}}=(0,r.j7)(),[o,m]=(0,l.useState)(a.EXPORT_SITE),s=(0,i.useSelector)((0,l.useMemo)(()=>(0,_.lj)(e),[e])),d=(0,l.useMemo)(()=>s.filter(({mac:e})=>c.includes(e)),[s,c]),A=n&&E&&c.length>0,u=(0,l.useCallback)(()=>{t((0,T.AS)())},[t]),C=(0,l.useCallback)(()=>{switch(o){case a.MIGRATE_DEVICES:return{modalTitle:"SETTINGS_SITE_CONFIGURATION_MIGRATE_DEVICES",modalFooter:l.createElement(v,{handleCancel:u,hasMigrationStarted:e,isMigrateActionEnabled:A}),modalViewContent:e?l.createElement(le,{removeTableItems:d}):l.createElement(se,{migrateTableItems:s})};case a.MIGRATE_SITE:return{modalTitle:"SETTINGS_SITE_CONFIGURATION_MIGRATE_SITE",modalFooter:l.createElement(D,{handleNextStep:()=>{m(a.MIGRATE_DEVICES)},handleCancel:u}),modalViewContent:l.createElement(L,null)};case a.EXPORT_SITE:default:return{modalTitle:"SETTINGS_SITE_CONFIGURATION_EXPORT_SITE",modalFooter:l.createElement(D,{handleNextStep:()=>{m(a.MIGRATE_SITE)},handleCancel:u}),modalViewContent:l.createElement(k,null)}}},[u,e,A,s,o,d]),{modalTitle:S,modalFooter:O,modalViewContent:N}=C();return l.createElement(de,{title:l.createElement(I.sA,{id:S}),footer:O,size:"medium"},N)},Ie=()=>{const e=(0,i.useDispatch)(),[t,n]=(0,l.useState)(!1),a=(0,l.useCallback)(t=>{const a={deviceMacs:t.macs,informUrl:`${c.DU}${t.inform_ip}:${t.inform_port}/inform`};n(!0),e((0,E.du)(a)).catch(()=>{n(!1)})},[e]);return l.createElement(r.l1,{initialValues:d,onSubmit:a,validationSchema:ne},l.createElement(Ae,{hasMigrationStarted:t}))}}}]);