"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[27784],{756594(e,n,i){i.d(n,{Ay:()=>u,W9:()=>A,v$:()=>T});var t=i(274934),r=i(977872),o=i(548941),_=i(247816),s=i(409844),a=i(82939),d=i(408402),c=i(470070),l=i(897166),m=i(309130);const I=(0,_.A)("div")`
  pointer-events: none;
`,N=s.AH`
  opacity: ${m.xN};
`,A=({warning:e,children:n})=>{return e?(0,t.jsx)(d.A,{condition:!!e,wrapper:(i=e,e=>(0,t.jsx)(o.A,{description:(0,a.Kg)(i)?(0,t.jsx)(c.sA,{id:i}):i,portal:!0,isInteractive:!(0,a.Kg)(i),children:(0,t.jsx)(I,{children:e})})),children:n}):(0,t.jsx)(t.Fragment,{children:n});var i},T=({disabled:e,children:n})=>e?(0,t.jsx)(I,{className:N,style:{width:"100%"},children:n}):(0,t.jsx)(t.Fragment,{children:n}),u=({disableWithWarning:e,children:n})=>{const i=(0,r.d4)(l.EL);return(0,t.jsx)(A,{warning:e,children:e?(0,t.jsx)("div",{className:i?void 0:N,children:n}):n})}},327784(e,n,i){i.r(n),i.d(n,{default:()=>Ie});var t,r=i(274934),o=i(977872),_=i(237725),s=i(42220),a=i(602086),d=i(159469),c=i(762542),l=i(43506),m=i(19856),I=i(871808),N=i(121713),A=i(756782),T=i(205521),u=i(700444),O=i(291935),E=i(598990),f=i(897166),S=i(95857),x=i(890222),h=i(577751),j=i(969288),v=i(877840),G=i(115114);!function(e){e.E1="e1",e.E2="e2"}(t||(t={}));const g=(e,n,i)=>e._id===j.R6?{configuration_file:void 0,name:void 0,device_mac:i,unbind_wan_monitors:!1,redistribute_to_sd_wan:!1,redistribute_to_sd_wan_type:t.E2}:{configuration_file:e.frr_bgpd_config?{name:e.uploaded_file_name||"frr.conf",content:e.frr_bgpd_config}:void 0,name:e.description,device_mac:e.device_mac||i,unbind_wan_monitors:n.unbind_wan_monitors||!1,redistribute_to_sd_wan:e.redistribute_to_sd_wan??!1,redistribute_to_sd_wan_type:e.redistribute_to_sd_wan_type??t.E2};var p=i(241792),b=i(260334);const R=p.Ik({configuration_file:p.Ik({name:p.Yj().refine(e=>e.endsWith(".conf"),{message:(0,b.rn)("SETTINGS_ROUTING_BGP_CONFIGURATION_CONF_EXTENSION_VALIDATION")}),content:p.Yj({message:(0,b.rn)("SETTINGS_ROUTING_BGP_CONFIGURATION_CONF_EXTENSION_VALIDATION")}).min(1,{message:(0,b.rn)("SETTINGS_ROUTING_BGP_CONFIGURATION_FILE_EMPTY")})},{message:(0,b.rn)("SETTINGS_ROUTING_BGP_CONFIGURATION_CONF_EXTENSION_VALIDATION")}),name:p.Yj({required_error:(0,b.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).nonempty({message:(0,b.rn)("COMMON_VALIDATION_NAME_REQUIRED")}),device_mac:p.Yj({required_error:(0,b.rn)("COMMON_VALIDATION_SELECT_A_DEVICE")}),unbind_wan_monitors:p.zM().optional(),redistribute_to_sd_wan:p.zM().optional(),redistribute_to_sd_wan_type:p.fc(t).optional()});var w=i(625133),M=i(470070);const C=({form:e})=>(0,r.jsx)(w.A,{control:e.control,name:"unbind_wan_monitors",tooltip:(0,r.jsx)(M.sA,{id:"SETTINGS_ROUTING_BGP_OVERRIDE_WAN_MONITORS_TOOLTIP"}),children:(0,r.jsx)(M.sA,{id:"SETTINGS_ROUTING_BGP_OVERRIDE_WAN_MONITORS"})});var U=i(689941),D=i(796091),P=i(756594),B=i(793442),F=i(100978),y=i(726831),W=i(184931);const L={[t.E1]:"SETTINGS_ROUTING_OSPF_METRIC_TYPE_E1",[t.E2]:"SETTINGS_ROUTING_OSPF_METRIC_TYPE_E2"},V=({form:e,disabledWarning:n})=>{const{formatMessage:i}=(0,M.tz)(),o=(0,s.FH)({control:e.control,name:"redistribute_to_sd_wan"}),_=(0,W.mQ)(),d=(0,a.useMemo)(()=>[t.E1,t.E2].map(e=>({value:e,label:i({id:L[e]})})),[i]);return(0,r.jsxs)(F.A,{alignItems:"flex-start",justifyContent:"space-between",children:[(0,r.jsx)(P.W9,{warning:!!_&&n,children:(0,r.jsx)(D.A,{children:(0,r.jsx)(w.A,{tooltip:(0,r.jsx)(M.sA,{id:"SETTINGS_ROUTING_BGP_REDISTRIBUTE_TO_SD_WAN_TOOLTIP",values:{link:(0,r.jsx)(B.A,{id:"COMMON_SD_WAN",noWrap:!0,href:y.A.unifiSiteMagic})}}),tooltipProps:{isInteractive:!0},control:e.control,name:"redistribute_to_sd_wan",isChecked:!_&&void 0,children:(0,r.jsx)(M.sA,{id:"SETTINGS_ROUTING_BGP_REDISTRIBUTE_TO_SD_WAN"})})})}),o?(0,r.jsx)(F.A,{width:72,children:(0,r.jsx)(U.A,{control:e.control,name:"redistribute_to_sd_wan_type",options:d})}):null]})};var k=i(635891);const Y=({form:e})=>(0,r.jsx)(k.A,{control:e.control,name:"name",label:(0,r.jsx)(M.sA,{id:"COMMON_NAME"})});var X=i(754924),H=i(741331),$=i(956978),z=i(901389);const K=({form:e,isExistingRecord:n})=>{const i=(0,o.d4)(X.UV),t=(0,o.d4)(H._V),_=(0,o.d4)(X.U$),d=(0,I.A)(S.Xj.BGP_ROUTING),c=(0,s.FH)({control:e.control,name:"device_mac"}),l=(0,a.useMemo)(()=>c?i.find(e=>e.mac===c):void 0,[i,c]),m=(0,a.useMemo)(()=>i.map(e=>({value:e.mac,label:e.name||""})).concat(d?[{value:_.mac,label:_.name||""}]:[]).map(e=>(n||(e.disabled=t.some(n=>n.device_mac===e.value),e.message=(0,r.jsx)(M.sA,{id:"SETTINGS_ROUTING_BGP_DISABLED_DEVICE_TOOLTIP"})),e)),[i,d,_,n,t]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(U.A,{control:e.control,name:"device_mac",label:(0,r.jsx)(M.sA,{id:"COMMON_DEVICE"}),options:m}),l&&(0,$.cR8)(l)?(0,r.jsx)(z.A,{children:(0,r.jsx)(M.sA,{id:"SETTINGS_BGP_ECS_AGGREGATION_WARNING"})}):null]})};var Q=i(108940),q=i(526744),J=i(775250),Z=i(663723),ee=i(559388),ne=i(494824),ie=i(888682),te=i(247816),re=i(296261),oe=i(246798),_e=i(833466),se=i(309130),ae=i(164487),de=i(597750);const ce=(0,te.A)(Q.A)`
  /* Prevent overflowing the button for long file names and allow truncation. */
  max-width: 100%;
  height: 24px;
  overflow: hidden;
  align-items: center;
  display: flex;
  > div {
    max-width: 100%;
  }
