"use strict";exports.id=454,exports.ids=[454],exports.modules={5587:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CustomAsset=void 0;var r=s(47859);class o extends r.Asset{}t.CustomAsset=o},60199:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CustomAssetProcessor=void 0;var r=s(5587);t.CustomAssetProcessor=class{constructor(e){this.assetProcessor=e}async process(e,t){return t instanceof r.CustomAsset?t:this.assetProcessor.process(e,t)}}},88327:(e,t,s)=>{var r=s(92120).default;Object.defineProperty(t,"__esModule",{value:!0}),t.S3CustomAssetResolver=void 0;var o=r(s(16928)),n=s(27630),a=s(16959),i=s(5587);t.S3CustomAssetResolver=class{constructor(e,t,s){this.assetResolver=s,this.s3=e,this.bucket=t}async resolve(e){const t=await this.assetResolver.resolve(e);if(t)return t;try{const t=await this.findMetadata(e);if(!t)return;const s=await this.getFileAttributes(e.getKey());if(!s)return;const 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){return void console.error(e)}}async findMetadata(e){const t=o.default.dirname(e.getKey()),s=await this.s3.listObjects({Bucket:this.bucket,Prefix:t+"/"});if(!s.Contents)return;const r=s.Contents.find((e=>e.Key?.endsWith(".metadata")));return r?r.Key:void 0}async getFileAttributes(e){const t=await this.s3.headObject({Bucket:this.bucket,Key:e});if(t)return{size:t.ContentLength||0,contentType:t.ContentType||""}}}},64994:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.customAssetDeliveryConfig=void 0;var r=s(47859),o=s(423),n=s(88327),a=s(60199);t.customAssetDeliveryConfig=()=>(0,r.createAssetDeliveryConfig)((e=>{e.decorateAssetResolver((({assetResolver:e})=>{const 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)))}))},16959:(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){const{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.5264272f.chunk.js.map