"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@aplus-frontend/oss");let n,c;function w(s,e){n=s,c=e}const y={"zh-cn":"zh_CN",en:"en_US"};function p(){return y[c.value]??"zh_CN"}async function U({file:s,dirName:e,oss:o,successCallBack:O,errorCallBack:r,progressCallBack:g,baseDirName:f="Frontend-Upload",bucket:l}){if(!e){r("required dirName");return}try{const t=await o.put({fileName:s.name,dirName:e,data:s,progressCallBack:a=>{g(a)},baseDirName:f});if(t.status===204)return;if(t.status===200){const{saveUrl:a,previewUrl:d}=t,m=l&&a?`${l}:${a}`:a;O(m,d)}else r(t?.message||n("ap.apUpload.networkAnomaly"))}catch(t){r(t)}}function u(){return{client:i.client,put:U}}async function h(s){if(!s)throw new Error(`${n("ap.apUpload.pleasePass")}getOssAccess`);return await i.client.initOssClient({getOssAccess:s,locale:p(),onFailure:e=>{throw new Error(typeof e?.message=="string"?e.message:n("ap.apUpload.FailedToObtainOssTemporaryPermissions"))}}),u()}async function T(s){if(!s)throw new Error(`${n("ap.apUpload.pleasePass")}getOssAccess`);const e=i.createOssInstance();return await e.initOssClient({getOssAccess:s,locale:p(),onFailure:o=>{throw new Error(typeof o?.message=="string"?o.message:n("ap.apUpload.FailedToObtainOssTemporaryPermissions"))}}),e}exports.getOssInstance=T;exports.injectLocaleToOss=w;exports.useOss=u;exports.useOssInit=h;
