"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[9599],{459599:(e,t,a)=>{a.r(t),a.d(t,{default:()=>L});var n=a(296540),l=a(951272),r=a(870443),o=a(204751),i=a(459449),m=a(847883),c=a(617147),s=a(71479),E=a(132196),_=a(709690),O=a(217439),A=a(388151),d=a(949330),p=a(294303),C=a(566723),u=a(189643),b=a(814680),g=a(766624),N=a(987588);const M=(0,s.A)(p.A)`
  gap: ${C.kc};
  border-radius: ${C.kc};
  padding: ${C.kc};
  background-color: ${({theme:{motifPalette:{neutral01:e}}})=>e};
  align-items: start;
`,P=(0,s.A)(_.A)`
  margin-top: 2px;
`,T=E.AH`
  z-index: 100001 !important;
`,S=150,h=8*b.k,v=E.AH`
  max-width: 150px;
  width: 150px;
`,D=Array.from({length:64},(e,t)=>t).map(e=>({label:d.iL.find(t=>t.value===e)?.label||e.toString(),value:e})),I=u.iK.filter(e=>![u.aS.TCP_UDP,u.aS.ICMPV6].includes(e)).map(e=>({label:(0,u.Wi)(e),value:e})),R=({isExistingItem:e})=>{const{values:t,resetForm:a,submitForm:r,isSubmitting:s,setFieldValue:E}=(0,l.j7)(),{formatMessage:_}=(0,i.tz)(),b=(0,n.useCallback)(()=>{r()},[r]),R=(0,n.useCallback)(e=>{e.value!==u.aS.NUMBER&&E("protocolNumber",0),e.value!==u.aS.TCP&&e.value!==u.aS.UDP&&(E("enableSourcePort",!1),E("enableDestinationPort",!1),E("qos_matching.src_port",void 0),E("qos_matching.dst_port",void 0)),E("qos_matching.protocol",e.value)},[E]);return n.createElement(c.A,{onRequestClose:()=>a(),isOpen:!0,title:n.createElement(i.sA,{id:e?"PORTS_EDIT_QOS_PROFILE":"PORTS_CREATE_NEW_QOS_PROFILE"}),size:"small",actions:[{disabled:s,text:n.createElement(i.sA,{id:"COMMON_ACTION_CANCEL"}),type:"button",variant:"default",onClick:()=>a()},{disabled:s,text:n.createElement(i.sA,{id:"COMMON_ACTION_SAVE"}),type:"button",variant:"primary",onClick:b}]},n.createElement(p.A,{flexDirection:"column",gap:C.kc},n.createElement(M,{gap:C.kc},n.createElement(P,{isActive:!0,variant:"fill"}),n.createElement(O.A,null,n.createElement(i.sA,{id:"PORTS_QOS_POLICY_INFO"}))),n.createElement(m.A,{marginBottom:0},n.createElement(A.A,{label:"COMMON_PROTOCOL",name:"qos_matching.protocol",options:I,translateLabel:!0,translateOptions:!0,type:"dropdown",isOpen:!0,portal:!0,optionContainerClassName:T,variant:"secondary",maxHeight:h,onChange:R})),t.qos_matching?.protocol===u.aS.NUMBER?n.createElement(m.A,{marginBottom:0},n.createElement(A.A,{className:v,max:255,min:0,name:"protocolNumber",width:80,type:"number",variant:"secondary",label:"COMMON_NUMBER",translateLabel:!0})):null,"number"!=typeof t.qos_matching?.protocol&&[u.aS.TCP,u.aS.UDP,u.aS.TCP_UDP].includes(t.qos_matching?.protocol)?n.createElement(n.Fragment,null,n.createElement(p.A,{gap:C.YC,alignItems:"center"},n.createElement(O.A,{size:"small",color:"text-3"},n.createElement(i.sA,{id:"PORTS_QOS_POLICY_MATCH_PORT"})),n.createElement(g.A,{description:n.createElement(i.sA,{id:"PORTS_QOS_POLICY_MATCH_PORT_DESC"}),width:250})),n.createElement(m.A,{marginBottom:0},n.createElement(N.l2,null,n.createElement(A.A,{name:"enableSourcePort",type:"realCheckbox"})),n.createElement(N.K_,{className:N.tk,htmlFor:"enableSourcePort",label:n.createElement(i.sA,{id:"COMMON_SOURCE_PORT"})}),t.enableSourcePort&&n.createElement(A.A,{className:v,full:!0,max:65535,min:1,name:"qos_matching.src_port",type:"number",variant:"secondary",width:80,placeholderValues:{value:10},placeholder:"COMMON_PLACEHOLDER_EG"})),n.createElement(m.A,{marginBottom:0},n.createElement(N.l2,null,n.createElement(A.A,{name:"enableDestinationPort",type:"realCheckbox"})),n.createElement(N.K_,{className:N.tk,htmlFor:"enableDestinationPort",label:n.createElement(i.sA,{id:"COMMON_DESTINATION_PORT"})}),t.enableDestinationPort&&n.createElement(A.A,{className:v,full:!0,max:65535,min:1,name:"qos_matching.dst_port",type:"number",variant:"secondary",width:80,placeholderValues:{value:10},placeholder:"COMMON_PLACEHOLDER_EG"}))):null,n.createElement(m.A,{marginBottom:0},n.createElement(p.A,{flexDirection:"column",gap:C.YC},n.createElement(p.A,{gap:C.YC,alignItems:"center"},n.createElement(O.A,{size:"small",color:"text-3"},n.createElement(i.sA,{id:"PORTS_FORM_FIELD_QOS_MATCHING"})),n.createElement(g.A,{description:n.createElement(i.sA,{id:"PORTS_FORM_FIELD_QOS_MATCHING_DESC"})})),n.createElement(p.A,{gap:C.Ln},n.createElement(A.A,{value:o.ev.DSCP,type:"radio",name:"matchingTrafficType"},n.createElement(i.sA,{id:d.kB[o.ev.DSCP]})),n.createElement(A.A,{value:o.ev.IP_PRECEDENCE,type:"radio",name:"matchingTrafficType"},n.createElement(i.sA,{id:d.kB[o.ev.IP_PRECEDENCE]})),n.createElement(A.A,{value:o.AC,type:"radio",name:"matchingTrafficType"},n.createElement(i.sA,{id:"COMMON_NONE"}))),t.matchingTrafficType===o.ev.DSCP?n.createElement(A.A,{name:"qos_matching.dscp_code",type:"dropdown",portal:!0,optionContainerClassName:T,variant:"secondary",options:D,label:"COMMON_CODE",translateLabel:!0,width:S,maxHeight:h}):null,t.matchingTrafficType===o.ev.IP_PRECEDENCE?n.createElement(A.A,{name:"qos_matching.ip_precedence_code",type:"dropdown",portal:!0,optionContainerClassName:T,variant:"secondary",options:d.Y$,label:"COMMON_CODE",translateLabel:!0,width:S,maxHeight:h}):null)),n.createElement(m.A,{marginBottom:0},n.createElement(N.l2,null,n.createElement(A.A,{name:"enableQosMarking",type:"realCheckbox"})),n.createElement(N.K_,{className:N.tk,htmlFor:"enableQosMarking",label:n.createElement(i.sA,{id:"PORTS_FORM_FIELD_QOS_MARKING"}),tooltip:n.createElement(i.sA,{id:"PORTS_FORM_FIELD_QOS_MARKING_DESC"})})),t.enableQosMarking?n.createElement(m.A,{marginBottom:0},n.createElement(p.A,{flexDirection:"column",gap:C.kc},n.createElement(O.A,{size:"small",color:"text-3"},n.createElement(i.sA,{id:"COMMON_TYPE"})),n.createElement(p.A,{gap:C.Ln},n.createElement(A.A,{value:o.ev.DSCP,type:"radio",name:"markingTrafficType"},n.createElement(i.sA,{id:d.kB[o.ev.DSCP]})),n.createElement(A.A,{value:o.ev.COS,type:"radio",name:"markingTrafficType"},n.createElement(i.sA,{id:d.kB[o.ev.COS]}))),t.markingTrafficType===o.ev.DSCP?n.createElement(A.A,{name:"qos_marking.dscp_code",type:"dropdown",portal:!0,optionContainerClassName:T,variant:"secondary",options:d.iL,label:"COMMON_CODE",translateLabel:!0,width:S,maxHeight:h}):null,t.markingTrafficType===o.ev.COS?n.createElement(A.A,{name:"qos_marking.cos_code",type:"dropdown",portal:!0,optionContainerClassName:T,variant:"secondary",options:d.TH,label:"COMMON_CODE",translateLabel:!0,width:S,maxHeight:h}):null)):null,n.createElement(m.A,{marginBottom:0},n.createElement(A.A,{className:v,max:7,min:0,name:"qos_marking.queue",type:"number",variant:"secondary",label:"COMMON_QUEUE",labelTooltip:_({id:"PORTS_QOS_POLICY_QUEUE_DESC"}),translateLabel:!0}))))};var x=a(877995),k=a(205975);const f=65535,y=e=>{const t=n.createElement(i.sA,{id:"COMMON_VALIDATION_INVALID_RANGE_WITH_FIELD_NAME",values:{min:0,max:7,name:e({id:"COMMON_QUEUES"}).toLocaleLowerCase()}}),a=n.createElement(i.sA,{id:"COMMON_VALIDATION_INVALID_RANGE_WITH_FIELD_NAME",values:{min:1,max:f,name:e({id:"COMMON_PORTS"}).toLocaleLowerCase()}}),l=n.createElement(i.sA,{id:"COMMON_VALIDATION_INVALID_RANGE",values:{min:0,max:255}});return r.A.object().shape({qos_marking:r.A.object().shape({cos_code:r.A.number().min(0).max(7).integer(),dscp_code:r.A.number().min(0).max(63),ip_precedence_code:r.A.number().min(0).max(7),queue:r.A.number().integer().required(t).label("COMMON_QUEUE").min(0,t).max(7,t)}),qos_matching:r.A.object().shape({cos_code:r.A.number().min(0).max(7),dscp_code:r.A.number().min(0).max(63),dst_port:r.A.number().integer().label("COMMON_DESTINATION_PORT").min(1,a).max(f,a).test({name:"dstPortRequired",test:(e,t)=>void 0!==e||!t.options.context.enableDestinationPort||t.createError({message:a})}),ip_precedence_code:r.A.number().min(0).max(7),protocol:r.A.string().label("COMMON_PROTOCOL"),src_port:r.A.number().integer().label("COMMON_SOURCE_PORT").min(1,a).max(f,a).test({name:"srcPortRequired",test:(e,t)=>void 0!==e||!t.options.context.enableSourcePort||t.createError({message:a})})}),enableDestinationPort:r.A.boolean(),enableSourcePort:r.A.boolean(),enableQosMarking:r.A.boolean(),matchingTrafficType:r.A.string().oneOf([o.ev.DSCP,o.ev.IP_PRECEDENCE,o.AC]),markingTrafficType:r.A.string().oneOf([o.ev.DSCP,o.ev.COS]),protocolNumber:r.A.number().label("COMMON_NUMBER").integer().min(0,l).max(255,l).required(l)})},L=({addCallback:e,hideModal:t,existingItem:a,existingItemIndex:r})=>{const{formatMessage:o}=(0,i.tz)(),m=(0,n.useCallback)(a=>{e(a,r),t()},[e,t,r]),c=(0,n.useMemo)(()=>a?(0,k.zN)(a):x.L,[a]);return n.createElement(l.l1,{initialValues:c,validationSchema:y(o),onSubmit:m,onReset:()=>{t()}},n.createElement(R,{isExistingItem:Boolean(a)}))}},814680:(e,t,a)=>{a.d(t,{W:()=>l,k:()=>n});const n=34,l=12*n}}]);