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, Element, Event, Prop, State, Watch } from '@stencil/core';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
import { sanitizeVegaComponent } from '../../utils/component';
import { VegaInputPasscodeRenderer } from './slimmers/renderers/vega-input-passcode-renderer';
import { VegaInputPasscodeValueController } from './slimmers/controllers/vega-input-passcode-value-controller';
import { VegaChange, VegaComplete } from '../../helpers/event-manager/event-id/vega-event-id';
import { createEventEmitSlimmer, } from '../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaInputPasscodeKeyboardController } from './slimmers/controllers/vega-input-passcode-keyboard-controller';
import { ChildNodesEventPreventSlimmer } from '../../helpers/event-manager/slimmers/child-nodes-event-prevent-slimmer';
import { FormFieldControllerSlimmer } from '../../helpers/slimmers/form-field-controller-slimmer';
import { RequiredFieldRule } from '../../helpers/validator/rules/required-field-rule';
import { ImmutableArray } from '../../helpers/immutable/immutable-array';
/**
 * @vegaVersion 2.66.0
 */
export class VegaInputPasscode {
  constructor() {
    this.globalSlimmers = {};
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: '',
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.inputPasscodeRenderer.getInputPasscodeContainerRef(),
      touchableAreaGetter: () => [...this.inputPasscodeRenderer.getVegaInputRefs()],
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.keyboardController = new VegaInputPasscodeKeyboardController();
    this.valueController = new VegaInputPasscodeValueController();
    this.inputPasscodeRenderer = new VegaInputPasscodeRenderer();
    this.changeEventEmitter = createEventEmitSlimmer(VegaInputPasscode, VegaChange);
    this.completeEventEmitter = createEventEmitSlimmer(VegaInputPasscode, VegaComplete);
    this.eventPreventSlimmer = new ChildNodesEventPreventSlimmer([VegaChange], () => this.host, { useCapture: true });
    this.vegaInputValues = new ImmutableArray(new Array(), (newArr) => {
      this.vegaInputValues = newArr;
    });
    /**
     * Specifies the visible label text rendered above the passcode input.
     * The label identifies the purpose of the field (e.g., "Enter verification
     * code") and serves as the accessible name for screen readers.
     *
     * @default ''
     * @vegaVersion 2.66.0
     */
    this.label = '';
    /**
     * Specifies whether the passcode input is disabled. When `true`, all
     * individual input boxes become non-interactive — the user cannot type,
     * paste, or focus any box.
     *
     * @default false
     * @vegaVersion 2.66.0
     */
    this.disabled = false;
    /**
     * Controls the visual size of the passcode input boxes.
     *
     * - `'medium'` — Standard height, suitable for most form layouts.
     * - `'small'` — Compact height, useful for dense UIs.
     *
     * @default 'medium'
     * @vegaVersion 2.66.0
     */
    this.size = 'medium';
    /**
     * Supplementary helper message displayed below the passcode input that
     * assists users in understanding the expected input. For example,
     * `'Enter the 4-digit code sent to your email'`.
     *
     * @default ''
     * @vegaVersion 2.66.0
     */
    this.hint = '';
    /**
     * Specifies the number of individual input boxes rendered for the passcode.
     * Each box accepts a single character. Common values are `4` for a PIN and
     * `6` for a two-factor authentication code.
     *
     * @default 4
     * @vegaVersion 2.66.0
     */
    this.length = 4;
    /**
     * Specifies the type of characters accepted by each passcode box.
     *
     * - `'numeric'` — Only digits `0`–`9` are accepted.
     * - `'text'` — Any non-space character is accepted.
     *
     * Spaces are always rejected regardless of the selected type.
     *
     * @default 'numeric'
     * @vegaVersion 2.66.0
     */
    this.inputType = 'numeric';
    /**
     * The current value of the passcode input, represented as a concatenated
     * string of all box values (e.g., `'1234'` for a 4-digit passcode).
     *
     * This property is mutable and reflected to the host element attribute.
     * It updates as the user types into the boxes and can be set externally
     * to pre-populate or reset the field.
     *
     * @default ''
     * @vegaVersion 2.66.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = '';
    /**
     * Determines whether the passcode field must have a value before the form
     * can be submitted. When `true`, the built-in `RequiredFieldRule` is
     * applied during validation and a required indicator is shown on the label.
     *
     * @default false
     * @vegaVersion 2.66.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.required = false;
    /**
     * An array of custom validation rules applied to the passcode input in
     * addition to the built-in `RequiredFieldRule`. Each rule must implement
     * the `FormFieldValidationRule` interface.
     *
     * Rules are evaluated in order when `autoValidation` is enabled or when
     * validation is triggered programmatically.
     *
     * @default []
     * @vegaVersion 2.66.0
     */
    this.validationRules = [];
    /**
     * Determines whether the passcode input should be validated automatically
     * as the user types. When `true`, validation rules (including `required`
     * and custom `validationRules`) are evaluated and the `isValid` property
     * is updated accordingly.
     *
     * Set to `false` to handle validation manually.
     *
     * @default true
     * @vegaVersion 2.66.0
     */
    this.autoValidation = true;
    /**
     * Reflects the current validation status of the passcode input.
     *
     * - `true` — the field value passes all validation rules.
     * - `false` — one or more validation rules have failed.
     * - `null` — the field has not been validated yet (initial state).
     *
     * This property is mutable: it is updated automatically when
     * `autoValidation` is enabled, but can also be set manually to override
     * the validation state.
     *
     * @default null
     * @vegaVersion 2.66.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
  }
  watchVegaInputValues() {
    methodPlaceholder();
  }
  watchLengthAndInputType() {
    methodPlaceholder();
  }
  watchValue() {
    methodPlaceholder();
  }
  watchValidationRules() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(this.inputPasscodeRenderer.render(), this.host);
  }
  static get is() { return "vega-input-passcode"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-input-passcode.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-input-passcode.css"]
  }; }
  static get properties() { return {
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "''"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Specifies the visible label text rendered above the passcode input.\nThe label identifies the purpose of the field (e.g., \"Enter verification\ncode\") and serves as the accessible name for screen readers."
      },
      "attribute": "label",
      "reflect": false,
      "defaultValue": "''"
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "false"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Specifies whether the passcode input is disabled. When `true`, all\nindividual input boxes become non-interactive \u2014 the user cannot type,\npaste, or focus any box."
      },
      "attribute": "disabled",
      "reflect": true,
      "defaultValue": "false"
    },
    "size": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'medium' | 'small'",
        "resolved": "\"medium\" | \"small\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "'medium'"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Controls the visual size of the passcode input boxes.\n\n- `'medium'` \u2014 Standard height, suitable for most form layouts.\n- `'small'` \u2014 Compact height, useful for dense UIs."
      },
      "attribute": "size",
      "reflect": false,
      "defaultValue": "'medium'"
    },
    "hint": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "''"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Supplementary helper message displayed below the passcode input that\nassists users in understanding the expected input. For example,\n`'Enter the 4-digit code sent to your email'`."
      },
      "attribute": "hint",
      "reflect": false,
      "defaultValue": "''"
    },
    "length": {
      "type": "number",
      "mutable": false,
      "complexType": {
        "original": "number",
        "resolved": "number",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "4"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Specifies the number of individual input boxes rendered for the passcode.\nEach box accepts a single character. Common values are `4` for a PIN and\n`6` for a two-factor authentication code."
      },
      "attribute": "length",
      "reflect": false,
      "defaultValue": "4"
    },
    "inputType": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'numeric' | 'text'",
        "resolved": "\"numeric\" | \"text\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "'numeric'"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Specifies the type of characters accepted by each passcode box.\n\n- `'numeric'` \u2014 Only digits `0`\u2013`9` are accepted.\n- `'text'` \u2014 Any non-space character is accepted.\n\nSpaces are always rejected regardless of the selected type."
      },
      "attribute": "input-type",
      "reflect": false,
      "defaultValue": "'numeric'"
    },
    "value": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "''"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "The current value of the passcode input, represented as a concatenated\nstring of all box values (e.g., `'1234'` for a 4-digit passcode).\n\nThis property is mutable and reflected to the host element attribute.\nIt updates as the user types into the boxes and can be set externally\nto pre-populate or reset the field."
      },
      "attribute": "value",
      "reflect": true,
      "defaultValue": "''"
    },
    "required": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "false"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Determines whether the passcode field must have a value before the form\ncan be submitted. When `true`, the built-in `RequiredFieldRule` is\napplied during validation and a required indicator is shown on the label."
      },
      "attribute": "required",
      "reflect": true,
      "defaultValue": "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": "default",
            "text": "[]"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "An array of custom validation rules applied to the passcode input in\naddition to the built-in `RequiredFieldRule`. Each rule must implement\nthe `FormFieldValidationRule` interface.\n\nRules are evaluated in order when `autoValidation` is enabled or when\nvalidation is triggered programmatically."
      },
      "defaultValue": "[]"
    },
    "autoValidation": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "true"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Determines whether the passcode input should be validated automatically\nas the user types. When `true`, validation rules (including `required`\nand custom `validationRules`) are evaluated and the `isValid` property\nis updated accordingly.\n\nSet to `false` to handle validation manually."
      },
      "attribute": "auto-validation",
      "reflect": true,
      "defaultValue": "true"
    },
    "isValid": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean | null",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "default",
            "text": "null"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Reflects the current validation status of the passcode input.\n\n- `true` \u2014 the field value passes all validation rules.\n- `false` \u2014 one or more validation rules have failed.\n- `null` \u2014 the field has not been validated yet (initial state).\n\nThis property is mutable: it is updated automatically when\n`autoValidation` is enabled, but can also be set manually to override\nthe validation state."
      },
      "attribute": "is-valid",
      "reflect": true,
      "defaultValue": "null"
    }
  }; }
  static get states() { return {
    "vegaInputValues": {}
  }; }
  static get events() { return [{
      "method": "vegaChange",
      "name": "vegaChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventDetail",
            "text": "string"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Fires whenever the passcode value changes \u2014 each time a character is\nentered, deleted, or pasted into any box. The event detail contains the\nconcatenated string of all box values at the time of the change."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "change",
      "name": "change",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventDetail",
            "text": "string"
          }, {
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Native-equivalent mirror of `vegaChange`. Fires with the same payload\nand at the same time, allowing consumers to listen using the standard\n`change` event name."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "vegaComplete",
      "name": "vegaComplete",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventDetail",
            "text": "string"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Fires when all passcode boxes have been filled (i.e., the value length\nequals the configured `length`). The event detail contains the complete\npasscode string. Useful for triggering auto-submit or verification\nworkflows."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }, {
      "method": "complete",
      "name": "complete",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventDetail",
            "text": "string"
          }, {
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.66.0"
          }],
        "text": "Native-equivalent mirror of `vegaComplete`. Fires with the same payload\nand at the same time, allowing consumers to listen using the standard\n`complete` event name."
      },
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      }
    }]; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "vegaInputValues",
      "methodName": "watchVegaInputValues"
    }, {
      "propName": "length",
      "methodName": "watchLengthAndInputType"
    }, {
      "propName": "inputType",
      "methodName": "watchLengthAndInputType"
    }, {
      "propName": "value",
      "methodName": "watchValue"
    }, {
      "propName": "validationRules",
      "methodName": "watchValidationRules"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaInputPasscode.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "keyboardController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "valueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "inputPasscodeRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "completeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaInputPasscode.prototype, "eventPreventSlimmer", void 0);
