import { j as t } from "./_virtual/jsx-runtime.js";
import { forwardRef as I, useRef as d, useImperativeHandle as P, useEffect as j } from "react";
import "./node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import "./node_modules/.pnpm/react-hot-toast@2.5.2_react-dom@18.3.0-canary-3d9b20132-20240124_react@18.3.0-canary-3d_c02c1e17bf76c343fd22d1f22394ecf5/node_modules/react-hot-toast/dist/index.js";
import { tx as D } from "./packages/style-system/dist/twind.js";
import { useDarkMode as E } from "./node_modules/.pnpm/usehooks-ts@3.1.1_react@18.3.0-canary-3d9b20132-20240124/node_modules/usehooks-ts/dist/index.js";
import { createEditorStore as C, EditorStoreContext as R } from "./use-editor.js";
import { UploaderProvider as w } from "./packages/components/src/editor/components/UploaderContext.js";
/* empty css                                                                                                                                                                                     */
/* empty css                                     */
/* empty css                                    */
/* empty css                                            */
/* empty css                                              */
/* empty css                                                 */
import { createDraftStore as B, DraftStoreContext as M } from "./use-page-data.js";
import { Theme as T } from "./node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/theme.js";
const V = I(
  ({
    config: s,
    pageVersion: n,
    pageId: c,
    onImageUpload: l,
    children: m,
    onSaveSite: p,
    onSavePage: f,
    onPublish: u,
    onShowPopup: g,
    onReady: v = () => {
    }
  }, x) => {
    const { site: i, pages: a } = s, e = new URL(self.location.href).searchParams, S = e.has("debug") && e.get("debug") !== "false", o = d(
      C({
        onPublish: u,
        onSaveSite: p,
        onSavePage: f,
        onShowPopup: g,
        logoLink: `/dashboard/sites/${i.id}`,
        debugMode: S,
        panel: e.get("panel") ?? void 0,
        selectedBrickId: e.get("selectedBrickId") ?? void 0,
        selectedSectionId: e.get("selectedBrickId") ? void 0 : e.get("selectedSectionId") ?? void 0,
        modal: e.get("modal") ?? void 0,
        attributesTab: e.get("attributesTab") ?? void 0,
        panelPosition: e.get("panelPosition") ?? void 0
      })
    ).current, h = a.find((k) => k.id === c) ?? a[0], r = d(
      B({
        site: i,
        page: {
          ...h,
          version: n
        }
      })
    ).current;
    P(
      x,
      () => ({
        editorStore: o,
        draftStore: r
      }),
      [o, r]
    );
    const { isDarkMode: b } = E();
    return j(v, []), /* @__PURE__ */ t.jsx(w, { onImageUpload: l, children: /* @__PURE__ */ t.jsx(R.Provider, { value: o, children: /* @__PURE__ */ t.jsx(M.Provider, { value: r, children: /* @__PURE__ */ t.jsx(
      T,
      {
        accentColor: "violet",
        className: D("w-full flex flex-col"),
        appearance: b ? "dark" : "light",
        children: m
      }
    ) }, "DraftStoreContext") }, "EditorStoreContext") });
  }
);
export {
  V as EditorWrapper
};
//# sourceMappingURL=EditorWrapper.js.map
