import * as i0 from '@angular/core';
import { input, booleanAttribute, output, inject, ElementRef, Injector, runInInjectionContext, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import '@ui5/webcomponents/dist/Menu.js';

class Menu {
    constructor() {
        /**
         * Defines the header text of the menu (displayed on mobile).
         */
        this.headerText = input(...(ngDevMode ? [undefined, { debugName: "headerText" }] : []));
        /**
         * Indicates if the menu is open.
         */
        this.open = input(false, ...(ngDevMode ? [{ debugName: "open", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Determines on which side the component is placed at.
         */
        this.placement = input("Bottom", ...(ngDevMode ? [{ debugName: "placement" }] : []));
        /**
         * Determines the horizontal alignment of the menu relative to its opener control.
         */
        this.horizontalAlign = input("Start", ...(ngDevMode ? [{ debugName: "horizontalAlign" }] : []));
        /**
         * Defines if a loading indicator would be displayed inside the corresponding ui5-menu popover.
         */
        this.loading = input(false, ...(ngDevMode ? [{ debugName: "loading", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
        /**
         * Defines the delay in milliseconds, after which the loading indicator will be displayed inside the corresponding ui5-menu popover.
         */
        this.loadingDelay = input(1000, ...(ngDevMode ? [{ debugName: "loadingDelay" }] : []));
        /**
         * Defines the ID or DOM Reference of the element at which the menu is shown.
      When using this attribute in a declarative way, you must only use the `id` (as a string) of the element at which you want to show the popover.
      You can only set the `opener` attribute to a DOM Reference when using JavaScript.
         */
        this.opener = input(...(ngDevMode ? [undefined, { debugName: "opener" }] : [])); // className is now passed
        /**
         * Fired when an item is being clicked.
      
      **Note:** Since 1.17.0 the event is preventable, allowing the menu to remain open after an item is pressed.
         */
        this.ui5ItemClick = output();
        /**
         * Fired before the menu is opened. This event can be cancelled, which will prevent the menu from opening.
      
      **Note:** Since 1.14.0 the event is also fired before a sub-menu opens.
         */
        this.ui5BeforeOpen = output();
        /**
         * Fired after the menu is opened.
         */
        this.ui5Open = output();
        /**
         * Fired before the menu is closed. This event can be cancelled, which will prevent the menu from closing.
         */
        this.ui5BeforeClose = output();
        /**
         * Fired after the menu 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 items of this component.
      
      **Note:** Use `ui5-menu-item` and `ui5-menu-separator` for their intended design.
         *
         * @example
         * ```html
         * <ui5-menu>
         *   <div slot="header">Custom header content</div>
         *   <p>Default slot content</p>
         * </ui5-menu>
         * ```
         *
         * @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 items of this component.\n\n**Note:** Use `ui5-menu-item` and `ui5-menu-separator` for their intended design."
            }
        ];
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'headerText',
            'open',
            'placement',
            'horizontalAlign',
            'loading',
            'loadingDelay',
            'opener',
        ];
        // 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 = [
            'ui5ItemClick',
            'ui5BeforeOpen',
            'ui5Open',
            'ui5BeforeClose',
            '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: Menu, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: Menu, isStandalone: true, selector: "ui5-menu, [ui5-menu]", inputs: { headerText: { classPropertyName: "headerText", publicName: "headerText", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "open", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, horizontalAlign: { classPropertyName: "horizontalAlign", publicName: "horizontalAlign", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, loadingDelay: { classPropertyName: "loadingDelay", publicName: "loadingDelay", isSignal: true, isRequired: false, transformFunction: null }, opener: { classPropertyName: "opener", publicName: "opener", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5ItemClick: "ui5ItemClick", ui5BeforeOpen: "ui5BeforeOpen", ui5Open: "ui5Open", ui5BeforeClose: "ui5BeforeClose", ui5Close: "ui5Close" }, exportAs: ["ui5Menu"], 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: Menu, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-menu, [ui5-menu]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5Menu',
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

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

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