import { o as h, n as f, q as p, u as g, E as u, T } from "./index-DSGwv2Yx.js";
import { r as b } from "./reshape-BIN71H3p.js";
function m(e, r) {
  let n = f(e, "broadcastTo", "x");
  const a = n.shape;
  if (p(r), r.length < n.rank)
    throw new Error(`broadcastTo(): shape.length=${r.length} < input.rank=${n.rank}.`);
  if (r.length > n.rank) {
    const t = n.shape.slice();
    for (; t.length < r.length; )
      t.unshift(1);
    n = b(n, t);
  }
  const s = n.shape, o = Array.from(r);
  for (let t = r.length - 1; t >= 0; t--)
    if (s[t] === r[t])
      o[t] = 1;
    else if (n.shape[t] !== 1)
      throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${r}].`);
  if (o.map((t, l) => t > 1 ? l : -1).filter((t) => t >= 0).length === 0)
    return g(n);
  const i = { x: n }, c = { reps: o };
  return u.runKernel(T, i, c);
}
const E = /* @__PURE__ */ h({ broadcastTo_: m });
export {
  E as b
};
