"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[79272],{217884(e,t,n){var a;n.d(t,{b:()=>a}),function(e){e.MASTER="MASTER",e.BACKUP="BACKUP",e.MEMBER="MEMBER"}(a||(a={}))},374976(e,t,n){n.d(t,{J6:()=>a,_y:()=>r}),n(217884);const a=(e,t)=>e.filter(e=>{if(!e.stacking_group_id)return!0;const n=t.find(t=>t._id===e.stacking_group_id);if(!n)return!0;const a=n.units.find(e=>1===e.index);return a?.mac===e.mac}),r=(e,t,n)=>{if(!t||!n)return e;const a=n.find(e=>e._id===t);return a?.name||e}},325734(e,t,n){n.d(t,{A:()=>_});var a=n(296540),r=n(758649),o=n(566723),l=n(795097),i=n(823084),s=n(294303),c=n(260844),m=n(916537);const _=({list:e,messageId:t})=>{const[n,_]=(0,a.useState)(!1),E=n?e.length:3;return a.createElement(c.A,{in:!0},a.createElement(i.A,null,a.createElement(s.A,{flexDirection:"column",gap:o.YC,alignItems:"flex-start"},a.createElement(m.sA,{id:t,values:{count:e.length}}),a.createElement(l.A,null,e.slice(0,E).map((e,t)=>a.createElement("li",{key:`${e} + ${t+1}`},e))),e.length>3?a.createElement(r.A,{type:"button",onClick:()=>_(e=>!e),variant:"inline"},a.createElement(m.sA,n?{id:"COMMON_SHOW_LESS"}:{id:"COMMON_SHOW_X_MORE",values:{value:e.length-3}})):null)))}},975280(e,t,n){n.d(t,{A:()=>s});var a=n(822336),r=n(296540),o=n(823858),l=n(382389),i=n(263130);const s=({children:e,...t})=>{const{themeName:n}=(0,l.u)();return r.createElement(i.A,{icon:r.createElement(o.A,{variant:"fill",size:"original",color:a.Ay[`desktop-color-orange-06-${n}`]}),description:e,...t})}},260844(e,t,n){n.d(t,{A:()=>s});var a=n(296540),r=n(573510),o=n(132196),l=n(566723);const i=(e,t)=>o.AH`
  &-appear,
  &-enter {
    opacity: 0;
    display: flex !important;
    transform: translateY(-${l.xO});
  }
  &-appear-active,
  &-enter-active {
    display: flex !important;
    ${e&&`flex-direction: ${e};`}
    ${t&&`padding: ${t};`}
    opacity: 1;
    transform: translateY(0px);
    transition:
      opacity 150ms ease-in-out,
      transform 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  &-appear-done,
  &-enter-done {
    display: flex !important;
    ${e&&`flex-direction: ${e};`}
    ${t&&`padding: ${t};`}
    opacity: 1;
  }
  &-exit {
    display: flex !important;
    opacity: 0;
    height: 0;
    box-sizing: border-box;
    margin: ${l.xO} 0 0 !important;
    & > * {
      display: none;
    }
  }
  &-exit-active {
    display: flex !important;
    margin: 0 !important;
    transition: margin 300ms cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  &-exit-done {
    display: none;
  }
`,s=(0,a.memo)(({timeout:e=300,in:t=!1,flexDirection:n,padding:o=`0 0 ${l.fS}`,wrap:s=!1,children:c,...m})=>{const _=(0,a.useMemo)(()=>a.Children.map(c,(o,l)=>a.createElement(r.A,{appear:t,in:t,timeout:e,classNames:i(n,void 0),mountOnEnter:!0,...m},null===o?a.createElement("div",null):o)),[c,n,t,m,e]);return s?a.createElement(r.A,{appear:t,in:t,timeout:e,classNames:i(n,o),mountOnEnter:!0,...m},a.createElement("div",null,c)):a.createElement(a.Fragment,null,_)})},879272(e,t,n){n.d(t,{A:()=>Xe});var a,r,o,l=n(614476),i=n(469733),s=n(349785),c=n(296540),m=n(742920),_=n(38671),E=n(853801),d=n(832468),A=n(895424),u=n(641777),p=n(79786),C=n(398300),I=n(566723),S=n(975280),T=n(823084),N=n(48925),O=n(349107),M=n(294303),f=n(845030),L=n(675359),g=n(916537),R=n(366188),y=n(602021),v=n(532419),P=n(239417),D=n(741095),b=n(997344),h=n(915334),x=n(968906),V=n(959341),U=n(765562),z=n(953141),G=n(329109);!function(e){e.ANY="any",e.DEVICE="device",e.MAC="mac",e.NETWORK="network",e.IP="ip"}(a||(a={})),function(e){e.ANY="any",e.SPECIFIC="specific"}(r||(r={})),function(e){e.ALL="all",e.SPECIFIC="specific"}(o||(o={}));var k=n(149133),F=n(348466),w=n(263963);const W=/^\d+$/,B=e=>{if(!W.test(e))return!1;const t=Number.parseInt(e,10);return!Number.isNaN(t)&&Number.isInteger(t)&&t>=1&&t<=65535},H=l.z.string().superRefine((e,t)=>{const n=e.split(F.KE).map(e=>e.trim()).filter(Boolean),a=new Set(n);n.every(B)||t.addIssue({code:l.z.ZodIssueCode.custom,message:(0,w.rn)("SETTINGS_COMMON_SINGLE_PORT_VALIDATION_REQUIRED")}),a.size!==n.length&&t.addIssue({code:l.z.ZodIssueCode.custom,message:(0,w.rn)("SETTINGS_COMMON_DUPLICATE_PORTS_VALIDATION")})});var Y=n(19607),$=n(961386),K=n(950700),j=n(143985);const Q=(0,$.S)([j.B,K.K],{message:(0,w.rn)("SETTINGS_ACL_RULES_IPV4_SUBNET_VALIDATION")});var Z=n(959207),X=n(712050),J=n(860631);const q=(e,t)=>{switch(e?.type){case a.IP:return e.ips?e.ips.map(e=>(0,k.Wn)(e)):[];case a.NETWORK:return t.filter(({_id:t})=>e.network_ids?.includes(t)).map(e=>(0,Z.mC)(e)).filter(Boolean);default:return[]}},ee=(e,t)=>{const[n,a]=(0,X.A)(t.filter(t=>!t.specific_enforcers?.length||t.specific_enforcers.includes(e.mac)),e=>e.type===D.xC.MAC);return{mac:(e.switch_caps?.max_custom_mac_acls||0)-n.length,ip:(e.switch_caps?.max_custom_ip_acls||0)-a.length}},te=(e,t,n)=>!t.length||t.every(t=>{if(!(0,J._E)(e,t))return!0;const a=ee(t,n);return e===D.xC.MAC&&a.mac>0||e===D.xC.IPV4&&a.ip>0}),ne=(e,t,n)=>{const a=(0,k.Wn)(e);return!t.some(e=>!!(0,k.MD)(a,e)||!(1!==(0,k.ut)(a)||1!==(0,k.ut)(e)||!n.some(t=>t.ip_subnet&&(0,k.xX)(t.ip_subnet,(0,k.a7)(e))&&(0,k.xX)(t.ip_subnet,(0,k.a7)(a)))))},ae=Q,re=l.z.object({type:l.z.literal(a.ANY)}),oe=l.z.object({type:l.z.literal(a.MAC),mac:Y.V,mac_mask:l.z.union([l.z.object({enabled:l.z.literal(!0),mask:l.z.string()}),l.z.object({enabled:l.z.literal(!1).optional()})]).optional().transform(e=>e||{enabled:!1})}),le=l.z.object({type:l.z.literal(a.DEVICE),macs:l.z.array(Y.V,{message:(0,w.rn)("SETTINGS_COMMON_DEVICE_REQUIRED")}).min(1,{message:(0,w.rn)("SETTINGS_COMMON_DEVICE_REQUIRED")})}),ie=l.z.object({type:l.z.literal(a.NETWORK),network_ids:l.z.array(l.z.string(),{message:(0,w.rn)("SETTINGS_COMMON_NETWORK_REQUIRED")}).min(1,{message:(0,w.rn)("SETTINGS_COMMON_NETWORK_REQUIRED")})}),se=l.z.object({type:l.z.literal(a.IP),ips:l.z.array(ae,{message:(0,w.rn)("SETTINGS_SECURITY_MIN_ONE_ENTRY")}).min(1,{message:(0,w.rn)("SETTINGS_SECURITY_MIN_ONE_ENTRY")})}),ce=(l.z.union([oe,le,ie,se,re]),l.z.union([l.z.object({type:l.z.literal(r.ANY)}),l.z.object({type:l.z.literal(r.SPECIFIC),port:H.refine(e=>e.split(F.KE).filter(Boolean).map(Number).length<=10,{message:(0,w.rn)("SETTINGS_ACL_RULES_PORTS_MEMBERS_MAX_VALIDATION",{count:10})})})]));var me=n(739354),_e=n(188738),Ee=n(938325);const de=function({form:e,name:t,getIsNetworkVisible:n,getDisabledReason:a,additionalInfo:r="subnet",...o}){const l=(0,i.useSelector)(R.Ct),m=(0,s.FH)({control:e.control,name:t}),_=(0,c.useMemo)(()=>l.filter(e=>m===e._id||n(e)).map(e=>{const t=m!==e._id?a?.(e):void 0,n=(0,Ee.A1)(e);return{label:n?`${e.name} (${n})`:e.name,value:e._id,tooltipDescription:t,disabled:!!t,additionalInfo:"subnet"===r?(0,Z.mC)(e):"vlan"===r?(0,Ee.mM)(e.vlan,(0,Z.nz)(e))?.toString():void 0}}),[l,m,n,a,r]);return c.createElement(_e.A,{control:e.control,name:t,options:_,renderOption:me.Ku,...o})};var Ae=n(317672),ue=n(349665),pe=n(263923);const Ce=({form:e})=>{const t=(0,i.useSelector)(v.m9),n=(0,i.useSelector)(v.ID);return c.createElement(ue.A,null,c.createElement(Ae.A,{htmlFor:"network_id",tooltip:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_NETWORK_TOOLTIP",values:{link:c.createElement(O.A,{href:U.A.aclRules,id:"COMMON_LEARN_MORE",noWrap:!0})}}),tooltipProps:{isInteractive:!0}},c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_VLAN_NETWORKS"})),c.createElement(de,{form:e,name:"network_id",additionalInfo:"subnet",getIsNetworkVisible:e=>(0,pe.d)(e,t),getDisabledReason:e=>n.some(t=>t.mgmt_network_id===e._id||e.ip_subnet&&(0,k.xX)(e.ip_subnet,t.ip))?c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_NETWORK_DISABLED_TOOLTIP"}):void 0}))};var Ie=n(610356),Se=n(553432);const Te=({form:e,existingRecord:t})=>{const n=(0,i.useSelector)(v.b2),r=(0,i.useSelector)(b.yT),l=(0,c.useCallback)(a=>{const l=r.filter(e=>e._id!==t?._id);e.getValues("devices.type")!==o.ALL||te(a,n,l)||e.setValue("devices.type",o.SPECIFIC),e.getValues("devices.type")===o.SPECIFIC&&e.setValue("devices.macs",e.getValues("devices.macs")?.filter(e=>n.some(t=>t.mac===e&&(0,J._E)(a,t)&&ee(t,l)[a===D.xC.MAC?"mac":"ip"]>0)))},[r,n,t?._id,e]);return c.createElement(Se.A,null,c.createElement(Ie.A,{control:e.control,name:"type",value:D.xC.MAC,onCheck:()=>{e.setValue("source.type",a.ANY),e.setValue("destination.type",a.ANY),l(D.xC.MAC)}},c.createElement(g.sA,{id:"COMMON_MAC"})),c.createElement(Ie.A,{control:e.control,name:"type",value:D.xC.IPV4,onCheck:()=>{e.setValue("source.type",a.ANY),e.setValue("destination.type",a.ANY),l(D.xC.IPV4)}},c.createElement(g.sA,{id:"COMMON_IPV4"})))};var Ne=n(6510),Oe=n(62170),Me=n(504779),fe=n(6176),Le=n(325734),ge=n(374976),Re=n(538535);const ye=({form:e,existingRecord:t})=>{const n=(0,i.useSelector)(v.b2),a=(0,i.useSelector)(b.yT),r=(0,i.useSelector)(Re.D5),l=(0,s.FH)({control:e.control,name:"type"}),m=(0,s.FH)({control:e.control,name:"devices"}),_=(0,c.useMemo)(()=>a.filter(e=>e._id!==t?._id),[a,t?._id]),E=(0,c.useMemo)(()=>(0,ge.J6)(n,r).map(e=>{const t=ee(e,_),n=(0,J._E)(l,e)?(l===D.xC.MAC?t.mac:t.ip)<=0?c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_SWITCH_LIMIT_REACHED_TOOLTIP"}):null:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_SWITCH_INCOMPATIBLE_TOOLTIP"});return{label:(0,ge._y)((0,Ne.Q)(e),e.stacking_group_id,r),value:e.mac,image:c.createElement(fe.A,{model:e.model}),disabled:!!n,tooltipDescription:n,tooltipPortal:!!n,tooltipPosition:"left",tooltipOffset:20}}),[n,l,_,r]),d=(0,c.useMemo)(()=>n.filter(e=>(!l||!(0,J._E)(l,e))&&(m?.type===o.ALL||m?.type===o.SPECIFIC&&m.macs?.includes(e.mac))),[n,m,l]);return c.createElement(c.Fragment,null,c.createElement(ue.A,null,c.createElement(Ae.A,{htmlFor:"devices.type",tooltip:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_SWITCH_TOOLTIP"})},c.createElement(g.sA,{id:"COMMON_SWITCH"})),c.createElement(Se.A,null,c.createElement(Me.A,{reason:m?.type===o.ALL||te(l,n,_)?null:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_SWITCH_LIMIT_REACHED_TOOLTIP_SOME"})},c.createElement(Ie.A,{name:"devices.type",control:e.control,value:o.ALL},c.createElement(g.sA,{id:"COMMON_ALL"}))),c.createElement(Ie.A,{name:"devices.type",control:e.control,value:o.SPECIFIC},c.createElement(g.sA,{id:"COMMON_SPECIFIC"})))),m?.type===o.SPECIFIC?c.createElement(Oe.A,{control:e.control,name:"devices.macs",options:E,triggerButtonText:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_SWITCH_TRIGGER"})}):null,d.length?c.createElement(Le.A,{list:d.map(e=>(0,Ne.Q)(e)),messageId:"SETTINGS_ACL_RULES_SWITCH_INCOMPATIBLE_ALERT"}):null)};var ve=n(21803),Pe=n(741821);const De=({form:e,name:t})=>{const n=(0,s.FH)({control:e.control,name:`${t}.type`}),a=(0,s.FH)({control:e.control,name:"protocol"}),{formatMessage:o}=(0,g.tz)();return c.createElement(c.Fragment,null,c.createElement(ue.A,null,c.createElement(Ae.A,{htmlFor:`${t}.type`},c.createElement(g.sA,{id:"COMMON_PORT"})),c.createElement(Se.A,null,c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:r.ANY},c.createElement(g.sA,{id:"COMMON_ANY"})),c.createElement(Me.A,{reason:a===D.w$.ALL?c.createElement(g.sA,{id:"SETTINGS_ROUTING_NAT_PORT_DISABLED_TOOLTIP"}):null},c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:r.SPECIFIC},c.createElement(g.sA,{id:"COMMON_SPECIFIC"}))))),n===r.SPECIFIC?c.createElement(A.A,{control:e.control,name:`${t}.port`,placeholder:o({id:"COMMON_PLACEHOLDER_EG"},{value:"11,12"})}):null)};var be=n(621690),he=n(897502),xe=n(400261);const Ve=function({form:e,name:t,...n}){const{formatMessage:a}=(0,g.tz)();return c.createElement(A.A,{control:e.control,name:t,onChange:({target:{value:e}},t)=>{t.onChange((0,xe.Z)(e))},placeholder:a({id:"COMMON_PLACEHOLDER_EG"},{value:"ab:cd:ef:12:34:56"}),...n})};var Ue=n(821580);const ze=({form:e,name:t})=>{const n=(0,s.FH)({control:e.control,name:t});return c.createElement(c.Fragment,null,c.createElement(Ve,{form:e,name:`${t}.mac`}),c.createElement(Ue.A,null,c.createElement(he.A,{tooltip:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_MAC_MASK_TOOLTIP"}),control:e.control,name:`${t}.mac_mask.enabled`},c.createElement(g.sA,{id:"SETTINGS_NETWORKS_FORM_NETMASK"}))),n?.type===a.MAC&&n.mac_mask?.enabled?c.createElement(M.A,{width:92,alignItems:"flex-start"},c.createElement(_e.A,{control:e.control,name:`${t}.mac_mask.mask`,options:(0,be.A)(9,49).map(e=>{return{value:(t=e,(2**48-1-(2**(48-t)-1)).toString(16).padStart(12,"0").match(/(.{2})/g).join(":")),label:e.toString()};var t})})):null)},Ge=({form:e,name:t})=>{const n=(0,s.FH)({control:e.control,name:"type"});return c.createElement(Se.A,null,c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:a.ANY},c.createElement(g.sA,{id:"COMMON_ANY"})),n===D.xC.MAC?c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:a.DEVICE},c.createElement(g.sA,{id:"COMMON_DEVICE"})):null,n===D.xC.MAC?c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:a.MAC},c.createElement(g.sA,{id:"COMMON_MAC_ADDRESS"})):null,n===D.xC.IPV4?c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:a.NETWORK},c.createElement(g.sA,{id:"COMMON_NETWORK"})):null,n===D.xC.IPV4?c.createElement(Ie.A,{control:e.control,name:`${t}.type`,value:a.IP},c.createElement(g.sA,{id:"COMMON_IP"})):null)};var ke=n(803983);const Fe=function({form:e,name:t,excludeUnifiDevices:n}){const{formatMessage:a}=(0,g.tz)(),r=(0,s.FH)({control:e.control,name:"network_id"}),o=(0,c.useCallback)(e=>e.network_id===r?"vlan":"other",[r]),l=(0,c.useMemo)(()=>({vlan:{label:a({id:"SETTINGS_VLAN_DEVICES"}),order:0},other:{label:a({id:"SETTINGS_FIREWALL_RULE_OTHER_DEVICES"}),order:1}}),[a]);return c.createElement(ke.A,{form:e,name:t,groups:l,getGroup:o,excludeUnifiDevices:n})},we=({form:e})=>{const t=(0,i.useSelector)(v.m9),n=(0,i.useSelector)(R.Ct),{formatMessage:r}=(0,g.tz)(),o=(0,s.FH)({control:e.control,name:"type"}),l=(0,s.FH)({control:e.control,name:"destination"}),m=(0,s.FH)({control:e.control,name:"source"}),_=(0,c.useMemo)(()=>q(l,n),[l,n]),E=(0,c.useMemo)(()=>n.filter(e=>!(0,Z.$q)(e)),[n]),d=(0,c.useMemo)(()=>ae.refine(e=>ne(e,_,E),{message:(0,w.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}),[_,E]);return c.createElement(N.A,{...x.A.addDataTestId(x.A.TestId.ACL_POLICY_FORM_SOURCE),title:c.createElement(g.sA,{id:"COMMON_SOURCE"})},c.createElement(Ge,{form:e,name:"source"}),m?.type===a.NETWORK?c.createElement(ve.A,{form:e,name:"source.network_ids",additionalInfo:"subnet",getIsNetworkVisible:e=>(0,pe.d)(e,t),getDisabledReason:({_id:e,ip_subnet:t})=>l?.type===a.NETWORK&&l.network_ids?.includes(e)?c.createElement(g.sA,{id:"SETTINGS_SECURITY_NETWORK_OPTION_DISABLED_REASON"}):_.some(e=>t&&(0,k.MD)(t,e))?c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP"}):void 0}):null,m?.type===a.IP?c.createElement(Pe.A,{form:e,name:"source.ips",schema:d,placeholder:r({id:"COMMON_IPV4_ADDRESS_OR_SUBNET"})}):null,m?.type===a.MAC?c.createElement(ze,{form:e,name:"source"}):null,m?.type===a.DEVICE?c.createElement(Fe,{form:e,name:"source.macs"}):null,o===D.xC.IPV4?c.createElement(De,{form:e,name:"source_port"}):null)},We=({form:e})=>c.createElement(ue.A,null,c.createElement(Ae.A,{htmlFor:"protocol"},c.createElement(g.sA,{id:"COMMON_PROTOCOL"})),c.createElement(Se.A,null,c.createElement(Ie.A,{control:e.control,name:"protocol",value:D.w$.ALL,onCheck:()=>{e.setValue("source_port.type",r.ANY),e.setValue("destination_port.type",r.ANY)}},c.createElement(g.sA,{id:"COMMON_ALL"})),c.createElement(Ie.A,{control:e.control,name:"protocol",value:D.w$.TCP_AND_UDP},c.createElement(g.sA,{id:"COMMON_TCP_AND_UDP"})),c.createElement(Ie.A,{control:e.control,name:"protocol",value:D.w$.TCP},c.createElement(g.sA,{id:"COMMON_TCP"})),c.createElement(Ie.A,{control:e.control,name:"protocol",value:D.w$.UDP},c.createElement(g.sA,{id:"COMMON_UDP"})))),Be=({form:e})=>{const t=(0,i.useSelector)(v.m9),n=(0,i.useSelector)(R.Ct),{formatMessage:r}=(0,g.tz)(),o=(0,s.FH)({control:e.control,name:"type"}),l=(0,s.FH)({control:e.control,name:"destination"}),m=(0,s.FH)({control:e.control,name:"source"}),_=(0,c.useMemo)(()=>q(m,n),[m,n]),E=(0,c.useMemo)(()=>n.filter(e=>!(0,Z.$q)(e)),[n]),d=(0,c.useMemo)(()=>ae.refine(e=>ne(e,_,E),{message:(0,w.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}),[_,E]);return c.createElement(N.A,{...x.A.addDataTestId(x.A.TestId.ACL_POLICY_FORM_DESTINATION),title:c.createElement(g.sA,{id:"COMMON_DESTINATION"})},c.createElement(Ge,{form:e,name:"destination"}),l?.type===a.NETWORK?c.createElement(ve.A,{form:e,name:"destination.network_ids",additionalInfo:"subnet",getIsNetworkVisible:e=>(0,pe.d)(e,t),getDisabledReason:({_id:e,ip_subnet:t})=>m?.type===a.NETWORK&&m.network_ids?.includes(e)?c.createElement(g.sA,{id:"SETTINGS_SECURITY_NETWORK_OPTION_DISABLED_REASON"}):_.some(e=>t&&(0,k.MD)(t,e))?c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP"}):void 0}):null,l?.type===a.IP?c.createElement(Pe.A,{form:e,name:"destination.ips",schema:d,placeholder:r({id:"COMMON_IPV4_ADDRESS_OR_SUBNET"})}):null,l?.type===a.MAC?c.createElement(ze,{form:e,name:"destination"}):null,l?.type===a.DEVICE?c.createElement(Fe,{form:e,name:"destination.macs",excludeUnifiDevices:!0}):null,o===D.xC.IPV4?c.createElement(De,{form:e,name:"destination_port"}):null)},He=({form:e})=>c.createElement(Se.A,null,c.createElement(Ie.A,{control:e.control,name:"action",value:D.tZ.BLOCK},c.createElement(g.sA,{id:"COMMON_ACTION_BLOCK"})),c.createElement(Ie.A,{control:e.control,name:"action",value:D.tZ.ALLOW},c.createElement(g.sA,{id:"COMMON_ALLOW"})));var Ye=n(624461);const $e=(e,t)=>e?.type===D.lP.CLIENT_MAC?e.specific_mac_addresses?.length?1!==e.specific_mac_addresses?.length||!e.mac_mask&&t.some(t=>"mac"in t&&t.mac===e.specific_mac_addresses?.[0])?{type:a.DEVICE,macs:e.specific_mac_addresses||[]}:{type:a.MAC,mac:e.specific_mac_addresses?.[0],mac_mask:e.mac_mask?{enabled:!0,mask:e.mac_mask}:{enabled:!1}}:{type:a.ANY}:e?.type===D.lP.NETWORK?0===e.network_ids?.length?{type:a.ANY}:{type:a.NETWORK,network_ids:e.network_ids}:e?.type===D.lP.IP_OR_SUBNET?0===e.ips_or_subnets?.length?{type:a.ANY}:{type:a.IP,ips:e.ips_or_subnets}:{type:a.ANY},Ke=(e,t,n,a,l,i)=>{const s=e?.type||n||D.xC.MAC;return{name:e?.name||i,type:s,action:e?.action||D.tZ.BLOCK,devices:e?e.specific_enforcers?.length?{type:o.SPECIFIC,macs:e.specific_enforcers}:{type:o.ALL}:te(s,a,l)?{type:o.ALL}:{type:o.SPECIFIC,macs:[]},network_id:e?.mac_acl_network_id,protocol:e?.ip_acl_protocol||D.w$.ALL,source:$e(e?.traffic_source,t),source_port:e?.traffic_source.ports?.length?{type:r.SPECIFIC,port:String(e.traffic_source.ports.join(F.KE))}:{type:r.ANY},destination:$e(e?.traffic_destination,t),destination_port:e?.traffic_destination.ports?.length?{type:r.SPECIFIC,port:String(e.traffic_destination.ports.join(F.KE))}:{type:r.ANY}}},je=(e,t,n)=>{const o=n?.type===r.SPECIFIC?n.port.split(F.KE).filter(Boolean).map(Number):[];return t?t.type===a.NETWORK?{type:D.lP.NETWORK,network_ids:t.network_ids,ports:o}:t.type===a.IP?{type:D.lP.IP_OR_SUBNET,ips_or_subnets:t.ips,ports:o}:t.type===a.ANY?e===D.xC.MAC?{type:D.lP.CLIENT_MAC,specific_mac_addresses:[]}:{type:D.lP.NETWORK,network_ids:[],ports:o}:t.type===a.DEVICE?{type:D.lP.CLIENT_MAC,specific_mac_addresses:t.macs||[],mac_mask:void 0}:t.type===a.MAC?{type:D.lP.CLIENT_MAC,specific_mac_addresses:[t.mac],mac_mask:t.mac_mask?.enabled?t.mac_mask.mask:void 0}:{}:{type:D.lP.IP_OR_SUBNET,ips_or_subnets:[],ports:o}},Qe=e=>`acl-policy-form-${e}`,Ze=l.z.nativeEnum(D.xC).optional().catch(()=>{}),Xe=({activeItem:e,typeSelector:t})=>{const{sharedName:n,setSharedName:r}=(0,Ye.H5)(),F=!e?._id||e._id?.startsWith(V.R6)?void 0:e,W=(0,i.useDispatch)(),B=(0,i.useSelector)(y.EL),H=(0,i.useSelector)(P.GB),Y=(0,i.useSelector)(R.Ct),$=(0,i.useSelector)(y.vc),K=(0,i.useSelector)(b.Us),j=(0,i.useSelector)(v.b2),Q=(0,i.useSelector)(b.yT),X=(0,c.useMemo)(()=>Q.filter(e=>e._id!==F?._id),[Q,F?._id]),J=(0,c.useMemo)(()=>((e,t)=>l.z.intersection(l.z.object({name:l.z.string({message:(0,w.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).min(1,{message:(0,w.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).max(32,{message:(0,w.rn)("SETTINGS_COMMON_FIELD_SHOULD_NOT_EXCEED_MAX_LENGTH",{name:(0,w.rn)("COMMON_NAME"),limit:32})}),action:l.z.nativeEnum(D.tZ),devices:l.z.union([l.z.object({type:l.z.literal(o.ALL)}),l.z.object({type:l.z.literal(o.SPECIFIC),macs:l.z.array(l.z.string(),{message:(0,w.rn)("SETTINGS_ACL_RULES_SWITCH_REQUIRED")}).min(1,{message:(0,w.rn)("SETTINGS_ACL_RULES_SWITCH_REQUIRED")})})])}),l.z.union([l.z.object({type:l.z.literal(D.xC.MAC),network_id:l.z.string({message:(0,w.rn)("SETTINGS_VALIDATION_SELECT_A_NETWORK")}),source:l.z.union([oe,le,re]),destination:l.z.union([oe,le,re])}),l.z.object({type:l.z.literal(D.xC.IPV4),protocol:l.z.union([l.z.literal(D.w$.ALL),l.z.literal(D.w$.TCP_AND_UDP),l.z.literal(D.w$.TCP),l.z.literal(D.w$.UDP)]),source:l.z.union([ie,se,re]),source_port:ce,destination:l.z.union([ie,se,re]),destination_port:ce}).refine(t=>{if(t.destination?.type!==a.NETWORK)return!0;const n=t.destination.network_ids||[],r=q(t.source,e),o=e.filter(({_id:e})=>n.includes(e)).map(e=>(0,Z.mC)(e)).filter(Boolean);return!r.some(e=>o.some(t=>(0,k.MD)(e,t)))},{path:["destination","network_ids"],message:(0,w.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}).refine(t=>{if(t.destination?.type!==a.IP)return!0;const n=t.destination.ips||[];return!q(t.source,e).some(e=>n.some(t=>(0,k.MD)(e,(0,k.Wn)(t))))},{path:["destination","ips"],message:(0,w.rn)("SETTINGS_ACL_RULES_IP_VALIDATION_NO_OVERLAP")}),l.z.object({type:l.z.literal(D.xC.IPV6)})])).refine(e=>e.type!==D.xC.MAC||e.action!==D.tZ.BLOCK||!(e.source.type===a.MAC&&e.source.mac===t),{path:["data","source","mac"],message:(0,w.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GATEWAY")}).refine(e=>e.type!==D.xC.MAC||e.action!==D.tZ.BLOCK||!(e.destination.type===a.MAC&&e.destination.mac===t),{path:["data","destination","mac"],message:(0,w.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GATEWAY")}))(Y,$),[Y,$]),ee=(0,p.m)({schema:J,defaultValues:Ke(F,H,Ze.parse(e._id.split(":")[1]),j,X,n)});(0,E.y)(ee);const te=(0,s.FH)({control:ee.control,name:"type"}),ne=(0,s.FH)({control:ee.control,name:"action"}),ae=(0,s.FH)({control:ee.control,name:"source.type"}),me=(0,s.FH)({control:ee.control,name:"destination.type"}),_e=ee.handleSubmit(async e=>W((0,h.OL)(((e,t,n)=>({enabled:!0,acl_index:n,...e,predefined:!!e?.predefined,name:t.name,type:t.type,action:t.action,specific_enforcers:t.devices.type===o.ALL?[]:t.devices.macs,mac_acl_network_id:t.type===D.xC.MAC?t.network_id:void 0,ip_acl_protocol:t.type===D.xC.IPV4?t.protocol:void 0,traffic_source:je(t.type,"source"in t?t.source:void 0,"source_port"in t?t.source_port:void 0),traffic_destination:je(t.type,"destination"in t?t.destination:void 0,"destination_port"in t?t.destination_port:void 0)}))(F,e,K))).then(e=>{W((0,f.SQ)(!1)),W((0,f.XP)({type:C.H.ACL_POLICY,id:e._id}))}).then(()=>{ee.reset()}).catch(e=>{const t=(0,_.F)(e)?e:void 0,n=t?.apiData?.details?.enforcer_mac;W((0,L.ox)(t?.apiData?.code===z.ApiString.apiErrCustomAclCapacityExceeded&&n?{icon:m.C.danger,message:"SETTINGS_ACL_RULES_ERROR_SAVE",errorMessage:"SETTINGS_ACL_RULES_EXCEEDED_ERROR",errorValues:{device:j.find(({mac:e})=>e===n)?.name||n}}:{icon:m.C.danger,message:"SETTINGS_ACL_RULES_ERROR_SAVE",errorMessage:t?.msg||"SETTINGS_ACL_RULES_GENERIC_ERROR",errorValues:t}))}));return c.createElement("form",{onSubmit:_e,id:Qe(e._id)},c.createElement(u.A,{isDisabled:B},c.createElement(M.A,{gap:I.Ln,flexDirection:"column",width:"100%"},c.createElement(N.A,null,t,c.createElement(A.A,{control:ee.control,name:"name",label:c.createElement(g.sA,{id:"COMMON_NAME"}),onChange:(e,t)=>{t.onChange(e),r(e.target.value)}})),c.createElement(N.A,{...x.A.addDataTestId(x.A.TestId.ACL_POLICY_FORM_TYPE),title:c.createElement(g.sA,{id:"COMMON_TYPE"}),tooltip:c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_TYPE_TOOLTIP",values:{link:c.createElement(O.A,{id:"COMMON_LEARN_MORE",href:U.A.aclRules})}}),tooltipProps:{isInteractive:!0}},c.createElement(Te,{form:ee,existingRecord:F}),te===D.xC.MAC?c.createElement(T.A,null,c.createElement(g.sA,{id:"SETTINGS_ACL_BANNER_MAC",values:{link:c.createElement(O.A,{href:U.A.aclRules,id:"COMMON_LEARN_MORE",noWrap:!0})}})):null,te===D.xC.IPV4||te===D.xC.IPV6?c.createElement(T.A,null,c.createElement(g.sA,{id:"SETTINGS_ACL_BANNER_IP",values:{link:c.createElement(O.A,{href:U.A.aclRules,id:"COMMON_LEARN_MORE",noWrap:!0})}})):null,c.createElement(ye,{form:ee,existingRecord:F}),te===D.xC.IPV4?c.createElement(We,{form:ee}):null,te===D.xC.MAC?c.createElement(Ce,{form:ee}):null),c.createElement(we,{form:ee}),c.createElement(N.A,{...x.A.addDataTestId(x.A.TestId.ACL_POLICY_FORM_ACTION),title:c.createElement(g.sA,{id:"COMMON_ACTION"})},c.createElement(He,{form:ee}),ne===D.tZ.BLOCK&&ae===a.ANY&&me===a.ANY?c.createElement(S.A,null,c.createElement(g.sA,{id:"SETTINGS_ACL_RULES_ANY_ANY_WARNING_MESSAGE",values:{link:c.createElement(O.A,{href:U.A.aclRules,noWrap:!0,id:"COMMON_LEARN_MORE"})}})):null),c.createElement(Be,{form:ee}),F?c.createElement(d.A,{enabled:F.enabled,name:F.name||"",onPause:async()=>{await W((0,h.RJ)([{_id:F._id,enabled:!1}])),await W((0,h.U9)())},onResume:async()=>{await W((0,h.RJ)([{_id:F._id,enabled:!0}])),await W((0,h.U9)())},onRemove:()=>W((0,h.DH)([F._id]))}):null),c.createElement(G.A,{onFormCancel:()=>ee.reset(),isDirty:ee.formState.isDirty||!F,hideCancelButton:!ee.formState.isDirty,submitButtonText:F?void 0:"COMMON_ACTION_ADD",form:Qe(e._id),isSubmitting:ee.formState.isSubmitting})))}},803983(e,t,n){n.d(t,{A:()=>I});var a=n(296540),r=n(469733),o=n(349785),l=n(784045),i=n(376618),s=n(217439),c=n(62170),m=n(454195),_=n(294303),E=n(703447),d=n(916537),A=n(951106),u=n(239417);const p={threshold:.1},C=({children:e})=>a.createElement(_.A,{alignItems:"center",height:m.b},a.createElement(s.A,{size:"inherit",color:"inherit"},e)),I=function({form:e,name:t,additionalInfo:n="mac",excludeUnifiDevices:s,getGroup:m,groups:I,...S}){const{formatMessage:T}=(0,d.tz)(),N=(0,o.FH)({control:e.control,name:t}),O=(0,r.useSelector)(u.GB),M=(0,a.useMemo)(()=>{const e=O.filter(e=>!(s&&"unifi_device"in e&&e.unifi_device)),t=(N||[]).filter(t=>!e.some(e=>"mac"in e&&e.mac===t)).map(e=>({mac:e,name:e})),r=[...e,...t].flatMap(e=>"mac"in e?[e]:[]);return(I&&m?(0,l.A)(Object.entries((0,i.A)(r,m)),([e])=>I[e]?.order??0).map(([e,t])=>({id:e,label:I[e]?.label,options:t})).filter(e=>e.options.length>0):[{id:void 0,label:void 0,options:r}]).flatMap(({options:e,label:t,id:r})=>[...t&&r?[{label:a.createElement(C,null,t),value:r,group:r,groupTitle:!0}]:[],...e.map(e=>({label:(0,A.tn)(e),value:e.mac,group:r,image:a.createElement(_.A,{maxWidth:24,maxHeight:24},a.createElement(E.A,{client:e})),additionalInfo:"mac"===n?e.mac:void 0}))])},[n,O.length,N,s]);return a.createElement(c.A,{control:e.control,name:t,options:M,truncateLabels:!0,isWindowed:!0,triggerButtonText:T({id:"COMMON_SELECT"}),searchOptions:p,...S})}},741821(e,t,n){n.d(t,{A:()=>l});var a=n(296540),r=n(916537),o=n(617883);const l=function({form:e,name:t,schema:n,placeholder:l,max:i,label:s="SETTINGS_IP_ADDRESS_SUBNET",disableMultiEdit:c=!1}){const{formatMessage:m}=(0,r.tz)();return a.createElement(o.A,{form:e,name:t,fieldLabel:s,modalTitle:a.createElement(r.sA,{id:"SETTINGS_ADD_MULTIPLE_IPS"}),modalFieldPlaceholder:m({id:"SETTINGS_ADD_MULTIPLE_IPS_PLACEHOLDER"}),getDuplicationMessage:()=>m({id:"SETTINGS_DUPLICATE_IP_VALIDATION"}),itemSchema:n,placeholder:l??m({id:"COMMON_ENTER_IP_ADDRESS"}),disableMultiEdit:c,max:i})}},21803(e,t,n){n.d(t,{A:()=>_});var a=n(296540),r=n(469733),o=n(349785),l=n(62170),i=n(938325),s=n(916537),c=n(959207),m=n(366188);const _=function({form:e,name:t,getIsNetworkVisible:n,getDisabledReason:_,additionalInfo:E,getOptionLabel:d,...A}){const{formatMessage:u}=(0,s.tz)(),p=(0,r.useSelector)(m.Ct),C=(0,o.FH)({control:e.control,name:t}),I=(0,a.useMemo)(()=>p.filter(e=>n(e)||C?.includes(e._id)).map(e=>{const t=C?.includes(e._id)?void 0:_?.(e);return{label:d?.(e)||e.name,value:e._id,disabled:!!t,tooltipDescription:t,tooltipPosition:"left",tooltipPortal:!0,additionalInfo:"subnet"===E?(0,c.mC)(e):"vlan"===E?(0,i.mM)(e.vlan,(0,c.nz)(e))?.toString():void 0}}),[p,n,C,_,d,E]);return a.createElement(l.A,{control:e.control,name:t,options:I,truncateLabels:!0,...A,triggerButtonText:u({id:"COMMON_SELECT"})})}},617883(e,t,n){n.d(t,{A:()=>m});var a=n(296540),r=n(349785),o=n(263963),l=n(284428),i=n(294303),s=n(916537),c=n(859510);const m=function({form:e,name:t,fieldLabel:n,modalTitle:m,modalFieldPlaceholder:_,placeholder:E,itemSchema:d,transformValue:A,getDuplicationMessage:u,extraDisplayColumns:p,actions:C,max:I,disableMultiEdit:S=!1,splitBy:T,validateInArray:N}){const O=(0,l.mQ)(),M=(0,o.L_)(),{formatMessage:f}=(0,s.tz)(),L=(0,a.useMemo)(()=>({fieldLabel:n,modalTitle:m,modalFieldPlaceholder:_}),[n,_,m]),g=(0,a.useMemo)(()=>({getDuplicationMessage:u??(()=>f({id:"SETTINGS_VALUE_UNIQUE"})),validateInArray:N,validate:e=>{if(T&&"string"==typeof e){const t=e.split(T).map(e=>e.trim()).filter(Boolean);for(const n of t.length>0?t:[e]){const e=d.safeParse(n);if(!e.success)return a.createElement(a.Fragment,null,M(e.error.issues[0]?.message))}return!0}const t=d.safeParse(e);return!!t.success||a.createElement(a.Fragment,null,M(t.error.issues[0]?.message))}}),[f,M,u,d,T,N]),R=(0,a.useMemo)(()=>({placeholder:E,translatePlaceholder:!1,parser:A?e=>A(e?.[0]?.target?.value):void 0}),[E,A]);return a.createElement(r.xI,{control:e.control,name:t,render:({field:e,fieldState:t,formState:n})=>a.createElement(i.A,{flexDirection:"column",width:"100%"},a.createElement(c.A,{disabled:O,labels:L,fieldValidation:g,extraFieldConfig:R,value:e.value||[],onChange:t=>e.onChange(t),invalid:t.invalid?M((0,r.Jt)(n.errors,e.name)?.message)||!0:void 0,extraDisplayColumns:p,actions:C,disableMultiEdit:S,max:I,splitBy:T}))})}},62170(e,t,n){n.d(t,{A:()=>_});var a=n(296540),r=n(349785),o=n(566723),l=n(662297),i=n(916537),s=n(263963),c=n(284428);const m=[],_=function({control:e,name:t,tooltip:n,options:_,triggerButtonText:E,truncateLabels:d=!0,isWindowed:A,searchOptions:u,maxSelections:p,narrowTrigger:C,chipClassName:I,label:S,onAfterChange:T}){const N=(0,c.mQ)(),O=(0,s.L_)();return a.createElement(r.xI,{control:e,name:t,render:({field:e,fieldState:s,formState:c})=>a.createElement(l.A,{name:e.name,onChange:t=>{e.onChange(t),T?.(t)},disabled:N,value:e.value||m,tooltipDescription:n,options:_,truncateLabels:d,invalid:s.invalid?O((0,r.Jt)(c.errors,t)?.message)||!0:void 0,translateTriggerButtonText:!1,triggerButtonText:E??a.createElement(i.sA,{id:"COMMON_EDIT_SELECTIONS"}),isWindowed:A,searchOptions:u,maxSelections:p,isFullWidth:!0,triggerButtonHeight:C?o.S2:void 0,chipClassName:I,label:S})})}},19607(e,t,n){n.d(t,{V:()=>l});var a=n(614476),r=n(546391),o=n(263963);const l=a.z.string({message:(0,o.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GENERIC")}).refine(e=>r.b8.test(e),{message:(0,o.rn)("SETTINGS_ACL_RULES_MAC_VALIDATION_GENERIC")})}}]);