/*! 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){var t={};function i(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(s,n,function(t){return e[t]}.bind(null,n));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=9)}([function(e,t,i){e.exports=i(11)(1465)},function(e,t){e.exports=__kbnSharedDeps__.RxjsOperators},function(e,t){e.exports=__kbnSharedDeps__.Rxjs},function(e,t){e.exports=__kbnSharedDeps__.EmotionReact},function(e,t){e.exports=__kbnSharedDeps__.KbnI18n},function(e,t){e.exports=__kbnSharedDeps__.KbnI18nReact},function(e,t){e.exports=__kbnSharedDeps__.ElasticEui},function(e,t,i){i.r(t);var s=__kbnBundles__.get("plugin/kibanaReact/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(s))},function(e,t){e.exports=__kbnSharedDeps__.Lodash},function(e,t,i){i(10),__kbnBundles__.define("plugin/licensing/public",i,13)},function(e,t,i){i.p=window.__kbnPublicPath__.licensing},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t){e.exports=__kbnSharedDeps__.React},function(e,t,i){"use strict";i.r(t),i.d(t,"plugin",(function(){return b}));var s=i(0),n=i.n(s),r=i(2),a=i(1),o=i(4);let c;!function(e){e[e.basic=10]="basic",e[e.standard=20]="standard",e[e.gold=30]="gold",e[e.platinum=40]="platinum",e[e.enterprise=50]="enterprise",e[e.trial=60]="trial"}(c||(c={}));class license_License{static fromJSON(e){return new license_License(e)}constructor({license:e,features:t,error:i,signature:s}){n()(this,"license",void 0),n()(this,"features",void 0),n()(this,"error",void 0),n()(this,"isActive",void 0),n()(this,"isAvailable",void 0),n()(this,"uid",void 0),n()(this,"status",void 0),n()(this,"expiryDateInMillis",void 0),n()(this,"type",void 0),n()(this,"mode",void 0),n()(this,"signature",void 0),this.isAvailable=Boolean(e),this.license=e,this.features=t,this.error=i,this.signature=s,e&&(this.uid=e.uid,this.status=e.status,this.expiryDateInMillis=e.expiryDateInMillis,this.type=e.type,this.mode=e.mode),this.isActive="active"===this.status}toJSON(){return{license:this.license,features:this.features,signature:this.signature}}getUnavailableReason(){return this.error?this.error:this.isAvailable?void 0:"X-Pack plugin is not installed on the Elasticsearch cluster."}hasAtLeast(e){const t=this.type;if(!t)return!1;if(!(e in c))throw new Error(`"${e}" is not a valid license type`);return c[e]<=c[t]}check(e,t){return this.isAvailable?this.isActive?this.hasAtLeast(t)?{state:"valid"}:{state:"invalid",message:o.i18n.translate("xpack.licensing.check.errorUnsupportedMessage",{defaultMessage:"Your {licenseType} license does not support {pluginName}. Please upgrade your license.",values:{licenseType:this.type,pluginName:e}})}:{state:"expired",message:o.i18n.translate("xpack.licensing.check.errorExpiredMessage",{defaultMessage:"You cannot use {pluginName} because your {licenseType} license has expired.",values:{licenseType:this.type,pluginName:e}})}:{state:"unavailable",message:o.i18n.translate("xpack.licensing.check.errorUnavailableMessage",{defaultMessage:"You cannot use {pluginName} because license information is not available at this time.",values:{pluginName:e}})}}getFeature(e){return this.isAvailable&&this.features&&this.features.hasOwnProperty(e)?{...this.features[e]}:{isAvailable:!1,isEnabled:!1}}}i(12);var u=i(6),l=i(5),p=i(7),h=i(3);const d=e=>Object(h.jsx)(u.EuiCallOut,{iconType:"help",color:"warning","data-test-subj":"licenseExpiredBanner",title:Object(h.jsx)(l.FormattedMessage,{id:"xpack.licensing.welcomeBanner.licenseIsExpiredTitle",defaultMessage:"Your {licenseType} license is expired",values:{licenseType:e.type}})},Object(h.jsx)(l.FormattedMessage,{id:"xpack.licensing.welcomeBanner.licenseIsExpiredDescription",defaultMessage:"Contact your administrator or {updateYourLicenseLinkText} directly.",values:{updateYourLicenseLinkText:Object(h.jsx)("a",{href:e.uploadUrl},Object(h.jsx)(l.FormattedMessage,{id:"xpack.licensing.welcomeBanner.licenseIsExpiredDescription.updateYourLicenseLinkText",defaultMessage:"update your license"}))}}));var g=i(8);class feature_usage_service_FeatureUsageService{constructor(){n()(this,"registrations",[])}setup(){return{register:async(e,t)=>{this.registrations.push({featureName:e,licenseType:t})}}}start({http:e}){const t=e.anonymousPaths.isAnonymous(window.location.pathname)||0===this.registrations.length?Promise.resolve():e.post("/internal/licensing/feature_usage/register",{body:JSON.stringify(this.registrations)});return{notifyUsage:async(i,s=Date.now())=>{if(e.anonymousPaths.isAnonymous(window.location.pathname))return;await t;const n=Object(g.isDate)(s)?s.getTime():s;await e.post("/internal/licensing/feature_usage/notify",{body:JSON.stringify({featureName:i,lastUsed:n})})}}}}const f="xpack.licensing";class plugin_LicensingPlugin{constructor(e,t=sessionStorage){n()(this,"stop$",new r.Subject),n()(this,"removeInterceptor",void 0),n()(this,"internalSubscription",void 0),n()(this,"isLicenseExpirationBannerShown",!1),n()(this,"infoEndpoint","/api/licensing/info"),n()(this,"coreStart",void 0),n()(this,"prevSignature",void 0),n()(this,"refresh",void 0),n()(this,"license$",void 0),n()(this,"featureUsage",new feature_usage_service_FeatureUsageService),n()(this,"fetchLicense",(async e=>{try{const t=await e.http.get({path:this.infoEndpoint,asSystemRequest:!0});return new license_License({license:t.license,features:t.features,signature:t.signature})}catch(e){return new license_License({error:e.message,signature:""})}})),this.storage=t}getSaved(){const e=this.storage.getItem(f);if(e)return license_License.fromJSON(JSON.parse(e))}save(e){this.storage.setItem(f,JSON.stringify(e))}removeSaved(){this.storage.removeItem(f)}setup(e){const t=new r.Subject,{license$:i,refreshManually:s}=function(e,t,i,s){const n=new r.Subject,o=Object(r.merge)(e,n).pipe(Object(a.takeUntil)(t),Object(a.exhaustMap)(i),Object(a.share)()),c=s?[void 0,s]:[void 0],u=o.pipe(Object(a.startWith)(...c),Object(a.pairwise)(),Object(a.filter)((([e,t])=>{return(i=e)!==(s=t)&&(!i||s.error!==i.error||s.type!==i.type||s.status!==i.status||s.expiryDateInMillis!==i.expiryDateInMillis||s.isAvailable!==i.isAvailable);var i,s})),Object(a.map)((([,e])=>e)),Object(a.shareReplay)(1)),l=u.subscribe();return t.pipe(Object(a.finalize)((()=>{n.complete(),l.unsubscribe()}))).subscribe(),{license$:u,refreshManually(){const e=Object(r.firstValueFrom)(o);return n.next(),e}}}(t,this.stop$,(()=>this.fetchLicense(e)),this.getSaved());return function(e,t){e.registerContextProvider({name:"license info",context$:t.pipe(Object(r.map)((e=>({license_id:e.uid,license_status:e.status,license_type:e.type})))),schema:{license_id:{type:"keyword",_meta:{description:"The license ID",optional:!0}},license_status:{type:"keyword",_meta:{description:"The license Status (active/invalid/expired)",optional:!0}},license_type:{type:"keyword",_meta:{description:"The license Type (basic/standard/gold/platinum/enterprise/trial)",optional:!0}}}})}(e.analytics,i),this.internalSubscription=i.subscribe((e=>{e.isAvailable?(this.prevSignature=e.signature,this.save(e)):(this.prevSignature=void 0,this.removeSaved()),"expired"===e.status&&!this.isLicenseExpirationBannerShown&&this.coreStart&&(this.isLicenseExpirationBannerShown=!0,this.showExpiredBanner(e))})),this.removeInterceptor=e.http.intercept({response:async i=>{if(e.http.anonymousPaths.isAnonymous(window.location.pathname))return i;if(i.response){const e=i.response.headers.get("kbn-license-sig");"string"==typeof e&&this.prevSignature!==e&&(i.request.url.includes(this.infoEndpoint)||t.next())}return i}}),this.refresh=s,this.license$=i,{refresh:s,license$:i,featureUsage:this.featureUsage.setup()}}start(e){if(this.coreStart=e,!this.refresh||!this.license$)throw new Error("Setup has not been completed");return{refresh:this.refresh,license$:this.license$,featureUsage:this.featureUsage.start({http:e.http})}}stop(){this.stop$.next(),this.stop$.complete(),void 0!==this.removeInterceptor&&this.removeInterceptor(),void 0!==this.internalSubscription&&(this.internalSubscription.unsubscribe(),this.internalSubscription=void 0)}showExpiredBanner(e){const t=this.coreStart.http.basePath.prepend("/app/management/stack/license_management/upload_license");var i;this.coreStart.overlays.banners.add((i={type:e.type,uploadUrl:t},Object(p.toMountPoint)(Object(h.jsx)(d,{type:i.type,uploadUrl:i.uploadUrl}))))}}const b=e=>new plugin_LicensingPlugin(e)}]);