import { N as p, a9 as w } from "./index-DSGwv2Yx.js";
function k(o, t, r) {
  const n = t.rank > 1 ? t.shape[t.rank - 1] : 1, e = t.rank > 1 ? t.rank - 1 : 1, h = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${r.shape}, indices.shape: ${t.shape}, shape: ${o}, sliceDim: ${n}, and batchDim: ${e}.`;
  if (r.rank < e)
    throw new Error(h + ` update.rank < ${e}. `);
  if (o.length < n + (r.rank - e))
    throw new Error(h + ` Output shape length < ${n + (r.rank - e)}`);
  if (r.rank !== e + o.length - n)
    throw new Error(h + ` update.rank != ${e + o.length - n}`);
  for (let a = 0; a < e; ++a)
    if (r.shape[a] !== t.shape[a])
      throw new Error(h + ` updates.shape[${a}] (${r.shape[a]}) != indices.shape[${a}] (${t.shape[a]}).`);
  for (let a = 0; a < r.rank - e; ++a)
    if (r.shape[a + e] !== o[a + n])
      throw new Error(h + ` updates.shape[${a + e}] (${r.shape[a + e]}) != shape[${a + e}] (${o[a + e]})`);
}
function $(o, t, r) {
  if (t.rank < 1)
    throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);
  if (o.rank < 1)
    throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${o.rank}.`);
  if (t.dtype !== "int32")
    throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);
  if (r.length < 1)
    throw new Error(`Output rank must be greater or equal to 1, but got shape: ${r}`);
  if (r.length === 0) {
    if (t.size === 0)
      throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);
    if (o.size === 0)
      throw new Error(`Updates specified for empty output. updates shape: ${o.shape}`);
  }
  k(r, t, o);
}
function m(o, t, r) {
  const n = t.shape.length, e = n > 1 ? t.shape[n - 1] : 1, h = r.length;
  let a = 1;
  for (let s = e; s < h; ++s)
    a *= r[s];
  const i = e < 1 ? 1 : e, f = p(t.shape) / i, c = [...w(r.slice(0, e)), 1], l = p(r);
  return { sliceRank: e, numUpdates: f, sliceSize: a, strides: c, outputSize: l };
}
export {
  k as a,
  m as c,
  $ as v
};
