/*! 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. */!function(e){function t(t){for(var i,s,r=t[0],a=t[1],o=0,c=[];o{if(e)return cluster_Cluster.fromUpstreamJSON(e.cluster)}))}isClusterInfoAvailable(){return this.loadCluster().then((e=>Boolean(e))).catch((()=>!1))}}var o=i(1);class logstash_license_service_LogstashLicenseService{constructor(e,t,i){this.license=e,this.navigateToApp=t,this.toasts=i}get enableLinks(){return this.calculated.enableLinks}get isAvailable(){return this.calculated.isAvailable}get isReadOnly(){return this.calculated.isReadOnly}get message(){return this.calculated.message}get isSecurityEnabled(){return this.license.getFeature("security").isEnabled}checkValidity(){return new Promise(((e,t)=>this.isAvailable?e():t()))}get calculated(){if(!this.license)throw new Error("No license available!");return this.isSecurityEnabled?this.license.hasAtLeast("standard")?this.license.isActive?{isAvailable:!0,enableLinks:!0,isReadOnly:!1}:{isAvailable:!0,enableLinks:!0,isReadonly:!0,message:o.i18n.translate("xpack.logstash.managementSection.pipelineCrudOperationsNotAllowedDescription",{defaultMessage:"You cannot edit, create, or delete your Logstash pipelines because your {licenseType} license has expired.",values:{licenseType:this.license.type}})}:{isAvailable:!1,enableLinks:!1,isReadOnly:!1,message:o.i18n.translate("xpack.logstash.managementSection.licenseDoesNotSupportDescription",{defaultMessage:"Your {licenseType} license does not support Logstash pipeline management features. Please upgrade your license.",values:{licenseType:this.license.type}})}:{isAvailable:!1,enableLinks:!1,isReadOnly:!1,message:o.i18n.translate("xpack.logstash.managementSection.enableSecurityDescription",{defaultMessage:"Security must be enabled in order to use Logstash pipeline management features. Please set xpack.security.enabled: true in your elasticsearch.yml."})}}}var l=i(3),c=i.n(l);class pipeline_list_item_PipelineListItem{constructor(e){var t;this.id=e.id,this.origin=e.origin,this.description=e.description,this.username=e.username,e.lastModified&&(this.lastModified=(t=e.lastModified)?c()(t):null,this.lastModifiedHumanized=Object(a.upperFirst)(this.lastModified.fromNow()))}get searchValue(){return this,e=["id"],Object(a.values)(Object(a.pick)(this,e)).join("\n");var e}get isCentrallyManaged(){return this.origin===s}static fromUpstreamJSON(e){const t=Object(a.pick)(e,["id","description","username"]);return t.origin=s,t.lastModified=e.last_modified,new pipeline_list_item_PipelineListItem(t)}static fromUpstreamMonitoringJSON(e){const t=Object(a.pick)(e,["id"]);return t.origin=r,new pipeline_list_item_PipelineListItem(t)}}class monitoring_service_MonitoringService{constructor(e,t,i){this.http=e,this._isMonitoringEnabled=t,this.clusterService=i}isMonitoringEnabled(){return this._isMonitoringEnabled}getPipelineList(){return this.isMonitoringEnabled()?this.clusterService.loadCluster().then((e=>{const t=`/api/monitoring/v1/clusters/${e.uuid}/logstash/pipeline_ids`,i=c.a.utc(),n=JSON.stringify({timeRange:{max:i.toISOString(),min:i.subtract(30,"seconds").toISOString()}});return this.http.post(t,{body:n})})).then((e=>e.map((e=>pipeline_list_item_PipelineListItem.fromUpstreamMonitoringJSON(e))))).catch((()=>[])):Promise.resolve([])}}var u=i(8);class pipeline_service_PipelineService{constructor(e,t){this.http=e,this.pipelinesService=t}loadPipeline(e){return this.http.get(`${n}/pipeline/${e}`).then((e=>u.a.fromUpstreamJSON(e)))}savePipeline(e){return this.http.put(`${n}/pipeline/${e.id}`,{body:JSON.stringify(e.upstreamJSON)}).catch((e=>{throw e.message}))}deletePipeline(e){return this.http.delete(`${n}/pipeline/${e}`).then((()=>this.pipelinesService.addToRecentlyDeleted(e))).catch((e=>{throw e.message}))}}const p="xpack.logstash.recentlyDeletedPipelines";class pipelines_service_PipelinesService{constructor(e,t){this.http=e,this.monitoringService=t}getPipelineList(){return Promise.all([this.getManagementPipelineList(),this.getMonitoringPipelineList()]).then((([e,t])=>{const i=Date.now(),n=t.map((e=>e.id));this.getRecentlyDeleted().forEach((e=>{i-e.deletedOn<3e4||n.includes(e.id)||this.removeFromRecentlyDeleted(e.id)}));const s=e.map((e=>e.id));return e.concat(t.filter((e=>!s.includes(e.id)&&!this.isRecentlyDeleted(e.id))))}))}getManagementPipelineList(){return this.http.get(`${n}/pipelines`).then((e=>e.pipelines.map((e=>pipeline_list_item_PipelineListItem.fromUpstreamJSON(e)))))}getMonitoringPipelineList(){return this.monitoringService.getPipelineList()}deletePipelines(e){const t=JSON.stringify({pipelineIds:e});return this.http.post(`${n}/pipelines/delete`,{body:t}).then((t=>(this.addToRecentlyDeleted(...e),t.results)))}addToRecentlyDeleted(...e){const t=this.getRecentlyDeleted(),i=t.map((e=>e.id));e.forEach((e=>{i.includes(e)||t.push({id:e,deletedOn:Date.now()})})),this.setRecentlyDeleted(t)}removeFromRecentlyDeleted(...e){const t=this.getRecentlyDeleted().filter((t=>!e.includes(t.id)));this.setRecentlyDeleted(t)}isRecentlyDeleted(e){return this.getRecentlyDeleted().map((e=>e.id)).includes(e)}getRecentlyDeleted(){const e=window.localStorage.getItem(p);return e?JSON.parse(e):[]}setRecentlyDeleted(e){window.localStorage.setItem(p,JSON.stringify(e))}}},function(e,t,i){"use strict";i.d(t,"a",(function(){return pipeline_Pipeline}));var n=i(2),s=i.n(n),r=i(0);const a={"pipeline.workers":null,"pipeline.batch.size":125,"pipeline.batch.delay":50,"queue.type":"memory","queue.max_bytes.number":1,"queue.max_bytes.units":"gb","queue.checkpoint.writes":1024};class pipeline_Pipeline{constructor(e=undefined){s()(this,"isEqualTo",(e=>{const t={...this},i={...e};return Object(r.isEqual)(t,i)})),this.id=Object(r.get)(e,"id"),this.description=Object(r.get)(e,"description",""),this.pipeline=Object(r.get)(e,"pipeline","input {\n}\nfilter {\n}\noutput {\n}"),this.username=Object(r.get)(e,"username"),this.settings=Object(r.defaultsDeep)(Object(r.get)(e,"settings",{}),a)}get clone(){return new pipeline_Pipeline({...Object(r.omit)(this,["id","username"])})}get upstreamJSON(){const e=this.settings,t=Object(r.get)(e,"queue.max_bytes.number"),i=Object(r.get)(e,"queue.max_bytes.units"),n={...e};return t&&i&&(delete n["queue.max_bytes.number"],delete n["queue.max_bytes.units"],n["queue.max_bytes"]=`${t}${i}`),{description:this.description,pipeline:this.pipeline,username:this.username,settings:n}}static fromUpstreamJSON(e){const t=e.settings,i=Object(r.get)(t,"queue.max_bytes","").match(/(\d+)(\w+)/);if(Array.isArray(i)&&3===i.length){const e=i[1],n=i[2];e&&n&&(delete t["queue.max_bytes"],t["queue.max_bytes.number"]=parseInt(e),t["queue.max_bytes.units"]=n)}return new pipeline_Pipeline({id:e.id,description:e.description,pipeline:e.pipeline,username:e.username,settings:t})}}},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t,i){i(11),__kbnBundles__.define("plugin/logstash/public",i,12)},function(e,t,i){i.p=window.__kbnPublicPath__.logstash},function(e,t,i){"use strict";i.r(t),i.d(t,"plugin",(function(){return u}));var n=i(2),s=i.n(n),r=i(1),a=i(4),o=i(6),l=i(0),c=i(7);class plugin_LogstashPlugin{constructor(){s()(this,"licenseSubscription",void 0),s()(this,"capabilities$",new a.Subject)}setup(e,t){const n=t.licensing.license$.pipe(Object(o.map)((e=>new c.b(e)))),s=t.management.sections.section.ingest.registerApp({id:"pipelines",title:r.i18n.translate("xpack.logstash.managementSection.pipelinesTitle",{defaultMessage:"Logstash Pipelines"}),order:1,mount:async s=>{const[r]=await e.getStartServices(),{renderApp:a}=await i.e(1).then(i.bind(null,29));return a(r,s,"monitoring"in t,n)}});this.licenseSubscription=Object(a.combineLatest)([n,this.capabilities$]).subscribe((([e,i])=>{const n=e.enableLinks&&!0===i.management.ingest.pipelines;n?s.enable():s.disable(),t.home&&n&&Object(l.once)((()=>{t.home.featureCatalogue.register({id:"management_logstash",title:r.i18n.translate("xpack.logstash.homeFeature.logstashPipelinesTitle",{defaultMessage:"Logstash Pipelines"}),description:r.i18n.translate("xpack.logstash.homeFeature.logstashPipelinesDescription",{defaultMessage:"Create, delete, update, and clone data ingestion pipelines."}),icon:"pipelineApp",path:"/app/management/ingest/pipelines",showOnHomePage:!1,category:"admin"})}))}))}start(e){this.capabilities$.next(e.application.capabilities)}stop(){this.licenseSubscription&&this.licenseSubscription.unsubscribe()}}const u=()=>new plugin_LogstashPlugin},function(e,t){e.exports=__kbnSharedDeps__.React},function(e,t){e.exports=__kbnSharedDeps__.EmotionReact},function(e,t){e.exports=__kbnSharedDeps__.ElasticEui},function(e,t){e.exports=__kbnSharedDeps__.KbnI18nReact},function(e,t){e.exports=__kbnSharedDeps__.ReactRouterDom},function(e,t){e.exports=__kbnSharedDeps__.TsLib},function(e,t){e.exports=__kbnSharedDeps__.ReactRouterDomV5Compat},function(e,t,i){i.r(t);var n=__kbnBundles__.get("plugin/kibanaReact/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t){e.exports=__kbnSharedDeps__.ReactDom}]);