import { Breakpoint as fe } from "../types/responsive.js";
import { PseudoClass as te, SizeType as g, BackgroundType as ee, DisplayType as oe } from "../types/style.js";
import { createStyle as ue } from "./index.js";
import { d as ce } from "../../../../_virtual/index2.js";
import de from "../../../../_virtual/cjs.js";
import { l as v } from "../../../../_virtual/lodash.js";
import { isUnitValue as me } from "./guard.js";
const le = (n, e) => {
  const o = ue(), c = o.register(e);
  return o.get().replaceAll(c, n);
}, Be = ({
  content: n,
  themeSettings: e,
  breakpoints: o,
  config: c
}) => Object.keys(n).length === 0 ? "" : Object.keys(n).filter((r) => r !== "root").reduce((r, t) => {
  var d;
  const i = n[t];
  if (!i) return r;
  const f = c[i.type];
  if (!f) return r;
  const u = {};
  if (f.style && Object.assign(
    u,
    f.style({
      blockId: i.id,
      settings: i.settings,
      themeSettings: e,
      breakpoints: o
    })
  ), !v.isEmpty(i.advancedSettings)) {
    const m = $e({
      settings: i.advancedSettings,
      breakpoints: o
    }), l = de(u, m);
    Object.assign(u, l);
  }
  return r += le(i.id, u), !f.disableAdvancedSettings && ((d = i.advancedSettings) != null && d.customCss) && (r += i.advancedSettings.customCss.replaceAll("selector", `.${i.id}`)), r;
}, "");
function ne(n, e) {
  const o = {};
  return n.forEach((c) => {
    const r = e(c.key);
    if (c.key === fe.DESKTOP)
      Object.assign(o, r);
    else {
      const t = `@media (max-width: ${c.maxWidth}px)`;
      o[t] = r;
    }
  }), ce.clean(v.cloneDeep(o));
}
function re(n, e) {
  const o = {};
  return Object.values(te).forEach((r) => {
    const t = v.pickBy(n(r), v.identity);
    if (Object.keys(t).length) {
      if (r === te.DEFAULT) {
        Object.assign(o, t);
        return;
      }
      o[`&:${r}`] = t;
    }
  }), o;
}
function $e({
  settings: n,
  breakpoints: e
}) {
  var r, t;
  const o = re((i) => {
    var S, x, T, z, w, s, W, E, R, D, F, j, O, H, I, P, X, N, U, M, V, q, B, K, Q, _, p, J, Y, Z, A, C, L, k, a, b, h, G;
    const {
      top: f,
      right: u,
      bottom: d,
      left: m
    } = y((x = (S = n.border) == null ? void 0 : S.radius) == null ? void 0 : x[i]), l = (z = (T = n.border) == null ? void 0 : T.type) == null ? void 0 : z[i];
    return {
      borderTopLeftRadius: f,
      borderTopRightRadius: u,
      borderBottomRightRadius: d,
      borderBottomLeftRadius: m,
      borderStyle: l || void 0,
      borderColor: (s = (w = n.border) == null ? void 0 : w.color) == null ? void 0 : s[i],
      backgroundAttachment: (E = (W = n.background) == null ? void 0 : W.attachment) == null ? void 0 : E[i],
      backgroundColor: ((D = (R = n.background) == null ? void 0 : R.type) == null ? void 0 : D[i]) === ee.CLASSIC ? (F = n.background.color) == null ? void 0 : F[i] : void 0,
      backgroundImage: ve({
        type: (O = (j = n.background) == null ? void 0 : j.type) == null ? void 0 : O[i],
        image: (P = (I = (H = n.background) == null ? void 0 : H.image) == null ? void 0 : I[i]) == null ? void 0 : P.url,
        angle: (U = (N = (X = n.background) == null ? void 0 : X.gradient) == null ? void 0 : N.angle) == null ? void 0 : U[i],
        color1: (q = (V = (M = n.background) == null ? void 0 : M.gradient) == null ? void 0 : V.color1) == null ? void 0 : q[i],
        color2: (Q = (K = (B = n.background) == null ? void 0 : B.gradient) == null ? void 0 : K.color2) == null ? void 0 : Q[i],
        location1: (J = (p = (_ = n.background) == null ? void 0 : _.gradient) == null ? void 0 : p.location1) == null ? void 0 : J[i],
        location2: (A = (Z = (Y = n.background) == null ? void 0 : Y.gradient) == null ? void 0 : Z.location2) == null ? void 0 : A[i],
        position: (k = (L = (C = n.background) == null ? void 0 : C.gradient) == null ? void 0 : L.position) == null ? void 0 : k[i],
        gradientType: (h = (b = (a = n.background) == null ? void 0 : a.gradient) == null ? void 0 : b.type) == null ? void 0 : h[i]
      }),
      // boxShadow: generateBoxShadow(settings.boxShadow?.[pseudoClass]),
      boxShadow: xe((G = n.boxShadow) == null ? void 0 : G[i]),
      ...Se(e, n.display)
    };
  }), c = ne(e, (i) => {
    var z, w, s, W, E, R, D, F, j, O, H, I, P, X, N, U, M, V, q;
    const {
      top: f,
      right: u,
      bottom: d,
      left: m
    } = y((z = n.padding) == null ? void 0 : z[i]), {
      top: l,
      right: S,
      bottom: x,
      left: T
    } = y((w = n.margin) == null ? void 0 : w[i]);
    return {
      paddingTop: f,
      paddingRight: u,
      paddingBottom: d,
      paddingLeft: m,
      marginTop: l,
      marginRight: S,
      marginBottom: x,
      marginLeft: T,
      zIndex: (s = n.zIndex) == null ? void 0 : s[i],
      flexOrder: ((W = n.orderCustom) == null ? void 0 : W[i]) ?? ((E = n.order) == null ? void 0 : E[i]),
      alignSelf: (R = n.alignSelf) == null ? void 0 : R[i],
      flexSize: (D = n.size) == null ? void 0 : D[i],
      flexGrow: (F = n.grow) == null ? void 0 : F[i],
      flexShrink: (j = n.shrink) == null ? void 0 : j[i],
      position: (H = (O = n.position) == null ? void 0 : O.value) == null ? void 0 : H[i],
      [`${(P = (I = n.position) == null ? void 0 : I.horizontal) == null ? void 0 : P[i]}`]: $(
        (N = (X = n.position) == null ? void 0 : X.horizontalOffset) == null ? void 0 : N[i]
      ),
      [`${(M = (U = n.position) == null ? void 0 : U.vertical) == null ? void 0 : M[i]}`]: $(
        (q = (V = n.position) == null ? void 0 : V.verticalOffset) == null ? void 0 : q[i]
      ),
      ...re((B) => {
        var J, Y, Z, A, C, L, k, a, b, h, G, ie;
        const {
          top: K,
          right: Q,
          bottom: _,
          left: p
        } = y((Z = (Y = (J = n.border) == null ? void 0 : J.width) == null ? void 0 : Y[i]) == null ? void 0 : Z[B]);
        return {
          borderTopWidth: K,
          borderRightWidth: Q,
          borderBottomWidth: _,
          borderLeftWidth: p,
          backgroundPosition: (L = (C = (A = n.background) == null ? void 0 : A.position) == null ? void 0 : C[i]) == null ? void 0 : L[B],
          backgroundRepeat: (b = (a = (k = n.background) == null ? void 0 : k.repeat) == null ? void 0 : a[i]) == null ? void 0 : b[B],
          backgroundSize: (ie = (G = (h = n.background) == null ? void 0 : h.size) == null ? void 0 : G[i]) == null ? void 0 : ie[B]
        };
      })
    };
  });
  return ce.clean(
    v.cloneDeep({
      borderTransitionDuration: (r = n.border) != null && r.transitionDuration ? `${(t = n.border) == null ? void 0 : t.transitionDuration}ms` : void 0,
      ...o,
      ...c
    })
  );
}
const Se = (n, e) => ({
  ...ne(n, (o) => {
    var r, t, i, f, u, d, m, l, S, x, T, z, w, s, W, E, R, D;
    const c = (r = e == null ? void 0 : e.value) == null ? void 0 : r[o];
    return c ? [oe.FLEX, oe.INLINE_FLEX].includes(c) ? {
      display: (t = e.value) == null ? void 0 : t[o],
      flexDirection: (i = e == null ? void 0 : e.flexDirection) == null ? void 0 : i[o],
      justifyContent: (f = e == null ? void 0 : e.justifyContent) == null ? void 0 : f[o],
      alignItems: (u = e == null ? void 0 : e.alignItems) == null ? void 0 : u[o],
      flexWrap: (d = e == null ? void 0 : e.flexWrap) == null ? void 0 : d[o],
      rowGap: ((l = (m = e == null ? void 0 : e.gap) == null ? void 0 : m[o]) == null ? void 0 : l.y) !== void 0 ? `${(x = (S = e == null ? void 0 : e.gap) == null ? void 0 : S[o]) == null ? void 0 : x.y}${(z = (T = e == null ? void 0 : e.gap) == null ? void 0 : T[o]) == null ? void 0 : z.unit}` : void 0,
      columnGap: ((s = (w = e == null ? void 0 : e.gap) == null ? void 0 : w[o]) == null ? void 0 : s.x) !== void 0 ? `${(E = (W = e == null ? void 0 : e.gap) == null ? void 0 : W[o]) == null ? void 0 : E.x}${(D = (R = e == null ? void 0 : e.gap) == null ? void 0 : R[o]) == null ? void 0 : D.unit}` : void 0
    } : {
      display: c
    } : {};
  })
}), Fe = (n) => {
  const o = ((i) => {
    const f = i.match(/(?:font-family:\s*([^;}]+)[;}])/g);
    return f ? f == null ? void 0 : f.map((u) => u.replace(/font-family:|;|}/g, "").trim()).filter((u) => !u.startsWith("var")).flatMap((u) => u.split(",")) : [];
  })(n), c = [100, 200, 300, 400, 500, 600, 700, 800, 900];
  return `https://fonts.googleapis.com/css2?family=${[...new Set(o)].map((i) => {
    const f = `${i}:ital,wght`, u = c.map((m) => `0,${m}`).join(";"), d = c.map((m) => `1,${m}`).join(";");
    return `${f}@${u};${d}`;
  }).join("&family=")}&display=swap`;
};
function je(n) {
  switch (n) {
    case g.SM:
      return {
        fontSize: "0.875rem",
        lineHeight: "1.25rem"
      };
    case g.MD:
      return {
        fontSize: "1.2rem",
        lineHeight: "1.5rem"
      };
    case g.LG:
      return {
        fontSize: "1.875rem",
        lineHeight: "2.25rem"
      };
    case g.XL:
      return {
        fontSize: "2.25rem",
        lineHeight: "2.5rem"
      };
    case g.XXL:
      return {
        fontSize: "3rem",
        lineHeight: "1"
      };
    default:
      return {
        fontSize: "1.5rem",
        lineHeight: "2rem"
      };
  }
}
function y(n) {
  if (!n) return {};
  const { top: e, bottom: o, right: c, left: r, unit: t } = n;
  return t ? {
    top: $({ value: e, unit: t }),
    right: $({ value: c, unit: t }),
    bottom: $({ value: o, unit: t }),
    left: $({ value: r, unit: t })
  } : {};
}
function ve({
  type: n,
  image: e,
  angle: o,
  color1: c,
  color2: r,
  location1: t,
  location2: i,
  position: f,
  gradientType: u
}) {
  if (n === ee.CLASSIC && e)
    return `url('${e}')`;
  if (n === ee.GRADIENT) {
    const d = `${o == null ? void 0 : o.value}${o == null ? void 0 : o.unit}`, m = c ? `${c} ${t == null ? void 0 : t.value}${t == null ? void 0 : t.unit}` : "", l = r ? `, ${r} ${i == null ? void 0 : i.value}${i == null ? void 0 : i.unit}` : "", S = `${f}`;
    return u === "linear" ? `linear-gradient(${d}, ${m}${l})` : `radial-gradient(at ${S}, ${m}${l})`;
  }
}
function Oe({
  type: n,
  angle: e,
  color1: o,
  color2: c,
  location1: r,
  location2: t,
  position: i,
  gradientType: f
}) {
  if (n === ee.GRADIENT) {
    const u = `${e == null ? void 0 : e.value}${e == null ? void 0 : e.unit}`, d = o ? `${o} ${r == null ? void 0 : r.value}${r == null ? void 0 : r.unit}` : "", m = c ? `, ${c} ${t == null ? void 0 : t.value}${t == null ? void 0 : t.unit}` : "", l = `${i}`;
    return f === "linear" ? `linear-gradient(${u}, ${d}${m})` : `radial-gradient(at ${l}, ${d}${m})`;
  }
  return "none";
}
function $(n) {
  if (n && n.value !== void 0 && me(n))
    return `${n.value}${n.unit}`;
}
function He(n) {
  if (n)
    return {
      borderTopWidth: $({ value: n.top, unit: n.unit }),
      borderRightWidth: $({
        value: n.right,
        unit: n.unit
      }),
      borderBottomWidth: $({
        value: n.bottom,
        unit: n.unit
      }),
      borderLeftWidth: $({ value: n.left, unit: n.unit })
    };
}
function Ie(n) {
  if (n)
    return {
      borderTopLeftRadius: $({
        value: n.top,
        unit: n.unit
      }),
      borderTopRightRadius: $({
        value: n.right,
        unit: n.unit
      }),
      borderBottomRightRadius: $({
        value: n.bottom,
        unit: n.unit
      }),
      borderBottomLeftRadius: $({
        value: n.left,
        unit: n.unit
      })
    };
}
function xe(n) {
  if (!n) return;
  const { color: e, blur: o, spread: c, horizontal: r, vertical: t, position: i } = n, f = [];
  if (r !== void 0 || t !== void 0) {
    const u = r !== void 0 ? `${r}px` : "0", d = t !== void 0 ? `${t}px` : "0";
    f.push(`${u} ${d}`);
  }
  return o !== void 0 && f.push(`${o}px`), c !== void 0 && f.push(`${c}px`), e !== void 0 && f.push(e), i !== void 0 && f.push(i), f.join(" ");
}
function Pe(n) {
  if (!n) return;
  const { color: e, blur: o, horizontal: c, vertical: r } = n, t = [];
  if (c !== void 0 || r !== void 0) {
    const i = c !== void 0 ? `${c}px` : "0", f = r !== void 0 ? `${r}px` : "0";
    t.push(`${i} ${f}`);
  }
  return o !== void 0 && t.push(`${o}px`), e !== void 0 && t.push(e), t.join(" ");
}
function Xe(n, e) {
  return {
    ...ne(n, (o) => Te(o, e))
  };
}
function Te(n, e) {
  var l, S, x, T, z, w, s, W, E, R, D, F, j, O, H, I, P, X, N, U, M, V, q, B, K, Q, _;
  const o = ((l = e == null ? void 0 : e.fontSize) == null ? void 0 : l[n]) ?? ((S = e == null ? void 0 : e.fontSize) == null ? void 0 : S.tablet) ?? ((x = e == null ? void 0 : e.fontSize) == null ? void 0 : x.desktop), c = ((T = e == null ? void 0 : e.lineHeight) == null ? void 0 : T[n]) ?? ((z = e == null ? void 0 : e.lineHeight) == null ? void 0 : z.tablet) ?? ((w = e == null ? void 0 : e.lineHeight) == null ? void 0 : w.desktop), r = ((s = e == null ? void 0 : e.letterSpacing) == null ? void 0 : s[n]) ?? ((W = e == null ? void 0 : e.letterSpacing) == null ? void 0 : W.tablet) ?? ((E = e == null ? void 0 : e.letterSpacing) == null ? void 0 : E.desktop), t = ((R = e == null ? void 0 : e.wordSpacing) == null ? void 0 : R[n]) ?? ((D = e == null ? void 0 : e.wordSpacing) == null ? void 0 : D.tablet) ?? ((F = e == null ? void 0 : e.wordSpacing) == null ? void 0 : F.desktop), i = ((j = e == null ? void 0 : e.fontFamily) == null ? void 0 : j[n]) ?? ((O = e == null ? void 0 : e.fontFamily) == null ? void 0 : O.tablet) ?? ((H = e == null ? void 0 : e.fontFamily) == null ? void 0 : H.desktop), f = ((I = e == null ? void 0 : e.fontWeight) == null ? void 0 : I[n]) ?? ((P = e == null ? void 0 : e.fontWeight) == null ? void 0 : P.tablet) ?? ((X = e == null ? void 0 : e.fontWeight) == null ? void 0 : X.desktop), u = ((N = e == null ? void 0 : e.textTransform) == null ? void 0 : N[n]) ?? ((U = e == null ? void 0 : e.textTransform) == null ? void 0 : U.tablet) ?? ((M = e == null ? void 0 : e.textTransform) == null ? void 0 : M.desktop), d = ((V = e == null ? void 0 : e.fontStyle) == null ? void 0 : V[n]) ?? ((q = e == null ? void 0 : e.fontStyle) == null ? void 0 : q.tablet) ?? ((B = e == null ? void 0 : e.fontStyle) == null ? void 0 : B.desktop), m = ((K = e == null ? void 0 : e.textDecoration) == null ? void 0 : K[n]) ?? ((Q = e == null ? void 0 : e.textDecoration) == null ? void 0 : Q.tablet) ?? ((_ = e == null ? void 0 : e.textDecoration) == null ? void 0 : _.desktop);
  return {
    fontFamily: i,
    fontWeight: f,
    textTransform: u,
    fontStyle: d,
    textDecoration: m,
    fontSize: $(o),
    lineHeight: $(c),
    letterSpacing: $(r),
    wordSpacing: $(t)
  };
}
function Ne(n, e, o) {
  const c = {};
  if (v.isEmpty(e))
    return c;
  const r = ne(o, (t) => {
    var i, f, u, d, m, l, S, x, T;
    return {
      fontFamily: v.isEmpty((i = e.fontFamily) == null ? void 0 : i[t]) ? void 0 : `var(--${n}-${t}-font-family)`,
      fontWeight: v.isEmpty((f = e.fontWeight) == null ? void 0 : f[t]) ? void 0 : `var(--${n}-${t}-font-weight)`,
      fontSize: v.isEmpty((u = e.fontSize) == null ? void 0 : u[t]) ? void 0 : `var(--${n}-${t}-font-size)`,
      textTransform: v.isEmpty((d = e.textTransform) == null ? void 0 : d[t]) ? void 0 : `var(--${n}-${t}-text-transform)`,
      fontStyle: v.isEmpty((m = e.fontStyle) == null ? void 0 : m[t]) ? void 0 : `var(--${n}-${t}-font-style)`,
      textDecoration: v.isEmpty((l = e.textDecoration) == null ? void 0 : l[t]) ? void 0 : `var(--${n}-${t}-text-decoration)`,
      lineHeight: v.isEmpty((S = e.lineHeight) == null ? void 0 : S[t]) ? void 0 : `var(--${n}-${t}-line-height)`,
      letterSpacing: v.isEmpty((x = e.letterSpacing) == null ? void 0 : x[t]) ? void 0 : `var(--${n}-${t}-letter-spacing)`,
      wordSpacing: v.isEmpty((T = e.wordSpacing) == null ? void 0 : T[t]) ? void 0 : `var(--${n}-${t}-word-spacing)`
    };
  });
  return Object.assign(c, r), c;
}
export {
  $e as generateAdvancedStyle,
  Oe as generateBgGradient,
  ve as generateBgImageWithGradient,
  le as generateBlockStyle,
  Ie as generateBorderRadius,
  He as generateBorderWidth,
  xe as generateBoxShadow,
  Be as generateContentStyles,
  Se as generateDisplayStyle,
  je as generateFontSize,
  Fe as generateFontsUrl,
  re as generatePseudoStyle,
  ne as generateResponsiveStyle,
  y as generateSpacingValue,
  Pe as generateTextShadow,
  Xe as generateTypography,
  Te as generateTypographyFromBreakpoint,
  Ne as generateTypographyStyles,
  $ as generateUnitValue
};
//# sourceMappingURL=style.js.map
