"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.getFieldTypeIcon = getFieldTypeIcon;
exports.toFieldType = toFieldType;
var _react = _interopRequireDefault(require("react"));
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/utils/fieldTypePrefixIcons.tsx";
/**
 * Canonical field type keys (UPPER_SNAKE_CASE).
 * The map is keyed by these values; incoming camelCase strings
 * are normalised before lookup.
 */

/**
 * Converts any casing (camelCase, snake_case, etc.) to a canonical FieldType.
 * e.g. "shortText" → "SHORT_TEXT", "dateTime" → "DATE_TIME".
 * Already UPPER_SNAKE_CASE strings pass through unchanged.
 */
function toFieldType(value) {
  return value.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();
}
/**
 * Maps canonical UPPER_SNAKE_CASE field types to icon components (small + medium).
 */
const FIELD_TYPE_ICON_MAP = {
  SHORT_TEXT: {
    small: _wixUiIconsCommon.TextSmall,
    medium: _wixUiIconsCommon.Text
  },
  LONG_TEXT: {
    small: _wixUiIconsCommon.TextSmall,
    medium: _wixUiIconsCommon.Text
  },
  NUMBER: {
    small: _wixUiIconsCommon.NumberSmall,
    medium: _wixUiIconsCommon.Number
  },
  BOOLEAN: {
    small: _wixUiIconsCommon.SquareRatioCheckedSmall,
    medium: _wixUiIconsCommon.SquareRatioChecked
  },
  DATE: {
    small: _wixUiIconsCommon.DateSmall,
    medium: _wixUiIconsCommon.Date
  },
  DATE_TIME: {
    small: _wixUiIconsCommon.DateAndTimeSmall,
    medium: _wixUiIconsCommon.DateAndTime
  },
  DATETIME: {
    small: _wixUiIconsCommon.DateAndTimeSmall,
    medium: _wixUiIconsCommon.DateAndTime
  },
  TIME: {
    small: _wixUiIconsCommon.TimeSmall,
    medium: _wixUiIconsCommon.Time
  },
  URL: {
    small: _wixUiIconsCommon.LinkSmall,
    medium: _wixUiIconsCommon.Link
  },
  EMAIL: {
    small: _wixUiIconsCommon.EmailSmall,
    medium: _wixUiIconsCommon.Email
  },
  IMAGE: {
    small: _wixUiIconsCommon.ImageSmall,
    medium: _wixUiIconsCommon.Image
  },
  MEDIA_GALLERY: {
    small: _wixUiIconsCommon.ProGalleriesSmall,
    medium: _wixUiIconsCommon.ProGalleries
  },
  AUDIO: {
    small: _wixUiIconsCommon.MusicSmall,
    medium: _wixUiIconsCommon.Music
  },
  DOCUMENT: {
    small: _wixUiIconsCommon.DocumentSmall,
    medium: _wixUiIconsCommon.Document
  },
  MULTI_DOCUMENT: {
    small: _wixUiIconsCommon.DocumentSmall,
    medium: _wixUiIconsCommon.DocDuplicate
  },
  RICH_TEXT: {
    small: _wixUiIconsCommon.RichTextSmall,
    medium: _wixUiIconsCommon.RichText
  },
  RICH_CONTENT: {
    small: _wixUiIconsCommon.ArticleSmall,
    medium: _wixUiIconsCommon.Article
  },
  REFERENCE: {
    small: _wixUiIconsCommon.ReferenceSmall,
    medium: _wixUiIconsCommon.Reference
  },
  MULTI_REFERENCE: {
    small: _wixUiIconsCommon.MultireferenceSmall,
    medium: _wixUiIconsCommon.Multireference
  },
  OBJECT: {
    small: _wixUiIconsCommon.CodeObjectSmall,
    medium: _wixUiIconsCommon.CodeObject
  },
  ARRAY: {
    small: _wixUiIconsCommon.TagSmall,
    medium: _wixUiIconsCommon.Tag
  },
  ADDRESS: {
    small: _wixUiIconsCommon.LocationSmall,
    medium: _wixUiIconsCommon.Location
  },
  INTEGER: {
    small: _wixUiIconsCommon.NumberSmall,
    medium: _wixUiIconsCommon.Number
  },
  DECIMAL: {
    small: _wixUiIconsCommon.NumberSmall,
    medium: _wixUiIconsCommon.Number
  },
  CHECKBOX: {
    small: _wixUiIconsCommon.SquareRatioCheckedSmall,
    medium: _wixUiIconsCommon.SquareRatioChecked
  },
  FILES: {
    small: _wixUiIconsCommon.DocumentSmall,
    medium: _wixUiIconsCommon.Document
  },
  MULTI_SELECT: {
    small: _wixUiIconsCommon.TagSmall,
    medium: _wixUiIconsCommon.Tag
  }
};

/**
 * Returns an icon ReactNode for the given field type string and size.
 * Accepts both UPPER_SNAKE_CASE and camelCase input.
 * If the field type is not mapped (or undefined), returns an info fallback icon.
 *
 * @param fieldType - The field type string
 * @param size - 'small' (default, for column headers / customize panel) or 'medium' (for filters)
 */
const ICON_STYLE = {
  display: 'flex',
  alignItems: 'center'
};
function getFieldTypeIcon({
  fieldType,
  size = 'small'
}) {
  const Fallback = size === 'medium' ? _wixUiIconsCommon.Database : _wixUiIconsCommon.DatabaseSmall;
  if (!fieldType) {
    return /*#__PURE__*/_react.default.createElement("span", {
      style: ICON_STYLE,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 153,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(Fallback, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 154,
        columnNumber: 9
      }
    }));
  }
  const entry = FIELD_TYPE_ICON_MAP[fieldType];
  if (!entry) {
    return /*#__PURE__*/_react.default.createElement("span", {
      style: ICON_STYLE,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 163,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(Fallback, {
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 164,
        columnNumber: 9
      }
    }));
  }
  const Icon = size === 'medium' ? entry.medium : entry.small;
  return /*#__PURE__*/_react.default.createElement("span", {
    style: ICON_STYLE,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 171,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(Icon, {
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 172,
      columnNumber: 7
    }
  }));
}
//# sourceMappingURL=fieldTypePrefixIcons.js.map