"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[53304],{547967(e,t,i){i.d(t,{AC:()=>m,D7:()=>A,Ie:()=>N,JL:()=>E,JX:()=>O,KY:()=>I,O2:()=>p,Op:()=>_,Rm:()=>u,e$:()=>T,t7:()=>h,yr:()=>g});var n=i(938984),o=i(814557),s=i(247816),r=i(409844),a=i(291508),d=i(61322),l=i(309130),c=i(100978);const _=(0,s.A)(c.A,(0,a.A)("inline","wrap"))`
  position: relative;
  flex: ${({inline:e})=>e?"1 1 0":"0 0 100%"};
  align-items: flex-start;
  flex-flow: ${({wrap:e})=>"row "+(e?"wrap":"nowrap")};
  gap: ${l.kc};
`,p=(0,s.A)(c.A,(0,a.A)("editMaxHeight","editFieldWrap"))`
  flex-direction: column;
  max-height: ${({editMaxHeight:e})=>`${e||300}px`};
  overflow-y: auto;
  overflow-x: hidden;
  gap: ${l.YC};

  ${({editFieldWrap:e,theme:{themeName:t}})=>e?`\n    gap: 0;\n\n    > * {\n      border-bottom: ${o.Ay[`desktop-border-divider-${t}`]};\n      padding-bottom: ${l.kc};\n      padding-top: ${l.kc};\n    }\n\n    > *:first-child {\n      padding-top: 0;\n    }\n\n    > *:last-child {\n      border-bottom: none;\n      padding-bottom: 0;\n    }\n  `:""}
