/**
 * Free field-type registrations (Phase 7 edition split).
 *
 * Importing this module registers the 21 Free types — descriptors moved from
 * constants/fields.js, behavior flags moved from the hard-coded type lists in
 * FieldEditorDrawer / FormCanvas / FormPreviewSurface, icons moved from
 * fields/icons.js. Free-type drawer markup stays inline in FieldEditorDrawer
 * (it is Free code); only the flags and palette data live here.
 *
 * Pro types are registered by src/admin-pro/fields/index.js, which only the
 * Pro entrypoint imports.
 */
import { registerFieldTypes } from "@/admin/fields/type-registry";
import { __ } from "@/utils/i18n";

import ICON_TEXT from "../../../assets/icons/input-check.svg";
import ICON_EMAIL from "../../../assets/icons/mail.svg";
import ICON_TEL from "../../../assets/icons/device-mobile-rotated.svg";
import ICON_TEXTAREA from "../../../assets/icons/text-resize.svg";
import ICON_SELECT from "../../../assets/icons/selector.svg";
import ICON_RADIO from "../../../assets/icons/gradienter.svg";
import ICON_CHECKBOX from "../../../assets/icons/checkbox.svg";
import ICON_PASSWORD from "../../../assets/icons/password.svg";
import ICON_FILE from "../../../assets/icons/upload.svg";
import ICON_DATE from "../../../assets/icons/calendar.svg";
import ICON_COUNTRY from "../../../assets/icons/flag-code.svg";
import ICON_STATE from "../../../assets/icons/building-stadium.svg";
import ICON_CUSTOM_TEXT from "../../../assets/icons/align-justified.svg";
import ICON_BUTTON from "../../../assets/icons/devices-share.svg";
import ICON_HIDDEN from "../../../assets/icons/eye-closed.svg";
import ICON_URL from "../../../assets/icons/link.svg";
import ICON_DATETIME from "../../../assets/icons/calendar-clock.svg";
import ICON_NUMBER from "../../../assets/icons/hash.svg";
import ICON_RANGE from "../../../assets/icons/adjustments-horizontal.svg";
import ICON_COLOR from "../../../assets/icons/color-picker.svg";

