function s(t) {
  return JSON.stringify(t, (n, r) => !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((i, e) => (i[e] = r[e], i), {}));
}
const y = [
  "i",
  "x",
  "y",
  "w",
  "h",
  "minW",
  "minH",
  "maxW",
  "maxH",
  "static",
  "isResizable",
  "isDraggable"
];
function f(t, n, r) {
  t[n] = r;
}
function a(t) {
  const n = {};
  for (const r of y) {
    const i = t[r];
    i !== void 0 && ((r === "isResizable" || r === "isDraggable") && i === !0 || f(n, r, i));
  }
  return n;
}
function o(t) {
  return t ? t.map(a).sort((n, r) => {
    const i = String(n.i ?? ""), e = String(r.i ?? "");
    return i !== e ? i.localeCompare(e) : Number(n.y ?? 0) - Number(r.y ?? 0) || Number(n.x ?? 0) - Number(r.x ?? 0) || Number(n.h ?? 0) - Number(r.h ?? 0) || Number(n.w ?? 0) - Number(r.w ?? 0);
  }) : [];
}
function u(t) {
  if (!t) return;
  const n = {};
  for (const r of Object.keys(t).sort()) {
    const i = t[r];
    i && (n[r] = o(i));
  }
  return n;
}
function c(t) {
  var n;
  return t ? {
    ...t,
    sheets: (n = t.sheets) == null ? void 0 : n.map((r) => {
      if (!r) return r;
      const i = {
        ...r
      };
      return r.layout && (i.layout = o(r.layout)), r.layouts && (i.layouts = u(r.layouts)), i;
    })
  } : null;
}
function m(t) {
  return JSON.stringify(t ?? null, function(n, r) {
    return n === "layout" && Array.isArray(r) ? o(r) : n === "layouts" && r && typeof r == "object" && !Array.isArray(r) ? u(r) : !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((i, e) => (i[e] = r[e], i), {});
  });
}
function b(t) {
  return s(u(t) ?? null);
}
export {
  s as a,
  b,
  c as n,
  m as s
};
