import h from "./loadTransformers.js";
import { AdamWOptimizer as m } from "../training/AdamW.js";
async function u(i, c) {
  const t = await i.file("config.json")?.async("string");
  if (!t)
    throw new Error("Config file not found in the zip archive");
  const g = JSON.parse(t), n = await i.file("tokeniser.json")?.async("string");
  if (!n)
    throw new Error("Tokeniser file not found in the zip archive");
  const w = JSON.parse(n), e = await i.file("model.safetensors")?.async("arraybuffer");
  if (!e)
    throw new Error("Model weights not found in the zip archive");
  const r = await i.file("optimizer_config.json")?.async("string");
  let o;
  if (r) {
    const l = JSON.parse(r), f = await i.file("optimizer.safetensors")?.async("arraybuffer");
    if (!f)
      throw new Error("Optimizer weights not found in the zip archive");
    o = new m(l), await o.loadMoments(f);
  }
  const a = await i.file("training_log.json")?.async("string");
  let s;
  return a && (s = JSON.parse(a)), {
    ...await h(g, w, c, e),
    optimizer: o,
    log: s
  };
}
export {
  u as default
};
