import { jsx } from "react/jsx-runtime";
import {
  useBoxShadow,
  useBorder as useBorderData,
  useLinkPropControllerData,
  useCheckboxPropControllerData,
  useDatePropControllerData,
  useFontPropControllerData,
  useVideoPropControllerData,
  useTablePropControllerData
} from "../../components/hooks";
import {
  useResponsiveBorder,
  useResponsiveBorderRadius,
  useResponsiveMargin,
  useResponsivePadding,
  useResponsiveShadow,
  useResponsiveWidth
} from "../../components/utils/responsive-style";
import { RenderHook } from "./components";
import { useStyle } from "./use-style";
import {
  Types as PropControllerTypes,
  getShadowsPropControllerDataResponsiveShadowsData,
  Shadows,
  BorderPropControllerFormat,
  getBorderPropControllerDataResponsiveBorderData,
  getBorderRadiusPropControllerDataResponsiveBorderRadiusData,
  BorderRadiusPropControllerFormat,
  MarginPropControllerFormat,
  getMarginPropControllerDataResponsiveMarginData,
  getPaddingPropControllerDataResponsivePaddingData,
  PaddingPropControllerFormat,
  getWidthPropControllerDataResponsiveLengthData,
  WidthPropControllerFormat,
  GapX,
  ResponsiveNumber,
  ResponsiveIconRadioGroup,
  ResponsiveSelect,
  ResponsiveOpacity,
  getSocialLinksPropControllerDataSocialLinksData
} from "@makeswift/prop-controllers";
import { useResponsiveLengthPropControllerData } from "../../components/hooks/useResponsiveLengthPropControllerData";
import { useNumberPropControllerData } from "../../components/hooks/useNumberPropControllerData";
import { useResponsiveColorPropControllerData } from "../../components/hooks/useResponsiveColorPropControllerData";
import { useTextStylePropControllerData } from "../../components/hooks/useTextStylePropControllerData";
import { useNavigationLinksPropControllerData } from "../../components/hooks/useNavigationLinksPropControllerData";
import { useTextAreaPropControllerData } from "../../components/hooks/useTextAreaPropControllerData";
import { usePropValue } from "../../components/hooks/usePropValue";
import { useGapYPropControllerData } from "../../components/hooks/useGapYPropControllerData";
import { useElementIDPropControllerData } from "../../components/hooks/useElementIDPropControllerData";
import { useTableFormFieldsPropControllerData } from "../../components/hooks/useTableFormFieldsPropControllerData";
import { useGridPropControllerData } from "../../components/hooks/useGridPropControllerData";
import { useImagePropControllerData } from "../../components/hooks/useImagePropControllerData";
import { useImagesPropControllerData } from "../../components/hooks/useImagesPropControllerData";
import { useBackgroundsPropControllerData } from "../../components/hooks/useBackgroundsPropControllerData";
import { useTextInputPropControllerData } from "../../components/hooks/useTextInputPropControllerData";
function useWidthStyle(data, descriptor) {
  const value = getWidthPropControllerDataResponsiveLengthData(data);
  return useStyle(useResponsiveWidth(value, descriptor.options.defaultValue));
}
function usePaddingStyle(data) {
  const value = getPaddingPropControllerDataResponsivePaddingData(data);
  return useStyle(useResponsivePadding(value));
}
function useMarginStyle(data) {
  const value = getMarginPropControllerDataResponsiveMarginData(data);
  return useStyle(useResponsiveMargin(value));
}
function useBorderRadiusStyle(data) {
  const value = getBorderRadiusPropControllerDataResponsiveBorderRadiusData(data);
  return useStyle(useResponsiveBorderRadius(value));
}
function useShadowsStyle(data) {
  return useStyle(useResponsiveShadow(useBoxShadow(data) ?? void 0));
}
function useBorderStyle(data) {
  const value = getBorderPropControllerDataResponsiveBorderData(data);
  const borderData = useBorderData(value);
  return useStyle(useResponsiveBorder(borderData ?? void 0));
}
function resolveLegacyDescriptorProp(descriptor, propName, propData, props, renderFn) {
  switch (descriptor.type) {
    case PropControllerTypes.Width:
      switch (descriptor.options.format) {
        case WidthPropControllerFormat.ClassName:
          return /* @__PURE__ */ jsx(
            RenderHook,
            {
              hook: useWidthStyle,
              parameters: [propData, descriptor],
              children: (value) => renderFn({ ...props, [propName]: value })
            },
            descriptor.type
          );
        case WidthPropControllerFormat.ResponsiveValue:
        default:
          return renderFn({
            ...props,
            [propName]: getWidthPropControllerDataResponsiveLengthData(propData)
          });
      }
    case PropControllerTypes.Padding:
      switch (descriptor.options.format) {
        case PaddingPropControllerFormat.ClassName:
          return /* @__PURE__ */ jsx(RenderHook, { hook: usePaddingStyle, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
        case PaddingPropControllerFormat.ResponsiveValue:
        default:
          return renderFn({
            ...props,
            [propName]: getPaddingPropControllerDataResponsivePaddingData(propData)
          });
      }
    case PropControllerTypes.Margin:
      switch (descriptor.options.format) {
        case MarginPropControllerFormat.ClassName:
          return /* @__PURE__ */ jsx(RenderHook, { hook: useMarginStyle, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
        case MarginPropControllerFormat.ResponsiveValue:
        default:
          return renderFn({
            ...props,
            [propName]: getMarginPropControllerDataResponsiveMarginData(propData)
          });
      }
    case PropControllerTypes.BorderRadius:
      switch (descriptor.options.format) {
        case BorderRadiusPropControllerFormat.ClassName:
          return /* @__PURE__ */ jsx(RenderHook, { hook: useBorderRadiusStyle, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
        case BorderRadiusPropControllerFormat.ResponsiveValue:
        default:
          return renderFn({
            ...props,
            [propName]: getBorderRadiusPropControllerDataResponsiveBorderRadiusData(propData)
          });
      }
    case PropControllerTypes.Backgrounds:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useBackgroundsPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.Image:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useImagePropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.Images:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useImagesPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.Number:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useNumberPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.ResponsiveNumber:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: (data) => usePropValue(ResponsiveNumber, data),
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.ResponsiveIconRadioGroup:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: (data) => usePropValue(ResponsiveIconRadioGroup, data),
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.ResponsiveSelect:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: (data) => usePropValue(ResponsiveSelect, data),
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.ResponsiveOpacity:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: (data) => usePropValue(ResponsiveOpacity, data),
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.ResponsiveLength:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useResponsiveLengthPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.Shadows:
      switch (descriptor.options.format) {
        case Shadows.Format.ClassName:
          return /* @__PURE__ */ jsx(RenderHook, { hook: useShadowsStyle, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
        case Shadows.Format.ResponsiveValue:
        default:
          return renderFn({
            ...props,
            [propName]: getShadowsPropControllerDataResponsiveShadowsData(propData)
          });
      }
    case PropControllerTypes.Border:
      switch (descriptor.options.format) {
        case BorderPropControllerFormat.ClassName:
          return /* @__PURE__ */ jsx(RenderHook, { hook: useBorderStyle, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
        case BorderPropControllerFormat.ResponsiveValue:
        default:
          return renderFn({
            ...props,
            [propName]: getBorderPropControllerDataResponsiveBorderData(propData)
          });
      }
    case PropControllerTypes.ResponsiveColor:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useResponsiveColorPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.Link:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useLinkPropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.Checkbox:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useCheckboxPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.Date:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useDatePropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.Font:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useFontPropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.Video:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useVideoPropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.Table:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useTablePropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.TextStyle:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useTextStylePropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.NavigationLinks:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useNavigationLinksPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.TextInput:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useTextInputPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.TextArea:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useTextAreaPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.GapX:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: (data) => usePropValue(GapX, data),
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.GapY:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useGapYPropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    case PropControllerTypes.ElementID:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useElementIDPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.TableFormFields:
      return /* @__PURE__ */ jsx(
        RenderHook,
        {
          hook: useTableFormFieldsPropControllerData,
          parameters: [propData],
          children: (value) => renderFn({ ...props, [propName]: value })
        },
        descriptor.type
      );
    case PropControllerTypes.SocialLinks:
      return renderFn({
        ...props,
        [propName]: getSocialLinksPropControllerDataSocialLinksData(propData)
      });
    case PropControllerTypes.Grid:
      return /* @__PURE__ */ jsx(RenderHook, { hook: useGridPropControllerData, parameters: [propData], children: (value) => renderFn({ ...props, [propName]: value }) }, descriptor.type);
    default:
      return renderFn({ ...props, [propName]: propData });
  }
}
export {
  resolveLegacyDescriptorProp
};
//# sourceMappingURL=legacy-controls.js.map