var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, Host, h, Element, Prop, Event, State, Watch } from '@stencil/core';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../../helpers/slimmers/component-usage-runtime-metrics';
import { RequiredFieldRule } from '../../../helpers/validator/rules/required-field-rule';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { sanitizeVegaComponent } from '../../../utils/component';
import { FormFieldControllerSlimmer } from '../../../helpers/slimmers/form-field-controller-slimmer';
import { ColorSwatchPickerRenderer } from './slimmers/renderers/color-swatch-picker-renderer';
import { createEventEmitSlimmer, } from '../../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaChange } from '../../../helpers/event-manager/event-id/vega-event-id';
import { ColorSwatchGridRenderer } from './slimmers/renderers/color-swatch-grid-renderer';
import { ColorSwatchInputRenderer } from './slimmers/renderers/color-swatch-input-renderer';
import { ColorSwatchPickerValueController } from './slimmers/controllers/color-swatch-picker-value-controller';
import { TranslationSlimmer } from '../../../helpers/slimmers/translation';
import { ColorSwatchPickerColorFormatController } from './slimmers/controllers/color-swatch-picker-color-format-controller';
import { ChildNodesEventPreventSlimmer } from '../../../helpers/event-manager/slimmers/child-nodes-event-prevent-slimmer';
import { PopoverNestedSlotProjectionSlimmer } from '../../../helpers/slimmers/popover-nested-slot-projection-slimmer';
/**
 * A color swatch picker component.
 *
 * @vegaVersion 2.84.0
 *
 * @slot swatch-picker-left - Custom content rendered on the left side of the picker popover. When provided, the popover switches to a two-column layout with a vertical divider.
 */
