import { jsxs as S, Fragment as u, jsx as e } from "@emotion/react/jsx-runtime";
import { Area as _ } from "./subcomponents/Area/Area.js";
import { useAreasStore as r } from "../../hooks/useAreas/index.js";
import { AreaMemonizedWindowModal as z } from "./subcomponents/Area/subcomponents/WindowModal/WindowModal.js";
import { shallow as m } from "zustand/shallow";
import { LoadingError as N } from "../../../LoadingError/LoadingError.js";
import { getNameDataTestId as R, getPropDataTestId as x } from "../../../../test/getNameDataTestId.js";
import { AREAS_VIEWER_CLASS_NAME as M } from "../../constants.js";
import { TEST_PROP_ID as T } from "../../../../test/constants_no_mock.js";
import { AreasViewerRootStyled as V } from "./slots/AreasViewerSlots.js";
import { AREAS_VIEWER_KEY_COMPONENT as a } from "./constants.js";
import { getComponentSlotRoot as g } from "../../../../utils/getComponentSlotRoot.js";
import { AreasViewerSlots as h } from "./slots/AreasViewerEnum.js";
import C from "clsx";
import { forwardRef as D } from "react";
import { useComponentSize as O } from "../../../../hooks/useComponentSize/index.js";
const Q = D((i, n) => {
  const {
    dataTestId: d,
    className: c,
    size: p
  } = i, f = r((o) => o.areasIds, m), l = r((o) => o.windowsModalsIds), t = r((o) => o.currentAreaId), s = r((o) => o.ownerState?.status), { init: A } = r((o) => o.areasActions), { currentSize: w } = O(p), E = r(
    (o) => t ? o.hashAreas[t]?.maximizedId : void 0,
    m
  ), I = {
    selected: !!t,
    maximized: !!E
  };
  return /* @__PURE__ */ S(u, { children: [
    /* @__PURE__ */ e(
      V,
      {
        ref: n,
        className: C(g(a), c),
        ...x(a, h.root, d),
        ownerState: I,
        ...process.env.NODE_ENV !== "production" ? {
          [T]: R(
            M,
            "root",
            ""
          )
        } : {},
        children: s === "loaded" ? f.map((o) => /* @__PURE__ */ e(_, { areaId: o, selected: t === o, size: w }, o)) : /* @__PURE__ */ e(N, { status: s, action: () => A() })
      }
    ),
    l.map((o) => /* @__PURE__ */ e(z, { windowId: o }, o))
  ] });
});
export {
  Q as AreasViewer
};
