import * as i0 from '@angular/core';
import { input, booleanAttribute, output, inject, ElementRef, Injector, runInInjectionContext, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import '@ui5/webcomponents/dist/Input.js';
import * as i1 from '@fundamental-ngx/ui5-webcomponents/utils';
import { GenericControlValueAccessor } from '@fundamental-ngx/ui5-webcomponents/utils';

class Input {
    constructor() {
        /**
         * Defines whether the component is in disabled state.
      
      **Note:** A disabled component is completely noninteractive.
         */
        this.disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines a short hint intended to aid the user with data entry when the
      component has no value.
         */
        this.placeholder = input(...(ngDevMode ? [undefined, { debugName: "placeholder" }] : []));
        /**
         * Defines whether the component is read-only.
      
      **Note:** A read-only component is not editable,
      but still provides visual feedback upon user interaction.
         */
        this.readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the component is required.
         */
        this.required = input(false, ...(ngDevMode ? [{ debugName: "required", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the value will be autcompleted to match an item
         */
        this.noTypeahead = input(false, ...(ngDevMode ? [{ debugName: "noTypeahead", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines the HTML type of the component.
      
      **Notes:**
      
      - The particular effect of this property differs depending on the browser
      and the current language settings, especially for type `Number`.
      - The property is mostly intended to be used with touch devices
      that use different soft keyboard layouts depending on the given input type.
         */
        this.type = input("Text", ...(ngDevMode ? [{ debugName: "type" }] : []));
        /**
         * Defines the value of the component.
      
      **Note:** The property is updated upon typing.
         */
        this.value = input("", ...(ngDevMode ? [{ debugName: "value" }] : []));
        /**
         * Defines the value state of the component.
         */
        this.valueState = input("None", ...(ngDevMode ? [{ debugName: "valueState" }] : []));
        /**
         * Determines the name by which the component will be identified upon submission in an HTML form.
      
      **Note:** This property is only applicable within the context of an HTML Form element.
         */
        this.name = input(...(ngDevMode ? [undefined, { debugName: "name" }] : []));
        /**
         * Defines whether the component should show suggestions, if such are present.
         */
        this.showSuggestions = input(false, ...(ngDevMode ? [{ debugName: "showSuggestions", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Sets the maximum number of characters available in the input field.
      
      **Note:** This property is not compatible with the ui5-input type InputType.Number. If the ui5-input type is set to Number, the maxlength value is ignored.
         */
        this.maxlength = input(...(ngDevMode ? [undefined, { debugName: "maxlength" }] : []));
        /**
         * Defines the accessible ARIA name of the component.
         */
        this.accessibleName = input(...(ngDevMode ? [undefined, { debugName: "accessibleName" }] : []));
        /**
         * Receives id(or many ids) of the elements that label the input.
         */
        this.accessibleNameRef = input(...(ngDevMode ? [undefined, { debugName: "accessibleNameRef" }] : []));
        /**
         * Defines the accessible description of the component.
         */
        this.accessibleDescription = input(...(ngDevMode ? [undefined, { debugName: "accessibleDescription" }] : []));
        /**
         * Receives id(or many ids) of the elements that describe the input.
         */
        this.accessibleDescriptionRef = input(...(ngDevMode ? [undefined, { debugName: "accessibleDescriptionRef" }] : []));
        /**
         * Defines whether the clear icon of the input will be shown.
         */
        this.showClearIcon = input(false, ...(ngDevMode ? [{ debugName: "showClearIcon", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines whether the suggestions picker is open.
      The picker will not open if the `showSuggestions` property is set to `false`, the input is disabled or the input is readonly.
      The picker will close automatically and `close` event will be fired if the input is not in the viewport.
         */
        this.open = input(false, ...(ngDevMode ? [{ debugName: "open", transform: booleanAttribute }] : [{ transform: booleanAttribute }])); // className is now passed
        /**
         * Fired when the input operation has finished by pressing Enter or on focusout.
         */
        this.ui5Change = output();
        /**
         * Fired when the value of the component changes at each keystroke,
      and when a suggestion item has been selected.
         */
        this.ui5Input = output();
        /**
         * Fired when some text has been selected.
         */
        this.ui5Select = output();
        /**
         * Fired when the user navigates to a suggestion item via the ARROW keys,
      as a preview, before the final selection.
         */
        this.ui5SelectionChange = output();
        /**
         * Fired when the suggestions picker is open.
         */
        this.ui5Open = output();
        /**
         * Fired when the suggestions picker is closed.
         */
        this.ui5Close = output();
        /**
         * Available slots for content projection in this component.
         *
         * Slots allow you to insert custom content into predefined areas of the web component.
         * Use the `slot` attribute on child elements to target specific slots.
         *
         * - **(default)**: Defines the suggestion items.
      
      **Note:** The suggestions would be displayed only if the `showSuggestions`
      property is set to `true`.
      
      **Note:** The `<ui5-suggestion-item>`, `<ui5-suggestion-item-group>` and `ui5-suggestion-item-custom` are recommended to be used as suggestion items.
         * - **icon**: Defines the icon to be displayed in the component.
         * - **valueStateMessage**: Defines the value state message that will be displayed as pop up under the component.
      The value state message slot should contain only one root element.
      
      **Note:** If not specified, a default text (in the respective language) will be displayed.
      
      **Note:** The `valueStateMessage` would be displayed,
      when the component is in `Information`, `Critical` or `Negative` value state.
      
      **Note:** If the component has `suggestionItems`,
      the `valueStateMessage` would be displayed as part of the same popover, if used on desktop, or dialog - on phone.
         *
         * @example
         * ```html
         * <ui5-input>
         *   <div slot="header">Custom header content</div>
         *   <p>Default slot content</p>
         * </ui5-input>
         * ```
         *
         * @readonly
         * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots | MDN Web Components Slots}
         */
        this.slots = [
            {
                "name": "default",
                "description": "Defines the suggestion items.\n\n**Note:** The suggestions would be displayed only if the `showSuggestions`\nproperty is set to `true`.\n\n**Note:** The `<ui5-suggestion-item>`, `<ui5-suggestion-item-group>` and `ui5-suggestion-item-custom` are recommended to be used as suggestion items."
            },
            {
                "name": "icon",
                "description": "Defines the icon to be displayed in the component."
            },
            {
                "name": "valueStateMessage",
                "description": "Defines the value state message that will be displayed as pop up under the component.\nThe value state message slot should contain only one root element.\n\n**Note:** If not specified, a default text (in the respective language) will be displayed.\n\n**Note:** The `valueStateMessage` would be displayed,\nwhen the component is in `Information`, `Critical` or `Negative` value state.\n\n**Note:** If the component has `suggestionItems`,\nthe `valueStateMessage` would be displayed as part of the same popover, if used on desktop, or dialog - on phone.",
                "since": "1.0.0-rc.6"
            }
        ];
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'disabled',
            'placeholder',
            'readonly',
            'required',
            'noTypeahead',
            'type',
            'value',
            'valueState',
            'name',
            'showSuggestions',
            'maxlength',
            'accessibleName',
            'accessibleNameRef',
            'accessibleDescription',
            'accessibleDescriptionRef',
            'showClearIcon',
            'open',
        ];
        // Synchronize inputs (properties)
        for (const inputName of inputsToSync) {
            // Find the corresponding camelCase signal property on the Angular component
            const signalName = inputName.replace(/-./g, (x) => x[1].toUpperCase());
            // Use the Injector to run the effect in the correct context
            if (this[signalName] && typeof this[signalName] === 'function') {
                runInInjectionContext(this.injector, () => {
                    effect(() => {
                        // Read the signal value
                        const value = this[signalName]();
                        if (wcElement) {
                            // Write the value to the Web Component's property
                            wcElement[inputName] = value;
                        }
                    });
                });
            }
        }
        const outputsToSync = [
            'ui5Change',
            'ui5Input',
            'ui5Select',
            'ui5SelectionChange',
            'ui5Open',
            'ui5Close',
        ];
        // Synchronize outputs (events)
        for (const outputName of outputsToSync) {
            // Map Angular output name to UI5 web component event name
            const eventName = outputName.replace('ui5', '').replace(/([A-Z])/g, '-$1').toLowerCase().substring(1);
            // Ensure the output property exists and has an emit function before adding listener
            if (this[outputName] && typeof this[outputName].emit === 'function' && wcElement.addEventListener) {
                // Cast the listener to the correct type to satisfy TypeScript
                wcElement.addEventListener(eventName, (e) => {
                    this[outputName].emit(e);
                });
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: Input, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: Input, isStandalone: true, selector: "ui5-input, [ui5-input]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, noTypeahead: { classPropertyName: "noTypeahead", publicName: "noTypeahead", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, valueState: { classPropertyName: "valueState", publicName: "valueState", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, showSuggestions: { classPropertyName: "showSuggestions", publicName: "showSuggestions", isSignal: true, isRequired: false, transformFunction: null }, maxlength: { classPropertyName: "maxlength", publicName: "maxlength", isSignal: true, isRequired: false, transformFunction: null }, accessibleName: { classPropertyName: "accessibleName", publicName: "accessibleName", isSignal: true, isRequired: false, transformFunction: null }, accessibleNameRef: { classPropertyName: "accessibleNameRef", publicName: "accessibleNameRef", isSignal: true, isRequired: false, transformFunction: null }, accessibleDescription: { classPropertyName: "accessibleDescription", publicName: "accessibleDescription", isSignal: true, isRequired: false, transformFunction: null }, accessibleDescriptionRef: { classPropertyName: "accessibleDescriptionRef", publicName: "accessibleDescriptionRef", isSignal: true, isRequired: false, transformFunction: null }, showClearIcon: { classPropertyName: "showClearIcon", publicName: "showClearIcon", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5Change: "ui5Change", ui5Input: "ui5Input", ui5Select: "ui5Select", ui5SelectionChange: "ui5SelectionChange", ui5Open: "ui5Open", ui5Close: "ui5Close" }, exportAs: ["ui5Input"], hostDirectives: [{ directive: i1.GenericControlValueAccessor }], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: Input, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-input, [ui5-input]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5Input',
                    hostDirectives: [GenericControlValueAccessor],
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { Input };
//# sourceMappingURL=fundamental-ngx-ui5-webcomponents-input.mjs.map
