"use strict";exports.ids=["498"],exports.modules={49791:function(e,t,n){t.OnBeforeTrigger=void 0;var r=n(50361),o=n(69871),i=n(53993);t.OnBeforeTrigger=class{constructor(e){this.context=e.context,this.indexManager=e.indexManager}async run(e){let t=(0,i.listCreateElasticsearchIndexTaskPlugin)(this.context.plugins),n=this.context.tenancy.getCurrentTenant();if(!n?.id)throw Error("Something went wrong, tenant not found when triggering a task.");let a=this.context.i18n.getContentLocale();if(!a)throw Error("Something went wrong, locale not found when triggering a task.");try{let i=(await (0,r.listIndexes)({context:this.context,plugins:t,tenants:[n],locales:[a]})).filter(t=>{if(!e?.length)return!0;for(let n of e)if(t.index.includes(n))return!0;return!1});if(0===i.length){console.warn("There are no indexes to create before triggering the Create indexes task.",{targets:e});return}let s=(0,o.createIndexFactory)(this.indexManager);for(let{index:e,settings:t}of i)try{console.log("Creating index",e),await s.createIfNotExists(e,t)}catch(t){console.error(`Failed to create index "${e}".`,t)}}catch(e){console.error(e)}}}}};
//# sourceMappingURL=OnBeforeTrigger.d3b1a5ca.chunk.js.map