import { jsxs as I, jsx as d } from "react/jsx-runtime";
import { u as Z, a as de, b as ue, c as fe, d as Ie, e as Be, f as De, g as Ne, h as Re } from "./use-editor.BioV43yU.js";
import * as E from "react";
import { useState as X, useRef as O, useCallback as $e, useLayoutEffect as Le, useEffect as F, useContext as pe, createContext as me, lazy as M, Suspense as z, startTransition as Ae } from "react";
import { _ as P, B as j, r as Te } from "./twind.D_WBdNpx.js";
import { y as Y, u as He, a as Me, c as Ke, P as ge, b as _e, d as ze, e as se, f as je, O as Oe } from "./index.B-GbFHzr.js";
import { u as ee, a as We, b as Fe, c as Ve, d as qe, e as Ue, f as te, g as Ge, h as Xe, i as he, j as Ye, k as Je, l as Qe } from "./use-page-data.ClF2QKbJ.js";
import { getThemeCss as Ze } from "../get-theme-css.js";
import { D as et } from "./dnd.esm.ByOls-Fs.js";
import { D as V, r as W, b as tt } from "./chunk-RXIM6GTA.C-ABNABt.js";
import "@sinclair/typebox";
import "lodash-es";
import { r as rt, o as ot, a as nt, v as at, b as it } from "./radius.prop.Qnji8gKF.js";
import { n as st } from "./base-button.UO-Ivxsv.js";
const J = E.forwardRef(({ className: e, ...t }, r) => E.createElement(st, { ...t, ref: r, className: Y("rt-Button", e) }));
J.displayName = "Button";
function ct(e) {
  const t = E.useRef({ value: e, previous: e });
  return E.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
}
var re = "Switch", [lt, ar] = Ke(re), [dt, ut] = lt(re), ve = E.forwardRef(
  (e, t) => {
    const {
      __scopeSwitch: r,
      name: a,
      checked: s,
      defaultChecked: l,
      required: c,
      disabled: f,
      value: u = "on",
      onCheckedChange: o,
      ...p
    } = e, [m, h] = E.useState(null), n = He(t, ($) => h($)), B = E.useRef(!1), D = m ? !!m.closest("form") : !0, [w = !1, v] = Me({
      prop: s,
      defaultProp: l,
      onChange: o
    });
    return /* @__PURE__ */ I(dt, { scope: r, checked: w, disabled: f, children: [
      /* @__PURE__ */ d(
        ge.button,
        {
          type: "button",
          role: "switch",
          "aria-checked": w,
          "aria-required": c,
          "data-state": ke(w),
          "data-disabled": f ? "" : void 0,
          disabled: f,
          value: u,
          ...p,
          ref: n,
          onClick: _e(e.onClick, ($) => {
            v((K) => !K), D && (B.current = $.isPropagationStopped(), B.current || $.stopPropagation());
          })
        }
      ),
      D && /* @__PURE__ */ d(
        ft,
        {
          control: m,
          bubbles: !B.current,
          name: a,
          value: u,
          checked: w,
          required: c,
          disabled: f,
          style: { transform: "translateX(-100%)" }
        }
      )
    ] });
  }
);
ve.displayName = re;
var be = "SwitchThumb", ye = E.forwardRef(
  (e, t) => {
    const { __scopeSwitch: r, ...a } = e, s = ut(be, r);
    return /* @__PURE__ */ d(
      ge.span,
      {
        "data-state": ke(s.checked),
        "data-disabled": s.disabled ? "" : void 0,
        ...a,
        ref: t
      }
    );
  }
);
ye.displayName = be;
var ft = (e) => {
  const { control: t, checked: r, bubbles: a = !0, ...s } = e, l = E.useRef(null), c = ct(r), f = ze(t);
  return E.useEffect(() => {
    const u = l.current, o = window.HTMLInputElement.prototype, m = Object.getOwnPropertyDescriptor(o, "checked").set;
    if (c !== r && m) {
      const h = new Event("click", { bubbles: a });
      m.call(u, r), u.dispatchEvent(h);
    }
  }, [c, r, a]), /* @__PURE__ */ d(
    "input",
    {
      type: "checkbox",
      "aria-hidden": !0,
      defaultChecked: r,
      ...s,
      tabIndex: -1,
      ref: l,
      style: {
        ...e.style,
        ...f,
        position: "absolute",
        pointerEvents: "none",
        opacity: 0,
        margin: 0
      }
    }
  );
};
function ke(e) {
  return e ? "checked" : "unchecked";
}
var pt = ve, mt = ye;
const gt = ["1", "2", "3"], ht = ["classic", "surface", "soft"], vt = { size: { type: "enum", className: "rt-r-size", values: gt, default: "2", responsive: !0 }, variant: { type: "enum", className: "rt-variant", values: ht, default: "surface" }, ...nt, ...ot, ...rt }, we = E.forwardRef((e, t) => {
  const { className: r, color: a, radius: s, ...l } = at(e, vt, it);
  return E.createElement(pt, { "data-accent-color": a, "data-radius": s, ...l, asChild: !1, ref: t, className: Y("rt-reset", "rt-SwitchRoot", r) }, E.createElement(mt, { className: Y("rt-SwitchThumb", { "rt-high-contrast": e.highContrast }) }));
});
we.displayName = "Switch";
const ce = 1e3;
function bt() {
  const e = ee(), t = We(), { onSavePage: r, onSaveSite: a } = Z(), s = se(async (c) => {
    await (r == null ? void 0 : r({
      pageId: t.id,
      pageVersionId: "latest",
      siteId: t.siteId,
      data: c
    })), e.setDirty(!1);
  }, ce), l = se(async (c) => {
    await (a == null ? void 0 : a({
      siteId: t.siteId,
      data: c
    })), e.setDirty(!1);
  }, ce);
  Fe((c) => {
    console.debug("Sections have changed, updating page version", c), e.setDirty(!0), s({ sections: c });
  }), Ve((c) => {
    console.debug("Attributes have changed:", c), e.setDirty(!0), s({ attr: c });
  }), qe((c) => {
    console.debug("pagePath has changed, updating page version"), e.setDirty(!0), s({ path: c });
  }), Ue((c) => {
    console.debug("theme has changed, updating page version"), e.setDirty(!0), l({ theme: c });
  });
}
function Q() {
  return Q = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var a in r) ({}).hasOwnProperty.call(r, a) && (e[a] = r[a]);
    }
    return e;
  }, Q.apply(null, arguments);
}
var xe = ["shift", "alt", "meta", "mod", "ctrl"], yt = {
  esc: "escape",
  return: "enter",
  ".": "period",
  ",": "comma",
  "-": "slash",
  " ": "space",
  "`": "backquote",
  "#": "backslash",
  "+": "bracketright",
  ShiftLeft: "shift",
  ShiftRight: "shift",
  AltLeft: "alt",
  AltRight: "alt",
  MetaLeft: "meta",
  MetaRight: "meta",
  OSLeft: "meta",
  OSRight: "meta",
  ControlLeft: "ctrl",
  ControlRight: "ctrl"
};
function A(e) {
  return (e && yt[e] || e || "").trim().toLowerCase().replace(/key|digit|numpad|arrow/, "");
}
function kt(e) {
  return xe.includes(e);
}
function q(e, t) {
  return t === void 0 && (t = ","), e.split(t);
}
function U(e, t, r) {
  t === void 0 && (t = "+");
  var a = e.toLocaleLowerCase().split(t).map(function(c) {
    return A(c);
  }), s = {
    alt: a.includes("alt"),
    ctrl: a.includes("ctrl") || a.includes("control"),
    shift: a.includes("shift"),
    meta: a.includes("meta"),
    mod: a.includes("mod")
  }, l = a.filter(function(c) {
    return !xe.includes(c);
  });
  return Q({}, s, {
    keys: l,
    description: r,
    hotkey: e
  });
}
(function() {
  typeof document < "u" && (document.addEventListener("keydown", function(e) {
    e.key !== void 0 && Se([A(e.key), A(e.code)]);
  }), document.addEventListener("keyup", function(e) {
    e.key !== void 0 && Ce([A(e.key), A(e.code)]);
  })), typeof window < "u" && window.addEventListener("blur", function() {
    T.clear();
  });
})();
var T = /* @__PURE__ */ new Set();
function oe(e) {
  return Array.isArray(e);
}
function wt(e, t) {
  t === void 0 && (t = ",");
  var r = oe(e) ? e : e.split(t);
  return r.every(function(a) {
    return T.has(a.trim().toLowerCase());
  });
}
function Se(e) {
  var t = Array.isArray(e) ? e : [e];
  T.has("meta") && T.forEach(function(r) {
    return !kt(r) && T.delete(r.toLowerCase());
  }), t.forEach(function(r) {
    return T.add(r.toLowerCase());
  });
}
function Ce(e) {
  var t = Array.isArray(e) ? e : [e];
  e === "meta" ? T.clear() : t.forEach(function(r) {
    return T.delete(r.toLowerCase());
  });
}
function xt(e, t, r) {
  (typeof r == "function" && r(e, t) || r === !0) && e.preventDefault();
}
function St(e, t, r) {
  return typeof r == "function" ? r(e, t) : r === !0 || r === void 0;
}
function Ct(e) {
  return Pe(e, ["input", "textarea", "select"]);
}
function Pe(e, t) {
  t === void 0 && (t = !1);
  var r = e.target, a = e.composed, s = null;
  return Pt(r) && a ? s = e.composedPath()[0] && e.composedPath()[0].tagName : s = r && r.tagName, oe(t) ? !!(s && t && t.some(function(l) {
    var c;
    return l.toLowerCase() === ((c = s) == null ? void 0 : c.toLowerCase());
  })) : !!(s && t && t);
}
function Pt(e) {
  return !!e.tagName && !e.tagName.startsWith("-") && e.tagName.includes("-");
}
function Et(e, t) {
  return e.length === 0 && t ? (console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'), !0) : t ? e.some(function(r) {
    return t.includes(r);
  }) || e.includes("*") : !0;
}
var It = function(t, r, a) {
  a === void 0 && (a = !1);
  var s = r.alt, l = r.meta, c = r.mod, f = r.shift, u = r.ctrl, o = r.keys, p = t.key, m = t.code, h = t.ctrlKey, n = t.metaKey, B = t.shiftKey, D = t.altKey, w = A(m), v = p.toLowerCase();
  if (!(o != null && o.includes(w)) && !(o != null && o.includes(v)) && !["ctrl", "control", "unknown", "meta", "alt", "shift", "os"].includes(w))
    return !1;
  if (!a) {
    if (s === !D && v !== "alt" || f === !B && v !== "shift")
      return !1;
    if (c) {
      if (!n && !h)
        return !1;
    } else if (l === !n && v !== "meta" && v !== "os" || u === !h && v !== "ctrl" && v !== "control")
      return !1;
  }
  return o && o.length === 1 && (o.includes(v) || o.includes(w)) ? !0 : o ? wt(o) : !o;
}, Bt = /* @__PURE__ */ me(void 0), Dt = function() {
  return pe(Bt);
};
function Ee(e, t) {
  return e && t && typeof e == "object" && typeof t == "object" ? Object.keys(e).length === Object.keys(t).length && //@ts-ignore
  Object.keys(e).reduce(function(r, a) {
    return r && Ee(e[a], t[a]);
  }, !0) : e === t;
}
var Nt = /* @__PURE__ */ me({
  hotkeys: [],
  enabledScopes: [],
  toggleScope: function() {
  },
  enableScope: function() {
  },
  disableScope: function() {
  }
}), Rt = function() {
  return pe(Nt);
};
function $t(e) {
  var t = O(void 0);
  return Ee(t.current, e) || (t.current = e), t.current;
}
var le = function(t) {
  t.stopPropagation(), t.preventDefault(), t.stopImmediatePropagation();
}, Lt = typeof window < "u" ? Le : F;
function x(e, t, r, a) {
  var s = X(null), l = s[0], c = s[1], f = O(!1), u = r instanceof Array ? a instanceof Array ? void 0 : a : r, o = oe(e) ? e.join(u == null ? void 0 : u.splitKey) : e, p = r instanceof Array ? r : a instanceof Array ? a : void 0, m = $e(t, p ?? []), h = O(m);
  p ? h.current = m : h.current = t;
  var n = $t(u), B = Rt(), D = B.enabledScopes, w = Dt();
  return Lt(function() {
    if (!((n == null ? void 0 : n.enabled) === !1 || !Et(D, n == null ? void 0 : n.scopes))) {
      var v = function(i, g) {
        var y;
        if (g === void 0 && (g = !1), !(Ct(i) && !Pe(i, n == null ? void 0 : n.enableOnFormTags))) {
          if (l !== null) {
            var H = l.getRootNode();
            if ((H instanceof Document || H instanceof ShadowRoot) && H.activeElement !== l && !l.contains(H.activeElement)) {
              le(i);
              return;
            }
          }
          (y = i.target) != null && y.isContentEditable && !(n != null && n.enableOnContentEditable) || q(o, n == null ? void 0 : n.splitKey).forEach(function(ne) {
            var S, L = U(ne, n == null ? void 0 : n.combinationKey);
            if (It(i, L, n == null ? void 0 : n.ignoreModifiers) || (S = L.keys) != null && S.includes("*")) {
              if (n != null && n.ignoreEventWhen != null && n.ignoreEventWhen(i) || g && f.current)
                return;
              if (xt(i, L, n == null ? void 0 : n.preventDefault), !St(i, L, n == null ? void 0 : n.enabled)) {
                le(i);
                return;
              }
              h.current(i, L), g || (f.current = !0);
            }
          });
        }
      }, $ = function(i) {
        i.key !== void 0 && (Se(A(i.code)), ((n == null ? void 0 : n.keydown) === void 0 && (n == null ? void 0 : n.keyup) !== !0 || n != null && n.keydown) && v(i));
      }, K = function(i) {
        i.key !== void 0 && (Ce(A(i.code)), f.current = !1, n != null && n.keyup && v(i, !0));
      }, _ = l || (u == null ? void 0 : u.document) || document;
      return _.addEventListener("keyup", K), _.addEventListener("keydown", $), w && q(o, n == null ? void 0 : n.splitKey).forEach(function(b) {
        return w.addHotkey(U(b, n == null ? void 0 : n.combinationKey, n == null ? void 0 : n.description));
      }), function() {
        _.removeEventListener("keyup", K), _.removeEventListener("keydown", $), w && q(o, n == null ? void 0 : n.splitKey).forEach(function(b) {
          return w.removeHotkey(U(b, n == null ? void 0 : n.combinationKey, n == null ? void 0 : n.description));
        });
      };
    }
  }, [l, o, n, D]), c;
}
function At() {
  const e = Z(), t = te(), r = ee(), a = de(), s = ue(), l = fe(), c = Ge(s), { undo: f, redo: u } = Xe();
  x("esc", () => {
    e.deselectBrick(), e.setSelectedSectionId(), e.hidePanel();
  }), x("mod+c", () => {
    const o = window.getSelection();
    o != null && o.rangeCount || console.debug("mod+c pressed");
  }), x(["backspace", "del"], (o) => {
    s && (o.preventDefault(), t.deleteBrick(s), e.deselectBrick(s), e.hidePanel("inspector"));
  }), x("s", (o) => {
    o.preventDefault(), e.togglePanel("settings");
  }), x("l", (o) => {
    o.preventDefault(), e.togglePanel("library");
  }), x("t", (o) => {
    o.preventDefault(), e.togglePanel("theme");
  }), x("p", (o) => {
    o.preventDefault(), e.togglePanel();
  }), x(["mod+z", "ctrl+z"], (o) => {
    o.preventDefault(), f();
  }), x(["mod+shift+z", "ctrl+shift+z"], (o) => {
    o.preventDefault(), u();
  }), x(
    ["mod+up", "mod+left"],
    (o) => {
      if (o.preventDefault(), s)
        t.moveBrickWithin(s, "previous");
      else if (l) {
        t.moveSectionUp(l);
        const p = document.getElementById(l);
        p && p.scrollIntoView({ behavior: "smooth", block: "center" });
      }
    },
    {
      enableOnContentEditable: !1
    }
  ), x(
    ["mod+down", "mod+right"],
    (o) => {
      if (o.preventDefault(), s)
        t.moveBrickWithin(s, "next");
      else if (l) {
        t.moveSectionDown(l);
        const p = document.getElementById(l);
        p && p.scrollIntoView({ behavior: "smooth", block: "center" });
      }
    },
    {
      enableOnContentEditable: !1
    }
  ), x("mod+d", (o) => {
    o.preventDefault(), s && (t.duplicateBrick(s), je("Brick duplicated", {
      id: "duplicate-brick"
    }));
  }), x("mod+j", (o) => {
    o.preventDefault(), e.toggleEditorEnabled();
  }), x("mod+g", (o) => {
    o.preventDefault(), console.log("Debugging draft:");
    const { sections: p, themes: m, siteAttr: h, sitemap: n, attr: B, brickMap: D } = r;
    console.log({ sections: p, themes: m, siteAttr: h, sitemap: n, attr: B, brickMap: D });
  }), x(
    "space",
    (o) => {
      o.target.classList.contains("tiptap") || (o.preventDefault(), o.stopPropagation(), c && t.updateBrickProps(
        c.id,
        {
          grow: !c.props.grow
        },
        a === "mobile"
      ));
    },
    {
      enableOnContentEditable: !0
    }
  );
}
function Tt({ themes: e }) {
  var o;
  const [t, r] = X(0), [a, s] = X(0), l = O(null), c = O(null), f = Ie(), u = e[t];
  return F(() => {
    const p = setInterval(() => {
      r((m) => (m + 1) % e.length), f != null && f.length && s((m) => (m + 1) % f.length);
    }, 1e4);
    return () => clearInterval(p);
  }, [e, f]), F(() => {
    var p, m, h;
    (p = c.current) == null || p.style.setProperty("background-color", u.colors.base200), (m = c.current) == null || m.style.setProperty("color", u.colors.baseContent), (h = l.current) == null || h.style.setProperty(
      "background-image",
      `conic-gradient(from 0deg, ${u.colors.primary}, ${u.colors.secondary}, ${u.colors.accent}, ${u.colors.primary})`
    );
  }, [u]), /* @__PURE__ */ I(
    "div",
    {
      ref: c,
      className: P(
        "w-full flex justify-center items-center h-full relative overflow-hidden animate-background bg-size[400%] opacity-50",
        j({
          backgroundImage: f ? `url(${(o = f[a]) == null ? void 0 : o.url})` : "none",
          backgroundSize: "cover"
        })
      ),
      children: [
        /* @__PURE__ */ d("div", { ref: l, className: P("absolute w-[100vh] h-[100vh] inset-0 animate-spin-blob z-20") }),
        /* @__PURE__ */ d(
          "div",
          {
            className: P(
              "rounded-full absolute backdrop-blur-3xl inset-0 scale-150 bg-white/40 z-50 flex items-center justify-center",
              j({
                textShadow: "0 0 3px rgba(0, 0, 0, 0.3)",
                color: "#FFFFFF",
                fontSize: "1.2rem",
                fontWeight: "bold",
                transition: "color 0.3s ease, background-color 0.3s ease"
              })
            ),
            children: u.name
          }
        )
      ]
    }
  );
}
function Ht() {
  return he(), Ye(), /* @__PURE__ */ d(
    "div",
    {
      className: P("absolute bg-gray-200 top-0 bottom-0 left-0 right-0 flex items-center justify-center"),
      children: /* @__PURE__ */ I("h2", { className: P("text-gray-400 leading-relaxed text-xl font-semibold flex-1 text-center !font-sans"), children: [
        "Welcome!",
        /* @__PURE__ */ d("br", {}),
        "To get started, please answer a few questions from our beloved Bot, Upsie.",
        /* @__PURE__ */ d("br", {}),
        "Your site will then appear here... 🤩"
      ] })
    }
  );
}
function Mt() {
  var e;
  return ((e = globalThis.location) == null ? void 0 : e.hostname) === "localhost";
}
const Kt = M(() => import("./Tour.B34zpbtq.js")), _t = M(() => import("./NavBar.BFOsOcWw.js")), zt = M(() => import("./Chat.-1bOnEGH.js")), jt = M(() => import("./EditablePage.CGC_-U1W.js")), Ot = M(() => import("../Page.js")), G = M(() => import("./DeviceFrame.20ohmqku.js")), Wt = M(() => import("./Panel.B-ALZYs9.js"));
function ir(e) {
  const t = O(null), r = ee(), a = Be(), s = De(), l = Je(), { panelPosition: c } = Ne(), f = Qe(), u = he(), o = te(), p = de(), { setDraggingBrickType: m, toggleDebugMode: h, hidePanel: n } = Z(), B = ue(), D = fe(), w = Mt(), v = Re();
  bt(), At(), F(() => {
    const b = r.previewTheme ?? r.theme;
    b && Te(j(Ze(b)));
  }, [r.previewTheme, r.theme]);
  const $ = (b) => {
    const { draggableId: i } = b, g = document.getElementById(i);
    g == null || g.classList.add(P("moving"));
  }, K = (b) => {
    m(b.draggableId);
    const i = document.getElementById(b.draggableId);
    if (i) {
      const g = window.getComputedStyle(i);
      console.log(
        "Original compute style background color:",
        g.getPropertyValue("background-color")
      ), g.getPropertyValue("background-color") === "rgba(0, 0, 0, 0)" && (console.log("Changing background color to upstart-200"), i.style.setProperty("background-color", "rgba(229, 231, 235, .85)", "important")), i.classList.add(P("shadow-2xl"));
    }
  }, _ = (b) => {
    var L, ae;
    const { destination: i, source: g, draggableId: y, type: H, combine: ne } = b;
    m(null);
    const S = document.getElementById(y);
    if (S && (S.classList.remove(P("moving")), S.classList.remove(P("shadow-2xl")), S.style.removeProperty("box-shadow"), S.style.removeProperty("background-color"), S.style.removeProperty("max-height"), S.style.removeProperty("overflow"), S.style.removeProperty("scale"), S.style.removeProperty("transform-origin"), S.style.removeProperty("transition")), !i) {
      console.warn("Dropped outside a valid droppable area, no action taken.");
      return;
    }
    if (i.droppableId === g.droppableId && i.index === g.index) {
      console.log("Dropped in the same position, no action taken.");
      return;
    }
    if (g.droppableId.startsWith("$library$")) {
      const R = l.find((N) => N.id === i.droppableId);
      if (R) {
        const N = V(y);
        o.addBrick(N, R.id, i.index, null), console.log(
          `Added new brick ${y} to section ${R.id} at index ${i.index}`
        );
      }
      const C = o.getBrick(i.droppableId);
      if (C && W[C.type] && W[C.type].isContainer) {
        const N = V(y), k = (L = r.brickMap.get(C.id)) == null ? void 0 : L.sectionId;
        if (!k) {
          console.warn(`No section found for container ${C.id}`);
          return;
        }
        o.addBrick(N, k, i.index, C.id), console.log(
          `Added new brick ${y} to container ${C.id} at index ${i.index} in section ${k}`
        );
      }
      if (i.droppableId === "page") {
        const N = `s_${tt()}`;
        o.createEmptySection(N);
        const k = V(y);
        o.addBrick(k, N, 0, null);
      }
    } else if (H === "section") {
      const R = Array.from(l), [C] = R.splice(g.index, 1);
      R.splice(i.index, 0, C), o.reorderSections(R.map((N) => N.id));
    } else if (H === "brick") {
      const R = g.droppableId, C = i.droppableId;
      if (l.find((k) => k.id === i.droppableId))
        R === C ? (console.log(
          `Moving brick ${y} within section from ${g.index} to ${i.index}`
        ), o.reorderBrickWithin(y, i.index)) : (console.log(
          `Moving brick ${y} from section ${R} to ${C}`
        ), o.moveBrickToSection(y, C, i.index));
      else {
        const k = o.getBrick(i.droppableId);
        if (k && W[k.type] && W[k.type].isContainer) {
          const ie = (ae = r.brickMap.get(k.id)) == null ? void 0 : ae.sectionId;
          if (!ie) {
            console.warn(`No section found for container ${k.id}`);
            return;
          }
          if (y === k.id) {
            console.warn("Cannot move a container into itself");
            return;
          }
          console.log(
            `Moving brick ${y} to container ${k.id} at index ${i.index} in section ${ie}`
          ), o.moveBrickToContainerBrick(y, k.id, i.index);
        }
      }
      p === "desktop" && Ae(() => {
        o.adjustMobileLayout();
      });
    }
  };
  return a ? /* @__PURE__ */ d(
    et,
    {
      onDragEnd: _,
      onDragStart: $,
      onBeforeCapture: K,
      children: /* @__PURE__ */ I(
        "div",
        {
          id: "editor",
          className: P(
            "grid relative transition-all mx-auto w-full",
            Ft(u, s),
            "min-h-[100dvh] max-h-[100dvh]",
            u.isReady === !1 && j({
              background: `linear-gradient(120deg,
              oklab(from #9291e7 l a b / 0.65),
              oklab(from #7270c6 l a b / 0.65),
              oklab(from #c050c2 l a b / 0.65),
              oklab(from #ef50a2 l a b / 0.65),
              oklab(from #ff6285 l a b / 0.65),
              oklab(from #ff806b l a b / 0.65),
              oklab(from #ffa25a l a b / 0.65),
              oklab(from #ffc358 l a b / 0.65)
          )`
            }),
            u.isReady === !1 && "transition-all duration-500 ease-in-out"
          ),
          ...e,
          ref: t,
          children: [
            l.length > 0 && u.isReady && /* @__PURE__ */ d(z, { children: /* @__PURE__ */ d(Kt, {}) }),
            /* @__PURE__ */ d(z, { children: /* @__PURE__ */ d(_t, {}) }),
            s && /* @__PURE__ */ d(z, { children: /* @__PURE__ */ d(zt, {}) }),
            /* @__PURE__ */ d(z, { children: /* @__PURE__ */ d(Wt, {}) }),
            /* @__PURE__ */ I(
              "main",
              {
                className: P(
                  "flex-1 flex place-content-center z-40 overflow-x-auto overscroll-none ",
                  u.isReady === !1 && "!hidden",
                  j({
                    gridArea: "main",
                    scrollbarColor: "var(--violet-4) var(--violet-2)",
                    scrollBehavior: "smooth",
                    scrollbarGutter: "stable",
                    scrollbarWidth: c === "left" ? "thin" : "none",
                    "&:hover": {
                      scrollbarColor: "var(--violet-7) var(--violet-3)"
                    }
                  })
                ),
                children: [
                  u.isReady && /* @__PURE__ */ d(z, { children: /* @__PURE__ */ I(G, { children: [
                    /* @__PURE__ */ d(jt, {}),
                    r.previewTheme && /* @__PURE__ */ d(Vt, {})
                  ] }) }),
                  !u.isReady && (f.length > 0 ? /* @__PURE__ */ d(G, { children: /* @__PURE__ */ d(Tt, { themes: f }) }) : /* @__PURE__ */ d(G, { children: /* @__PURE__ */ d(Ht, {}) })),
                  /* @__PURE__ */ d(
                    Oe,
                    {
                      toastOptions: {
                        position: "bottom-center",
                        style: {
                          background: "rgba(0, 0, 0, 0.85)",
                          color: "white",
                          fontSize: "0.85rem",
                          fontWeight: "500"
                          // marginBottom: "1rem",
                        },
                        className: P("last:mb-1 px-1 py-1 rounded-lg"),
                        error: {
                          style: {
                            background: "#880808"
                          }
                        }
                      }
                    }
                  ),
                  w && /* @__PURE__ */ I(
                    "div",
                    {
                      className: "fixed flex max-w-[548px] items-center divide-x divide-gray-300 bottom-0 right-6 p-2 text-xs text-gray-500 bg-gray-100 dark:bg-dark-800 z-[19999] rounded-t-md",
                      style: {
                        // Shadow to the top left corner
                        boxShadow: "0 -2px 4px rgba(0, 0, 0, 0.1), -2px 0 4px rgba(0, 0, 0, 0.1)"
                      },
                      children: [
                        /* @__PURE__ */ I("div", { className: "px-2", children: [
                          "Selected brick: ",
                          B ?? "none"
                        ] }),
                        /* @__PURE__ */ I("div", { className: "px-2", children: [
                          "Selected section: ",
                          D ?? "none"
                        ] }),
                        /* @__PURE__ */ I("div", { className: "flex items-center gap-1 px-2", children: [
                          /* @__PURE__ */ d(we, { defaultChecked: v, onCheckedChange: h, size: "1", id: "debug-mode" }),
                          /* @__PURE__ */ I("label", { htmlFor: "debug-mode", className: "cursor-pointer select-none", children: [
                            "Debug mode",
                            " ",
                            /* @__PURE__ */ d("b", { className: P("font-semibold", v ? "text-upstart-600" : "text-gray-500"), children: v ? "on" : "off" })
                          ] })
                        ] })
                      ]
                    }
                  )
                ]
              }
            )
          ]
        }
      )
    }
  ) : /* @__PURE__ */ d("div", { className: "@container", children: /* @__PURE__ */ d(z, { children: /* @__PURE__ */ d(
    Ot,
    {
      page: {
        ...r,
        tags: []
      }
    }
  ) }) });
}
function Ft(e, t) {
  return j({
    gridTemplateAreas: t ? '"navbar navbar" "chat main"' : '"navbar" "main"',
    gridTemplateRows: "64px 1fr",
    gridTemplateColumns: e.isReady === !1 ? "1fr 0px" : t ? "360px 1fr" : "1fr"
    // maxWidth: generationState.isReady === false ? "clamp(500px, 40dvw, 650px)" : "none",
  });
}
function Vt() {
  const { validatePreviewTheme: e } = te();
  return /* @__PURE__ */ d("div", { className: "sticky bottom-4 left-0 right-0 flex justify-center items-center z-[9999]", children: /* @__PURE__ */ I("div", { className: "p-3 bg-black/70 backdrop-blur-md rounded-lg max-w-fit flex gap-2 shadow-xl", children: [
    /* @__PURE__ */ d(J, { variant: "solid", color: "gray", onClick: () => e(!1), children: "Revert" }),
    /* @__PURE__ */ d(J, { onClick: () => e(!0), variant: "solid", children: "Accept theme" })
  ] }) });
}
export {
  ir as E,
  we as i,
  J as o,
  ct as u
};
//# sourceMappingURL=Editor.3nV7m5_p.js.map
