"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeStyles = mergeStyles;
exports.createStyleMerger = createStyleMerger;
exports.conditionalStyle = conditionalStyle;
exports.responsiveValue = responsiveValue;
exports.platformStyle = platformStyle;
exports.hexToRgba = hexToRgba;
exports.debounce = debounce;
exports.throttle = throttle;
exports.forwardProps = forwardProps;
const react_native_1 = require("react-native");
/**
 * Merges React Native styles similar to how cn() merges CSS classes
 * Handles arrays, objects, and falsy values
 */
function mergeStyles(...styles) {
    const validStyles = styles.filter(Boolean).flat();
    return react_native_1.StyleSheet.flatten(validStyles) || {};
}
/**
 * Creates a style merger function that includes base styles
 * Useful for component variants
 */
function createStyleMerger(baseStyle) {
    return (...styles) => {
        return mergeStyles(baseStyle, ...styles);
    };
}
/**
 * Conditionally applies styles based on boolean conditions
 */
function conditionalStyle(condition, trueStyle, falseStyle) {
    return condition ? trueStyle : falseStyle;
}
/**
 * Creates responsive values based on screen dimensions
 */
function responsiveValue(values, screenWidth) {
    if (screenWidth >= 1280 && values.xl !== undefined)
        return values.xl;
    if (screenWidth >= 1024 && values.lg !== undefined)
        return values.lg;
    if (screenWidth >= 768 && values.md !== undefined)
        return values.md;
    if (screenWidth >= 640 && values.sm !== undefined)
        return values.sm;
    return values.default;
}
/**
 * Creates platform-specific styles
 */
function platformStyle(styles) {
    const Platform = require("react-native").Platform;
    if (Platform.OS === "ios" && styles.ios)
        return styles.ios;
    if (Platform.OS === "android" && styles.android)
        return styles.android;
    if (Platform.OS === "web" && styles.web)
        return styles.web;
    return styles.default || {};
}
/**
 * Converts hex color to rgba
 */
function hexToRgba(hex, alpha = 1) {
    const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    if (!result)
        return hex;
    const r = parseInt(result[1], 16);
    const g = parseInt(result[2], 16);
    const b = parseInt(result[3], 16);
    return `rgba(${r}, ${g}, ${b}, ${alpha})`;
}
/**
 * Creates a debounced function for performance
 */
function debounce(func, delay) {
    let timeoutId;
    return (...args) => {
        clearTimeout(timeoutId);
        timeoutId = setTimeout(() => func(...args), delay);
    };
}
/**
 * Creates a throttled function for performance
 */
function throttle(func, delay) {
    let lastCall = 0;
    return (...args) => {
        const now = Date.now();
        if (now - lastCall >= delay) {
            lastCall = now;
            func(...args);
        }
    };
}
/**
 * Type-safe component prop forwarding
 */
function forwardProps(props, omit) {
    const result = { ...props };
    omit.forEach((key) => delete result[key]);
    return result;
}
//# sourceMappingURL=utils.js.map