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, Prop, h, Element, Event, Watch } from '@stencil/core';
import { sanitizeVegaComponent } from '../../../utils/component';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { VegaSelectionTileGroupRenderer } from './slimmers/renderers/vega-selection-tile-group-renderer';
import { createEventEmitSlimmer, } from '../../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaChange } from '../../../helpers/event-manager/event-id/vega-event-id';
import { ChildNodesNotifyObserverSlimmer, } from '../../../helpers/event-manager/slimmers/child-nodes-notify-observer-slimmer';
import { SELECTION_TILE_VALUE_CHANGE } from '../../../helpers/change-manager/subject/static-subject/static-subject-title';
import { VegaSelectionTileGroupValueController } from './slimmers/controllers/vega-selection-tile-group-value-controller';
import { createSubStateNotifySlimmer } from '../../../helpers/slimmers/sub-state/sub-state-notify-slimmer';
import { FormFieldControllerSlimmer } from '../../../helpers/slimmers/form-field-controller-slimmer';
import { RequiredFieldRule } from '../../../helpers/validator/rules/required-field-rule';
import { ChildNodesEventPreventSlimmer } from '../../../helpers/event-manager/slimmers/child-nodes-event-prevent-slimmer';
import { VegaSelectionTileGroupItemsController } from './slimmers/controllers/vega-selection-tile-group-items-controller';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../../helpers/slimmers/component-usage-runtime-metrics';
/**
 * @vegaVersion 2.7.0
 */
export class VegaSelectionTileGroup {
  constructor() {
    this.globalSlimmers = {};
    this.renderer = new VegaSelectionTileGroupRenderer();
    this.itemsController = new VegaSelectionTileGroupItemsController();
    this.valueController = new VegaSelectionTileGroupValueController();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      inputContainerGetter: () => this.renderer.getGroupContainerRef(),
      touchableAreaGetter: () => this.itemsController.touchableAreaGetter(),
      defaultValue: (target) => (target.selectType === 'checkbox' ? [] : ''),
      attributeGetter: (propertyName) => this[propertyName],
    });
    this.changeEventEmitter = createEventEmitSlimmer(VegaSelectionTileGroup, VegaChange);
    this.checkboxEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.renderer.getGroupContainerRef());
    this.selectionTileChangeObserver = new ChildNodesNotifyObserverSlimmer(SELECTION_TILE_VALUE_CHANGE, (payload) => this.valueController.onSelectionTileChecked(payload.detail));
    this.selectTypeNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'selectType', 'watchSelectType');
    this.disabledNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'disabled', 'watchDisabled');
    this.valueNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'value', 'watchValue');
    this.distributeEvenlyNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'distributeEvenly', 'watchDistributeEvenly');
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Specifies the label or title for the selection tile group.
     *    It provides descriptive text that helps identify
     *    the purpose of the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    this.label = '';
    /**
     * Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group
     *
     * @vegaVersion 2.58.0
     */
    this.distributeEvenly = false;
    /**
     * Determines the selection method for the tile group. Options are:
     *
     * - `radio`:
     *      Displays a radio button for selection.
     * - `checkbox`:
     *      Displays a checkbox for selection.
     *
     * @vegaVersion 2.7.0
     */
    this.selectType = 'radio';
    /**
     * Stores the selected values of the nested selection tiles
     *    within the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = this.selectType === 'checkbox' ? [] : '';
    /**
     * Controls the layout of the nested selection tiles
     *    within the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    this.layout = 'vertical';
    /**
     * Defines custom validation rules for the selection tile group field.
     *
     * @vegaVersion 2.7.0
     */
    this.validationRules = [];
    /**
     * Sets the validation status for the selection tile group.
     *
     * @vegaVersion 2.7.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
  }
  watchDistributeEvenly() {
    methodPlaceholder();
  }
  watchSelectType() {
    methodPlaceholder();
  }
  watchValue() {
    methodPlaceholder();
  }
  watchDisabled() {
    methodPlaceholder();
  }
  watchValidationRules() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  static get is() { return "vega-selection-tile-group"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-selection-tile-group.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-selection-tile-group.css"]
  }; }
  static get properties() { return {
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Specifies the label or title for the selection tile group.\n   It provides descriptive text that helps identify\n   the purpose of the selection tile group."
      },
      "attribute": "label",
      "reflect": false,
      "defaultValue": "''"
    },
    "hint": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Provides a supplementary prompt message that\n   assists users in selecting the appropriate\n   value for the selection tile group."
      },
      "attribute": "hint",
      "reflect": false
    },
    "distributeEvenly": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.58.0"
          }],
        "text": "Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group"
      },
      "attribute": "distribute-evenly",
      "reflect": false,
      "defaultValue": "false"
    },
    "selectType": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'radio' | 'checkbox'",
        "resolved": "\"checkbox\" | \"radio\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Determines the selection method for the tile group. Options are:\n\n- `radio`:\n     Displays a radio button for selection.\n- `checkbox`:\n     Displays a checkbox for selection."
      },
      "attribute": "select-type",
      "reflect": false,
      "defaultValue": "'radio'"
    },
    "value": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string | string[]",
        "resolved": "string | string[]",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Stores the selected values of the nested selection tiles\n   within the selection tile group."
      },
      "attribute": "value",
      "reflect": false,
      "defaultValue": "this.selectType === 'checkbox' ? [] : ''"
    },
    "layout": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'vertical' | 'horizontal'",
        "resolved": "\"horizontal\" | \"vertical\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Controls the layout of the nested selection tiles\n   within the selection tile group."
      },
      "attribute": "layout",
      "reflect": false,
      "defaultValue": "'vertical'"
    },
    "required": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Indicates whether at least one selection tile in the\n   selection tile group must be checked to pass\n   form validation."
      },
      "attribute": "required",
      "reflect": false
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Indicates if the selection tile group is disabled."
      },
      "attribute": "disabled",
      "reflect": false
    },
    "validationRules": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "FormFieldValidationRule<unknown>[]",
        "resolved": "FormFieldValidationRule<unknown>[]",
        "references": {
          "FormFieldValidationRule": {
            "location": "import",
            "path": "../../../helpers/validator/rules/form-field-validation-rule"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Defines custom validation rules for the selection tile group field."
      },
      "defaultValue": "[]"
    },
    "isValid": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "Sets the validation status for the selection tile group."
      },
      "attribute": "is-valid",
      "reflect": true,
      "defaultValue": "null"
    }
  }; }
  static get events() { return [{
      "method": "vegaChange",
      "name": "vegaChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.7.0"
          }],
        "text": "An event emitter notifying changes in the value of the selection tile group,\n   whether triggered programmatically or through user interaction."
      },
      "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.7.0"
          }],
        "text": "An event emitter notifying changes in the value of the selection tile group,\n   whether triggered programmatically or through user interaction."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }]; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "distributeEvenly",
      "methodName": "watchDistributeEvenly"
    }, {
      "propName": "selectType",
      "methodName": "watchSelectType"
    }, {
      "propName": "value",
      "methodName": "watchValue"
    }, {
      "propName": "disabled",
      "methodName": "watchDisabled"
    }, {
      "propName": "validationRules",
      "methodName": "watchValidationRules"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaSelectionTileGroup.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "itemsController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "valueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "checkboxEventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "selectionTileChangeObserver", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "selectTypeNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "disabledNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "valueNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "distributeEvenlyNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionTileGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
