"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[16653],{41488(e,t,_){_.d(t,{iw:()=>N,Zb:()=>O,N0:()=>o,uE:()=>A,Je:()=>m,od:()=>T});var s=_(911513),n=_(961386),r=_(263963),a=_(282214),E=_(303303);const i=(0,n.S)([E.m9,a.q],{message:(0,r.rn)("SETTINGS_IPV6_ADDRESS_OR_SUBNET_VALIDATION")});var l=_(242299),S=_(16914),I=_(867955);const O={[I.B.PORT_GROUP]:"SETTINGS_DUPLICATE_PORT_VALIDATION",[I.B.ADDRESS_GROUP]:"SETTINGS_DUPLICATE_IP_VALIDATION",[I.B.IPV6_ADDRESS_GROUP]:"SETTINGS_DUPLICATE_IP_VALIDATION"},A={[I.B.PORT_GROUP]:{id:"COMMON_PLACEHOLDER_EG",values:{value:"1-10"}},[I.B.ADDRESS_GROUP]:{id:"SETTINGS_IP_SUBNET_RANGE",values:{version:S.oi.IPV4}},[I.B.IPV6_ADDRESS_GROUP]:{id:"SETTINGS_IP_SUBNET_RANGE",values:{version:S.oi.IPV6}}},N=[I.B.PORT_GROUP,I.B.ADDRESS_GROUP,I.B.IPV6_ADDRESS_GROUP],T={[I.B.PORT_GROUP]:"COMMON_PORT",[I.B.ADDRESS_GROUP]:"SETTINGS_PROFILES_NETWORK_OBJECT_TYPE_ADDRESS_GROUP",[I.B.IPV6_ADDRESS_GROUP]:"SETTINGS_PROFILES_NETWORK_OBJECT_TYPE_IPV6_ADDRESS_GROUP"},o={[I.B.PORT_GROUP]:"COMMON_PORT",[I.B.ADDRESS_GROUP]:"COMMON_ADDRESS",[I.B.IPV6_ADDRESS_GROUP]:"COMMON_ADDRESS"},m={[I.B.PORT_GROUP]:s.c,[I.B.ADDRESS_GROUP]:l.q.refine(e=>!e.endsWith("/32"),{message:(0,r.rn)("SETTINGS_REMOVE_SUBNET_SUFFIX",{subnet:32})}),[I.B.IPV6_ADDRESS_GROUP]:i.refine(e=>!e.endsWith("/128"),{message:(0,r.rn)("SETTINGS_REMOVE_SUBNET_SUFFIX",{subnet:128})})}},867955(e,t,_){var s;_.d(t,{B:()=>s}),function(e){e.PORT_GROUP="port-group",e.ADDRESS_GROUP="address-group",e.IPV6_ADDRESS_GROUP="ipv6-address-group"}(s||(s={}))},378807(e,t,_){_.d(t,{b:()=>n});var s=_(81126);const n=(0,_(71479).A)(s.A)`
  ${({column:e})=>e?"justify-content: center;":"align-items: center;"}
