/*! 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.fleet_bundle_jsonpfunction=window.fleet_bundle_jsonpfunction||[]).push([[3],{161:function(e,t,a){"use strict";t.decode=t.parse=a(376),t.encode=t.stringify=a(377)},376:function(e,t,a){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,a,i){t=t||"&",a=a||"=";var s={};if("string"!=typeof e||0===e.length)return s;var r=/\+/g;e=e.split(t);var o=1e3;i&&"number"==typeof i.maxKeys&&(o=i.maxKeys);var c=e.length;o>0&&c>o&&(c=o);for(var u=0;u=0?(d=E.substr(0,f),g=E.substr(f+1)):(d=E,g=""),m=decodeURIComponent(d),p=decodeURIComponent(g),n(s,m)?l(s[m])?s[m].push(p):s[m]=[s[m],p]:s[m]=p}return s};var l=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},377:function(e,t,a){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,a,r){return t=t||"&",a=a||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var r=encodeURIComponent(n(s))+a;return l(e[s])?i(e[s],(function(e){return r+encodeURIComponent(n(e))})).join(t):r+encodeURIComponent(n(e[s]))})).join(t):r?encodeURIComponent(n(r))+a+encodeURIComponent(n(e)):""};var l=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var a=[],n=0;n",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),d=["%","/","?",";","#"].concat(u),g=["/","?","#"],m=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,E={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},h=a(161);function y(e,t,a){if(e&&l.isObject(e)&&e instanceof i)return e;var n=new i;return n.parse(e,t,a),n}i.prototype.parse=function(e,t,a){if(!l.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),r=-1!==i&&i127?A+="x":A+=P[L];if(!A.match(m)){var D=j.slice(0,O),B=j.slice(O+1),R=P.match(p);R&&(D.push(R[1]),B.unshift(R[2])),B.length&&(y="/"+B.join(".")+y),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),w||(this.hostname=n.toASCII(this.hostname));var z=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+z,this.href+=this.host,w&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!E[x])for(O=0,C=u.length;O0)&&a.host.split("@"))&&(a.auth=w.shift(),a.host=a.hostname=w.shift())),a.search=e.search,a.query=e.query,l.isNull(a.pathname)&&l.isNull(a.search)||(a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"")),a.href=a.format(),a;if(!F.length)return a.pathname=null,a.search?a.path="/"+a.search:a.path=null,a.href=a.format(),a;for(var I=F.slice(-1)[0],S=(a.host||e.host||F.length>1)&&("."===I||".."===I)||""===I,O=0,T=F.length;T>=0;T--)"."===(I=F[T])?F.splice(T,1):".."===I?(F.splice(T,1),O++):O&&(F.splice(T,1),O--);if(!v&&!x)for(;O--;O)F.unshift("..");!v||""===F[0]||F[0]&&"/"===F[0].charAt(0)||F.unshift(""),S&&"/"!==F.join("/").substr(-1)&&F.push("");var w,j=""===F[0]||F[0]&&"/"===F[0].charAt(0);return M&&(a.hostname=a.host=j?"":F.length?F.shift():"",(w=!!(a.host&&a.host.indexOf("@")>0)&&a.host.split("@"))&&(a.auth=w.shift(),a.host=a.hostname=w.shift())),(v=v||a.host&&F.length)&&!j&&F.unshift(""),F.length?a.pathname=F.join("/"):(a.pathname=null,a.path=null),l.isNull(a.pathname)&&l.isNull(a.search)||(a.path=(a.pathname?a.pathname:"")+(a.search?a.search:"")),a.auth=e.auth||a.auth,a.slashes=a.slashes||e.slashes,a.href=a.format(),a},i.prototype.parseHost=function(){var e=this.host,t=r.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},379:function(e,t,a){e.exports=a(36)(2947)},380:function(e,t,a){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},381:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=a(47),l=a(0),i=n.__importDefault(a(71)),s=a(166),r={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};t.default=s.isClient&&window.ResizeObserver?function(){var e=l.useState(null),t=e[0],a=e[1],n=l.useState(r),s=n[0],o=n[1],c=l.useMemo((function(){return new window.ResizeObserver((function(e){if(e[0]){var t=e[0].contentRect,a=t.x,n=t.y,l=t.width,i=t.height,s=t.top,r=t.left,c=t.bottom,u=t.right;o({x:a,y:n,width:l,height:i,top:s,left:r,bottom:c,right:u})}}))}),[]);return i.default((function(){if(t)return c.observe(t),function(){c.disconnect()}}),[t]),[a,s]}:function(){return[function(){},r]}},382:function(e,t,a){e.exports=a(36)(1937)},386:function(e,t,a){"use strict";a.r(t),a.d(t,"ProtectedRoute",(function(){return Bs})),a.d(t,"renderApp",(function(){return zs})),a.d(t,"teardownFleet",(function(){return Ns}));var n=a(0),l=a.n(n),i=a(84),s=a.n(i),r=a(18),o=a(103),c=a(17),u=a(6),d=a(9),g=a(4),m=a(52),p=a.n(m),E=a(57),f=a.n(E),b=a(7),h=a(85),y=a(26),k=a(86),v=a(99),x=a(98),F=a(12),M=a(104),I=a(108),S=a(114),O=a(37),T=a.n(O),w=a(137),j=a(53),C=a(27);const P=p()(u.EuiFlyout).withConfig({displayName:"FlyoutWithHigherZIndex",componentId:"sc-1pwanx7-0"})(["z-index:",";"],(e=>e.theme.eui.euiZLevel5)),A=({onClose:e,as:t,...a})=>{const{notifications:i}=Object(c.hc)(),s=Object(c.tb)().fleet.all,[r,o]=Object(n.useState)(Object(C.b)()),[m,p]=Object(n.useState)(!1),[E,f]=Object(n.useState)(!0),b=Object(S.h)(r),h=l.a.createElement(u.EuiFlyoutHeader,{hasBorder:!0,"aria-labelledby":"CreateAgentPolicyFlyoutTitle"},l.a.createElement(u.EuiTitle,{size:"m"},l.a.createElement("h2",{id:"CreateAgentPolicyFlyoutTitle","data-test-subj":"createAgentPolicyFlyoutTitle"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createAgentPolicy.flyoutTitle",defaultMessage:"Create agent policy"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiText,{size:"s"},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createAgentPolicy.flyoutTitleDescription",defaultMessage:"Agent policies are used to manage settings across a group of agents. You can add integrations to your agent policy to specify what data your agents collect. When you edit an agent policy, you can use Fleet to deploy updates to a specified group of agents."})))),y=l.a.createElement(u.EuiFlyoutBody,null,l.a.createElement(S.d,{agentPolicy:r,updateAgentPolicy:e=>{o({...r,...e})},withSysMonitoring:E,updateSysMonitoring:e=>f(e),validation:b})),{showDevtoolsRequest:k}=j.b.get(),v=Object(n.useMemo)((()=>Object(w.a)(r,E)),[r,E]),F=l.a.createElement(u.EuiFlyoutFooter,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:()=>e(),flush:"left"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createAgentPolicy.cancelButtonLabel",defaultMessage:"Cancel"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFlexGroup,{gutterSize:"none"},k?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(x.i,{isDisabled:m||Object.keys(b).length>0,description:g.i18n.translate("xpack.fleet.createAgentPolicy.devtoolsRequestDescription",{defaultMessage:"This Kibana request creates a new agent policy."}),request:v})):null,l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{fill:!0,isLoading:m,isDisabled:!s||m||Object.keys(b).length>0,onClick:async()=>{p(!0);try{const{data:t,error:a}=await(async()=>await Object(c.j)(r,{withSysMonitoring:E}))();p(!1),t?(i.toasts.addSuccess(g.i18n.translate("xpack.fleet.createAgentPolicy.successNotificationTitle",{defaultMessage:"Agent policy '{name}' created",values:{name:r.name}})),e(t.item)):i.toasts.addDanger(a?a.message:g.i18n.translate("xpack.fleet.createAgentPolicy.errorNotificationTitle",{defaultMessage:"Unable to create agent policy"}))}catch(e){p(!1),i.toasts.addDanger(g.i18n.translate("xpack.fleet.createAgentPolicy.errorNotificationTitle",{defaultMessage:"Unable to create agent policy"}))}},"data-test-subj":"createAgentPolicyFlyoutBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createAgentPolicy.submitButtonLabel",defaultMessage:"Create agent policy"})))))));return l.a.createElement(P,T()({onClose:()=>e(),size:"l",maxWidth:400},a),h,y,F)},L=()=>{var e,t;Object(c.ub)("policies_list");const{getPath:a}=Object(c.Zb)(),i=Object(c.tb)().fleet.all,{agents:{enabled:s}}=Object(c.wb)(),{urlParams:o,toUrlParams:m}=Object(c.lc)(),[p,E]=Object(n.useState)(Array.isArray(o.kuery)?o.kuery[o.kuery.length-1]:null!==(e=o.kuery)&&void 0!==e?e:""),{pagination:f,pageSizeOptions:b,setPagination:h}=Object(c.bc)(),{sorting:y,setSorting:k}=Object(c.gc)({field:"updated_at",direction:"desc"}),v=Object(r.useHistory)(),M="create"in o,O=Object(n.useCallback)((e=>{if(e!==M)if(e)v.push(`${a("policies_list")}?${m({...o,create:null})}`);else{const{create:e,...t}=o;v.push(`${a("policies_list")}?${m(t)}`)}}),[a,v,M,m,o]),{isLoading:T,data:w,resendRequest:j}=Object(c.Fb)({page:f.currentPage,perPage:f.pageSize,sortField:null==y?void 0:y.field,sortOrder:null==y?void 0:y.direction,kuery:p,full:!0}),C=Object(n.useMemo)((()=>{const e=[{field:"name",sortable:!0,name:g.i18n.translate("xpack.fleet.agentPolicyList.nameColumnTitle",{defaultMessage:"Name"}),width:"25%",render:(e,t)=>l.a.createElement(I.e,{policy:t})},{field:"description",name:g.i18n.translate("xpack.fleet.agentPolicyList.descriptionColumnTitle",{defaultMessage:"Description"}),width:"35%",render:e=>l.a.createElement(u.EuiTextColor,{color:"subdued",className:"eui-textTruncate",title:e},e)},{field:"updated_at",sortable:!0,name:g.i18n.translate("xpack.fleet.agentPolicyList.updatedOnColumnTitle",{defaultMessage:"Last updated on"}),render:e=>l.a.createElement(d.FormattedDate,{value:e,year:"numeric",month:"short",day:"2-digit"})},{field:"agents",name:g.i18n.translate("xpack.fleet.agentPolicyList.agentsColumnTitle",{defaultMessage:"Agents"}),dataType:"number",render:(e,t)=>l.a.createElement(S.g,{count:e,agentPolicyId:t.id})},{field:"package_policies",name:g.i18n.translate("xpack.fleet.agentPolicyList.packagePoliciesCountColumnTitle",{defaultMessage:"Integrations"}),dataType:"number",render:e=>e?e.length:0},{field:"actions",name:g.i18n.translate("xpack.fleet.agentPolicyList.actionsColumnTitle",{defaultMessage:"Actions"}),actions:[{render:e=>l.a.createElement(S.a,{agentPolicy:e,onCopySuccess:()=>j()})}]}];return s?e:e.filter((e=>!("field"in e)||"agents"!==e.field))}),[s,j]),P=Object(n.useMemo)((()=>l.a.createElement(u.EuiButton,{fill:!0,iconType:"plusInCircle",isDisabled:!i,onClick:()=>O(!0),"data-test-subj":"createAgentPolicyButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.addButton",defaultMessage:"Create agent policy"}))),[i,O]),L=Object(n.useMemo)((()=>l.a.createElement(u.EuiButton,{fill:!0,iconType:"plusInCircle",isDisabled:!i,onClick:()=>O(!0),"data-test-subj":"emptyPromptCreateAgentPolicyButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.addButton",defaultMessage:"Create agent policy"}))),[i,O]),_=Object(n.useMemo)((()=>l.a.createElement(u.EuiEmptyPrompt,{title:l.a.createElement("h2",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.noAgentPoliciesPrompt",defaultMessage:"No agent policies"})),actions:L})),[L]);return l.a.createElement(l.a.Fragment,null,M?l.a.createElement(A,{onClose:()=>{O(!1),j()}}):null,l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"m"},l.a.createElement(u.EuiFlexItem,{grow:4},l.a.createElement(x.w,{value:p,onChange:e=>{h({...f,currentPage:1}),E(e)},fieldPrefix:F.c,dataTestSubj:"agentPolicyList.queryInput"})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"primary",iconType:"refresh",onClick:()=>j()},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.reloadAgentPoliciesButtonText",defaultMessage:"Reload"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},P)),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiBasicTable,{loading:T,hasActions:!0,noItemsMessage:T?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.loadingAgentPoliciesMessage",defaultMessage:"Loading agent policies…"}):p.trim()||0!==(null!==(t=null==w?void 0:w.total)&&void 0!==t?t:0)?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.noFilteredAgentPoliciesPrompt",defaultMessage:"No agent policies found. {clearFiltersLink}",values:{clearFiltersLink:l.a.createElement(u.EuiLink,{onClick:()=>E("")},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicyList.clearFiltersLinkText",defaultMessage:"Clear filters"}))}}):_,items:w?w.items:[],itemId:"id",columns:C,isSelectable:!1,pagination:{pageIndex:f.currentPage-1,pageSize:f.pageSize,totalItemCount:w?w.total:0,pageSizeOptions:b},sorting:{sort:y},onChange:e=>{const t={...f,currentPage:e.page.index+1,pageSize:e.page.size};h(t),k(e.sort)}}))},_=l.a.createContext({refresh:()=>{}});var D=a(15),B=a(8);const R=(e,t)=>e.localeCompare(t),z=e=>({name:e,value:e}),N=({packagePolicies:e,agentPolicy:t,...a})=>{var i,s;const{application:r}=Object(c.hc)(),o=Object(c.tb)().integrations.writeIntegrationPolicies,m=Object(c.tb)().integrations.readIntegrationPolicies,{isPackagePolicyUpgradable:p}=Object(c.Vb)(),{getHref:E}=Object(c.Zb)(),f=Object(c.cc)(),b=!(null!==(i=f.data)&&void 0!==i&&i.success)&&"MISSING_SECURITY"===(null===(s=f.data)||void 0===s?void 0:s.error),[h,y]=Object(n.useMemo)((()=>{const t=new Set;return[e.map((e=>{var a,n,l,i,s,r;e.namespace&&t.add(e.namespace);const o=p(e);return{...e,packageName:null!==(a=null===(n=e.package)||void 0===n?void 0:n.name)&&void 0!==a?a:"",packageTitle:null!==(l=null===(i=e.package)||void 0===i?void 0:i.title)&&void 0!==l?l:"",packageVersion:null!==(s=null===(r=e.package)||void 0===r?void 0:r.version)&&void 0!==s?s:"",hasUpgrade:o}})),[...t].sort(R).map(z)]}),[e,p]),k=Object(n.useMemo)((()=>[{field:"name",sortable:!0,truncateText:!0,name:g.i18n.translate("xpack.fleet.policyDetails.packagePoliciesTable.nameColumnTitle",{defaultMessage:"Name"}),render:(e,a)=>l.a.createElement(u.EuiLink,T()({title:e},m?{href:E("edit_integration",{policyId:t.id,packagePolicyId:a.id})}:{disabled:!0}),l.a.createElement("span",{className:"eui-textTruncate",title:e},e),a.description?l.a.createElement("span",null," ",l.a.createElement(u.EuiToolTip,{content:a.description},l.a.createElement(u.EuiIcon,{type:"help"}))):null)},{field:"packageTitle",sortable:!0,name:g.i18n.translate("xpack.fleet.policyDetails.packagePoliciesTable.packageNameColumnTitle",{defaultMessage:"Integration"}),render:(e,a)=>l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{"data-test-subj":"PackagePoliciesTableLink",grow:!1},l.a.createElement(u.EuiLink,{href:a.package&&E("integration_details_overview",{pkgkey:Object(j.s)(a.package)})},l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",alignItems:"center"},a.package&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(x.t,{packageName:a.package.name,version:a.package.version,size:"m",tryApi:!0})),l.a.createElement(u.EuiFlexItem,{grow:!1},e),a.package&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiText,{color:"subdued",size:"xs",className:"eui-textNoWrap"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.packagePoliciesTable.packageVersion",defaultMessage:"v{version}",values:{version:a.package.version}})))))),a.hasUpgrade&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiToolTip,{content:g.i18n.translate("xpack.fleet.policyDetails.packagePoliciesTable.upgradeAvailable",{defaultMessage:"Upgrade Available"})},l.a.createElement(u.EuiIcon,{type:"warning",color:"warning"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{"data-test-subj":"PackagePoliciesTableUpgradeButton",size:"s",minWidth:"0",isDisabled:!o,href:`${E("upgrade_package_policy",{policyId:t.id,packagePolicyId:a.id})}?from=fleet-policy-list`},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.packagePoliciesTable.upgradeButton",defaultMessage:"Upgrade"})))))},{field:"namespace",name:g.i18n.translate("xpack.fleet.policyDetails.packagePoliciesTable.namespaceColumnTitle",{defaultMessage:"Namespace"}),render:e=>e?l.a.createElement(u.EuiBadge,{color:"hollow"},e):""},{name:g.i18n.translate("xpack.fleet.policyDetails.packagePoliciesTable.actionsColumnTitle",{defaultMessage:"Actions"}),actions:[{render:e=>o?l.a.createElement(x.u,{agentPolicy:t,packagePolicy:e,upgradePackagePolicyHref:`${E("upgrade_package_policy",{policyId:t.id,packagePolicyId:e.id})}?from=fleet-policy-list`}):l.a.createElement(l.a.Fragment,null)}]}]),[t,E,o,m]);return l.a.createElement(u.EuiInMemoryTable,T()({itemId:"id",items:h,columns:k,sorting:{sort:{field:"name",direction:"asc"}}},a,{search:{toolsRight:t.is_managed?[]:[l.a.createElement(x.k,{key:"addPackagePolicyButton",fill:!0,isDisabled:!o,iconType:"plusInCircle",onClick:()=>{r.navigateToApp(D.INTEGRATIONS_PLUGIN_ID,{path:B.v.integrations_all({})[1],state:{forAgentPolicyId:t.id}})},"data-test-subj":"addPackagePolicyButton",tooltip:o?void 0:{content:b?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.epm.addPackagePolicyButtonSecurityRequiredTooltip",defaultMessage:"To add Elastic Agent Integrations, you must have security enabled and have the All privilege for Fleet. Contact your administrator."}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.epm.addPackagePolicyButtonPrivilegesRequiredTooltip",defaultMessage:"Elastic Agent Integrations require the All privilege for Fleet and All privilege for Integrations. Contact your administrator."})}},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.addPackagePolicyButtonText",defaultMessage:"Add integration"}))],box:{incremental:!0,schema:!0},filters:[{type:"field_value_selection",field:"namespace",name:"Namespace",options:y,multiSelect:"or",operator:"exact"}]},isSelectable:!1}))},H=Object(n.memo)((({policyId:e})=>{const{application:t}=Object(c.hc)(),a=Object(c.tb)().integrations.writeIntegrationPolicies;return l.a.createElement(u.EuiEmptyPrompt,{iconType:"plusInCircle",title:l.a.createElement("h3",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetailsPackagePolicies.createFirstTitle",defaultMessage:"Add your first integration"})),body:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetailsPackagePolicies.createFirstMessage",defaultMessage:"This policy does not have any integrations yet."}),actions:l.a.createElement(u.EuiButton,{iconType:"plusInCircle",isDisabled:!a,fill:!0,onClick:()=>t.navigateToApp(F.l,{path:F.q.integrations_all({})[1],state:{forAgentPolicyId:e}}),"data-test-subj":"addPackagePolicyButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetailsPackagePolicies.createFirstButtonText",defaultMessage:"Add integration"}))})})),U=Object(n.memo)((({agentPolicy:e})=>(Object(c.ub)("policy_details",{policyName:e.name}),e.package_policies&&0!==e.package_policies.length?l.a.createElement(N,{agentPolicy:e,packagePolicies:e.package_policies}):l.a.createElement(H,{policyId:e.id}))));var q=a(14);const G=e=>Object(q.pick)(e,["name","description","namespace","monitoring_enabled","unenroll_timeout","inactivity_timeout","data_output_id","monitoring_output_id","download_source_id","fleet_server_host_id","agent_features","is_protected"]),W=p.a.div.withConfig({displayName:"FormWrapper",componentId:"sc-1lbh22t-0"})(["max-width:800px;margin-right:auto;margin-left:auto;"]),$=Object(n.memo)((({agentPolicy:e})=>{Object(c.ub)("policy_details",{policyName:e.name});const{notifications:t}=Object(c.hc)(),{agents:{enabled:a}}=Object(c.wb)(),i=Object(r.useHistory)(),{getPath:s}=Object(c.Zb)(),o=Object(c.tb)().fleet.all,m=Object(c.sb)(),[p,E]=Object(n.useState)({...e}),[f,b]=Object(n.useState)(!1),[h,y]=Object(n.useState)(!1),[k,v]=Object(n.useState)(0),[F,M]=Object(n.useState)(!0),I=Object(S.h)(p),O=async()=>{b(!0);try{const{data:e,error:a}=await Object(c.pb)(p.id,G(p));e?(t.toasts.addSuccess(g.i18n.translate("xpack.fleet.editAgentPolicy.successNotificationTitle",{defaultMessage:"Successfully updated '{name}' settings",values:{name:p.name}})),m(),y(!1)):t.toasts.addDanger(a?a.message:g.i18n.translate("xpack.fleet.editAgentPolicy.errorNotificationTitle",{defaultMessage:"Unable to update agent policy"}))}catch(e){t.toasts.addDanger(g.i18n.translate("xpack.fleet.editAgentPolicy.errorNotificationTitle",{defaultMessage:"Unable to update agent policy"}))}b(!1)},{showDevtoolsRequest:T}=j.b.get(),C=Object(n.useMemo)((()=>Object(w.c)(p.id,G(p))),[p]);return l.a.createElement(W,null,k?l.a.createElement(S.f,{agentCount:k,agentPolicy:p,onConfirm:()=>{v(0),O()},onCancel:()=>{v(0),b(!1)}}):null,l.a.createElement(S.d,{agentPolicy:p,updateAgentPolicy:e=>{E({...p,...e}),y(!0)},withSysMonitoring:F,updateSysMonitoring:e=>M(e),validation:I,isEditing:!0,onDelete:()=>{i.push(s("policies_list"))}}),h?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"xl"}),l.a.createElement(u.EuiSpacer,{size:"xl"}),l.a.createElement(u.EuiBottomBar,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.editAgentPolicy.unsavedChangesText",defaultMessage:"You have unsaved changes"})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{color:"ghost",onClick:()=>{E({...e}),y(!1)}},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.editAgentPolicy.cancelButtonText",defaultMessage:"Cancel"}))),T?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(x.i,{isDisabled:f||Object.keys(I).length>0,btnProps:{color:"ghost"},description:g.i18n.translate("xpack.fleet.editAgentPolicy.devtoolsRequestDescription",{defaultMessage:"This Kibana request updates an agent policy."}),request:C})):null,l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{onClick:async()=>{if(a){b(!0);const{data:e}=await Object(c.w)({policyId:p.id});null!=e&&e.results.total?v(e.results.total):await O()}else await O()},isLoading:f,isDisabled:!o||f||Object.keys(I).length>0,iconType:"save",color:"primary",fill:!0},f?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.editAgentPolicy.savingButtonText",defaultMessage:"Saving…"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.editAgentPolicy.saveButtonText",defaultMessage:"Save changes"})))))))):null)})),K=({isLoading:e,policyId:t,agentPolicy:a})=>{const{getHref:n}=Object(c.Zb)();return l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"s",alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiButtonEmpty,{iconType:"arrowLeft",href:n("policies_list"),flush:"left",size:"xs"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.viewAgentListTitle",defaultMessage:"View all agent policies"}))),l.a.createElement(u.EuiFlexItem,null,e?l.a.createElement(x.r,null):l.a.createElement(u.EuiFlexGroup,{alignItems:"center",wrap:!0,responsive:!1,gutterSize:"s"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiTitle,null,l.a.createElement("h1",null,a&&a.name||l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.policyDetailsTitle",defaultMessage:"Policy '{id}'",values:{id:t}})))),(null==a?void 0:a.is_managed)&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiIconTip,{title:"Hosted agent policy",content:g.i18n.translate("xpack.fleet.policyDetails.policyDetailsHostedPolicyTooltip",{defaultMessage:"This policy is managed outside of Fleet. Most actions related to this policy are unavailable."}),type:"lock",size:"l",color:"subdued"})))),a&&a.description?l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiText,{color:"subdued",size:"s",className:"eui-textBreakWord"},a.description)):null)};var V=a(1);const Q=p.a.div.withConfig({displayName:"Divider",componentId:"sc-zpeocb-0"})(["width:0;height:100%;border-left:",";"],(e=>e.theme.eui.euiBorderThin)),Y=({isLoading:e,policyId:t,agentPolicy:a,agentStatus:i,addAgent:s,onCancelEnrollment:o,isAddAgentHelpPopoverOpen:m,setIsAddAgentHelpPopoverOpen:p})=>{var E;const{getPath:f}=Object(c.Zb)(),b=Object(r.useHistory)(),h=Object(n.useMemo)((()=>{var e;return null==a||null===(e=a.package_policies)||void 0===e?void 0:e.some((e=>{var t;return(null===(t=e.package)||void 0===t?void 0:t.name)===V.Q}))}),[a]);if(!a)return null;const y=l.a.createElement(u.EuiLink,{onClick:s,"data-test-subj":"addAgentLink"},h?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.addFleetServerButton",defaultMessage:"Add Fleet Server"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.addAgentButton",defaultMessage:"Add agent"}));return l.a.createElement(u.EuiFlexGroup,{justifyContent:"flexEnd",direction:"row"},[{label:g.i18n.translate("xpack.fleet.policyDetails.summary.revision",{defaultMessage:"Revision"}),content:null!==(E=null==a?void 0:a.revision)&&void 0!==E?E:0},{isDivider:!0},{label:g.i18n.translate("xpack.fleet.policyDetails.summary.integrations",{defaultMessage:"Integrations"}),content:l.a.createElement(u.EuiI18nNumber,{value:a&&a.package_policies&&a.package_policies.length||0})},{isDivider:!0},{label:g.i18n.translate("xpack.fleet.policyDetails.summary.usedBy",{defaultMessage:"Agents"}),content:i&&i.total?l.a.createElement(S.g,{count:i.total,agentPolicyId:a&&a.id||"",showAgentText:!0}):null!=a&&a.is_managed?l.a.createElement(S.g,{count:0,agentPolicyId:a&&a.id||"",showAgentText:!0}):l.a.createElement(x.a,{button:y,isOpen:m,offset:15,closePopover:()=>{p(!1)}})},{isDivider:!0},{label:g.i18n.translate("xpack.fleet.policyDetails.summary.lastUpdated",{defaultMessage:"Last updated on"}),content:a&&l.a.createElement(d.FormattedDate,{value:null==a?void 0:a.updated_at,year:"numeric",month:"short",day:"2-digit"})||""},{isDivider:!0},{content:a&&l.a.createElement(S.a,{agentPolicy:a,fullButton:!0,onCopySuccess:e=>{b.push(f("policy_details",{policyId:e.id}))},onCancelEnrollment:o})}].map(((e,t)=>{var a;return l.a.createElement(u.EuiFlexItem,{grow:!1,key:t},null!==(a=e.isDivider)&&void 0!==a&&a?l.a.createElement(Q,null):e.label?l.a.createElement(u.EuiDescriptionList,{compressed:!0,textStyle:"reverse",style:{textAlign:"right"}},l.a.createElement(u.EuiDescriptionListTitle,{className:"eui-textNoWrap"},e.label),l.a.createElement(u.EuiDescriptionListDescription,{className:"eui-textNoWrap"},e.content)):e.content)})))},Z=()=>{var e;const{params:{policyId:t,tabId:a=""}}=Object(r.useRouteMatch)(),{getHref:i}=Object(c.Zb)(),s=Object(c.Mb)(t),o=s.data?s.data.item:null,{isLoading:m,error:p,sendRequest:E}=s,f=new URLSearchParams(Object(r.useLocation)().search),b="true"===f.get("openEnrollmentFlyout"),h="true"===f.get("showAddAgentHelp"),[y]=Object(n.useState)(!1),[k,v]=Object(n.useState)(b),[F,I]=Object(n.useState)(h),S=function(e,t){const a=Object(c.ec)({path:j.d.getStatusPath(),query:{policyId:e},method:"get"});return{isLoading:a.isLoading,data:a.data,error:a.error,refreshAgentStatus:()=>a.resendRequest}}(t),{refreshAgentStatus:O}=S,{application:{navigateToApp:T}}=Object(c.hc)(),w=Object(c.Ub)(),C=null===(e=S.data)||void 0===e?void 0:e.results,{isReady:P}=Object(c.Db)(),A=Object(n.useMemo)((()=>{if(w&&w.onDoneNavigateTo&&P){const[e,t]=w.onDoneNavigateTo;return()=>T(e,t)}}),[P,T,w]),L=Object(n.useCallback)((()=>{I(!1),v(!0)}),[]),D=Object(n.useMemo)((()=>[{id:"integrations",name:g.i18n.translate("xpack.fleet.policyDetails.subTabs.packagePoliciesTabText",{defaultMessage:"Integrations"}),href:i("policy_details",{policyId:t,tabId:"integrations"}),isSelected:""===a||"integrations"===a},{id:"settings",name:g.i18n.translate("xpack.fleet.policyDetails.subTabs.settingsTabText",{defaultMessage:"Settings"}),href:i("policy_details",{policyId:t,tabId:"settings"}),isSelected:"settings"===a}]),[i,t,a]),B=Object(n.useMemo)((()=>y?l.a.createElement(r.Redirect,{to:"/"}):m?l.a.createElement(x.r,null):p?l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.unexceptedErrorTitle",defaultMessage:"An error happened while loading the agent policy"}),error:p}):o?l.a.createElement(l.a.Fragment,null,k&&l.a.createElement(u.EuiPortal,null,l.a.createElement(x.c,{agentPolicy:o,onClose:A||(()=>v(!1))})),l.a.createElement(J,{agentPolicy:o})):l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyDetails.unexceptedErrorTitle",defaultMessage:"An error happened while loading the agent policy"}),error:g.i18n.translate("xpack.fleet.policyDetails.policyNotFoundErrorTitle",{defaultMessage:"Policy '{id}' not found",values:{id:t}})})),[y,m,p,o,k,A,t]),R=l.a.createElement(K,{agentPolicy:o,policyId:t,isLoading:m}),z=l.a.createElement(Y,{agentPolicy:o,agentStatus:C,policyId:t,onCancelEnrollment:A,isLoading:m,isAddAgentHelpPopoverOpen:F,setIsAddAgentHelpPopoverOpen:I,addAgent:L});return l.a.createElement(c.a.Provider,{value:{refresh:E}},l.a.createElement(_.Provider,{value:{refresh:O}},l.a.createElement(M.c,{leftColumn:R,rightColumn:z,tabs:D},B)))},J=({agentPolicy:e})=>(Object(c.ub)("policy_details",{policyName:e.name}),l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.policy_details_settings,render:()=>l.a.createElement($,{agentPolicy:e})}),l.a.createElement(o.a,{path:F.h.policy_details,render:()=>l.a.createElement(U,{agentPolicy:e})})));var X=a(162);const ee=Object(n.memo)((()=>{const{params:{packagePolicyId:e}}=Object(r.useRouteMatch)(),{search:t}=Object(r.useLocation)(),a=new URLSearchParams(t).get("from");let n;return a&&"fleet-policy-list"===a?n="upgrade-from-fleet-policy-list":a&&"integrations-policy-list"===a&&(n="upgrade-from-integrations-policy-list"),l.a.createElement(X.a,{packagePolicyId:e,from:n,forceUpgrade:!0})})),te=()=>(Object(c.ub)("policies"),l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.edit_integration},l.a.createElement(X.b,null)),l.a.createElement(o.a,{path:F.h.upgrade_package_policy},l.a.createElement(ee,null)),l.a.createElement(o.a,{path:F.h.policy_details},l.a.createElement(Z,null)),l.a.createElement(o.a,{path:F.h.policies_list},l.a.createElement(M.a,{section:"agent_policies"},l.a.createElement(L,null)))));var ae=a(63);const ne=Object(n.memo)((({datastream:e})=>{const{dashboards:t}=e,a=Object(c.zb)(),n=l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.dataStreamList.viewDashboardActionText",defaultMessage:"View dashboard"}),i=l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.dataStreamList.viewDashboardsActionText",defaultMessage:"View dashboards"}),s=g.i18n.translate("xpack.fleet.dataStreamList.viewDashboardsPanelTitle",{defaultMessage:"View dashboards"}),r=g.i18n.translate("xpack.fleet.dataStreamList.viewInApmActionText",{defaultMessage:"View in APM"}),{isSuccessful:o,href:u}=Object(ae.a)(e);if(o&&u){const e=[{id:0,items:[{icon:"apmApp",href:u,name:r}]}];return l.a.createElement(x.h,{panels:e})}if(!t||0===t.length){const e=[{id:0,items:[{icon:"dashboardApp",disabled:!0,name:n}]}];return l.a.createElement(x.h,{panels:e})}if(1===t.length){var m;const e=[{id:0,items:[{icon:"dashboardApp",href:null==a?void 0:a.getRedirectUrl({dashboardId:null===(m=t[0])||void 0===m?void 0:m.id}||""),name:n}]}];return l.a.createElement(x.h,{panels:e})}const p=[{id:0,items:[{icon:"dashboardApp",panel:1,name:i}]},{id:1,title:s,items:t.map((e=>({icon:"dashboardApp",href:null==a?void 0:a.getRedirectUrl({dashboardId:null==e?void 0:e.id}||""),name:e.title})))}];return l.a.createElement(x.h,{panels:p})})),le=()=>{Object(c.ub)("data_streams");const{pagination:e,pageSizeOptions:t}=Object(c.bc)(),{isLoading:a,data:i,resendRequest:s}=Object(c.Gb)(),r=Object(n.useMemo)((()=>[{field:"dataset",sortable:!0,width:"25%",name:g.i18n.translate("xpack.fleet.dataStreamList.datasetColumnTitle",{defaultMessage:"Dataset"})},{field:"type",sortable:!0,name:g.i18n.translate("xpack.fleet.dataStreamList.typeColumnTitle",{defaultMessage:"Type"})},{field:"namespace",sortable:!0,name:g.i18n.translate("xpack.fleet.dataStreamList.namespaceColumnTitle",{defaultMessage:"Namespace"}),render:e=>e?l.a.createElement(u.EuiBadge,{color:"hollow"},e):""},{field:"package",sortable:!0,name:g.i18n.translate("xpack.fleet.dataStreamList.integrationColumnTitle",{defaultMessage:"Integration"}),render:(e,t)=>l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",alignItems:"center"},t.package_version&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(x.t,{packageName:e,version:t.package_version,size:"m",tryApi:!0})),l.a.createElement(u.EuiFlexItem,{grow:!1},e))},{field:"last_activity_ms",sortable:!0,width:"25%",dataType:"date",name:g.i18n.translate("xpack.fleet.dataStreamList.lastActivityColumnTitle",{defaultMessage:"Last activity"}),render:e=>l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedDate,{value:e,year:"numeric",month:"short",day:"numeric"}),l.a.createElement(l.a.Fragment,null," @ "),l.a.createElement(d.FormattedTime,{value:e,hour:"numeric",minute:"numeric",second:"numeric"}))},{field:"size_in_bytes",sortable:!0,name:g.i18n.translate("xpack.fleet.dataStreamList.sizeColumnTitle",{defaultMessage:"Size"}),render:(e,t)=>l.a.createElement(l.a.Fragment,null,t.size_in_bytes_formatted)},{name:g.i18n.translate("xpack.fleet.dataStreamList.actionsColumnTitle",{defaultMessage:"Actions"}),actions:[{render:e=>l.a.createElement(ne,{datastream:e})}]}]),[]),o=Object(n.useMemo)((()=>l.a.createElement(u.EuiEmptyPrompt,{title:l.a.createElement("h2",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.dataStreamList.noDataStreamsPrompt",defaultMessage:"No data streams"}))})),[]),m={dataset:[],type:[],namespace:[],package:[]};if(i&&i.data_streams.length){const e={dataset:[],type:[],namespace:[],package:[]};i.data_streams.forEach((t=>{const{dataset:a,type:n,namespace:l,package:i}=t;e.dataset.includes(a)||e.dataset.push(a),e.type.includes(n)||e.type.push(n),e.namespace.includes(l)||e.namespace.push(l),e.package.includes(i)||e.package.push(i)}));for(const t in e)m[t]&&(m[t]=e[t].sort().map((e=>({value:e,name:e}))))}return l.a.createElement(u.EuiInMemoryTable,{loading:a,hasActions:!0,tableLayout:"auto",message:a?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.dataStreamList.loadingDataStreamsMessage",defaultMessage:"Loading data streams…"}):i&&!i.data_streams.length?o:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.dataStreamList.noFilteredDataStreamsMessage",defaultMessage:"No matching data streams found"}),items:i?i.data_streams:[],itemId:"index",columns:r,pagination:{initialPageSize:e.pageSize,pageSizeOptions:t},sorting:!0,search:{toolsRight:[l.a.createElement(u.EuiButton,{key:"reloadButton",color:"primary",iconType:"refresh",onClick:()=>s()},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.dataStreamList.reloadDataStreamsButtonText",defaultMessage:"Reload"}))],box:{placeholder:g.i18n.translate("xpack.fleet.dataStreamList.searchPlaceholderTitle",{defaultMessage:"Filter data streams"}),incremental:!0},filters:[{type:"field_value_selection",field:"dataset",name:g.i18n.translate("xpack.fleet.dataStreamList.datasetColumnTitle",{defaultMessage:"Dataset"}),multiSelect:"or",operator:"exact",options:m.dataset},{type:"field_value_selection",field:"type",name:g.i18n.translate("xpack.fleet.dataStreamList.typeColumnTitle",{defaultMessage:"Type"}),multiSelect:"or",operator:"exact",options:m.type},{type:"field_value_selection",field:"namespace",name:g.i18n.translate("xpack.fleet.dataStreamList.namespaceColumnTitle",{defaultMessage:"Namespace"}),multiSelect:"or",operator:"exact",options:m.namespace},{type:"field_value_selection",field:"package",name:g.i18n.translate("xpack.fleet.dataStreamList.integrationColumnTitle",{defaultMessage:"Integration"}),multiSelect:"or",operator:"exact",options:m.package}]}})},ie=()=>l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.data_streams},l.a.createElement(M.a,{section:"data_streams"},l.a.createElement(le,null))));var se=a(5),re=a(115),oe=a(167);const ce=({onClose:e,agents:t,agentCount:a})=>{const{notifications:i}=Object(c.hc)(),[s,o]=Object(n.useState)(!1),m=Array.isArray(t)&&1===t.length,{getPath:p}=Object(c.Zb)(),E=Object(r.useHistory)();return l.a.createElement(u.EuiConfirmModal,{"data-test-subj":"requestDiagnosticsModal",title:m?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.singleTitle",defaultMessage:"Request diagnostics"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.multipleTitle",defaultMessage:"Request diagnostics for {count} agents",values:{count:a}}),onCancel:e,onConfirm:async function(){try{o(!0);const{error:a}=m?await Object(c.cb)(t[0].id):await Object(c.U)({agents:"string"==typeof t?t:t.map((e=>e.id))});if(a)throw a;o(!1);const n=g.i18n.translate("xpack.fleet.requestDiagnostics.successSingleNotificationTitle",{defaultMessage:"Request diagnostics submitted"});if(i.toasts.addSuccess(n),m){const e=p("agent_details_diagnostics",{agentId:t[0].id});E.push(e)}e()}catch(e){o(!1),i.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.requestDiagnostics.fatalErrorNotificationTitle",{defaultMessage:"Error requesting diagnostics {count, plural, one {agent} other {agents}}",values:{count:a}})})}},cancelButtonText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.cancelButtonLabel",defaultMessage:"Cancel"}),confirmButtonDisabled:s,confirmButtonText:m?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.confirmSingleButtonLabel",defaultMessage:"Request diagnostics"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.confirmMultipleButtonLabel",defaultMessage:"Request diagnostics for {count} agents",values:{count:a}}),buttonColor:"primary"},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.description",defaultMessage:"Diagnostics files are stored in Elasticsearch, and as such can incur storage costs."})))};var ue=a(88);const de=Object(u.euiPaletteColorBlindBehindText)(),ge={default:ue.euiLightVars.euiColorLightShade,primary:de[1],success:de[0],accent:de[2],warning:de[5],danger:de[9],inactive:ue.euiLightVars.euiColorDarkShade,lightest:ue.euiLightVars.euiColorDisabled},me=["healthy","unhealthy","updating","offline","inactive","unenrolled"];function pe(e){switch(e){case"healthy":return ge.success;case"offline":return ge.default;case"inactive":return ge.inactive;case"unhealthy":return ge.warning;case"updating":return ge.primary;case"unenrolled":return ge.lightest;default:throw new Error(`Unsupported Agent status ${e}`)}}const Ee=p()(u.EuiColorPaletteDisplay).withConfig({displayName:"StyledEuiColorPaletteDisplay",componentId:"sc-1wvk6tr-0"})(["&.ingest-agent-status-bar{border:none;border-radius:0;&:after{border:none;}}"]),fe=({agentStatus:e})=>{const t=Object(n.useMemo)((()=>me.reduce(((t,a)=>{const n=t.length>0?t[t.length-1].stop:0;return t.push({stop:n+(e[a]||0),color:pe(a)}),t}),[])),[e]);return 0===t[t.length-1].stop?l.a.createElement(u.EuiSpacer,{size:"s"}):l.a.createElement(Ee,{"data-test-subj":"agentStatusBar",className:"ingest-agent-status-bar",size:"s",palette:t})},be=p.a.div.withConfig({displayName:"Divider",componentId:"sc-1e6bwq9-0"})(["width:0;height:",";border-left:",";"],(e=>e.theme.eui.euiSizeL),(e=>e.theme.eui.euiBorderThin)),he=p()(u.EuiFlexItem).withConfig({displayName:"FlexItem",componentId:"sc-1e6bwq9-1"})(["height:",";"],(e=>e.theme.eui.euiSizeL)),ye=p()(u.EuiButtonEmpty).withConfig({displayName:"Button",componentId:"sc-1e6bwq9-2"})([".euiButtonEmpty__text{font-size:",";}"],(e=>e.theme.eui.euiFontSizeXS)),ke=({totalAgents:e,selectableAgents:t,managedAgentsOnCurrentPage:a,selectionMode:n,setSelectionMode:i,selectedAgents:s,setSelectedAgents:r})=>{const o="manual"===n&&s.length>0||"query"===n&&e>0,c="manual"===n&&s.length===t&&tF.p?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.totalAgentsWithLimit",defaultMessage:"Showing {count} of {total} agents",values:{count:l.a.createElement(d.FormattedNumber,{value:F.p}),total:l.a.createElement(d.FormattedNumber,{value:e})}}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.totalAgents",defaultMessage:"Showing {count, plural, one {# agent} other {# agents}}",values:{count:e}}))),o?l.a.createElement(l.a.Fragment,null,l.a.createElement(he,{grow:!1},l.a.createElement(be,null)),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiText,{size:"xs",color:"subdued","data-test-subj":"selectedAgentCountLabel"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.agentsSelected",defaultMessage:"{count, plural, one {# agent} other {# agents} =all {All agents}} selected",values:{count:"manual"===n?s.length:"all"}}))),c?l.a.createElement(l.a.Fragment,null,l.a.createElement(he,{grow:!1},l.a.createElement(be,null)),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ye,{size:"xs",flush:"left","data-test-subj":"selectedEverythingOnAllPagesButton",onClick:()=>i("query")},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.selectAll",defaultMessage:"Select everything on all pages"})))):null,l.a.createElement(he,{grow:!1},l.a.createElement(be,null)),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ye,{size:"xs",flush:"left","data-test-subj":"clearAgentSelectionButton",onClick:()=>{i("manual"),r([])}},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.clearSelection",defaultMessage:"Clear selection"})))):l.a.createElement(he,{grow:!1})))},ve=Object(n.memo)((({agentStatus:e,showInactive:t})=>{const a=Object(n.useMemo)((()=>me.filter((e=>!!t||"inactive"!==e&&"unenrolled"!==e))),[t]);return l.a.createElement(u.EuiFlexGroup,{gutterSize:"m"},a.map((t=>l.a.createElement(u.EuiFlexItem,{key:t,grow:!1},l.a.createElement(xe,{status:t,count:e[t]||0})))))})),xe=Object(n.memo)((({status:e,count:t})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiHealth,{color:pe(e)},l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"s"},l.a.createElement(u.EuiFlexItem,{grow:!1},function(e){switch(e){case"healthy":return g.i18n.translate("xpack.fleet.agentStatus.healthyLabel",{defaultMessage:"Healthy"});case"offline":return g.i18n.translate("xpack.fleet.agentStatus.offlineLabel",{defaultMessage:"Offline"});case"inactive":return g.i18n.translate("xpack.fleet.agentStatus.inactiveLabel",{defaultMessage:"Inactive"});case"unenrolled":return g.i18n.translate("xpack.fleet.agentStatus.unenrolledLabel",{defaultMessage:"Unenrolled"});case"unhealthy":return g.i18n.translate("xpack.fleet.agentStatus.unhealthyLabel",{defaultMessage:"Unhealthy"});case"updating":return g.i18n.translate("xpack.fleet.agentStatus.updatingLabel",{defaultMessage:"Updating"});default:throw new Error(`Unsupported Agent status ${e}`)}}(e)),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiNotificationBadge,{size:"s",color:"subdued"},t))))))),Fe=({agentStatus:e,totalAgents:t,selectableAgents:a,managedAgentsOnCurrentPage:n,selectionMode:i,setSelectionMode:s,selectedAgents:r,setSelectedAgents:o,showInactive:c,clearFilters:g,isUsingFilter:m})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexGroup,{justifyContent:"flexStart",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ke,{totalAgents:t,selectableAgents:a,managedAgentsOnCurrentPage:n,selectionMode:i,setSelectionMode:s,selectedAgents:r,setSelectedAgents:o})),m?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiLink,{onClick:()=>g()},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.header.clearFiltersLinkText",defaultMessage:"Clear filters"}))):null),l.a.createElement(u.EuiFlexItem,{grow:!1},e&&l.a.createElement(ve,{showInactive:c,agentStatus:e}))),l.a.createElement(u.EuiSpacer,{size:"s"}),e&&l.a.createElement(fe,{agentStatus:e}));var Me=a(205);const Ie=20;function Se(e){return e.length>Ie?`${e.substring(0,Ie)}...`:e}function Oe(e){return e.replace(/[^a-zA-Z0-9 \-_]/g,"").slice(0,20)}const Te=()=>{const{notifications:e}=Object(c.hc)(),t=Object(n.useCallback)((async(t,a,n,l)=>{try{const l=await t();if(l.error)throw l.error;const i=!l.data.actionId,s=null!=n?n:g.i18n.translate("xpack.fleet.updateAgentTags.successNotificationTitle",{defaultMessage:"Tag(s) updated"});e.toasts.addSuccess(s),a(i)}catch(t){const a=null!=l?l:g.i18n.translate("xpack.fleet.updateAgentTags.errorNotificationTitle",{defaultMessage:"Tag(s) update failed"});e.toasts.addError(t,{title:a})}}),[e.toasts]);return{updateTags:Object(n.useCallback)((async(e,a,n,l,i)=>{await t((async()=>await Object(c.eb)(e,{tags:a})),n,l,i)}),[t]),bulkUpdateTags:Object(n.useCallback)((async(e,a,n,l,i,s)=>{await t((async()=>await Object(c.R)({agents:e,tagsToAdd:a,tagsToRemove:n})),l,i,s)}),[t])}},we="fleet.lastSeenInactiveAgentsCount",je="fleet.inactiveAgentsCalloutHasBeenDismissed";async function Ce(){var e,t;const a=await Object(c.z)({kuery:"status:online",perPage:0,showInactive:!1});if(a.error)throw new Error(a.error.message);return null!==(e=null===(t=a.data)||void 0===t?void 0:t.total)&&void 0!==e?e:0}const Pe=({tagName:e,isTagHovered:t,onTagsUpdated:a})=>{const[i,s]=Object(n.useState)(!1),[r,o]=Object(n.useState)(),[c,m]=Object(n.useState)(t),[p,E]=Object(n.useState)(e);Object(n.useEffect)((()=>{m(t||i)}),[t,i]),Object(n.useEffect)((()=>{E(e)}),[e]);const f=(e=!1)=>{s(!1),e?v():k(p)},b=Te(),h=b.bulkUpdateTags,y='tags:"{name}"',k=t=>{if(t===e||!t)return;const n=y.replace("{name}",e);h(n,[t],[e],(n=>a([t],[e],n)),g.i18n.translate("xpack.fleet.renameAgentTags.successNotificationTitle",{defaultMessage:"Tag renamed"}),g.i18n.translate("xpack.fleet.renameAgentTags.errorNotificationTitle",{defaultMessage:"Tag rename failed"}))},v=()=>{const t=y.replace("{name}",e);b.bulkUpdateTags(t,[],[e],(t=>a([],[e],t)),g.i18n.translate("xpack.fleet.deleteAgentTags.successNotificationTitle",{defaultMessage:"Tag deleted"}),g.i18n.translate("xpack.fleet.deleteAgentTags.errorNotificationTitle",{defaultMessage:"Tag delete failed"}))};return l.a.createElement(l.a.Fragment,null,c&&l.a.createElement(u.EuiButtonIcon,{iconType:"boxesHorizontal","aria-label":g.i18n.translate("xpack.fleet.tagOptions.tagOptionsToggleButtonLabel",{defaultMessage:"Tag Options"}),color:"text",onClick:e=>{o(e.currentTarget),s(!i)}}),i&&l.a.createElement(u.EuiWrappingPopover,{isOpen:!0,button:r,closePopover:f,anchorPosition:"downCenter"},l.a.createElement(u.EuiFlexGroup,{direction:"column",alignItems:"flexStart",gutterSize:"xs"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFieldText,{placeholder:g.i18n.translate("xpack.fleet.tagOptions.nameTextFieldPlaceholder",{defaultMessage:"Enter new name for tag"}),value:p,required:!0,onKeyDown:e=>{"Enter"===e.key&&f()},onChange:e=>{const t=e.currentTarget.value;E(Oe(t))}})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiButtonEmpty,{size:"s",color:"danger",onClick:()=>{f(!0)}},l.a.createElement(u.EuiIcon,{type:"trash"})," ",l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.tagOptions.deleteText",defaultMessage:"Delete tag"}))))))},Ae=p()(u.EuiHighlight).withConfig({displayName:"TruncatedEuiHighlight",componentId:"sc-492jbf-0"})(["width:120px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"]),Le=({agentId:e,agents:t,allTags:a,selectedTags:i,button:s,onTagsUpdated:r,onClosePopover:o})=>{const c=Object(n.useCallback)(((e,t)=>e.map((e=>({label:e,checked:t.includes(e)?"on":void 0,onFocusBadge:!1})))),[]),[m,p]=Object(n.useState)(c(a,i)),[E,f]=Object(n.useState)(void 0),[b,h]=Object(n.useState)(!0),[y,k]=Object(n.useState)({}),v=Te();Object(n.useEffect)((()=>{p(c(a,i))}),[a,c,i]);const x=Object(n.useMemo)((()=>m.some((e=>e.label===E))),[m,E]),F=(e,t,n=!0,l=!1)=>{if(n)return r();const i=m.filter((e=>"on"===e.checked)).map((e=>e.label)),s=Object(q.difference)(i,t).concat(e),o=Object(q.uniq)(a.concat(s)),u=l?Object(q.difference)(o,t):o;p(c(u,s))},M=async(a,n,l,s)=>{if(e){const t=Object(q.difference)(i,n).concat(a);v.updateTags(e,t,(()=>r()),l,s)}else v.bulkUpdateTags(t,a,n,(e=>F(a,n,e)),l,s)},I=l.a.createElement(u.EuiButtonEmpty,{color:"text","data-test-subj":"createTagBtn",onClick:()=>{E&&M([E],[],g.i18n.translate("xpack.fleet.createAgentTags.successNotificationTitle",{defaultMessage:"Tag created"}),g.i18n.translate("xpack.fleet.createAgentTags.errorNotificationTitle",{defaultMessage:"Tag creation failed"}))}},l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"s"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiIcon,{type:"plus"})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.tagsAddRemove.createText",defaultMessage:'Create a new tag "{name}"',values:{name:E}}))));return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiWrappingPopover,{isOpen:b,button:s,closePopover:()=>{h(!1),o()},anchorPosition:"leftUp"},l.a.createElement(u.EuiSelectable,{onFocus:()=>{},"aria-label":g.i18n.translate("xpack.fleet.tagsAddRemove.selectableTagsLabel",{defaultMessage:"Add / remove tags"}),searchable:!0,searchProps:{"data-test-subj":"addRemoveTags",placeholder:g.i18n.translate("xpack.fleet.tagsAddRemove.findOrCreatePlaceholder",{defaultMessage:"Find or create tag..."}),onChange:e=>{f(Oe(e))},value:null!=E?E:""},options:m,renderOption:(e,t)=>l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",onMouseEnter:()=>k({...y,[e.label]:!0}),onMouseLeave:()=>k({...y,[e.label]:!1})},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(Ae,{search:t,onClick:()=>{const t="on"===e.checked?[]:[e.label],a="on"===e.checked?[e.label]:[];M(t,a)}},e.label)),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(Pe,{tagName:e.label,isTagHovered:y[e.label],onTagsUpdated:(e,t,a)=>F(e,t,a,!0)})))},((e,t)=>l.a.createElement(n.Fragment,null,t,e))),x&&0!==m.length||""===E?null:I))},_e=({shownAgents:e,inactiveShownAgents:t,totalManagedAgentIds:a,selectionMode:i,currentQuery:s,selectedAgents:r,visibleAgents:o,refreshAgents:g,allTags:m,agentPolicies:p})=>{const E=Object(c.Yb)().hasAtLeast(V.bb),[f,b]=Object(n.useState)(!1),h=()=>b(!1),[y,k]=Object(n.useState)(!1),[v,x]=Object(n.useState)(!1),[F,M]=Object(n.useState)({isOpen:!1,isScheduled:!1}),[I,S]=Object(n.useState)(!1),[O,T]=Object(n.useState)(!1),w=Object(n.useMemo)((()=>{if(a.length){const e=`${V.b}.agent.id : (${a.map((e=>`"${e}"`)).join(" or ")})`;return`${s} AND NOT (${e})`}return s}),[s,a]),C="manual"===i?!!r.find((e=>e.active)):e>t,P=e-t,A="manual"===i?r.length:P-(null==a?void 0:a.length),L="manual"===i?r:w,[_,D]=Object(n.useState)(),{diagnosticFileUploadEnabled:B}=j.b.get(),R=[{name:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.addRemoveTags","data-test-subj":"agentBulkActionsAddRemoveTags",defaultMessage:"Add / remove tags"}),icon:l.a.createElement(u.EuiIcon,{type:"tag",size:"m"}),disabled:!C,onClick:e=>{D(e.target.closest("button")),S(!I)}},{name:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.reassignPolicy","data-test-subj":"agentBulkActionsReassign",defaultMessage:"Assign to new policy"}),icon:l.a.createElement(u.EuiIcon,{type:"pencil",size:"m"}),disabled:!C,onClick:()=>{h(),k(!0)}},{name:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.unenrollAgents","data-test-subj":"agentBulkActionsUnenroll",defaultMessage:"Unenroll {agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:A}}),icon:l.a.createElement(u.EuiIcon,{type:"trash",size:"m"}),disabled:!C,onClick:()=>{h(),x(!0)}},{name:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.upgradeAgents","data-test-subj":"agentBulkActionsUpgrade",defaultMessage:"Upgrade {agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:A}}),icon:l.a.createElement(u.EuiIcon,{type:"refresh",size:"m"}),disabled:!C,onClick:()=>{h(),M({isOpen:!0,isScheduled:!1})}},{name:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.scheduleUpgradeAgents","data-test-subj":"agentBulkActionsScheduleUpgrade",defaultMessage:"Schedule upgrade for {agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:A}}),icon:l.a.createElement(u.EuiIcon,{type:"timeRefresh",size:"m"}),disabled:!C||!E,onClick:()=>{h(),M({isOpen:!0,isScheduled:!0})}}];B&&R.push({name:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.requestDiagnostics","data-test-subj":"agentBulkActionsRequestDiagnostics",defaultMessage:"Request diagnostics for {agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:A}}),icon:l.a.createElement(u.EuiIcon,{type:"download",size:"m"}),disabled:!C,onClick:()=>{h(),T(!0)}});const z=[{id:0,items:R}],N=Object(n.useMemo)((()=>((e,t,a)=>{const n=e=>e.reduce(((e,t)=>{var n,l;return(e=>{const t=a.find((t=>t.id===e.policy_id));return!!t&&t.is_managed})(t)?e:e.length<1?null!==(l=t.tags)&&void 0!==l?l:[]:Object(q.intersection)(null!==(n=t.tags)&&void 0!==n?n:[],e)}),[]);return Array.isArray(e)?n(t.length>0?t.filter((t=>e.find((e=>e.id===t.id)))):e):n(t)})(L,null!=o?o:[],p)),[L,o,p]);return l.a.createElement(l.a.Fragment,null,y&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.c,{agents:L,onClose:()=>{k(!1),g()}})),v&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.d,{agents:L,agentCount:A,onClose:()=>{x(!1),g({refreshTags:!0})}})),F.isOpen&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.e,{agents:L,agentCount:A,isScheduled:F.isScheduled,onClose:()=>{M({isOpen:!1,isScheduled:!1}),g()}})),I&&l.a.createElement(Le,{agents:Array.isArray(L)?L.map((e=>e.id)):L,allTags:null!=m?m:[],selectedTags:N,button:_,onTagsUpdated:()=>{g({refreshTags:!0})},onClosePopover:()=>{S(!1),h()}}),O&&l.a.createElement(u.EuiPortal,null,l.a.createElement(ce,{agents:L,agentCount:A,onClose:()=>{T(!1)}})),l.a.createElement(u.EuiFlexGroup,{gutterSize:"m",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiPopover,{id:"agentBulkActionsMenu",button:l.a.createElement(u.EuiButton,{fill:!0,iconType:"arrowDown",iconSide:"right",onClick:()=>b(!f),"data-test-subj":"agentBulkActionsButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentBulkActions.actions",defaultMessage:"Actions"})),isOpen:f,closePopover:h,panelPaddingSize:"none",anchorPosition:"downLeft"},l.a.createElement(u.EuiContextMenu,{initialPanelId:0,panels:z})))))},De=({onClickAgentActivity:e,showAgentActivityTour:t})=>{const{uiSettings:a}=Object(c.hc)(),[i,s]=Object(n.useState)(t),r=a.get("hideAgentActivityTour",!1);Object(n.useEffect)((()=>{s(t)}),[t,s]);const o=()=>{s({isOpen:!1}),a.set("hideAgentActivityTour",!0)};return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiTourStep,{content:l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityButton.tourContent",defaultMessage:"Review in progress, completed, and scheduled agent action activity history here anytime."})),isStepOpen:!r&&i.isOpen,onFinish:o,minWidth:360,maxWidth:360,step:1,stepsTotal:1,title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityButton.tourTitle",defaultMessage:"Agent activity history"}),anchorPosition:"upCenter",footerAction:l.a.createElement(u.EuiButtonEmpty,{onClick:o},"OK"),anchor:"#agentActivityButton"}),l.a.createElement(u.EuiButtonEmpty,{onClick:()=>{e(),s({isOpen:!1})},"data-test-subj":"agentActivityButton",iconType:"clock",id:"agentActivityButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.agentActivityButton",defaultMessage:"Agent activity"})))},Be=[{status:"healthy",label:g.i18n.translate("xpack.fleet.agentList.statusHealthyFilterText",{defaultMessage:"Healthy"})},{status:"unhealthy",label:g.i18n.translate("xpack.fleet.agentList.statusUnhealthyFilterText",{defaultMessage:"Unhealthy"})},{status:"updating",label:g.i18n.translate("xpack.fleet.agentList.statusUpdatingFilterText",{defaultMessage:"Updating"})},{status:"offline",label:g.i18n.translate("xpack.fleet.agentList.statusOfflineFilterText",{defaultMessage:"Offline"})},{status:"inactive",label:g.i18n.translate("xpack.fleet.agentList.statusInactiveFilterText",{defaultMessage:"Inactive"})},{status:"unenrolled",label:g.i18n.translate("xpack.fleet.agentList.statusUnenrolledFilterText",{defaultMessage:"Unenrolled"})}],Re=p()(u.EuiNotificationBadge).withConfig({displayName:"LeftpaddedNotificationBadge",componentId:"sc-94zpuo-0"})(["margin-left:10px;"]),ze=p()(u.EuiTourStep).withConfig({displayName:"TourStepNoHeaderFooter",componentId:"sc-94zpuo-1"})([".euiTourFooter{display:none;}.euiTourHeader{display:none;}"]),Ne=({children:e,isOpen:t})=>l.a.createElement(ze,{content:l.a.createElement(u.EuiText,{size:"s"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.inactiveAgentsTourStepContent",defaultMessage:"Some agents have become inactive and have been hidden. Use status filters to show inactive or unenrolled agents."})),isStepOpen:t,minWidth:300,step:1,stepsTotal:0,title:"",onFinish:()=>{},anchorPosition:"upCenter",maxWidth:280},e),He=e=>{const{selectedStatus:t,onSelectedStatusChange:a,disabled:i,totalInactiveAgents:s,isOpenByDefault:r=!1}=e,[o,c]=(()=>{const[e,t]=Object(n.useState)(0);return Object(n.useEffect)((()=>{const e=localStorage.getItem(we);e&&t(parseInt(e,10))}),[]),[e,e=>{localStorage.setItem(we,e.toString()),t(e)}]})(),[g,m]=(()=>{const[e,t]=Object(n.useState)(!1);return Object(n.useEffect)((()=>{const e=localStorage.getItem(je);e&&t(Boolean(e))}),[]),[e,e=>{localStorage.setItem(je,e.toString()),t(e)}]})(),p=Object(n.useMemo)((()=>{const e=s-o;return e<0?0:e}),[o,s]);Object(n.useMemo)((()=>{t.length&&t.includes("inactive")&&p&&c(s)}),[t,p,c,s]),Object(n.useMemo)((()=>{s>0&&o>s&&c(s)}),[o,s,c]);const[E,f]=Object(n.useState)(r),b=e=>{e&&p>0&&!g&&m(!0),f(e)},{euiTheme:h}=Object(u.useEuiTheme)();return l.a.createElement(Ne,{isOpen:p>0&&!g},l.a.createElement(u.EuiPopover,{ownFocus:!0,button:l.a.createElement(u.EuiFilterButton,{iconType:"arrowDown",onClick:()=>b(!E),isSelected:E,hasActiveFilters:t.length>0,numActiveFilters:t.length,numFilters:Be.length,disabled:i,"data-test-subj":"agentList.statusFilter"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.statusFilterText",defaultMessage:"Status"})),isOpen:E,closePopover:()=>b(!1),panelPaddingSize:"none"},l.a.createElement(Ue,{className:"eui-yScroll",$_css:30*h.base},Be.map((({label:e,status:n},i)=>l.a.createElement(u.EuiFilterSelectItem,{key:i,checked:t.includes(n)?"on":void 0,onClick:()=>{t.includes(n)?a([...t.filter((e=>e!==n))]):a([...t,n])}},l.a.createElement("span",null,e,"inactive"===n&&p>0&&l.a.createElement(Re,null,p))))))))};var Ue=p()("div").withConfig({displayName:"_StyledDiv",componentId:"sc-94zpuo-2"})((e=>({maxHeight:e.$_css})));const qe=()=>{const e=Object(c.zb)(),t=t=>(null==e?void 0:e.getRedirectUrl({dashboardId:t}))||"",{dashboardExists:a,loading:i}=(e=>{const[t,a]=l.a.useState(!1),[i,s]=l.a.useState(!0),{dashboard:r}=Object(c.hc)();return Object(n.useEffect)((()=>{(async()=>{try{const t=await r.findDashboardsService(),[n]=await t.findByIds([e]);s(!1),a("success"===(null==n?void 0:n.status))}catch(e){s(!1),a(!1)}})()}),[e,r]),{dashboardExists:t,loading:i}})(V.n.ELASTIC_AGENT_OVERVIEW);return i||!a?null:l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexStart"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{iconType:"dashboardApp",href:t(V.n.ELASTIC_AGENT_OVERVIEW),"data-test-subj":"ingestOverviewLinkButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.ingestOverviewlinkButton",defaultMessage:"Ingest Overview Metrics"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{iconType:"dashboardApp",href:t(V.n.ELASTIC_AGENT_AGENT_INFO),"data-test-subj":"agentInfoLinkButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.agentInfoLinkButton",defaultMessage:"Agent Info Metrics"})))))},Ge=p()(u.EuiFilterSelectItem).withConfig({displayName:"ClearAllTagsFilterItem",componentId:"sc-isvns5-0"})(["padding:",";"],(e=>e.theme.eui.euiSizeS)),We=({agentPolicies:e,draftKuery:t,onDraftKueryChange:a,onSubmitSearch:i,selectedAgentPolicies:s,onSelectedAgentPoliciesChange:r,selectedStatus:o,onSelectedStatusChange:g,showUpgradeable:m,onShowUpgradeableChange:p,tags:E,selectedTags:f,onSelectedTagsChange:b,shownAgents:h,inactiveShownAgents:y,totalInactiveAgents:k,totalManagedAgentIds:v,selectionMode:M,currentQuery:I,selectedAgents:S,refreshAgents:O,onClickAddAgent:T,onClickAddFleetServer:w,visibleAgents:j,onClickAgentActivity:C,showAgentActivityTour:P})=>{const{euiTheme:A}=Object(u.useEuiTheme)(),{isFleetServerStandalone:L}=Object(c.Cb)(),{isFirstTimeAgentUser:_,isLoading:D}=Object(Me.a)(),B=!L,[R,z]=Object(n.useState)(!1),[N,H]=Object(n.useState)(!1);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexGroup,{direction:"column"},l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(u.EuiFlexItem,null,!D&&!_&&l.a.createElement(qe,null)),l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(De,{onClickAgentActivity:C,showAgentActivityTour:P})),B&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.addFleetServerButton.tooltip",defaultMessage:"Fleet Server is a component of the Elastic Stack used to centrally manage Elastic Agents"})},l.a.createElement(u.EuiButton,{onClick:w,"data-test-subj":"addFleetServerButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.addFleetServerButton",defaultMessage:"Add Fleet Server"})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.addAgentButton.tooltip",defaultMessage:"Add Elastic Agents to your hosts to collect data and send it to the Elastic Stack"})},l.a.createElement(u.EuiButton,{fill:!0,onClick:T,"data-test-subj":"addAgentButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.addButton",defaultMessage:"Add agent"})))))),l.a.createElement(u.EuiFlexItem,{grow:4},l.a.createElement(u.EuiFlexGroup,{gutterSize:"s"},l.a.createElement(u.EuiFlexItem,{grow:6},l.a.createElement(x.w,{value:t,onChange:(e,t)=>{a(e),t&&i(e)},fieldPrefix:F.b,indexPattern:F.a,dataTestSubj:"agentList.queryInput"})),l.a.createElement(u.EuiFlexItem,{grow:2},l.a.createElement(u.EuiFilterGroup,null,l.a.createElement(He,{selectedStatus:o,onSelectedStatusChange:g,totalInactiveAgents:k,disabled:0===e.length}),l.a.createElement(u.EuiPopover,{ownFocus:!0,button:l.a.createElement(u.EuiFilterButton,{iconType:"arrowDown",onClick:()=>H(!N),isSelected:N,hasActiveFilters:f.length>0,numActiveFilters:f.length,numFilters:E.length,disabled:0===E.length,"data-test-subj":"agentList.tagsFilter"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.tagsFilterText",defaultMessage:"Tags"})),isOpen:N,closePopover:()=>H(!1),panelPaddingSize:"none"},l.a.createElement($e,{className:"eui-yScroll",$_css:30*A.base},l.a.createElement(l.a.Fragment,null,E.map(((e,t)=>l.a.createElement(u.EuiFilterSelectItem,{checked:f.includes(e)?"on":void 0,key:t,onClick:()=>{f.includes(e)?(e=>{b(f.filter((t=>t!==e)))})(e):(e=>{b([...f,e])})(e)}},e.length>Ie?l.a.createElement(u.EuiToolTip,{content:e},l.a.createElement("span",null,Se(e))):e))),l.a.createElement(u.EuiHorizontalRule,{margin:"none"}),l.a.createElement(Ge,{showIcons:!1,onClick:()=>{b([])}},l.a.createElement(u.EuiFlexGroup,{alignItems:"center",justifyContent:"center",gutterSize:"s"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiIcon,{type:"error",color:"danger",size:"s"})),l.a.createElement(u.EuiFlexItem,{grow:!1},"Clear all")))))),l.a.createElement(u.EuiPopover,{ownFocus:!0,button:l.a.createElement(u.EuiFilterButton,{iconType:"arrowDown",onClick:()=>z(!R),isSelected:R,hasActiveFilters:s.length>0,numActiveFilters:s.length,numFilters:e.length,disabled:0===e.length,"data-test-subj":"agentList.policyFilter"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.policyFilterText",defaultMessage:"Agent policy"})),isOpen:R,closePopover:()=>z(!1),panelPaddingSize:"none"},l.a.createElement(Ke,{className:"eui-yScroll",$_css2:30*A.base},e.map(((e,t)=>l.a.createElement(u.EuiFilterSelectItem,{checked:s.includes(e.id)?"on":void 0,key:t,onClick:()=>{var t;s.includes(e.id)?(t=e.id,r(s.filter((e=>e!==t)))):(e=>{r([...s,e])})(e.id)}},e.name))))),l.a.createElement(u.EuiFilterButton,{hasActiveFilters:m,onClick:()=>{p(!m)},"data-test-subj":"agentList.showUpgradeable"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.showUpgradeableFilterLabel",defaultMessage:"Upgrade available"})))),"manual"===M&&S.length||"query"===M&&h>0?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(_e,{shownAgents:h,inactiveShownAgents:y,totalManagedAgentIds:v,selectionMode:M,currentQuery:I,selectedAgents:S,visibleAgents:j,refreshAgents:O,allTags:E,agentPolicies:e})):null))))};var $e=p()("div").withConfig({displayName:"_StyledDiv",componentId:"sc-isvns5-1"})((e=>({maxHeight:e.$_css}))),Ke=p()("div").withConfig({displayName:"_StyledDiv2",componentId:"sc-isvns5-2"})((e=>({maxHeight:e.$_css2})));const Ve=({search:e,selectedAgentPolicies:t,selectedTags:a,selectedStatus:n,selectedAgentIds:l})=>{let i="";if(e&&(i=e.trim()),null!=t&&t.length&&(i&&(i=`(${i}) and`),i=`${i} ${F.b}.policy_id : (${t.map((e=>`"${e}"`)).join(" or ")})`),null!=a&&a.length&&(i&&(i=`(${i}) and`),i=`${i} ${F.b}.tags : (${a.map((e=>`"${e}"`)).join(" or ")})`),null!=l&&l.length&&(i&&(i=`(${i}) and`),i=`${i} ${F.b}.agent.id : (${l.map((e=>`"${e}"`)).join(" or ")})`),null!=n&&n.length){const e=n.map((e=>{switch(e){case"healthy":return j.a.buildKueryForOnlineAgents();case"unhealthy":return j.a.buildKueryForErrorAgents();case"offline":return j.a.buildKueryForOfflineAgents();case"updating":return j.a.buildKueryForUpdatingAgents();case"inactive":return j.a.buildKueryForInactiveAgents();case"unenrolled":return j.a.buildKueryForUnenrolledAgents()}})).filter((e=>void 0!==e)).join(" or ");i=i?`(${i}) and (${e})`:e}return i.trim()},Qe=()=>(new Date).toISOString().substring(0,10);var Ye=a(161),Ze=a(93),Je=a(83);const Xe=l.a.createContext(null),et=({children:e,...t})=>{const{navigateToUrl:a,currentAppId:n}=t;return Object(Je.jsx)(Xe.Provider,{value:{navigateToUrl:a,currentAppId:n}},e)},tt=({children:e,coreStart:t})=>{const{navigateToUrl:a,currentAppId$:n}=t.application,l=f()(n,void 0);return Object(Je.jsx)(Xe.Provider,{value:{navigateToUrl:a,currentAppId:l}},e)},at={name:"36bnqj",styles:"display:flex;flex:1"},nt=({children:e,navigateToUrl:t,currentAppId:a})=>{const l=Object(n.useRef)(null),i=Object(n.useCallback)((e=>(({event:e,container:t,navigateToUrl:a,currentAppId:n})=>{if(!t||!n)return;const l=((e,t)=>{let a=e;do{var n,l;if("a"===(null===(n=a)||void 0===n?void 0:n.tagName.toLowerCase()))return a;const e=null===(l=a)||void 0===l?void 0:l.parentElement;if(!e||e===document.body||e===t)break;a=e}while(parent||parent!==document.body||parent!==t)})(e.target,t);if(!l)return;const i=l.href,s=""===l.target||"_self"===l.target,r=0===e.button;i&&s&&r&&!e.defaultPrevented&&!(e=>e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)(e)&&(e.preventDefault(),a(l.href))})({event:e,currentAppId:a,navigateToUrl:t,container:l.current})),[a,t]);return Object(Je.jsx)("div",{onClick:i,ref:l,css:at},e)},lt=({children:e})=>Object(Je.jsx)(nt,function(){const e=Object(n.useContext)(Xe);if(!e)throw new Error("RedirectAppLinksContext is missing. Ensure your component or React root is wrapped with RedirectAppLinksProvider.");return e}(),e),it=({children:e,...t})=>{const a=Object(Je.jsx)(lt,null,e);if(void 0!==t.coreStart){const{coreStart:e}=t;return Object(Je.jsx)(tt,{coreStart:e},a)}const{navigateToUrl:n,currentAppId:l}=t;return Object(Je.jsx)(et,{currentAppId:l,navigateToUrl:n},a)},st="logs-elastic_agent-*,logs-elastic_agent.*-*",rt="elastic_agent",ot="elastic_agent.id",ct={name:V.o,type:"string",aggregatable:!0,searchable:!0},ut="log.level",dt="now-1d",gt="now",mt={start:dt,end:gt,logLevels:[],datasets:[rt],query:""},pt="datasets",Et={ERROR:"error",WARNING:"warning",INFO:"info",DEBUG:"debug"},ft=Et.INFO,bt=({agentId:e,datasets:t,logLevels:a,userQuery:n})=>{const l=`${ot}:${e}`,i=t.length?t.map((e=>`${ct.name}:${e}`)).join(" or "):`${ct.name}:${rt} or ${ct.name}:elastic_agent.*`,s=a.map((e=>`${ut}:${e}`)).join(" or "),r=`${l} and (${i})`,o=s?`${r} and (${s})`:r;return n?`(${o}) and (${n})`:o},ht=p()(u.EuiText).withConfig({displayName:"TruncatedEuiText",componentId:"sc-1ioa7tn-0"})(["overflow:hidden;max-height:3rem;text-overflow:ellipsis;"]),yt=({action:e})=>{var t;const a=Object(c.hc)(),n=e=>bt({agentId:e,datasets:["elastic_agent"],logLevels:["error"],userQuery:""}),i=(e,t)=>{const l=Object(Ye.stringify)({logPosition:Object(Ze.encode)({position:{time:Date.parse(t)},streamLive:!1}),logFilter:Object(Ze.encode)({expression:n(e),kind:"kuery"})});return a.http.basePath.prepend(`/app/logs/stream?${l}`)},s=[{field:"hostname",name:g.i18n.translate("xpack.fleet.agentList.viewErrors.hostnameColumnTitle",{defaultMessage:"Host Name"}),render:e=>l.a.createElement(u.EuiText,{size:"s","data-test-subj":"hostText"},e)},{field:"error",name:g.i18n.translate("xpack.fleet.agentList.viewErrors.errorColumnTitle",{defaultMessage:"Error Message"}),render:e=>l.a.createElement(u.EuiToolTip,{content:e},l.a.createElement(ht,{size:"s",color:"red","data-test-subj":"errorText"},e))},{field:"agentId",name:g.i18n.translate("xpack.fleet.agentList.viewErrors.actionColumnTitle",{defaultMessage:"Action"}),render:t=>{var n;const s=(null!==(n=e.latestErrors)&&void 0!==n?n:[]).find((e=>e.agentId===t));return l.a.createElement(it,{coreStart:a},l.a.createElement(u.EuiButton,{href:i(t,s.timestamp),color:"danger","data-test-subj":"viewLogsBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.reviewErrorLogs",defaultMessage:"Review error logs"})))}}];return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiAccordion,{id:e.actionId+"_errors",buttonContent:"Show errors"},l.a.createElement(u.EuiBasicTable,{items:null!==(t=e.latestErrors)&&void 0!==t?t:[],columns:s,tableLayout:"auto"})))},kt=p()(u.EuiFlyoutBody).withConfig({displayName:"FullHeightFlyoutBody",componentId:"sc-1uu095g-0"})([".euiFlyoutBody__overflowContent{height:100%;}"]),vt=p()(u.EuiFlyoutFooter).withConfig({displayName:"FlyoutFooterWPadding",componentId:"sc-1uu095g-1"})(["padding:16px 24px !important;"]),xt=({onClose:e,onAbortSuccess:t,refreshAgentActivity:a,setSearch:i,setSelectedStatus:s})=>{const{notifications:r}=Object(c.hc)(),{data:o}=Object(c.Fb)({perPage:F.p}),{currentActions:m,abortUpgrade:p,isFirstLoading:E}=function(e,t){const[a,l]=Object(n.useState)([]),[i,s]=Object(n.useState)(!0),{notifications:r,overlays:o}=Object(c.hc)(),u=Object(n.useCallback)((async()=>{try{const e=await Object(c.u)();if(s(!1),e.error)throw e.error;if(!e.data)throw new Error("No data");l(e.data.items)}catch(e){r.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.actionStatus.fetchRequestError",{defaultMessage:"An error happened while fetching action status"})})}}),[r.toasts]);i&&u(),Object(n.useEffect)((()=>(t&&u(),()=>{l([]),s(!0)})),[u,t]);const d=Object(n.useCallback)((async t=>{try{if(!await o.openConfirm(g.i18n.translate("xpack.fleet.currentUpgrade.confirmDescription",{defaultMessage:"This action will cancel upgrade of {nbAgents, plural, one {# agent} other {# agents}}",values:{nbAgents:t.nbAgentsActioned-t.nbAgentsAck}}),{title:g.i18n.translate("xpack.fleet.currentUpgrade.confirmTitle",{defaultMessage:"Cancel upgrade?"})}))return;await Object(c.V)(t.actionId),await Promise.all([u(),e()])}catch(e){r.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.currentUpgrade.abortRequestError",{defaultMessage:"An error happened while cancelling upgrade"})})}}),[u,r.toasts,o,e]);return{currentActions:a,refreshActions:u,abortUpgrade:d,isFirstLoading:i}}(t,a),f=e=>{var t;const a=null==o?void 0:o.items.find((t=>t.id===e));return null!==(t=null==a?void 0:a.name)&&void 0!==t?t:e},b=m.map((e=>{var t,a;return{...e,newPolicyId:f(null!==(t=e.newPolicyId)&&void 0!==t?t:""),policyId:f(null!==(a=e.policyId)&&void 0!==a?a:"")}})),h=b.filter((e=>"IN_PROGRESS"===e.status)),y=b.filter((e=>"IN_PROGRESS"!==e.status)),k=y.filter((e=>e.creationTime.startsWith(Qe()))),v=function(e){const t={};return e.filter((e=>!e.creationTime.startsWith(Qe()))).forEach((e=>{const a=e.creationTime.substring(0,10);t[a]||(t[a]=[]),t[a].push(e)})),t}(y),x=async t=>{try{var a;const{data:n}=await Object(c.db)({actionIds:[t.actionId]});if(null!=n&&null!==(a=n.items)&&void 0!==a&&a.length){const e=Ve({selectedAgentIds:n.items});i(e)}s(me),e()}catch(e){r.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.agentActivityFlyout.error",{defaultMessage:"Error viewing selected agents"})})}};return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlyout,{"data-test-subj":"agentActivityFlyout",onClose:e,size:"m",paddingSize:"none"},l.a.createElement(u.EuiFlyoutHeader,{"aria-labelledby":"FleetAgentActivityFlyoutTitle"},l.a.createElement(u.EuiPanel,{borderRadius:"none",hasShadow:!1,hasBorder:!0},l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"m"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiTitle,{size:"l"},l.a.createElement("h1",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.title",defaultMessage:"Agent activity"})))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.activityLogText",defaultMessage:"Activity log of Elastic Agent operations will appear here."}))))))),l.a.createElement(kt,null,E?l.a.createElement(u.EuiFlexGroup,{direction:"row",justifyContent:"center",alignItems:"center",className:"eui-fullHeight"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(re.i,null))):0===b.length?l.a.createElement(u.EuiFlexGroup,{direction:"column",justifyContent:"center",alignItems:"center",className:"eui-fullHeight"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiEmptyPrompt,{iconType:"clock",iconColor:"default",title:l.a.createElement("h2",null," ",l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.noActivityText",defaultMessage:"No activity to display"})),titleSize:"m",body:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.noActivityDescription",defaultMessage:"Activity feed will appear here as agents are reassigned, upgraded, or unenrolled."})}))):null,h.length>0?l.a.createElement(Ft,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.inProgressTitle",defaultMessage:"In progress"}),actions:h,abortUpgrade:p,onClickViewAgents:x}):null,k.length>0?l.a.createElement(Ft,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.todayTitle",defaultMessage:"Today"}),actions:k,abortUpgrade:p,onClickViewAgents:x}):null,Object.keys(v).map((e=>l.a.createElement(Ft,{key:e,title:l.a.createElement(d.FormattedDate,{value:e,year:"numeric",month:"short",day:"2-digit"}),actions:v[e],abortUpgrade:p,onClickViewAgents:x})))),l.a.createElement(vt,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"flexStart"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:e},l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.closeBtn",defaultMessage:"Close"}))))))))},Ft=({title:e,actions:t,abortUpgrade:a,onClickViewAgents:n})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiPanel,{color:"subdued",hasBorder:!0,borderRadius:"none"},l.a.createElement(u.EuiText,null,l.a.createElement("b",null,e))),t.map((e=>"UPGRADE"===e.type&&"IN_PROGRESS"===e.status?l.a.createElement(Ct,{action:e,abortUpgrade:a,key:e.actionId,onClickViewAgents:n}):l.a.createElement(jt,{action:e,key:e.actionId,onClickViewAgents:n})))),Mt={POLICY_REASSIGN:{inProgressText:"Reassigning",completedText:"assigned to a new policy",cancelledText:"assignment"},UPGRADE:{inProgressText:"Upgrading",completedText:"upgraded",cancelledText:"upgrade"},UNENROLL:{inProgressText:"Unenrolling",completedText:"unenrolled",cancelledText:"unenrollment"},FORCE_UNENROLL:{inProgressText:"Force unenrolling",completedText:"force unenrolled",cancelledText:"force unenrollment"},UPDATE_TAGS:{inProgressText:"Updating tags of",completedText:"updated tags",cancelledText:"update tags"},CANCEL:{inProgressText:"Cancelling",completedText:"cancelled",cancelledText:""},REQUEST_DIAGNOSTICS:{inProgressText:"Requesting diagnostics for",completedText:"requested diagnostics",cancelledText:"request diagnostics"},SETTINGS:{inProgressText:"Updating settings of",completedText:"updated settings",cancelledText:"update settings"},POLICY_CHANGE:{inProgressText:"Applying policy change on",completedText:"applied policy change",cancelledText:"policy change"},INPUT_ACTION:{inProgressText:"Input action in progress of",completedText:"input action completed",cancelledText:"input action"},ACTION:{inProgressText:"Actioning",completedText:"actioned",cancelledText:"action"}},It=e=>{var t;return null!==(t=Mt[null!=e?e:"ACTION"])&&void 0!==t?t:Mt.ACTION},St="#0077CC",Ot=e=>e?l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedDate,{value:e,year:"numeric",month:"short",day:"2-digit"})," ",l.a.createElement(d.FormattedTime,{value:e})):null,Tt=e=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivity.inProgressTitle",defaultMessage:"{inProgressText} {nbAgents} {agents} {reassignText}{upgradeText}{failuresText}",values:{nbAgents:e.nbAgentsAck>=e.nbAgentsActioned?e.nbAgentsAck:0===e.nbAgentsAck?e.nbAgentsActioned:e.nbAgentsActioned-e.nbAgentsAck+" of "+e.nbAgentsActioned,agents:1===e.nbAgentsActioned?"agent":"agents",inProgressText:It(e.type).inProgressText,reassignText:"POLICY_REASSIGN"===e.type&&e.newPolicyId?`to ${e.newPolicyId}`:"",upgradeText:"UPGRADE"===e.type?`to version ${e.version}`:"",failuresText:e.nbAgentsFailed>0?`, has ${e.nbAgentsFailed} failure(s)`:""}}),wt=e=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.startedDescription",defaultMessage:"Started on {date}.",values:{date:Ot(e)}}),jt=({action:e,onClickViewAgents:t})=>{const a="POLICY_CHANGE"===e.type&&0===e.nbAgentsActioned?l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivity.policyChangeCompletedTitle",defaultMessage:"Policy changed"})):l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivity.completedTitle",defaultMessage:"{nbAgents} {agents} {completedText}{offlineText}",values:{nbAgents:e.nbAgentsAck===e.nbAgentsActioned?e.nbAgentsAck:e.nbAgentsAck+" of "+e.nbAgentsActioned,agents:1===e.nbAgentsActioned?"agent":"agents",completedText:It(e.type).completedText,offlineText:"ROLLOUT_PASSED"===e.status&&e.nbAgentsActioned-e.nbAgentsAck>0?`, ${e.nbAgentsActioned-e.nbAgentsAck} agent(s) offline during the rollout period`:""}})),n=l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.completedDescription",defaultMessage:"Completed {date}",values:{date:Ot(e.completionTime)}}),i=l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.failureDescription",defaultMessage:"A problem occurred during this operation."})," ",wt(e.creationTime))),s={IN_PROGRESS:{icon:l.a.createElement(u.EuiLoadingSpinner,{size:"m"}),title:l.a.createElement(u.EuiText,null,Tt(e)),titleColor:St,description:l.a.createElement(u.EuiText,{color:"subdued"},wt(e.creationTime))},ROLLOUT_PASSED:{icon:e.nbAgentsFailed>0?l.a.createElement(u.EuiIcon,{size:"m",type:"warning",color:"red"}):l.a.createElement(u.EuiIcon,{size:"m",type:"checkInCircleFilled",color:"green"}),title:a,titleColor:e.nbAgentsFailed>0?"red":"green",description:e.nbAgentsFailed>0?i:l.a.createElement(u.EuiText,{color:"subdued"},n)},COMPLETE:{icon:l.a.createElement(u.EuiIcon,{size:"m",type:"checkInCircleFilled",color:"green"}),title:a,titleColor:"green",description:"POLICY_REASSIGN"===e.type&&e.newPolicyId?l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.reassignCompletedDescription",defaultMessage:"Assigned to {policy}.",values:{policy:e.newPolicyId}})," ",n)):"POLICY_CHANGE"===e.type?l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement("p",null,l.a.createElement("b",null,e.policyId)," ",l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.policyChangedDescription",defaultMessage:"changed to revision {rev} at {date}.",values:{rev:e.revision,date:Ot(e.creationTime)}}))):l.a.createElement(u.EuiText,{color:"subdued"},n)},FAILED:{icon:l.a.createElement(u.EuiIcon,{size:"m",type:"warning",color:"red"}),title:a,titleColor:"red",description:i},CANCELLED:{icon:l.a.createElement(u.EuiIcon,{size:"m",type:"warning",color:"grey"}),titleColor:"grey",title:l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.cancelledTitle",defaultMessage:"Agent {cancelledText} cancelled",values:{cancelledText:It(e.type).cancelledText}})),description:l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.cancelledDescription",defaultMessage:"Cancelled on {date}",values:{date:Ot(e.cancellationTime)}}))},EXPIRED:{icon:l.a.createElement(u.EuiIcon,{size:"m",type:"warning",color:"grey"}),titleColor:"grey",title:l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.expiredTitle",defaultMessage:"Agent {expiredText} expired",values:{expiredText:It(e.type).cancelledText}})),description:l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.expiredDescription",defaultMessage:"Expired on {date}",values:{date:Ot(e.expiration)}}))}};return l.a.createElement(u.EuiPanel,{hasBorder:!0,borderRadius:"none"},l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"m"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFlexGroup,{direction:"row",gutterSize:"m",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},s[e.status].icon),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{color:s[e.status].titleColor,"data-test-subj":"statusTitle"},s[e.status].title)))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{color:"subdued","data-test-subj":"statusDescription"},s[e.status].description)),l.a.createElement(u.EuiFlexItem,{grow:!1},"FAILED"===e.status&&e.latestErrors&&e.latestErrors.length>0?l.a.createElement(yt,{action:e}):null)),l.a.createElement(u.EuiSpacer,{size:"xs"}),l.a.createElement(Pt,{action:e,onClickViewAgents:t}))},Ct=({action:e,abortUpgrade:t,onClickViewAgents:a})=>{const{docLinks:i}=Object(c.hc)(),[s,r]=Object(n.useState)(!1),o=Object(n.useCallback)((async()=>{try{r(!0),await t(e)}finally{r(!1)}}),[e,t]),g=Object(n.useMemo)((()=>{if(!e.startTime)return!1;const t=Date.now();return new Date(e.startTime).getTime()>t}),[e]),m=Object(n.useMemo)((()=>g||e.hasRolloutPeriod),[e,g]);return l.a.createElement(u.EuiPanel,{hasBorder:!0,borderRadius:"none"},l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"m"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFlexGroup,{direction:"row",gutterSize:"m",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},g?l.a.createElement(u.EuiIcon,{type:"clock"}):l.a.createElement(u.EuiLoadingSpinner,{size:"m"})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{color:St,"data-test-subj":"upgradeInProgressTitle"},g&&e.startTime?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.scheduleTitle",defaultMessage:"{nbAgents} agents scheduled to upgrade to version {version}",values:{nbAgents:e.nbAgentsActioned-e.nbAgentsAck,version:e.version}}):Tt(e))))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFlexGroup,{direction:"column",alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{color:"subdued","data-test-subj":"upgradeInProgressDescription"},l.a.createElement("p",null,g&&e.startTime?l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.scheduledDescription",defaultMessage:"Scheduled for "}),l.a.createElement("strong",null,Ot(e.startTime)),". "):l.a.createElement(l.a.Fragment,null,wt(e.creationTime)," "),l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.upgradeDescription",defaultMessage:"{guideLink} about agent upgrades.",values:{guideLink:l.a.createElement(u.EuiLink,{href:i.links.fleet.upgradeElasticAgent,target:"_blank"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.guideLink",defaultMessage:"Learn more"}))}})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(Pt,{action:e,onClickViewAgents:a})),l.a.createElement(u.EuiFlexItem,{grow:!1},m?l.a.createElement(u.EuiButton,{size:"s",onClick:o,isLoading:s,"data-test-subj":"abortBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.abortUpgradeButtom",defaultMessage:"Cancel"})):null)))))},Pt=({action:e,onClickViewAgents:t})=>"UPDATE_TAGS"!==e.type?l.a.createElement(u.EuiButtonEmpty,{size:"m",onClick:()=>t(e),flush:"left","data-test-subj":"agentActivityFlyout.viewAgentsButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentActivityFlyout.viewAgentsButton",defaultMessage:"View Agents"})):null,At=()=>{var e,t;const a=Object(c.wb)();return l.a.createElement(u.EuiCallOut,{iconType:"warning",color:"warning",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentSoftLimitCallout.calloutTitle",defaultMessage:"Max number of online agents reached"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentSoftLimitCallout.calloutDescription",defaultMessage:"Fleet supports a maximum of {nbAgents} active agents. You need to unenroll some agents to ensure that all active agents are able to connect and new agents can be enrolled.",values:{nbAgents:l.a.createElement(d.FormattedNumber,{value:null!==(e=null===(t=a.internal)||void 0===t?void 0:t.activeAgentsSoftLimit)&&void 0!==e?e:25e3})}}))},Lt=({agent:e,agentPolicy:t,onReassignClick:a,onUnenrollClick:i,onGetUninstallCommandClick:s,onUpgradeClick:r,onAddRemoveTagsClick:o,onRequestDiagnosticsClick:g})=>{const{getHref:m}=Object(c.Zb)(),p=Object(c.tb)().fleet.all,E="unenrolling"===e.status,f=Object(c.Xb)(),[b,h]=Object(n.useState)(!1),{diagnosticFileUploadEnabled:y,agentTamperProtectionEnabled:k}=j.b.get(),v=[l.a.createElement(u.EuiContextMenuItem,{icon:"inspect",href:m("agent_details",{agentId:e.id}),key:"viewAgent"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.viewActionText",defaultMessage:"View agent"}))];return!1===(null==t?void 0:t.is_managed)&&(v.push(l.a.createElement(u.EuiContextMenuItem,{icon:"tag",onClick:e=>{o(e.target.closest("button"))},disabled:!e.active,key:"addRemoveTags"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.addRemoveTagsActionText",defaultMessage:"Add / remove tags"})),l.a.createElement(u.EuiContextMenuItem,{icon:"pencil",onClick:()=>{a()},disabled:!e.active,key:"reassignPolicy"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.reassignActionText",defaultMessage:"Assign to new policy"})),l.a.createElement(u.EuiContextMenuItem,{key:"agentUnenrollBtn",disabled:!p||!e.active,icon:"trash",onClick:()=>{i()}},E?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.forceUnenrollOneButton",defaultMessage:"Force unenroll"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.unenrollOneButton",defaultMessage:"Unenroll agent"})),l.a.createElement(u.EuiContextMenuItem,{key:"agentUpgradeBtn",icon:"refresh",disabled:!Object(j.m)(e,f),onClick:()=>{r()}},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.upgradeOneButton",defaultMessage:"Upgrade agent"}))),k&&e.policy_id&&v.push(l.a.createElement(u.EuiContextMenuItem,{icon:"minusInCircle",onClick:()=>{s(),h(!1)},disabled:!e.active,key:"getUninstallCommand","data-test-subj":"uninstallAgentMenuItem"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.getUninstallCommand",defaultMessage:"Uninstall agent"})))),y&&v.push(l.a.createElement(u.EuiContextMenuItem,{key:"requestAgentDiagnosticsBtn",icon:"download","data-test-subj":"requestAgentDiagnosticsBtn",disabled:!p||!Object(se.G)(e),onClick:()=>{g()}},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.diagnosticsOneButton",defaultMessage:"Request diagnostics .zip"}))),l.a.createElement(x.h,{isOpen:b,onChange:e=>h(e),items:v})},_t=p.a.div.withConfig({displayName:"Wrapped",componentId:"sc-rnfjm9-0"})(["display:flex;.wrappedText{white-space:pre-wrap;}"]),Dt=({tags:e,color:t,size:a})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(_t,null,l.a.createElement(u.EuiToolTip,{anchorClassName:"wrappedText",content:l.a.createElement("span",{"data-test-subj":"agentTagsTooltip"},e.join(", "))},l.a.createElement(u.EuiText,{size:a,color:t},l.a.createElement("span",{"data-test-subj":"agentTags"},Object(q.take)(e,3).map(Se).join(", "),e.length>3?` + ${e.length-3} more`:"")))));function Bt(e,t){return void 0!==(null==e?void 0:e.cpu_avg)?l.a.createElement(u.EuiToolTip,{content:`${(100*e.cpu_avg).toFixed(4)} %`},l.a.createElement(l.a.Fragment,null,(100*e.cpu_avg).toFixed(2)," %")):l.a.createElement(re.j,{agentPolicy:t})}function Rt(e,t){return null!=e&&e.memory_size_byte_avg?function(e,t=0){if(0===e)return"0 Bytes";const a=t<0?0:t,n=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,n)).toFixed(a))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][n]}(e.memory_size_byte_avg):l.a.createElement(re.j,{agentPolicy:t})}const zt=({hasFleetAllPrivileges:e,setEnrollmentFlyoutState:t})=>l.a.createElement(u.EuiEmptyPrompt,{title:l.a.createElement("h2",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.noAgentsPrompt",defaultMessage:"No agents enrolled"})),actions:e?l.a.createElement(u.EuiButton,{fill:!0,iconType:"plusInCircle",onClick:()=>t({isOpen:!0})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.addButton",defaultMessage:"Add agent"})):null});function Nt(e){return"string"!=typeof e?"-":e}const Ht=e=>{const{agents:t,isLoading:a,agentPoliciesIndexedById:n,renderActions:i,sortField:s,sortOrder:r,tableRef:o,onTableChange:m,onSelectionChange:p,totalAgents:E=0,showUpgradeable:f,pagination:b,pageSizeOptions:h,isUsingFilter:y,setEnrollmentFlyoutState:k,clearFilters:v,isCurrentRequestIncremented:F}=e,M=Object(c.tb)().fleet.all,{displayAgentMetrics:I}=j.b.get(),{getHref:S}=Object(c.Zb)(),O=Object(c.Xb)(),T=e=>{if(!e.active)return!1;if(!e.policy_id)return!0;const t=n[e.policy_id];return!(!0===(null==t?void 0:t.is_managed))},w=a&&F?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.loadingAgentsMessage",defaultMessage:"Loading agents…"}):y?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.noFilteredAgentsPrompt",defaultMessage:"No agents found. {clearFiltersLink}",values:{clearFiltersLink:l.a.createElement(u.EuiLink,{onClick:()=>v()},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.clearFiltersLinkText",defaultMessage:"Clear filters"}))}}):l.a.createElement(zt,{hasFleetAllPrivileges:M,setEnrollmentFlyoutState:k}),C={sort:{field:s,direction:r}},P=[{field:"active",sortable:!1,width:"85px",name:g.i18n.translate("xpack.fleet.agentList.statusColumnTitle",{defaultMessage:"Status"}),render:(e,t)=>l.a.createElement(re.a,{agent:t})},{field:"local_metadata.host.hostname",sortable:!0,name:g.i18n.translate("xpack.fleet.agentList.hostColumnTitle",{defaultMessage:"Host"}),width:"185px",render:(e,t)=>{var a;return l.a.createElement(u.EuiFlexGroup,{gutterSize:"none",direction:"column"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiLink,{href:S("agent_details",{agentId:t.id})},Nt(e))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(Dt,{tags:null!==(a=t.tags)&&void 0!==a?a:[],color:"subdued",size:"xs"})))}},{field:"policy_id",sortable:!0,truncateText:!0,name:g.i18n.translate("xpack.fleet.agentList.policyColumnTitle",{defaultMessage:"Agent policy"}),width:"260px",render:(e,t)=>{const a=n[e],i=t.policy_revision&&(null==a?void 0:a.revision)>t.policy_revision;return l.a.createElement(u.EuiFlexGroup,{gutterSize:"m",style:{minWidth:0},alignItems:"center"},a&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(x.f,{direction:"column",policy:a,agent:t})),i&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiText,{color:"subdued",size:"xs",className:"eui-textNoWrap"},l.a.createElement(u.EuiIcon,{size:"m",type:"warning",color:"warning"})," ",l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.outOfDateLabel",defaultMessage:"Outdated policy"}))))}},...I?[{field:"metrics",sortable:!1,name:l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.cpuTooltip",defaultMessage:"Average CPU usage in the last 5 minutes"})},l.a.createElement("span",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.cpuTitle",defaultMessage:"CPU"})," ",l.a.createElement(u.EuiIcon,{type:"iInCircle"}))),width:"75px",render:(e,t)=>Bt(t.metrics,t.policy_id?n[t.policy_id]:void 0)},{field:"metrics",sortable:!1,name:l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.memoryTooltip",defaultMessage:"Average memory usage in the last 5 minutes"})},l.a.createElement("span",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.memoryTitle",defaultMessage:"Memory"})," ",l.a.createElement(u.EuiIcon,{type:"iInCircle"}))),width:"90px",render:(e,t)=>Rt(t.metrics,t.policy_id?n[t.policy_id]:void 0)}]:[],{field:"last_checkin",sortable:!0,name:g.i18n.translate("xpack.fleet.agentList.lastCheckinTitle",{defaultMessage:"Last activity"}),width:"180px",render:(e,t)=>e?l.a.createElement(d.FormattedRelative,{value:e}):null},{field:"local_metadata.elastic.agent.version",sortable:!0,width:"70px",name:g.i18n.translate("xpack.fleet.agentList.versionTitle",{defaultMessage:"Version"}),render:(e,t)=>l.a.createElement(u.EuiFlexGroup,{gutterSize:"none",style:{minWidth:0},direction:"column"},l.a.createElement(u.EuiFlexItem,{grow:!1,className:"eui-textNoWrap"},Nt(e)),T(t)&&Object(j.m)(t,O)?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiText,{color:"subdued",size:"xs",className:"eui-textNoWrap"},l.a.createElement(u.EuiIcon,{size:"m",type:"warning",color:"warning"})," ",l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.agentUpgradeLabel",defaultMessage:"Upgrade available"}))):null)},{name:g.i18n.translate("xpack.fleet.agentList.actionsColumnTitle",{defaultMessage:"Actions"}),actions:[{render:i}],width:"100px"}];return l.a.createElement(u.EuiBasicTable,{ref:o,className:"fleet__agentList__table","data-test-subj":"fleetAgentListTable",loading:a,hasActions:!0,noItemsMessage:w,items:E?f?t.filter((e=>T(e)&&Object(j.m)(e,O))):t:[],itemId:"id",columns:P,pagination:{pageIndex:b.currentPage-1,pageSize:b.pageSize,totalItemCount:E,pageSizeOptions:h},isSelectable:!0,selection:{onSelectionChange:p,selectable:T,selectableMessage:(e,t)=>e?"":t.active?t.policy_id&&n[t.policy_id].is_managed?"This action is not available for agents enrolled in an externally managed agent policy":"":"This agent is not active"},onChange:m,sorting:C})},Ut=()=>{var e;const{displayAgentMetrics:t}=j.b.get(),{notifications:a,cloud:i}=Object(c.hc)();Object(c.ub)("agent_list");const s=Object(c.lc)().urlParams.kuery||"",[r,o]=Object(n.useState)(!1),[d,m]=Object(n.useState)(s),[p,E]=Object(n.useState)(s),[f,h]=Object(n.useState)("manual"),[y,k]=Object(n.useState)([]),v=Object(n.useRef)(null),{pagination:M,pageSizeOptions:I,setPagination:S}=Object(c.bc)(),[O,T]=Object(n.useState)("enrolled_at"),[w,C]=Object(n.useState)("desc"),P="local_metadata.elastic.agent.version",A="local_metadata.host.hostname",L=Object(n.useCallback)((e=>{E(e),S({...M,currentPage:1})}),[E,M,S]),[_,D]=Object(n.useState)([]),[B,R]=Object(n.useState)(["healthy","unhealthy","updating","offline"]),[z,N]=Object(n.useState)([]),H=!!(p.trim()||_.length||B.length||z.length||r),U=Object(n.useCallback)((()=>{m(""),E(""),D([]),R([]),N([]),o(!1)}),[E,m,D,R,o]),[G,W]=Object(n.useState)({isOpen:!1}),[$,K]=Object(n.useState)(!1),V=Object(c.Eb)(),[Q,Y]=Object(n.useState)(void 0),[Z,J]=Object(n.useState)(void 0),[X,ee]=Object(n.useState)(void 0),[te,ae]=Object(n.useState)(void 0),[ne,le]=Object(n.useState)(void 0),[ie,ue]=Object(n.useState)(),[de,ge]=Object(n.useState)(!1),[me,pe]=Object(n.useState)(void 0),Ee=Object(n.useMemo)((()=>B.some((e=>"inactive"===e||"unenrolled"===e))),[B]),fe=Object(n.useMemo)((()=>Ve({search:p,selectedAgentPolicies:_,selectedTags:z,selectedStatus:B})),[p,_,B,z]),[be,he]=Object(n.useState)([]),[ye,ke]=Object(n.useState)(),[ve,xe]=Object(n.useState)(),[Me,Ie]=Object(n.useState)(!1),[Se,Oe]=Object(n.useState)(0),[Te,we]=Object(n.useState)(0),[je,Pe]=Object(n.useState)(0),[Ae,_e]=Object(n.useState)([]),[De,Be]=Object(n.useState)(0),[Re,ze]=Object(n.useState)({isOpen:!1}),Ne=Object(n.useRef)(!1),He=Object(n.useRef)(0),Ue=Object(n.useCallback)((({refreshTags:e=!1}={})=>{!async function(){if(Ne.current)return;He.current++;const n=He.current;Ne.current=!0;try{var l,i;Ie(!0);const[a,d,g,m]=await Promise.all([Object(c.z)({page:M.currentPage,perPage:M.pageSize,kuery:fe&&""!==fe?fe:void 0,sortField:(u=O,[P,A].includes(u)?`${u}.keyword`:u),sortOrder:w,showInactive:Ee,showUpgradeable:r,getStatusSummary:!0,withMetrics:t}),Object(c.w)({kuery:j.a.buildKueryForInactiveAgents()}),Object(c.v)({kuery:`${F.c}.is_managed:true`,perPage:F.p,full:!1}),Object(c.x)({kuery:fe&&""!==fe?fe:void 0,showInactive:Ee})]);if(Ne.current=!1,He.current!==n)return;if(a.error)throw a.error;if(!a.data)throw new Error("Invalid GET /agents response");if(!d.data)throw new Error("Invalid GET /agents_status response");if(g.error)throw new Error(g.error.message);if(m.error)throw m.error;if(!m.data)throw new Error("Invalid GET /agent/tags response");const p=a.data.statusSummary;if(!p)throw new Error("Invalid GET /agents response - no status summary");ke(Object(se.g)(p));const E=m.data.items;ve&&!e&&Object(q.isEqual)(E,ve)||xe(E),he(a.data.items),Oe(a.data.total),Pe(d.data.results.inactive||0),we(Ee&&d.data.results.inactive||0);const f=null!==(l=null===(i=g.data)||void 0===i?void 0:i.items)&&void 0!==l?l:[];if(0===f.length)_e([]),Be(0);else{var s,o;const e=f.map((e=>`policy_id:"${e.id}"`)).join(" or "),t=await Object(c.z)({kuery:`NOT (status:unenrolled) and ${e}`,perPage:F.p,showInactive:!0});if(t.error)throw new Error(t.error.message);const n=null!==(s=null===(o=t.data)||void 0===o?void 0:o.items)&&void 0!==s?s:[],l=null==n?void 0:n.map((e=>e.id));_e(l),Be(a.data.items.map((e=>e.id)).filter((e=>l.includes(e))).length)}}catch(e){a.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.agentList.errorFetchingDataTitle",{defaultMessage:"Error fetching agents"})})}var u;Ie(!1)}()}),[M.currentPage,M.pageSize,fe,O,w,Ee,r,t,ve,a.toasts]);Object(n.useEffect)((()=>{Ue();const e=setInterval((()=>{Ue()}),3e4);return()=>clearInterval(e)}),[Ue]);const qe=Object(c.Fb)({page:1,perPage:F.p,full:!0}),Ge=Object(n.useMemo)((()=>qe.data?qe.data.items:[]),[qe]),$e=Object(n.useMemo)((()=>Ge.reduce(((e,t)=>(e[t.id]=t,e)),{})),[Ge]),Ke=Object(n.useCallback)((e=>{if(!e.active)return!1;if(!e.policy_id)return!0;const t=$e[e.policy_id];return!(!0===(null==t?void 0:t.is_managed))}),[$e]),Qe=Object(n.useMemo)((()=>{if(!Z||!Z.policy_id)return!1;const e=$e[Z.policy_id];return!!e&&Object(j.t)(e)}),[Z,$e]),{isUnhealthy:Ye}=Object(oe.a)(),{isFleetServerStandalone:Ze}=Object(c.Cb)(),Je=Ye&&!Ze,{shouldDisplayAgentSoftLimit:Xe}=function(){var e;const t=null===(e=Object(c.wb)().internal)||void 0===e?void 0:e.activeAgentsSoftLimit,{data:a}=Object(b.useQuery)(["fetch-total-online-agents"],Ce,{enabled:void 0!==t});return{shouldDisplayAgentSoftLimit:!(!t||!a)&&a>t}}(),et=Object(n.useCallback)((()=>{V.openFleetServerFlyout()}),[V]),tt=Object(n.useCallback)((()=>{K(!0)}),[K]),at=({refreshTags:e=!1}={})=>{Ue({refreshTags:e}),ze({isOpen:!0})},nt=1===(null==He?void 0:He.current);return l.a.createElement(l.a.Fragment,null,$?l.a.createElement(u.EuiPortal,null,l.a.createElement(xt,{onAbortSuccess:Ue,onClose:()=>K(!1),refreshAgentActivity:Me,setSearch:E,setSelectedStatus:R})):null,G.isOpen?l.a.createElement(u.EuiPortal,null,l.a.createElement(x.c,{agentPolicy:Ge.find((e=>e.id===G.selectedPolicyId)),onClose:()=>{W({isOpen:!1}),Ue(),qe.resendRequest()}})):null,Q&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.c,{agents:[Q],onClose:()=>{Y(void 0),at()}})),Z&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.d,{agents:[Z],agentCount:1,onClose:()=>{J(void 0),at({refreshTags:!0})},useForceUnenroll:"unenrolling"===Z.status,hasFleetServer:Qe})),(null==X?void 0:X.policy_id)&&l.a.createElement(u.EuiPortal,null,l.a.createElement(x.y,{target:"agent",policyId:X.policy_id,onClose:()=>{ee(void 0),at({refreshTags:!0})}})),te&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.e,{agents:[te],agentCount:1,onClose:()=>{ae(void 0),at()}})),me&&l.a.createElement(u.EuiPortal,null,l.a.createElement(ce,{agents:[me],agentCount:1,onClose:()=>{pe(void 0)}})),de&&l.a.createElement(Le,{agentId:null==ne?void 0:ne.id,allTags:null!=ve?ve:[],selectedTags:null!==(e=null==ne?void 0:ne.tags)&&void 0!==e?e:[],button:ie,onTagsUpdated:()=>{at()},onClosePopover:()=>{ge(!1)}}),Je&&l.a.createElement(l.a.Fragment,null,null!=i&&i.deploymentUrl?l.a.createElement(re.g,{deploymentUrl:i.deploymentUrl}):l.a.createElement(re.h,{onClickAddFleetServer:et}),l.a.createElement(u.EuiSpacer,{size:"l"})),Xe&&l.a.createElement(l.a.Fragment,null,l.a.createElement(At,null),l.a.createElement(u.EuiSpacer,{size:"l"})),l.a.createElement(We,{agentPolicies:Ge,draftKuery:d,onDraftKueryChange:m,onSubmitSearch:L,selectedAgentPolicies:_,onSelectedAgentPoliciesChange:D,selectedStatus:B,onSelectedStatusChange:R,showUpgradeable:r,onShowUpgradeableChange:o,tags:null!=ve?ve:[],selectedTags:z,onSelectedTagsChange:N,shownAgents:Se,inactiveShownAgents:Te,totalInactiveAgents:je,totalManagedAgentIds:Ae,selectionMode:f,currentQuery:fe,selectedAgents:y,refreshAgents:at,onClickAddAgent:()=>W({isOpen:!0}),onClickAddFleetServer:et,visibleAgents:be,onClickAgentActivity:tt,showAgentActivityTour:Re}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Fe,{showInactive:Ee,totalAgents:Se,agentStatus:ye,selectableAgents:(null==be?void 0:be.filter(Ke).length)||0,managedAgentsOnCurrentPage:De,selectionMode:f,setSelectionMode:h,selectedAgents:y,setSelectedAgents:e=>{null!=v&&v.current&&(v.current.setSelection(e),h("manual"))},clearFilters:U,isUsingFilter:H}),l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(Ht,{agents:be,sortField:O,pageSizeOptions:I,sortOrder:w,isLoading:Me,agentPoliciesIndexedById:$e,renderActions:e=>{const t="string"==typeof e.policy_id?$e[e.policy_id]:void 0;return(null==ne?void 0:ne.id)!==e.id||Object(q.isEqual)(e.tags,ne.tags)||le(e),l.a.createElement(Lt,{agent:e,agentPolicy:t,onReassignClick:()=>Y(e),onUnenrollClick:()=>J(e),onUpgradeClick:()=>ae(e),onAddRemoveTagsClick:t=>{ue(t),le(e),ge(!de)},onGetUninstallCommandClick:()=>ee(e),onRequestDiagnosticsClick:()=>pe(e)})},onSelectionChange:e=>{k(e),"query"===f&&e.length0&&0===Object(q.differenceBy)(y,be,"id").length?h("manual"):null!=v&&v.current&&v.current.setSelection(be))},tableRef:v,showUpgradeable:r,onTableChange:({page:e,sort:t})=>{const a={...M,currentPage:e.index+1,pageSize:e.size};S(a),T(t.field),C(t.direction)},pagination:M,totalAgents:Math.min(Se,F.p),isUsingFilter:H,setEnrollmentFlyoutState:W,clearFilters:U,isCurrentRequestIncremented:nt}))};var qt=a(163);const Gt=l.a.createContext({refresh:()=>{}});var Wt=a(59),$t=a(378),Kt=a.n($t),Vt=a(381),Qt=a.n(Vt),Yt=a(89),Zt=a(61),Jt=a.n(Zt),Xt=a(23),ea=a.n(Xt),ta=a(97);const aa=Object(n.memo)((({selectedDatasets:e,onToggleDataset:t})=>{const{unifiedSearch:a,data:i}=Object(c.hc)(),[s,r]=Object(n.useState)(!1),[o,d]=Object(n.useState)(!1),[m,p]=Object(n.useState)([rt]),E=Object(n.useCallback)((()=>r((e=>!e))),[r]),f=Object(n.useCallback)((()=>r(!1)),[r]);return Object(n.useEffect)((()=>{(async()=>{d(!0);try{const e=(await i.dataViews.getFieldsForWildcard({pattern:st})).reduce(((e,t)=>(e[t.name]=t,e)),{}),t=await i.dataViews.create({title:st,fields:e}),n=await a.autocomplete.getValueSuggestions({indexPattern:t,field:ct,query:""});n.length>0&&p(n.sort())}catch(e){p([rt])}d(!1)})()}),[i.dataViews,a.autocomplete]),l.a.createElement(u.EuiPopover,{button:l.a.createElement(u.EuiFilterButton,{"data-test-subj":"agentList.datasetFilterBtn",iconType:"arrowDown",onClick:E,isSelected:s,isLoading:o,numFilters:m.length,hasActiveFilters:e.length>0,numActiveFilters:e.length},g.i18n.translate("xpack.fleet.agentLogs.datasetSelectText",{defaultMessage:"Dataset"})),isOpen:s,closePopover:f,panelPaddingSize:"none"},m.map((a=>l.a.createElement(u.EuiFilterSelectItem,{checked:e.includes(a)?"on":void 0,key:a,onClick:()=>t(a)},a))))})),na=Object.values(Et),la=Object(n.memo)((({selectedLevels:e,onToggleLevel:t})=>{const[a,i]=Object(n.useState)(!1),s=Object(n.useCallback)((()=>i((e=>!e))),[]),r=Object(n.useCallback)((()=>i(!1)),[]),o=na.map((a=>l.a.createElement(u.EuiFilterSelectItem,{checked:e.includes(a)?"on":void 0,key:a,onClick:()=>t(a)},a)));return l.a.createElement(u.EuiPopover,{button:l.a.createElement(u.EuiFilterButton,{"data-test-subj":"agentList.logLevelFilterBtn",iconType:"arrowDown",onClick:s,isSelected:a,numFilters:na.length,hasActiveFilters:e.length>0,numActiveFilters:e.length},g.i18n.translate("xpack.fleet.agentLogs.logLevelSelectText",{defaultMessage:"Log level"})),isOpen:a,closePopover:r,panelPaddingSize:"none"},o)}));var ia=a(90);const sa=[ot,ct.name,ut],ra=Object(n.memo)((({query:e,isQueryValid:t,onUpdateQuery:a})=>{const{data:i,notifications:s,http:r,docLinks:o,uiSettings:u,unifiedSearch:d,storage:m,dataViews:p}=Object(c.hc)(),[E,f]=Object(n.useState)();return Object(n.useEffect)((()=>{(async()=>{try{const e=(await i.dataViews.getFieldsForWildcard({pattern:st})||[]).filter((e=>!sa.includes(e.name)));f(e)}catch(e){f(void 0)}})()}),[i.dataViews]),l.a.createElement(ia.QueryStringInput,{iconType:"search",autoSubmit:!0,disableLanguageSwitcher:!0,indexPatterns:E?[{title:st,fields:E}]:[],query:{query:e,language:"kuery"},isInvalid:!t,disableAutoFocus:!0,placeholder:g.i18n.translate("xpack.fleet.agentLogs.searchPlaceholderText",{defaultMessage:"Search logs…"}),onChange:e=>{a(e.query)},onSubmit:e=>{a(e.query,!0)},appName:g.i18n.translate("xpack.fleet.appTitle",{defaultMessage:"Fleet"}),deps:{unifiedSearch:d,notifications:s,http:r,docLinks:o,uiSettings:u,data:i,dataViews:p,storage:m}})})),oa=Object.values(Et),ca=Object(n.memo)((({agent:e})=>{var t,a,i,s;const{notifications:r}=Object(c.hc)(),[o,m]=Object(n.useState)(!1),[p,E]=Object(n.useState)(null!==(t=null===(a=e.local_metadata)||void 0===a||null===(i=a.elastic)||void 0===i||null===(s=i.agent)||void 0===s?void 0:s.log_level)&&void 0!==t?t:ft),[f,b]=Object(n.useState)(p),h=Object(n.useCallback)((()=>{m(!0),async function(){try{const t=await Object(c.M)(e.id,{action:{type:"SETTINGS",data:{log_level:f}}});if(t.error)throw t.error;E(f),r.toasts.addSuccess(g.i18n.translate("xpack.fleet.agentLogs.selectLogLevel.successText",{defaultMessage:"Changed agent logging level to '{logLevel}'.",values:{logLevel:f}}))}catch(e){r.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.agentLogs.selectLogLevel.errorTitleText",{defaultMessage:"Error updating agent logging level"})})}m(!1)}()}),[r,f,e.id]);return l.a.createElement(u.EuiFlexGroup,{gutterSize:"m",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFormLabel,{htmlFor:"selectAgentLogLevel"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.selectLogLevelLabelText",defaultMessage:"Agent logging level"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiSelect,{disabled:o,compressed:!0,id:"selectAgentLogLevel",value:f,onChange:e=>{b(e.target.value)},options:oa.map((e=>({text:e,value:e})))})),p!==f&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{flush:"left",size:"xs",isLoading:o,disabled:p===f,iconType:"refresh",onClick:h},o?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.updateButtonLoadingText",defaultMessage:"Applying changes..."}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.updateButtonText",defaultMessage:"Apply changes"}))))})),ua=p()(u.EuiFlexGroup).withConfig({displayName:"WrapperFlexGroup",componentId:"sc-fcgfrk-0"})(["height:100%;"]),da=p()(u.EuiFlexItem).withConfig({displayName:"DatePickerFlexItem",componentId:"sc-fcgfrk-1"})(["max-width:312px;"]),ga={type:"log-view-reference",logViewId:"default"},ma=Object(Wt.createStateContainerReactHelpers)(),pa=({agentPolicy:e})=>{const{getHref:t}=Object(c.Zb)();return l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiCallOut,{size:"m",color:"primary",iconType:"iInCircle",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.logDisabledCallOutTitle",defaultMessage:"Log collection is disabled"})},e.is_managed?null:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.logDisabledCallOutDescription",defaultMessage:"Update the agent's policy {settingsLink} to enable logs collection.",values:{settingsLink:l.a.createElement(u.EuiLink,{href:t("policy_details",{policyId:e.id,tabId:"settings"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.settingsLink",defaultMessage:"settings"}))}})))},Ea=Object(n.memo)((({agent:e,agentPolicy:t,state:a})=>{var i,s,r,o;const{data:g,application:m,http:p}=Object(c.hc)(),{update:E}=ma.useTransitions(),f=Object(n.useCallback)((e=>{const{min:t,max:a}=g.query.timefilter.timefilter.calculateBounds(e);return t&&a?{start:t.valueOf(),end:a.valueOf()}:void 0}),[g.query.timefilter.timefilter]),b=Object(n.useCallback)((e=>{f(e)&&E({start:e.from,end:e.to})}),[f,E]),[h,k]=Object(n.useState)(f({from:a.start,to:a.end})||f({from:dt,to:gt}));Object(n.useEffect)((()=>{const e=f({from:a.start,to:a.end});e?k(e):b({from:dt,to:gt})}),[a.start,a.end,f,b]);const v=Object(n.useCallback)((e=>{try{return Object(Yt.fromKueryExpression)(e),!0}catch(e){return!1}}),[]),[x,F]=Object(n.useState)(a.query),[M,I]=Object(n.useState)(v(a.query)),S=Object(n.useCallback)(((e,t)=>{F(e),v(e)?(I(!0),t&&E({query:e})):I(!1)}),[v,E]),O=Object(n.useMemo)((()=>bt({agentId:e.id,datasets:a.datasets,logLevels:a.logLevels,userQuery:a.query})),[e.id,a.datasets,a.logLevels,a.query]),T=Object(n.useMemo)((()=>p.basePath.prepend(Kt.a.format({pathname:"/app/logs/stream",search:Object(Ye.stringify)({logPosition:Object(Ze.encode)({start:a.start,end:a.end,streamLive:!1}),logFilter:Object(Ze.encode)({expression:O,kind:"kuery"})})}))),[p.basePath,a.start,a.end,O]),w=null===(i=e.local_metadata)||void 0===i||null===(s=i.elastic)||void 0===s||null===(r=s.agent)||void 0===r?void 0:r.version,j=Object(n.useMemo)((()=>{var e;if(!w)return!1;const t=null===(e=ea()(w))||void 0===e?void 0:e.version;return!!t&&Jt()(t,"7.11.0")}),[w]),[C,{height:P}]=Qt()(),A=Object(n.useMemo)((()=>Math.max(P,600)),[P]);return j?l.a.createElement(ua,{direction:"column",gutterSize:"m"},t&&!(null!==(o=t.monitoring_enabled)&&void 0!==o&&o.includes("logs"))&&l.a.createElement(pa,{agentPolicy:t}),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFlexGroup,{gutterSize:"m"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(ra,{query:x,onUpdateQuery:S,isQueryValid:M})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFilterGroup,null,l.a.createElement(aa,{selectedDatasets:a.datasets,onToggleDataset:e=>{const t=[...a.datasets],n=t.indexOf(e);n>=0?(t.splice(n,1),E({datasets:t})):E({datasets:[...a.datasets,e]})}}),l.a.createElement(la,{selectedLevels:a.logLevels,onToggleLevel:e=>{const t=[...a.logLevels],n=t.indexOf(e);n>=0?(t.splice(n,1),E({logLevels:t})):E({logLevels:[...a.logLevels,e]})}}))),l.a.createElement(da,{grow:!1},l.a.createElement(u.EuiSuperDatePicker,{showUpdateButton:!1,start:a.start,end:a.end,onTimeChange:({start:e,end:t})=>{b({from:e,to:t})}})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(y.RedirectAppLinks,{application:m},l.a.createElement(u.EuiButtonEmpty,{href:T,iconType:"popout",flush:"both"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.openInLogsUiLinkText",defaultMessage:"Open in Logs"})))))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiPanel,{paddingSize:"none",panelRef:C,grow:!1},l.a.createElement(ta.LogStream,{logView:ga,height:A,startTimestamp:h.start,endTimestamp:h.end,query:O}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ca,{agent:e}))):l.a.createElement(u.EuiCallOut,{size:"m",color:"warning",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.oldAgentWarningTitle",defaultMessage:"The Logs view requires Elastic Agent 7.11 or higher. To upgrade an agent, go to the Actions menu, or {downloadLink} a newer version.",values:{downloadLink:l.a.createElement(u.EuiLink,{href:"https://ela.st/download-elastic-agent",external:!0,target:"_blank"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentLogs.downloadLink",defaultMessage:"download"}))}})})})),fa=Object(n.memo)((({agent:e,agentPolicy:t})=>{const a=Object(n.useMemo)((()=>Object(Wt.createStateContainer)({...mt,...Object(Wt.getStateFromKbnUrl)("_q",window.location.href,{getFromHashQuery:!1})},{update:e=>t=>({...e,...t})})),[]),i=Object(n.useMemo)((()=>ma.connect((e=>({state:e||mt})))(Ea)),[]),[s,r]=Object(n.useState)(!1);return Object(n.useEffect)((()=>{const e=Object(Wt.createKbnUrlStateStorage)({useHashQuery:!1,useHash:!1}),{start:t,stop:n}=Object(Wt.syncState)({storageKey:"_q",stateContainer:a,stateStorage:e});return t(),r(!0),()=>{n(),a.set(mt)}}),[a]),l.a.createElement(ma.Provider,{value:a},s?l.a.createElement(i,{agent:e,agentPolicy:t}):null)})),ba=Object(n.memo)((({agent:e,onClose:t})=>{var a,n;const i=JSON.stringify(e,null,2),s="string"==typeof(null===(a=e.local_metadata)||void 0===a||null===(n=a.host)||void 0===n?void 0:n.hostname)?e.local_metadata.host.hostname:e.id,{docLinks:r}=Object(c.hc)();return l.a.createElement(u.EuiFlyout,{onClose:t,size:"l",maxWidth:640},l.a.createElement(u.EuiFlyoutHeader,{hasBorder:!0},l.a.createElement(u.EuiTitle,{size:"m"},l.a.createElement("h2",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.jsonFlyoutTitle",defaultMessage:"'{name}' agent details",values:{name:s}})))),l.a.createElement(u.EuiFlyoutBody,null,l.a.createElement(u.EuiText,null,l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.jsonFlyoutDescription",defaultMessage:"The JSON below is the raw agent data tracked by Fleet. This data can be useful for debugging or troubleshooting Elastic Agent. For more information, see the {doc}.",values:{doc:l.a.createElement(u.EuiLink,{href:r.links.fleet.troubleshooting},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.jsonFlyoutDocLink",defaultMessage:"troubleshooting documentation"}))}}))),l.a.createElement(u.EuiSpacer,null),l.a.createElement(u.EuiCodeBlock,{language:"json",isCopyable:!0},i)),l.a.createElement(u.EuiFlyoutFooter,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:t,flush:"left"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.agentDetailsJsonFlyoutCloseButtonLabel",defaultMessage:"Close"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{iconType:"download",onClick:()=>{const e=document.createElement("a");e.href=`data:text/json;charset=utf-8,${encodeURIComponent(i)}`,e.download=`${s}-agent-details.json`,e.click()}},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.agentDetailsJsonDownloadButtonLabel",defaultMessage:"Download JSON"}))))))})),ha=Object(n.memo)((({agent:e,assignFlyoutOpenByDefault:t=!1,onCancelReassign:a,agentPolicy:i})=>{const s=Object(c.tb)().fleet.all,r=Object(c.Xb)(),o=l.a.useContext(Gt).refresh,[g,m]=Object(n.useState)(t),[p,E]=Object(n.useState)(!1),[f,b]=Object(n.useState)(!1),[h,y]=Object(n.useState)(!1),[k,v]=Object(n.useState)(!1),F="unenrolling"===e.status,[M,I]=Object(n.useState)(!1),S=Object(n.useCallback)((e=>{I(e)}),[I]),O=i&&Object(j.t)(i),{diagnosticFileUploadEnabled:T}=j.b.get(),w=Object(n.useMemo)((()=>a||(()=>m(!1))),[a,m]),C=[];return null!=i&&i.is_managed||C.push(l.a.createElement(u.EuiContextMenuItem,{icon:"pencil",onClick:()=>{m(!0)},disabled:!e.active&&!i,key:"reassignPolicy"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.reassignActionText",defaultMessage:"Assign to new policy"})),l.a.createElement(u.EuiContextMenuItem,{icon:"trash",disabled:!s||!e.active,onClick:()=>{E(!0)},key:"unenrollAgent"},F?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.forceUnenrollOneButton",defaultMessage:"Force unenroll"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.unenrollOneButton",defaultMessage:"Unenroll agent"})),l.a.createElement(u.EuiContextMenuItem,{icon:"refresh",disabled:!Object(j.m)(e,r),onClick:()=>{b(!0)},key:"upgradeAgent"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.upgradeOneButton",defaultMessage:"Upgrade agent"}))),C.push(l.a.createElement(u.EuiContextMenuItem,{icon:"inspect",onClick:()=>{I(!1),v(!k)},key:"agentDetailsJson","data-test-subj":"viewAgentDetailsJsonBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.viewAgentDetailsJsonText",defaultMessage:"View agent JSON"}))),T&&C.push(l.a.createElement(u.EuiContextMenuItem,{icon:"download",disabled:!s||!Object(se.G)(e),onClick:()=>{y(!0)},"data-test-subj":"requestAgentDiagnosticsBtn",key:"requestDiagnostics"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.diagnosticsOneButton",defaultMessage:"Request diagnostics .zip"}))),l.a.createElement(l.a.Fragment,null,g&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.c,{agents:[e],onClose:w})),p&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.d,{agents:[e],agentCount:1,onClose:()=>{E(!1),o()},useForceUnenroll:F,hasFleetServer:O})),f&&l.a.createElement(u.EuiPortal,null,l.a.createElement(re.e,{agents:[e],agentCount:1,onClose:()=>{b(!1),o()}})),h&&l.a.createElement(u.EuiPortal,null,l.a.createElement(ce,{agents:[e],agentCount:1,onClose:()=>{y(!1)}})),k&&l.a.createElement(u.EuiPortal,null,l.a.createElement(ba,{agent:e,onClose:()=>v(!1)})),l.a.createElement(x.h,{isOpen:M,onChange:S,button:{props:{iconType:"arrowDown",iconSide:"right",color:"primary"},children:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.actionsButton",defaultMessage:"Actions"})},items:C}))})),ya=p()(u.EuiButton).withConfig({displayName:"EuiButtonCompressed",componentId:"sc-1y6vsns-0"})(["height:32px;"]),ka=({agent:e,agentPolicy:t})=>{var a,n;const{isInstalled:i,link:s,isLoading:r}=function(e){const{isLoading:t,data:a}=Object(c.Pb)(V.I),n="installed"===(null==a?void 0:a.item.status),l=Object(c.zb)();return{isLoading:t,isInstalled:n,link:null==l?void 0:l.getRedirectUrl({dashboardId:V.n.ELASTIC_AGENT_AGENT_METRICS,query:{language:"kuery",query:`elastic_agent.id:${e.id}`}})}}(e),{getHref:o}=Object(c.Zb)(),g=null!==(a=null==t||null===(n=t.monitoring_enabled)||void 0===n?void 0:n.length)&&void 0!==a&&a,m=i&&!r&&g?{href:s}:{disabled:!0},p=l.a.createElement(ya,T()({},m,{isLoading:r,color:"primary",iconType:"dashboardApp"}),l.a.createElement(d.FormattedMessage,{"data-test-subj":"agentDetails.viewMoreMetricsButton",id:"xpack.fleet.agentDetails.viewDashboardButtonLabel",defaultMessage:"View more agent metrics"}));return r||g||!t?i?p:l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.viewDashboardButton.disabledNoIntegrationTooltip",defaultMessage:"Agent dashboard not found, you need to install the elastic_agent integration."})},p):l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.viewDashboardButton.disabledNoLogsAndMetricsTooltip",defaultMessage:"Logs and metrics for agent are not enabled in the agent policy."})},l.a.createElement(ya,{"data-test-subj":"agentDetails.enableLogsAndMetricsButton",isLoading:r,color:"primary",href:o("policy_details",{policyId:t.id,tabId:"settings"}),disabled:null==t?void 0:t.is_managed},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.enableLogsAndMetricsLabel",defaultMessage:"Enable logs and metrics"})))},va=p()(u.EuiFlexItem).withConfig({displayName:"FlexItemWithMinWidth",componentId:"sc-1y4d0ny-0"})(["min-width:0px;"]),xa=Object(n.memo)((({agent:e,agentPolicy:t})=>{var a,n,i,s,r,o,m,p,E,f,b,h,y,k,v,F,M;const I=Object(c.Xb)(),{displayAgentMetrics:S}=j.b.get();return l.a.createElement(u.EuiPanel,null,l.a.createElement(u.EuiDescriptionList,{compressed:!0},l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"m"},S&&l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(va,{grow:5},l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"m"},[{title:l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.cpuTooltip",defaultMessage:"Average CPU usage in the last 5 minutes"})},l.a.createElement("span",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.cpuTitle",defaultMessage:"CPU"})," ",l.a.createElement(u.EuiIcon,{type:"iInCircle"}))),description:Bt(e.metrics,t)},{title:l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.memoryTooltip",defaultMessage:"Average memory usage in the last 5 minutes"})},l.a.createElement("span",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.memoryTitle",defaultMessage:"Memory"})," ",l.a.createElement(u.EuiIcon,{type:"iInCircle"}))),description:Rt(e.metrics,t)}].map((({title:e,description:t})=>{const a="string"==typeof t&&t.length>20?t:"";return l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(va,{grow:8},l.a.createElement(u.EuiDescriptionListTitle,null,e)),l.a.createElement(va,{grow:4},l.a.createElement(u.EuiToolTip,{position:"top",content:a},l.a.createElement(u.EuiDescriptionListDescription,{className:"eui-textTruncate"},t))))})))),l.a.createElement(va,{grow:5},l.a.createElement(u.EuiFlexGroup,{justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ka,{agent:e,agentPolicy:t}))))),[{title:g.i18n.translate("xpack.fleet.agentDetails.statusLabel",{defaultMessage:"Status"}),description:l.a.createElement(re.a,{agent:e,showOfflinePreviousStatus:!0})},{title:g.i18n.translate("xpack.fleet.agentDetails.lastActivityLabel",{defaultMessage:"Last activity"}),description:e.last_checkin?l.a.createElement(d.FormattedRelative,{value:new Date(e.last_checkin)}):"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.lastCheckinMessageLabel",{defaultMessage:"Last checkin message"}),description:e.last_checkin_message?e.last_checkin_message:"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.hostIdLabel",{defaultMessage:"Agent ID"}),description:e.id},{title:g.i18n.translate("xpack.fleet.agentDetails.agentPolicyLabel",{defaultMessage:"Agent policy"}),description:t?l.a.createElement(x.f,{policy:t,agent:e}):l.a.createElement(u.EuiSkeletonText,{lines:1})},{title:g.i18n.translate("xpack.fleet.agentDetails.versionLabel",{defaultMessage:"Agent version"}),description:"string"==typeof(null===(a=e.local_metadata)||void 0===a||null===(n=a.elastic)||void 0===n||null===(i=n.agent)||void 0===i?void 0:i.version)?l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",alignItems:"center",style:{minWidth:0}},l.a.createElement(u.EuiFlexItem,{grow:!1,className:"eui-textNoWrap"},e.local_metadata.elastic.agent.version),Object(j.m)(e,I)?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiToolTip,{position:"right",content:g.i18n.translate("xpack.fleet.agentList.agentUpgradeLabel",{defaultMessage:"Upgrade available"})},l.a.createElement(u.EuiIcon,{type:"warning",color:"warning"}))):null):"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.hostNameLabel",{defaultMessage:"Host name"}),description:"string"==typeof(null===(s=e.local_metadata)||void 0===s||null===(r=s.host)||void 0===r?void 0:r.hostname)?e.local_metadata.host.hostname:"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.logLevel",{defaultMessage:"Logging level"}),description:"string"==typeof(null===(o=e.local_metadata)||void 0===o||null===(m=o.elastic)||void 0===m||null===(p=m.agent)||void 0===p?void 0:p.log_level)?e.local_metadata.elastic.agent.log_level:"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.releaseLabel",{defaultMessage:"Agent release"}),description:"boolean"==typeof(null===(E=e.local_metadata)||void 0===E||null===(f=E.elastic)||void 0===f||null===(b=f.agent)||void 0===b?void 0:b.snapshot)?!0===e.local_metadata.elastic.agent.snapshot?"snapshot":"stable":"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.platformLabel",{defaultMessage:"Platform"}),description:"string"==typeof(null===(h=e.local_metadata)||void 0===h||null===(y=h.os)||void 0===y?void 0:y.platform)?e.local_metadata.os.platform:"-"},{title:g.i18n.translate("xpack.fleet.agentDetails.monitorLogsLabel",{defaultMessage:"Monitor logs"}),description:Array.isArray(null==t?void 0:t.monitoring_enabled)?null!=t&&null!==(k=t.monitoring_enabled)&&void 0!==k&&k.includes("logs")?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.monitorLogsEnabledText",defaultMessage:"Enabled"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.monitorLogsDisabledText",defaultMessage:"Disabled"}):l.a.createElement(u.EuiSkeletonText,{lines:1})},{title:g.i18n.translate("xpack.fleet.agentDetails.monitorMetricsLabel",{defaultMessage:"Monitor metrics"}),description:Array.isArray(null==t?void 0:t.monitoring_enabled)?null!=t&&null!==(v=t.monitoring_enabled)&&void 0!==v&&v.includes("metrics")?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.monitorMetricsEnabledText",defaultMessage:"Enabled"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.monitorMetricsDisabledText",defaultMessage:"Disabled"}):l.a.createElement(u.EuiSkeletonText,{lines:1})},{title:g.i18n.translate("xpack.fleet.agentDetails.tagsLabel",{defaultMessage:"Tags"}),description:(null!==(F=e.tags)&&void 0!==F?F:[]).length>0?l.a.createElement(Dt,{tags:null!==(M=e.tags)&&void 0!==M?M:[]}):"-"}].map((({title:e,description:t})=>{const a="string"==typeof t&&t.length>20?t:"";return l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(va,{grow:3},l.a.createElement(u.EuiDescriptionListTitle,null,e)),l.a.createElement(va,{grow:7},l.a.createElement(u.EuiToolTip,{position:"top",content:a},l.a.createElement(u.EuiDescriptionListDescription,{className:"eui-textTruncate"},t))))})))))})),Fa=p()(u.EuiText).withConfig({displayName:"StyledEuiText",componentId:"sc-sfo0eu-0"})(["text-align:left;white-space:normal;"]),Ma=Object(n.memo)((({inputStatusFormatter:e})=>e.hasError?l.a.createElement(u.EuiCallOut,{title:e.getErrorTitleFromStatus(),color:"danger",iconType:"error","data-test-subj":"integrationInputErrorCallOut"},l.a.createElement(Fa,{size:"s","data-test-subj":"integrationInputErrorDescription"},e.description)):l.a.createElement(u.EuiText,{size:"s"},e.description)));function Ia(e){return"logfile"===e?g.i18n.translate("xpack.fleet.agentDetailsIntegrations.inputTypeLogText",{defaultMessage:"Logs"}):"endpoint"===e?g.i18n.translate("xpack.fleet.agentDetailsIntegrations.inputTypeEndpointText",{defaultMessage:"Endpoint"}):e.match(/\/metrics$/)?g.i18n.translate("xpack.fleet.agentDetailsIntegrations.inputTypeMetricsText",{defaultMessage:"Metrics"}):e}var Sa=a(13),Oa=a.n(Sa);class input_status_utils_InputStatusFormatter{constructor(e,t){Oa()(this,"status",void 0),Oa()(this,"description",void 0),Oa()(this,"hasError",void 0),this.status=e,this.description=t||g.i18n.translate("xpack.fleet.agentDetailsIntegrations.inputStatusDefaultDescription",{defaultMessage:"Not available"}),this.hasError="FAILED"===e||"DEGRADED"===e}getErrorTitleFromStatus(){switch(this.status){case"FAILED":return g.i18n.translate("xpack.fleet.agentDetailsIntegrations.inputErrorTitle.failed",{defaultMessage:"Failed"});case"DEGRADED":return g.i18n.translate("xpack.fleet.agentDetailsIntegrations.inputErrorTitle.degraded",{defaultMessage:"Degraded"});default:return}}}const Ta=(e,t)=>{const a=new RegExp(t.id);return e.map((e=>(null==e?void 0:e.units)||[])).flat().filter((e=>!!e&&e.id.match(a)))},wa=p()(u.EuiLink).withConfig({displayName:"StyledEuiLink",componentId:"sc-6q2goy-0"})(["font-size:",";"],(e=>e.theme.eui.euiFontSizeS)),ja=p()(u.EuiTreeView).withConfig({displayName:"StyledEuiTreeView",componentId:"sc-6q2goy-1"})([".input-action-item-expanded{height:auto;padding-top:",";padding-bottom:",";.euiTreeView__nodeLabel{width:100%;}}.inputStatusHealth{padding-top:5px;}.euiTreeView__node--expanded{max-height:none !important;.policy-response-action-expanded + div{.euiTreeView__node{max-height:none !important;}}}.euiTreeView__node{max-height:none !important;.euiNotificationBadge{margin-right:5px;}.euiTreeView__nodeLabel{.euiText{font-size:",";}}}"],(({theme:e})=>e.eui.euiSizeS),(({theme:e})=>e.eui.euiSizeS),(({theme:e})=>e.eui.euiFontSize)),Ca=Object(n.memo)((({agent:e,packagePolicy:t,"data-test-subj":a})=>{const{getHref:i}=Object(c.Zb)(),s=Object(n.useMemo)((()=>t.inputs.reduce(((a,n)=>{if(!e.components)return new Map;if(n.enabled){var l;const i=null===(l=Ta(e.components,t))||void 0===l?void 0:l.find((e=>e.id.match(new RegExp(n.type))));a.set(n.type,i?new input_status_utils_InputStatusFormatter(i.status,i.message):new input_status_utils_InputStatusFormatter)}return a}),new Map)),[e.components,t]),r=e=>{const t=s.get(e);return void 0===(null==t?void 0:t.status)?l.a.createElement(u.EuiHealth,{color:"default","data-test-subj":"agentDetailsIntegrationsInputStatusHealthDefault",className:"inputStatusHealth"}):"HEALTHY"===t.status?l.a.createElement(u.EuiHealth,{color:"success","data-test-subj":"agentDetailsIntegrationsInputStatusHealthSuccess",className:"inputStatusHealth"}):l.a.createElement(u.EuiNotificationBadge,{"data-test-subj":"agentDetailsIntegrationsInputStatusAttentionHealth"},1)};return l.a.createElement(ja,{items:(()=>{const a=Array.from(s.values()).reduce(((e,t)=>(t.hasError&&(e+=1),e)),0);return[{label:l.a.createElement(u.EuiText,{color:a?"danger":"default",size:"s","data-test-subj":"agentIntegrationsInputsTitle"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetailsIntegrations.inputsTypeLabel",defaultMessage:"Inputs"})),id:"agentIntegrationsInputs",icon:a?l.a.createElement(u.EuiNotificationBadge,{"data-test-subj":"agentIntegrationsInputsStatusHealth"},a):void 0,children:t.inputs.reduce(((t,a)=>{return a.enabled?[...t,{label:l.a.createElement(u.EuiToolTip,{content:g.i18n.translate("xpack.fleet.agentDetailsIntegrations.viewLogsButton",{defaultMessage:"View logs"})},l.a.createElement(wa,{href:i("agent_details",{agentId:e.id,tabId:"logs",logQuery:(n=a.type,"logfile"===n?`(${pt}:!(elastic_agent.filebeat))`:n.match(/\/metrics$/)?`(${pt}:!(elastic_agent.metricbeat))`:"osquery"===n?`(${pt}:!(elastic_agent.osquerybeat))`:n.match(/^synthetics\//)?`(${pt}:!(elastic_agent.heartbeat))`:"apm"===n?`(${pt}:!(elastic_agent.apm_server))`:"endpoint"===n?`(${pt}:!(elastic_agent.endpoint_security))`:"")}),"aria-label":g.i18n.translate("xpack.fleet.agentDetailsIntegrations.viewLogsButton",{defaultMessage:"View logs"})},Ia(a.type))),id:a.type,icon:r(a.type),children:[{label:l.a.createElement(Ma,{inputStatusFormatter:s.get(a.type)}),id:`input-status-${a.type}`,isExpanded:!0,className:"input-action-item-expanded"}]}]:t;var n}),[])}]})(),showExpansionArrows:!0,"aria-label":"inputsTreeView","aria-labelledby":"inputsTreeView"})})),Pa=p()(u.EuiAccordion).withConfig({displayName:"StyledEuiAccordion",componentId:"sc-f6nvxk-0"})([".euiAccordion__button{width:90%;}.euiAccordion__triggerWrapper{padding-left:",";}&.euiAccordion-isOpen{.euiAccordion__childWrapper{padding:",";padding-top:0px;}}.ingest-integration-title-button{padding:",";}.euiTableRow:last-child .euiTableRowCell{border-bottom:none;}.euiIEFlexWrapFix{min-width:0;}.euiAccordion__buttonContent{width:100%;}"],(e=>e.theme.eui.euiSizeM),(e=>e.theme.eui.euiSizeM),(e=>e.theme.eui.euiSizeS)),Aa=({id:e,title:t,children:a,"data-test-subj":i})=>{const s=Object(n.useMemo)((()=>{if(i)return{"data-test-subj":`${i}-openCloseToggle`}}),[i]);return l.a.createElement(u.EuiPanel,{paddingSize:"none"},l.a.createElement(Pa,{id:e,arrowDisplay:"left",buttonClassName:"ingest-integration-title-button",buttonContent:t,arrowProps:s,"data-test-subj":i},a))},La=Object(n.memo)((({agent:e,agentPolicy:t,packagePolicy:a,"data-test-subj":i})=>{var s,r,o,g;const{getHref:m}=Object(c.Zb)(),p=Object(u.useEuiTheme)(),[E,f]=Object(n.useState)(!1),b=Object(c.kc)(null!==(s=null===(r=a.package)||void 0===r?void 0:r.name)&&void 0!==s?s:"","package-policy-response"),h=Object(n.useMemo)((()=>b&&l.a.createElement(x.l,null,l.a.createElement(b.Component,{agent:e,onShowNeedsAttentionBadge:f}))),[e,b]),y=Object(n.useMemo)((()=>e.components?Ta(e.components,a).filter((e=>"DEGRADED"===e.status||"FAILED"===e.status)):[]),[e.components,a]),k=E||!!y.length,v=Object(c.kc)(null!==(o=null===(g=a.package)||void 0===g?void 0:g.name)&&void 0!==o?o:"","package-generic-errors-list"),F=Object(n.useMemo)((()=>v&&l.a.createElement(x.l,null,l.a.createElement(v.Component,{packageErrors:y}))),[y,v]);return l.a.createElement(Aa,{id:a.id,"data-test-subj":i,title:l.a.createElement(u.EuiTitle,{size:"xs"},l.a.createElement("h3",null,l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},a.package?l.a.createElement(x.t,{packageName:a.package.name,version:a.package.version,size:"l",tryApi:!0}):l.a.createElement(x.t,{size:"l",packageName:"default",version:"0"})),l.a.createElement(u.EuiFlexItem,{className:"eui-textTruncate"},l.a.createElement(u.EuiLink,{className:"eui-textTruncate","data-test-subj":"agentPolicyDetailsLink",href:m("edit_integration",{policyId:t.id,packagePolicyId:a.id})},a.name)),k&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiBadge,{color:p.euiTheme.colors.danger,iconType:"warning",iconSide:"left","data-test-subj":i?`${i}-needsAttention`:void 0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetailsIntegrations.needsAttention.label",defaultMessage:"Needs attention"}))))))},l.a.createElement(Ca,{agent:e,packagePolicy:a}),h,F,l.a.createElement(u.EuiSpacer,null))})),_a=Object(n.memo)((({agent:e,agentPolicy:t})=>t&&t.package_policies?l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"m"},t.package_policies.map(((a,n)=>{var i,s;const r=(null!==(i=null===(s=a.package)||void 0===s?void 0:s.name)&&void 0!==i?i:"packagePolicy")+"-"+n;return l.a.createElement(u.EuiFlexItem,{grow:!1,key:a.id,"data-test-subj":r},l.a.createElement(La,{agent:e,agentPolicy:t,packagePolicy:a,"data-test-subj":`${r}-accordion`}))}))):null)),Da=p()(u.EuiFlexItem).withConfig({displayName:"FlexItemWithMinWidth",componentId:"sc-1n7kbng-0"})(["min-width:0px;"]),Ba=Object(n.memo)((({agent:e,agentPolicy:t})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(Da,null,l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.overviewSectionTitle",defaultMessage:"Overview"}))),l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(xa,{agent:e,agentPolicy:t})),l.a.createElement(Da,null,l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.integrationsSectionTitle",defaultMessage:"Integrations"}))),l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(_a,{agent:e,agentPolicy:t})))))),Ra=p()(u.EuiFlexItem).withConfig({displayName:"FlexStartEuiFlexItem",componentId:"sc-z35w3m-0"})(["align-self:flex-start;"]),za=p()(u.EuiIcon).withConfig({displayName:"MarginedIcon",componentId:"sc-z35w3m-1"})(["margin-right:7px;"]),Na=({agent:e})=>{const{notifications:t}=Object(c.hc)(),{getAbsolutePath:a}=Object(c.Zb)(),[i,s]=Object(n.useState)(!1),[r,o]=Object(n.useState)(!0),[m,p]=Object(n.useState)([]),[E,f]=Object(n.useState)([]),[b,h]=Object(n.useState)(1e4),y=Object(n.useCallback)((async()=>{try{const t=await Object(c.y)(e.id),a=t.error;if(a)throw a;if(!t.data)throw new Error("No data");const n=t.data.items;p(n),o(!1),n.some((e=>"IN_PROGRESS"===e.status||"AWAITING_UPLOAD"===e.status))?h(3e3):h(1e4)}catch(e){t.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.requestDiagnostics.errorLoadingUploadsNotificationTitle",{defaultMessage:"Error loading diagnostics uploads"})})}}),[e.id,t.toasts,h]);Object(n.useEffect)((()=>{y();const e=setInterval((async()=>{y()}),b);return()=>{e&&clearInterval(e)}}),[y,b]),Object(n.useEffect)((()=>{f(m),E.length>0&&m.filter((e=>{const t=E.find((t=>t.id===e.id));return"READY"===e.status&&(!t||"READY"!==(null==t?void 0:t.status))})).forEach((e=>{t.toasts.addSuccess({title:g.i18n.translate("xpack.fleet.requestDiagnostics.readyNotificationTitle",{defaultMessage:"Agent diagnostics {name} ready",values:{name:e.name}})},{toastLifeTimeMs:5e3})}))}),[E,m,t.toasts]);const k=l.a.createElement(za,{type:"warning",color:"red"}),v=[{field:"id",name:"File",render:e=>{const t=m.find((t=>t.id===e));return"READY"===(null==t?void 0:t.status)?l.a.createElement(u.EuiLink,{href:a(null==t?void 0:t.filePath),download:!0,target:"_blank"},l.a.createElement(u.EuiIcon,{type:"download"}),"   ",null==t?void 0:t.name):"IN_PROGRESS"===(null==t?void 0:t.status)||"AWAITING_UPLOAD"===(null==t?void 0:t.status)?l.a.createElement(u.EuiLink,{color:"subdued",disabled:!0},l.a.createElement(u.EuiLoadingSpinner,null),"  ",l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.generatingText",defaultMessage:"Generating diagnostics file..."})):l.a.createElement(u.EuiLink,{color:"subdued",disabled:!0},null!=t&&t.status?l.a.createElement(u.EuiToolTip,{content:l.a.createElement(l.a.Fragment,null,l.a.createElement("p",null,"Diagnostics status: ",null==t?void 0:t.status),l.a.createElement("p",null,(n=null==t?void 0:t.error,n?`Error: ${n}`:"")))},k):k," ",null==t?void 0:t.name);var n}},{field:"id",name:"Date",dataType:"date",render:e=>{const t=m.find((t=>t.id===e));return l.a.createElement(u.EuiText,{color:"READY"===(null==t?void 0:t.status)?"default":"subdued"},Object(u.formatDate)(null==t?void 0:t.createTime,"lll"))}}],x=l.a.createElement(u.EuiButton,{fill:!0,size:"m",onClick:async function(){try{s(!0);const{error:a}=await Object(c.cb)(e.id);if(a)throw a;s(!1);const n=g.i18n.translate("xpack.fleet.requestDiagnostics.successSingleNotificationTitle",{defaultMessage:"Request diagnostics submitted"});t.toasts.addSuccess(n),y()}catch(e){s(!1),t.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.requestDiagnostics.fatalErrorNotificationTitle",{defaultMessage:"Error requesting diagnostics {count, plural, one {agent} other {agents}}",values:{count:1}})})}},disabled:i||!Object(se.G)(e)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentList.diagnosticsOneButton",defaultMessage:"Request diagnostics .zip"}));return l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"l"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiCallOut,{iconType:"warning",color:"warning",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.fleetServerSetup.calloutTitle",defaultMessage:"Agent diagnostics"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.calloutText",defaultMessage:"Diagnostics files are stored in Elasticsearch, and as such can incur storage costs."}))),l.a.createElement(Ra,null,Object(se.G)(e)?x:l.a.createElement(u.EuiToolTip,{content:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.requestDiagnostics.notSupportedTooltip",defaultMessage:"Requesting agent diagnostics is not supported for agents before version {version}.",values:{version:se.d}})},x)),l.a.createElement(u.EuiFlexItem,null,r?l.a.createElement(u.EuiSkeletonText,{lines:3}):l.a.createElement(u.EuiBasicTable,{items:m,columns:v})))},Ha=()=>{var e,t,a;const{params:{agentId:i,tabId:s=""}}=Object(r.useRouteMatch)(),{getHref:o}=Object(c.Zb)(),{displayAgentMetrics:m}=j.b.get(),{isLoading:p,isInitialRequest:E,error:f,data:b,resendRequest:h}=Object(c.Lb)(i,{pollIntervalMs:5e3,query:{withMetrics:m}}),{isLoading:y,data:k,sendRequest:v}=Object(c.Mb)(null==b||null===(e=b.item)||void 0===e?void 0:e.policy_id),{application:{navigateToApp:F}}=Object(c.hc)(),I=Object(c.Ub)(),S="true"===new URLSearchParams(Object(r.useLocation)().search).get("openReassignFlyout"),O=Object(n.useCallback)((()=>{I&&I.onDoneNavigateTo&&F(I.onDoneNavigateTo[0],I.onDoneNavigateTo[1])}),[I,F]),{diagnosticFileUploadEnabled:T}=j.b.get(),w=null==b||null===(t=b.item)||void 0===t||null===(a=t.local_metadata)||void 0===a?void 0:a.host,C=Object(n.useMemo)((()=>l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:"s",alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiButtonEmpty,{iconType:"arrowLeft",href:o("agent_list"),flush:"left",size:"xs"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.viewAgentListTitle",defaultMessage:"View all agents"}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{className:"eui-textBreakWord"},l.a.createElement("h1",null,p&&E?l.a.createElement(x.r,null):"object"==typeof w&&"string"==typeof(null==w?void 0:w.hostname)?w.hostname:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.agentDetailsTitle",defaultMessage:"Agent '{id}'",values:{id:i}})))))),[w,i,o,E,p]),P=Object(n.useMemo)((()=>b&&b.item?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{justifyContent:"flexEnd",alignItems:"center",gutterSize:"s",direction:"row"},!y&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ha,{agent:b.item,agentPolicy:null==k?void 0:k.item,assignFlyoutOpenByDefault:S,onCancelReassign:I&&I.onDoneNavigateTo?O:void 0})))):void 0),[k,b,o,y]),A=Object(n.useMemo)((()=>{const e=[{id:"details",name:g.i18n.translate("xpack.fleet.agentDetails.subTabs.detailsTab",{defaultMessage:"Agent details"}),href:o("agent_details",{agentId:i,tabId:"details"}),isSelected:!s||"details"===s},{id:"logs",name:g.i18n.translate("xpack.fleet.agentDetails.subTabs.logsTab",{defaultMessage:"Logs"}),href:o("agent_details_logs",{agentId:i,tabId:"logs"}),isSelected:"logs"===s}];return T&&e.push({id:"diagnostics",name:g.i18n.translate("xpack.fleet.agentDetails.subTabs.diagnosticsTab",{defaultMessage:"Diagnostics"}),href:o("agent_details_diagnostics",{agentId:i,tabId:"diagnostics"}),isSelected:"diagnostics"===s}),e}),[o,i,s,T]);return l.a.createElement(Gt.Provider,{value:{refresh:()=>{h(),v()}}},l.a.createElement(M.c,{leftColumn:C,rightColumn:P,tabs:A},p&&E?l.a.createElement(x.r,null):f?l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.unexceptedErrorTitle",defaultMessage:"Error loading agent"}),error:f}):b&&b.item?l.a.createElement(Ua,{agent:b.item,agentPolicy:null==k?void 0:k.item}):l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentDetails.agentNotFoundErrorTitle",defaultMessage:"Agent not found"}),error:g.i18n.translate("xpack.fleet.agentDetails.agentNotFoundErrorDescription",{defaultMessage:"Cannot find agent ID {agentId}",values:{agentId:i}})})))},Ua=({agent:e,agentPolicy:t})=>(Object(c.ub)("agent_details",{agentHost:"object"==typeof e.local_metadata.host&&"string"==typeof e.local_metadata.host.hostname?e.local_metadata.host.hostname:"-"}),l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.agent_details_logs,render:()=>l.a.createElement(fa,{agent:e,agentPolicy:t})}),l.a.createElement(o.a,{path:F.h.agent_details_diagnostics,render:()=>l.a.createElement(Na,{agent:e})}),l.a.createElement(o.a,{path:F.h.agent_details,render:()=>l.a.createElement(Ba,{agent:e,agentPolicy:t})}))),qa=Object(r.withRouter)((({actionSection:e,title:t,children:a})=>l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceAround"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiPageSection,{color:"transparent"},l.a.createElement(u.EuiEmptyPrompt,{color:"plain",iconType:"logoBeats",title:l.a.createElement("h2",null,t),body:a,actions:e})))))),Ga=Object(d.injectI18n)((({intl:e})=>l.a.createElement(qa,{title:e.formatMessage({id:"xpack.fleet.noAccess.accessDeniedTitle",defaultMessage:"Access denied"}),actionSection:[]},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.noAccess.accessDeniedDescription",defaultMessage:"You are not authorized to access Elastic Fleet. To use Elastic Fleet, you need a user role that contains All permissions for this application."}))))),Wa=()=>{var e;Object(c.ub)("agent_list");const{agents:t}=Object(c.wb)(),a=Object(c.tb)().fleet.all,n=Object(c.Db)(),i=Object(c.Eb)();if(!t.enabled)return null;if(!n.missingRequirements&&n.isLoading)return l.a.createElement(x.r,null);if(n.error)return l.a.createElement(M.d,null,l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentsInitializationErrorMessageTitle",defaultMessage:"Unable to initialize central management for Elastic Agents"}),error:n.error}));const s=1===(null==n||null===(e=n.missingRequirements)||void 0===e?void 0:e.length)&&"fleet_server"===n.missingRequirements[0],r=n.forceDisplayInstructions||s;if(!s&&n.missingRequirements&&n.missingRequirements.length>0)return l.a.createElement(qt.b,{missingRequirements:n.missingRequirements});if(!a)return l.a.createElement(Ga,null);const g=r?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{fill:!0,iconType:"plusInCircle",onClick:()=>i.openEnrollmentFlyout(),"data-test-subj":"addAgentBtnTop"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addAgentButton",defaultMessage:"Add Agent"}))))):void 0;return l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.agent_details},l.a.createElement(Ha,null)),l.a.createElement(o.a,{path:F.h.agents},l.a.createElement(M.a,{section:"agents",rightColumn:g},r?l.a.createElement(qt.a,{showEnrollmentRecommendation:!1}):l.a.createElement(Ut,null))))};var $a=a(199),Ka=a(22);const Va=e=>{const{packagePolicy:t,queryParamsPolicyId:a}=e,l=Object(c.Ub)(),i=Object(n.useRef)(!0),{getPath:s}=Object(c.Zb)(),{application:{navigateToApp:r}}=Object(c.hc)();return Object(n.useEffect)((()=>()=>{i.current=!1}),[]),Object(n.useCallback)(((e,n=[])=>{if(!i.current)return;const o=s("policy_details",{policyId:t.policy_id}),[c,u]=null!=l&&l.onSaveNavigateTo?[l.onSaveNavigateTo,null==l?void 0:l.onSaveQueryParams]:[[F.o,{path:o}],{showAddAgentHelp:!0,openEnrollmentFlyout:!0}],[d,g]=c;if(null!=g&&g.path){const t=function({path:e,policy:t,paramsToApply:a,mappingOptions:n={}}){const[l,i]=e.split("?"),s=Object(Ka.parse)(i);a.forEach((e=>{const a=n[e];if(a){const[n,o]=(l=e,i=a,r=t.policy_id,i?"boolean"==typeof i&&i?[l,"true"]:[i.renameKey?i.renameKey:l,i.policyIdAsValue?r:"true"]:[]);n&&o&&(s[n]=o)}var l,i,r}));const r=Object(Ka.stringify)(s);return l+(r?`?${r}`:"")}({path:a?o:g.path,policy:e,mappingOptions:u,paramsToApply:n});r(d,{...g,path:t})}else r(...c)}),[t.policy_id,s,r,l,a])};var Qa=a(117),Ya=a(204),Za=a(107),Ja=a(119),Xa=a(160);const en={name:"",description:"",namespace:"default",policy_id:"",enabled:!0,inputs:[]};const tn=({onConfirm:e,onCancel:t,agentPolicy:a,packagePolicy:n})=>{var i,s;const{data:r}=Object(b.useQuery)(["cloudFormationApiKeys"],(()=>Object(c.B)({page:1,perPage:1,kuery:`policy_id:${a.id}`}))),o=Object(j.j)(n),{cloudFormationUrl:g,error:m,isError:p,isLoading:E}=Object(c.xb)({enrollmentAPIKey:null==r||null===(i=r.data)||void 0===i||null===(s=i.items[0])||void 0===s?void 0:s.api_key,cloudFormationProps:o});return l.a.createElement(u.EuiModal,{"data-test-subj":"postInstallCloudFormationModal",onClose:t},l.a.createElement(u.EuiModalHeader,null,l.a.createElement(u.EuiModalHeaderTitle,{"data-test-subj":"confirmCloudFormationModalTitleText"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicy.postInstallCloudFormationModalTitle",defaultMessage:"CloudFormation deployment"}))),l.a.createElement(u.EuiModalBody,null,l.a.createElement(x.g,{awsAccountType:o.awsAccountType}),m&&p&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCallOut,{title:m,color:"danger",iconType:"error"}))),l.a.createElement(u.EuiModalFooter,null,l.a.createElement(u.EuiButtonEmpty,{"data-test-subj":"confirmCloudFormationModalCancelButton",onClick:t},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicy.postInstallCloudFormationModal.cancelButton",defaultMessage:"Launch CloudFormation later"})),l.a.createElement(u.EuiButton,{"data-test-subj":"confirmCloudFormationModalConfirmButton",onClick:()=>{window.open(g),e()},fill:!0,color:"primary",isLoading:E,isDisabled:p},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicy.postInstallCloudFormationModalConfirmButtonLabel",defaultMessage:"Launch CloudFormation"}))))};var an=a(138);const nn=({onConfirm:e,onCancel:t,agentPolicy:a,packagePolicy:n})=>{var i,s,r,o;const{data:g}=Object(b.useQuery)(["googleCloudShellApiKeys"],(()=>Object(c.B)({page:1,perPage:1,kuery:`policy_id:${a.id}`}))),{fleetServerHosts:m,fleetProxy:p}=Object(c.Bb)(a),E=Object(c.Xb)(),f=Object(an.a)({apiKey:(null==g||null===(i=g.data)||void 0===i||null===(s=i.items[0])||void 0===s?void 0:s.api_key)||"no_key",fleetServerHosts:m,fleetProxy:p,kibanaVersion:E}),{cloudShellUrl:h,error:y,isError:k,isLoading:v}=Object(c.yb)({enrollmentAPIKey:null==g||null===(r=g.data)||void 0===r||null===(o=r.items[0])||void 0===o?void 0:o.api_key,packagePolicy:n});return l.a.createElement(u.EuiModal,{"data-test-subj":"postInstallGoogleCloudShellModal",onClose:t},l.a.createElement(u.EuiModalHeader,null,l.a.createElement(u.EuiModalHeaderTitle,{"data-test-subj":"confirmGoogleCloudShellTitleText"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicy.postInstallGoogleCloudShellModalTitle",defaultMessage:"Google Cloud Shell deployment"}))),l.a.createElement(u.EuiModalBody,null,l.a.createElement(x.o,{commandText:f.googleCloudShell}),y&&k&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCallOut,{title:y,color:"danger",iconType:"error"}))),l.a.createElement(u.EuiModalFooter,null,l.a.createElement(u.EuiButtonEmpty,{"data-test-subj":"confirmGoogleCloudShellModalCancelButton",onClick:t},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicy.postInstallGoogleCloudShellModal.cancelButton",defaultMessage:"Launch Google Cloud Shell later"})),l.a.createElement(u.EuiButton,{"data-test-subj":"confirmGoogleCloudShellModalConfirmButton",onClick:()=>{window.open(h),e()},fill:!0,color:"primary",isLoading:v,isDisabled:k},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentPolicy.postInstallGoogleCloudShellModalConfirmButtonLabel",defaultMessage:"Launch Google Cloud Shell"}))))},ln=p()(u.EuiSteps).withConfig({displayName:"StepsWithLessPadding",componentId:"sc-12f9cyq-0"})([".euiStep__content{padding-bottom:",";}@media (max-width:","){margin-bottom:100px;}"],(e=>e.theme.eui.euiSizeM),(e=>e.theme.eui.euiBreakpoints.m)),sn=p()(u.EuiBottomBar).withConfig({displayName:"CustomEuiBottomBar",componentId:"sc-12f9cyq-1"})(["z-index:50;"]),rn=({from:e,queryParamsPolicyId:t,prerelease:a})=>{var i,s,o,m;const{agents:{enabled:p}}=Object(c.wb)(),{params:E}=Object(r.useRouteMatch)(),[f,b]=Object(n.useState)(Object(C.b)({name:"Agent policy 1"})),[h,y]=Object(n.useState)(!0),k=Object(S.h)(f),[F,M]=Object(n.useState)(t?Qa.b.EXISTING:Qa.b.NEW),{pkgName:I,pkgVersion:O}=Object(se.X)(E.pkgkey),{data:P,error:A,isLoading:L}=Object(c.Pb)(I,O,{full:!0,prerelease:a}),_=Object(n.useMemo)((()=>{if(P&&P.item)return P.item}),[P]),[B,R]=Object(n.useState)(0),z=Object(n.useMemo)((()=>{var e;return E.integration?null==_||null===(e=_.policy_templates)||void 0===e?void 0:e.find((e=>e.name===E.integration)):void 0}),[null==_?void 0:_.policy_templates,E]),{onSubmit:N,updatePackagePolicy:H,packagePolicy:U,agentPolicy:q,updateAgentPolicy:G,savedPackagePolicy:W,formState:$,setFormState:K,navigateAddAgent:Q,navigateAddAgentHelp:Y,setHasAgentPolicyError:Z,validationResults:J,hasAgentPolicyError:X,isInitialized:ee}=function({agentCount:e,selectedPolicyTab:t,newAgentPolicy:a,withSysMonitoring:l,queryParamsPolicyId:i,packageInfo:s,integrationToEnable:r}){const{notifications:o}=Object(c.hc)(),u=Object(v.p)(),[d,m]=Object(n.useState)(),[p,E]=Object(n.useState)("VALID"),[f,b]=Object(n.useState)(!1),h=Object(n.useRef)(!1),[y,k]=Object(n.useState)(),[x,F]=Object(n.useState)({...en}),[M,I]=Object(n.useState)(),[S,O]=Object(n.useState)(!1),T=!!M&&Object(Ja.f)(M),w=Object(n.useCallback)((e=>{e?(k(e),s&&O(!1)):(O(!0),k(void 0)),console.debug("Agent policy updated",e)}),[s,k]),C=Object(n.useCallback)((e=>{if(s){const t=Object(Ja.d)(e||x,s,Za.safeLoad);return I(t),console.debug("Package policy validation results",t),t}}),[x,s]),P=Object(n.useCallback)((e=>{const a={...x,...e};F(a),console.debug("Package policy updated",a);const n=C(a),l=a.package,i=!!n&&Object(Ja.f)(n),s=a.policy_id&&""!==a.policy_id;!l||!s&&t!==Qa.b.NEW||i?E("INVALID"):E("VALID")}),[x,E,C,t]);Object(n.useEffect)((()=>{!async function(){if(h.current||!s)return;const{data:e}=await Object(c.H)({perPage:D.SO_SEARCH_LIMIT,page:1,kuery:`${D.PACKAGE_POLICY_SAVED_OBJECT_TYPE}.package.name:${s.name}`}),t=Object(se.y)(s.name,null==e?void 0:e.items);h.current=!0,P(Object(j.r)(s,(null==y?void 0:y.id)||"",(null==y?void 0:y.namespace)||en.namespace,en.name||t,en.description,r)),b(!0)}()}),[s,y,P,r,f]),Object(n.useEffect)((()=>{y&&x.policy_id!==y.id&&P({policy_id:y.id,namespace:y.namespace})}),[x,y,P]);const A=Va({packagePolicy:x,queryParamsPolicyId:i}),L=Object(n.useCallback)((async({force:n,overrideCreatedAgentPolicy:i}={})=>{var r,d;if("VALID"===p&&T)return void E("INVALID");if(0!==e&&"CONFIRM"!==p)return void E("CONFIRM");let f=i;if(t===Qa.b.NEW&&!i)try{var b,h;if(E("LOADING"),null!==(b=l||(null===(h=a.monitoring_enabled)||void 0===h?void 0:h.length))&&void 0!==b&&b){var v,F;const e=[];s&&e.push({name:s.name,version:s.version}),l&&e.push(D.FLEET_SYSTEM_PACKAGE),null!==(v=null===(F=a.monitoring_enabled)||void 0===F?void 0:F.length)&&void 0!==v&&v&&e.push(D.FLEET_ELASTIC_AGENT_PACKAGE),e.length>0&&await Object(c.h)([...new Set(e)])}f=await async function({packagePolicy:e,newAgentPolicy:t,withSysMonitoring:a}){var n;const l=(null==e||null===(n=e.package)||void 0===n?void 0:n.name)===D.FLEET_SYSTEM_PACKAGE,i=await Object(c.j)(t,{withSysMonitoring:a&&!l});if(i.error)throw i.error;if(!i.data)throw new Error("Invalid agent policy creation no data");return i.data.item}({newAgentPolicy:a,packagePolicy:x,withSysMonitoring:l}),k(f),P({policy_id:f.id})}catch(e){return E("VALID"),void o.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.createAgentPolicy.errorNotificationTitle",{defaultMessage:"Unable to create agent policy"})})}E("LOADING");const{error:M,data:I}=await async function(e){const{policy:t,forceCreateNeeded:a}=await Object(Xa.a)(e);return await Object(c.l)({...t,...a&&{force:!0}})}({...x,policy_id:null!==(r=null===(d=f)||void 0===d?void 0:d.id)&&void 0!==r?r:x.policy_id,force:n}),S=!(null==I||!I.item)&&Object(j.j)(I.item).templateUrl,O=!(null==I||!I.item)&&Object(j.k)(I.item);if(E(S?e?"SUBMITTED":"SUBMITTED_CLOUD_FORMATION":e?"SUBMITTED":"SUBMITTED_NO_AGENTS"),E(O?e?"SUBMITTED":"SUBMITTED_GOOGLE_CLOUD_SHELL":e?"SUBMITTED":"SUBMITTED_NO_AGENTS"),M){if(Object(j.p)(M))return E("VALID"),void(await u(x.package)&&L({overrideCreatedAgentPolicy:f,force:!0}));o.toasts.addError(M,{title:"Error"}),E("VALID")}else{m(I.item);const t=e&&y;if(!t&&S)return void E("SUBMITTED_CLOUD_FORMATION");if(!t&&O)return void E("SUBMITTED_GOOGLE_CLOUD_SHELL");if(!t)return void E("SUBMITTED_NO_AGENTS");A(I.item),o.toasts.addSuccess({title:g.i18n.translate("xpack.fleet.createPackagePolicy.addedNotificationTitle",{defaultMessage:"'{packagePolicyName}' integration added.",values:{packagePolicyName:x.name}}),text:t?g.i18n.translate("xpack.fleet.createPackagePolicy.addedNotificationMessage",{defaultMessage:"Fleet will deploy updates to all agents that use the '{agentPolicyName}' policy.",values:{agentPolicyName:y.name}}):void 0,"data-test-subj":"packagePolicyCreateSuccessToast"})}}),[p,T,e,t,x,o.toasts,y,A,u,a,P,l,s]);return{agentPolicy:y,updateAgentPolicy:w,packagePolicy:x,updatePackagePolicy:P,savedPackagePolicy:d,onSubmit:L,formState:p,setFormState:E,hasErrors:T,validationResults:M,setValidationResults:I,hasAgentPolicyError:S,setHasAgentPolicyError:O,isInitialized:f,navigateAddAgent:e=>A(e,["openEnrollmentFlyout"]),navigateAddAgentHelp:e=>A(e,["showAddAgentHelp"])}}({agentCount:B,packageInfo:_,newAgentPolicy:f,selectedPolicyTab:F,withSysMonitoring:h,queryParamsPolicyId:t,integrationToEnable:null==z?void 0:z.name}),te=Object(n.useCallback)(((e,t)=>{e===Qa.b.NEW&&(t.name&&""!==t.name.trim()&&t.namespace&&""!==t.namespace.trim()?Z(!1):Z(!0))}),[Z]),ae=Object(n.useCallback)((e=>{const t={...f,...e};b(t),te(F,t)}),[b,te,f,F]),ne=Object(n.useCallback)((e=>{M(e),te(e,f)}),[M,te,f]),le=null==q?void 0:q.id,{cancelClickHandler:ie,cancelUrl:re}=(e=>{const{from:t,pkgkey:a,agentPolicyId:l}=e,{application:{navigateToApp:i}}=Object(c.hc)(),s=Object(c.Ub)(),{getHref:r}=Object(c.Zb)();return{cancelClickHandler:Object(n.useCallback)((e=>{null!=s&&s.onCancelNavigateTo&&(e.preventDefault(),i(...s.onCancelNavigateTo))}),[s,i]),cancelUrl:Object(n.useMemo)((()=>s&&s.onCancelUrl?s.onCancelUrl:"policy"===t&&l?r("policy_details",{policyId:l}):r("integration_details_overview",{pkgkey:a})),[s,t,l,r,a])}})({from:e,pkgkey:E.pkgkey,agentPolicyId:le});Object(n.useEffect)((()=>{p&&le&&(async()=>{const{data:e}=await Object(c.w)({policyId:le});void 0!==(null==e?void 0:e.results.total)&&R(e.results.total)})()}),[le,p]);const oe=Object(n.useCallback)((({isValid:e,updatedPolicy:t})=>{H(t),K((t=>"VALID"!==t||e?t:"INVALID"))}),[H,K]),{devtoolRequest:ce,devtoolRequestDescription:ue,showDevtoolsRequest:de}=function({newAgentPolicy:e,packagePolicy:t,packageInfo:a,selectedPolicyTab:l,withSysMonitoring:i}){var s;const{showDevtoolsRequest:r}=j.b.get(),o=!V.V.includes(null!==(s=null==a?void 0:a.name)&&void 0!==s?s:"")&&r,[c,u]=Object(n.useMemo)((()=>{if(l===Qa.b.NEW){var a;const n=(null==t||null===(a=t.package)||void 0===a?void 0:a.name)===V.T;return[`${Object(w.a)(e,i&&!n)}\n\n${Object(w.b)({...t})}`,g.i18n.translate("xpack.fleet.createPackagePolicy.devtoolsRequestWithAgentPolicyDescription",{defaultMessage:"These Kibana requests create a new agent policy and a new package policy."})]}return[Object(w.b)({...t}),g.i18n.translate("xpack.fleet.createPackagePolicy.devtoolsRequestDescription",{defaultMessage:"This Kibana request creates a new package policy."})]}),[t,e,i,l]);return{showDevtoolsRequest:o,devtoolRequest:c,devtoolRequestDescription:u}}({newAgentPolicy:f,packagePolicy:U,selectedPolicyTab:F,withSysMonitoring:h,packageInfo:_}),ge=Object(n.useMemo)((()=>({from:e,cancelUrl:re,onCancel:ie,agentPolicy:q,packageInfo:_,integrationInfo:z})),[q,ie,re,e,z,_]),me=Object(n.useMemo)((()=>l.a.createElement(Qa.e,{agentPolicy:q,updateAgentPolicy:G,newAgentPolicy:f,updateNewAgentPolicy:ae,withSysMonitoring:h,updateSysMonitoring:e=>y(e),validation:k,packageInfo:_,setHasAgentPolicyError:Z,updateSelectedTab:ne,selectedAgentPolicyId:t})),[_,q,G,f,ae,k,h,ne,t,Z]),pe=Object(n.useMemo)((()=>Object($a.b)(null==_?void 0:_.assets)),[null==_?void 0:_.assets]),Ee=Object(c.kc)(null!==(i=null===(s=U.package)||void 0===s?void 0:s.name)&&void 0!==i?i:"","package-policy-create"),fe=Object(c.kc)(null!==(o=null===(m=U.package)||void 0===m?void 0:m.name)&&void 0!==o?o:"","package-policy-replace-define-step");if(fe&&Ee)throw new Error("'package-policy-create' and 'package-policy-replace-define-step' cannot both be registered as UI extensions");const be=fe&&null!=_&&_.name?ee?l.a.createElement(x.l,null,l.a.createElement(fe.Component,{agentPolicy:q,packageInfo:_,newPolicy:U,onChange:oe,validationResults:J,isEditPage:!1})):l.a.createElement(x.r,null):void 0,he=Object(n.useMemo)((()=>{var e;return L||!ee?l.a.createElement(x.r,null):_?l.a.createElement(l.a.Fragment,null,l.a.createElement(Qa.d,{agentPolicy:q,packageInfo:_,packagePolicy:U,updatePackagePolicy:H,validationResults:J,submitAttempted:"INVALID"===$}),!Ee&&l.a.createElement(Qa.c,{packageInfo:_,showOnlyIntegration:null==z?void 0:z.name,packagePolicy:U,updatePackagePolicy:H,validationResults:J,submitAttempted:"INVALID"===$}),Ee&&(null===(e=U.package)||void 0===e?void 0:e.name)&&l.a.createElement(x.l,null,l.a.createElement(Ee.Component,{newPolicy:U,onChange:oe}))):l.a.createElement("div",null)}),[ee,L,q,_,U,H,J,$,null==z?void 0:z.name,Ee,oe]),ye=[{title:g.i18n.translate("xpack.fleet.createPackagePolicy.stepConfigurePackagePolicyTitle",{defaultMessage:"Configure integration"}),"data-test-subj":"dataCollectionSetupStep",children:be||he},{title:g.i18n.translate("xpack.fleet.createPackagePolicy.stepSelectAgentPolicyTitle",{defaultMessage:"Where to add this integration?"}),children:me}];return A?l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.StepSelectPolicy.errorLoadingPackageTitle",defaultMessage:"Error loading package information"}),error:A}):l.a.createElement(Ya.a,T()({},ge,{"data-test-subj":"createPackagePolicy"}),l.a.createElement(u.EuiErrorBoundary,null,"CONFIRM"===$&&q&&l.a.createElement(S.f,{agentCount:B,agentPolicy:q,onConfirm:N,onCancel:()=>K("VALID")}),"SUBMITTED_NO_AGENTS"===$&&q&&_&&W&&l.a.createElement(Ya.b,{packageInfo:_,onConfirm:()=>Q(W),onCancel:()=>Y(W)}),"SUBMITTED_CLOUD_FORMATION"===$&&q&&W&&l.a.createElement(tn,{agentPolicy:q,packagePolicy:W,onConfirm:()=>Q(W),onCancel:()=>Y(W)}),"SUBMITTED_GOOGLE_CLOUD_SHELL"===$&&q&&W&&l.a.createElement(nn,{agentPolicy:q,packagePolicy:W,onConfirm:()=>Q(W),onCancel:()=>Y(W)}),_&&l.a.createElement(Qa.a,{pkgTitle:(null==z?void 0:z.title)||_.title,pkgkey:Object(j.s)(_),integration:null==z?void 0:z.name}),pe>0?l.a.createElement(l.a.Fragment,null,l.a.createElement($a.a,{count:pe}),l.a.createElement(u.EuiSpacer,{size:"xl"})):null,l.a.createElement(ln,{steps:ye}),l.a.createElement(u.EuiSpacer,{size:"xl"}),l.a.createElement(u.EuiSpacer,{size:"xl"}),l.a.createElement(sn,{"data-test-subj":"integrationsBottomBar"},l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},_&&("INVALID"===$||X)?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.errorOnSaveText",defaultMessage:"Your integration policy has errors. Please fix them before saving."}):null),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{color:"ghost",href:re,onClick:ie,"data-test-subj":"createPackagePolicyCancelButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.cancelButton",defaultMessage:"Cancel"}))),de?l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(x.i,{request:ce,description:ue,btnProps:{color:"ghost"}})):null,l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{onClick:()=>N(),isLoading:"LOADING"===$,disabled:"VALID"!==$||X||!J,iconType:"save",color:"primary",fill:!0,"data-test-subj":"createPackagePolicySaveButton"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.saveButton",defaultMessage:"Save and continue"})))))))))};var on=a(11);const cn="fleet-first-agent-policy",un=Object.freeze(Object(C.b)({id:cn,name:g.i18n.translate("xpack.fleet.createPackagePolicy.firstAgentPolicyNameText",{defaultMessage:"My first agent policy"})})),dn=on.m.bind(null,un),gn=e=>{const{discover:t}=Object(on.Mc)(),[a,l]=Object(n.useState)(null);return Object(n.useEffect)((()=>{(async()=>{if(t&&t.locator){const a=await t.locator.getUrl({indexPatternId:"logs-*",timeRange:{from:"now-1h",to:"now",mode:"relative"},filters:[{meta:{alias:"Recently enrolled agents",index:"logs-*"},query:{terms:{"agent.id":e}}}]});l(a)}})()}),[t,e]),a},mn=p()("h1").withConfig({displayName:"CentralTitle",componentId:"sc-ve6hfp-0"})(["text-align:center;"]),pn=({children:e})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiTitle,{size:"l"},l.a.createElement(mn,null,e)),l.a.createElement(u.EuiSpacer,{size:"xl"})),En=p()(u.EuiText).withConfig({displayName:"SubtitleText",componentId:"sc-ve6hfp-1"})(["max-width:250px;margin:0 auto;text-align:center;"]),fn=p()(u.EuiStepNumber).withConfig({displayName:"CenteredEuiStepNumber",componentId:"sc-ve6hfp-2"})(["margin:0 auto;"]),bn=e=>l.a.createElement("div",{style:{margin:"0 auto"}},l.a.createElement(u.EuiImage,e)),hn=({children:e})=>{const t=Object(u.useIsWithinMaxBreakpoint)("s");return l.a.createElement(u.EuiFlexGroup,{direction:"column",gutterSize:t?"xs":"l",alignItems:"center",justifyContent:"center",wrap:!0},e)},yn=()=>{const{http:e}=Object(c.hc)(),t=e.basePath.prepend("/plugins/fleet/assets/");return l.a.createElement(u.EuiFlexGroup,{alignItems:"center",justifyContent:"spaceEvenly",gutterSize:"none"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(hn,null,l.a.createElement(u.EuiFlexItem,null,l.a.createElement(fn,{status:"incomplete",number:1})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement("div",{style:{margin:"0 auto"}},l.a.createElement(bn,{alt:"Illustration of installing the Elastic Agent",src:t+"1_install_agent.svg"}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{textAlign:"center"},l.a.createElement("h4",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.installAgentStepTitle",defaultMessage:"Install Elastic Agent"}))),l.a.createElement(En,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.installAgentStep",defaultMessage:"Install agents on the hosts that you want to connect to Elastic."}))))),l.a.createElement(u.EuiShowFor,{sizes:["s","xs"]},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiSpacer,{size:"xl"}))),l.a.createElement(u.EuiHideFor,{sizes:["s","xs"]},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(bn,{alt:"Illustration of an arrow pointing from left to right",src:t+"arrow_right_curve_over.svg"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(hn,null,l.a.createElement(u.EuiFlexItem,null,l.a.createElement(fn,{status:"incomplete",number:2})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(bn,{alt:"Illustration of adding an integration",src:t+"2_add_integration.svg"})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{textAlign:"center"},l.a.createElement("h4",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.addIntegrationStepTitle",defaultMessage:"Add the integration"}))),l.a.createElement(En,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.addIntegrationStep",defaultMessage:"Make a few selections to finalize how Elastic receives your data."}))))),l.a.createElement(u.EuiShowFor,{sizes:["s","xs"]},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiSpacer,{size:"xl"}))),l.a.createElement(u.EuiHideFor,{sizes:["s","xs"]},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(bn,{alt:"Illustration of an arrow pointing from left to right",src:t+"arrow_right_curve_under.svg"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(hn,null,l.a.createElement(u.EuiFlexItem,null,l.a.createElement(fn,{status:"incomplete",number:3})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(bn,{alt:"Illustration of a dashboard with data",src:t+"3_confirm_data.svg"})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{textAlign:"center"},l.a.createElement("h4",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.confirmDataStepTitle",defaultMessage:"Confirm incoming data"}))),l.a.createElement(En,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.confirmDataStep",defaultMessage:"Explore and analyze the incoming data."}))))))},kn=p()("div").withConfig({displayName:"NotObscuredByBottomBar",componentId:"sc-ve6hfp-3"})(["padding-bottom:100px;"]),vn=()=>{const{docLinks:e}=Object(c.hc)();return l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceAround"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiLink,{href:e.links.fleet.elasticAgent,target:"_blank"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.learnMoreLink",defaultMessage:"Learn more about installing Elastic Agent"}))))},xn=({integrationInfo:e,packageInfo:t,isLoading:a,error:n,cancelUrl:i,cancelClickHandler:s,onNext:r})=>{if(n)return l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.errorLoadingPackageTitle",defaultMessage:"Error loading package information"}),error:n});const o=l.a.createElement(pn,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.pageTitle",defaultMessage:"Ready to add your first integration?"}));return l.a.createElement(M.c,{topContent:o},l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"xxl"}),l.a.createElement(u.EuiSpacer,{size:"xxl"}),l.a.createElement(yn,null),l.a.createElement(u.EuiSpacer,{size:"xxl"}),l.a.createElement(u.EuiSpacer,{size:"xxl"}),l.a.createElement(kn,null,l.a.createElement(vn,null)),l.a.createElement(Sn,{cancelUrl:i,cancelMessage:l.a.createElement("span",{"data-test-subj":"skipAgentInstallation"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicyBottomBar.skipAddAgentButton",defaultMessage:"Add integration only (skip agent installation)"})),cancelClickHandler:s,isLoading:a,onNext:r,noAnimation:!0,actionMessage:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.installAgentButton",defaultMessage:"Install Elastic Agent"})}),t&&l.a.createElement(Qa.a,{pkgTitle:(null==e?void 0:e.title)||t.title,pkgkey:Object(j.s)(t),integration:null==e?void 0:e.name})))},Fn=p()(u.EuiBottomBar).withConfig({displayName:"CenteredRoundedBottomBar",componentId:"sc-113t0u1-0"})(["max-width:820px;margin:0 auto;border-radius:8px 8px 0px 0px;"]),Mn=p()(Fn).withConfig({displayName:"NoAnimationCenteredRoundedBottomBar",componentId:"sc-113t0u1-1"})(["animation-delay:-99s;#stop bottom bar flying in on step change"]),In=p()("div").withConfig({displayName:"NotObscuredByBottomBar",componentId:"sc-113t0u1-2"})(["padding-bottom:100px;"]),Sn=({isLoading:e,loadingMessage:t,onNext:a,cancelClickHandler:n,cancelUrl:i,actionMessage:s,cancelMessage:r,isDisabled:o=!1,noAnimation:c=!1})=>{const g=c?Mn:Fn;return l.a.createElement(g,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{color:"ghost",size:"s",href:i,onClick:n},r||l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicyBottomBar.backButton",defaultMessage:"Go back"})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"primary",fill:!0,size:"m",isDisabled:o,isLoading:!o&&e,onClick:a},e?t||l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicyBottomBar.loading",defaultMessage:"Loading..."}):s))))},On=({onNext:e,cancelClickHandler:t,cancelUrl:a,noAnimation:n=!1})=>{const i=n?Mn:Fn;return l.a.createElement(i,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{color:"ghost",size:"s",href:a,onClick:t},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentStandaloneBottomBar.backButton",defaultMessage:"Go back"})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"primary",fill:!0,size:"m",onClick:e},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentStandaloneBottomBar.viewIncomingDataBtn",defaultMessage:"View incoming data"})))))},Tn=({pkgkey:e})=>{const t=e.includes(D.FLEET_KUBERNETES_PACKAGE),{getHref:a}=Object(on.Bc)(),{getAbsolutePath:n}=Object(on.Bc)();return l.a.createElement(Fn,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{color:"ghost",size:"s",href:a("integrations_all")},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicyBottomBar.addAnotherIntegration",defaultMessage:"Add another integration"})))),!t&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"success",fill:!0,size:"m",href:a("integration_details_assets",{pkgkey:e})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.viewDataAssetsButtonText'",defaultMessage:"View assets"}))),t&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"success",fill:!0,size:"m",href:n("/app/dashboards#/view/kubernetes-f4dc26db-1b53-4ea2-a78b-1bfab8ea267c")},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData. '",defaultMessage:"View Kubernetes metrics dashboards"})))))},wn=({troubleshootLink:e,agentIds:t,integration:a})=>{const n=gn(t);return l.a.createElement(Fn,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{color:"ghost",size:"s",href:e,iconType:"popout",target:"_blank"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.timeout.troubleshootLinkBottomBar",defaultMessage:"Troubleshooting guide"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"success",fill:!0,href:null!=n?n:""},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.timeout.discoverLogsLink",defaultMessage:"View incoming {integration} logs",values:{integration:null!=a?a:""}})))))},jn=e=>{const{packageInfo:t,integrationInfo:a,steps:n,currentStep:i,error:s}=e;if(s)return l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.errorLoadingPackageTitle",defaultMessage:"Error loading package information"}),error:s});const r=n[i].component,o=l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiTitle,{size:"l",className:"eui-textCenter"},l.a.createElement("h1",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.multiPageTitle",defaultMessage:"Set up {title} integration",values:{title:t.title}}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(An,{currentStep:i,steps:n.map((e=>e.title))}),l.a.createElement(u.EuiSpacer,{size:"xl"}));return l.a.createElement(M.c,{topContent:o,restrictHeaderWidth:866,restrictWidth:866},l.a.createElement(r,e),t&&l.a.createElement(Qa.a,{pkgTitle:(null==a?void 0:a.title)||t.title,pkgkey:Object(j.s)(t),integration:null==a?void 0:a.name}))},Cn=p()(u.EuiStepsHorizontal).withConfig({displayName:"NumberlessHorizontalSteps",componentId:"sc-opcgc5-0"})([".euiStepNumber{color:transparent;width:16px;height:16px;outline-color:#07c;}.euiStepHorizontal::before{width:calc(50% - 8px);top:32px;}.euiStepHorizontal::after{width:calc(50% - 8px);top:32px;}.euiStepHorizontal{padding:25px 16px 16px;}.euiStepHorizontal[data-step-status='incomplete'] .euiStepHorizontal__title{color:#69707d;}"]),Pn=(e,t,a)=>e===t?a?"complete":"current":e>t?"complete":"incomplete",An=({steps:e,currentStep:t=0,currentStepComplete:a=!1})=>{const n=e.map(((e,n)=>({title:e,status:Pn(t,n,a),onClick:()=>{}})));return l.a.createElement(Cn,{steps:n})};var Ln=a(141),_n=a(129);var Dn=p()(u.EuiCodeBlock).withConfig({displayName:"_StyledEuiCodeBlock",componentId:"sc-oz6m9j-1"})(["max-width:1100px;"]);const Bn=e=>{const{cancelUrl:t,onNext:a,cancelClickHandler:i,setIsManaged:s,agentPolicy:r,enrollmentAPIKey:o,fleetServerHosts:c,fleetProxy:m,enrolledAgentIds:E}=e,f=Object(on.Mc)(),{docLinks:b}=f,h=b.links.fleet.troubleshooting,y=Object(on.zc)(),[k,v]=Object(n.useState)(!1),[F,M]=Object(n.useState)(!1);if(!o)return l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.errorLoadingPackageTitle",defaultMessage:"Error loading package information"}),error:"Enrollment API key not found"});const I="kubernetes"===e.packageInfo.name?"IS_KUBERNETES_MULTIPAGE":"IS_NOT_KUBERNETES",S=Object(an.a)({apiKey:o.api_key,fleetProxy:m,fleetServerHosts:c,kibanaVersion:y}),O=[Object(_n.h)({installCommand:S,apiKeyData:{item:o},enrollToken:o.api_key,isK8s:I,selectedApiKeyId:o.id,isComplete:k||!!E.length,fullCopyButton:!0,fleetServerHost:null==c?void 0:c[0],onCopy:()=>v(!0)})];return"IS_KUBERNETES_MULTIPAGE"===I&&O.push((({isComplete:e,fullCopyButton:t,onCopy:a})=>{const[i,s]=Object(n.useState)(!1),r=p.a.pre.withConfig({displayName:"CommandCode",componentId:"sc-oz6m9j-0"})({overflow:"auto"});return{status:e?"complete":void 0,title:g.i18n.translate("xpack.fleet.agentEnrollment.stepKubernetesApplyManifest",{defaultMessage:"Run the apply command"}),children:l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.agentEnrollment.kubernetesCommandInstructions",defaultMessage:"From the directory where the manifest is downloaded, run the apply command."}),l.a.createElement(u.EuiSpacer,{size:"m"})),l.a.createElement(Dn,{onClick:()=>{a&&a()},fontSize:"m",isCopyable:!t,paddingSize:"m"},l.a.createElement(r,null,"kubectl apply -f elastic-agent-managed-kubernetes.yml")),l.a.createElement(u.EuiSpacer,{size:"s"}),t&&l.a.createElement(u.EuiCopy,{textToCopy:"kubectl apply -f elastic-agent-managed-kubernetes.yml"},(e=>l.a.createElement(u.EuiButton,{color:"primary",iconType:"copyClipboard",size:"m",onClick:()=>(e=>{e(),s(!0),a&&a()})(e)},i?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollmentInstructions.copyButtonClicked",defaultMessage:"Copied"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollmentInstructions.copyButton",defaultMessage:"Copy to clipboard"})))))}})({isComplete:F||!!E.length,fullCopyButton:!0,onCopy:()=>M(!0)})),O.push(Object(_n.a)({selectedPolicyId:null==r?void 0:r.id,troubleshootLink:h,agentCount:E.length,showLoading:!0,poll:k})),l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addIntegration.installAgentStepTitle",defaultMessage:"These steps configure and enroll the Elastic Agent in Fleet to automatically deploy updates and centrally manage the agent. As an alternative to Fleet, advanced users can run agents in {standaloneLink}.",values:{standaloneLink:l.a.createElement(u.EuiLink,{onClick:()=>s(!1)},"standalone mode")}})),l.a.createElement(u.EuiSpacer,{size:"xl"}),l.a.createElement(u.EuiSteps,{steps:O}),!!E.length&&l.a.createElement(l.a.Fragment,null,l.a.createElement(In,null),l.a.createElement(Sn,{cancelUrl:t,cancelClickHandler:i,onNext:a,actionMessage:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addFirstIntegrationSplash.addIntegrationButton",defaultMessage:"Add the integration"})})))};var Rn=a(3);const zn=e=>{const{setIsManaged:t,agentPolicy:a,cancelUrl:i,onNext:s,cancelClickHandler:r}=e,o=Object(on.Mc)(),c=Object(on.zc)(),[g,m]=Object(n.useState)(""),[p,E]=Object(n.useState)(!1),[f,b]=Object(n.useState)(!1),[h,y]=Object(n.useState)();if(Object(n.useEffect)((()=>{!async function(){try{if(null==a||!a.id)return;const e={standalone:!0,kubernetes:!1},t=await Object(on.K)(null==a?void 0:a.id,e);if(t.error)throw t.error;if(!t.data)throw new Error("No data while fetching full agent policy");y(t.data.item)}catch(e){o.notifications.toasts.addError(e,{title:"Error"})}}()}),[o.http.basePath,null==a?void 0:a.id,o.notifications.toasts]),Object(n.useEffect)((()=>{h&&m(Object(Rn.n)(h,Za.safeDump))}),[h]),!a)return l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.errorLoadingPackageTitle",defaultMessage:"Error loading package information"}),error:"Agent policy not provided"});const k=Object(an.b)(c),v=o.http.basePath.prepend(`${Rn.c.getInfoFullDownloadPath(null==a?void 0:a.id)}?standalone=true`),F=[Object(_n.d)({selectedPolicyId:null==a?void 0:a.id,yaml:g,downloadLink:v,isComplete:f,onCopy:()=>b(!0)}),Object(_n.i)({installCommand:k,isComplete:g&&p,fullCopyButton:!0,onCopy:()=>E(!0)})];return l.a.createElement(l.a.Fragment,null,l.a.createElement(Un,{setIsManaged:t}),l.a.createElement(u.EuiSpacer,{size:"xl"}),l.a.createElement(u.EuiSteps,{steps:F}),p&&l.a.createElement(l.a.Fragment,null,l.a.createElement(In,null),l.a.createElement(On,{cancelUrl:i,onNext:s,cancelClickHandler:r})))},Nn=({children:e})=>{const[t,a]=Object(n.useState)(!1);return l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",direction:"column"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween",direction:"row"},l.a.createElement(u.EuiFlexItem,null),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{size:"s",iconType:t?"arrowUp":"arrowDown",iconSide:"right",onClick:()=>a(!t),flush:"left"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createPackagePolicy.stepConfigure.advancedOptionsToggleLinkText",defaultMessage:"Advanced options"}))))),t&&l.a.createElement(u.EuiFlexItem,null,e)))},Hn=({error:e,title:t})=>l.a.createElement(x.j,{title:t||l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addIntegration.errorTitle",defaultMessage:"Error adding integration"}),error:e}),Un=({setIsManaged:e})=>l.a.createElement(u.EuiCallOut,{title:"Setting up to run Elastic Agent in standalone mode",color:"primary",iconType:"iInCircle"},l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addIntegration.standaloneWarning",defaultMessage:"Setting up integrations by running Elastic Agent in standalone mode is advanced. When possible, we recommend using {link} instead. ",values:{link:l.a.createElement(u.EuiLink,{href:"#"},"Fleet-managed agents")}})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiButton,{onClick:()=>e(!0),color:"primary"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.addIntegration.switchToManagedButton",defaultMessage:"Enroll in Fleet instead (recommended)"})));var qn=a(29),Gn=a(382),Wn=a.n(Gn),$n=a(174);const Kn=({agentIds:e,troubleshootLink:t,packageInfo:a})=>{var n;const i=gn(e);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiTitle,null,l.a.createElement("h3",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.timeout.title",defaultMessage:"Confirming data is taking longer than expected"}))),l.a.createElement(u.EuiText,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.timeout.body",defaultMessage:"If the system is not generating data, it may help to generate some to ensure data is being collected correctly. If you're having trouble, see our {troubleshootLink}, or you may check later by viewing {discoverLink}.",values:{troubleshootLink:l.a.createElement(u.EuiLink,{external:!0,href:t,target:"_blank"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.timeout.troubleshootLink",defaultMessage:"troubleshooting guide"})),discoverLink:l.a.createElement(u.EuiLink,{external:!0,href:null!=i?i:"",target:"_blank"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingData.timeout.discoverLink",defaultMessage:"{integration} logs in Discover",values:{integration:null!==(n=null==a?void 0:a.title)&&void 0!==n?n:""}}))}})),l.a.createElement(In,null),l.a.createElement(wn,{agentIds:e,troubleshootLink:t,integration:null==a?void 0:a.title}))},Vn=["agent.ephemeral_id","agent.id","elastic_agent.id","data_stream.namespace","@timestamp"],Qn=p()(u.EuiDescriptionList).withConfig({displayName:"CleanOverflowDescriptionList",componentId:"sc-6co0kl-0"})(["overflow:hidden;max-height:125px;word-break:break-all;white-space:pre-wrap;"]),Yn=p()("pre").withConfig({displayName:"CompressedPre",componentId:"sc-6co0kl-1"})(["&&&{background:none;padding:0 0;}"]),Zn=({hit:e})=>{const t=Wn()(Object(qn.getFlattenedObject)(e._source),Vn),a=Object.entries(t).map((([e,t])=>({title:`${e}:`,description:JSON.stringify(t)})));return l.a.createElement("pre",null,l.a.createElement("code",null,l.a.createElement(Qn,{listItems:a,type:"inline",align:"left",compressed:!0})))},Jn=({hit:e})=>{const t=(null==e?void 0:e._source)||{},a=(null==t?void 0:t["@timestamp"])||"-";return l.a.createElement(u.EuiText,{size:"xs"},l.a.createElement(Yn,null,a?Object(u.formatDate)(a,"MMM D, YYYY @ HH:mm:ss.SSS"):"-"))},Xn=({dataPreview:e})=>{const t=e.slice(0,5);return l.a.createElement(l.a.Fragment,null,t.map((e=>l.a.createElement("div",{id:e._id},l.a.createElement(u.EuiFlexGroup,{gutterSize:"xs"},l.a.createElement(u.EuiFlexItem,{style:{minWidth:"220px"}},l.a.createElement(Jn,{hit:e})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(Zn,{hit:e}))),l.a.createElement(u.EuiHorizontalRule,{margin:"s"})))))},el=({agentIds:e,packageInfo:t,agentDataConfirmed:a,setAgentDataConfirmed:n,troubleshootLink:i})=>{const{incomingData:s,dataPreview:r,isLoading:o,hasReachedTimeout:c}=Object($n.b)(e,!0,5),{enrolledAgents:m,numAgentsWithData:p}=Object($n.a)(s,t),E=Object(on.wc)(null==t?void 0:t.name),{guidedOnboarding:f}=Object(on.Mc)();var b;return!o&&m>0&&p>0&&(n(!0),E&&(null===(b=f.guidedOnboardingApi)||void 0===b||b.completeGuidedOnboardingForIntegration(null==t?void 0:t.name))),a?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiCallOut,{"data-test-subj":"IncomingDataConfirmedCallOut",title:g.i18n.translate("xpack.fleet.confirmIncomingDataWithPreview.title",{defaultMessage:"Incoming data received from {numAgentsWithData} enrolled { numAgentsWithData, plural, one {agent} other {agents}}.",values:{numAgentsWithData:p}}),color:"success",iconType:"check"}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiText,null,l.a.createElement("h3",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingDataWithPreview.previewTitle",defaultMessage:"Preview of incoming data:"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Xn,{dataPreview:r})):l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,null,l.a.createElement(u.EuiCallOut,{size:"m",color:"primary",iconType:u.EuiLoadingSpinner,title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingDataWithPreview.listening",defaultMessage:"Listening for incoming data from enrolled agents..."})}),l.a.createElement(u.EuiSpacer,{size:"m"}),c?l.a.createElement(Kn,{agentIds:e,troubleshootLink:i,packageInfo:t}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingDataWithPreview.loading",defaultMessage:"It might take a few minutes for the data to get to Elasticsearch. If you're not seeing any, try generating some to verify. If you're having trouble connecting, check out the {link}.",values:{link:l.a.createElement(u.EuiLink,{target:"_blank",external:!0,href:i},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollmentInstructions.troubleshootingLink",defaultMessage:"troubleshooting guide"}))}})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiSkeletonText,{lines:10}))},tl=({troubleshootLink:e})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,null,l.a.createElement(u.EuiCallOut,{size:"m",color:"primary",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingDataStandalone.title",defaultMessage:"Data preview is not available for standalone agents. "})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingDataStandalone.description",defaultMessage:"You can check for agent data in the integration asset tab. If you're having trouble seeing data, check out the {link}.",values:{link:l.a.createElement(u.EuiLink,{target:"_blank",external:!0,href:e},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.confirmIncomingDataStandalone.troubleshootingLink",defaultMessage:"troubleshooting guide"}))}})))),al={title:g.i18n.translate("xpack.fleet.createFirstPackagePolicy.installAgentStepTitle",{defaultMessage:"Install Elastic Agent"}),component:e=>{var t;const[a,i]=Object(n.useState)(e.isManaged),[s,r]=Object(n.useState)(!1),o=Object(Ln.b)((null===(t=e.agentPolicy)||void 0===t?void 0:t.id)||"",{noLowerTimeLimit:!0,pollImmediately:!0}),c=()=>{e.setEnrolledAgentIds(o),e.onNext()},u={...e,onNext:c,enrolledAgentIds:o,setIsManaged:s?i:e.setIsManaged};if(a)return l.a.createElement(Bn,u);const d={...e,onNext:c,enrolledAgentIds:o,setIsManaged:e=>{e&&r(!0),i(e)}};return l.a.createElement(zn,d)}},nl={title:g.i18n.translate("xpack.fleet.createFirstPackagePolicy.addIntegrationStepTitle",{defaultMessage:"Add the integration"}),component:e=>{var t;const{onNext:a,onBack:i,isManaged:s,setIsManaged:r,packageInfo:o,integrationInfo:m,agentPolicy:p}=e,[E,f]=Object(n.useState)(),{notifications:b}=Object(c.hc)(),[h,y]=Object(n.useState)("VALID"),[k,F]=Object(n.useState)(),M=Object(v.p)(),[I,S]=Object(n.useState)({name:"",description:"",namespace:"default",policy_id:"",enabled:!0,inputs:[]}),O=Object(n.useCallback)((e=>{const t=Object(Ja.d)({...I,...e},o,Za.safeLoad);return F(t),console.debug("Package policy validation results",t),t}),[o,I]),T=Object(n.useCallback)((e=>{const t={...I,...e};S(t),console.debug("Package policy updated",t);const a=O(t),n=t.package,l=!!a&&Object(Ja.f)(a);y(n&&!l?"VALID":"INVALID")}),[I,O]),w=Object(n.useCallback)((async({force:e=!1}={})=>{const t=!!k&&Object(Ja.f)(k);if("VALID"===h&&t)return void y("INVALID");y("LOADING");const{error:n}=await(async({newPackagePolicy:e,force:t})=>{y("LOADING");const{policy:a,forceCreateNeeded:n}=await Object(Xa.a)(e),l=await Object(c.l)({...a,force:n||t});return y("SUBMITTED"),l})({newPackagePolicy:I,force:e});if(n){if(Object(Rn.z)(n))return void(await M(o)?w({force:!0}):y("VALID"));b.toasts.addError(n,{title:"Error"}),y("VALID")}else a()}),[k,h,I,b.toasts,M,o,a]);Object(n.useEffect)((()=>{(async()=>{if(!p)return;const{packagePolicy:e,error:t}=await(async(e,t,a)=>{const{data:n,error:l}=await Object(c.H)({perPage:V.pb,page:1,kuery:`${B.s}.package.name:${t.name}`}),i={name:Object(se.y)(t.name,null==n?void 0:n.items),description:"",namespace:"default",policy_id:e,enabled:!0,inputs:[]};return{packagePolicy:Object(j.r)(t,e,i.namespace,i.name,i.description,a),error:l}})(p.id,o,null==m?void 0:m.name);t&&f(t),T(e)})()}),[]);const C=Object(c.kc)(null!==(t=o.name)&&void 0!==t?t:"","package-policy-create-multi-step"),P=Object(n.useMemo)((()=>C&&l.a.createElement(x.l,null,l.a.createElement(C.Component,null))),[C]),A=Object(n.useMemo)((()=>{if("endpoint"!==o.name)return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"l"}),l.a.createElement(Qa.c,{packageInfo:o,showOnlyIntegration:null==m?void 0:m.name,packagePolicy:I,updatePackagePolicy:T,validationResults:k,submitAttempted:"INVALID"===h,noTopRule:!0}),k&&l.a.createElement(Nn,null,l.a.createElement(Qa.d,{packageInfo:o,packagePolicy:I,updatePackagePolicy:T,validationResults:k,submitAttempted:"INVALID"===h,noAdvancedToggle:!0})))}),[h,null==m?void 0:m.name,o,I,T,k]);return p?E?l.a.createElement(Hn,{error:E}):l.a.createElement(l.a.Fragment,null,s?null:l.a.createElement(Un,{setIsManaged:r}),A,P,l.a.createElement(In,null),l.a.createElement(Sn,{cancelClickHandler:s?i:()=>r(!0),onNext:w,isLoading:"LOADING"===h,isDisabled:"INVALID"===h,loadingMessage:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createFirstPackagePolicy.savingPackagePolicy",defaultMessage:"Saving policy..."}),actionMessage:s?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createFirstPackagePolicy.confirmIncomingDataButton",defaultMessage:"Confirm incoming data"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.createFirstPackagePolicy.installAgentButton",defaultMessage:"Save and continue"})})):l.a.createElement(Hn,{error:g.i18n.translate("xpack.fleet.addIntegration.noAgentPolicy",{defaultMessage:"Error creating agent policy."})})}},ll={title:g.i18n.translate("xpack.fleet.createFirstPackagePolicy.confirmDataStepTitle",{defaultMessage:"Confirm incoming data"}),component:e=>{const{enrolledAgentIds:t,packageInfo:a,isManaged:i}=e,s=Object(c.hc)(),[r,o]=Object(n.useState)(!1),{docLinks:u}=s,d=u.links.fleet.troubleshooting,g=l.a.createElement(l.a.Fragment,null,l.a.createElement(In,null),l.a.createElement(Tn,{pkgkey:`${a.name}-${a.version}`}));return i?l.a.createElement(l.a.Fragment,null,l.a.createElement(el,{agentIds:t,packageInfo:a,agentDataConfirmed:r,setAgentDataConfirmed:o,troubleshootLink:d}),!!r&&g):l.a.createElement(l.a.Fragment,null,l.a.createElement(tl,{troubleshootLink:d}),g)}},il=[al,nl,ll],sl=[nl,al,ll],rl=({queryParamsPolicyId:e,prerelease:t})=>{const{params:a}=Object(r.useRouteMatch)(),{pkgkey:i,policyId:s,integration:o}=a,{pkgName:u,pkgVersion:d}=Object(se.X)(i),[g,m]=Object(n.useState)(!0),[p,E]=Object(n.useState)(0),[f,b]=Object(n.useState)(!0),{getHref:h}=Object(c.Zb)(),[y,k]=Object(n.useState)([]),v=s||e,{data:x,error:F,isLoading:M}=Object(c.Pb)(u,d,{prerelease:t,full:!0}),{agentPolicy:I,enrollmentAPIKey:S,error:O,isLoading:T}=function(e){const[t,a]=Object(n.useState)({isLoading:!0});return Object(n.useEffect)((()=>{(async()=>{var t;const n=e||cn,{data:l,error:i}=await(async e=>{var t;let a,n;try{a=await Object(on.J)(e),a.error&&(n=a.error)}catch(e){n=e}return n&&404!==n.statusCode?{error:n}:{data:null===(t=a)||void 0===t?void 0:t.data}})(n),s=null==l?void 0:l.item;if(e&&!s)return void a({isLoading:!1,error:new Error(`Agent policy ${n} not found`)});let r;if(i)return void a({isLoading:!1,error:i});if(!s){const{data:e,error:t}=await dn();if(t)return void a({isLoading:!1,error:t});r=e.item}const o=s||r,{data:c,error:u}=await Object(on.H)({page:1,perPage:1,kuery:`policy_id:${n}`});if(u)return void a({isLoading:!1,error:u});if(!c||null===(t=c.items)||void 0===t||!t.length)return void a({isLoading:!1,error:new Error(`No enrollment API key found for policy ${n}`)});const d=c.items[0];a({isLoading:!1,created:!!r,agentPolicy:o,enrollmentAPIKey:d})})()}),[e]),t}(v),w=Object(n.useMemo)((()=>null==x?void 0:x.item),[x]),j=Object(n.useMemo)((()=>{var e;if(o)return null==w||null===(e=w.policy_templates)||void 0===e?void 0:e.find((e=>e.name===o))}),[null==w?void 0:w.policy_templates,o]),{fleetServerHosts:C,fleetProxy:P,isLoadingInitialRequest:A}=Object(c.Bb)(I),L=h("add_integration_to_policy",{pkgkey:i,useMultiPageLayout:!1,...o?{integration:o}:{},...v?{agentPolicyId:v}:{}});if(g||!w)return l.a.createElement(xn,{isLoading:M||A||T,error:F||O,integrationInfo:j,packageInfo:w,cancelUrl:L,onNext:()=>{m(!1)}});const _=f?il:sl;return l.a.createElement(jn,{fleetServerHosts:C,fleetProxy:P,agentPolicy:I,enrollmentAPIKey:S,currentStep:p,steps:_,packageInfo:w,integrationInfo:j,cancelUrl:L,onNext:()=>{p!==_.length-1&&E(p+1)},onBack:()=>{0!==p&&E(p-1)},isManaged:f,setIsManaged:e=>{b(e),E(0)},setEnrolledAgentIds:k,enrolledAgentIds:y})},ol=()=>{const{search:e}=Object(r.useLocation)(),{params:t}=Object(r.useRouteMatch)(),a=Object(n.useMemo)((()=>new URLSearchParams(e)),[e]),i=Object(n.useMemo)((()=>a.has("useMultiPageLayout")),[a]),s=Object(n.useMemo)((()=>{var e;return null!==(e=a.get("policyId"))&&void 0!==e?e:void 0}),[a]),[o,u]=l.a.useState(!1),{data:d}=Object(c.Sb)();Object(n.useEffect)((()=>{const e=Boolean(null==d?void 0:d.item.prerelease_integrations_enabled);null!=d&&d.item&&u(e)}),[null==d?void 0:d.item]);const g={from:"policyId"in t||s?"policy":"package",queryParamsPolicyId:s,prerelease:o};return i?l.a.createElement(rl,g):l.a.createElement(rn,g)},cl=({apiKeyId:e,length:t,sendGetAPIKey:a,tokenGetter:i})=>{const{euiTheme:s}=Object(u.useEuiTheme)(),{notifications:r}=Object(on.Mc)(),[o,c]=Object(n.useState)("HIDDEN"),[d,m]=Object(n.useState)(),p=Object(n.useMemo)((()=>"•".repeat(t)),[t]);return l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"xs"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(ul,{color:"subdued",size:"xs","data-test-subj":"apiKeyField",$_css:s.font.familyCode},"VISIBLE"===o?d:p)),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiToolTip,{content:"VISIBLE"===o?g.i18n.translate("xpack.fleet.enrollmentTokensList.hideTokenButtonLabel",{defaultMessage:"Hide token"}):g.i18n.translate("xpack.fleet.enrollmentTokensList.showTokenButtonLabel",{defaultMessage:"Show token"})},l.a.createElement(u.EuiButtonIcon,{"aria-label":"VISIBLE"===o?g.i18n.translate("xpack.fleet.enrollmentTokensList.hideTokenButtonLabel",{defaultMessage:"Hide token"}):g.i18n.translate("xpack.fleet.enrollmentTokensList.showTokenButtonLabel",{defaultMessage:"Show token"}),color:"text",onClick:async()=>{if("VISIBLE"===o)c("HIDDEN");else if("HIDDEN"===o)try{c("LOADING");const t=await a(e);if(t.error)throw t.error;m(i(t)),c("VISIBLE")}catch(e){r.toasts.addError(e,{title:"Error"}),c("HIDDEN")}},iconType:"VISIBLE"===o?"eyeClosed":"eye","data-test-subj":"showHideTokenButton"}))))};var ul=p()(u.EuiText).withConfig({displayName:"_StyledEuiText",componentId:"sc-hm2aoi-0"})(["font-family:",";"],(e=>e.$_css)),dl=a(146);const gl=e=>{const{onCancel:t,onConfirm:a,enrollmentKey:n}=e;return l.a.createElement(u.EuiConfirmModal,{title:g.i18n.translate("xpack.fleet.enrollmentTokenDeleteModal.title",{defaultMessage:"Revoke enrollment token"}),onCancel:t,onConfirm:a,cancelButtonText:g.i18n.translate("xpack.fleet.enrollmentTokenDeleteModal.cancelButton",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.enrollmentTokenDeleteModal.deleteButton",{defaultMessage:"Revoke enrollment token"}),defaultFocusedButton:"confirm",buttonColor:"danger"},l.a.createElement(u.EuiCallOut,{title:g.i18n.translate("xpack.fleet.enrollmentTokenDeleteModal.description",{defaultMessage:"Are you sure you want to revoke {keyName}? New agents will no longer be able to be enrolled using this token.",values:{keyName:n.name}}),color:"danger"}))},ml=({apiKey:e,refresh:t})=>{const{notifications:a}=Object(c.hc)(),[i,s]=Object(n.useState)("CONFIRM_HIDDEN");return l.a.createElement(l.a.Fragment,null,"CONFIRM_VISIBLE"===i&&l.a.createElement(gl,{enrollmentKey:e,onCancel:()=>s("CONFIRM_HIDDEN"),onConfirm:async()=>{try{const t=await Object(c.q)(e.id);if(t.error)throw t.error}catch(e){a.toasts.addError(e,{title:"Error"})}s("CONFIRM_HIDDEN"),t()}}),l.a.createElement(u.EuiToolTip,{content:g.i18n.translate("xpack.fleet.enrollmentTokensList.revokeTokenButtonLabel",{defaultMessage:"Revoke token"})},l.a.createElement(u.EuiButtonIcon,{"data-test-subj":"enrollmentTokenTable.revokeBtn","aria-label":g.i18n.translate("xpack.fleet.enrollmentTokensList.revokeTokenButtonLabel",{defaultMessage:"Revoke token"}),onClick:()=>s("CONFIRM_VISIBLE"),iconType:"trash",color:"danger"})))},pl=()=>{var e,t,a;Object(c.ub)("enrollment_tokens");const[i,s]=Object(n.useState)(!1),[r,o]=Object(n.useState)(""),{pagination:m,setPagination:p,pageSizeOptions:E}=Object(c.bc)(),f=Object(c.Ib)({page:m.currentPage,perPage:m.pageSize,kuery:""!==r.trim()?r:void 0}),b=Object(c.Fb)({page:1,perPage:F.p}),h=b.data?b.data.items:[],y=h.reduce(((e,t)=>(e[t.id]=t,e)),{}),k=null!==(e=null==f||null===(t=f.data)||void 0===t?void 0:t.total)&&void 0!==e?e:0,v=(null==f||null===(a=f.data)||void 0===a?void 0:a.items.filter((e=>{if(!h.length||!e.policy_id)return!1;const t=y[e.policy_id];return!(null!=t&&t.is_managed)})))||[],I=[{field:"name",name:g.i18n.translate("xpack.fleet.enrollmentTokensList.nameTitle",{defaultMessage:"Name"}),render:e=>l.a.createElement("span",{className:"eui-textTruncate",title:e},e)},{field:"id",name:g.i18n.translate("xpack.fleet.enrollmentTokensList.secretTitle",{defaultMessage:"Secret"}),width:"215px",render:e=>l.a.createElement(cl,{apiKeyId:e,sendGetAPIKey:c.D,tokenGetter:e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.item.api_key},length:60})},{field:"policy_id",name:g.i18n.translate("xpack.fleet.enrollmentTokensList.policyTitle",{defaultMessage:"Agent policy"}),render:e=>{const t=y[e],a=t?t.name:e;return l.a.createElement("span",{className:"eui-textTruncate",title:a},a)}},{field:"created_at",name:g.i18n.translate("xpack.fleet.enrollmentTokensList.createdAtTitle",{defaultMessage:"Created on"}),width:"150px",render:e=>e?l.a.createElement(d.FormattedDate,{year:"numeric",month:"short",day:"2-digit",value:e}):null},{field:"active",name:g.i18n.translate("xpack.fleet.enrollmentTokensList.activeTitle",{defaultMessage:"Active"}),width:"70px",align:"center",render:e=>l.a.createElement(u.EuiIcon,{size:"m",color:e?"success":"danger",type:"dot"})},{field:"actions",name:g.i18n.translate("xpack.fleet.enrollmentTokensList.actionsTitle",{defaultMessage:"Actions"}),width:"70px",render:(e,t)=>{const a=h.find((e=>e.id===t.policy_id));return t.active&&!(null!=a&&a.is_managed)&&l.a.createElement(ml,{apiKey:t,refresh:()=>f.resendRequest()})}}],S=f.isLoading&&f.isInitialRequest||b.isLoading&&b.isInitialRequest;return l.a.createElement(M.a,{section:"enrollment_tokens"},i&&l.a.createElement(x.s,{agentPolicies:h,onClose:e=>{s(!1),f.resendRequest()}}),l.a.createElement(u.EuiText,{color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollmentTokensList.pageDescription",defaultMessage:"Create and revoke enrollment tokens. An enrollment token enables one or more agents to enroll in Fleet and send data."})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{alignItems:"center"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(dl.a,{value:r,onChange:e=>{p({...m,currentPage:1}),o(e)},indexPattern:F.e,fieldPrefix:F.g,dataTestSubj:"enrollmentKeysList.queryInput"})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{"data-test-subj":"createEnrollmentTokenButton",fill:!0,iconType:"plusInCircle",onClick:()=>s(!0)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollmentTokensList.newKeyButton",defaultMessage:"Create enrollment token"})))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiBasicTable,{"data-test-subj":"enrollmentTokenListTable",loading:S,hasActions:!0,noItemsMessage:S?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollemntAPIKeyList.loadingTokensMessage",defaultMessage:"Loading enrollment tokens..."}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.enrollemntAPIKeyList.emptyMessage",defaultMessage:"No enrollment tokens found."}),items:k?v:[],itemId:"id",columns:I,pagination:{pageIndex:m.currentPage-1,pageSize:m.pageSize,totalItemCount:k,pageSizeOptions:E},onChange:({page:e})=>{const t={...m,currentPage:e.index+1,pageSize:e.size};p(t)}}))};var El=a(175);const fl=g.i18n.translate("xpack.fleet.uninstallTokenList.policyIdTitle",{defaultMessage:"Policy ID"}),bl=g.i18n.translate("xpack.fleet.uninstallTokenList.createdAtTitle",{defaultMessage:"Created at"}),hl=g.i18n.translate("xpack.fleet.uninstallTokenList.tokenTitle",{defaultMessage:"Token"}),yl=g.i18n.translate("xpack.fleet.uninstallTokenList.actionsTitle",{defaultMessage:"Actions"}),kl=g.i18n.translate("xpack.fleet.uninstallTokenList.viewUninstallCommandLabel",{defaultMessage:"View uninstall command"}),vl=g.i18n.translate("xpack.fleet.uninstallTokenList.searchByPolicyPlaceholder",{defaultMessage:"Search by policy ID"}),xl=({policyId:e})=>l.a.createElement(u.EuiText,{size:"s",className:"eui-textTruncate",title:e,"data-test-subj":"uninstallTokensPolicyIdField"},e),Fl=({onClick:e})=>l.a.createElement(u.EuiToolTip,{content:kl},l.a.createElement(u.EuiButtonIcon,{"data-test-subj":"uninstallTokensViewCommandButton","aria-label":kl,onClick:e,iconType:"inspect",color:"text"})),Ml=({isLoading:e})=>e?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.uninstallTokenList.loadingTokensMessage",defaultMessage:"Loading uninstall tokens..."}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.uninstallTokenList.emptyMessage",defaultMessage:"No uninstall tokens found."}),Il=()=>{var e,t;Object(c.ub)("uninstall_tokens");const[a,i]=Object(n.useState)(""),[s,r]=Object(n.useState)(null),{pagination:o,setPagination:g,pageSizeOptions:m}=Object(c.bc)(),{isLoading:p,data:E}=Object(El.c)({perPage:o.pageSize,page:o.currentPage,policyId:a}),f=null!==(e=null==E?void 0:E.items)&&void 0!==e?e:[],b=null!==(t=null==E?void 0:E.total)&&void 0!==t?t:0,h=Object(n.useMemo)((()=>[{field:"policy_id",name:fl,render:e=>l.a.createElement(xl,{policyId:e})},{field:"created_at",name:bl,width:"130px",render:e=>e?l.a.createElement(d.FormattedDate,{year:"numeric",month:"short",day:"2-digit",value:e}):null},{field:"id",name:hl,width:"300px",render:e=>l.a.createElement(cl,{apiKeyId:e,sendGetAPIKey:El.a,tokenGetter:e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.item.token},length:32})},{field:"actions",name:yl,align:"center",width:"70px",render:(e,{id:t})=>l.a.createElement(Fl,{onClick:()=>r(t)})}]),[]),y=Object(n.useCallback)((({page:e})=>{g((t=>({...t,currentPage:e.index+1,pageSize:e.size})))}),[g]),k=Object(n.useCallback)((e=>{i(e),g((e=>({...e,currentPage:1})))}),[g]);return l.a.createElement(M.a,{section:"uninstall_tokens"},s&&l.a.createElement(x.y,{onClose:()=>r(null),target:"agent",uninstallTokenId:s}),l.a.createElement(u.EuiText,{color:"subdued",size:"s"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.uninstallTokenList.pageDescription",defaultMessage:"Uninstall token allows you to get the uninstall command if you need to uninstall the Agent/Endpoint on the Host."})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFieldSearch,{onSearch:k,incremental:!0,fullWidth:!0,placeholder:vl,"data-test-subj":"uninstallTokensPolicyIdSearchInput"}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiBasicTable,{"data-test-subj":"uninstallTokenListTable",items:f,columns:h,itemId:"id",loading:p,pagination:{pageIndex:o.currentPage-1,pageSize:o.pageSize,totalItemCount:b,pageSizeOptions:m},onChange:y,noItemsMessage:l.a.createElement(Ml,{isLoading:p}),hasActions:!0}),l.a.createElement(u.EuiSpacer,{size:"xl"}))},Sl=p()(u.EuiFlexItem).withConfig({displayName:"NameFlexItemWithMaxWidth",componentId:"sc-1t6qzy1-0"})(["max-width:250px;"]),Ol=p()(u.EuiFlexGroup).withConfig({displayName:"FlexGroupWithMinWidth",componentId:"sc-1t6qzy1-1"})(["min-width:0px;"]),Tl=({fleetServerHosts:e,deleteFleetServerHost:t})=>{const{getHref:a}=Object(c.Zb)(),i=Object(n.useMemo)((()=>[{render:e=>l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"xs"},l.a.createElement(Sl,{grow:!1},l.a.createElement("p",{title:e.name,className:"eui-textTruncate"},e.name)),e.is_preconfigured&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiIconTip,{content:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.managedTooltip",{defaultMessage:"This Fleet server host is managed outside of Fleet. Please refer to your kibana config file for more info."}),type:"lock",size:"m",color:"subdued"}))),width:"288px",name:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.nameColumnTitle",{defaultMessage:"Name"})},{truncateText:!0,field:"host_urls",render:e=>l.a.createElement(Ol,{direction:"column",gutterSize:"xs"},e.map((e=>l.a.createElement(u.EuiFlexItem,{key:e},l.a.createElement("p",{title:e,className:"eui-textTruncate"},e))))),name:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.hostUrlsColumnTitle",{defaultMessage:"Host URLs"})},{render:e=>e.is_default?l.a.createElement(u.EuiIcon,{type:"check","data-test-subj":"fleetServerHostTable.defaultIcon"}):null,width:"200px",name:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.defaultColumnTitle",{defaultMessage:"Default"})},{width:"68px",render:e=>{const n=!e.is_default&&!e.is_preconfigured;return l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},n&&l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"trash",onClick:()=>t(e),title:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.deleteButtonTitle",{defaultMessage:"Delete"}),"data-test-subj":"fleetServerHostsTable.delete.btn"})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"pencil",href:a("settings_edit_fleet_server_hosts",{itemId:e.id}),title:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.editButtonTitle",{defaultMessage:"Edit"}),"data-test-subj":"fleetServerHostsTable.edit.btn"})))},name:g.i18n.translate("xpack.fleet.settings.fleetServerHostsTable.actionsColumnTitle",{defaultMessage:"Actions"})}]),[a,t]);return l.a.createElement(u.EuiBasicTable,{columns:i,items:e})},wl=({fleetServerHosts:e,deleteFleetServerHost:t})=>{var a;const{docLinks:n}=Object(c.hc)(),{getHref:i}=Object(c.Zb)(),s=!0!==(null===(a=Object(c.wb)().internal)||void 0===a?void 0:a.fleetServerStandalone);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h4",{"data-test-subj":"fleetServerHostHeader"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostSectionTitle",defaultMessage:"Fleet server hosts"}))),l.a.createElement(u.EuiSpacer,{size:"xs"}),l.a.createElement(u.EuiText,{color:"subdued",size:"m"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostSectionSubtitle",defaultMessage:"Specify the URLs that your agents will use to connect to a Fleet Server. If multiple URLs exist, Fleet will show the first provided URL for enrollment purposes. For more information, see the {guideLink} .",values:{guideLink:l.a.createElement(u.EuiLink,{href:n.links.fleet.guide,target:"_blank",external:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetUserGuideLink",defaultMessage:"Fleet and Elastic Agent Guide"}))}})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Tl,{fleetServerHosts:e,deleteFleetServerHost:t}),s&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiButtonEmpty,{iconType:"plusInCircle",href:i("settings_create_fleet_server_hosts"),"data-test-subj":"settings.fleetServerHosts.addFleetServerHostBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostCreateButtonLabel",defaultMessage:"Add Fleet Server"}))),l.a.createElement(u.EuiSpacer,{size:"m"}))},jl=l.a.memo((({output:e})=>{const t=Object(n.useMemo)((()=>{const t=[];return e.is_default&&t.push(l.a.createElement(Cl,{key:"default-output"})),e.is_default_monitoring&&t.push(l.a.createElement(Pl,{key:"default-monitoring-output"})),t}),[e]);return l.a.createElement(u.EuiBadgeGroup,{gutterSize:"xs"},t.map(((e,t)=>e)))})),Cl=()=>l.a.createElement(u.EuiBadge,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.outputs.defaultOutputBadgeTitle",defaultMessage:"Agent integrations"})),Pl=()=>l.a.createElement(u.EuiBadge,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.outputs.defaultMonitoringOutputBadgeTitle",defaultMessage:"Agent monitoring"})),Al=p()(u.EuiFlexItem).withConfig({displayName:"NameFlexItemWithMaxWidth",componentId:"sc-uvxtm0-0"})(["max-width:250px;"]),Ll=p()(u.EuiFlexGroup).withConfig({displayName:"FlexGroupWithMinWidth",componentId:"sc-uvxtm0-1"})(["min-width:0px;"]),_l=({outputs:e,deleteOutput:t})=>{const{getHref:a}=Object(c.Zb)(),i=Object(n.useMemo)((()=>[{render:e=>l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"xs"},l.a.createElement(Al,{grow:!1},l.a.createElement("p",{title:e.name,className:"eui-textTruncate"},e.name)),e.is_preconfigured&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiIconTip,{content:g.i18n.translate("xpack.fleet.settings.outputsTable.managedTooltip",{defaultMessage:"This output is managed outside of Fleet."}),type:"lock",size:"m",color:"subdued"}))),width:"288px",name:g.i18n.translate("xpack.fleet.settings.outputsTable.nameColomnTitle",{defaultMessage:"Name"})},{width:"172px",render:e=>{return"elasticsearch"===(t=e.type)?g.i18n.translate("xpack.fleet.settings.outputsTable.elasticsearchTypeLabel",{defaultMessage:"Elasticsearch"}):t;var t},name:g.i18n.translate("xpack.fleet.settings.outputsTable.typeColomnTitle",{defaultMessage:"Type"})},{truncateText:!0,render:e=>l.a.createElement(Ll,{direction:"column",gutterSize:"xs"},(e.hosts||[]).map((e=>l.a.createElement(u.EuiFlexItem,{key:e},l.a.createElement("p",{title:e,className:"eui-textTruncate"},e))))),name:g.i18n.translate("xpack.fleet.settings.outputsTable.hostColomnTitle",{defaultMessage:"Hosts"})},{render:e=>l.a.createElement(jl,{output:e}),width:"200px",name:g.i18n.translate("xpack.fleet.settings.outputSection.defaultColomnTitle",{defaultMessage:"Default"})},{width:"68px",render:e=>{const n=!e.is_default&&!e.is_default_monitoring&&!e.is_preconfigured;return l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},n&&l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"trash",onClick:()=>t(e),title:g.i18n.translate("xpack.fleet.settings.outputSection.deleteButtonTitle",{defaultMessage:"Delete"})})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"pencil",href:a("settings_edit_outputs",{outputId:e.id}),title:g.i18n.translate("xpack.fleet.settings.outputSection.editButtonTitle",{defaultMessage:"Edit"}),"data-test-subj":"editOutputBtn"})))},name:g.i18n.translate("xpack.fleet.settings.outputSection.actionsColomnTitle",{defaultMessage:"Actions"})}]),[t,a]);return l.a.createElement(u.EuiBasicTable,{columns:i,items:e})},Dl=({outputs:e,deleteOutput:t})=>{const{getHref:a}=Object(c.Zb)();return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h4",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.outputSectionTitle",defaultMessage:"Outputs"}))),l.a.createElement(u.EuiSpacer,{size:"xs"}),l.a.createElement(u.EuiText,{color:"subdued",size:"m"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.outputSectionSubtitle",defaultMessage:"Specify where agents will send data."})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(_l,{outputs:e,deleteOutput:t}),l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiButtonEmpty,{iconType:"plusInCircle",href:a("settings_create_outputs"),"data-test-subj":"addOutputBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.outputCreateButtonLabel",defaultMessage:"Add output"})))},Bl=p()(u.EuiFlexItem).withConfig({displayName:"NameFlexItemWithMaxWidth",componentId:"sc-xsf6c1-0"})(["max-width:250px;"]),Rl=p()(u.EuiFlexGroup).withConfig({displayName:"FlexGroupWithMinWidth",componentId:"sc-xsf6c1-1"})(["min-width:0px;"]),zl=({downloadSources:e,deleteDownloadSource:t})=>{const{getHref:a}=Object(c.Zb)(),i=Object(n.useMemo)((()=>[{render:e=>l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"xs"},l.a.createElement(Bl,{grow:!1},l.a.createElement("p",{title:e.name,className:"eui-textTruncate","data-test-subj":"editDownloadSourceTable.name"},e.name))),width:"288px",name:g.i18n.translate("xpack.fleet.settings.downloadSourcesTable.nameColumnTitle",{defaultMessage:"Name"})},{truncateText:!0,render:e=>l.a.createElement(Rl,{direction:"column",gutterSize:"xs"},l.a.createElement(u.EuiFlexItem,{key:e.host},l.a.createElement("p",{title:e.host,className:"eui-textTruncate","data-test-subj":"editDownloadSourceTable.host"},e.host))),name:g.i18n.translate("xpack.fleet.settings.downloadSourcesTable.hostColumnTitle",{defaultMessage:"Host"})},{render:e=>e.is_default?l.a.createElement(u.EuiIcon,{type:"check","data-test-subj":"editDownloadSourceTable.defaultIcon"}):null,width:"200px",name:g.i18n.translate("xpack.fleet.settings.downloadSourcesTable.defaultColumnTitle",{defaultMessage:"Default"})},{width:"68px",render:e=>{const n=!e.is_default;return l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},n&&l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"trash",onClick:()=>t(e),title:g.i18n.translate("xpack.fleet.settings.downloadSourceSection.deleteButtonTitle",{defaultMessage:"Delete"}),"data-test-subj":"editDownloadSourceTable.delete.btn"})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"pencil",href:a("settings_edit_download_sources",{downloadSourceId:e.id}),title:g.i18n.translate("xpack.fleet.settings.downloadSourceSection.editButtonTitle",{defaultMessage:"Edit"}),"data-test-subj":"editDownloadSourceTable.edit.btn"})))},name:g.i18n.translate("xpack.fleet.settings.downloadSourceSection.actionsColumnTitle",{defaultMessage:"Actions"})}]),[t,a]);return l.a.createElement(u.EuiBasicTable,{columns:i,items:e,"data-test-subj":"AgentDownloadSourcesTable"})},Nl=({downloadSources:e,deleteDownloadSource:t})=>{const{getHref:a}=Object(c.Zb)();return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h4",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.downloadSourcesSection.Title",defaultMessage:"Agent Binary Download"}))),l.a.createElement(u.EuiSpacer,{size:"xs"}),l.a.createElement(u.EuiText,{color:"subdued",size:"m"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.downloadSourcesSection.Subtitle",defaultMessage:"Specify where the agents will download their binary from. Checked default will apply to all policies unless overwritten."})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(zl,{downloadSources:e,deleteDownloadSource:t}),l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiButtonEmpty,{iconType:"plusInCircle",href:a("settings_create_download_sources"),"data-test-subj":"addDownloadSourcesBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.downloadSourcesSection.CreateButtonLabel",defaultMessage:"Add agent binary source"})))},Hl=p()(u.EuiFlexItem).withConfig({displayName:"NameFlexItemWithMaxWidth",componentId:"sc-czjc9c-0"})(["max-width:250px;"]),Ul=({proxies:e,deleteFleetProxy:t})=>{const{getHref:a}=Object(c.Zb)(),i=Object(n.useMemo)((()=>[{render:e=>l.a.createElement(u.EuiFlexGroup,{alignItems:"center",gutterSize:"xs"},l.a.createElement(Hl,{grow:!1},l.a.createElement("p",{title:e.name,className:"eui-textTruncate","data-test-subj":"fleetProxiesTable.name"},e.name)),e.is_preconfigured&&l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiIconTip,{content:g.i18n.translate("xpack.fleet.settings.fleetProxiesTable.managedTooltip",{defaultMessage:"This proxy is managed outside of Fleet. Please refer to your kibana config file for more info."}),type:"lock",size:"m",color:"subdued"}))),width:"288px",name:g.i18n.translate("xpack.fleet.settings.fleetProxiesTable.nameColumnTitle",{defaultMessage:"Name"})},{truncateText:!0,field:"url",name:g.i18n.translate("xpack.fleet.settings.fleetProxiesTable.urlColumnTitle",{defaultMessage:"Url"})},{width:"68px",render:e=>{const n=!e.is_preconfigured;return l.a.createElement(u.EuiFlexGroup,{gutterSize:"s",justifyContent:"flexEnd"},l.a.createElement(u.EuiFlexItem,{grow:!1},n&&l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"trash",onClick:()=>t(e),title:g.i18n.translate("xpack.fleet.settings.fleetProxiesTable.deleteButtonTitle",{defaultMessage:"Delete"}),"data-test-subj":"fleetProxiesTable.delete.btn"})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonIcon,{color:"text",iconType:"pencil",href:a("settings_edit_fleet_proxy",{itemId:e.id}),title:g.i18n.translate("xpack.fleet.settings.fleetProxiesTable.editButtonTitle",{defaultMessage:"Edit"}),"data-test-subj":"fleetProxiesTable.edit.btn"})))},name:g.i18n.translate("xpack.fleet.settings.fleetProxiesTable.actionsColumnTitle",{defaultMessage:"Actions"})}]),[t,a]);return l.a.createElement(u.EuiBasicTable,{columns:i,items:e,"data-test-subj":"fleetProxiesTable"})},ql=({proxies:e,deleteFleetProxy:t})=>{const{getHref:a}=Object(c.Zb)();return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFlexGroup,{gutterSize:"xs"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h4",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxiesSection.title",defaultMessage:"Proxies"})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiBetaBadge,{label:"beta"}))),l.a.createElement(u.EuiText,{color:"subdued",size:"m"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxiesSection.subtitle",defaultMessage:"Specify any proxy URLs to be used in Fleet servers or Outputs."})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Ul,{proxies:e,deleteFleetProxy:t}),l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiButtonEmpty,{iconType:"plusInCircle",href:a("settings_create_fleet_proxy"),"data-test-subj":"addProxyBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxiesSection.CreateButtonLabel",defaultMessage:"Add proxy"})))},Gl=({outputs:e,proxies:t,fleetServerHosts:a,deleteOutput:n,deleteFleetServerHost:i,downloadSources:s,deleteDownloadSource:r,deleteFleetProxy:o})=>{var d;const g=!0!==(null===(d=Object(c.wb)().internal)||void 0===d?void 0:d.disableProxies);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(wl,{fleetServerHosts:a,deleteFleetServerHost:i}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Dl,{outputs:e,deleteOutput:n}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Nl,{downloadSources:s,deleteDownloadSource:r}),g&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(ql,{proxies:t,deleteFleetProxy:o})))};var Wl=a(109),$l=a(120);const Kl=670,Vl=({label:e,inputProps:t,placeholder:a,dataTestSubj:n})=>l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:e},t.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":n,fullWidth:!0},t.props,{placeholder:a}))),Ql=({label:e,inputProps:t,placeholder:a,dataTestSubj:n})=>l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:e},t.formRowProps),l.a.createElement(u.EuiTextArea,T()({fullWidth:!0,rows:5,"data-test-subj":n},t.props,{placeholder:a})));var Yl=a(169);const Zl=({onClose:e,fleetServerHost:t,proxies:a})=>{const{docLinks:i}=Object(c.hc)(),s=Object(Yl.a)(t,e),{inputs:r}=s,o=Object(n.useMemo)((()=>a.map((e=>({value:e.id,label:e.name})))),[a]);return l.a.createElement(u.EuiFlyout,{maxWidth:Kl,onClose:e},l.a.createElement(u.EuiFlyoutHeader,{hasBorder:!0},l.a.createElement(u.EuiTitle,{size:"m"},l.a.createElement("h2",null,t?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.editTitle",defaultMessage:"Edit Fleet Server"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.addTitle",defaultMessage:"Add Fleet Server"})))),l.a.createElement(u.EuiFlyoutBody,null,l.a.createElement(u.EuiCallOut,{size:"m",color:"warning",iconType:"warning",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.warningCalloutTitle",defaultMessage:"Changing these settings can break your agent connections"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.warningCalloutDescription",defaultMessage:"Invalid settings can break the connection between Elastic Agent and Fleet Server. If this happens, you will need to re-enroll your agents."})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiForm,{onSubmit:s.submit},l.a.createElement(Vl,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.nameInputLabel",defaultMessage:"Name"}),inputProps:r.nameInput,dataTestSubj:"fleetServerHostsFlyout.nameInput",placeholder:g.i18n.translate("xpack.fleet.settings.fleetServerHostsFlyout.nameInputPlaceholder",{defaultMessage:"Specify name"})}),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.hostUrlLabel",defaultMessage:"URL"})},l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{color:"subdued",size:"relative"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.description",defaultMessage:"Specify multiple URLs to scale out your deployment and provide automatic failover. If multiple URLs exist, Fleet shows the first provided URL for enrollment purposes. Enrolled Elastic Agents will connect to the URLs in round robin order until they connect successfully. For more information, see the {link} .",values:{link:l.a.createElement(u.EuiLink,{href:i.links.fleet.settingsFleetServerHostSettings,target:"_blank",external:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.userGuideLink",defaultMessage:"Fleet and Elastic Agent Guide"}))}})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement($l.a,T()({},s.inputs.hostUrlsInput.props,{id:"fleet-server-inputs",placeholder:g.i18n.translate("xpack.fleet.settings.fleetServerHostsFlyout.fleetServerHostsInputPlaceholder",{defaultMessage:"Specify host URL"}),isUrl:!0})))),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.proxyIdLabel",defaultMessage:"Proxy"})},l.a.createElement(u.EuiComboBox,T()({fullWidth:!0,"data-test-subj":"fleetServerHostsFlyout.proxyIdInput"},r.proxyIdInput.props,{onChange:e=>{var t,a;return r.proxyIdInput.setValue(null!==(t=null==e||null===(a=e[0])||void 0===a?void 0:a.value)&&void 0!==t?t:"")},selectedOptions:""!==r.proxyIdInput.value?o.filter((e=>e.value===r.proxyIdInput.value)):[],options:o,singleSelection:{asPlainText:!0},isClearable:!0,placeholder:g.i18n.translate("xpack.fleet.settings.fleetServerHostsFlyout.proxyIdPlaceholder",{defaultMessage:"Select proxy"})}))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},r.isDefaultInput.formRowProps),l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"fleetServerHostsFlyout.isDefaultSwitch"},r.isDefaultInput.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.defaultOutputSwitchLabel",defaultMessage:"Make this Fleet server the default one."})}))))),l.a.createElement(u.EuiFlyoutFooter,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:()=>e(),flush:"left"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.cancelButtonLabel",defaultMessage:"Cancel"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{fill:!0,isLoading:s.isLoading,isDisabled:s.isDisabled,onClick:s.submit,"data-test-subj":"saveApplySettingsBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.saveButton",defaultMessage:"Save and apply settings"}))))))},Jl=()=>{const{docLinks:e}=Object(c.hc)();return l.a.createElement(Xl,{iconType:"iInCircle",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.calloutTitle",defaultMessage:"Additional Logstash configuration required"})},l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.description",defaultMessage:"Add an Elastic Agent pipeline configuration to Logstash to receive events from the Elastic Agent framework. {documentationLink}.",values:{documentationLink:l.a.createElement(u.EuiLink,{external:!0,href:e.links.logstash.inputElasticAgent},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.documentationLink",defaultMessage:"Learn more"}))}}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(ei,null)))},Xl=({children:e,...t})=>{const[a,i]=Object(n.useState)(!1);return l.a.createElement(u.EuiCallOut,t,l.a.createElement(u.EuiSpacer,{size:"s"}),a?l.a.createElement(u.EuiButton,{onClick:()=>i(!1)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.collapseInstructionsButtonLabel",defaultMessage:"Collapse steps"})):l.a.createElement(u.EuiButton,{onClick:()=>i(!0),fill:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.viewInstructionButtonLabel",defaultMessage:"View steps"})),a&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),e))},ei=()=>{const{docLinks:e}=Object(c.hc)(),t=function(){const[e,t]=Object(n.useState)(!1),[a,l]=Object(n.useState)(),{notifications:i}=Object(c.hc)(),s=Object(n.useCallback)((async()=>{try{var e;t(!0);const a=await Object(c.ab)();if(a.error)throw a.error;l(null===(e=a.data)||void 0===e?void 0:e.api_key)}catch(e){i.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.logstashInstructions.generateApiKeyError",{defaultMessage:"Impossible to generate an api key"})})}finally{t(!1)}}),[i.toasts]);return Object(n.useMemo)((()=>({isLoading:e,generateApiKey:s,apiKey:a})),[e,s,a])}(),a=Object(n.useMemo)((()=>{return[{children:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.apiKeyStepDescription",defaultMessage:"We recommend authorizing Logstash to output to Elasticsearch with minimal privileges for Elastic Agent."}),l.a.createElement(u.EuiSpacer,{size:"m"}),t.apiKey?l.a.createElement(u.EuiCodeBlock,{paddingSize:"m"},l.a.createElement("h5",null,"API Key"),t.apiKey,l.a.createElement("div",{className:"euiCodeBlock__controls"},l.a.createElement("div",{className:"euiCodeBlock__copyButton"},l.a.createElement(u.EuiCopy,{textToCopy:t.apiKey},(e=>l.a.createElement(u.EuiButtonIcon,{onClick:e,iconType:"copyClipboard",color:"text","aria-label":g.i18n.translate("xpack.fleet.settings.logstashInstructions.copyApiKeyButtonLabel",{defaultMessage:"Copy message"})})))))):l.a.createElement(u.EuiButton,{isLoading:t.isLoading,onClick:t.generateApiKey},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.generateApiKeyButtonLabel",defaultMessage:"Generate API key"})),l.a.createElement(u.EuiSpacer,{size:"m"}))},{children:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.editPipelineStepDescription",defaultMessage:"Next, open the {pipelineConfFile} file and insert the following content:",values:{pipelineConfFile:l.a.createElement(u.EuiCode,null,"elastic-agent-pipeline.conf")}}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCodeBlock,{paddingSize:"m",language:"yaml",isCopyable:!0},(a=t.apiKey,'input {\n elastic_agent {\n port => 5044\n ssl => true\n ssl_certificate_authorities => [""]\n ssl_certificate => ""\n ssl_key => ""\n ssl_verify_mode => "force_peer"\n }\n}\n\noutput {\n elasticsearch {\n hosts => ""\n api_key => ""\n data_stream => true\n ssl => true\n # cacert => ""\n }\n}'.replace("",a||""))))},{children:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.addPipelineStepDescription",defaultMessage:"In your Logstash configuration directory, open the {pipelineFile} file and add the following configuration. Replace the path to your file.",values:{pipelineFile:l.a.createElement(u.EuiCode,null,"pipelines.yml")}}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCodeBlock,{paddingSize:"m",language:"yaml",isCopyable:!0},'- pipeline.id: elastic-agent-pipeline\n path.config: "/etc/path/to/elastic-agent-pipeline.conf"\n'))},{children:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.replaceStepDescription",defaultMessage:"Replace the parts between the brackets with your generated SSL certificate file paths. View {documentationLink} to generate the certificates.",values:{documentationLink:l.a.createElement(u.EuiLink,{external:!0,href:e.links.fleet.secureLogstash},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.ourDocumentationLink",defaultMessage:"our documentation"}))}}),l.a.createElement(u.EuiSpacer,{size:"m"}))},{children:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.logstashInstructions.saveAndRestartStepDescription",defaultMessage:"Save the pipeline and restart Logstash so the changes take effect."}),l.a.createElement(u.EuiSpacer,{size:"m"}))}];var a}),[t,e]);return l.a.createElement("ol",null,a.map(((e,t)=>l.a.createElement("li",{key:t},e.children))))},ti=e=>{const{inputs:t}=e,{props:{onChange:a,id:i},value:s,formRowProps:{error:r}}=t.kafkaTopicsInput,o=Object(m.useTheme)(),[c,E]=Object(n.useState)(!1),{docLinks:f}=Object(on.Mc)(),b=Object(n.useMemo)((()=>r?r.reduce(((e,t)=>(void 0===t.index||(e[t.index]||(e[t.index]=[]),t.condition||e[t.index].push(t.message)),e)),[]):[]),[r]),h=Object(n.useMemo)((()=>r?r.reduce(((e,t)=>(void 0===t.index||(e[t.index]||(e[t.index]=[]),t.condition&&e[t.index].push(t.message)),e)),[]):[]),[r]),y=Object(n.useCallback)(((e,t,n)=>{const l=s.map(((a,l)=>l===e?"topic"===t?{...a,topic:n}:{...a,when:{...a.when||{},..."condition"===t?{condition:n}:{},..."type"===t?{type:n}:{}}}:a));a(l)}),[s,a]),k=Object(n.useCallback)((()=>{E(!0);const e=[...s,{topic:"",when:{type:V.Db.Contains}}];a(e)}),[s,a]),v=Object(n.useCallback)((e=>{const t=s.filter(((t,a)=>a!==e));b.splice(e,1),h.splice(e,1),a(t)}),[s,b,h,a]),x=e=>null!=e&&e.length?e.map(((e,t)=>l.a.createElement(u.EuiFormErrorText,{key:t},e))):null,F=Object(n.useMemo)((()=>r&&r.filter((e=>void 0===e.index)).map((({message:e})=>e))),[r]),M=Object(n.useMemo)((()=>Object.keys(V.Db).map((e=>({text:V.Db[e],label:e})))),[]),I=p.a.div.withConfig({displayName:"DraggableDiv",componentId:"sc-v0mmey-0"})(["margin:",";"],(e=>e.theme.eui.euiSizeS)),S=Object(n.useCallback)((({source:e,destination:t})=>{if(e&&t){const n=Object(u.euiDragDropReorder)(s,e.index,t.index),l=b[e.index];b.splice(e.index,1),b.splice(t.index,0,l);const i=h[e.index];h.splice(e.index,1),h.splice(t.index,0,i),a(n)}}),[s,b,h,a]);return l.a.createElement(u.EuiPanel,{borderRadius:"m",hasShadow:!1,paddingSize:"m",color:"subdued","data-test-subj":"settingsOutputsFlyout.kafkaTopicsPanel"},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",{id:"FleetEditOutputFlyoutKafkaHeaders"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaTopcisTitle",defaultMessage:"Topics"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaTopicsDefaultTopicLabel",defaultMessage:"Default topic"})},t.kafkaDefaultTopicInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaDefaultTopicInput",fullWidth:!0},t.kafkaDefaultTopicInput.props))),s.length>0&&l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaTopicsProcessorsLabel",defaultMessage:"Processors"}),l.a.createElement(u.EuiText,{color:"subdued",size:"xs"},l.a.createElement("i",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaTopicsProcessorsHelpText",defaultMessage:"For more information read the {link}.",values:{link:l.a.createElement(u.EuiLink,{href:f.links.fleet.kafkaSettings,target:"_blank"},"documentation")}}))))},s.length>1?l.a.createElement(u.EuiDragDropContext,{onDragEnd:S},l.a.createElement(u.EuiDroppable,{droppableId:`${i}Droppable`,spacing:"none"},s.map(((e,t)=>{const a=b[t],n=h[t];return l.a.createElement(l.a.Fragment,{key:t},l.a.createElement(u.EuiDraggable,{spacing:"m",index:t,draggableId:`${i}${t}Draggable`,customDragHandle:!0,style:{paddingLeft:0,paddingRight:0}},((i,s)=>{var r,d,m,p,E,f;return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiFlexGroup,{gutterSize:"none",wrap:!0,style:s.isDragging?{background:o.eui.euiPanelBackgroundColorModifiers.plain}:{}},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(I,T()({"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorDragHandle${t}`},i.dragHandleProps,{"aria-label":g.i18n.translate("xpack.fleet.settings.sortHandle",{defaultMessage:"Sort host handle"})}),l.a.createElement(u.EuiIcon,{color:"text",type:"grab"}))),l.a.createElement(u.EuiFlexItem,{style:{flex:"30%",paddingRight:10}},l.a.createElement(u.EuiFormRow,{fullWidth:!0},l.a.createElement(u.EuiSelect,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorWhenInput${t}`,fullWidth:!0,options:M,value:null===(r=e.when)||void 0===r?void 0:r.type,onChange:e=>y(t,"type",e.target.value)}))),l.a.createElement(u.EuiFlexItem,{style:{flex:"40%"}},l.a.createElement(u.EuiFormRow,{fullWidth:!0,error:x(n),isInvalid:(null!==(d=null==n?void 0:n.length)&&void 0!==d?d:0)>0},l.a.createElement(u.EuiFieldText,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorConditionInput${t}`,value:null===(m=e.when)||void 0===m?void 0:m.condition,isInvalid:(null!==(p=null==n?void 0:n.length)&&void 0!==p?p:0)>0,onChange:e=>y(t,"condition",e.target.value)}))),l.a.createElement(u.EuiFlexItem,{grow:!1,style:{marginTop:10}},l.a.createElement(u.EuiButtonIcon,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorDeleteButton${t}`,color:"text",onClick:()=>v(t),iconType:"cross","aria-label":g.i18n.translate("xpack.fleet.multiRowInput.deleteButton",{defaultMessage:"Delete row"})})),l.a.createElement(u.EuiFlexItem,{style:{flex:"0 50%",marginLeft:"auto",marginRight:23,paddingTop:10}},l.a.createElement(u.EuiFormRow,{fullWidth:!0,error:x(a),isInvalid:(null!==(E=null==a?void 0:a.length)&&void 0!==E?E:0)>0},l.a.createElement(u.EuiFieldText,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorTopicInput${t}`,autoFocus:c,prepend:"Topic",value:e.topic,isInvalid:(null!==(f=null==a?void 0:a.length)&&void 0!==f?f:0)>0,onChange:e=>y(t,"topic",e.target.value)})))))})))})))):l.a.createElement(l.a.Fragment,null,s.map(((e,t)=>{var a,n,i,s,r,o;const d=b[t],m=h[t];return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiFlexGroup,{gutterSize:"none",wrap:!0},l.a.createElement(u.EuiFlexItem,{style:{flex:"30%",paddingRight:10}},l.a.createElement(u.EuiFormRow,{fullWidth:!0},l.a.createElement(u.EuiSelect,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorWhenInput${t}`,fullWidth:!0,options:M,value:null===(a=e.when)||void 0===a?void 0:a.type,onChange:e=>y(t,"type",e.target.value)}))),l.a.createElement(u.EuiFlexItem,{style:{flex:"40%"}},l.a.createElement(u.EuiFormRow,{fullWidth:!0,error:x(m),isInvalid:(null!==(n=null==m?void 0:m.length)&&void 0!==n?n:0)>0},l.a.createElement(u.EuiFieldText,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorConditionInput${t}`,value:null===(i=e.when)||void 0===i?void 0:i.condition,isInvalid:(null!==(s=null==m?void 0:m.length)&&void 0!==s?s:0)>0,onChange:e=>y(t,"condition",e.target.value)}))),l.a.createElement(u.EuiFlexItem,{grow:!1,style:{marginTop:10}},l.a.createElement(u.EuiButtonIcon,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorDeleteButton${t}`,color:"text",onClick:()=>v(t),iconType:"cross","aria-label":g.i18n.translate("xpack.fleet.multiRowInput.deleteButton",{defaultMessage:"Delete row"})})),l.a.createElement(u.EuiFlexItem,{style:{flex:"0 53%",marginLeft:"auto",marginRight:23,paddingTop:10}},l.a.createElement(u.EuiFormRow,{fullWidth:!0,error:x(d),isInvalid:(null!==(r=null==d?void 0:d.length)&&void 0!==r?r:0)>0},l.a.createElement(u.EuiFieldText,{"data-test-subj":`settingsOutputsFlyout.kafkaTopicsProcessorTopicInput${t}`,isInvalid:(null!==(o=null==d?void 0:d.length)&&void 0!==o?o:0)>0,autoFocus:c,prepend:"Topic",value:e.topic,onChange:e=>y(t,"topic",e.target.value)})))))})))),x(F),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiButtonEmpty,{"data-test-subj":"fleetServerHosts.kafkaTopicsInput.addRowButton",size:"xs",flush:"left",iconType:"plusInCircle",onClick:k},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.kafkaTopics.addTopicProcessor",defaultMessage:"Add topic processor"})),l.a.createElement(u.EuiSpacer,{size:"m"}))},ai=e=>{const{inputs:t}=e,{props:{onChange:a},value:i,formRowProps:{error:s}}=t.kafkaHeadersInput,[r,o]=Object(n.useState)(!1),c=Object(n.useCallback)(((e,t,n)=>{const l=i.map(((a,l)=>l===e?{...a,[t]:n}:a));a(l)}),[i,a]),m=Object(n.useCallback)((()=>{o(!0);const e=[...i,{key:"",value:""}];a(e)}),[i,a]),p=Object(n.useCallback)((e=>{const t=i.filter(((t,a)=>a!==e));a(t)}),[i,a]),E=1===i.length,f=1===i.length&&(""===i[0].key||""===i[0].value),b=e=>null!=e&&e.length?e.map(((e,t)=>l.a.createElement(u.EuiFormErrorText,{key:t},e))):null,h=Object(n.useMemo)((()=>(e,t)=>null==s?void 0:s.filter((a=>a.index===e&&("key"===t?a.hasKeyError:a.hasValueError))).map((e=>e.message))),[s]),y=Object(n.useMemo)((()=>s&&s.filter((e=>void 0===e.index)).map((({message:e})=>e))),[s]);return l.a.createElement(u.EuiPanel,{borderRadius:"m",hasShadow:!1,paddingSize:"m",color:"subdued","data-test-subj":"settingsOutputsFlyout.kafkaHeadersPanel"},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",{id:"FleetEditOutputFlyoutKafkaHeaders"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaHeadersTitle",defaultMessage:"Headers"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),i.map(((e,t)=>{var a,n;const i=h(t,"key"),s=h(t,"value");return l.a.createElement("div",{key:t},t>0&&l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart",gutterSize:"none",style:{gap:30}},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaHeaderKeyInputLabel",defaultMessage:"Key"}),error:b(i),isInvalid:(null!==(a=null==i?void 0:i.length)&&void 0!==a?a:0)>0},l.a.createElement(u.EuiFieldText,{"data-test-subj":`settingsOutputsFlyout.kafkaHeadersKeyInput${t}`,fullWidth:!0,value:e.key,onChange:e=>c(t,"key",e.target.value),autoFocus:r}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaHeaderValueInputLabel",defaultMessage:"Value"}),error:b(s),isInvalid:(null!==(n=null==s?void 0:s.length)&&void 0!==n?n:0)>0},l.a.createElement(u.EuiFieldText,{"data-test-subj":`settingsOutputsFlyout.kafkaHeadersValueInput${t}`,fullWidth:!0,value:e.value,onChange:e=>c(t,"value",e.target.value)}))),l.a.createElement(u.EuiFlexItem,{grow:!1,style:{marginTop:28}},l.a.createElement(u.EuiButtonIcon,{"data-test-subj":`settingsOutputsFlyout.kafkaHeadersDeleteButton${t}`,color:"text",onClick:()=>p(t),iconType:"cross",disabled:E,"aria-label":g.i18n.translate("xpack.fleet.kafkaHeadersInput.deleteButton",{defaultMessage:"Delete row"})}))))})),b(y),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiButtonEmpty,{"data-test-subj":"kafkaHeaders.multiRowInput.addRowButton",disabled:f,size:"xs",flush:"left",iconType:"plusInCircle",onClick:m},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.kafkaHeadersInput.addRow",defaultMessage:"Add header"})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaClientIdLabel",defaultMessage:"Client ID"})},t.kafkaClientIdInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaClientIdInput",fullWidth:!0},t.kafkaClientIdInput.props))))},ni=e=>{const{inputs:t}=e,a=Object(n.useMemo)((()=>Array.from({length:6},((e,t)=>10*(t+1))).map((e=>({text:e,label:`${e} seconds`})))),[]),i=e=>{switch(e){case V.wb.DoNotWait:return"No response";case V.wb.Replica:return"Wait for all replicas to commit";default:case V.wb.Commit:return"Wait for local commit"}},s=Object(n.useMemo)((()=>Object.keys(V.wb).map((e=>({text:V.wb[e],label:i(V.wb[e])})))),[]);return l.a.createElement(u.EuiPanel,{borderRadius:"m",hasShadow:!1,paddingSize:"m",color:"subdued","data-test-subj":"settingsOutputsFlyout.kafkaBrokerSettingsPanel"},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",{id:"FleetEditOutputFlyoutKafkaBrokerSettings"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerSettingsTitle",defaultMessage:"Broker settings"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerTimeoutInputLabel",defaultMessage:"Broker timeout"}),helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerTimeoutInputHelpText",defaultMessage:"Define how long a Kafka server waits for data in the same cluster."})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.kafkaBrokerTimeoutInput"},t.kafkaBrokerTimeoutInput.props,{options:a}))),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerReachabilityTimeoutInputLabel",defaultMessage:"Broker reachability timeout"}),helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerReachabilityTimeoutInputHelpText",defaultMessage:"Define how long an Agent would wait for a response from Kafka broker."})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.kafkaBrokerReachabilityTimeoutInput"},t.kafkaBrokerReachabilityTimeoutInput.props,{options:a}))),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerAckReliabilityInputLabel",defaultMessage:"ACK Reliability"}),helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaBrokerAckReliabilityInputHelpText",defaultMessage:"Reliability level required from the broker."})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.kafkaBrokerAckReliabilityInputLabel"},t.kafkaBrokerAckReliabilityInput.props,{options:s}))))},li=e=>{const{inputs:t}=e,a=Object(n.useMemo)((()=>Object.keys(V.yb).filter((e=>"None"!==e)).map((e=>({text:V.yb[e],label:V.yb[e]})))),[]),i=Object(n.useMemo)((()=>Array.from({length:9},((e,t)=>t+1)).map((e=>({text:e,label:e.toString()})))),[]);return l.a.createElement(u.EuiPanel,{borderRadius:"m",hasShadow:!1,paddingSize:"m",color:"subdued","data-test-subj":"settingsOutputsFlyout.kafkaCompressionPanel"},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",{id:"FleetEditOutputFlyoutKafkaCompression"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaCompressionTitle",defaultMessage:"Compression"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"settingsOutputsFlyout.kafkaCompressionSwitch"},t.kafkaCompressionInput.props,{onChange:e=>{e.target.checked||t.kafkaCompressionCodecInput.setValue(V.yb.None),t.kafkaCompressionInput.setValue(e.target.checked)},label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaCompressionSwitchLabel",defaultMessage:"Enable compression"})})),t.kafkaCompressionInput.value?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaCompressionCodecInputLabel",defaultMessage:"Codec"})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.kafkaCompressionCodecInput"},t.kafkaCompressionCodecInput.props,{options:a}))),t.kafkaCompressionCodecInput.value===V.yb.Gzip&&l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaCompressionLevelInputLabel",defaultMessage:"Level"})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0},t.kafkaCompressionLevelInput.props,{"data-test-subj":"settingsOutputsFlyout.kafkaCompressionLevelInput",options:i})))):null)},ii=[{id:V.Ab.Random,label:"Random","data-test-subj":"kafkaPartitionRandomRadioButton"},{id:V.Ab.RoundRobin,label:"Round robin","data-test-subj":"kafkaPartitionRoundRobinRadioButton"},{id:V.Ab.Hash,label:"Hash","data-test-subj":"kafkaPartitionHashRadioButton"}],si=e=>{const{inputs:t}=e;return l.a.createElement(u.EuiPanel,{borderRadius:"m",hasShadow:!1,paddingSize:"m",color:"subdued","data-test-subj":"settingsOutputsFlyout.kafkaPartitionPanel"},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",{id:"FleetEditOutputFlyoutKafkaPartitionTitle"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPartitionTitle",defaultMessage:"Partitioning"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPartitioningInputLabel",defaultMessage:"Partitioning strategy"})},l.a.createElement(u.EuiRadioGroup,T()({style:{display:"flex",gap:30},"data-test-subj":"settingsOutputsFlyout.kafkaPartitioningRadioInput",options:ii,compressed:!0},t.kafkaPartitionTypeInput.props))),(()=>{switch(t.kafkaPartitionTypeInput.value){case V.Ab.Random:return l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPartitionTypeRandomInputLabel",defaultMessage:"Number of events"})},t.kafkaPartitionTypeRandomInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaPartitionTypeRandomInput",fullWidth:!0},t.kafkaPartitionTypeRandomInput.props)));case V.Ab.RoundRobin:return l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPartitionTypeRoundRobinInputLabel",defaultMessage:"Number of events"})},t.kafkaPartitionTypeRoundRobinInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaPartitionTypeRoundRobinInput",fullWidth:!0},t.kafkaPartitionTypeRoundRobinInput.props)));case V.Ab.Hash:default:return l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPartitionTypeHashInputLabel",defaultMessage:"List of fields"}),helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPartitionTypeHashHelpTextLabel",defaultMessage:"Comma separated."})},l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaPartitionTypeHashInput",fullWidth:!0},t.kafkaPartitionTypeHashInput.props))))}})())},ri=[{id:V.Bb.Plain,label:"Plain","data-test-subj":"kafkaSaslPlainRadioButton"},{id:V.Bb.ScramSha256,label:"SCRAM-SHA-256","data-test-subj":"kafkaSaslScramSha256RadioButton"},{id:V.Bb.ScramSha512,label:"SCRAM-SHA-512","data-test-subj":"kafkaSaslScramSha512RadioButton"}],oi=[{id:V.xb.None,label:"None","data-test-subj":"kafkaAuthenticationNoneRadioButton"},{id:V.xb.Userpass,label:"Username / Password","data-test-subj":"kafkaAuthenticationUsernamePasswordRadioButton"},{id:V.xb.Ssl,label:"SSL","data-test-subj":"kafkaAuthenticationSSLRadioButton"}],ci=e=>{const{inputs:t}=e,a=Object(n.useMemo)((()=>Object.keys(V.Eb).map((e=>({text:V.Eb[e],label:e})))),[]),i=Object(n.useMemo)((()=>Object.keys(V.zb).map((e=>({id:V.zb[e],label:e,"data-test-subj":`kafkaConnectionType${e}RadioButton`})))),[]);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiPanel,{borderRadius:"m",hasShadow:!1,paddingSize:"m",color:"subdued","data-test-subj":"settingsOutputsFlyout.kafkaAuthenticationPanel"},l.a.createElement(u.EuiTitle,{size:"s"},l.a.createElement("h3",{id:"FleetEditOutputFlyoutKafkaAuthenticationTitle"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaAuthenticationTitle",defaultMessage:"Authentication"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,{fullWidth:!0},l.a.createElement(u.EuiRadioGroup,T()({style:{display:"flex",gap:30},"data-test-subj":"settingsOutputsFlyout.kafkaAuthenticationRadioInput",options:oi,compressed:!0},t.kafkaAuthMethodInput.props))),(()=>{switch(t.kafkaAuthMethodInput.value){case V.xb.None:return l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaConnectionTypeLabel",defaultMessage:"Connection"})},l.a.createElement(u.EuiRadioGroup,T()({style:{display:"flex",gap:30},"data-test-subj":"settingsOutputsFlyout.kafkaConnectionTypeRadioInput",options:i,compressed:!0},t.kafkaConnectionTypeInput.props)));case V.xb.Ssl:return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.sslCertificateInputLabel",defaultMessage:"Client SSL certificate"})},t.kafkaSslCertificateInput.formRowProps),l.a.createElement(u.EuiTextArea,T()({fullWidth:!0,rows:5},t.kafkaSslCertificateInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslCertificateInputPlaceholder",{defaultMessage:"Specify ssl certificate"})}))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.sslKeyInputLabel",defaultMessage:"Client SSL certificate key"})},t.kafkaSslKeyInput.formRowProps),l.a.createElement(u.EuiTextArea,T()({fullWidth:!0,rows:5},t.kafkaSslKeyInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslKeyInputPlaceholder",{defaultMessage:"Specify certificate key"})}))));default:case V.xb.Userpass:return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaUsernameInputLabel",defaultMessage:"Username"})},t.kafkaAuthUsernameInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaUsernameInput",fullWidth:!0},t.kafkaAuthUsernameInput.props))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaPasswordInputLabel",defaultMessage:"Password"})},t.kafkaAuthPasswordInput.formRowProps),l.a.createElement(u.EuiFieldPassword,T()({type:"dual","data-test-subj":"settingsOutputsFlyout.kafkaPasswordInput",fullWidth:!0},t.kafkaAuthPasswordInput.props))),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaSaslInputLabel",defaultMessage:"SASL Mechanism"})},l.a.createElement(u.EuiRadioGroup,T()({style:{display:"flex",gap:30},"data-test-subj":"settingsOutputsFlyout.kafkaSaslInput",options:ri,compressed:!0},t.kafkaSaslMechanismInput.props))))}})()),t.kafkaConnectionTypeInput.value!==V.zb.Plaintext||t.kafkaAuthMethodInput.value!==V.xb.None?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement($l.a,T()({placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslCertificateAuthoritiesInputPlaceholder",{defaultMessage:"Specify certificate authority"}),label:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslCertificateAuthoritiesInputLabel",{defaultMessage:"Server SSL certificate authorities (optional)"}),multiline:!0,sortable:!1},t.kafkaSslCertificateAuthoritiesInput.props)),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaVerificationModeInputLabel",defaultMessage:"Verification mode"})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.kafkaVerificationModeInput"},t.kafkaVerificationModeInput.props,{options:a,placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.kafkaVerificationModeInputPlaceholder",{defaultMessage:"Specify verification mode"})})))):null)},ui=e=>{const{inputs:t}=e,{docLinks:a}=Object(on.Mc)(),i=Object(n.useMemo)((()=>V.Cb.map((e=>({text:e,label:e})))),[]);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaVersionInputLabel",defaultMessage:"Kafka version"})},l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.kafkaVersionInput"},t.kafkaVersionInput.props,{options:i,placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.kafkaVersionInputPlaceholder",{defaultMessage:"Specify version"})}))),l.a.createElement($l.a,T()({placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.kafkaHostsInputPlaceholder",{defaultMessage:"Specify host"}),sortable:!0,helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaHostsInputDescription",defaultMessage:"Specify the URLs that your agents will use to connect to Kafka. {guideLink}.",values:{guideLink:l.a.createElement(u.EuiLink,{href:a.links.fleet.kafkaSettings,target:"_blank",external:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.kafkaUserGuideLink",defaultMessage:"Learn more"}))}}),label:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.kafkaHostsInputLabel",{defaultMessage:"Hosts"})},t.kafkaHostsInput.props)),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(ci,{inputs:t}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(si,{inputs:t}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(ti,{inputs:t}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(ai,{inputs:t}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(li,{inputs:t}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(ni,{inputs:t}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaKeyInputLabel",defaultMessage:"Key (optional)"}),helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.kafkaKeyInputHelpText",defaultMessage:"If configured, the event key can be extracted from the event using a format string."})},l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.kafkaKeyInput",fullWidth:!0},t.kafkaKeyInput.props))))},di=p.a.div.withConfig({displayName:"CodeEditorContainer",componentId:"sc-1u19e39-0"})(["min-height:0;position:relative;height:116px;"]),gi=p()(u.EuiTextColor).attrs((e=>({color:"subdued",size:"xs"}))).withConfig({displayName:"CodeEditorPlaceholder",componentId:"sc-1u19e39-1"})(["position:absolute;top:0;left:0;font-family:Menlo,Monaco,'Courier New',monospace;font-size:12px;line-height:21px;pointer-events:none;"]),mi={minimap:{enabled:!1},ariaLabel:g.i18n.translate("xpack.fleet.settings.yamlCodeEditor",{defaultMessage:"YAML Code Editor"}),scrollBeyondLastLine:!1,wordWrap:"on",wrappingIndent:"indent",automaticLayout:!0,tabSize:2,lineNumbers:"off",lineNumbersMinChars:0,glyphMargin:!1,folding:!1,lineDecorationsWidth:0},pi=e=>{const{placeholder:t,disabled:a,...n}=e;return a?l.a.createElement(u.EuiCodeBlock,{style:{height:"116px"},language:"yaml",isCopyable:!1,paddingSize:"s"},l.a.createElement("pre",null,n.value)):l.a.createElement(di,null,l.a.createElement(y.CodeEditor,T()({languageId:"yaml",width:"100%",height:"116px",options:mi},n)),(!n.value||""===n.value)&&l.a.createElement(gi,null,t))};function Ei(e){const t=[],a={};if(e.forEach(((e,n)=>{if(!e)return void t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHostFieldRequiredError",{defaultMessage:"Host is required"})});const l=e.split(":");if(2!==l.length||!l[0]||!l[1])return void t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHostPortError",{defaultMessage:'Invalid format. Expected "host:port" without protocol.'}),index:n});const i=parseInt(l[1],10);(isNaN(i)||i<1||i>65535)&&t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaPortError",{defaultMessage:"Invalid port number. Expected a number between 1 and 65535"}),index:n});const s=a[e]||[];a[e]=[...s,n]})),Object.values(a).filter((({length:e})=>e>1)).forEach((e=>{e.forEach((e=>t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHostDuplicateError",{defaultMessage:"Duplicate URL"}),index:e})))})),0===e.length&&t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHostRequiredError",{defaultMessage:"Host is required"})}),t.length)return t}function fi(e){const t=[],a={};if(e.forEach(((e,n)=>{try{if(!e)throw new Error("Host URL required");const t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol")}catch(e){t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.elasticHostError",{defaultMessage:"Invalid URL"}),index:n})}const l=a[e]||[];a[e]=[...l,n]})),Object.values(a).filter((({length:e})=>e>1)).forEach((e=>{e.forEach((e=>t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.elasticHostDuplicateError",{defaultMessage:"Duplicate URL"}),index:e})))})),0===e.length&&t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.elasticUrlRequiredError",{defaultMessage:"URL is required"})}),t.length)return t}function bi(e){const t=[],a={};if(e.forEach(((e,n)=>{try{if(e.match(/^http([s]){0,1}:\/\//))return void t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.logstashHostProtocolError",{defaultMessage:"Host address must begin with a domain name or IP address"}),index:n});if(new URL(`http://${e}`).host!==e)throw new Error("Invalid host")}catch(a){0===e.length?t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.logstashHostRequiredError",{defaultMessage:"Host is required"}),index:n}):t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.logstashHostError",{defaultMessage:"Invalid Host"}),index:n})}const l=a[e]||[];a[e]=[...l,n]})),Object.values(a).filter((({length:e})=>e>1)).forEach((e=>{e.forEach((e=>t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.logstashHostDuplicateError",{defaultMessage:"Duplicate Host"}),index:e})))})),0===e.length&&t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.logstashHostRequiredError",{defaultMessage:"Host is required"})}),t.length)return t}function hi(e){try{return void Object(Za.safeLoad)(e)}catch(e){return[g.i18n.translate("xpack.fleet.settings.outputForm.invalidYamlFormatErrorMessage",{defaultMessage:"Invalid YAML: {reason}",values:{reason:e.message}})]}}function yi(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.outputForm.nameIsRequiredErrorMessage",{defaultMessage:"Name is required"})]}function ki(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.outputForm.kafkaUsernameIsRequired",{defaultMessage:"Username is required"})]}function vi(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.outputForm.kafkaPasswordIsRequired",{defaultMessage:"Password is required"})]}function xi(e){if(""!==e&&!e.match(/^[a-zA-Z0-9]+$/))return[g.i18n.translate("xpack.fleet.settings.outputForm.caTrusterdFingerprintInvalidErrorMessage",{defaultMessage:"CA trusted fingerprint should be valid HEX encoded SHA-256 of a CA certificate"})]}function Fi(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.outputForm.sslCertificateRequiredErrorMessage",{defaultMessage:"SSL certificate is required"})]}function Mi(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.outputForm.sslKeyRequiredErrorMessage",{defaultMessage:"SSL key is required"})]}function Ii(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.outputForm.kafkaDefaultTopicRequiredMessage",{defaultMessage:"Default topic is required"})]}function Si(e){return/^[A-Za-z0-9._-]+$/.test(e)?void 0:[g.i18n.translate("xpack.fleet.settings.outputForm.kafkaClientIdFormattingMessage",{defaultMessage:"Client ID is invalid. Only letters, numbers, dots, underscores, and dashes are allowed."})]}function Oi(e){return/^[0-9]+$/.test(e)?void 0:[g.i18n.translate("xpack.fleet.settings.outputForm.kafkaPartitioningGroupEventsFormattingMessage",{defaultMessage:"Number of events must be a number"})]}function Ti(e){const t=[];if(e.forEach(((e,a)=>{var n;e.topic&&""!==e.topic||t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaTopicRequiredMessage",{defaultMessage:"Topic is required"}),index:a}),null!==(n=e.when)&&void 0!==n&&n.condition&&""!==e.when.condition&&e.when.condition.split(":").length-1==1||t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaTopicConditionRequired",{defaultMessage:'Must be a key, value pair i.e. "http.response.code: 200"'}),index:a,condition:!0})})),t.length)return t}function wi(e){const t=[],a=new Set;if(e.forEach(((e,n)=>{const{key:l,value:i}=e,s=!!l,r=!!i;s&&!r?t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHeadersMissingKeyError",{defaultMessage:'Missing value for key "{key}"',values:{key:l}}),index:n,hasKeyError:!1,hasValueError:!0}):!s&&r?t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHeadersMissingValueError",{defaultMessage:'Missing key for value "{value}"',values:{value:i}}),index:n,hasKeyError:!0,hasValueError:!1}):s&&r&&(a.has(l)?t.push({message:g.i18n.translate("xpack.fleet.settings.outputForm.kafkaHeadersDuplicateKeyError",{defaultMessage:'Duplicate key "{key}"',values:{key:l}}),index:n,hasKeyError:!0,hasValueError:!1}):a.add(l))})),t.length)return t}async function ji(e){var t,a,n;let l=`${F.c}.data_output_id:"${e.id}" or ${F.c}.monitoring_output_id:"${e.id}"`;e.is_default&&(l+=` or (not ${F.c}.data_output_id:*)`);const i=await Object(c.v)({kuery:l,page:1,perPage:F.p});if(i.error)throw i.error;const s=null!==(t=null===(a=i.data)||void 0===a||null===(n=a.items)||void 0===n?void 0:n.length)&&void 0!==t?t:0;let r=0;if(s>0){var o,u,d;const e=await Object(c.z)({page:1,perPage:0,showInactive:!1,kuery:null===(o=i.data)||void 0===o?void 0:o.items.map((e=>`policy_id:"${e.id}"`)).join(" or ")});if(e.error)throw e.error;r=null!==(u=null===(d=e.data)||void 0===d?void 0:d.total)&&void 0!==u?u:0}return{agentPolicyCount:s,agentCount:r}}const Ci=()=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateOutput.confirmModalTitle",defaultMessage:"Save and deploy changes?"}),Pi=({output:e,agentCount:t,agentPolicyCount:a})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{"data-test-subj":"settings.outputModal",id:"xpack.fleet.settings.updateOutput.confirmModalText",defaultMessage:"This action will update {outputName} output. It will update {policies} and {agents}. This action can not be undone. Are you sure you wish to continue?",values:{outputName:l.a.createElement("strong",null,e.name),agents:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateOutput.agentsCount",defaultMessage:"{agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:t}})),policies:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateOutput.agentPolicyCount",defaultMessage:"{agentPolicyCount, plural, one {# agent policy} other {# agent policies}}",values:{agentPolicyCount:a}}))}}),"logstash"===e.type?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiCallOut,{iconType:"warning",color:"warning",size:"m",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateOutput.warningTitle",defaultMessage:"Logstash output for agent integration is not supported for fleet server and synthetics."})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateOutput.warningMessage",defaultMessage:"Fleet server and synthetics policies will keep using the existing ES output."}))," "):null),Ai=4096;const Li=()=>{const{docLinks:e}=Object(c.hc)();return l.a.createElement(u.EuiCallOut,{iconType:"warning",color:"warning",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.encryptionKeyRequired.calloutTitle",defaultMessage:"Additional setup required"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.encryptionKeyRequired.calloutDescription",defaultMessage:"You must configure an encryption key before configuring this output. {link}",values:{link:l.a.createElement(u.EuiLink,{href:e.links.kibana.secureSavedObject,target:"_blank",external:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.encryptionKeyRequired.link",defaultMessage:"Learn more"}))}}))},_i=({enabled:e,inputs:t})=>{const{diskQueueEnabledInput:a,diskQueuePathInput:n,diskQueueMaxSizeInput:i,loadBalanceEnabledInput:s,diskQueueEncryptionEnabled:r,diskQueueCompressionEnabled:o,compressionLevelInput:c,memQueueEvents:m,queueFlushTimeout:p,maxBatchBytes:E}=t,{showExperimentalShipperOptions:f}=j.b.get();return e?l.a.createElement(u.EuiAccordion,{id:"advancedOutputOptions",arrowDisplay:"left",buttonContent:l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.advancedOptionsToggleLabel",defaultMessage:"Advanced options"})),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiBetaBadge,{label:"Experimental",color:"subdued"})))},l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},E.formRowProps,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.maxBatchSizeDescriptionLabel",defaultMessage:"Maximum Batch Size"})}),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFieldNumber,T()({},E.props,{placeholder:"Batching Bytes",min:0}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.maxBatchSizeDescription",defaultMessage:"Data will be sent to the output when the agent has more events in the queue than this number."}))))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},p.formRowProps,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.queueFlushTimeoutLabel",defaultMessage:"Flush Timeout"})}),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFieldNumber,T()({},p.props,{placeholder:"Seconds",min:0}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.queueFlushTimeoutDescription",defaultMessage:"Upon expiry the output queue is flushed and data is written to the output."}))))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},m.formRowProps,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.memQueueEventsLabel",defaultMessage:"Memory Queue Size"})}),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFieldNumber,T()({},m.props,{placeholder:"Events",min:0}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.memQueueEventsSizeDescription",defaultMessage:"Maximum number of events that can be stored in the queue. Default is set to 4096. When this queue is full, new events are dropped."}))))),f&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiHorizontalRule,null),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},a.formRowProps),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"editOutputFlyout.diskQueueSwitch"},a.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueueSwitchLabel",defaultMessage:"Disk Queue"})}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueueSwitchDescription",defaultMessage:"Once enabled, events will be queued on disk if, for some reason, agent is not able to send them."}))))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},r.formRowProps),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"editOutputFlyout.diskQueueEncryption"},r.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueueEncryptionLabel",defaultMessage:"Disk Queue Encryption"})}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueueEncryptionDescription",defaultMessage:"Enable encryption of data written to the disk queue."}))))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueuePathLabel",defaultMessage:"Disk Queue Path"})},n.formRowProps),l.a.createElement(u.EuiFieldText,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.diskQueuePath"},n.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.diskQueuePathPlaceholder",{defaultMessage:"path_data/diskqueue"})}))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},i.formRowProps,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueueMaxSize",defaultMessage:"Maximum Disk Queue Size"})}),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFieldNumber,T()({},i.props,{placeholder:"Bytes",min:0}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.diskQueueMaxSizeDescription",defaultMessage:"Limits the disk queue size for spooling of data. When data in the queue exceeds this limit, new events will be dropped."}))))),l.a.createElement(u.EuiHorizontalRule,null),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},s.formRowProps),l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"editOutputFlyout.loadBalancingSwitch"},s.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.loadBalancingSwitchLabel",defaultMessage:"Load Balancing"})}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.loadBalancingDescription",defaultMessage:"Once enabled, the agents will balance the load across all the hosts defined for this output. This will increase the number of connections opened by the agent."}))))),l.a.createElement(u.EuiHorizontalRule,null),l.a.createElement(u.EuiFormRow,{fullWidth:!0},l.a.createElement(u.EuiFlexGroup,{alignItems:"flexStart"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"editOutputFlyout.compressionSwitch"},o.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.compressionSwitchLabel",defaultMessage:"Compression"})}))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiSelect,T()({"data-test-subj":"editOutputFlyout.compressionLevelSelect",id:"selectCompressionLevel","aria-label":"Use aria labels when no actual label is in use"},c.props))),l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiText,{size:"s",color:"subdued"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.compressionSwitchDescription",defaultMessage:"Level 1 compression is the fastest, Level 9 however would provide the most compression."})))))))):null},Di=({onClose:e,output:t,proxies:a})=>{Object(c.ub)("settings");const i=function(e,t){var a,i,s,r,o,u,d,m,p,E,f,b,h,y,k,v,x,F,M,I,S,O,T,w,C,P,A,L,_,D,B,R,z,N,H,U,q,G,W,$,K,Q,Y,Z,J,X,ee,te,ae,ne,le,ie,se,re,oe,ce,ue,de,ge,me,pe,Ee;const fe=Object(c.Db)(),{showExperimentalShipperOptions:be}=j.b.get(),he=!(null!==(a=fe.missingOptionalFeatures)&&void 0!==a&&a.includes("encrypted_saved_object_encryption_key_required")),[ye,ke]=Object(n.useState)(!1),{notifications:ve}=Object(c.hc)(),{confirm:xe}=Object(Wl.a)(),Fe=null!==(i=null==t?void 0:t.is_preconfigured)&&void 0!==i&&i,Me=null!==(s=null==t?void 0:t.allow_edit)&&void 0!==s?s:[];function Ie(e){return!!Fe&&!Me.includes(e)}const Se=Object(c.Tb)(null!==(r=null==t?void 0:t.name)&&void 0!==r?r:"",yi,Ie("name")),Oe=Object(c.Tb)(null!==(o=null==t?void 0:t.type)&&void 0!==o?o:"elasticsearch",void 0,Ie("type")),Te=Object(c.Tb)(null!==(u=null==t?void 0:t.config_yaml)&&void 0!==u?u:"",hi,Ie("config_yaml")),we=Object(c.ic)(null!==(d=null==t?void 0:t.is_default)&&void 0!==d&&d,Ie("is_default")||(null==t?void 0:t.is_default)),je=Object(c.ic)(null!==(m=null==t?void 0:t.is_default_monitoring)&&void 0!==m&&m,Ie("is_default_monitoring")||(null==t?void 0:t.is_default_monitoring)),Ce=Object(c.Tb)(null!==(p=null==t?void 0:t.ca_trusted_fingerprint)&&void 0!==p?p:"",xi,Ie("ca_trusted_fingerprint")),Pe=Object(c.vb)("esHostsComboxBox",null!==(E=null==t?void 0:t.hosts)&&void 0!==E?E:[],fi,Ie("hosts")),Ae=null!=t&&t.config_yaml?Object(Za.safeLoad)(null==t?void 0:t.config_yaml):{},Le=!(null!=Ae&&Ae.shipper)||!1===(null==Ae||null===(f=Ae.shipper)||void 0===f?void 0:f.enabled),_e=Object(c.ic)(null!==(b=null==t||null===(h=t.shipper)||void 0===h?void 0:h.disk_queue_enabled)&&void 0!==b&&b),De=Object(c.Tb)(null!==(y=null==t||null===(k=t.shipper)||void 0===k?void 0:k.disk_queue_path)&&void 0!==y?y:"",void 0,null!==(v=!_e.value)&&void 0!==v&&v),Be=Object(c.ac)(null!==(x=null==t||null===(F=t.shipper)||void 0===F?void 0:F.disk_queue_max_size)&&void 0!==x?x:Ai,void 0,null!==(M=!_e.value)&&void 0!==M&&M),Re=Object(c.ic)(null!==(I=null==t||null===(S=t.shipper)||void 0===S?void 0:S.disk_queue_encryption_enabled)&&void 0!==I&&I,null!==(O=!_e.value)&&void 0!==O&&O),ze=Object(c.ic)(null!==(T=null==t||null===(w=t.shipper)||void 0===w?void 0:w.disk_queue_enabled)&&void 0!==T&&T),Ne=Object(c.ic)(null!==(C=null==t||null===(P=t.shipper)||void 0===P?void 0:P.disk_queue_compression_enabled)&&void 0!==C&&C),He=Array.from(Array(10).keys()).slice(1).map((e=>({value:`${e}`,text:`Level ${e}`}))),Ue=Object(c.fc)(He,null!==(A=`${null==t||null===(L=t.shipper)||void 0===L?void 0:L.compression_level}`)&&void 0!==A?A:He[0].value,null!==(_=!Ne.value)&&void 0!==_&&_),qe=Object(c.ac)((null==t||null===(D=t.shipper)||void 0===D?void 0:D.mem_queue_events)||void 0),Ge=Object(c.ac)((null==t||null===(B=t.shipper)||void 0===B?void 0:B.queue_flush_timeout)||void 0),We=Object(c.ac)((null==t||null===(R=t.shipper)||void 0===R?void 0:R.max_batch_bytes)||void 0),$e=Ie("ssl"),Ke=Object(c.vb)("logstashHostsComboxBox",null!==(z=null==t?void 0:t.hosts)&&void 0!==z?z:[],bi,Ie("hosts")),Ve=Object(c.vb)("sslCertificateAuthoritiesComboxBox",null!==(N=null==t||null===(H=t.ssl)||void 0===H?void 0:H.certificate_authorities)&&void 0!==N?N:[],void 0,$e),Qe=Object(c.Tb)(null!==(U=null==t||null===(q=t.ssl)||void 0===q?void 0:q.certificate)&&void 0!==U?U:"",Fi,$e),Ye=Object(c.Tb)(null!==(G=null==t||null===(W=t.ssl)||void 0===W?void 0:W.key)&&void 0!==G?G:"",Mi,$e),Ze=Object(c.Tb)(null!==($=null==t?void 0:t.proxy_id)&&void 0!==$?$:"",(()=>{}),Ie("proxy_id")),Je=t,Xe=Object(c.Tb)(null!==(K=null==Je?void 0:Je.version)&&void 0!==K?K:"1.0.0",void 0,Ie("version")),et=Object(c.vb)("kafkaHostsComboBox",null!==(Q=null==t?void 0:t.hosts)&&void 0!==Q?Q:[],Ei,Ie("hosts")),tt=Object(c.dc)(null!==(Y=null==Je?void 0:Je.auth_type)&&void 0!==Y?Y:V.xb.None,Ie("auth_type")),at=Object(c.dc)(null!==(Z=null==Je?void 0:Je.connection_type)&&void 0!==Z?Z:V.zb.Plaintext,Ie("connection_type")),nt=Object(c.Tb)(null==Je?void 0:Je.username,tt.value===V.xb.Userpass?ki:void 0,Ie("username")),lt=Object(c.Tb)(null==Je?void 0:Je.password,tt.value===V.xb.Userpass?vi:void 0,Ie("password")),it=Object(c.vb)("kafkaSslCertificateAuthoritiesComboBox",null!==(J=null==Je||null===(X=Je.ssl)||void 0===X?void 0:X.certificate_authorities)&&void 0!==J?J:[],void 0,$e),st=Object(c.Tb)(null==Je||null===(ee=Je.ssl)||void 0===ee?void 0:ee.certificate,tt.value===V.xb.Ssl?Fi:void 0,$e),rt=Object(c.Tb)(null==Je||null===(te=Je.ssl)||void 0===te?void 0:te.key,tt.value===V.xb.Ssl?Mi:void 0,$e),ot=Object(c.Tb)(null!==(ae=null==Je||null===(ne=Je.ssl)||void 0===ne?void 0:ne.verification_mode)&&void 0!==ae?ae:V.Eb.Full,void 0,$e),ct=Object(c.dc)(null!==(le=null==Je||null===(ie=Je.sasl)||void 0===ie?void 0:ie.mechanism)&&void 0!==le?le:V.Bb.Plain,Ie("sasl")),ut=Object(c.dc)(null!==(se=null==Je?void 0:Je.partition)&&void 0!==se?se:V.Ab.Random,Ie("partition")),dt=Object(c.Tb)(null!=Je&&null!==(re=Je.random)&&void 0!==re&&re.group_events?`${Je.random.group_events}`:"1",ut.value===V.Ab.Random?Oi:void 0,Ie("partition")),gt=Object(c.Tb)(null==Je||null===(oe=Je.hash)||void 0===oe?void 0:oe.hash,void 0,Ie("partition")),mt=Object(c.Tb)(null!=Je&&null!==(ce=Je.round_robin)&&void 0!==ce&&ce.group_events?`${Je.round_robin.group_events}`:"1",ut.value===V.Ab.RoundRobin?Oi:void 0,Ie("partition")),pt=Object(c.Tb)((e=>e&&0!==e.length&&e[e.length-1].topic||"")(null==Je?void 0:Je.topics),Ii,Ie("topics")),Et=Object(c.jc)("kafkaTopicsComboBox",!(ft=null==Je?void 0:Je.topics)||ft.length<=1?[]:ft.slice(0,-1),Ti,Ie("topics"));var ft;const bt=Object(c.Wb)("kafkaHeadersComboBox",null!==(ue=null==Je?void 0:Je.headers)&&void 0!==ue?ue:[{key:"",value:""}],wi,Ie("headers")),ht=Object(c.Tb)(null!==(de=null==Je?void 0:Je.client_id)&&void 0!==de?de:"Elastic",Si,Ie("client_id")),yt=Object(c.ic)(!(null==Je||!Je.compression||Je.compression===V.yb.None),Ie("compression")),kt=Object(c.Tb)(`${null!==(ge=null==Je?void 0:Je.compression_level)&&void 0!==ge?ge:4}`,void 0,Ie("compression_level")),vt=Object(c.Tb)(null!=Je&&Je.compression&&Je.compression!==V.yb.None?Je.compression:V.yb.Gzip,void 0,Ie("compression")),xt=Object(c.Tb)(`${null!==(me=null==Je?void 0:Je.timeout)&&void 0!==me?me:30}`,void 0,Ie("broker_timeout")),Ft=Object(c.Tb)(`${null!==(pe=null==Je?void 0:Je.broker_timeout)&&void 0!==pe?pe:30}`,void 0,Ie("timeout")),Mt=Object(c.Tb)(`${null!==(Ee=null==Je?void 0:Je.required_acks)&&void 0!==Ee?Ee:V.wb.Commit}`,void 0,Ie("required_acks")),It=Object(c.Tb)(null==Je?void 0:Je.key,void 0,Ie("key")),St=Oe.value===V.Fb.Logstash,Ot=Oe.value===V.Fb.Kafka,Tt={nameInput:Se,typeInput:Oe,elasticsearchUrlInput:Pe,diskQueueEnabledInput:_e,diskQueuePathInput:De,diskQueueEncryptionEnabled:Re,diskQueueMaxSizeInput:Be,diskQueueCompressionEnabled:Ne,compressionLevelInput:Ue,logstashHostsInput:Ke,additionalYamlConfigInput:Te,defaultOutputInput:we,defaultMonitoringOutputInput:je,caTrustedFingerprintInput:Ce,sslCertificateInput:Qe,sslKeyInput:Ye,sslCertificateAuthoritiesInput:Ve,proxyIdInput:Ze,loadBalanceEnabledInput:ze,memQueueEvents:qe,queueFlushTimeout:Ge,maxBatchBytes:We,kafkaVersionInput:Xe,kafkaHostsInput:et,kafkaVerificationModeInput:ot,kafkaAuthMethodInput:tt,kafkaConnectionTypeInput:at,kafkaAuthUsernameInput:nt,kafkaAuthPasswordInput:lt,kafkaSaslMechanismInput:ct,kafkaPartitionTypeInput:ut,kafkaPartitionTypeRandomInput:dt,kafkaPartitionTypeHashInput:gt,kafkaPartitionTypeRoundRobinInput:mt,kafkaHeadersInput:bt,kafkaClientIdInput:ht,kafkaCompressionInput:yt,kafkaCompressionLevelInput:kt,kafkaCompressionCodecInput:vt,kafkaBrokerTimeoutInput:xt,kafkaBrokerReachabilityTimeoutInput:Ft,kafkaBrokerAckReliabilityInput:Mt,kafkaKeyInput:It,kafkaSslCertificateAuthoritiesInput:it,kafkaSslCertificateInput:st,kafkaSslKeyInput:rt,kafkaDefaultTopicInput:pt,kafkaTopicsInput:Et},wt=Object.values(Tt).some((e=>e.hasChanged)),jt=Object(n.useCallback)((()=>{const e=Se.validate(),t=Pe.validate(),a=et.validate(),n=nt.validate(),l=lt.validate(),i=ht.validate(),s=st.validate(),r=rt.validate(),o=pt.validate(),c=Et.validate(),u=bt.validate(),d=Ke.validate(),g=Te.validate(),m=Ce.validate(),p=Qe.validate(),E=Ye.validate(),f=De.validate(),b=dt.validate(),h=mt.validate();return St?d&&g&&e&&p&&E:Ot?e&&a&&s&&r&&n&&l&&u&&o&&c&&g&&i&&b&&h:t&&g&&e&&m&&f}),[Se,Pe,et,nt,lt,ht,st,rt,pt,Et,bt,Ke,Te,Ce,Qe,Ye,De,dt,mt,St,Ot]),Ct=Object(n.useCallback)((async()=>{try{if(!jt())return;ke(!0);let a={};Le||(a={shipper:{mem_queue_events:qe.value?Number(qe.value):null,queue_flush_timeout:Ge.value?Number(Ge.value):null,max_batch_bytes:We.value?Number(We.value):null}}),!Le&&be&&(a={...a,shipper:{disk_queue_enabled:_e.value,disk_queue_path:_e.value&&De.value?De.value:"",disk_queue_max_size:_e.value&&Be.value?Be.value:null,disk_queue_encryption_enabled:_e.value&&Re.value,disk_queue_compression_enabled:Ne.value,compression_level:Ne.value?Number(Ue.value):null,loadbalance:ze.value}});const n=""!==Ze.value?Ze.value:null,i=(()=>{const e=e=>{if(void 0!==e){const t=parseInt(e,10);if(!isNaN(t))return t}};switch(Oe.value){case V.Fb.Kafka:const t=it.value.filter((e=>""!==e)).length;return{name:Se.value,type:V.Fb.Kafka,hosts:et.value,is_default:we.value,is_default_monitoring:je.value,config_yaml:Te.value,...at.value!==V.zb.Plaintext||tt.value!==V.xb.None?{ssl:{...t?{certificate_authorities:it.value.filter((e=>""!==e))}:{},...tt.value===V.xb.Ssl?{certificate:st.value,key:rt.value}:{},verification_mode:ot.value}}:{},proxy_id:n,client_id:ht.value||void 0,version:Xe.value,...It.value?{key:It.value}:{},compression:yt.value?vt.value:V.yb.None,...yt.value&&vt.value===V.yb.Gzip?{compression_level:e(kt.value)}:{},auth_type:tt.value,...tt.value===V.xb.None?{connection_type:at.value}:{},...tt.value===V.xb.Userpass&&nt.value?{username:nt.value}:{},...tt.value===V.xb.Userpass&<.value?{password:lt.value}:{},...tt.value===V.xb.Userpass&&ct.value?{sasl:{mechanism:ct.value}}:{},partition:ut.value,...ut.value===V.Ab.Random&&dt.value?{random:{group_events:e(dt.value)}}:{},...ut.value===V.Ab.RoundRobin&&mt.value?{round_robin:{group_events:e(mt.value)}}:{},...ut.value===V.Ab.Hash&>.value?{hash:{hash:gt.value}}:{},topics:[...Et.value,{topic:pt.value}],headers:bt.value,timeout:e(xt.value),broker_timeout:e(Ft.value),required_acks:e(Mt.value),...a};case V.Fb.Logstash:return{name:Se.value,type:V.Fb.Logstash,hosts:Ke.value,is_default:we.value,is_default_monitoring:je.value,config_yaml:Te.value,ssl:{certificate:Qe.value,key:Ye.value,certificate_authorities:Ve.value.filter((e=>""!==e))},proxy_id:n,...a};case V.Fb.Elasticsearch:default:return{name:Se.value,type:V.Fb.Elasticsearch,hosts:Pe.value,is_default:we.value,is_default_monitoring:je.value,config_yaml:Te.value,ca_trusted_fingerprint:Ce.value,proxy_id:n,...a}}})();if(t){if(!await async function(e,t){const{agentCount:a,agentPolicyCount:n}=await ji(e);return t(l.a.createElement(Ci,null),l.a.createElement(Pi,{agentCount:a,agentPolicyCount:n,output:e}))}(t,xe))return void ke(!1);const e=await Object(c.ib)(t.id,i);if(e.error)throw e.error}else{const e=await Object(c.bb)(i);if(e.error)throw e.error}e(),ke(!1)}catch(e){ke(!1),ve.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.outputForm.errorToastTitle",{defaultMessage:"Error while saving output"})})}}),[jt,Le,be,Ze.value,t,e,qe.value,Ge.value,We.value,_e.value,De.value,Be.value,Re.value,Ne.value,Ue.value,ze.value,Oe.value,it.value,yt.value,Se.value,et.value,we.value,je.value,Te.value,tt.value,st.value,rt.value,ot.value,ht.value,Xe.value,It.value,vt.value,kt.value,at.value,nt.value,lt.value,ct.value,ut.value,dt.value,mt.value,gt.value,Et.value,pt.value,bt.value,xt.value,Ft.value,Mt.value,Ke.value,Qe.value,Ye.value,Ve.value,Pe.value,Ce.value,xe,ve.toasts]);return{inputs:Tt,submit:Ct,isLoading:ye,hasEncryptedSavedObjectConfigured:he,isShipperEnabled:!Le,isDisabled:ye||t&&!wt||St&&!he}}(e,t),s=i.inputs,{docLinks:r}=Object(c.hc)(),{euiTheme:o}=Object(u.useEuiTheme)(),m=Object(n.useMemo)((()=>a.map((e=>({value:e.id,label:e.name})))),[a]),{kafkaOutput:p}=Rn.b.get(),E=[{value:V.Fb.Elasticsearch,text:"Elasticsearch"},{value:V.Fb.Logstash,text:"Logstash"},...p?[{value:V.Fb.Kafka,text:"Kafka"}]:[]];return l.a.createElement(u.EuiFlyout,{maxWidth:Kl,onClose:e},l.a.createElement(u.EuiFlyoutHeader,{hasBorder:!0},l.a.createElement(u.EuiTitle,{size:"m"},l.a.createElement("h2",{id:"FleetEditOutputFlyoutTitle"},t?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.editTitle",defaultMessage:"Edit output"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.createTitle",defaultMessage:"Add new output"})))),l.a.createElement(u.EuiFlyoutBody,null,(null==t?void 0:t.is_preconfigured)&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiCallOut,{iconType:"lock",title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.preconfiguredOutputCalloutTitle",defaultMessage:"This output is managed outside of Fleet"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.preconfiguredOutputCalloutDescription",defaultMessage:"Most actions related to this output are unavailable. Refer to your kibana config for more detail."})),l.a.createElement(u.EuiSpacer,{size:"m"})),l.a.createElement(u.EuiForm,null,l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.nameInputLabel",defaultMessage:"Name"})},s.nameInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"settingsOutputsFlyout.nameInput",fullWidth:!0},s.nameInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.nameInputPlaceholder",{defaultMessage:"Specify name"})}))),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(l.a.Fragment,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.typeInputLabel",defaultMessage:"Type"}),s.typeInput.value===V.Fb.Kafka&&l.a.createElement(Bi,{label:g.i18n.translate("xpack.fleet.settings.betaBadgeLabel",{defaultMessage:"Beta"}),size:"s",$_css:o.size.s,$_css2:o.colors.text,$_css3:o.size.xxs}))},l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSelect,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.typeInput"},s.typeInput.props,{options:E,placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.typeInputPlaceholder",{defaultMessage:"Specify type"})})),(()=>{const e=s.typeInput.value===V.Fb.Elasticsearch;return s.typeInput.value===V.Fb.Kafka||e?l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"xs"}),l.a.createElement(u.EuiCallOut,{"data-test-subj":`settingsOutputsFlyout.${s.typeInput.value}OutputTypeCallout`,title:(()=>{switch(s.typeInput.value){case V.Fb.Kafka:return g.i18n.translate("xpack.fleet.settings.editOutputFlyout.kafkaOutputTypeCallout",{defaultMessage:"Kafka output is currently not supported on Agents using the Elastic Defend integration."});default:case V.Fb.Elasticsearch:return g.i18n.translate("xpack.fleet.settings.editOutputFlyout.esOutputTypeCallout",{defaultMessage:"This output type currently does not support connectivity to a remote Elasticsearch cluster."})}})(),iconType:"alert",color:"warning",size:"s",heading:"p"})):null})())),(e=>{switch(e){case V.Fb.Logstash:return l.a.createElement(l.a.Fragment,null,!i.hasEncryptedSavedObjectConfigured&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Li,null)),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(Jl,null),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement($l.a,T()({placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.logstashHostsInputPlaceholder",{defaultMessage:"Specify host"}),sortable:!1,helpText:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.logstashHostsInputDescription",defaultMessage:"Specify the addresses that your agents will use to connect to Logstash. {guideLink}.",values:{guideLink:l.a.createElement(u.EuiLink,{href:r.links.fleet.logstashSettings,target:"_blank",external:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetSettingsLink",defaultMessage:"Learn more"}))}}),label:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.logstashHostsInputLabel",{defaultMessage:"Logstash hosts"})},s.logstashHostsInput.props)),l.a.createElement($l.a,T()({placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslCertificateAuthoritiesInputPlaceholder",{defaultMessage:"Specify certificate authority"}),label:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslCertificateAuthoritiesInputLabel",{defaultMessage:"Server SSL certificate authorities (optional)"}),multiline:!0,sortable:!1},s.sslCertificateAuthoritiesInput.props)),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.sslCertificateInputLabel",defaultMessage:"Client SSL certificate"})},s.sslCertificateInput.formRowProps),l.a.createElement(u.EuiTextArea,T()({fullWidth:!0,rows:5},s.sslCertificateInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslCertificateInputPlaceholder",{defaultMessage:"Specify ssl certificate"})}))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.sslKeyInputLabel",defaultMessage:"Client SSL certificate key"})},s.sslKeyInput.formRowProps),l.a.createElement(u.EuiTextArea,T()({fullWidth:!0,rows:5},s.sslKeyInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.sslKeyInputPlaceholder",{defaultMessage:"Specify certificate key"})}))));case V.Fb.Kafka:return p?l.a.createElement(ui,{inputs:s}):null;case V.Fb.Elasticsearch:default:return l.a.createElement(l.a.Fragment,null,l.a.createElement($l.a,T()({"data-test-subj":"settingsOutputsFlyout.hostUrlInput",label:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.esHostsInputLabel",{defaultMessage:"Hosts"}),placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.esHostsInputPlaceholder",{defaultMessage:"Specify host URL"})},s.elasticsearchUrlInput.props,{isUrl:!0})),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.caTrustedFingerprintInputLabel",defaultMessage:"Elasticsearch CA trusted fingerprint (optional)"})},s.caTrustedFingerprintInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({fullWidth:!0},s.caTrustedFingerprintInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.caTrustedFingerprintInputPlaceholder",{defaultMessage:"Specify Elasticsearch CA trusted fingerprint"})}))))}})(s.typeInput.value),l.a.createElement(u.EuiFormRow,{fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.proxyIdLabel",defaultMessage:"Proxy"})},l.a.createElement(u.EuiComboBox,T()({fullWidth:!0,"data-test-subj":"settingsOutputsFlyout.proxyIdInput"},s.proxyIdInput.props,{onChange:e=>{var t,a;return s.proxyIdInput.setValue(null!==(t=null==e||null===(a=e[0])||void 0===a?void 0:a.value)&&void 0!==t?t:"")},selectedOptions:""!==s.proxyIdInput.value?m.filter((e=>e.value===s.proxyIdInput.value)):[],options:m,singleSelection:{asPlainText:!0},isDisabled:s.proxyIdInput.props.disabled,isClearable:!0,placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.proxyIdPlaceholder",{defaultMessage:"Select proxy"})}))),l.a.createElement(u.EuiFormRow,T()({label:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.yamlConfigInputLabel",{defaultMessage:"Advanced YAML configuration"})},s.additionalYamlConfigInput.formRowProps,{fullWidth:!0}),l.a.createElement(pi,{value:s.additionalYamlConfigInput.value,onChange:s.additionalYamlConfigInput.setValue,disabled:s.additionalYamlConfigInput.props.disabled,placeholder:g.i18n.translate("xpack.fleet.settings.editOutputFlyout.yamlConfigInputPlaceholder",{defaultMessage:"# YAML settings here will be added to the output section of each agent policy."})})),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},s.defaultOutputInput.formRowProps),l.a.createElement(u.EuiSwitch,T()({},s.defaultOutputInput.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.defaultOutputSwitchLabel",defaultMessage:"Make this output the default for {boldAgentIntegrations}.",values:{boldAgentIntegrations:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.agentIntegrationsBold",defaultMessage:"agent integrations"}))}})}))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},s.defaultMonitoringOutputInput.formRowProps),l.a.createElement(u.EuiSwitch,T()({},s.defaultMonitoringOutputInput.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.defaultMontoringOutputSwitchLabel",defaultMessage:"Make this output the default for {boldAgentMonitoring}.",values:{boldAgentMonitoring:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editOutputFlyout.agentMonitoringBold",defaultMessage:"agent monitoring"}))}})}))),l.a.createElement(u.EuiSpacer,{size:"l"}),l.a.createElement(_i,{enabled:i.isShipperEnabled,inputs:s}))),l.a.createElement(u.EuiFlyoutFooter,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:e,flush:"left"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.cancelButtonLabel",defaultMessage:"Cancel"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{fill:!0,isLoading:i.isLoading,isDisabled:i.isDisabled,onClick:i.submit,"data-test-subj":"saveApplySettingsBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetServerHostsFlyout.saveButton",defaultMessage:"Save and apply settings"}))))))};var Bi=p()(u.EuiBetaBadge).withConfig({displayName:"_StyledEuiBetaBadge",componentId:"sc-1v16k6o-0"})(["margin-left:",";color:",";vertical-align:middle;margin-bottom:",";"],(e=>e.$_css),(e=>e.$_css2),(e=>e.$_css3));const Ri=()=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteFleetProxy.confirmModalTitle",defaultMessage:"Delete and deploy changes?"}),zi=({})=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteFleetProxy.confirmModalText",defaultMessage:"This action will change agent policies currently using that proxy. Are you sure you wish to continue?"}),Ni=()=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteOutput.confirmModalTitle",defaultMessage:"Delete and deploy changes?"}),Hi=({output:e,agentCount:t,agentPolicyCount:a})=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteOutput.confirmModalText",defaultMessage:"This action will delete {outputName} output. It will update {policies} and {agents}. This action can not be undone. Are you sure you wish to continue?",values:{outputName:l.a.createElement("strong",null,e.name),agents:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteOutput.agentsCount",defaultMessage:"{agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:t}})),policies:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteOutput.agentPolicyCount",defaultMessage:"{agentPolicyCount, plural, one {# agent policy} other {# agent policies}}",values:{agentPolicyCount:a}}))}}),Ui=()=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteFleetServerHosts.confirmModalTitle",defaultMessage:"Delete and deploy changes?"}),qi=({})=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteFleetServerHosts.confirmModalText",defaultMessage:"This action will change agent policies currently enrolled in this Fleet Server, to instead enroll in your default Fleet server. Are you sure you wish to continue?"});async function Gi(e){var t,a,n;let l=`${F.c}.download_source_id:"${e.id}"`;e.is_default&&(l+=` or (not ${F.c}.download_source_id:*)`);const i=await Object(c.v)({kuery:l,page:1,perPage:F.p});if(i.error)throw i.error;const s=null!==(t=null===(a=i.data)||void 0===a||null===(n=a.items)||void 0===n?void 0:n.length)&&void 0!==t?t:0;let r=0;if(s>0){var o,u,d;const e=await Object(c.z)({page:1,perPage:0,showInactive:!1,kuery:null===(o=i.data)||void 0===o?void 0:o.items.map((e=>`policy_id:"${e.id}"`)).join(" or ")});if(e.error)throw e.error;r=null!==(u=null===(d=e.data)||void 0===d?void 0:d.total)&&void 0!==u?u:0}return{agentPolicyCount:s,agentCount:r}}const Wi=({downloadSource:e,agentCount:t,agentPolicyCount:a})=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateDownloadSourceModal.confirmModalText","data-test-subj":"editDownloadSourcesConfirmModal.confirmModalText",defaultMessage:"This action will update {downloadSourceName} agent binary source. It will update {policies} and {agents}. This action can not be undone. Are you sure you wish to continue?",values:{downloadSourceName:l.a.createElement("strong",null,e.name),agents:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateDownloadSourceModal.agentsCount",defaultMessage:"{agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:t}})),policies:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateDownloadSourceModal.agentPolicyCount",defaultMessage:"{agentPolicyCount, plural, one {# agent policy} other {# agent policies}}",values:{agentPolicyCount:a}}))}});function $i(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.dowloadSourceFlyoutForm.nameIsRequiredErrorMessage",{defaultMessage:"Name is required"})]}function Ki(e){try{if(!e)return[g.i18n.translate("xpack.fleet.settings.dowloadSourceFlyoutForm.HostIsRequiredErrorMessage",{defaultMessage:"Host is required"})];const t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol")}catch(e){return[g.i18n.translate("xpack.fleet.settings.dowloadSourceFlyoutForm.hostError",{defaultMessage:"Invalid URL"})]}}const Vi=({onClose:e,downloadSource:t})=>{Object(c.ub)("settings");const a=function(e,t){var a,i,s;const[r,o]=Object(n.useState)(!1),{notifications:u}=Object(c.hc)(),{confirm:m}=Object(Wl.a)(),p=Object(c.Tb)(null!==(a=null==t?void 0:t.name)&&void 0!==a?a:"",$i),E=Object(c.ic)(null!==(i=null==t?void 0:t.is_default)&&void 0!==i&&i,null==t?void 0:t.is_default),f=Object(c.Tb)(null!==(s=null==t?void 0:t.host)&&void 0!==s?s:"",Ki),b={nameInput:p,hostInput:f,defaultDownloadSourceInput:E},h=Object.values(b).some((e=>e.hasChanged)),y=Object(n.useCallback)((()=>{const e=p.validate(),t=f.validate();return e&&t}),[p,f]),k=Object(n.useCallback)((async()=>{try{if(!y())return;o(!0);const a={name:p.value.trim(),host:f.value.trim(),is_default:E.value};if(t){if(!await async function(e,t){const{agentCount:a,agentPolicyCount:n}=await Gi(e);return t(l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.updateDownloadSourceModal.confirmModalTitle",defaultMessage:"Save and deploy changes?"}),l.a.createElement(Wi,{agentCount:a,agentPolicyCount:n,downloadSource:e}))}(t,m))return void o(!1);const e=await Object(c.fb)(t.id,a);if(e.error)throw e.error}else{const e=await Object(c.W)(a);if(e.error)throw e.error}e(),o(!1)}catch(e){o(!1),u.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.dowloadSourceFlyoutForm.errorToastTitle",{defaultMessage:"Error while saving binary source"})})}}),[m,E.value,t,f.value,p.value,u.toasts,e,y]);return{inputs:b,submit:k,isLoading:r,isDisabled:r||t&&!h}}(e,t),i=a.inputs,{docLinks:s}=Object(c.hc)();return l.a.createElement(u.EuiFlyout,{maxWidth:Kl,onClose:e},l.a.createElement(u.EuiFlyoutHeader,{hasBorder:!0},l.a.createElement(u.EuiTitle,{size:"m"},l.a.createElement("h2",{id:"FleetEditDownloadSourcesFlyoutTitle"},t?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.editTitle",defaultMessage:"Edit agent binary source","data-test-subj":"editDownloadSourcesFlyout.edit.title"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.createTitle",defaultMessage:"Add new agent binary source","data-test-subj":"editDownloadSourcesFlyout.add.title"})))),l.a.createElement(u.EuiFlyoutBody,null,l.a.createElement(u.EuiForm,null,l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.nameInputLabel",defaultMessage:"Name"})},i.nameInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"editDownloadSourcesFlyout.nameInput",fullWidth:!0},i.nameInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editDownloadSourcesFlyout.nameInputPlaceholder",{defaultMessage:"Specify name"})}))),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0,helpText:l.a.createElement(d.FormattedMessage,{"data-test-subj":"editDownloadSourcesFlyout.hostHelpText",id:"xpack.fleet.settings.editDownloadSourcesFlyout.hostsInputDescription",defaultMessage:"Address that your agents will use to download their binary from. Specify the path to the directory containing the binary. {guideLink}",values:{guideLink:l.a.createElement(u.EuiLink,{href:s.links.fleet.settings,target:"_blank",external:!0},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetSettingsLink",defaultMessage:"Learn more"}))}}),label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.hostInputLabel",defaultMessage:"Host"})},i.hostInput.formRowProps),l.a.createElement(u.EuiFieldText,T()({"data-test-subj":"editDownloadSourcesFlyout.hostInput",fullWidth:!0},i.hostInput.props,{placeholder:g.i18n.translate("xpack.fleet.settings.editDownloadSourcesFlyout.hostsInputPlaceholder",{defaultMessage:"Specify host"})}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFormRow,T()({fullWidth:!0},i.defaultDownloadSourceInput.formRowProps),l.a.createElement(u.EuiSwitch,T()({"data-test-subj":"editDownloadSourcesFlyout.isDefaultSwitch"},i.defaultDownloadSourceInput.props,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.defaultSwitchLabel",defaultMessage:"Make this host the default for all agent policies."})}))))),l.a.createElement(u.EuiFlyoutFooter,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:e,flush:"left","data-test-subj":"editDownloadSourcesFlyout.cancelBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.cancelButtonLabel",defaultMessage:"Cancel"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{fill:!0,isLoading:a.isLoading,isDisabled:a.isDisabled,onClick:a.submit,"data-test-subj":"editDownloadSourcesFlyout.submitBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.editDownloadSourcesFlyout.saveButton",defaultMessage:"Save and apply settings"}))))))},Qi=()=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteDowloadSource.confirmModalTitle",defaultMessage:"Delete and deploy changes?"}),Yi=({downloadSource:e,agentCount:t,agentPolicyCount:a})=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteDowloadSource.confirmModalText",defaultMessage:"This action will delete {downloadSourceName} agent binary source. It will update {policies} and {agents}. This action can not be undone. Are you sure you wish to continue?",values:{downloadSourceName:l.a.createElement("strong",null,e.name),agents:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteDowloadSource.agentsCount",defaultMessage:"{agentCount, plural, one {# agent} other {# agents}}",values:{agentCount:t}})),policies:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.deleteDowloadSource.agentPolicyCount",defaultMessage:"{agentPolicyCount, plural, one {# agent policy} other {# agent policies}}",values:{agentPolicyCount:a}}))}}),Zi=/^(http)(s)?:\/\/[^\s$.?#].[^\s]*$/gm,Ji=()=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.confirmModalTitle",defaultMessage:"Save and deploy changes?"}),Xi=({})=>l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.confirmModalText",defaultMessage:"This action will update agent policies using that proxies. This action can not be undone. Are you sure you wish to continue?"});function es(e){return e&&""!==e?e.match(Zi)?void 0:[g.i18n.translate("xpack.fleet.settings.fleetProxyFlyoutUrlError",{defaultMessage:"Invalid URL"})]:[g.i18n.translate("xpack.fleet.settings.fleetProxyFlyoutUrlRequired",{defaultMessage:"URL is required"})]}function ts(e){if(e&&""!==e){const t=Object(Za.safeLoad)(e);if("object"!=typeof t||Object.values(t).some((e=>{const t=typeof e;return"string"!==t&&"number"!==t&&"boolean"!==t})))return[g.i18n.translate("xpack.fleet.settings.fleetProxy.proxyHeadersErrorMessage",{defaultMessage:"Proxy headers is not a valid key: value object."})]}}function as(e){if(!e||""===e)return[g.i18n.translate("xpack.fleet.settings.fleetProxy.nameIsRequiredErrorMessage",{defaultMessage:"Name is required"})]}const ns=({onClose:e,fleetProxy:t})=>{const a=function(e,t){var a,i,s,r,o,u;const[d,m]=Object(n.useState)(!1),{notifications:p}=Object(c.hc)(),{confirm:E}=Object(Wl.a)(),f=null!==(a=null==e?void 0:e.is_preconfigured)&&void 0!==a&&a,b=Object(c.Tb)(null!==(i=null==e?void 0:e.name)&&void 0!==i?i:"",as,f),h=Object(c.Tb)(null!==(s=null==e?void 0:e.url)&&void 0!==s?s:"",es,f),y=Object(c.Tb)(null!=e&&e.proxy_headers?Object(Za.safeDump)(e.proxy_headers):"",ts,f),k=Object(c.Tb)(null!==(r=null==e?void 0:e.certificate_authorities)&&void 0!==r?r:"",(()=>{}),f),v=Object(c.Tb)(null!==(o=null==e?void 0:e.certificate)&&void 0!==o?o:"",(()=>{}),f),x=Object(c.Tb)(null!==(u=null==e?void 0:e.certificate_key)&&void 0!==u?u:"",(()=>{}),f),F=Object(n.useMemo)((()=>({nameInput:b,urlInput:h,proxyHeadersInput:y,certificateAuthoritiesInput:k,certificateInput:v,certificateKeyInput:x})),[b,h,y,k,v,x]),M=Object(n.useCallback)((()=>Object(c.mc)(F)),[F]),I=Object(n.useCallback)((async()=>{try{if(!M())return;if(e&&!await E(l.a.createElement(Ji,null),l.a.createElement(Xi,null)))return;m(!0);const a={name:b.value,url:h.value,proxy_headers:""===y.value?void 0:Object(Za.safeLoad)(y.value),certificate_authorities:k.value,certificate:v.value,certificate_key:x.value};if(e){const t=await Object(c.gb)(e.id,a);if(t.error)throw t.error}else{const e=await Object(c.X)(a);if(e.error)throw e.error}p.toasts.addSuccess(g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.successToastTitle",{defaultMessage:"Fleet proxy saved"})),m(!1),await t()}catch(e){m(!1),p.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.errorToastTitle",{defaultMessage:"An error happened while saving Fleet Server host"})})}}),[e,b.value,h.value,y.value,k.value,v.value,x.value,M,p,E,t]),S=Object.values(F).some((e=>e.hasChanged));return{isLoading:d,isDisabled:d||!S||b.props.isInvalid||h.props.isInvalid,submit:I,inputs:F}}(t,e),{inputs:i}=a;return l.a.createElement(u.EuiFlyout,{maxWidth:Kl,onClose:e},l.a.createElement(u.EuiFlyoutHeader,{hasBorder:!0},l.a.createElement(u.EuiTitle,{size:"m"},l.a.createElement("h2",null,t?l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.editTitle",defaultMessage:"Edit Proxy"}):l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.addTitle",defaultMessage:"Add Proxy"})))),l.a.createElement(u.EuiFlyoutBody,null,l.a.createElement(u.EuiForm,{onSubmit:a.submit},l.a.createElement(Vl,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.nameInputLabel",defaultMessage:"Name"}),inputProps:i.nameInput,"data-test-subj":"fleetProxyFlyout.nameInput",placeholder:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.nameInputPlaceholder",{defaultMessage:"Specify name"})}),l.a.createElement(Vl,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.urlInputLabel",defaultMessage:"Proxy Url"}),dataTestSubj:"fleetProxyFlyout.urlInput",inputProps:i.urlInput,placeholder:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.urlInputPlaceholder",{defaultMessage:"Specify proxy url"})}),l.a.createElement(Ql,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.proxyHeadersLabel",defaultMessage:"Proxy headers"}),dataTestSubj:"fleetProxyFlyout.proxyHeadersInput",inputProps:i.proxyHeadersInput,placeholder:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.proxyHeadersPlaceholder",{defaultMessage:"Specify proxy headers"})}),l.a.createElement(Vl,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.certificateAuthoritiesLabel",defaultMessage:"Certificate authorities"}),dataTestSubj:"fleetProxyFlyout.certificateAuthoritiesInput",inputProps:i.certificateAuthoritiesInput,placeholder:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.certificateAuthoritiesPlaceholder",{defaultMessage:"Specify certificate authorities"})}),l.a.createElement(Vl,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.certificateLabel",defaultMessage:"Certificate"}),dataTestSubj:"fleetProxyFlyout.certificateInput",inputProps:i.certificateInput,placeholder:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.certificatePlaceholder",{defaultMessage:"Specify certificate"})}),l.a.createElement(Vl,{label:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.certificateKeyLabel",defaultMessage:"Certificate key"}),dataTestSubj:"fleetProxyFlyout.certificateKeyInput",inputProps:i.certificateKeyInput,placeholder:g.i18n.translate("xpack.fleet.settings.fleetProxyFlyout.certificateKeyPlaceholder",{defaultMessage:"Specify certificate key"})}))),l.a.createElement(u.EuiFlyoutFooter,null,l.a.createElement(u.EuiFlexGroup,{justifyContent:"spaceBetween"},l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButtonEmpty,{onClick:()=>e(),flush:"left"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.cancelButtonLabel",defaultMessage:"Cancel"}))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{fill:!0,isLoading:a.isLoading,isDisabled:a.isDisabled,onClick:a.submit,"data-test-subj":"saveApplySettingsBtn"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.settings.fleetProxyFlyout.saveButton",defaultMessage:"Save and apply settings"}))))))},ls=Object(Wl.b)((()=>{var e,t,a,i;Object(c.ub)("settings");const s=Object(r.useHistory)(),d=Object(c.Eb)(),{outputs:m,fleetServerHosts:p,downloadSources:E,proxies:f}={outputs:Object(c.Ob)(),fleetServerHosts:Object(c.Kb)(),downloadSources:Object(c.Hb)(),proxies:Object(c.Jb)()},{deleteOutput:b}=function(e){const{confirm:t}=Object(Wl.a)(),{notifications:a}=Object(c.hc)();return{deleteOutput:Object(n.useCallback)((async n=>{try{const{agentCount:a,agentPolicyCount:i}=await ji(n);if(!await t(l.a.createElement(Ni,null),l.a.createElement(Hi,{output:n,agentCount:a,agentPolicyCount:i}),{buttonColor:"danger",confirmButtonText:g.i18n.translate("xpack.fleet.settings.deleteOutputs.confirmButtonLabel",{defaultMessage:"Delete and deploy"})}))return;const s=await Object(c.r)(n.id);if(s.error)throw s.error;e()}catch(e){a.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.deleteOutputs.errorToastTitle",{defaultMessage:"Error deleting output"})})}}),[t,a.toasts,e])}}(m.resendRequest),{deleteDownloadSource:h}=function(e){const{confirm:t}=Object(Wl.a)(),{notifications:a}=Object(c.hc)();return{deleteDownloadSource:Object(n.useCallback)((async n=>{try{const{agentCount:a,agentPolicyCount:i}=await Gi(n);if(!await t(l.a.createElement(Qi,null),l.a.createElement(Yi,{"data-test-subj":"editDownloadSourcesDeleteModal.confirmModalText",downloadSource:n,agentCount:a,agentPolicyCount:i}),{buttonColor:"danger",confirmButtonText:g.i18n.translate("xpack.fleet.settings.deleteDownloadSource.confirmButtonLabel",{defaultMessage:"Delete and deploy"})}))return;const s=await Object(c.n)(n.id);if(s.error)throw s.error;e()}catch(e){a.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.deleteDownloadSource.errorToastTitle",{defaultMessage:"Error deleting agent binary source."})})}}),[t,a.toasts,e])}}(E.resendRequest),{deleteFleetServerHost:y}=function(e){const{confirm:t}=Object(Wl.a)(),{notifications:a}=Object(c.hc)();return{deleteFleetServerHost:Object(n.useCallback)((async n=>{try{if(!await t(l.a.createElement(Ui,null),l.a.createElement(qi,null),{buttonColor:"danger",confirmButtonText:g.i18n.translate("xpack.fleet.settings.deleteFleetServerHosts.confirmButtonLabel",{defaultMessage:"Delete and deploy changes"})}))return;const a=await Object(c.p)(n.id);if(a.error)throw a.error;e()}catch(e){a.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.deleteFleetServerHosts.errorToastTitle",{defaultMessage:"Error deleting Fleet Server hosts"})})}}),[t,a.toasts,e])}}(p.resendRequest),{deleteFleetProxy:k}=function(e){const{confirm:t}=Object(Wl.a)(),{notifications:a}=Object(c.hc)();return{deleteFleetProxy:Object(n.useCallback)((async n=>{try{if(!await t(l.a.createElement(Ri,null),l.a.createElement(zi,null),{buttonColor:"danger",confirmButtonText:g.i18n.translate("xpack.fleet.settings.deleteFleetProxy.confirmButtonLabel",{defaultMessage:"Delete and deploy changes"})}))return;const a=await Object(c.o)(n.id);if(a.error)throw a.error;e()}catch(e){a.toasts.addError(e,{title:g.i18n.translate("xpack.fleet.settings.deleteFleetProxy.errorToastTitle",{defaultMessage:"Error deleting proxy"})})}}),[t,a.toasts,e])}}(f.resendRequest),v=m.resendRequest,I=E.resendRequest,S=p.resendRequest,O=f.resendRequest,T=Object(n.useCallback)((()=>{d.closeFleetServerFlyout(),v(),I(),S(),O(),s.replace(F.q.settings()[1])}),[d,v,I,S,O,s]);return m.isLoading&&m.isInitialRequest||null===(e=m.data)||void 0===e||!e.items||p.isLoading&&p.isInitialRequest||null===(t=p.data)||void 0===t||!t.items||E.isLoading&&E.isInitialRequest||null===(a=E.data)||void 0===a||!a.items||f.isLoading&&f.isInitialRequest||null===(i=f.data)||void 0===i||!i.items?l.a.createElement(M.a,{section:"settings"},l.a.createElement(x.r,null)):l.a.createElement(M.a,{section:"settings"},l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.settings_edit_fleet_server_hosts},(e=>{var t,a,n;const i=null===(t=p.data)||void 0===t?void 0:t.items.find((t=>e.match.params.itemId===t.id));return i?l.a.createElement(u.EuiPortal,null,l.a.createElement(Zl,{proxies:null!==(a=null===(n=f.data)||void 0===n?void 0:n.items)&&void 0!==a?a:[],onClose:T,fleetServerHost:i})):l.a.createElement(r.Redirect,{to:F.h.settings})})),l.a.createElement(o.a,{path:F.h.settings_create_fleet_server_hosts},l.a.createElement(u.EuiPortal,null,l.a.createElement(x.m,{onClose:T}))),l.a.createElement(o.a,{path:F.h.settings_create_outputs},l.a.createElement(u.EuiPortal,null,l.a.createElement(Di,{proxies:f.data.items,onClose:T}))),l.a.createElement(o.a,{path:F.h.settings_create_fleet_proxy},l.a.createElement(u.EuiPortal,null,l.a.createElement(ns,{onClose:T}))),l.a.createElement(o.a,{path:F.h.settings_edit_fleet_proxy},(e=>{var t;const a=null===(t=f.data)||void 0===t?void 0:t.items.find((t=>e.match.params.itemId===t.id));return a?l.a.createElement(u.EuiPortal,null,l.a.createElement(ns,{onClose:T,fleetProxy:a})):l.a.createElement(r.Redirect,{to:F.h.settings})})),l.a.createElement(o.a,{path:F.h.settings_edit_outputs},(e=>{var t,a,n;const i=null===(t=m.data)||void 0===t?void 0:t.items.find((t=>e.match.params.outputId===t.id));return i?l.a.createElement(u.EuiPortal,null,l.a.createElement(Di,{proxies:null!==(a=null===(n=f.data)||void 0===n?void 0:n.items)&&void 0!==a?a:[],onClose:T,output:i})):l.a.createElement(r.Redirect,{to:F.h.settings})})),l.a.createElement(o.a,{path:F.h.settings_create_download_sources},l.a.createElement(u.EuiPortal,null,l.a.createElement(Vi,{onClose:T}))),l.a.createElement(o.a,{path:F.h.settings_edit_download_sources},(e=>{var t;const a=null===(t=E.data)||void 0===t?void 0:t.items.find((t=>e.match.params.downloadSourceId===t.id));return a?l.a.createElement(u.EuiPortal,null,l.a.createElement(Vi,{onClose:T,downloadSource:a})):l.a.createElement(r.Redirect,{to:F.h.settings})}))),l.a.createElement(Gl,{deleteFleetProxy:k,proxies:f.data.items,outputs:m.data.items,fleetServerHosts:p.data.items,deleteOutput:b,deleteFleetServerHost:y,downloadSources:E.data.items,deleteDownloadSource:h}))})),is=({value:e})=>l.a.createElement(y.CodeEditor,{isCopyable:!0,languageId:"",height:"600px",width:"100%",options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,readOnly:!0,tabSize:2,lineNumbers:"off",lineNumbersMinChars:0,glyphMargin:!1,lineDecorationsWidth:0,overviewRulerBorder:!1},value:e}),ss=async()=>{const e=await Object(c.v)({full:!0,perPage:F.p,sortOrder:"asc"});if(e.error)throw new Error(e.error.message);return e},rs=()=>{var e,t;const{getHref:a}=Object(c.Zb)(),[i,s]=Object(n.useState)(),{data:r,status:o}=Object(b.useQuery)(["debug-agent-policies"],ss),m=null!==(e=null==r||null===(t=r.data)||void 0===t?void 0:t.items)&&void 0!==e?e:[],p=m.map((e=>({label:`${e.name} - ${e.id}`,value:e.id}))),E=i?[p.find((e=>e.value===i))]:[],f=m.find((e=>e.id===i)),h=()=>{s(void 0),Ss.invalidateQueries(["debug-agent-policies"])};return"error"===o?l.a.createElement(u.EuiCallOut,{title:"Error",color:"danger"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.agentPolicyDebugger.fetchError",defaultMessage:"Error fetching Agent Policies"})):l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.agentPolicyDebugger.description",defaultMessage:"Search for an Agent Policy using its name or {codeId} value. Use the code block below to diagnose any potential issues with the policy's configuration.",values:{codeId:l.a.createElement(u.EuiCode,null,"id")}}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{alignItems:"center",justifyContent:"flexStart"},l.a.createElement(os,{grow:!1},l.a.createElement(u.EuiComboBox,{"aria-label":g.i18n.translate("xpack.fleet.debug.agentPolicyDebugger.selectLabel",{defaultMessage:"Select an Agent Policy"}),placeholder:g.i18n.translate("xpack.fleet.debug.agentPolicyDebugger.selectLabel",{defaultMessage:"Select an Agent Policy"}),fullWidth:!0,options:p,singleSelection:{asPlainText:!0},selectedOptions:E,isLoading:"loading"===o,onChange:e=>{e.length?s(e[0].value):s(void 0)}})),i&&l.a.createElement(S.c,{hasFleetServer:Object(j.t)(f)},(e=>l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement("div",null,l.a.createElement(u.EuiButton,{color:"danger",onClick:()=>e(i,h)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.policyForm.deletePolicyActionText",defaultMessage:"Delete policy"}))))))),i&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiLink,{target:"_blank",href:a("policy_details",{policyId:i})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.agentPolicyDebugger.viewAgentPolicyLink",defaultMessage:"View Agent Policy in Fleet UI"})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(is,{value:JSON.stringify(f,null,2)})))};var os=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem",componentId:"sc-1uw5h1v-0"})(["min-width:600px;"]),cs=a(51);const us=async()=>{var e;const t=await Object(c.I)({prerelease:!0});if(t.error)throw new Error(t.error.message);return null===(e=t.data)||void 0===e?void 0:e.items.filter((({status:e})=>"installed"===e))},ds=()=>{var e,t,a,i,s;const{http:r,notifications:o}=Object(c.hc)(),{getHref:m}=Object(c.Zb)(),[p,E]=Object(n.useState)(),[f,h]=Object(n.useState)(!1),[y,k]=Object(n.useState)(!1),v=Object(b.useQuery)(["debug-integrations"],us),x=Object(b.useMutation)((async e=>{const t=await Object(c.jb)(e.name,e.version,!0);if(t.error)throw o.toasts.addError(t.error,{title:g.i18n.translate("xpack.fleet.debug.integrationDebugger.uninstall.error",{defaultMessage:"Error uninstalling {integrationTitle}",values:{integrationTitle:e.title}}),toastMessage:t.error.message}),k(!1),new Error(t.error.message);return o.toasts.addSuccess(g.i18n.translate("xpack.fleet.debug.integrationDebugger.uninstall.success",{defaultMessage:"Successfully uninstalled {integrationTitle}",values:{integrationTitle:e.title}})),E(void 0),k(!1),Ss.invalidateQueries(["debug-integrations"]),t.data})),F=Object(b.useMutation)((async e=>{const t=await Object(c.jb)(e.name,e.version,!0);if(t.error)throw o.toasts.addError(t.error,{title:g.i18n.translate("xpack.fleet.debug.integrationDebugger.reinstall.error",{defaultMessage:"Error reinstalling {integrationTitle}",values:{integrationTitle:e.title}}),toastMessage:t.error.message}),h(!1),new Error(t.error.message);const a=await Object(c.L)(e.name,e.version);if(a.error)throw o.toasts.addError(new Error(a.error.message),{title:g.i18n.translate("xpack.fleet.debug.integrationDebugger.reinstall.error",{defaultMessage:"Error reinstalling {integrationTitle}",values:{integrationTitle:e.title}}),toastMessage:a.error.message}),h(!1),new Error(a.error.message);return o.toasts.addSuccess(g.i18n.translate("xpack.fleet.debug.integrationDebugger.reinstall.success",{defaultMessage:"Successfully reinstalled {integrationTitle}",values:{integrationTitle:e.title}})),E(void 0),h(!1),Ss.invalidateQueries(["debug-integrations"]),a.data}));if("error"===v.status)return l.a.createElement(u.EuiCallOut,{title:"Error",color:"danger"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.integrationDebugger.fetchError",defaultMessage:"Error fetching installed Integrations"}));const M=null!==(e=null===(t=v.data)||void 0===t?void 0:t.map((e=>({label:e.name,value:e.id,icon:Object(cs.a)(e,r.basePath)}))))&&void 0!==e?e:[],I=p?[M.find((e=>e.value===p))]:[],S=null===(a=v.data)||void 0===a?void 0:a.find((e=>e.id===p));return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.integrationDebugger.description",defaultMessage:"Use this tool to uninstall or reinstall installed integrations."})),l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.integrationDebugger.reinstallationDescription",defaultMessage:"Reinstalling an integration will uninstall and then immediately install it again. This can be useful in restoring broken or malformed integration installations when a user hasn't done much customization."}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{alignItems:"center",justifyContent:"flexStart"},l.a.createElement(gs,{grow:!1},l.a.createElement(u.EuiComboBox,{"aria-label":g.i18n.translate("xpack.fleet.debug.integrationDebugger.selectLabel",{defaultMessage:"Select an Integration"}),placeholder:g.i18n.translate("xpack.fleet.debug.integrationDebugger.selectLabel",{defaultMessage:"Select an Integration"}),fullWidth:!0,options:M,singleSelection:{asPlainText:!0},selectedOptions:I,isDisabled:"loading"===v.status,prepend:I.length>0?l.a.createElement(u.EuiButtonEmpty,null,l.a.createElement(u.EuiIcon,{type:null!==(i=null===(s=I[0])||void 0===s?void 0:s.icon)&&void 0!==i?i:"fleetApp"})):void 0,renderOption:(e,t,a)=>l.a.createElement("span",{className:a},l.a.createElement(u.EuiIcon,{type:e.icon})," ",l.a.createElement(u.EuiHighlight,{search:t},e.label)),onChange:e=>{e.length?E(e[0].value):E(void 0)}})),S&&l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"primary",onClick:()=>h(!0)},"Reinstall")),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement(u.EuiButton,{color:"danger",onClick:()=>k(!0)},"Uninstall")),f&&l.a.createElement(u.EuiConfirmModal,{title:`Reinstall ${S.title}`,onCancel:()=>h(!1),onConfirm:()=>F.mutate(S),isLoading:F.isLoading,cancelButtonText:g.i18n.translate("xpack.fleet.debug.integrationDebugger.cancelReinstall",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.debug.integrationDebugger.confirmReinstall",{defaultMessage:"Reinstall"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.integrationDebugger.reinstallModal",defaultMessage:"Are you sure you want to reinstall {integrationTitle}?",values:{integrationTitle:S.title}})),y&&l.a.createElement(u.EuiConfirmModal,{title:`Uninstall ${S.title}`,onCancel:()=>k(!1),onConfirm:()=>x.mutate(S),isLoading:x.isLoading,cancelButtonText:g.i18n.translate("xpack.fleet.debug.integrationDebugger.cancelUninstall",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.debug.integrationDebugger.confirmUninstall",{defaultMessage:"Uninstall"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.integrationDebugger.uninstallModal",defaultMessage:"Are you sure you want to uninstall {integrationTitle}?",values:{integrationTitle:S.title}})))),S&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiLink,{target:"_blank",href:m("integration_details_overview",{pkgkey:Object(j.s)({name:S.name,version:S.version})})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.integrationDebugger.viewIntegrationLink",defaultMessage:"View integration settings in Integrations UI"}))))};var gs=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem",componentId:"sc-xg6n36-0"})(["min-width:600px;"]);const ms=Object(n.forwardRef)((({name:e,setName:t,type:a,setNamesStatus:i},s)=>{const{data:r,refetch:o,status:d}=Object(b.useQuery)(["debug-saved-object-names",a],(()=>(async e=>{var t;const a={size:0,query:{bool:{filter:{term:{type:e}}}},aggs:{names:{terms:{field:`${e}.name`,size:500}}}},n=await Object(c.kb)({method:"post",path:"/api/console/proxy",query:{path:"/.kibana/_search",method:"GET"},body:a});if(n.error)throw new Error(n.error.message);return null===(t=n.data)||void 0===t?void 0:t.aggregations.names.buckets})(a)),{refetchOnWindowFocus:!1});null==i||i(d),Object(n.useImperativeHandle)(s,(()=>({refetchNames:o})));const m=(null!=r?r:[]).map((e=>({label:e.key,value:e.key}))),p=m.find((t=>t.value===e)),E=p?[p]:[];return l.a.createElement(u.EuiComboBox,{prepend:"Name","aria-label":g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.selectedSavedObjectLabel",{defaultMessage:"Select a Saved Object"}),placeholder:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.selectedSavedObjectLabel",{defaultMessage:"Select a Saved Object"}),fullWidth:!0,options:m,singleSelection:{asPlainText:!0},selectedOptions:E,isLoading:"loading"===d,onChange:e=>{e.length?t(e[0].value):t(void 0)}})})),ps=()=>{const e=[{value:`${V.i}`,text:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.agentPolicyLabel",{defaultMessage:"Agent policy"})},{value:`${V.jb}`,text:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.packagePolicyLabel",{defaultMessage:"Integration policy"})},{value:`${V.fb}`,text:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.outputLabel",{defaultMessage:"Output"})},{value:`${V.gb}`,text:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.packageLabel",{defaultMessage:"Packages"})},{value:`${V.s}`,text:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.downloadSourceLabel",{defaultMessage:"Download Sources"})},{value:`${V.P}`,text:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.fleetServerHostLabel",{defaultMessage:"Fleet Server Hosts"})}],[t,a]=Object(n.useState)(e[0].value),[i,s]=Object(n.useState)(),[r,o]=Object(n.useState)(),m=Object(n.useRef)(),{data:p,status:E}=Object(b.useQuery)(["debug-saved-objects",t,i],(()=>(async(e,t)=>{var a;if(!e||!t)return;const n={query:{bool:{must:{match:{[`${e}.name`]:t}},filter:{term:{type:e}}}}},l=await Object(c.kb)({method:"post",path:"/api/console/proxy",query:{path:"/.kibana/_search",method:"GET"},body:n});if(l.error)throw new Error(l.error.message);return null===(a=l.data)||void 0===a?void 0:a.hits})(t,i)));return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.savedObjectDebugger.description",defaultMessage:"Search for Fleet-related saved objects by selecting a type and name. Use the code block below to diagnose any potential issues."}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{alignItems:"center",justifyContent:"flexStart"},l.a.createElement(Es,{grow:!1},l.a.createElement(u.EuiFormRow,null,l.a.createElement(u.EuiSelect,{prepend:"Type",id:"soType",options:e,value:t,onChange:e=>(e=>{a(e.target.value),s(void 0),m.current.refetchNames()})(e),"aria-label":g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.selectTypeLabel",{defaultMessage:"Select saved object type"})}))),l.a.createElement(fs,{grow:!1},l.a.createElement(u.EuiFormRow,null,l.a.createElement(ms,{name:i,setName:s,type:t,setNamesStatus:o,ref:m})))),p&&("error"===E||"error"===r)&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCallOut,{title:"Error",color:"danger"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.savedObjectDebugger.fetchError",defaultMessage:"Error fetching Saved Objects"}))),(p||"loading"===E)&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(is,{value:JSON.stringify(p,null,2)})))};var Es=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem",componentId:"sc-1ovx3fm-0"})(["min-width:300px;"]),fs=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem2",componentId:"sc-1ovx3fm-1"})(["min-width:400px;"]);const bs=async()=>{var e,t;const a=`${F.c}.is_preconfigured:true`,n=await Object(c.v)({kuery:a,perPage:F.p,full:!0});if(n.error)throw new Error(n.error.message);return null!==(e=null===(t=n.data)||void 0===t?void 0:t.items)&&void 0!==e?e:[]},hs=()=>{var e,t,a,i;const{getHref:s}=Object(c.Zb)(),{notifications:r}=Object(c.hc)(),[o,m]=Object(n.useState)(),[p,E]=Object(n.useState)(!1),[f,h]=Object(n.useState)(!1),y=Object(b.useQuery)(["debug-preconfigured-policies"],bs),k=null!==(e=null===(t=y.data)||void 0===t?void 0:t.map((e=>({label:e.name,value:e.id}))))&&void 0!==e?e:[],v=o?[k.find((({value:e})=>e===o))]:[],x=null===(a=y.data)||void 0===a?void 0:a.find((e=>e.id===o)),F=Object(b.useMutation)((async e=>{const t=await Object(c.nb)(e);if(t.error)throw r.toasts.addError(t.error,{title:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetError",{defaultMessage:"Error resetting policy"}),toastMessage:t.error.message}),new Error(t.error.message);return r.toasts.addSuccess(g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetSuccess",{defaultMessage:"Successfully reset policy"})),Ss.invalidateQueries(["debug-preconfigured-policies"]),m(void 0),E(!1),t.data})),M=Object(b.useMutation)((async()=>{const e=await Object(c.mb)();if(e.error)throw r.toasts.addError(e.error,{title:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetAllError",{defaultMessage:"Error resetting policies"}),toastMessage:e.error.message}),new Error(e.error.message);return r.toasts.addSuccess(g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetAllSuccess",{defaultMessage:"Successfully reset policies"})),Ss.invalidateQueries(["debug-preconfigured-policies"]),m(void 0),h(!1),e.data}));return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.description",defaultMessage:"This tool can be used to reset preconfigured policies that are managed via {codeKibanaYml}. This includes Fleet's default policies that may exist in cloud environments.",values:{codeKibanaYml:l.a.createElement(u.EuiCode,null,"kibana.yml")}})),l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.resetInstructions",defaultMessage:'You may reset a single preconfigured policy or use the "Reset all" button to reset all preconfigured policies at once.'}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(ys,{grow:!1},l.a.createElement(u.EuiComboBox,{"aria-label":g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.selectLabel",{defaultMessage:"Select a preconfigured policy"}),placeholder:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.selectLabel",{defaultMessage:"Select a preconfigured policy"}),fullWidth:!0,options:k,singleSelection:{asPlainText:!0},selectedOptions:v,onChange:e=>{e.length?m(e[0].value):m(void 0)}})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement("div",null,l.a.createElement(u.EuiButton,{color:"warning",isDisabled:!o,onClick:()=>E(!0)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.resetButton",defaultMessage:"Reset"})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement("div",null,l.a.createElement(u.EuiButton,{color:"danger",isDisabled:!(null!==(i=y.data)&&void 0!==i&&i.length),onClick:()=>h(!0)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.resetAllButton",defaultMessage:"Reset all"}))))),p&&x&&o&&l.a.createElement(u.EuiConfirmModal,{title:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetModalTitle",{defaultMessage:"Reset {policyName}",values:{policyName:x.name}}),onCancel:()=>E(!1),onConfirm:()=>F.mutate(o),isLoading:F.isLoading,cancelButtonText:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetModalCancel",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetModalConfirm",{defaultMessage:"Reset"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.resetModalBody",defaultMessage:"Are you sure you want to reset {policyName}?",values:{policyName:x.name}})),f&&l.a.createElement(u.EuiConfirmModal,{title:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetAllModalTitle",{defaultMessage:"Reset all preconfigured policies"}),onCancel:()=>h(!1),onConfirm:()=>M.mutate(),isLoading:M.isLoading,cancelButtonText:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetAllModalCancel",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.resetAllModalConfirm",{defaultMessage:"Reset all"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.resetAllModalBody",defaultMessage:"Are you sure you want to reset all preconfigured policies?"})),o&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiLink,{target:"_blank",href:s("policy_details",{policyId:o})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.preconfigurationDebugger.viewAgentPolicyLink",defaultMessage:"View Agent Policy in Fleet UI"})),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(is,{value:JSON.stringify(x,null,2)})))};var ys=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem",componentId:"sc-y0mpv-0"})(["min-width:400px;"]);const ks=()=>{var e,t,a,i;const s=[{label:".fleet-agents",value:".fleet-agents"},{label:".fleet-actions",value:".fleet-actions"},{label:".fleet-servers",value:".fleet-servers"},{label:".fleet-enrollment-api-keys",value:".fleet-enrollment-api-keys"}],[r,o]=Object(n.useState)(),{data:m,status:p}=Object(b.useQuery)(["debug-indices",r],(()=>(async e=>{if(!e)return;const t=`/${e}/_search`;return await Object(c.kb)({method:"post",path:"/api/console/proxy",query:{path:t,method:"GET"}})})(r)),{retry:!1}),E=r?[s.find((e=>e.value===r))]:[];return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.fleetIndexDebugger.description",defaultMessage:"Search for the contents of Fleet indices. Use the code block below to diagnose any potential issues. "}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(u.EuiFlexItem,null,l.a.createElement(u.EuiFormRow,null,l.a.createElement(u.EuiComboBox,{prepend:"Index","aria-label":g.i18n.translate("xpack.fleet.debug.fleetIndexDebugger.selectLabel",{defaultMessage:"Select an index"}),placeholder:g.i18n.translate("xpack.fleet.debug.fleetIndexDebugger.selectLabel",{defaultMessage:"Select an index"}),fullWidth:!0,options:s,singleSelection:{asPlainText:!0},selectedOptions:E,isLoading:"loading"===p,onChange:e=>{e.length?o(e[0].value):o(void 0)}})))),(null==m?void 0:m.error)&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCallOut,{title:"Error",color:"danger"},null!==(e=null==m||null===(t=m.error)||void 0===t||null===(a=t.error)||void 0===a?void 0:a.reason)&&void 0!==e?e:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.fleetIndexDebugger.fetchError",defaultMessage:"Error fetching index data"}))),m&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(is,{value:JSON.stringify(null===(i=m.data)||void 0===i?void 0:i.hits,null,2)})))},vs=async()=>{var e,t;const a=await Object(c.F)();if(a.error)throw new Error(a.error.message);return null!==(e=null===(t=a.data)||void 0===t?void 0:t.items)&&void 0!==e?e:[]},xs=()=>{var e;const{notifications:t}=Object(c.hc)(),[a,i]=Object(n.useState)(),[s,r]=Object(n.useState)(!1),[o,m]=Object(n.useState)(!1),{data:p}=Object(b.useQuery)(["debug-orphaned-policies"],vs),E=null!==(e=null==p?void 0:p.map((e=>({label:e.name,value:e.id}))))&&void 0!==e?e:[],f=a?[E.find((({value:e})=>e===a))]:[],h=null==p?void 0:p.find((e=>e.id===a)),y=Object(b.useMutation)((async e=>{const a=await Object(c.s)({packagePolicyIds:[e],force:!0});if(a.error)throw t.toasts.addError(a.error,{title:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteError",{defaultMessage:"Error deleting policy"}),toastMessage:a.error.message}),new Error(a.error.message);return t.toasts.addSuccess(g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteSuccess",{defaultMessage:"Successfully deleted orphaned policy"})),Ss.invalidateQueries(["debug-orphaned-policies"]),i(void 0),r(!1),a.data})),k=Object(b.useMutation)((async()=>{const e=await Object(c.s)({packagePolicyIds:null==p?void 0:p.map((e=>e.id)),force:!0});if(e.error)throw t.toasts.addError(e.error,{title:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteAllError",{defaultMessage:"Error deleting orphaned policies"}),toastMessage:e.error.message}),new Error(e.error.message);return t.toasts.addSuccess(g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteAllSuccess",{defaultMessage:"Successfully deleted all orphaned policies"})),Ss.invalidateQueries(["debug-orphaned-policies"]),i(void 0),m(!1),e.data}));return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.orphanedIntegrationPolicyDebugger.description",defaultMessage:'This tool can be used to delete "orphaned" integration policies that have been unlinked from their parent agent policy objects'})),l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteOptions",defaultMessage:'You may delete a single orphaned integration policy or use the "Delete all" button to delete all orphaned integration policies at once.'}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,null,l.a.createElement(Fs,{grow:!1},l.a.createElement(u.EuiComboBox,{"aria-label":g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.selectLabel",{defaultMessage:"Select an orphaned integration policy"}),placeholder:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.selectLabel",{defaultMessage:"Select an orphaned integration policy"}),fullWidth:!0,options:E,singleSelection:{asPlainText:!0},selectedOptions:f,onChange:e=>{e.length?i(e[0].value):i(void 0)}})),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement("div",null,l.a.createElement(u.EuiButton,{color:"warning",isDisabled:!a,onClick:()=>r(!0)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteButton",defaultMessage:"Delete"})))),l.a.createElement(u.EuiFlexItem,{grow:!1},l.a.createElement("div",null,l.a.createElement(u.EuiButton,{color:"danger",isDisabled:!(null!=p&&p.length),onClick:()=>m(!0)},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteAllButton",defaultMessage:"Delete all"}))))),s&&h&&a&&l.a.createElement(u.EuiConfirmModal,{title:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteModalTitle",{defaultMessage:"Delete {policyName}",values:{policyName:h.name}}),onCancel:()=>r(!1),onConfirm:()=>y.mutate(a),isLoading:y.isLoading,cancelButtonText:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.cancelDelete",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.confirmDelete",{defaultMessage:"Delete"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteModalBody",defaultMessage:"Are you sure you want to delete {policyName}?",values:{policyName:h.name}})),o&&l.a.createElement(u.EuiConfirmModal,{title:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteAllModalTitle",{defaultMessage:"Delete all orphaned integration policies"}),onCancel:()=>m(!1),onConfirm:()=>k.mutate(),isLoading:k.isLoading,cancelButtonText:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.cancelDeleteAll",{defaultMessage:"Cancel"}),confirmButtonText:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.confirmDeleteAll",{defaultMessage:"Delete all"})},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.orphanedIntegrationPolicyDebugger.deleteAllModalBody",defaultMessage:"Are you sure you want to delete all orphaned integration policies?"})),a&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(is,{value:JSON.stringify(h,null,2)})))};var Fs=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem",componentId:"sc-tbjlhb-0"})(["min-width:400px;"]);const Ms=()=>{var e,t,a,i,s,r;const[o,g]=Object(n.useState)(),{data:m}=Object(c.Kb)(),p=Object(n.useMemo)((()=>{var e;return null!==(e=null==m?void 0:m.items)&&void 0!==e?e:[]}),[null==m?void 0:m.items]);Object(n.useEffect)((()=>{const e=p.find((e=>!0===e.is_default));e&&g(e)}),[p]);const E=Object(n.useMemo)((()=>(null==o?void 0:o.host_urls[0])||""),[null==o?void 0:o.host_urls]),[f,h]=Object(n.useState)(),{data:y}=Object(b.useQuery)(["fleetServerHealth",E],(()=>Object(c.Z)({host:E})),{refetchInterval:1e4});Object(n.useEffect)((()=>{h(y)}),[y]);const k=Object(n.useMemo)((()=>[...p.map((e=>({inputDisplay:`${e.name} (${e.host_urls[0]})`,value:e.id})))]),[p]);return l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiText,{grow:!1},l.a.createElement("p",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.healthCheckPanel.description",defaultMessage:"Select the host used to enroll Fleet Server. The connection is refreshed every {interval}s.",values:{interval:10}}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiFlexGroup,{alignItems:"center"},l.a.createElement(Is,{grow:!1},l.a.createElement(u.EuiSuperSelect,{fullWidth:!0,"data-test-subj":"fleetDebug.fleetServerHostsSelect",prepend:l.a.createElement(u.EuiText,{size:"relative",color:""},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.healthCheckPanel.fleetServerHostsLabel",defaultMessage:"Fleet Server Hosts"})),onChange:e=>{h(void 0),g(p.find((t=>t.id===e)))},valueOfSelected:null==o?void 0:o.id,options:k})),l.a.createElement(u.EuiFlexItem,{grow:!1},null!=f&&null!==(e=f.data)&&void 0!==e&&e.status&&E===(null==f||null===(t=f.data)||void 0===t?void 0:t.host)?l.a.createElement(u.EuiFlexGroup,{alignItems:"center"},l.a.createElement(u.EuiFlexItem,null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.healthCheckPanel.status",defaultMessage:"Status:"})),l.a.createElement(u.EuiFlexItem,null,(e=>{if(!e)return null;let t;switch(e){case"HEALTHY":t="success";break;case"UNHEALTHY":t="warning";break;default:t="subdued"}return l.a.createElement(u.EuiHealth,{color:t},e)})(null==f||null===(a=f.data)||void 0===a?void 0:a.status))):null)),(null==f?void 0:f.error)&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCallOut,{title:"Error",color:"danger"},null!==(i=null==f||null===(s=f.error)||void 0===s?void 0:s.message)&&void 0!==i?i:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.healthCheckPanel.fetchError",defaultMessage:"Message: {errorMessage}",values:{errorMessage:null==f||null===(r=f.error)||void 0===r?void 0:r.message}}))))};var Is=p()(u.EuiFlexItem).withConfig({displayName:"_StyledEuiFlexItem",componentId:"sc-1ss3z0x-0"})(["min-width:600px;"]);const Ss=new b.QueryClient,Os=[{title:g.i18n.translate("xpack.fleet.debug.HealthCheckStatus.title",{defaultMessage:"Health Check Status"}),id:"healthCheckStatus",component:l.a.createElement(Ms,null)},{title:g.i18n.translate("xpack.fleet.debug.agentPolicyDebugger.title",{defaultMessage:"Agent Policy Debugger"}),id:"agentPolicyDebugger",component:l.a.createElement(rs,null)},{title:g.i18n.translate("xpack.fleet.debug.integrationDebugger.title",{defaultMessage:"Integration Debugger"}),id:"integrationDebugger",component:l.a.createElement(ds,null)},{title:g.i18n.translate("xpack.fleet.debug.savedObjectDebugger.title",{defaultMessage:"Saved Object Debugger"}),id:"savedObjectDebugger",component:l.a.createElement(ps,null)},{title:g.i18n.translate("xpack.fleet.debug.fleetIndexDebugger.title",{defaultMessage:"Fleet Index Debugger"}),id:"fleetIndexDebugger",component:l.a.createElement(ks,null)},{title:g.i18n.translate("xpack.fleet.debug.preconfigurationDebugger.title",{defaultMessage:"Preconfiguration Debugger"}),id:"preconfigurationDebugger",component:l.a.createElement(hs,null)},{title:g.i18n.translate("xpack.fleet.debug.orphanedIntegrationPolicyDebugger.title",{defaultMessage:"Orphaned Integration Policy Debugger"}),id:"orphanedIntegrationPolicyDebugger",component:l.a.createElement(xs,null)}],Ts=({isInitialized:e,setupError:t})=>{const{chrome:a}=Object(c.hc)(),{getHref:n}=Object(c.Zb)();return a.docTitle.change(["Debug","Fleet"]),l.a.createElement(b.QueryClientProvider,{client:Ss},l.a.createElement(u.EuiPage,{paddingSize:"xl"},l.a.createElement(u.EuiPageBody,{panelled:!0},l.a.createElement(u.EuiPageSection,null,l.a.createElement(u.EuiPageHeader,{pageTitle:g.i18n.translate("xpack.fleet.debug.pageTitle",{defaultMessage:"Fleet Debugging Dashboard"}),iconType:"wrench"}),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiCallOut,{color:"danger",iconType:"warning",title:"Danger zone"},l.a.createElement(u.EuiText,{grow:!1},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.dangerZone.description",defaultMessage:"This page provides an interface for directly managing Fleet's underlying data and diagnosing issues. Be aware that these debugging tools can be {strongDestructive} in nature and can result in {strongLossOfData}. Please proceed with caution.",values:{strongDestructive:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.dangerZone.destructive",defaultMessage:"destructive"})),strongLossOfData:l.a.createElement("strong",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.dangerZone.lossOfData",defaultMessage:"loss of data"}))}}))),!e&&(null==t?void 0:t.message)&&l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiSpacer,{size:"s"}),l.a.createElement(u.EuiCallOut,{color:"danger",iconType:"warning",title:"Setup error"},l.a.createElement(u.EuiText,{grow:!1},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.initializationError.description",defaultMessage:"{message}. You can use this page to debug the error.",values:{message:null==t?void 0:t.message}}))))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiPageSection,null,Os.map((({title:e,id:t,component:a})=>l.a.createElement(l.a.Fragment,null,l.a.createElement(u.EuiAccordion,{id:t,initialIsOpen:!0,buttonContent:l.a.createElement(u.EuiTitle,{size:"l"},l.a.createElement("h2",null,e))},l.a.createElement(u.EuiSpacer,{size:"m"}),a),l.a.createElement(u.EuiHorizontalRule,null)))),l.a.createElement(u.EuiTitle,{size:"l"},l.a.createElement("h2",null,l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.debug.usefulLinks.title",defaultMessage:"Useful links"}))),l.a.createElement(u.EuiSpacer,{size:"m"}),l.a.createElement(u.EuiListGroup,{listItems:[{label:g.i18n.translate("xpack.fleet.debug.usefulLinks.viewAgents",{defaultMessage:"View Agents in Fleet UI"}),href:n("agent_list"),iconType:"agentApp",target:"_blank"},{label:g.i18n.translate("xpack.fleet.debug.usefulLinks.troubleshootingGuide",{defaultMessage:"Troubleshooting Guide"}),href:"https://www.elastic.co/guide/en/fleet/current/fleet-troubleshooting.html",iconType:"popout",target:"_blank"}]})))),l.a.createElement(h.ReactQueryDevtools,{initialIsOpen:!1}))},ws=new b.QueryClient,js=({isAddIntegrationsPath:e,children:t})=>l.a.createElement(u.EuiErrorBoundary,null,e?l.a.createElement(M.c,{leftColumn:l.a.createElement(M.b,null)},t):l.a.createElement(M.a,null,l.a.createElement(M.d,null,t))),Cs=p()(u.EuiPanel).withConfig({displayName:"Panel",componentId:"sc-1lganp-0"})(["max-width:500px;margin-right:auto;margin-left:auto;"]),Ps=Object(n.memo)((({error:e})=>"MISSING_SECURITY"===e?l.a.createElement(qt.b,{missingRequirements:["security_required","api_keys"]}):"MISSING_PRIVILEGES"===e?l.a.createElement(Cs,{"data-test-subj":"missingPrivilegesPrompt"},l.a.createElement(u.EuiEmptyPrompt,{iconType:"securityApp",title:l.a.createElement("h2",{"data-test-subj":"missingPrivilegesPromptTitle"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.permissionDeniedErrorTitle",defaultMessage:"Permission denied"})),body:l.a.createElement("p",{"data-test-subj":"missingPrivilegesPromptMessage"},l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.permissionDeniedErrorMessage",defaultMessage:"You are not authorized to access Fleet. It requires the {roleName1} Kibana privilege for Fleet, and the {roleName2} or {roleName1} privilege for Integrations.",values:{roleName1:l.a.createElement(u.EuiCode,null,'"All"'),roleName2:l.a.createElement(u.EuiCode,null,'"Read"')}}))})):l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.permissionsRequestErrorMessageTitle",defaultMessage:"Unable to check permissions"}),error:g.i18n.translate("xpack.fleet.permissionsRequestErrorMessageDescription",{defaultMessage:"There was a problem checking Fleet permissions"})}))),As=Object(n.memo)((({children:e})=>{Object(c.ub)("base");const t=Object(c.hc)(),{notifications:a}=t,i=Object(c.tb)().fleet.all,[s,o]=Object(n.useState)(!1),[u,m]=Object(n.useState)(),[p,E]=Object(n.useState)(!1),[f,b]=Object(n.useState)(null),h=!!Object(r.useRouteMatch)(F.h.add_integration_to_policy),y=!!Object(r.useRouteMatch)(F.h.debug);return Object(n.useEffect)((()=>{(async()=>{o(!1),m(void 0),E(!1),b(null);try{var e;o(!0);const s=await Object(c.J)();if(o(!1),null!==(e=s.data)&&void 0!==e&&e.success){try{var t,n;const e=await Object(c.ob)();e.error&&b(e.error),null!==(t=e.data)&&void 0!==t&&null!==(n=t.nonFatalErrors)&&void 0!==n&&n.length&&a.toasts.addError(e.data.nonFatalErrors[0],{title:g.i18n.translate("xpack.fleet.setup.uiPreconfigurationErrorTitle",{defaultMessage:"Configuration error"})}),i||m("MISSING_PRIVILEGES")}catch(e){b(e)}E(!0)}else{var l;m((null===(l=s.data)||void 0===l?void 0:l.error)||"REQUEST_ERROR")}}catch(e){m("REQUEST_ERROR")}})()}),[a.toasts,i]),s||u?l.a.createElement(js,{isAddIntegrationsPath:h},s?l.a.createElement(x.r,null):l.a.createElement(Ps,{error:u})):y?l.a.createElement(Ts,{setupError:f,isInitialized:p}):!p||f?l.a.createElement(js,{isAddIntegrationsPath:h},f?l.a.createElement(x.j,{title:l.a.createElement(d.FormattedMessage,{id:"xpack.fleet.initializationErrorMessageTitle",defaultMessage:"Unable to initialize Fleet"}),error:f}):l.a.createElement(x.n,null)):l.a.createElement(l.a.Fragment,null,e)})),Ls=Object(n.memo)((({children:e,startServices:t,config:a,history:n,kibanaVersion:i,extensions:s,routerHistory:r,theme$:d,fleetStatus:g})=>{const m=f()(d),p=m&&m.darkMode;return l.a.createElement(y.RedirectAppLinks,{application:t.application},l.a.createElement(t.i18n.Context,null,l.a.createElement(y.KibanaContextProvider,{services:{...t,theme:{theme$:d}}},l.a.createElement(u.EuiErrorBoundary,null,l.a.createElement(c.b.Provider,{value:a},l.a.createElement(c.e.Provider,{value:i},l.a.createElement(y.KibanaThemeProvider,{theme$:d},l.a.createElement(k.EuiThemeProvider,{darkMode:p},l.a.createElement(b.QueryClientProvider,{client:ws},l.a.createElement(h.ReactQueryDevtools,{initialIsOpen:!1}),l.a.createElement(c.f.Provider,{value:s},l.a.createElement(c.c,{defaultFleetStatus:g},l.a.createElement(o.b,{history:n},l.a.createElement(v.e,{notifications:t.notifications,theme$:d},l.a.createElement(c.d,null,e))))))))))))))})),_s=Object(n.memo)((({setHeaderActionMenu:e})=>{const t=Object(c.hc)(),{TopNavMenu:a}=t.navigation.ui,n=[{label:g.i18n.translate("xpack.fleet.appNavigation.sendFeedbackButton",{defaultMessage:"Send feedback"}),iconType:"popout",run:()=>window.open("https://ela.st/fleet-feedback")}];return l.a.createElement(a,{appName:g.i18n.translate("xpack.fleet.appTitle",{defaultMessage:"Fleet"}),config:n,setMenuMountPoint:e})})),Ds=Object(n.memo)((({setHeaderActionMenu:e})=>{var t;const a=Object(c.Eb)(),n=Object(c.Db)(),{agentTamperProtectionEnabled:i}=j.b.get();return l.a.createElement(l.a.Fragment,null,l.a.createElement(_s,{setHeaderActionMenu:e}),l.a.createElement(o.c,null,l.a.createElement(o.a,{path:F.h.agents},l.a.createElement(Wa,null)),l.a.createElement(o.a,{path:F.h.policies},l.a.createElement(te,null)),l.a.createElement(o.a,{path:F.h.enrollment_tokens},l.a.createElement(pl,null)),i&&l.a.createElement(o.a,{path:F.h.uninstall_tokens},l.a.createElement(Il,null)),l.a.createElement(o.a,{path:F.h.data_streams},l.a.createElement(ie,null)),l.a.createElement(o.a,{path:F.h.settings},l.a.createElement(ls,null)),l.a.createElement(o.a,{path:F.h.add_integration_to_policy},l.a.createElement(ol,null)),l.a.createElement(o.a,{render:({location:e})=>{if(!(""===e.pathname&&e.hash.length>0))return l.a.createElement(r.Redirect,{to:F.h.agents});const t=e.hash.replace(/^#(\/fleet)?/,"");return l.a.createElement(r.Redirect,{to:{...e,pathname:t,hash:void 0}})}})),a.isEnrollmentFlyoutOpen&&l.a.createElement(u.EuiPortal,null,l.a.createElement(x.c,{defaultMode:!n.isReady||null!==(t=n.missingRequirements)&&void 0!==t&&t.includes("fleet_server")?"standalone":"managed",isIntegrationFlow:!0,onClose:()=>a.closeEnrollmentFlyout()})),a.isFleetServerFlyoutOpen&&l.a.createElement(u.EuiPortal,null,l.a.createElement(x.m,{onClose:()=>a.closeFleetServerFlyout()})))})),Bs=({isAllowed:e=!1,restrictedPath:t="/",...a})=>e?l.a.createElement(o.a,a):l.a.createElement(r.Redirect,{to:{pathname:t}}),Rs=({startServices:e,config:t,history:a,kibanaVersion:n,extensions:i,setHeaderActionMenu:s,theme$:r})=>l.a.createElement(Ls,{startServices:e,config:t,history:a,kibanaVersion:n,extensions:i,theme$:r},l.a.createElement(As,null,l.a.createElement(Ds,{setHeaderActionMenu:s})));function zs(e,{element:t,history:a,setHeaderActionMenu:n,theme$:i},r,o,c){return s.a.render(l.a.createElement(Rs,{startServices:e,config:r,history:a,kibanaVersion:o,extensions:c,setHeaderActionMenu:n,theme$:i}),t),()=>{s.a.unmountComponentAtNode(t)}}const Ns=e=>{e.chrome.docTitle.reset(),e.chrome.setBreadcrumbs([]),c.g.stop()}}}]);