/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.cloudDefend_bundle_jsonpfunction=window.cloudDefend_bundle_jsonpfunction||[]).push([[2],{32:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var a=n(8);const o=()=>Object(a.useKibana)()},43:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDeepEqual=t.off=t.on=t.isClient=void 0;var a=n(16).__importDefault(n(69));t.isClient="object"==typeof window,t.on=function(e){for(var t=[],n=1;n{const s=Object(i.useMemo)((()=>{if(t)return e=>Object(g.jsx)(r.a.Fragment,null,Object(g.jsx)(b,null),Object(g.jsx)(t,e))}),[t]);if(s)return Object(g.jsx)(c.Route,o()({},a,{component:s}));if(n||"function"==typeof e){const t="function"==typeof e?e:n;return Object(g.jsx)(c.Route,o()({},a,{render:e=>Object(g.jsx)(r.a.Fragment,null,Object(g.jsx)(b,null),t(e))}))}return Object(g.jsx)(c.Route,a,Object(g.jsx)(b,null),e)},b=()=>{const{executionContext:e}=Object(i.useContext)(u).services,t=Object(c.useRouteMatch)();return function(e,t){j()((()=>(null==e||e.set(t),()=>{null==e||e.clear()})),[t])}(e,{type:"application",page:t.path,id:Object.keys(t.params).length>0?JSON.stringify(t.params):void 0}),null};var f=n(28),M=n(24);const x=({legacySwitch:e=!0,children:t})=>{const n=Object(c.useRouteMatch)();return e?Object(g.jsx)(c.Switch,null,t):Object(g.jsx)(f.Routes,null,i.Children.map(t,(e=>{if(r.a.isValidElement(e)&&e.type===p){var a;const o=Object(M.replace)(null==e?void 0:e.props.path,n.url+"/",""),i="function"==typeof(null==e?void 0:e.props.children)?null==e?void 0:e.props.children:null==e?void 0:e.props.render;return Object(g.jsx)(f.Route,{path:o,element:Object(g.jsx)(r.a.Fragment,null,Object(g.jsx)(b,null),(null==e||null===(a=e.props)||void 0===a?void 0:a.component)&&Object(g.jsx)(e.props.component,null)||i&&i()||t)})}return e})))};var O=n(3);const y=r.a.createContext(void 0);var m=n(2),I=n(26),D=n(73),v=n.n(D),k=n(7);const N=({title:e})=>Object(g.jsx)(m.EuiFlexGroup,{alignItems:"center",gutterSize:"s"},Object(g.jsx)(m.EuiFlexItem,{grow:!1},Object(g.jsx)(m.EuiTitle,null,Object(g.jsx)("h1",null,e))));var T=n(8),h=n(32);const z=()=>{const{application:e}=Object(h.a)().services;return Object(g.jsx)(m.EuiPageSection,{color:"danger",alignment:"center"},Object(g.jsx)(m.EuiEmptyPrompt,{iconType:"warning",title:Object(g.jsx)("h2",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.subscriptionNotAllowed.promptTitle",defaultMessage:"Upgrade for subscription features"})),body:Object(g.jsx)("p",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.subscriptionNotAllowed.promptDescription",defaultMessage:"To use these cloud security features, you must {link}.",values:{link:Object(g.jsx)(m.EuiLink,{href:e.getUrlForApp("management",{path:"stack/license_management/home"})},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.subscriptionNotAllowed.promptLinkText",defaultMessage:"start a trial or upgrade your subscription"}))}}))}))};var C=n(13),E=n(5);var _=n(12),L=n(11),S=n(25),w=n(10);const P=()=>{const{http:e}=Object(h.a)().services,t=(()=>{const{http:e}=Object(h.a)().services;return Object(s.useQuery)(["integrations"],(()=>e.get(w.epmRouteService.getInfoPath(E.c))))})();if(!t.isSuccess)return{addIntegrationLink:void 0,docsLink:"https://www.elastic.co/guide/index.html"};const n=S.pagePathGetters.add_integration_to_policy({integration:E.c,pkgkey:Object(S.pkgKeyFromPackageInfo)({name:t.data.item.name,version:t.data.item.version})}).join(""),a=S.pagePathGetters.integration_details_overview({integration:E.c,pkgkey:Object(S.pkgKeyFromPackageInfo)({name:t.data.item.name,version:t.data.item.version})}).join("");return{addIntegrationLink:e.basePath.prepend(n),docsLink:e.basePath.prepend(a)}};var A=n(71),F=n.n(A);const G=e=>{var t,n,a;return!!(null!=e&&e.body&&null!=e&&null!==(t=e.body)&&void 0!==t&&t.error&&null!=e&&null!==(n=e.body)&&void 0!==n&&n.message&&null!=e&&null!==(a=e.body)&&void 0!==a&&a.statusCode)},R=()=>Object(g.jsx)(L.a,{"data-test-subj":"cloud_defend_page_loading"},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.loadingDescription",defaultMessage:"Loading..."})),Y=e=>Object(g.jsx)(_.a,null,Object(g.jsx)(m.EuiEmptyPrompt,{color:"danger",iconType:"warning","data-test-subj":"cloud_defend_page_error",title:Object(g.jsx)("h2",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.errorRenderer.errorTitle",defaultMessage:"We couldn't fetch your cloud defend data"})),body:G(e)?Object(g.jsx)("p",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.errorRenderer.errorDescription",defaultMessage:"{error} {statusCode}: {body}",values:{error:e.body.error,statusCode:e.body.statusCode,body:e.body.message}})):void 0})),Q=e=>Object(g.jsx)(_.a,null,Object(g.jsx)(T.NoDataPage,{"data-test-subj":"cloud_defend_page_no_data",pageTitle:k.i18n.translate("xpack.cloudDefend.cloudDefendPage.defaultNoDataConfig.pageTitle",{defaultMessage:"No data found"}),solution:k.i18n.translate("xpack.cloudDefend.cloudDefendPage.defaultNoDataConfig.solutionNameLabel",{defaultMessage:"Defend for containers"}),docsLink:e,logo:"logoSecurity",actions:{}})),Z=({children:e,query:t,loadingRender:n=R,errorRender:a=Y,noDataRenderer:o=Q})=>{const c=(()=>{const{licensing:e}=Object(h.a)().services,{isCloudEnabled:t}=Object(i.useContext)(C.a);return Object(s.useQuery)(["cloud_defend_subscription_query_key"],(async()=>{const n=await e.refresh();return((e,t)=>!!e||!!t&&"valid"===t.check(E.d,"enterprise").state)(t,n)}))})(),l=(()=>{const{http:e}=Object(h.a)().services;return Object(s.useQuery)(["cloud_defend_status_key"],(()=>e.get(E.f,{version:E.a})))})(),{addIntegrationLink:u,docsLink:d}=P();return Object(g.jsx)(r.a.Fragment,null,c.isError?Y(c.error):c.isLoading?R():c.data?l.isError?Y(l.error):l.isLoading?R():"not-installed"===l.data.status?(({addIntegrationLink:e,docsLink:t})=>Object(g.jsx)(_.a,null,Object(g.jsx)(m.EuiEmptyPrompt,{"data-test-subj":"cloud_defend_page_package_not_installed",icon:Object(g.jsx)(m.EuiImage,{size:"m",margin:"m",src:F.a,alt:"no-data-illustration"}),title:Object(g.jsx)("h2",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.packageNotInstalledRenderer.promptTitle",defaultMessage:"Detect container drift and block malicious behavior at the source!"})),layout:"horizontal",color:"plain",body:Object(g.jsx)("p",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.packageNotInstalledRenderer.promptDescription",defaultMessage:"Add the Defend for containers (D4C) integration to begin. {learnMore}.",values:{learnMore:Object(g.jsx)(m.EuiLink,{href:t},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.packageNotInstalledRenderer.learnMoreTitle",defaultMessage:"Learn more about Defend for containers (D4C)"}))}})),actions:Object(g.jsx)(m.EuiFlexGroup,null,Object(g.jsx)(m.EuiFlexItem,{grow:!1},Object(g.jsx)(m.EuiButton,{color:"primary",fill:!0,href:e},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.cloudDefendPage.packageNotInstalledRenderer.addCloudDefendmIntegrationButtonTitle",defaultMessage:"Add D4C Integration"}))))})))({addIntegrationLink:u,docsLink:d}):t?t.isError?a(t.error):t.isLoading?n():t.data?e:o(d):e:Object(g.jsx)(_.a,{"data-test-subj":"cloud_defend_page_subscription_not_allowed"},Object(g.jsx)(z,null)))};var U=n(29),W=n.n(U);const B=({timestamp:e})=>{const t=Object(T.useUiSetting)("dateFormat"),n=Object(m.formatDate)(e,t);return Object(g.jsx)(m.EuiToolTip,{position:"top",content:n},Object(g.jsx)("span",null,W()(e).fromNow()))},J=({name:e,id:t})=>{const{http:n}=Object(h.a)().services,[a,o]=S.pagePathGetters.policy_details({policyId:t});return Object(g.jsx)(m.EuiLink,{href:n.basePath.prepend([a,o].join(""))},e)},V=({packageName:e,policyId:t,packagePolicyId:n})=>{const a=S.pagePathGetters.edit_integration({packagePolicyId:n,policyId:t}).join("");return Object(g.jsx)(m.EuiLink,{href:a},e)},H=[{field:"package_policy.name",name:k.i18n.translate("xpack.cloudDefend.policies.policiesTable.integrationNameColumnTitle",{defaultMessage:"Integration Name"}),render:(e,t)=>Object(g.jsx)(V,{packageName:e,packagePolicyId:t.package_policy.id,policyId:t.package_policy.policy_id}),truncateText:!0,sortable:!0,"data-test-subj":"policies-table-column-integration-name"},{field:"agent_policy.name",name:k.i18n.translate("xpack.cloudDefend.policies.policiesTable.agentPolicyColumnTitle",{defaultMessage:"Agent Policy"}),render:(e,t)=>Object(g.jsx)(J,{name:e,id:t.agent_policy.id}),truncateText:!0,"data-test-subj":"policies-table-column-agent-policy"},{field:"agent_policy.agents",name:k.i18n.translate("xpack.cloudDefend.policies.policiesTable.numberOfAgentsColumnTitle",{defaultMessage:"Number of Agents"}),truncateText:!0,"data-test-subj":"policies-table-column-number-of-agents"},{field:"package_policy.created_by",name:k.i18n.translate("xpack.cloudDefend.policies.policiesTable.createdByColumnTitle",{defaultMessage:"Created by"}),dataType:"string",truncateText:!0,sortable:!0,"data-test-subj":"policies-table-column-created-by"},{field:"package_policy.created_at",name:k.i18n.translate("xpack.cloudDefend.policies.policiesTable.createdAtColumnTitle",{defaultMessage:"Created at"}),dataType:"date",truncateText:!0,render:e=>Object(g.jsx)(B,{timestamp:e}),sortable:!0,"data-test-subj":"policies-table-column-created-at"}],K=({policies:e,pageIndex:t,pageSize:n,totalItemCount:a,loading:o,error:i,setQuery:r,noItemsMessage:s,sorting:c,...l})=>{const u={pageIndex:Math.max(t-1,0),pageSize:n,totalItemCount:a};return Object(g.jsx)(m.EuiBasicTable,{"data-test-subj":l["data-test-subj"],items:e,columns:H,itemId:e=>[e.agent_policy.id,e.package_policy.id].join("/"),pagination:u,onChange:({page:e,sort:t})=>{r({page:{...e,index:e.index+1},sort:t})},tableLayout:"fixed",loading:o,noItemsMessage:s,error:i,sorting:c})};var X=n(35),q=n(38),$=n(72),ee=n.n($);const te=()=>{const{addIntegrationLink:e}=P();return Object(g.jsx)(m.EuiButton,{"data-test-subj":"cloud_defend_add_integration",fill:!0,iconType:"plusInCircle",href:e},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.policies.policiesPageHeader.addIntegrationButtonLabel",defaultMessage:"Add Integration"}))},ne=({name:e})=>Object(g.jsx)("div",null,Object(g.jsx)(m.EuiSpacer,{size:"l"}),Object(g.jsx)(m.EuiText,null,Object(g.jsx)("strong",null,Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.policies.policyEmptyState.integrationsNotFoundTitle",defaultMessage:"No policies found"}),e&&Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.policies.policyEmptyState.integrationsNotFoundForNameTitle",defaultMessage:' for "{name}"',values:{name:e}}))),Object(g.jsx)(m.EuiSpacer,{size:"s"}),Object(g.jsx)(m.EuiText,null,Object(g.jsx)(m.EuiTextColor,{color:"subdued"},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.policies.policyEmptyState.integrationsNotFoundWithFiltersTitle",defaultMessage:"We weren't able to find any policies with the above filters."}))),Object(g.jsx)(m.EuiSpacer,{size:"l"})),ae=({pageCount:e,totalCount:t})=>Object(g.jsx)(m.EuiText,{size:"xs",style:{marginLeft:8}},Object(g.jsx)(m.EuiTextColor,{color:"subdued"},Object(g.jsx)(I.FormattedMessage,{id:"xpack.cloudDefend.policies.totalIntegrationsCountMessage",defaultMessage:"Showing {pageCount} of {totalCount, plural, one {# integration} other {# integrations}}",values:{pageCount:e,totalCount:t}}))),oe=({onSearch:e,isLoading:t})=>{const[n,a]=Object(i.useState)("");return v()((()=>e(n)),300,[n]),Object(g.jsx)(m.EuiFlexGroup,null,Object(g.jsx)(m.EuiFlexItem,{grow:!0,style:{alignItems:"flex-end"}},Object(g.jsx)(m.EuiFieldSearch,{fullWidth:!0,onSearch:a,isLoading:t,placeholder:k.i18n.translate("xpack.cloudDefend.policies.policySearchField.searchPlaceholder",{defaultMessage:"Search integration name"}),incremental:!0})))},ie=()=>{var e,t,n;const{pageSize:a,setPageSize:o}=(e=>{const[t,n]=ee()(e,q.a);let a=q.a;return t&&(a=t),{pageSize:a,setPageSize:n}})(q.c),[r,c]=Object(i.useState)({name:"",page:1,perPage:a,sortField:"package_policy.name",sortOrder:"asc"}),l=(({name:e,perPage:t,page:n,sortField:a,sortOrder:o})=>{const{http:i}=Object(h.a)().services,r={policy_name:e,per_page:t,page:n,sort_field:a,sort_order:o};return Object(s.useQuery)(["cloud_defend_policies",r],(()=>i.get(E.e,{version:E.a,query:r})),{keepPreviousData:!0})})(r),u=(null===(e=l.data)||void 0===e?void 0:e.total)||0;return Object(g.jsx)(Z,null,Object(g.jsx)(m.EuiPageHeader,{"data-test-subj":"policies-page-header",pageTitle:Object(g.jsx)(N,{title:k.i18n.translate("xpack.cloudDefend.policies.policiesPageHeader",{defaultMessage:"Defend for containers (D4C)"})}),rightSideItems:[Object(g.jsx)(te,null)],bottomBorder:!0}),Object(g.jsx)(m.EuiSpacer,null),Object(g.jsx)(oe,{isLoading:l.isFetching,onSearch:e=>c((t=>({...t,name:e})))}),Object(g.jsx)(m.EuiSpacer,null),Object(g.jsx)(ae,{pageCount:((null===(t=l.data)||void 0===t?void 0:t.items)||[]).length,totalCount:u}),Object(g.jsx)(m.EuiSpacer,{size:"s"}),Object(g.jsx)(K,{policies:(null===(n=l.data)||void 0===n?void 0:n.items)||[],"data-test-subj":"cloud_defend_policies_table",error:l.error?Object(X.a)(l.error):void 0,loading:l.isFetching,pageIndex:r.page,pageSize:a||r.perPage,sorting:{sort:{field:r.sortField,direction:r.sortOrder},allowNeutralSort:!1},totalItemCount:u,setQuery:({page:e,sort:t})=>{o(e.size),c((n=>({...n,page:e.index,perPage:e.size,sortField:(null==t?void 0:t.field)||n.sortField,sortOrder:(null==t?void 0:t.direction)||n.sortOrder})))},noItemsMessage:l.isSuccess&&!l.data.total?Object(g.jsx)(ne,{name:r.name}):void 0}))};var re=n(30);const se=Object.fromEntries(Object.values(O.b).map((({id:e})=>[e,!0]))),ce=({id:e,children:t,component:n,disabled:a=!1,...o})=>{var r;const s=null===(r=Object(i.useContext)(y))||void 0===r?void 0:r.getSpyRouteComponent();if(a)return null;const c={...o,...n&&{render:t=>Object(g.jsx)(re.TrackApplicationView,{viewId:e},se[e]&&s&&Object(g.jsx)(s,{pageName:e}),Object(g.jsx)(n,t))}};return Object(g.jsx)(p,c,t)},le=new s.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1}}}),ue=({securitySolutionContext:e})=>{const t=Object(g.jsx)(s.QueryClientProvider,{client:le},Object(g.jsx)(x,null,Object(g.jsx)(ce,o()({},O.b.policies,{component:ie})),Object(g.jsx)(p,null,Object(g.jsx)(c.Redirect,{to:O.b.policies.path}))));return e?Object(g.jsx)(y.Provider,{value:e},t):Object(g.jsx)(r.a.Fragment,null,t)}}}]);