import { t as React, aF as returnPageBasedOnCLSID, j as jsxRuntimeExports, a7 as TabItem, aI as Tabs, aX as updateVisibleGrids, ah as AxiosRequest } from "./index-D15x63tD.js";
function loadMultipage(id) {
  const params = /* @__PURE__ */ new Map();
  params.set("prefix", "pages");
  params.set("comand", "GetMembers");
  params.set("SectionID", id);
  return AxiosRequest(true, params);
}
function OtherObjects({ sectionData }) {
  const tabPanel = React.useRef(null);
  const [multipage, setMultipage] = React.useState();
  const [content, setContent] = React.useState();
  React.useEffect(() => {
    if (sectionData.ID) {
      loadMultipage(sectionData.ID).then((res) => {
        setMultipage(res);
      });
    } else setMultipage({ Pages: sectionData.Pages });
  }, []);
  React.useEffect(() => {
    if (multipage) {
      firstLoadContent();
    }
  }, [multipage]);
  async function firstLoadContent() {
    if (multipage && multipage.Pages !== void 0) {
      const elements = [];
      let index = 0;
      for (let Page of multipage.Pages) {
        const innerContent = index === 0 ? await returnPageBasedOnCLSID(Page, void 0, sectionData.ID) : void 0;
        if (Page.CLSID) {
          elements.push(
            /* @__PURE__ */ jsxRuntimeExports.jsx(TabItem, { style: { height: "100%", width: "100%" }, label: Page.Name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: "100%", width: "100%" }, children: innerContent }) }, `multipage-${index}`)
          );
        }
        index++;
      }
      setContent([...elements]);
      return;
    }
    setContent(/* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {}));
  }
  async function updatePage(ev) {
    if (ev.target !== null) return;
    updateVisibleGrids();
    if (content) {
      const id = tabPanel.current.selectedIndex ? tabPanel.current.selectedIndex : 0;
      const Page = multipage.Pages[id];
      const innerContent = await returnPageBasedOnCLSID(Page, void 0, sectionData.ID);
      content[id] = /* @__PURE__ */ jsxRuntimeExports.jsx(TabItem, { style: { height: "100%", width: "100%" }, label: Page.Name, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: "100%", width: "100%" }, children: innerContent }) }, `multipage-${id}`);
      setContent([...content]);
    }
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
    Tabs,
    {
      ref: tabPanel,
      onChange: async (ev) => await updatePage(ev),
      animation: "none",
      style: {
        height: "100%",
        width: "100%",
        backgroundColor: "s"
      },
      children: content
    }
  ) });
}
export {
  OtherObjects as default
};
//# sourceMappingURL=OtherObjects-y5GTeuVi.js.map