`,le=({form:e})=>{const{field:n}=(0,s.as)({control:e.control,name:"configuration_file"}),i=n.value?.name,t=n.value?.content,o=!!n.value,_=(0,a.useMemo)(()=>{if(!t)return null;try{return`data:application/octet-stream;charset=utf-8;base64,${btoa(t)}`}catch{return null}},[t]);return(0,r.jsxs)(de.A,{children:[(0,r.jsx)(ae.A,{htmlFor:"configuration_file",tooltip:(0,r.jsx)(M.sA,{id:"SETTINGS_ROUTING_BGP_CONFIGURATION_FILE_TOOLTIP",values:{link:(0,r.jsx)(B.A,{id:"COMMON_LEARN_MORE",href:y.A.bgpArticle,noWrap:!0})}}),tooltipProps:{isInteractive:!0},children:(0,r.jsx)(M.sA,{id:"SETTINGS_COMMON_CONFIGURATION_FILE"})}),(0,r.jsxs)(F.A,{maxWidth:"100%",flexDirection:"column",children:[(0,r.jsxs)(F.A,{gap:se.xO,alignItems:"center",maxWidth:"100%",overflow:"hidden",minHeight:_e.b,children:[(0,r.jsx)(ce,{onChange:async e=>{const i=e.target?.files?.[0];n.onChange(i?{name:i.name,content:await(0,re.Gu)(i).catch(()=>{})}:null)},variant:"inline",size:"medium",Icon:o?ne.A:Z.A,iconProps:{isActive:!0},children:o?(0,r.jsx)(J.A,{variant:"inherit",isTruncated:!0,children:i||(0,r.jsx)(M.sA,{id:"SETTINGS_COMMON_CONFIGURATION_FILE"})}):(0,r.jsx)(M.sA,{id:"COMMON_UPLOAD"})},i),o?(0,r.jsxs)(F.A,{gap:se.YC,alignItems:"center",children:[_?(0,r.jsx)(q.A,{component:"a",href:_,download:i,Icon:ie.A,variant:"inline"}):null,(0,r.jsx)(q.A,{Icon:ee.A,variant:"inline",color:"danger",onClick:()=>n.onChange(null)})]}):null]}),(0,r.jsx)(oe.Ay,{form:e,name:"configuration_file",noMargin:!0})]}),(0,r.jsx)("input",{type:"hidden",...n,value:n.value?.content})]})},me="bgp-settings-form",Ie=({activeItem:e,typeSelector:n})=>{const i=(0,o.wA)(),t=(0,_.W6)(),p=(0,l.A)(`${j.p7}?${j.Rp}=${j.O4}`),b=(0,o.d4)(f.vc),w=!e?._id||e._id?.startsWith(j.R6)?void 0:e,M=(0,o.d4)(O.oP),U=(0,I.A)(S.Xj.UNBOUND_WAN_MONITOR),D=(0,I.A)(S.Xj.BGP_REDISTRIBUTION_INTO_OSPF),P=(0,o.d4)(h.j),B=!!(0,m.A)(S.Xj.SDWAN_MESH)?.enabled,F=!!(0,m.A)(S.Xj.SDWAN_HUB_SPOKE)?.enabled,y=P||B||F,W=!!w,L=(0,N.m)({schema:R,defaultValues:g(e,M,b)});(0,c.y)(L);const k=(0,s.FH)({control:L.control,name:"device_mac"}),X=(0,a.useMemo)(()=>L.handleSubmit(async e=>{const n=e.device_mac===b,r={_id:w?._id,enabled:!w?._id||!!w.error&&!w.enabled||w.enabled,frr_bgpd_config:e.configuration_file.content,uploaded_file_name:e.configuration_file.name,description:e.name,device_mac:n?void 0:e.device_mac,redistribute_to_sd_wan:D&&n&&y?e.redistribute_to_sd_wan:void 0,redistribute_to_sd_wan_type:D&&n&&y&&e.redistribute_to_sd_wan?e.redistribute_to_sd_wan_type:void 0},o=W?x.B7:x.kY;try{await i(o(n,r)),n&&U&&await i((0,E.fU)({...M,unbind_wan_monitors:e.unbind_wan_monitors})),i((0,x.kC)()),i((0,T.SQ)(!1)),i((0,T.K5)()),w||t.push(p)}catch{i((0,u.ox)({icon:d.C.danger,message:"SETTINGS_ROUTING_BGP_SAVE_ERROR"}))}}),[L,b,w,W,i,U,D,y,M,t,p]);return(0,r.jsxs)("form",{onSubmit:X,id:me,children:[(0,r.jsxs)(A.A,{children:[n,(0,r.jsx)(Y,{form:L}),(0,r.jsx)(K,{form:L,isExistingRecord:!!w}),(0,r.jsx)(le,{form:L}),U&&k===b?(0,r.jsx)(C,{form:L}):null,D?(0,r.jsx)(v.A,{isDisabled:k!==b||!y,children:(0,r.jsx)(V,{form:L,disabledWarning:!y&&"SETTINGS_ROUTING_BGP_REDISTRIBUTE_TO_SD_WAN_DISABLED_TOOLTIP"})}):null]}),(0,r.jsx)(G.A,{onFormSubmit:X,onFormCancel:()=>L.reset(),isDirty:L.formState.isDirty||!w,hideCancelButton:!L.formState.isDirty,submitButtonText:w?void 0:"COMMON_ACTION_ADD",form:me,isSubmitting:L.formState.isSubmitting})]},e._id)}}}]);