`},74805(e,t,_){_.d(t,{A:()=>E});var s=_(296540),n=_(951272),r=_(79760),a=_(859510);const E=function({fieldName:e,...t}){const{values:_,setFieldValue:E,errors:i,touched:l,submitCount:S}=(0,n.j7)();return s.createElement(a.A,{...t,value:(0,n.O6)(_,e),invalid:(0,r.t$)(e,i,l,S),onChange:t=>E(e,t)})}},116653(e,t,_){_.d(t,{A:()=>v});var s=_(296540),n=_(469733),r=_(951272),a=_(71479),E=_(742920),i=_(248543),l=_(705426),S=_(675359),I=_(916537),O=_(711748),A=_(323013),N=_(602021),T=_(870443),o=_(263963);const m=(e,t)=>_=>{const n=e.safeParse(_);return!!n.success||s.createElement(s.Fragment,null,(0,o.MS)(t,n.error.issues[0]?.message))};var R=_(867955),u=_(41488);const P=e=>T.A.object({name:T.A.string().label("COMMON_NAME").max(64,s.createElement(I.sA,{id:"SETTINGS_COMMON_FIELD_SHOULD_NOT_EXCEED_MAX_LENGTH",values:{name:s.createElement(I.sA,{id:"COMMON_NAME"}),limit:64}})).test("isUnique",s.createElement(I.sA,{id:"COMMON_PLEASE_ENTER_UNIQUE_NAME"}),t=>t&&!e.some(e=>e.name===t)).required(),group_type:T.A.string(),group_members:T.A.array().when("group_type",{is:R.B.PORT_GROUP,then:T.A.array().min(1,s.createElement(I.sA,{id:"SETTINGS_PROFILES_PORT_IP_GROUPS_FORM_FIELD_GROUP_MEMBERS_PORT_MIN"}))}).when("group_type",{is:R.B.ADDRESS_GROUP,then:T.A.array().min(1,s.createElement(I.sA,{id:"SETTINGS_PROFILES_PORT_IP_GROUPS_FORM_FIELD_GROUP_MEMBERS_ADDRESS_MIN"}))}).when("group_type",{is:R.B.IPV6_ADDRESS_GROUP,then:T.A.array().min(1,s.createElement(I.sA,{id:"SETTINGS_PROFILES_PORT_IP_GROUPS_FORM_FIELD_GROUP_MEMBERS_ADDRESS_MIN"}))})}),c=(e,t,_)=>{const s=u.uE[t],n=u.Je[t];return{disabled:e,fieldName:"group_members",labels:{fieldLabel:u.N0[t],modalTitle:"SETTINGS_ADD_MULTIPLE_NETWORK_LIST_VALUES",modalFieldPlaceholder:_({id:s.id},s.values)},extraFieldConfig:{placeholder:s.id,placeholderValues:s.values},fieldValidation:{validate:m(n,{formatMessage:_}),getDuplicationMessage:()=>_({id:u.Zb[t]})}}};var D=_(847883),d=_(81126),g=_(842151),M=_(679783),p=_(553432),V=_(143811),G=_(74805),U=_(378807);const L=({types:e,disabled:t})=>{const{values:_,initialValues:n}=(0,r.j7)(),{formatMessage:a}=(0,I.tz)(),E=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),i=(0,s.useMemo)(()=>e?.length?u.iw.filter(t=>e.includes(t)):u.iw,[e]),l=(0,s.useMemo)(()=>n.group_type===_.group_type&&i.length<=1&&i.includes(_.group_type),[i,n.group_type,_.group_type]);return s.createElement(g.A,{padding:"none"},s.createElement(D.A,null,s.createElement(d.A,{column:!0},s.createElement(V.A,{full:!0,name:"name",variant:"secondary",label:"COMMON_NAME",fast:!0}))),l?null:s.createElement(D.A,null,s.createElement(U.b,{column:!0,style:{flex:1}},s.createElement(M.A,{label:s.createElement(I.sA,{id:"COMMON_TYPE"}),tooltip:s.createElement(I.sA,{id:"SETTINGS_PROFILES_NETWORK_LIST_TYPE_DESCRIPTION"})}),s.createElement(p.A,null,i.map(e=>s.createElement(V.A,{key:e,name:"group_type",type:"radio",value:e,disabled:_.group_members.length>0},s.createElement(I.sA,{id:u.od[e]})))))),s.createElement(D.A,null,s.createElement(d.A,null,s.createElement("form",{style:{width:"100%"},onSubmit:E,key:_.group_type},_.group_type?s.createElement(G.A,{...c(t,_.group_type,a)}):null))))},C=(0,a.A)(l.A)`
  width: 400px !important;
  padding: 0 !important;