export class VegaColorSwatchPicker {
  constructor() {
    this.globalSlimmers = {};
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: '',
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.colorSwatchPickerRenderer.getContainerRef(),
      touchableAreaGetter: () => [],
    });
    this.translationSlimmer = new TranslationSlimmer();
    this.leftSlotProjection = new PopoverNestedSlotProjectionSlimmer('swatch-picker-left', () => this.colorSwatchPickerRenderer.getLeftContainerRef());
    this.colorSwatchPickerRenderer = new ColorSwatchPickerRenderer();
    this.colorSwatchGridRenderer = new ColorSwatchGridRenderer();
    this.colorSwatchInputRenderer = new ColorSwatchInputRenderer();
    this.colorSwatchPickerValueController = new ColorSwatchPickerValueController();
    this.colorSwatchPickerColorFormatController = new ColorSwatchPickerColorFormatController();
    this.childNodeEventPreventSlimmer = new ChildNodesEventPreventSlimmer([VegaChange], () => this.colorSwatchPickerRenderer.getContainerRef());
    this.changeEventEmitter = createEventEmitSlimmer(VegaColorSwatchPicker, VegaChange);
    this.internalColor = '';
    this.isPopoverOpen = false;
    /**
     * Specifies the currently selected color value.
     *
     * @vegaVersion 2.84.0
     */
    // eslint-disable-next-line @stencil/strict-mutable
    this.value = '';
    /**
     * Specifies the label or title for the color swatch picker.
     *   It provides descriptive text that helps identify the purpose
     *   or content expected in the color swatch picker.
     *
     * @vegaVersion 2.84.0
     */
    this.label = '';
    /**
     * Specifies whether the color swatch picker is disabled.
     *
     * @vegaVersion 2.84.0
     */
    this.disabled = false;
    /**
     * Specifies whether a color value must be selected for the color swatch picker to pass form validation.
     *
     * @vegaVersion 2.84.0
     */
    this.required = false;
    /**
     * Specifies the validation status of the color swatch picker.
     *
     * @vegaVersion 2.84.0
     */
    // eslint-disable-next-line @stencil/strict-mutable
    this.isValid = null;
    /**
     * Determines whether automatic validation should be implemented for the color swatch picker.
     *
     * @vegaVersion 2.84.0
     */
    // eslint-disable-next-line @stencil/strict-mutable
    this.autoValidation = true;
    /**
     * Specifies custom validation rules for the color swatch picker.
     *
     * @vegaVersion 2.84.0
     */
    this.validationRules = [];
    /**
     * Specifies the available color options for the color swatch picker.
     *
     * @vegaVersion 2.84.0
     */
    this.colors = [
      '#73E6DC',
      '#806BFF',
      '#FFDC83',
      '#FF9571',
      '#00BBFF',
      '#FF82C9',
      '#259F9F',
      '#563D82',
    ];
    /**
     * Specifies the number or configuration of columns in the color
     *   swatch picker grid layout within the popover.
     *
     * @vegaVersion 2.84.0
     */
    this.swatchGridColumns = 8;
    /**
     * Determines whether the custom color input is shown in the color swatch picker popover.
     *
     * @vegaVersion 2.84.0
     */
    this.showInput = true;
    /**
     * Specifies a placeholder string that displays as a temporary hint
     *   or example inside the color swatch picker.
     * It indicates the expected format or pattern of the picker.
     *
     * @vegaVersion 2.84.0
     */
    this.inputPlaceholder = '';
    /**
     * The icon for the custom color input in the color swatch picker popover.
     * Specifies the icon displayed in the custom color input field
     *   within the color swatch picker popover.
     *
     * @vegaVersion 2.84.0
     * @defaultValue hexColorIcon
     */
    this.inputPrefixIcon = ColorSwatchInputRenderer.DEFAULT_INPUT_ICON;
    /**
     * Determines whether the clear button is shown in the color swatch picker popover.
     *
     * @vegaVersion 2.84.0
     */
    this.showClearButton = false;
    /**
     * Specifies the formatting method for color values in the color swatch picker.
     * It can be set to a predefined format (`hexColorFormatter`) or a custom
     *   formatter function. The `hexColorFormatter` automatically adds a # prefix on output and removes it on input. A custom formatter function
     *   allows more complex formatting logic based on the processing stage (input or output).
     * Applies only when `showInput` is set to `true`.
     *
     * @vegaVersion 2.84.0
     * @defaultValue hexColorFormatter
     */
    this.inputFormatter = ColorSwatchPickerColorFormatController.DEFAULT_INPUT_FORMATTER;
  }
  watchValue() {
    methodPlaceholder();
  }
  watchDisabled() {
    this.disabled && this.colorSwatchPickerRenderer.hidePopover();
  }
  watchValidationRules() {
    methodPlaceholder();
  }
  watchInputFormatter() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(h(Host, { class: { disabled: this.disabled } },
      this.colorSwatchPickerRenderer.render(),
      h("div", { class: "vega-error vega-hidden", part: "field-error-message" })), this.host);
  }
  static get is() { return "vega-color-swatch-picker"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-color-swatch-picker.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-color-swatch-picker.css"]
  }; }
  static get properties() { return {
    "value": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies the currently selected color value."
      },
      "attribute": "value",
      "reflect": false,
      "defaultValue": "''"
    },
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies the label or title for the color swatch picker.\n  It provides descriptive text that helps identify the purpose\n  or content expected in the color swatch picker."
      },
      "attribute": "label",
      "reflect": false,
      "defaultValue": "''"
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies whether the color swatch picker is disabled."
      },
      "attribute": "disabled",
      "reflect": false,
      "defaultValue": "false"
    },
    "required": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies whether a color value must be selected for the color swatch picker to pass form validation."
      },
      "attribute": "required",
      "reflect": true,
      "defaultValue": "false"
    },
    "isValid": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean | null",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies the validation status of the color swatch picker."
      },
      "attribute": "is-valid",
      "reflect": true,
      "defaultValue": "null"
    },
    "autoValidation": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Determines whether automatic validation should be implemented for the color swatch picker."
      },
      "attribute": "auto-validation",
      "reflect": true,
      "defaultValue": "true"
    },
    "validationRules": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "FormFieldValidationRule<string>[]",
        "resolved": "FormFieldValidationRule<string>[]",
        "references": {
          "FormFieldValidationRule": {
            "location": "import",
            "path": "../../../helpers/validator/rules/form-field-validation-rule"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies custom validation rules for the color swatch picker."
      },
      "defaultValue": "[]"
    },
    "colors": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "string[]",
        "resolved": "string[]",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies the available color options for the color swatch picker."
      },
      "defaultValue": "[\n\t\t'#73E6DC',\n\t\t'#806BFF',\n\t\t'#FFDC83',\n\t\t'#FF9571',\n\t\t'#00BBFF',\n\t\t'#FF82C9',\n\t\t'#259F9F',\n\t\t'#563D82',\n\t]"
    },
    "swatchGridColumns": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "GridColumnsType",
        "resolved": "3 | 4 | 9 | 6 | 1 | 2 | 5 | 7 | 8 | 10 | 11 | 12 | \"1-auto\" | \"2-auto\" | \"3-auto\" | \"4-auto\" | \"5-auto\" | \"6-auto\" | \"7-auto\" | \"8-auto\" | \"9-auto\" | \"10-auto\" | \"11-auto\" | \"12-auto\"",
        "references": {
          "GridColumnsType": {
            "location": "import",
            "path": "../../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies the number or configuration of columns in the color\n  swatch picker grid layout within the popover."
      },
      "attribute": "swatch-grid-columns",
      "reflect": false,
      "defaultValue": "8"
    },
    "showInput": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Determines whether the custom color input is shown in the color swatch picker popover."
      },
      "attribute": "show-input",
      "reflect": false,
      "defaultValue": "true"
    },
    "inputPlaceholder": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Specifies a placeholder string that displays as a temporary hint\n  or example inside the color swatch picker.\nIt indicates the expected format or pattern of the picker."
      },
      "attribute": "input-placeholder",
      "reflect": false,
      "defaultValue": "''"
    },
    "inputPrefixIcon": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }, {
            "name": "defaultValue",
            "text": "hexColorIcon"
          }],
        "text": "The icon for the custom color input in the color swatch picker popover.\nSpecifies the icon displayed in the custom color input field\n  within the color swatch picker popover."
      },
      "attribute": "input-prefix-icon",
      "reflect": false,
      "defaultValue": "ColorSwatchInputRenderer.DEFAULT_INPUT_ICON"
    },
    "showClearButton": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "Determines whether the clear button is shown in the color swatch picker popover."
      },
      "attribute": "show-clear-button",
      "reflect": false,
      "defaultValue": "false"
    },
    "inputFormatter": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "VegaColorSwatchPickerFormatOption",
        "resolved": "\"hexColorFormatter\" | ((colorStageType: VegaColorStageType, color: string) => string)",
        "references": {
          "VegaColorSwatchPickerFormatOption": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }, {
            "name": "defaultValue",
            "text": "hexColorFormatter"
          }],
        "text": "Specifies the formatting method for color values in the color swatch picker.\nIt can be set to a predefined format (`hexColorFormatter`) or a custom\n  formatter function. The `hexColorFormatter` automatically adds a # prefix on output and removes it on input. A custom formatter function\n  allows more complex formatting logic based on the processing stage (input or output).\nApplies only when `showInput` is set to `true`."
      },
      "attribute": "input-formatter",
      "reflect": false,
      "defaultValue": "ColorSwatchPickerColorFormatController.DEFAULT_INPUT_FORMATTER"
    }
  }; }
  static get states() { return {
    "internalColor": {},
    "isPopoverOpen": {}
  }; }
  static get events() { return [{
      "method": "vegaChange",
      "name": "vegaChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "An event emitter notifying the change of the selected color value."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "change",
      "name": "change",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.84.0"
          }],
        "text": "An event emitter notifying the change of the selected color value."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }]; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "value",
      "methodName": "watchValue"
    }, {
      "propName": "disabled",
      "methodName": "watchDisabled"
    }, {
      "propName": "validationRules",
      "methodName": "watchValidationRules"
    }, {
      "propName": "inputFormatter",
      "methodName": "watchInputFormatter"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaColorSwatchPicker.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "translationSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "leftSlotProjection", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "colorSwatchPickerRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "colorSwatchGridRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "colorSwatchInputRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "colorSwatchPickerValueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "colorSwatchPickerColorFormatController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "childNodeEventPreventSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaColorSwatchPicker.prototype, "changeEventEmitter", void 0);
