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