function E(o, i, h) {
  let c = 0;
  const a = [];
  o.forEach((t, n) => {
    t === void 0 ? a.push(n) : c += t;
  });
  const r = 1 - c, l = a.length;
  if (o.length && !a.length && c !== 1) {
    if (c === 0) {
      const n = 1 / o.length;
      return o.map(() => n);
    }
    const t = 1 / c;
    return o.map((n) => n * t);
  }
  if (r < 0) {
    const t = 1 / c;
    return o.map((n) => n === void 0 ? 0 : n * t);
  }
  let u = 0, x = 0, d = 0, m = 1;
  for (const t of a) {
    const n = i[t] || 0, e = h[t] || 1;
    u += n, x += e, d = Math.max(d, n), m = Math.min(m, e);
  }
  if (u > 1 && x < 1) {
    const t = 1 / l;
    return o.map((n) => n === void 0 ? t : n);
  }
  const s = r / l;
  if (d <= s && s <= m)
    return o.map((t) => t === void 0 ? s : t);
  const f = [...o];
  let v = r - u;
  for (let t = 0; t < l; t += 1) {
    const n = a[t], e = i[n] || 0, A = h[n] || 1;
    f[n] = e;
    const C = A - e, M = Math.min(C, v);
    f[n] += M, v -= M;
  }
  return f;
}
export {
  E as autoPtgSizes
};
