import { createOssInstance as r } from "@aplus-frontend/oss";
let a, c, n;
function g(e, t, s) {
  a = e, c = t, s && (n = s);
}
const i = {
  "zh-cn": "zh_CN",
  en: "en_US"
};
function l() {
  return i[c.value] ?? "zh_CN";
}
async function O({ bucket: e } = {}) {
  if (!n)
    throw new Error(`${a("ap.apUpload.pleasePass")}getOssAccess`);
  const t = await (e ? n(e) : n()), s = r();
  return await s.initOssClient({
    getOssAccess: async () => t,
    locale: l(),
    onFailure: (o) => {
      throw new Error(
        typeof o?.message == "string" ? o.message : a("ap.apUpload.FailedToObtainOssTemporaryPermissions")
      );
    }
  }), {
    oss: s,
    bucket: t?.bucket
  };
}
export {
  O as getOssInstance,
  g as injectHookOss
};
