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, Prop, Watch, Event, Method, State } from '@stencil/core';
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer, methodPlaceholder, } from 'vega-slimmer/core';
import { VegaInternalIconManager } from '../../helpers/icon/internal-icon-manager';
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
import { sanitizeVegaComponent } from '../../utils/component';
import { VegaSignatureCaptureRenderer } from './slimmers/renderers/vega-signature-capture-renderer';
import { WrittenModeRenderer } from './slimmers/written-mode/renderers/written-mode-renderer';
import { WrittenModeSvgController } from './slimmers/written-mode/controllers/written-mode-svg-controller';
import { createEventEmitSlimmer, } from '../../helpers/event-manager/slimmers/event-emit-slimmer';
import { VegaChange } from '../../helpers/event-manager/event-id/vega-event-id';
import { FormFieldControllerSlimmer } from '../../helpers/slimmers/form-field-controller-slimmer';
import { RequiredFieldRule } from '../../helpers/validator/rules/required-field-rule';
import { PageResizeObserverSlimmer } from '../../helpers/slimmers/page-resize-observer-slimmer';
import { getCurrentBreakpoint } from '../../utils/breakpoints';
import { TranslationSlimmer } from '../../helpers/slimmers/translation';
/**
 * @vegaVersion 2.19.0
 */
