"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[61114],{341149(e,_,t){t.d(_,{D:()=>s});var i=t(29472);const n=`${t(290454).J}/stat/device`,s=(e,_)=>(0,i.Kd)("deviceCfg",`${n}/${e}`,e,void 0,{idField:"mac",fetchConfig:{params:_}})},547967(e,_,t){t.d(_,{AC:()=>O,D7:()=>N,Ie:()=>p,JL:()=>A,JX:()=>h,KY:()=>R,O2:()=>E,Op:()=>c,Rm:()=>m,e$:()=>I,t7:()=>T,yr:()=>S});var i=t(938984),n=t(814557),s=t(247816),a=t(409844),r=t(291508),o=t(61322),l=t(309130),d=t(100978);const c=(0,s.A)(d.A,(0,r.A)("inline","wrap"))`
  position: relative;
  flex: ${({inline:e})=>e?"1 1 0":"0 0 100%"};
  align-items: flex-start;
  flex-flow: ${({wrap:e})=>"row "+(e?"wrap":"nowrap")};
  gap: ${l.kc};
`,E=(0,s.A)(d.A,(0,r.A)("editMaxHeight","editFieldWrap"))`
  flex-direction: column;
  max-height: ${({editMaxHeight:e})=>`${e||300}px`};
  overflow-y: auto;
  overflow-x: hidden;
  gap: ${l.YC};

  ${({editFieldWrap:e,theme:{themeName:_}})=>e?`\n    gap: 0;\n\n    > * {\n      border-bottom: ${n.Ay[`desktop-border-divider-${_}`]};\n      padding-bottom: ${l.kc};\n      padding-top: ${l.kc};\n    }\n\n    > *:first-child {\n      padding-top: 0;\n    }\n\n    > *:last-child {\n      border-bottom: none;\n      padding-bottom: 0;\n    }\n  `:""}
