import { a as t } from "../../../../sdk/dist/shared/chunk-CZRCW5EN.js";
import "@sinclair/typebox";
import { propToClass as E$1, propToStyle as B } from "../../../../sdk/dist/shared/themes/color-system.js";
import { css as E } from "../../../../style-system/dist/twind.js";
function getBackgroundStyles(props) {
  if (!props?.image) {
    return null;
  }
  return [
    E({
      backgroundImage: `url(${props.image})`,
      backgroundSize: props.size ?? "auto",
      backgroundRepeat: props.repeat ?? "no-repeat"
    })
  ];
}
function simplePropertyHandler(cssProp) {
  return function(value, mobileValue) {
    if (!value) {
      return null;
    }
    if (!mobileValue) {
      return E({
        [cssProp]: value
      });
    }
    return `@desktop:(${E({ [cssProp]: value })}) @mobile:(${E({ [cssProp]: mobileValue })})`;
  };
}
function getGapStyles(value, mobileValue) {
  if (!mobileValue) {
    return E({
      gap: value
    });
  }
  return `@desktop:(${E({ gap: value })}) @mobile:(${E({ gap: mobileValue })})`;
}
function getBackgroundColorStyles(value, mobileValue) {
  if (!mobileValue) {
    return E$1(value, "bg");
  }
  return `@desktop:(${E$1(value, "bg-color")}) @mobile:(${E$1(mobileValue, "bg-color")})`;
}
function getColorStyles(value, mobileValue) {
  return B(value, "color");
}
function getOpacityStyles(opacity) {
  return B(opacity, "opacity");
}
function simpleClassHandler(value, mobileValue, schema) {
  if (schema?.["ui:desktop-only"]) {
    return `@desktop:(${value})`;
  }
  if (!mobileValue) {
    return value;
  }
  if (value && mobileValue) {
    return `@desktop:(${value}) @mobile:(${mobileValue})`;
  }
  if (mobileValue) {
    return `@mobile:(${mobileValue})`;
  }
}
function simpleClassHandleObject(value, mobileValue, schema) {
  if (schema?.["ui:desktop-only"]) {
    return `@desktop:(${Object.values(value).join(" ")})`;
  }
  if (value && !mobileValue) {
    return Object.values(value);
  }
  if (value && mobileValue) {
    return `@desktop:(${Object.values(value).join(" ")}) @mobile:(${Object.values(mobileValue).join(" ")})`;
  }
  if (mobileValue) {
    return `@mobile:(${Object.values(mobileValue).join(" ")})`;
  }
}
function getFixedPositionedStyles(value) {
  if (!value) {
    return null;
  }
  return "sticky top-0 left-0 right-0 self-start w-fill z-[99999] isolate";
}
function getGrowStyles(props, mobileProps, schema) {
  if (schema?.["ui:desktop-only"]) {
    return `@desktop:(flex-grow)`;
  }
  if (props && mobileProps) {
    return `flex-grow`;
  }
  if (!mobileProps) {
    return props ? "@desktop:(flex-grow)" : null;
  }
  if (mobileProps) {
    return `@mobile:(flex-grow) @desktop:(grow-0)`;
  }
}
function getWrapStyles(value, mobileValue, schema) {
  if (schema?.["ui:desktop-only"]) {
    return `@desktop:(${value ? "flex-wrap" : "flex-nowrap"})`;
  }
  if (!mobileValue) {
    return value ? "flex-wrap" : "flex-nowrap";
  }
  if (value && mobileValue) {
    return `@desktop:(flex-wrap) @mobile:(flex-wrap)`;
  }
  if (mobileValue) {
    return `@mobile:(flex-wrap) @desktop:(flex-nowrap)`;
  }
}
function getColorPresetStyles(value, mobileValue, schema) {
  const presets = schema?.["ui:presets"] ?? t;
  if (schema?.["ui:desktop-only"]) {
    return `@desktop:(${presets[value]?.className})`;
  }
  if (!mobileValue) {
    return presets[value]?.className;
  }
  if (value && mobileValue) {
    return `@desktop:(${presets[value]?.className}) @mobile:(${presets[mobileValue]?.className})`;
  }
  if (mobileValue) {
    return `@mobile:(${presets[mobileValue]?.className})`;
  }
}
const pageStylesHelpersMap = {
  "presets:color": getColorPresetStyles,
  "styles:gradientDirection": simpleClassHandler
};
const brickStylesHelpersMap = {
  "styles:color": getColorStyles,
  "styles:textShadow": simpleClassHandler,
  "styles:opacity": getOpacityStyles,
  "styles:objectFit": simpleClassHandler,
  "styles:objectPosition": simpleClassHandler,
  "styles:heroSize": simpleClassHandler,
  "styles:fontSize": simpleClassHandler,
  "styles:wrap": getWrapStyles,
  "styles:padding": simplePropertyHandler("padding"),
  // test
  "styles:gap": getGapStyles,
  "styles:gradientDirection": simpleClassHandler,
  "styles:backgroundColor": getBackgroundColorStyles,
  "styles:background": getBackgroundStyles,
  "presets:color": getColorPresetStyles,
  "styles:borderColor": simpleClassHandler,
  "styles:rounding": simpleClassHandler,
  "styles:direction": simpleClassHandler,
  // test putting here
  "styles:alignItems": simpleClassHandler,
  "styles:justifyContent": simpleClassHandler,
  "styles:border": simpleClassHandleObject,
  // "styles:rounding": simpleClassHandler,
  "styles:shadow": simpleClassHandler
};
const brickWrapperStylesHelpersMap = {
  "styles:direction": simpleClassHandler,
  "styles:rounding": simpleClassHandler,
  "styles:justifyContent": simpleClassHandler,
  "styles:alignItems": simpleClassHandler,
  "styles:fixedPositioned": getFixedPositionedStyles,
  "styles:alignSelf": simpleClassHandler,
  "styles:grow": getGrowStyles
};
function extractStylePath(path) {
  if (!path.includes(".")) {
    return path;
  }
  return path.split(".").slice(0, -1).join(".");
}
export {
  brickStylesHelpersMap,
  brickWrapperStylesHelpersMap,
  extractStylePath,
  getBackgroundStyles,
  getGapStyles,
  pageStylesHelpersMap,
  simpleClassHandleObject,
  simpleClassHandler
};
//# sourceMappingURL=helpers.js.map