export class VegaSignatureCapture {
  constructor() {
    this.globalSlimmers = {};
    this.translationSlimmer = new TranslationSlimmer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.vegaSignatureCaptureRenderer = new VegaSignatureCaptureRenderer();
    this.writtenModeRenderer = new WrittenModeRenderer();
    this.writtenModeSvgController = new WrittenModeSvgController();
    this.changeEventEmitter = createEventEmitSlimmer(VegaSignatureCapture, VegaChange);
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: null,
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.writtenModeRenderer.getSignatureCaptureContainer(),
      touchableAreaGetter: () => [this.writtenModeRenderer.getSignatureCaptureContainer()],
    });
    this.pageResizeSlimmer = new PageResizeObserverSlimmer();
    this.currentBreakpoint = getCurrentBreakpoint();
    /**
     * Specifies the state of the signature
     */
    this.isDrawing = false;
    /**
     * Specifies the mode of the signature capture
     *
     * @vegaVersion 2.19.0
     */
    this.mode = 'written';
    /**
     * Specifies the label or title for the signature capture.
     *
     * It provides descriptive text that helps identify the
     *    purpose or content expected in the signature capture.
     *
     * @vegaVersion 2.19.0
     */
    this.label = '';
    /**
     * Determines whether the signature capture field is required.
     *
     * @vegaVersion 2.19.0
     */
    this.required = false;
    /**
     * Determines whether the clear button is displayed.
     *
     * @vegaVersion 2.19.0
     */
    this.showClearBtn = true;
    /**
     * Specifies a placeholder string that displays as a temporary hint
     *    or example inside the signature capture.
     *
     * It indicates the expected format or pattern of the signature capture.
     *
     * @vegaVersion 2.19.0
     */
    this.placeholder = 'Please sign here';
    /**
     * Specifies an icon or symbol that appears before the placeholder,
     *    providing visual context or enhancing the aesthetic appearance
     *    of the signature capture.
     *
     * @vegaVersion 2.19.0
     * @defaultValue v-internal-icon signature
     */
    this.placeholderIcon = VegaInternalIconManager.getIconKey('signature');
    /**
     * Specifies whether the signature capture is disabled.
     *
     * @vegaVersion 2.19.0
     */
    this.disabled = false;
    /**
     * Specifies the value of the signature capture
     *
     * @vegaVersion 2.19.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = null;
    /**
     * Indicates whether the current value in the field is considered valid or
     *    invalid based on the defined validation rules.
     *
     * @vegaVersion 2.19.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Determines whether the signature capture field should undergo automatic validation
     *    during the user's sign.
     *
     * @vegaVersion 2.19.0
     */
    this.autoValidation = true;
    /**
     * Defines custom validation rules for the signature capture field.
     *
     * @vegaVersion 2.19.0
     */
    this.validationRules = [];
    /**
     * Defines the height of the signature capture field.
     *
     * @vegaVersion 2.20.0
     */
    this.height = '320px';
  }
  watchValue(newValue, oldValue) {
    methodPlaceholder(newValue, oldValue);
  }
  watchValidationRules() {
    methodPlaceholder();
  }
  /**
   * Invoke this method to clear the signature
   *
   * @vegaVersion 2.19.0
   */
  async clear() {
    methodPlaceholder();
  }
  render() {
    return sanitizeVegaComponent(this.vegaSignatureCaptureRenderer.render(), this.host);
  }
  static get is() { return "vega-signature-capture"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["vega-signature-capture.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["vega-signature-capture.css"]
  }; }
  static get properties() { return {
    "mode": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "VegaSignatureCaptureMode",
        "resolved": "\"written\"",
        "references": {
          "VegaSignatureCaptureMode": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Specifies the mode of the signature capture"
      },
      "attribute": "mode",
      "reflect": false,
      "defaultValue": "'written'"
    },
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Specifies the label or title for the signature capture.\n\nIt provides descriptive text that helps identify the\n   purpose or content expected in the signature capture."
      },
      "attribute": "label",
      "reflect": false,
      "defaultValue": "''"
    },
    "required": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Determines whether the signature capture field is required."
      },
      "attribute": "required",
      "reflect": true,
      "defaultValue": "false"
    },
    "showClearBtn": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Determines whether the clear button is displayed."
      },
      "attribute": "show-clear-btn",
      "reflect": false,
      "defaultValue": "true"
    },
    "placeholder": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Specifies a placeholder string that displays as a temporary hint\n   or example inside the signature capture.\n\nIt indicates the expected format or pattern of the signature capture."
      },
      "attribute": "placeholder",
      "reflect": false,
      "defaultValue": "'Please sign here'"
    },
    "placeholderIcon": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }, {
            "name": "defaultValue",
            "text": "v-internal-icon signature"
          }],
        "text": "Specifies an icon or symbol that appears before the placeholder,\n   providing visual context or enhancing the aesthetic appearance\n   of the signature capture."
      },
      "attribute": "placeholder-icon",
      "reflect": false,
      "defaultValue": "VegaInternalIconManager.getIconKey('signature')"
    },
    "disabled": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Specifies whether the signature capture is disabled."
      },
      "attribute": "disabled",
      "reflect": false,
      "defaultValue": "false"
    },
    "value": {
      "type": "unknown",
      "mutable": true,
      "complexType": {
        "original": "VegaSignatureValue | null",
        "resolved": "{ type: \"written\"; img: string; }",
        "references": {
          "VegaSignatureValue": {
            "location": "import",
            "path": "./types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Specifies the value of the signature capture"
      },
      "defaultValue": "null"
    },
    "isValid": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean | null",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "Indicates whether the current value in the field is considered valid or\n   invalid based on the defined validation rules."
      },
      "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.19.0"
          }],
        "text": "Determines whether the signature capture field should undergo automatic validation\n   during the user's sign."
      },
      "attribute": "auto-validation",
      "reflect": true,
      "defaultValue": "true"
    },
    "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.19.0"
          }],
        "text": "Defines custom validation rules for the signature capture field."
      },
      "defaultValue": "[]"
    },
    "height": {
      "type": "any",
      "mutable": false,
      "complexType": {
        "original": "ResponsiveType<HeightType>",
        "resolved": "number | string | { S?: HeightType; M?: HeightType; L?: HeightType; XL?: HeightType; default?: HeightType; }",
        "references": {
          "ResponsiveType": {
            "location": "import",
            "path": "../../types/ui.type"
          },
          "HeightType": {
            "location": "import",
            "path": "../../types/ui.type"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.20.0"
          }],
        "text": "Defines the height of the signature capture field."
      },
      "attribute": "height",
      "reflect": false,
      "defaultValue": "'320px'"
    }
  }; }
  static get states() { return {
    "currentBreakpoint": {},
    "isDrawing": {}
  }; }
  static get events() { return [{
      "method": "vegaChange",
      "name": "vegaChange",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "An event emitter notifying a value change."
      },
      "complexType": {
        "original": "VegaSignatureValue",
        "resolved": "{ type: \"written\"; img: string; }",
        "references": {
          "VegaSignatureValue": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }, {
      "method": "change",
      "name": "change",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [{
            "name": "eventSemantics",
            "text": "namespace:native"
          }, {
            "name": "vegaVersion",
            "text": "2.19.0"
          }],
        "text": "An event emitter notifying a value change."
      },
      "complexType": {
        "original": "VegaSignatureValue",
        "resolved": "{ type: \"written\"; img: string; }",
        "references": {
          "VegaSignatureValue": {
            "location": "import",
            "path": "./types"
          }
        }
      }
    }]; }
  static get methods() { return {
    "clear": {
      "complexType": {
        "signature": "() => Promise<void>",
        "parameters": [],
        "references": {
          "Promise": {
            "location": "global"
          }
        },
        "return": "Promise<void>"
      },
      "docs": {
        "text": "Invoke this method to clear the signature",
        "tags": [{
            "name": "vegaVersion",
            "text": "2.19.0"
          }]
      }
    }
  }; }
  static get elementRef() { return "host"; }
  static get watchers() { return [{
      "propName": "value",
      "methodName": "watchValue"
    }, {
      "propName": "validationRules",
      "methodName": "watchValidationRules"
    }]; }
}
__decorate([
  InjectVegaGlobalSlimmer()
], VegaSignatureCapture.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "translationSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "vegaSignatureCaptureRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "writtenModeRenderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "writtenModeSvgController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSignatureCapture.prototype, "pageResizeSlimmer", void 0);