`,m=(0,s.A)("div",(0,a.A)("isWindowsTable","rows","tableMaxHeight","marginTop"))`
  width: 100%;
  // windows table inherits height from parent container
  height: ${({rows:e,isWindowsTable:t})=>t&&`${d.I.ROW_HEIGHT*e+d.I.HEADER_HEIGHT}`}px;
  max-height: ${({tableMaxHeight:e})=>e?`${e}px`:"auto"};
  margin-top: ${({marginTop:e})=>e||l.Ln};

  table {
    td {
      max-width: 170px;

      span {
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
`,A=(0,s.A)(n.A)`
  margin-right: ${l.YC};
`,I=r.AH`
  :first-of-type {
    padding: 0 ${l.fS} 0 0px;
  }
`,u="drag-and-drop-table-row-placeholder",h=(0,s.A)(c.A)`
  flex-direction: column;

  /* Adjust weird padding on the right side for the ID column when right aligned (drag & drop table) */
  table > thead > tr > th:last-of-type {
    padding-right: ${l.kc};
  }

  /* Add missing border between drag and drop groups (tbody elements) */
  table > tbody {
    border-bottom: ${({theme:{themeName:e}})=>o.Ay[`desktop-border-divider-${e}`]};
  }
  /* Last cell in table is hover content which is not used in this table */
  table > tbody[data-rbd-droppable-context-id] td:not(:last-of-type),
  table > thead > tr > th {
    /* Align drag & drop table cell padding to regular table padding */
    padding-right: ${l.kc} !important;
  }
  /* Align drop zone placeholder row when a row is dragged to matched the CSS overrides for drag and drop table we use */
  table .${u} {
    display: flex;
  }
`,E=r.AH`
  /* This is default for the table rows, so we need it for the header. */
  display: flex;
  width: 100%;

  > th:first-child {
    /* Since we flex the header, we must specify this to align with the table rows. */
    width: 24px;
  }
  > th:not(:first-child) {
    /* Something inside UIC sets the padding to 8px for table header and 5px for table rows. This aligns it to make flex work. */
    padding-right: ${l.kc} !important;
  }
`,T=r.AH`
  /* Override the padding-right of the first column to align with manage + drop modes. */
  > th:first-child {
    padding-right: ${l.kc} !important;
  }
  > th:first-child:has(> label) {
    padding-right: 1px !important;
    width: 36px;
  }
`,g=r.AH`
  /* UIC already does this for some table states, like drag and drop and when in manage mode. If we just use this ALWAYS, we're avoiding many issues related to using different alignment techniques in different places. */
  display: flex;
`,O=r.AH`
  tbody {
    display: flex;
    flex-direction: column;
  }
`;function N(e,t){return r.AH`
    width: ${t.width?`${t.width}px`:"auto"};
    min-width: ${t.minWidth?`${t.minWidth}px`:"0px"};
    flex: ${t.growthFactor||0} !important;
    padding-left: ${l.kc} !important;
    padding-right: ${l.kc} !important;
  `}},256468(e,t,i){var n;i.d(t,{EE:()=>s,Uh:()=>n,Vf:()=>o}),function(e){e.SINGLE="single",e.PLURAL="plural"}(n||(n={}));const o="editActive",s=20},612389(e,t,i){i.d(t,{A:()=>_});var n=i(274934),o=i(814557),s=i(938984),r=i(247816),a=i(263705),d=i(309130),l=i(100978);const c=(0,r.A)(s.A)`
  line-height: 20px;
`,_=({icon:e,description:t,action:i,footer:s,background:r,..._})=>{const{themeName:p}=(0,a.u)();return(0,n.jsxs)(l.A,{flexGrow:1,borderRadius:d.YC,padding:d.kc,background:r||o.Ay[`desktop-color-neutral-01-${p}`],gap:d.kc,flexDirection:"column",..._,children:[(0,n.jsxs)(l.A,{flexGrow:1,gap:d.kc,children:[e,t?(0,n.jsx)(c,{size:"medium",children:t}):null,i?(0,n.jsx)(l.A,{marginLeft:"auto",children:(0,n.jsx)(c,{size:"medium",children:i})}):null]}),s]})}},307336(e,t,i){i.d(t,{s:()=>s});var n=i(814557),o=i(707096);const s=(0,i(247816).A)(o.A)`
  color: ${({theme:{themeName:e}})=>n.Ay[`desktop-color-neutral-08-${e}`]};
`},753959(e,t,i){i.d(t,{A:()=>d});var n=i(274934),o=i(814557),s=i(853777),r=i(263705),a=i(612389);const d=({children:e,icon:t,background:i,...d})=>{const{themeName:l}=(0,r.u)();return(0,n.jsx)(a.A,{icon:t||(0,n.jsx)(s.A,{variant:"fill",size:"original",color:o.Ay[`desktop-color-ublue-06-${l}`]}),description:e,background:i,...d})}},737364(e,t,i){i.d(t,{A:()=>p});var n=i(274934),o=i(599110),s=i(309130),r=i(580988),a=i(100978),d=i(470070),l=i(421314),c=i(300626),_=i(174710);const p=({enabled:e,label:t,tooltipItems:i,neverShowListMarkers:p,limit:m=20,seeMoreCallback:A,isInteractive:I,title:u,showMatchOppositeIcon:h,listGap:E,iconProps:T})=>(0,n.jsxs)(a.A,{flex:1,overflow:"hidden",gap:s.YC,children:[h?(0,n.jsx)(r.A,{enabled:e}):null,(0,n.jsx)(c.A,{tooltip:(0,n.jsx)(_.A,{title:u,position:"top",isInteractive:Boolean(A)||I,items:i,showListMarkers:!p,maxItemCount:m,getItemKey:(e,t)=>t,renderItem:e=>e,listGap:E,renderShowMore:A?()=>(0,n.jsx)(o.A,{variant:"inline",onClick:A,children:(0,n.jsx)(d.sA,{id:"COMMON_SEE_MORE"})}):void 0,iconProps:T}),children:t?(0,n.jsx)(l.A,{color:e?"inherit":"disabled",children:t}):null})]})},174710(e,t,i){i.d(t,{A:()=>r});var n=i(274934),o=i(304151),s=i(158498);const r=function({items:e,getItemKey:t,renderItem:i,maxItemCount:r,renderShowMore:a,showListMarkers:d,title:l,position:c,isInteractive:_,cursorType:p,listGap:m,iconProps:A}){return(0,n.jsx)(o.A,{title:l,position:c,isInteractive:_,cursorType:p,description:(0,n.jsx)(s.A,{items:e,getItemKey:t,renderItem:i,maxItemCount:r,listGap:m,renderShowMore:a,showListMarkers:d}),iconProps:A})}},580988(e,t,i){i.d(t,{A:()=>l});var n=i(274934),o=i(125799),s=i(815879),r=i(309130),a=i(100978),d=i(470070);const l=({enabled:e})=>(0,n.jsx)(a.A,{opacity:e?void 0:r.xN,children:(0,n.jsx)(o.A,{description:(0,n.jsx)(d.sA,{id:"COMMON_MATCH_OPPOSITE"}),portal:!0,children:(0,n.jsx)(s.A,{size:"original"})})})},300626(e,t,i){i.d(t,{A:()=>r});var n=i(274934),o=i(309130),s=i(100978);const r=({children:e,tooltip:t})=>(0,n.jsxs)(s.A,{maxWidth:"100%",overflow:"hidden",gap:o.YC,alignItems:"center",children:[e?(0,n.jsx)(s.A,{flex:1,overflow:"hidden",children:e}):null,t]})},384783(e,t,i){i.d(t,{A:()=>r});var n=i(274934),o=i(832162),s=i(826600);const r=({children:e=null,hideModal:t,onRequestClose:i,portalSelector:r=s.J,forwardedRef:a=null,...d})=>(0,n.jsx)(o.A,{isOpen:!0,shouldCloseOnEsc:!0,onRequestClose:i||t,parentSelector:r,ref:a,...d,children:e})},826600(e,t,i){i.d(t,{J:()=>n,g:()=>o});const n=()=>document.getElementById("modal-container"),o=()=>document.getElementById("modal-settings-container")},122985(e,t,i){i.d(t,{A:()=>He});var n,o,s=i(274934),r=i(977872),a=i(42220),d=i(602086),l=i(159469),c=i(464920),_=i(762542),p=i(404056),m=i(292027),A=i(199742),I=i(871808),u=i(635891),h=i(877840),E=i(436417),T=i(449339),g=i(309130),O=i(756782),N=i(100978),f=i(205521),x=i(700444),S=i(470070),C=i(623568),M=i(423564),R=i(197571),v=i(6276),D=i(897166),j=i(95857),b=i(969288),y=i(441966),w=i(633502),L=i(115114);!function(e){e.ANY="any",e.IP="ip",e.DOMAIN="domain",e.REGION="region"}(n||(n={})),function(e){e.ANY="any",e.DEVICES_AND_NETWORKS="devices_and_networks"}(o||(o={}));var k=i(241792),P=i(765282),G=i(745454),H=i(810024),F=i(149450),V=i(260334);const Y=e=>k.Ik({name:k.Yj({message:(0,V.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).min(1,{message:(0,V.rn)("COMMON_VALIDATION_NAME_REQUIRED")}).max(128),interface:k.Yj(),next_hop:k.Yj().optional(),kill_switch_enabled:k.zM(),source:k.gM("type",[k.Ik({type:k.eu(o.ANY)}),k.Ik({type:k.eu(o.DEVICES_AND_NETWORKS),devices_and_networks:k.YO(k.Yj()).min(1)})]),destination:k.gM("type",[k.Ik({type:k.eu(n.ANY)}),k.Ik({type:k.eu(n.DOMAIN),domains:k.YO(k.Yj(),{message:(0,V.rn)("SETTINGS_ROUTING_QOS_DOMAINS_VALIDATION")}).min(1,{message:(0,V.rn)("SETTINGS_ROUTING_QOS_DOMAINS_VALIDATION")})}),k.Ik({type:k.eu(n.REGION),regions:k.YO(k.Yj(),{message:(0,V.rn)("COMMON_VALIDATION_SELECT_AT_LEAST_ONE",{target:(0,V.rn)("COMMON_REGION")})}).min(1,{message:(0,V.rn)("COMMON_VALIDATION_SELECT_AT_LEAST_ONE",{target:(0,V.rn)("COMMON_REGION")})}).max(150,{message:(0,V.rn)("COMMON_VALIDATION_TOTAL_ENTRIES_LIMIT",{limit:150})})}),k.Ik({type:k.eu(n.IP),ips:k.YO(k.Ie()).optional(),simple_ips:k.YO(k.Yj()).optional()})])}).superRefine((t,i)=>{const o=e.find(e=>e._id===t.interface);if(o){if((0,M.ok)(o)&&t.destination.type===n.IP){const e=k.YO(F.B).min(1).safeParse(t.destination?.simple_ips);e.error&&e.error.issues.forEach(e=>{i.addIssue({...e,path:["destination","simple_ips"]})})}if(!(0,M.ok)(o)&&t.destination.type===n.IP){const e=k.YO(k.Ie()).min(1).safeParse(t.destination?.ips);e.error&&e.error.issues.forEach(e=>{i.addIssue({...e,path:["destination","ips"]})})}}}).superRefine((t,i)=>{const n=e.find(e=>e._id===t.interface);if(!n||!(0,M.ok)(n)||!n.ip_subnet)return;const o=F.B.refine(e=>(0,H.xc)(n.ip_subnet,e),{message:(0,V.rn)("SETTINGS_TRAFFIC_ROUTES_NEXT_HOP_ERROR")}).safeParse(t.next_hop);o.error&&o.error.issues.forEach(e=>{i.addIssue({...e,path:["next_hop"]})});const s=(0,G.subnet)(n.ip_subnet).info();t.next_hop!==s.networkAddress&&t.next_hop!==s.broadcastAddress||i.addIssue({code:P.eq.custom,message:(0,V.rn)("SETTINGS_NEXT_HOP_NOT_NETWORK_OR_BROADCAST_ADDRESS"),path:["next_hop"]})});var W=i(482609),$=i(244081),U=i(749445),K=i(254590),B=i(307336),Q=i(243436),X=i(650632),z=i(556059),J=i(287196),q=i(164398),Z=i(570801),ee=i(831433),te=i(239627),ie=i(928609);const ne=[],oe=function({form:e,name:t,valueDelimiter:i,networkConfig:n,deviceConfig:o,...l}){const c=(0,r.wA)(),_=(0,r.d4)(R.Ct),{formatMessage:p}=(0,S.tz)(),m=(0,r.d4)(J.g),A=(0,r.d4)(Z.lW);(0,d.useEffect)(()=>{c((0,te.$3)(void 0,{crudCacheStrategy:{type:$.e.CACHE}})),c((0,te.bk)(void 0,{crudCacheStrategy:{type:$.e.CACHE}})),c((0,te.QG)({queryParams:{withinHours:A}},{crudCacheStrategy:{type:$.e.CACHE}}))},[c,A]);const I=(0,a.FH)({control:e.control,name:t})||ne,u=(0,d.useMemo)(()=>I.flatMap(e=>{const t=(0,ie.tY)(e,i);return t.type===z.Q.CLIENT?[t.client_mac]:[]}),[I,i]),h=(e,t)=>"subnet"===t?(0,M.ok)(e)&&e.ip_subnet?(0,H.nX)(e.ip_subnet):void 0:"",E=(0,d.useMemo)(()=>_.filter(q.mH).map(e=>{const t=(0,Q.A1)(e),o=t&&!n?.hideVlanId?`${e.name} (${t})`:e.name;return{value:(0,ie.gb)(e._id,i),label:o,group:z.Q.NETWORK,image:(0,s.jsx)(B.s,{height:20,width:20}),additionalInfo:h(e,n?.additionalInfo)}}),[n?.additionalInfo,n?.hideVlanId,_,i]),T=(e,t)=>"mac"===t?e.mac:"",g=(0,d.useMemo)(()=>{const e=m.flatMap(e=>"mac"in e?[{label:(0,ee.tn)(e)||K.L,value:(0,ie.om)(e.mac,i),group:z.Q.CLIENT,image:(0,s.jsx)(N.A,{alignItems:"center",justifyContent:"center",width:22,height:22,children:(0,s.jsx)(X.A,{client:e,height:20,width:20})}),additionalInfo:T(e,o?.additionalInfo)}]:[]),t=u.filter(t=>!e.some(e=>{const n=(0,ie.tY)(e.value,i);return e.value===t||n.type===z.Q.CLIENT&&n.client_mac===t})).map(e=>({value:(0,ie.om)(e,i),label:e,group:z.Q.CLIENT,additionalInfo:e}));return[...e,...t]},[u,o?.additionalInfo,m,i]),O=(0,d.useMemo)(()=>[...E.length?[{label:p({id:"COMMON_NETWORKS"}),value:"network-title",group:z.Q.NETWORK,groupTitle:!0}]:[],...E,...g.length?[{label:p({id:"COMMON_DEVICES"}),value:"devices-title",group:z.Q.CLIENT,groupTitle:!0}]:[],...g],[g,p,E]);return(0,s.jsx)(U.A,{control:e.control,name:t,options:O,truncateLabels:!0,triggerButtonText:(0,s.jsx)(S.sA,{id:"COMMON_SELECT"}),...l})};var se=i(787481),re=i(846294);const ae=({children:e,disabled:t})=>(0,s.jsx)(re.A,{reason:t?(0,s.jsx)(S.sA,{id:"SETTINGS_TRAFFIC_ROUTES_FEATURE_NOT_AVAILABLE_WITH_LOCAL_NETWORK"}):null,children:e}),de=({form:e})=>{const t=(0,r.d4)(R.Ct),i=(0,a.FH)({control:e.control,name:"source.type"}),n=(0,a.FH)({control:e.control,name:"interface"}),l=(0,d.useMemo)(()=>t.find(e=>e._id===n),[n,t]),c=!!l&&(0,M.ok)(l);return(0,s.jsxs)(O.A,{title:(0,s.jsx)(S.sA,{id:"COMMON_SOURCE"}),tooltip:(0,s.jsx)(S.sA,{id:"SETTINGS_TRAFFIC_ROUTES_FORM_TARGET_DEVICES_DESCRIPTION"}),children:[(0,s.jsxs)(se.A,{children:[(0,s.jsx)(W.A,{control:e.control,name:"source.type",value:o.ANY,children:(0,s.jsx)(S.sA,{id:"COMMON_ANY"})}),(0,s.jsx)(ae,{disabled:c&&i!==o.DEVICES_AND_NETWORKS,children:(0,s.jsx)(W.A,{control:e.control,name:"source.type",value:o.DEVICES_AND_NETWORKS,children:(0,s.jsx)(S.sA,{id:"SETTINGS_DEVICES_AND_NETWORKS"})})})]}),i===o.DEVICES_AND_NETWORKS?(0,s.jsx)(oe,{form:e,name:"source.devices_and_networks",valueDelimiter:":::",networkConfig:{additionalInfo:"subnet"},deviceConfig:{additionalInfo:"mac"}}):null]})};var le=i(625133),ce=i(796091);const _e=({form:e})=>(0,s.jsx)(ce.A,{children:(0,s.jsx)(le.A,{control:e.control,name:"kill_switch_enabled",tooltip:(0,s.jsx)(S.sA,{id:"SETTINGS_KILL_SWITCH_TOOLTIP"}),children:(0,s.jsx)(S.sA,{id:"COMMON_KILL_SWITCH"})})});var pe=i(370115),me=i(689941),Ae=i(167933),Ie=i(754924);const ue=({form:e})=>{const{formatMessage:t}=(0,S.tz)(),i=(0,r.d4)(R.Ct),l=(0,r.d4)(Ie.AL),c=(0,r.d4)(Ae.GW),_=(0,I.A)(j.Xj.TRAFFIC_ROUTES_OPENVPN_S2S_VPN),p=(0,I.A)(j.Xj.TRAFFIC_ROUTES_IPSEC_S2S_VPN),m=(0,I.A)(j.Xj.TRAFFIC_ROUTES_WIREGUARD_S2S_VPN),A=(0,a.FH)({control:e.control,name:"destination.type"}),u=(0,a.FH)({control:e.control,name:"interface"}),h=(0,d.useMemo)(()=>{const n={isOpenVpnTrafficRoutesSupported:c,isSiteToSiteOpenVpnTrafficRoutesSupported:_,isSiteToSiteIpsecTrafficRoutesSupported:p,isSiteToSiteWireguardTrafficRoutesSupported:m,trafficRuleTarget:A,networks:i},o=i.filter(e=>{if(u===e._id)return!0;const t=(0,M.ok)(e),i=(0,q.kY)(e,n),o=(0,q.XD)(e,n);return!(t||!i&&!o)}),r=e.formState.defaultValues?.interface;return(0,pe.MG)(o,t,l?.name,e=>{const t=(0,q.XD)(e,n);return{disabled:!!t,tooltipDescription:t?(0,s.jsx)(S.sA,{id:t}):void 0}},r)},[c,_,p,m,A,i,e.formState.defaultValues?.interface,t,l?.name,u]);return(0,s.jsx)(me.A,{control:e.control,name:"interface",options:h,onChange:(t,{field:s})=>{s.onChange(t),e.setValue("next_hop","");const r=i.find(e=>e._id===t);r&&(0,M.ok)(r)&&(e.setValue("source.type",o.ANY),e.setValue("destination.type",n.IP))},label:(0,s.jsx)(S.sA,{id:"SETTINGS_TRAFFIC_ROUTES_FORM_INTERFACE_S2S_VPN"}),tooltip:(0,s.jsx)(S.sA,{id:"SETTINGS_TRAFFIC_ROUTES_SOURCE_INTERFACE_DESCRIPTION"}),placeholder:t({id:"SETTINGS_TRAFFIC_ROUTES_INTERFACE_SELECT"}),renderOption:pe.Ku})};var he=i(942460),Ee=i(625796),Te=i(198301),ge=i(680163),Oe=i(139847),Ne=i(570866),fe=i(443444);const xe=({form:e})=>{const{formatMessage:t}=(0,S.tz)(),i=(0,V.L_)(),n=(0,r.d4)(R.Ct),o=(0,a.FH)({control:e.control,name:"interface"}),l=(0,d.useMemo)(()=>n.find(e=>e._id===o),[o,n]),c=!!l&&(0,M.ok)(l);return(0,s.jsx)(s.Fragment,{children:c?(0,s.jsx)(a.xI,{control:e.control,name:"destination.simple_ips",render:({field:e,fieldState:n,formState:o})=>(0,s.jsx)(ge.A,{value:e.value||[],onChange:t=>e.onChange(t),invalid:n.invalid?i((0,a.Jt)(o.errors,e.name)?.message)||!0:void 0,labels:{fieldLabel:"SETTINGS_IP_ADDRESS_SUBNET",modalTitle:"SETTINGS_ADD_MULTIPLE_IPS",modalFieldPlaceholder:t({id:"SETTINGS_ADD_MULTIPLE_IPS_PLACEHOLDER"})},fieldValidation:{getDuplicationMessage:()=>t({id:"SETTINGS_DUPLICATE_IP_VALIDATION"}),validate:e=>!e||Ne.M9.test(e)?t({id:"COMMON_VALIDATION_VALID_IPV4"}):(0,fe.GH)(Oe.oi.IPV4,e,!0,t)},extraFieldConfig:{placeholder:"COMMON_ENTER_IP_ADDRESS",placeholderValues:{version:Oe.oi.IPV4}}})},"simple"):(0,s.jsx)(a.xI,{control:e.control,name:"destination.ips",render:({field:e,fieldState:t,formState:n})=>(0,s.jsx)(Te.f,{value:e.value||[],onChange:t=>e.onChange(t),invalid:t.invalid?i((0,a.Jt)(n.errors,e.name)?.message)||!0:void 0})},"advanced")})},Se=({form:e})=>{const t=(0,r.d4)(R.Ct),i=(0,I.A)(j.Xj.TRAFFIC_RULE_AND_ROUTE_REGIONS),o=(0,a.FH)({control:e.control,name:"destination.type"}),l=(0,a.FH)({control:e.control,name:"interface"}),c=(0,d.useMemo)(()=>t.find(e=>e._id===l),[l,t]),_=!!c&&(0,M.ok)(c);return(0,s.jsxs)(O.A,{title:(0,s.jsx)(S.sA,{id:"COMMON_DESTINATION"}),tooltip:(0,s.jsx)(S.sA,{id:"SETTINGS_POLICY_BASED_ROUTES_DESTINATION_DESCRIPTION"}),children:[(0,s.jsxs)(se.A,{children:[(0,s.jsx)(ae,{disabled:_&&o!==n.ANY,children:(0,s.jsx)(W.A,{control:e.control,name:"destination.type",value:n.ANY,children:(0,s.jsx)(S.sA,{id:"COMMON_ANY"})})}),(0,s.jsx)(W.A,{control:e.control,name:"destination.type",value:n.IP,children:(0,s.jsx)(S.sA,{id:"COMMON_IP"})}),(0,s.jsx)(ae,{disabled:_&&o!==n.DOMAIN,children:(0,s.jsx)(W.A,{control:e.control,name:"destination.type",value:n.DOMAIN,children:(0,s.jsx)(S.sA,{id:"COMMON_DOMAIN"})})}),i||o===n.REGION?(0,s.jsx)(ae,{disabled:_&&o!==n.REGION,children:(0,s.jsx)(W.A,{control:e.control,name:"destination.type",value:n.REGION,children:(0,s.jsx)(S.sA,{id:"COMMON_REGION"})})}):null]}),o===n.IP?(0,s.jsx)(xe,{form:e}):null,o===n.DOMAIN?(0,s.jsx)(he.A,{form:e,name:"destination.domains"}):null,o===n.REGION?(0,s.jsx)(U.A,{control:e.control,name:"destination.regions",options:Ee.Ay,triggerButtonText:(0,s.jsx)(S.sA,{id:"COMMON_SELECT"}),truncateLabels:!0,isWindowed:!0}):null]})};var Ce=i(420174),Me=i(753959),Re=i(793442),ve=i(341699);const De=({existingRecord:e})=>(0,s.jsx)(Me.A,{children:(0,s.jsxs)(N.A,{flexDirection:"column",children:[(0,s.jsx)(S.sA,{id:"COMMON_MANAGED_BY_FABRIC",values:{feature:(0,s.jsx)(S.sA,{id:"COMMON_POLICY_BASED_ROUTE"})}}),(0,s.jsx)(Re.A,{id:"COMMON_VIEW_IN_SITE_MANAGER",href:(0,ve.vF)(e?.cloud_template)})]})});var je=i(640708),be=i(258978);const ye=":::";var we;!function(e){e.DEVICE="device",e.NETWORK="network"}(we||(we={}));const Le=e=>!e||e?.target_devices?.some(e=>e.type===z.Q.ALL_CLIENTS)?{type:o.ANY}:{type:o.DEVICES_AND_NETWORKS,devices_and_networks:e?.target_devices.flatMap(e=>{return e.type===z.Q.NETWORK&&e.network_id?[(t=e.network_id,[we.NETWORK,t].join(ye))]:e.type===z.Q.CLIENT&&e.client_mac?[(i=e.client_mac,[we.DEVICE,i].join(ye))]:[];var t,i})},ke=e=>e?.matching_target===be.d.REGION?{type:n.REGION,regions:e.regions||[]}:e?.matching_target===be.d.DOMAIN?{type:n.DOMAIN,domains:(e.domains||[]).map(q.vt)}:e?.matching_target===be.d.IP?{type:n.IP,ips:[...e.ip_addresses||[],...e.ip_ranges||[]],simple_ips:e.ip_addresses.flatMap(e=>{return"ip_start"in(t=e)&&t.ip_start||"ip_stop"in t&&t.ip_stop||"ports"in t&&t.ports?.length||"port_ranges"in t&&t.port_ranges?.length?[]:[e.ip_or_subnet];var t})}:{type:n.ANY},Pe=(e,t,i)=>({name:e?.description||i,interface:e?.network_id||void 0,kill_switch_enabled:e?.kill_switch_enabled??t,next_hop:e?.next_hop||"",source:Le(e),destination:ke(e)}),Ge="policy-based-route-form",He=({activeItem:e,typeSelector:t,subTypeSelector:i})=>{const{sharedName:k,setSharedName:P}=(0,Ce.H5)(),H=e&&e._id!==b.R6?e:void 0,F=(0,r.wA)(),V=(0,r.d4)(D.EL),W=(0,r.d4)(R.Ct),$=(0,I.A)(j.Xj.TRAFFIC_ROUTE_KILL_SWITCH),U=(0,y.I)(),{formatMessage:K}=(0,S.tz)(),B=(0,E.m)({schema:Y(W),defaultValues:Pe(H,$,k)});(0,_.y)(B);const Q=(0,a.FH)({control:B.control,name:"interface"}),X=(0,a.FH)({control:B.control,name:"destination.type"}),J=(0,d.useMemo)(()=>W.find(e=>e._id===Q),[Q,W]),Z=!!J&&(0,M.ok)(J),ee=B.handleSubmit(async e=>F((0,C.kk)(((e,t,i)=>{const s=i.find(e=>e._id===t.interface),r=!!s&&(0,M.ok)(s);return{enabled:!0,...e,description:t.name,network_id:t.interface,kill_switch_enabled:t.kill_switch_enabled,target_devices:t.source.type===o.ANY||r?[{type:z.Q.ALL_CLIENTS}]:t.source.type===o.DEVICES_AND_NETWORKS?t.source.devices_and_networks.map(e=>(e=>{const[t,i]=e.split(ye);return t===we.DEVICE?{type:z.Q.CLIENT,client_mac:i}:{type:z.Q.NETWORK,network_id:i}})(e)):[],next_hop:t.next_hop||"",matching_target:t.destination.type===n.DOMAIN?be.d.DOMAIN:t.destination.type===n.IP?be.d.IP:t.destination.type===n.REGION?be.d.REGION:be.d.INTERNET,ip_addresses:t.destination.type===n.IP?(r?t.destination.simple_ips?.map(e=>({ip_or_subnet:e}))||[]:t.destination.ips?.filter(e=>"ip_or_subnet"in e)||[]).map(e=>({...e,ip_version:(0,G.isValidIpv6)(e.ip_or_subnet)||(0,je.dS)(e.ip_or_subnet)?"v6":"v4"})):[],ip_ranges:t.destination.type===n.IP?(t.destination.ips||[]).filter(e=>"ip_start"in e).map(e=>({...e,ip_version:(0,G.isValidIpv6)(e.ip_start)?"v6":"v4"})):[],domains:t.destination.type===n.DOMAIN?t.destination.domains.map(q.DP):[],regions:t.destination.type===n.REGION&&t.destination.regions||[]}})(H,e,W))).then(e=>{F((0,f.SQ)(!1)),F((0,f.XP)({type:T.H.POLICY_BASED_ROUTE,id:e._id})),U(w.J)}).then(()=>{B.reset()}).catch(e=>{const t=(0,c.F)(e)?e:void 0;F((0,x.ox)({errorMessage:t?.msg,errorValues:t?.details,icon:l.C.danger,message:"SETTINGS_TRAFFIC_ROUTES_TOAST_SAVE_FAILURE"}))})),te=(0,v.A)(H);return(0,s.jsx)("form",{onSubmit:ee,id:Ge,children:(0,s.jsxs)(h.A,{isDisabled:V||te,children:[(0,s.jsxs)(N.A,{gap:g.Ln,flexDirection:"column",width:"100%",children:[(0,s.jsxs)(O.A,{children:[H&&te?(0,s.jsx)(De,{existingRecord:H}):null,t,(0,s.jsx)(u.A,{control:B.control,name:"name",label:(0,s.jsx)(S.sA,{id:"COMMON_NAME"}),onChange:(e,t)=>{t.onChange(e),P(e.target.value)}})]}),(0,s.jsxs)(O.A,{title:i?(0,s.jsx)(S.sA,{id:"COMMON_TYPE"}):void 0,children:[i,(0,s.jsx)(ue,{form:B}),Z&&X===n.IP?(0,s.jsx)(u.A,{control:B.control,name:"next_hop",label:(0,s.jsx)(S.sA,{id:"COMMON_NEXT_HOP"}),tooltip:(0,s.jsx)(S.sA,{id:"SETTINGS_TRAFFIC_ROUTES_NEXT_HOP_DESC"}),placeholder:K({id:"COMMON_ENTER_IP_ADDRESS"})}):null,$?(0,s.jsx)(_e,{form:B}):null]}),(0,s.jsx)(de,{form:B}),(0,s.jsx)(Se,{form:B}),H&&!te?(0,s.jsx)(m.A,{enabled:H.enabled,name:H.description,onPause:async()=>{await F((0,C.kk)({...H,enabled:!1})),await F((0,C.EO)())},onResume:async()=>{await F((0,C.kk)({...H,enabled:!0})),await F((0,C.EO)())},onRemove:()=>F((0,C.Xo)({id:H._id,description:H.description}))}):null,H&&te?(0,s.jsx)(A.A,{actions:[(0,s.jsx)(p.A,{name:H.description,onRemove:()=>F((0,C.Xo)({id:H._id,description:H.description})),additionalMessage:(0,s.jsx)(S.sA,{id:"SETTINGS_ENTITY_MANAGED_BY_SITE_MANAGER_CONFIRMATION",values:{count:1,entity:(0,s.jsx)(S.sA,{id:"COMMON_POLICY_BASED_ROUTE"})}})})]}):null]}),(0,s.jsx)(L.A,{onFormCancel:()=>B.reset(),isDirty:B.formState.isDirty||!H,hideCancelButton:!B.formState.isDirty,submitButtonText:H?void 0:"COMMON_ACTION_ADD",form:Ge,isSubmitting:B.formState.isSubmitting})]})})}},16944(e,t,i){i.d(t,{A:()=>p});var n=i(274934),o=i(602086),s=i(977872),r=i(890932),a=i(726831);const d={};var l=i(247816),c=i(291508);const _=(0,l.A)("img",(0,c.A)("dimension"))`
  ${({dimension:e=22})=>`\n    height: ${e}px;\n    width: ${e}px;\n  `}
`,p=(0,o.memo)(({iconFileName:e,dimension:t,style:i={}})=>{const o=(0,s.d4)(r.p);return(0,n.jsx)(_,{src:d[e]||encodeURI(`${a.A.dpiPath}${e}`),dimension:t,onLoad:({target:t})=>{d[e]=t.src},onError:({currentTarget:e})=>{e.src=`${o}/dpiFallback.svg`},style:i})})},61322(e,t,i){i.d(t,{I:()=>n});const n={HEADER_HEIGHT:32,ROW_HEIGHT:32,EDIT_FIELD_HEIGHT:36,getHeight(e,t,i,n){return Math.min((n||this.ROW_HEIGHT)*e+(i??this.HEADER_HEIGHT),(n||this.ROW_HEIGHT)*t+(i??this.HEADER_HEIGHT))},getEditContainerHeight(e,t,i){return Math.min((i||this.EDIT_FIELD_HEIGHT)*e,(i||this.EDIT_FIELD_HEIGHT)*t)}}},942460(e,t,i){i.d(t,{A:()=>c});var n=i(274934),o=i(241792),s=i(570866),r=i(260334);const a=o.Yj({message:(0,r.rn)("COMMON_DOMAIN_VALIDATION")}).refine(e=>s.V2.test(e),{message:(0,r.rn)("COMMON_DOMAIN_VALIDATION")});var d=i(470070),l=i(858098);const c=function({form:e,name:t}){const{formatMessage:i}=(0,d.tz)();return(0,n.jsx)(l.A,{form:e,name:t,fieldLabel:"COMMON_DOMAIN_NAME",modalTitle:(0,n.jsx)(d.sA,{id:"SETTINGS_ADD_MULTIPLE_DOMAINS"}),modalFieldPlaceholder:i({id:"SETTINGS_ADD_MULTIPLE_DOMAINS_PLACEHOLDER"}),itemSchema:a,placeholder:i({id:"SETTINGS_NETWORKS_FORM_FIELD_DOMAIN_NAME_PLACEHOLDER"}),getDuplicationMessage:()=>i({id:"SETTINGS_SECURITY_DOMAINS_VALIDATION"})})}},928609(e,t,i){i.d(t,{gb:()=>r,om:()=>s,tY:()=>a});var n,o=i(556059);!function(e){e.DEVICE="device",e.NETWORK="network"}(n||(n={}));const s=(e,t)=>[n.DEVICE,e].join(t),r=(e,t)=>[n.NETWORK,e].join(t),a=(e,t)=>{const[i,s]=e.split(t);return i===n.DEVICE?{type:o.Q.CLIENT,client_mac:s}:{type:o.Q.NETWORK,network_id:s}}},858098(e,t,i){i.d(t,{A:()=>_});var n=i(274934),o=i(602086),s=i(42220),r=i(260334),a=i(184931),d=i(100978),l=i(470070),c=i(680163);const _=function({form:e,name:t,fieldLabel:i,modalTitle:_,modalFieldPlaceholder:p,placeholder:m,itemSchema:A,transformValue:I,getDuplicationMessage:u,extraDisplayColumns:h,actions:E,max:T,disableMultiEdit:g=!1,splitBy:O,validateInArray:N,sortValue:f}){const x=(0,a.mQ)(),S=(0,r.L_)(),{formatMessage:C}=(0,l.tz)(),M=(0,o.useMemo)(()=>({fieldLabel:i,modalTitle:_,modalFieldPlaceholder:p}),[i,p,_]),R=(0,o.useMemo)(()=>({getDuplicationMessage:u??(()=>C({id:"SETTINGS_VALUE_UNIQUE"})),validateInArray:N,validate:e=>{if(O&&"string"==typeof e){const t=e.split(O).map(e=>e.trim()).filter(Boolean);for(const i of t.length>0?t:[e]){const e=A.safeParse(i);if(!e.success)return S(e.error.issues[0]?.message)}return!0}const t=A.safeParse(e);return!!t.success||S(t.error.issues[0]?.message)}}),[C,S,u,A,O,N]),v=(0,o.useMemo)(()=>({placeholder:m,translatePlaceholder:!1,parser:I?e=>I(e?.[0]?.target?.value):void 0}),[m,I]);return(0,n.jsx)(s.xI,{control:e.control,name:t,render:({field:e,fieldState:t,formState:i})=>(0,n.jsx)(d.A,{flexDirection:"column",width:"100%",children:(0,n.jsx)(c.A,{disabled:x,labels:M,fieldValidation:R,extraFieldConfig:v,value:f?f(e.value||[]):e.value||[],onChange:t=>e.onChange(t),invalid:t.invalid?S((0,s.Jt)(i.errors,e.name)?.message)||!0:void 0,extraDisplayColumns:h,actions:E,disableMultiEdit:g,max:T,splitBy:O,transformValue:I})})})}},749445(e,t,i){i.d(t,{A:()=>_});var n=i(274934),o=i(42220),s=i(309130),r=i(897396),a=i(470070),d=i(260334),l=i(184931);const c=[],_=function({control:e,name:t,tooltip:i,options:_,triggerButtonText:p,truncateLabels:m=!0,isWindowed:A,searchOptions:I,maxSelections:u,narrowTrigger:h,chipClassName:E,label:T,onAfterChange:g}){const O=(0,l.mQ)(),N=(0,d.L_)();return(0,n.jsx)(o.xI,{control:e,name:t,render:({field:e,fieldState:d,formState:l})=>(0,n.jsx)(r.A,{name:e.name,onChange:t=>{e.onChange(t),g?.(t)},disabled:O,value:e.value||c,tooltipDescription:i,options:_,truncateLabels:m,invalid:d.invalid?N((0,o.Jt)(l.errors,t)?.message)||!0:void 0,translateTriggerButtonText:!1,triggerButtonText:p??(0,n.jsx)(a.sA,{id:"COMMON_EDIT_SELECTIONS"}),isWindowed:A,searchOptions:I,maxSelections:u,isFullWidth:!0,triggerButtonHeight:h?s.S2:void 0,chipClassName:E,label:T})})}}}]);