`,v=({hideModal:e,handleGroupField:t,types:_,initialValues:a={}})=>{const l=(0,n.useDispatch)(),T=(0,n.useSelector)(N.EL),o=(0,n.useSelector)(O.O9),m=(0,s.useMemo)(()=>P(o),[o]),R=(0,s.useCallback)((_,{setSubmitting:s})=>l((0,A.Qe)({..._,group_members:(_.group_members||[]).filter(e=>!!e)})).then(e=>{t?.(e)}).then(e).catch(e=>{l((0,S.ox)({errorMessage:e.msg,errorValues:e,icon:E.C.danger,message:"SETTINGS_PROFILES_NETWORK_OBJECT_FORM_SAVE_FAILURE",values:{name:_.name}})),s(!1)}),[l,e,t]),u=(0,s.useMemo)(()=>({name:"",group_type:_?.[0],group_members:[],...a}),[a,_]);return s.createElement(r.l1,{onSubmit:R,initialValues:u,validationSchema:m},({handleSubmit:t,isSubmitting:n})=>s.createElement(C,{parentSelector:i.J,isOpen:!0,title:s.createElement(I.sA,{id:"SETTINGS_NEW_LIST"}),actions:[{text:s.createElement(I.sA,{id:"COMMON_ACTION_CANCEL"}),type:"button",onClick:e},{text:s.createElement(I.sA,{id:"COMMON_ACTION_CREATE"}),type:"submit",variant:"primary",disabled:T||n,loader:n?"spinner":void 0,onClick:()=>t()}],shouldFocusAfterRender:!0,allowOverflow:!0},s.createElement(L,{types:_,disabled:T})))}},679783(e,t,_){_.d(t,{A:()=>l});var s=_(296540),n=_(271856),r=_(217439),a=_(709690),E=_(566723),i=_(294303);const l=({label:e,tooltip:t,tooltipProps:_,style:l})=>s.createElement(i.A,{alignItems:"center",gap:E.YC,style:l},s.createElement(r.A,{size:"small",color:"text-3"},e),t?s.createElement(n.A,{description:t,portal:!0,style:{display:"flex",alignItems:"center"},..._},s.createElement(a.A,{size:"original",isActive:!0})):null)},143985(e,t,_){_.d(t,{B:()=>E,b:()=>a});var s=_(614476),n=_(620637),r=_(263963);const a=s.z.string({message:(0,r.rn)("COMMON_VALIDATION_VALID_IPV4")}).refine(e=>!e||(0,n.isValidIpv4)(e),{message:(0,r.rn)("COMMON_VALIDATION_VALID_IPV4")}),E=s.z.string({message:(0,r.rn)("COMMON_VALIDATION_VALID_IPV4")}).refine(e=>(0,n.isValidIpv4)(e),{message:(0,r.rn)("COMMON_VALIDATION_VALID_IPV4")})},242299(e,t,_){_.d(t,{q:()=>A});var s=_(961386),n=_(263963),r=_(950700),a=_(614476),E=_(620637),i=_(149133),l=_(546391),S=_(348466);const I=a.z.string({message:(0,n.rn)("COMMON_VALIDATION_IPV4_SUBNET")}).refine(e=>{const t=e.split(S.jr),[_,s]=t;return 2===t.length&&_&&s&&l.zF.test(_)&&l.zF.test(s)&&(0,E.isValidIpv4)(_)&&(0,E.isValidIpv4)(s)&&(0,i.GQ)(_)<(0,i.GQ)(s)},{message:(0,n.rn)("COMMON_VALIDATION_IPV4_SUBNET")});var O=_(143985);const A=(0,s.S)([O.B,r.K,I],{message:(0,n.rn)("SETTINGS_ROUTING_NAT_FORM_IP_OR_SUBNET_OR_RANGE_VALIDATION")})},950700(e,t,_){_.d(t,{K:()=>E});var s=_(614476),n=_(149133),r=_(546391),a=_(263963);const E=s.z.string({message:(0,a.rn)("COMMON_VALIDATION_IPV4_SUBNET")}).regex(r.wK,{message:(0,a.rn)("COMMON_VALIDATION_IPV4_SUBNET")}).refine(n.N7,{message:(0,a.rn)("COMMON_VALIDATION_IPV4_SUBNET")})},303303(e,t,_){_.d(t,{Jh:()=>E,XK:()=>a,m9:()=>i});var s=_(614476),n=_(383653),r=_(263963);const a=s.z.string().ip({version:"v6",message:(0,r.rn)("SETTINGS_NETWORKS_IPV6_ADDRESS_INVALID")}).refine(e=>!e||!e.includes("%"),{message:(0,r.rn)("SETTINGS_NETWORKS_IPV6_ADDRESS_INVALID")}),E=s.z.union([s.z.string().ip({version:"v6",message:(0,r.rn)("SETTINGS_NETWORKS_IPV6_ADDRESS_INVALID")}),s.z.literal("")]).optional().refine(e=>!e||!e.includes("%"),{message:(0,r.rn)("SETTINGS_NETWORKS_IPV6_ADDRESS_INVALID")}),i=a.refine(e=>!(0,n.m0)(e),{message:(0,r.rn)("SETTINGS_NETWORKS_IPV6_ADDRESS_IPV4_MAPPED_IPV6_INVALID")}).refine(e=>!(0,n.aN)(e),{message:(0,r.rn)("SETTINGS_NETWORKS_IPV6_ADDRESS_MULTICAST_INVALID")})},282214(e,t,_){_.d(t,{q:()=>a});var s=_(614476),n=_(383653),r=_(263963);const a=s.z.string({message:(0,r.rn)("COMMON_VALIDATION_IPV6_SUBNET")}).refine(n.In,{message:(0,r.rn)("COMMON_VALIDATION_IPV6_SUBNET")})},911513(e,t,_){_.d(t,{c:()=>E});var s=_(961386),n=_(263963),r=_(976118),a=_(790163);const E=(0,s.S)([r.L,a.i],{message:(0,n.rn)("SETTINGS_COMMON_PORT_VALIDATION_REQUIRED")})},790163(e,t,_){_.d(t,{i:()=>E});var s=_(614476),n=_(348466),r=_(263963),a=_(976118);const E=s.z.string().refine(e=>{const t=e.split(n.jr);return 2===t.length&&(0,a.w)(t[0])&&(0,a.w)(t[1])&&Number(t[0])<Number(t[1])},{message:(0,r.rn)("SETTINGS_COMMON_SINGLE_PORT_RANGE_VALIDATION_REQUIRED")})},976118(e,t,_){_.d(t,{L:()=>E,w:()=>a});var s=_(614476),n=_(263963);const r=/^\d+$/,a=e=>{if(!r.test(e)||e.startsWith("0"))return!1;const t=Number.parseInt(e,10);return!Number.isNaN(t)&&Number.isInteger(t)&&t>=1&&t<=65535},E=s.z.string().refine(e=>a(e),{message:(0,n.rn)("SETTINGS_COMMON_SINGLE_PORT_VALIDATION_REQUIRED")})},961386(e,t,_){_.d(t,{S:()=>n});var s=_(614476);function n(e,{message:t}){return s.z.custom(t=>s.z.union(e).safeParse(t).success,{message:t})}}}]);