import { useMemo as L } from "react";
import { shallow as s } from "zustand/shallow";
import { usePopupsStore as t } from "./usePopupsStore.js";
import { useHeaderActionsPopups as N } from "./useHeaderActionsPopups.js";
import O from "../../../../ToastContainer/helpers/toaster.js";
const p = (e) => {
  const {
    moduleId: u,
    winType: w,
    title: d,
    iconUrl: g,
    status: f,
    dynamicMFStore: T,
    loading: y,
    version: b,
    buildTime: v,
    subTitle: C,
    editionInfo: W,
    zIndex: A,
    variant: z = "normal",
    draggable: k = !0,
    resizable: x = !0,
    defaultPosition: H,
    bounds: F,
    onMouseDown: M,
    allowHeightResizeContainer: S,
    allowWidthResizeContainer: Q,
    maxHeight: R,
    maxWidth: _,
    minHeight: D,
    minWidth: E
  } = t(
    (o) => o.hashPopups[e],
    s
  ), G = t(
    (o) => o.hashPopups[e].winType === "microfrontend" ? o.hashPopups[e].mfProps : void 0,
    s
  ), U = t(
    (o) => o.hashPopups[e].winType === "component" ? o.hashPopups[e].component : void 0,
    s
  ), j = t(
    (o) => o.hashPopups[e].winType === "component" ? o.hashPopups[e].componentProps : void 0,
    s
  ), q = t(
    (o) => o.hashGroups[o.hashPopups[e].groupId].selectedPopupId,
    s
  ), {
    setFnQueryClose: i
  } = t((o) => o.popupsActions, s), {
    hide: r,
    show: c,
    update: n,
    close: a,
    setActions: m,
    startProgress: h,
    stopProgress: l
  } = t((o) => o.popupActions, s), B = L(
    () => ({
      getWindowId: () => e,
      setActions: (o, P, K) => {
        m(e, o, P, K);
      },
      /**
       * TODO: Implement this when popup cookies become first-class runtime data.
       */
      getCookie: () => {
      },
      /**
       * TODO: Implement this when popup cookies become first-class runtime data.
       */
      getCookies: () => ({}),
      setCookie: (o, P) => {
      },
      close: (o = !0) => a(e, o),
      startProgress: () => h(e),
      stopProgress: () => l(e),
      setFnQueryClose: (o) => i(e, o),
      toast: O(e),
      setWindowTitle: (o) => n(e, { title: o }),
      setWindowSubTitle: (o) => n(e, { subTitle: o }),
      setWindowEditionInfo: (o) => n(e, { editionInfo: o }),
      hide: () => r(e),
      show: () => {
        c(e);
      }
    }),
    [
      e,
      m,
      //getCookie,
      //getCookies,
      //setCookie,
      a,
      h,
      l,
      i,
      n,
      r,
      c
    ]
  ), J = N({
    popupId: e
  });
  return {
    winType: w,
    moduleId: u,
    title: d,
    subTitle: C,
    iconUrl: g,
    selected: q === e,
    mfProps: G,
    component: U,
    componentProps: j,
    loading: y,
    status: f,
    version: b,
    buildTime: v,
    dynamicMFStore: T,
    windowTools: B,
    //onTouch,
    memoizedActions: J,
    editionInfo: W,
    zIndex: A,
    variant: z,
    draggable: k,
    resizable: x,
    defaultPosition: H,
    bounds: F,
    onMouseDown: M,
    allowHeightResizeContainer: S,
    allowWidthResizeContainer: Q,
    maxHeight: R,
    maxWidth: _,
    minHeight: D,
    minWidth: E
  };
};
export {
  p as usePopups
};