registerFieldTypes([
    {
        type: "text",
        label: __("Text Field", "formatrica"),
        description: __("Single line input", "formatrica"),
        icon: ICON_TEXT,
        default: {
            placeholder: __("Enter text…", "formatrica"),
        },
    },
    {
        type: "email",
        label: __("Email Field", "formatrica"),
        description: __("Email address input", "formatrica"),
        icon: ICON_EMAIL,
        default: {
            placeholder: __("you@example.com", "formatrica"),
        },
    },
    {
        type: "tel",
        label: __("Telephone", "formatrica"),
        description: __("Phone number input", "formatrica"),
        icon: ICON_TEL,
        default: {
            placeholder: __("+1 (555) 123-4567", "formatrica"),
        },
    },
    {
        type: "textarea",
        label: __("Textarea", "formatrica"),
        description: __("Multiline text area", "formatrica"),
        icon: ICON_TEXTAREA,
        default: {
            placeholder: __("Type your message…", "formatrica"),
        },
    },
    {
        type: "select",
        label: __("Select", "formatrica"),
        description: __("Dropdown options", "formatrica"),
        icon: ICON_SELECT,
        supportsOptions: true,
        default: {
            options: [
                __("Option 1", "formatrica"),
                __("Option 2", "formatrica"),
            ],
            multiple: false,
        },
    },
    {
        type: "radio",
        label: __("Radio Group", "formatrica"),
        description: __("Single choice options", "formatrica"),
        icon: ICON_RADIO,
        supportsOptions: true,
        supportsPlaceholder: false,
        default: {
            options: [
                __("Choice 1", "formatrica"),
                __("Choice 2", "formatrica"),
            ],
            required: true,
        },
    },
    {
        type: "checkbox",
        label: __("Checkbox", "formatrica"),
        description: __("Agreement toggle", "formatrica"),
        icon: ICON_CHECKBOX,
        supportsPlaceholder: false,
        default: {
            label: __("I agree", "formatrica"),
            required: true,
        },
    },
    {
        type: "password",
        label: __("Password", "formatrica"),
        description: __("Hidden characters input", "formatrica"),
        icon: ICON_PASSWORD,
        default: {
            placeholder: __("Enter password…", "formatrica"),
            required: true,
        },
    },
    {
        type: "file",
        label: __("File Upload", "formatrica"),
        description: __("Upload field", "formatrica"),
        icon: ICON_FILE,
        supportsPlaceholder: false,
        supportsAccept: true,
        logicPeer: false,
        default: {
            label: __("Upload file", "formatrica"),
            required: false,
            accept:
                "image/jpeg,image/png,image/gif,image/webp,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,text/plain",
            maxFileSize: 5,
        },
    },
    {
        type: "date",
        label: __("Date Picker", "formatrica"),
        description: __("Pick a date", "formatrica"),
        icon: ICON_DATE,
        supportsPlaceholder: false,
        default: {
            label: __("Select a date", "formatrica"),
            required: false,
        },
    },
    {
        type: "url",
        label: __("URL", "formatrica"),
        description: __("Web address input", "formatrica"),
        icon: ICON_URL,
        default: {
            placeholder: __("https://example.com", "formatrica"),
        },
    },
    {
        type: "number",
        label: __("Number", "formatrica"),
        description: __("Numeric input", "formatrica"),
        icon: ICON_NUMBER,
        default: {
            placeholder: __("0", "formatrica"),
            min: "",
            max: "",
            step: "",
        },
    },
    {
        type: "range",
        label: __("Range Slider", "formatrica"),
        description: __("Slider between a min and max", "formatrica"),
        icon: ICON_RANGE,
        supportsPlaceholder: false,
        default: {
            label: __("Range", "formatrica"),
            required: false,
            min: 0,
            max: 100,
            step: 1,
        },
    },
    {
        type: "datetime",
        label: __("Date & Time", "formatrica"),
        description: __("Pick a date and time", "formatrica"),
        icon: ICON_DATETIME,
        supportsPlaceholder: false,
        default: {
            label: __("Select date & time", "formatrica"),
            required: false,
        },
    },
    {
        type: "color",
        label: __("Color", "formatrica"),
        description: __("Color picker", "formatrica"),
        icon: ICON_COLOR,
        supportsPlaceholder: false,
        default: {
            label: __("Choose a color", "formatrica"),
            required: false,
        },
    },
    {
        type: "country",
        label: __("Country", "formatrica"),
        description: __("Country selector", "formatrica"),
        icon: ICON_COUNTRY,
        default: {
            label: __("Country", "formatrica"),
            required: false,
            placeholder: __("Select a country", "formatrica"),
            woocommerce_mode: "all",
        },
    },
    {
        type: "state",
        label: __("State/Province", "formatrica"),
        description: __("State or province selector", "formatrica"),
        icon: ICON_STATE,
        default: {
            label: __("State/Province", "formatrica"),
            required: false,
            placeholder: __("Select a state", "formatrica"),
            country_field: "",
            allow_text_input: true,
        },
    },
    {
        type: "hidden",
        label: __("Hidden Field", "formatrica"),
        description: __("Store an internal value", "formatrica"),
        icon: ICON_HIDDEN,
        grid: false,
        logicPeer: false,
        supportsRequired: false,
        supportsPlaceholder: false,
        default: {
            label: __("Hidden Field", "formatrica"),
            required: false,
            value: "",
        },
    },
    {
        type: "custom_text",
        label: __("Custom Text", "formatrica"),
        description: __("Static content block", "formatrica"),
        icon: ICON_CUSTOM_TEXT,
        static: true,
        supportsRequired: false,
        supportsPlaceholder: false,
        grid: false,
        logicPeer: false,
        default: {
            label: __("Custom text", "formatrica"),
            required: false,
            content: __("Add your custom text...", "formatrica"),
        },
    },
    {
        type: "button",
        label: __("Submit Button", "formatrica"),
        description: __("Call to action", "formatrica"),
        icon: ICON_BUTTON,
        static: true,
        supportsRequired: false,
        supportsPlaceholder: false,
        grid: false,
        logicPeer: false,
        default: {
            label: __("Send Message", "formatrica"),
            required: false,
        },
    },
]);