`,O=(0,s.A)("div",(0,r.A)("isWindowsTable","rows","tableMaxHeight","marginTop"))`
  width: 100%;
  // windows table inherits height from parent container
  height: ${({rows:e,isWindowsTable:_})=>_&&`${o.I.ROW_HEIGHT*e+o.I.HEADER_HEIGHT}`}px;
  max-height: ${({tableMaxHeight:e})=>e?`${e}px`:"auto"};
  margin-top: ${({marginTop:e})=>e||l.Ln};

  table {
    td {
      max-width: 170px;

      span {
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
`,N=(0,s.A)(i.A)`
  margin-right: ${l.YC};
`,R=a.AH`
  :first-of-type {
    padding: 0 ${l.fS} 0 0px;
  }
`,m="drag-and-drop-table-row-placeholder",T=(0,s.A)(d.A)`
  flex-direction: column;

  /* Adjust weird padding on the right side for the ID column when right aligned (drag & drop table) */
  table > thead > tr > th:last-of-type {
    padding-right: ${l.kc};
  }

  /* Add missing border between drag and drop groups (tbody elements) */
  table > tbody {
    border-bottom: ${({theme:{themeName:e}})=>n.Ay[`desktop-border-divider-${e}`]};
  }
  /* Last cell in table is hover content which is not used in this table */
  table > tbody[data-rbd-droppable-context-id] td:not(:last-of-type),
  table > thead > tr > th {
    /* Align drag & drop table cell padding to regular table padding */
    padding-right: ${l.kc} !important;
  }
  /* Align drop zone placeholder row when a row is dragged to matched the CSS overrides for drag and drop table we use */
  table .${m} {
    display: flex;
  }
`,A=a.AH`
  /* This is default for the table rows, so we need it for the header. */
  display: flex;
  width: 100%;

  > th:first-child {
    /* Since we flex the header, we must specify this to align with the table rows. */
    width: 24px;
  }
  > th:not(:first-child) {
    /* Something inside UIC sets the padding to 8px for table header and 5px for table rows. This aligns it to make flex work. */
    padding-right: ${l.kc} !important;
  }
`,I=a.AH`
  /* Override the padding-right of the first column to align with manage + drop modes. */
  > th:first-child {
    padding-right: ${l.kc} !important;
  }
  > th:first-child:has(> label) {
    padding-right: 1px !important;
    width: 36px;
  }
`,S=a.AH`
  /* UIC already does this for some table states, like drag and drop and when in manage mode. If we just use this ALWAYS, we're avoiding many issues related to using different alignment techniques in different places. */
  display: flex;
`,h=a.AH`
  tbody {
    display: flex;
    flex-direction: column;
  }
`;function p(e,_){return a.AH`
    width: ${_.width?`${_.width}px`:"auto"};
    min-width: ${_.minWidth?`${_.minWidth}px`:"0px"};
    flex: ${_.growthFactor||0} !important;
    padding-left: ${l.kc} !important;
    padding-right: ${l.kc} !important;
  `}},256468(e,_,t){var i;t.d(_,{EE:()=>s,Uh:()=>i,Vf:()=>n}),function(e){e.SINGLE="single",e.PLURAL="plural"}(i||(i={}));const n="editActive",s=20},711921(e,_,t){t.r(_),t.d(_,{default:()=>te});var i=t(274934),n=t(602086),s=t(977872),a=t(843871),r=t(950804);const o=r.A.string().label("COMMON_NETWORK_NAME").required().min(2).max(32);var l=t(205521),d=t(449339),c=t(180847),E=t(547120),O=t(703826);const N=e=>e.reduce((e,_)=>("DEVICE"===_.type?e.device_mac_list.push(_.mac):e.client_mac_list.push(_.mac),e),{device_mac_list:[],client_mac_list:[]}),R=e=>({mac:e.mac,type:e.type,name:e.name});var m=t(313401),T=t(125799),A=t(938984),I=t(599110),S=t(749888),h=t(347625),p=t(309130),u=t(291950),g=t(927728),M=t(309675),f=t(115114),W=t(146215),x=t(250266),C=t(120197),b=t(555612),K=t(100978),w=t(612389),U=t(821773),L=t(535322),j=t(969819),P=t(254585),v=t(470070),D=t(192967),k=t(286231),V=t(626879),F=t(423564),y=t(197571),G=t(754924),Y=t(34118),$=t(720770),B=t(95032),H=t(920679),q=t(493978),z=t(650632),X=t(670830);const J=()=>(0,i.jsxs)(K.A,{gap:p.kc,alignItems:"center",children:[(0,i.jsx)(H.A,{isActive:!0,size:"large"}),(0,i.jsx)(A.A,{size:"medium",color:"text-2",children:(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_SIDEPANEL_EMPTY_DEVICES"})})]}),Q=({item:{mac:e,name:_}})=>{const t=(0,s.d4)((0,n.useMemo)(()=>(0,Y.og)(e),[e])),a=(0,s.d4)((0,n.useMemo)(()=>(0,X.i7)(e),[e]));return(0,i.jsxs)(K.A,{alignItems:"center",gap:p.xO,height:"100%",children:[(0,i.jsx)(K.A,{height:"100%",minWidth:30,maxWidth:30,alignItems:"center",justifyContent:"center",children:(0,i.jsx)(z.A,{client:Object.keys(t).length?t:a})}),(0,i.jsx)(B.A,{size:"inherit",isTruncated:!0,children:_})]})},Z=()=>{const e=(0,s.d4)(c.k0),_=(0,s.wA)();return e.length>0?(0,i.jsx)(q.Ay,{idField:"mac",multiSelectMode:!0,disableColumnFilters:!0,columns:[{id:"mac",label:(0,i.jsx)(v.sA,{id:"COMMON_NAME"}),renderCell:e=>(0,i.jsx)(Q,{item:e})}],items:e,isRemovable:()=>!0,removeItems:async e=>{e.forEach(e=>{_((0,O.X8)(e))})}}):(0,i.jsx)(J,{})},ee=()=>{const{values:e,initialValues:_,submitForm:t,setValues:r}=(0,a.j7)(),{formatMessage:o}=(0,v.tz)(),d=(0,s.wA)(),B=(0,s.d4)(c.k0),H=(0,s.d4)(V.o),q=H.vertices?.map(R)||(0,$.A)(),z=(0,s.d4)(D.F0),X=(0,s.d4)(P.gm),J=!!X&&X!==m.PANEL_VISUAL_PROGRAMMING_ID,Q=J?X:"",ee=(0,s.d4)(y.Ct),_e=(0,s.d4)(y.Tn),te=(0,s.d4)(G.Kh),ie=(0,s.d4)(Y.Cx),{forceDeleteModal:ne,removeNetworks:se}=(0,U.G)({genericErrorMessage:"COMMON_NETWORKS_MANAGE_REMOVE_ERROR",deletionSuccessCallback:()=>{d((0,l.K5)())}}),[ae,re]=(0,n.useState)(!1),[oe,le]=(0,n.useState)({..._,device_mac_list:[],client_mac_list:[]}),de=(0,n.useCallback)(()=>{se([{_id:Q,name:oe.name}])},[se,Q,oe.name]),ce=(0,n.useMemo)(()=>{const{device_mac_list:_,client_mac_list:t}=N(B);return e.name!==oe.name||e.internet_access_enabled!==oe.internet_access_enabled||e.network_isolation_enabled!==oe.network_isolation_enabled||!(0,S.L)(_,oe.device_mac_list)||!(0,S.L)(t,oe.client_mac_list)},[e,B,oe]),Ee=(0,n.useCallback)(()=>{const{device_mac_list:_,client_mac_list:i}=N(B);le({name:e.name,network_isolation_enabled:e.network_isolation_enabled,internet_access_enabled:e.internet_access_enabled,device_mac_list:_,client_mac_list:i,id:Q}),t()},[B,e.name,e.network_isolation_enabled,e.internet_access_enabled,Q,t]),Oe=(0,n.useRef)(0),Ne=(0,n.useCallback)(()=>{let t={...E.g};const i=ee.find(e=>e._id===Q);if(J&&i){const e=((e,_,t)=>{const i=(_[e]||[]).map(e=>e.id);return t.filter(e=>i.includes(e.mac))})(Q,z,q),{client_mac_list:n,device_mac_list:s}=N(e);d((0,O.Vq)(e)),Oe.current=n.length+s.length,t={network_isolation_enabled:i?.network_isolation_enabled??_.network_isolation_enabled,internet_access_enabled:i?.internet_access_enabled??_.internet_access_enabled,name:i?.name??_.name,device_mac_list:s,client_mac_list:n,id:Q}}r({...e,id:Q,network_isolation_enabled:t.network_isolation_enabled,internet_access_enabled:t.internet_access_enabled,name:t.name}),le(t)},[ee,Q,r,e,z,q,d,_.network_isolation_enabled,_.internet_access_enabled,_.name]);(0,n.useEffect)(()=>{J&&(z[Q]?.length??0)!==Oe.current&&Ne()},[Q,z]),(0,n.useEffect)(()=>{Q!==oe.id&&Ne()},[Q]);const Re=(0,n.useMemo)(()=>ee.find(e=>e._id===Q),[ee,Q]),me=Re?(0,F.gm)(Re):o({id:"TOPOLOGY_VP_VLAN_FALLBACK_NAME"}),Te=(0,n.useMemo)(()=>{if(!J||!B.length)return[];const e=[];for(const{mac:_,type:t}of B)if(t===k.Z.DEVICE){const t=te.get(_);if(!t)continue;const{remotePort:i}=(0,j.uj)(t,te);if((0,j.GJ)(i,Q)){const _=t.uplink?.uplink_mac??t.last_uplink?.uplink_mac,n=_?te.get(_):void 0;e.push({entityName:(0,h.Q)(t),switchName:n?(0,h.Q)(n):_||"",port:i?.port_idx||0})}}else{const t=ie.get(_);if(!t)continue;const i=(0,j.Xs)("uplink_mac"in t?t.uplink_mac:void 0,"sw_port"in t?t.sw_port:void 0,Q,te,_e);i&&e.push({entityName:t.display_name||t.name||_,switchName:i.switchName,port:i.port})}return e},[Q,B,te,ie,_e]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(L.A,{children:(0,i.jsxs)(K.A,{flexDirection:"column",gap:p.Ln,children:[(0,i.jsx)(C.A,{label:"COMMON_NETWORK_NAME",name:"name",full:!0,variant:"secondary"}),(0,i.jsx)(C.A,{name:"network_isolation_enabled",type:"realCheckbox",children:(0,i.jsxs)(K.A,{alignItems:"center",gap:p.YC,children:[(0,i.jsx)(v.sA,{id:"COMMON_ISOLATE_NETWORK"}),(0,i.jsx)(T.A,{description:(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_SIDEPANEL_NETWORK_ISOLATION_TOOLTIP"}),position:"bottom",width:200,children:(0,i.jsx)(u.a,{isActive:!0,size:"original"})})]})}),(0,i.jsx)(C.A,{name:"internet_access_enabled",type:"realCheckbox",children:(0,i.jsx)(v.sA,{id:"COMMON_ALLOW_INTERNET_ACCESS"})})]})}),(0,i.jsx)(L.A,{children:(0,i.jsx)(Z,{})}),1===Te.length?(0,i.jsx)(L.A,{children:(0,i.jsx)(w.A,{icon:(0,i.jsx)(M.A,{}),description:(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFLICT_WARNING_SINGLE",values:{networkName:me,switchName:Te[0].switchName,port:Te[0].port}})})}):null,Te.length>1?(0,i.jsx)(L.A,{children:(0,i.jsx)(w.A,{icon:(0,i.jsx)(M.A,{}),description:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFLICT_WARNING_MULTI",values:{networkName:me}}),(0,i.jsx)(g.A,{children:Te.map(({entityName:e,switchName:_,port:t})=>(0,i.jsx)("li",{children:(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFLICT_ITEM",values:{entityName:e,switchName:_,port:t}})},`${e}-${_}-${t}`))})]})})}):null,J?(0,i.jsx)(L.A,{children:(0,i.jsx)(K.A,{children:(0,i.jsx)(x.A,{title:"COMMON_QUESTION_REMOVE",titleValues:{name:oe.name},buttonMessage:"COMMON_ACTION_PROCEED",buttonVariant:"danger",handleClose:re,handleConfirm:de,isOpen:ae,body:(0,i.jsx)(A.A,{size:"inherit",children:(0,i.jsx)(v.sA,{id:"COMMON_QUESTION_ARE_YOU_SURE_YOU_WANT_TO_REMOVE",values:{name:oe.name}})}),children:(0,i.jsx)(I.A,{type:"button",variant:"inline",size:"medium",onClick:()=>re(!0),children:(0,i.jsx)(A.A,{size:"medium",color:"red-06",children:(0,i.jsx)(v.sA,{id:"COMMON_ACTION_REMOVE"})})})})})}):null,(0,i.jsx)(f.A,{isDirty:ce,onFormCancel:()=>{r({...e,name:oe.name,internet_access_enabled:oe.internet_access_enabled,network_isolation_enabled:oe.network_isolation_enabled});const _=[...oe.device_mac_list,...oe.client_mac_list],t=q.filter(e=>_.includes(e.mac));d((0,O.Vq)(t))},applyButton:Te.length>0?(0,i.jsx)(W.A,{onConfirm:Ee,trigger:(0,i.jsx)("span",{children:(0,i.jsx)(b.A,{showWarning:!0})}),title:(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFIRM_TITLE"}),message:1===Te.length?(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFLICT_WARNING_SINGLE",values:{networkName:me,switchName:Te[0].switchName,port:Te[0].port}}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFLICT_WARNING_MULTI",values:{networkName:me}}),(0,i.jsx)(g.A,{children:Te.map(({entityName:e,switchName:_,port:t})=>(0,i.jsx)("li",{children:(0,i.jsx)(v.sA,{id:"TOPOLOGY_VP_VLAN_CONFLICT_ITEM",values:{entityName:e,switchName:_,port:t}})},`${e}-${_}-${t}`))})]})}):(0,i.jsx)(b.A,{showWarning:!0,onSubmit:Ee})}),ne]})},_e=r.A.object().shape({name:o,network_isolation_enabled:r.A.boolean().required(),internet_access_enabled:r.A.boolean().required()}),te=({activeItem:e})=>{const _=(0,s.wA)(),t=(0,s.d4)(c.k0),r=e._id===m.PANEL_VISUAL_PROGRAMMING_ID,o="name"in e;(0,n.useEffect)(()=>()=>{_((0,O.oq)())},[_]);const R=(0,n.useCallback)(i=>{const{device_mac_list:n,client_mac_list:s}=N(Object.values(t)),a=r?void 0:e._id;_((0,O.P$)({...i,device_mac_list:n,client_mac_list:s,id:a})).then(e=>{const t=a||e?.data?.networkconf?._id;t&&_((0,l.XP)({type:d.H.VISUAL_PROGRAMMING,id:t}))})},[_,t,r,e._id]),T=o?{...E.g,name:e.name,internet_access_enabled:e.internet_access_enabled??!0,network_isolation_enabled:e.network_isolation_enabled??!1}:{...E.g,internet_access_enabled:!0,network_isolation_enabled:!1};return(0,i.jsx)(a.l1,{initialValues:T,validationSchema:_e,onSubmit:R,children:(0,i.jsx)(ee,{})},e._id)}},821773(e,_,t){t.d(_,{G:()=>k});var i=t(274934),n=t(602086),s=t(977872),a=t(508659),r=t(159469),o=t(793442),l=t(700444),d=t(470070),c=t(549059),E=t(301940),O=t(598990),N=t(619046),R=t(775211),m=t(553732),T=t(62749),A=t(897166),I=t(20148),S=t(754924),h=t(795206),p=t(341149),u=t(634788),g=t(726831),M=t(352210),f=t(200500),W=t(596603),x=t(309130),C=t(384783),b=t(100978),K=t(396489),w=t.n(K),U=t(501558),L=t(197571);var j;!function(e){e.NETWORK_IS_USED_BY_CLIENT_AS_VIRTUAL_NETWORK="NETWORK_IS_USED_BY_CLIENT_AS_VIRTUAL_NETWORK",e.NETWORK_IS_USED_IN_FIREWALL_RULE="NETWORK_IS_USED_IN_FIREWALL_RULE",e.NETWORK_IS_USED_BY_HONEYPOT="NETWORK_IS_USED_BY_HONEYPOT",e.NETWORK_IS_USED_AS_MANAGEMENT_VLAN="NETWORK_IS_USED_AS_MANAGEMENT_VLAN",e.NETWORK_IS_USED_IN_PORT_FORWARD="NETWORK_IS_USED_IN_PORT_FORWARD",e.NETWORK_IS_USED_IN_ROUTING_AS_INTERFACE_ROUTE="NETWORK_IS_USED_IN_ROUTING_AS_INTERFACE_ROUTE",e.NETWORK_IS_USED_BY_WIFI_AS_NETWORK="NETWORK_IS_USED_BY_WIFI_AS_NETWORK",e.FIXED_IP_OVERLAPS_NETWORK_SUBNET="FIXED_IP_OVERLAPS_NETWORK_SUBNET",e.NETWORK_IS_USED_BY_WIFI_IN_PPSK="NETWORK_IS_USED_BY_WIFI_IN_PPSK",e.NETWORK_IS_USED_IN_OSPF_ROUTE="NETWORK_IS_USED_IN_OSPF_ROUTE",e.NETWORK_IS_USED_IN_NAT_RULES="NETWORK_IS_USED_IN_NAT_RULES",e.NETWORK_IS_USED_BY_AUTO_IGMP_SNOOPING="NETWORK_IS_USED_BY_AUTO_IGMP_SNOOPING",e.NETWORK_IS_USED_BY_PORT_NATIVE_NETWORK="NETWORK_IS_USED_BY_PORT_NATIVE_NETWORK"}(j||(j={}));const P={[j.NETWORK_IS_USED_BY_CLIENT_AS_VIRTUAL_NETWORK]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_BY_CLIENT_AS_VIRTUAL_NETWORK",[j.NETWORK_IS_USED_IN_FIREWALL_RULE]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_IN_FIREWALL_RULE",[j.NETWORK_IS_USED_BY_HONEYPOT]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_BY_HONEYPOT",[j.NETWORK_IS_USED_AS_MANAGEMENT_VLAN]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_AS_MANAGEMENT_VLAN",[j.NETWORK_IS_USED_IN_PORT_FORWARD]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_IN_PORT_FORWARD",[j.NETWORK_IS_USED_IN_ROUTING_AS_INTERFACE_ROUTE]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_IN_ROUTING_AS_INTERFACE_ROUTE",[j.NETWORK_IS_USED_BY_WIFI_AS_NETWORK]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_BY_WIFI_AS_NETWORK",[j.FIXED_IP_OVERLAPS_NETWORK_SUBNET]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_FIXED_IP_OVERLAPS_NETWORK_SUBNET",[j.NETWORK_IS_USED_BY_WIFI_IN_PPSK]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_BY_WIFI_IN_PPSK",[j.NETWORK_IS_USED_IN_OSPF_ROUTE]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_IN_OSPF_ROUTE",[j.NETWORK_IS_USED_IN_NAT_RULES]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_IN_NAT_RULES",[j.NETWORK_IS_USED_BY_AUTO_IGMP_SNOOPING]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_BY_AUTO_IGMP_SNOOPING",[j.NETWORK_IS_USED_BY_PORT_NATIVE_NETWORK]:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_NETWORK_IS_USED_BY_PORT_NATIVE_NETWORK"},v=({onCancel:e,onConfirm:_,confirmations:t})=>{const a=(()=>{const e=(0,s.wA)(),_=(0,s.d4)(S.ID),t=(0,s.d4)(L.nT);return(0,n.useCallback)(async i=>{if(!i.length)return;const n=[];if(_.forEach(e=>{e.port_table&&e.port_table.length&&e.port_table.forEach(_=>{const t=((e,_)=>{const t=_?.find(_=>_.port_idx===e.port_idx);return t?{...e,...t}:e})(_,e.port_overrides);t.native_networkconf_id&&i.includes(t.native_networkconf_id)&&(e=>!e.port_security_enabled&&!(!e.qos_profile?.qos_profile_mode||e.qos_profile.qos_profile_mode===U.If.CUSTOM))(t)&&n.push({device:e,port:t,portIdx:_.port_idx})})}),!n.length)return;const s=n.reduce((e,{device:_,portIdx:t})=>(e[_._id]||(e[_._id]={device:_,portIndices:[]}),e[_._id].portIndices.push(t),e),{}),a=Object.values(s).map(async({device:_,portIndices:i})=>{const n=_.port_overrides||[],s=[];return n.forEach(e=>{if(i.includes(e.port_idx)){const{qos_profile:_,port_security_enabled:i,native_networkconf_id:n,...a}=e;s.push({...a,qos_profile:void 0,port_security_enabled:!1,native_networkconf_id:t?._id})}else s.push(e)}),i.forEach(e=>{n.some(_=>_.port_idx===e)||s.push({port_idx:e,qos_profile:void 0,port_security_enabled:!1,native_networkconf_id:t?._id})}),w()(n,s)?Promise.resolve():e((0,h.c8)({port_overrides:s},_._id))});await Promise.all(a)},[_,e,t])})(),[r,o]=(0,n.useState)(!1),l=t.filter(e=>e.error?.reference_resources?.some(e=>e.reference_type===j.NETWORK_IS_USED_BY_AUTO_IGMP_SNOOPING)).map(e=>e._id),c=l.length>0;return(0,i.jsx)(C.A,{actions:[{disabled:!1,text:(0,i.jsx)(d.sA,{id:"COMMON_ACTION_CANCEL"}),type:"button",variant:"default",onClick:e},{disabled:!1,text:(0,i.jsx)(d.sA,{id:"COMMON_ACTION_CONFIRM"}),type:"submit",variant:"danger",onClick:async()=>{r&&await a(l),_()}}].filter(Boolean),title:(0,i.jsx)(d.sA,{id:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_WARNING_TITLE"}),size:"small",onRequestClose:e,children:(0,i.jsxs)(b.A,{flexDirection:"column",gap:x.Ln,children:[(0,i.jsx)(d.sA,{id:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_WARNING_BODY",values:{count:t.length}}),(0,i.jsxs)(b.A,{flexDirection:"column",children:[t.map(({_id:e,name:_,error:t})=>(0,i.jsxs)("div",{children:[(0,i.jsx)("h4",{children:_}),(0,i.jsx)("ul",{children:(0,f.A)((t?.reference_resources||[]).flatMap(({reference_type:e})=>e)).map(e=>(0,i.jsx)("li",{children:(0,i.jsx)(d.sA,{id:P[e]||"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_REFERENCE_GENERAL_DESCRIPTION"})},e))})]},e)),c?(0,i.jsx)(W.A,{isSelected:r,onChange:e=>o(e),label:(0,i.jsx)(d.sA,{id:"COMMON_NETWORKS_REMOVE_NETWORK_FORCE_DISABLE_PRO_AV_ON_PORTS"})}):null]})]})})},D=e=>e.error?.apiMsg===M.ApiString.apiErrResourceReferredBy&&Array.isArray(e.error.reference_resources);function k({genericErrorMessage:e,deletionSuccessCallback:_}){const[t,f]=(0,n.useState)([]),W=(0,s.d4)(S.C$),x=(0,s.d4)(A.vc),{formatMessage:C}=(0,d.tz)(),b=(0,s.wA)(),K=(0,n.useCallback)(async(t,n)=>{const{referenceErrors:s,otherErrors:d}=await(async({networks:e,forceDelete:_,dispatch:t,genericErrorMessage:n,formatMessage:s})=>{const d=e.map(({_id:e,name:i})=>t((0,m.wR)(e,{},_)).then(()=>({type:"success",_id:e,name:i})).catch(_=>({type:"error",error:_,_id:e,name:i}))),c=(await Promise.all(d)).flatMap(e=>"error"===e.type?[e]:[]),[E,O]=(0,a.A)(c,D);return O.forEach(e=>{const _=e.error;t((0,l.ox)(_?.apiMsg!==M.ApiString.apiErrCannotDeleteNetworkWhichIsConfiguredInMagicSiteToSiteVpn?{icon:r.C.danger,message:n,values:{name:e.name},errorMessage:_?.msg,errorValues:{modelType:"network",..._}}:{icon:r.C.danger,details:(0,i.jsxs)("span",{children:[s({id:"COMMON_NETWORKS_MANAGE_REMOVE_ERROR_MAGIC_SITE_TO_SITE"})," ",(0,i.jsx)(o.A.Simplified,{message:s({id:"SETTINGS_MANAGE_SITE_TO_SITE_VPN"}),href:g.A.unifiSiteToSiteVpn})]})}))}),{referenceErrors:E,otherErrors:O}})({networks:t,forceDelete:n,dispatch:b,formatMessage:C,genericErrorMessage:e});if(f(s),d.length)throw d[0].error;s.length||(b((0,N.fi)()),b((0,T.uL)()),b((0,c.P)()),b((0,E.uy)()),b((0,O.Uc)()),b((0,h.Uc)()),b((0,R.rt)()),W&&x?(b((0,I.s_)()),b((0,p.D)(x,{cfg:"system"}))):b((0,u.A)()),_?.())},[b,C,e,W,x,_]);return{removeNetworks:K,forceDeleteModal:t.length?(0,i.jsx)(v,{onCancel:()=>f([]),onConfirm:()=>(f([]),K(t,!0)),confirmations:t}):null}}},384783(e,_,t){t.d(_,{A:()=>a});var i=t(274934),n=t(832162),s=t(826600);const a=({children:e=null,hideModal:_,onRequestClose:t,portalSelector:a=s.J,forwardedRef:r=null,...o})=>(0,i.jsx)(n.A,{isOpen:!0,shouldCloseOnEsc:!0,onRequestClose:t||_,parentSelector:a,ref:r,...o,children:e})},826600(e,_,t){t.d(_,{J:()=>i,g:()=>n});const i=()=>document.getElementById("modal-container"),n=()=>document.getElementById("modal-settings-container")}}]);