"use strict";exports.ids=["713"],exports.modules={49599:function(e,t,s){Object.defineProperty(t,"__esModule",{value:!0}),t.CustomAsset=void 0;var r=s(66892);class o extends r.Asset{}t.CustomAsset=o},17422:function(e,t,s){Object.defineProperty(t,"__esModule",{value:!0}),t.CustomAssetProcessor=void 0;var r=s(49599);t.CustomAssetProcessor=class{constructor(e){this.assetProcessor=e}async process(e,t){return t instanceof r.CustomAsset?t:this.assetProcessor.process(e,t)}}},61684:function(e,t,s){var r=s(15755).default;Object.defineProperty(t,"__esModule",{value:!0}),t.S3CustomAssetResolver=void 0;var o=r(s(71017)),n=s(30247),a=s(7849),i=s(49599);t.S3CustomAssetResolver=class{constructor(e,t,s){this.assetResolver=s,this.s3=e,this.bucket=t}async resolve(e){let t=await this.assetResolver.resolve(e);if(t)return t;try{let t=await this.findMetadata(e);if(!t)return;let s=await this.getFileAttributes(e.getKey());if(!s)return;let r=new n.S3AssetMetadataReader(this.s3,this.bucket),o=await r.getMetadata(t.replace(".metadata","")),c=new i.CustomAsset({id:o.id,tenant:o.tenant,locale:o.locale,size:s.size,contentType:s.contentType,key:e.getKey()});return c.setContentsReader(new a.S3ContentsReader(this.s3,this.bucket)),c}catch(e){console.error(e);return}}async findMetadata(e){let t=o.default.dirname(e.getKey()),s=await this.s3.listObjects({Bucket:this.bucket,Prefix:t+"/"});if(!s.Contents)return;let r=s.Contents.find(e=>e.Key?.endsWith(".metadata"));return r?r.Key:void 0}async getFileAttributes(e){let t=await this.s3.headObject({Bucket:this.bucket,Key:e});if(t)return{size:t.ContentLength||0,contentType:t.ContentType||""}}}},15726:function(e,t,s){Object.defineProperty(t,"__esModule",{value:!0}),t.customAssetDeliveryConfig=void 0;var r=s(66892),o=s(84442),n=s(61684),a=s(17422);t.customAssetDeliveryConfig=()=>(0,r.createAssetDeliveryConfig)(e=>{e.decorateAssetResolver(({assetResolver:e})=>{let t=new o.S3({region:process.env.AWS_REGION});return new n.S3CustomAssetResolver(t,String(process.env.S3_BUCKET),e)}),e.decorateAssetProcessor(({assetProcessor:e})=>new a.CustomAssetProcessor(e))})},7849:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.S3ContentsReader=void 0,t.S3ContentsReader=class{constructor(e,t){this.s3=e,this.bucket=t}async read(e){let{Body:t}=await this.s3.getObject({Bucket:this.bucket,Key:e.getKey()});if(!t)throw Error(`Unable to read ${e.getKey()}!`);return Buffer.from(await t.transformToByteArray())}}}};
//# sourceMappingURL=customAssetDelivery.094c4d95.chunk.js.map