import * as i0 from '@angular/core';
import { Directive, computed } from '@angular/core';

/** Copies the current theme from the root element.
 *
 * For use with single-component variables from the theme generator
 */
class NxThemeAttributeDirective {
    constructor(host) {
        host.nativeElement.setAttribute('data-theme', document.documentElement.getAttribute('data-theme'));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NxThemeAttributeDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.3", type: NxThemeAttributeDirective, isStandalone: true, selector: "[nxThemeAttribute]", ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: NxThemeAttributeDirective, decorators: [{
            type: Directive,
            args: [{ selector: '[nxThemeAttribute]', standalone: true }]
        }], ctorParameters: () => [{ type: i0.ElementRef }] });

function writeOnlySignal(s) {
    return s;
}
var Compass8;
(function (Compass8) {
    Compass8["N"] = "North";
    Compass8["NE"] = "Northeast";
    Compass8["E"] = "East";
    Compass8["SE"] = "Southeast";
    Compass8["S"] = "South";
    Compass8["SW"] = "Southwest";
    Compass8["W"] = "West";
    Compass8["NW"] = "Northwest";
})(Compass8 || (Compass8 = {}));
function compass8ToAngularPosition(direction) {
    switch (direction) {
        case 'N':
            return { x: 'center', y: 'top' };
        case 'NE':
            return { x: 'end', y: 'top' };
        case 'E':
            return { x: 'end', y: 'center' };
        case 'SE':
            return { x: 'end', y: 'bottom' };
        case 'S':
            return { x: 'center', y: 'bottom' };
        case 'SW':
            return { x: 'start', y: 'bottom' };
        case 'W':
            return { x: 'start', y: 'center' };
        case 'NW':
            return { x: 'start', y: 'top' };
    }
}
function cdkOriginPosition(direction) {
    const { x, y } = compass8ToAngularPosition(direction);
    return { originX: x, originY: y };
}
function cdkOverlayPosition(direction) {
    const { x, y } = compass8ToAngularPosition(direction);
    return { overlayX: x, overlayY: y };
}
function connectedPosition(position) {
    const { originPoint, overlayPoint, ...other } = position;
    return {
        ...cdkOriginPosition(originPoint),
        ...cdkOverlayPosition(overlayPoint),
        ...other,
    };
}

function ariaBoolean(state) {
    return state ? 'true' : 'false';
}
/** Compute aria boolean from signals */
function ariaComputed(...signals) {
    return computed(() => ariaBoolean(signals.some(s => s())));
}
/** Check whether a mouse event is inside an element */
function clickedInside({ pageX: eventX, pageY: eventY }, element) {
    const elemRect = element.getBoundingClientRect();
    const withinHorizontal = elemRect.left <= eventX && eventX <= elemRect.right;
    const withinVertical = elemRect.top <= eventY && eventY <= elemRect.bottom;
    return withinHorizontal && withinVertical;
}
/**
 * Scroll an item into view inside in a list container like a dropdown
 *
 * The list container element must be the ancestor the browser uses for calculating coordinates.
 *
 * https://javascript.info/size-and-scroll#offsetparent-offsetleft-top
 *
 * @param item The item element to scroll to
 * @param container The container element of the item
 */
function scrollItemIntoView(item, container) {
    const itemTop = item.offsetTop;
    const itemBottom = itemTop + item.offsetHeight;
    const containerVisibleTop = container.scrollTop;
    const containerVisibleBottom = containerVisibleTop + container.offsetHeight;
    if (itemTop < containerVisibleTop) {
        item.scrollIntoView(true); // alignToTop
    }
    else if (itemBottom > containerVisibleBottom) {
        item.scrollIntoView(false);
    }
}

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

export { NxThemeAttributeDirective, ariaBoolean, ariaComputed, cdkOriginPosition, cdkOverlayPosition, clickedInside, connectedPosition, scrollItemIntoView, writeOnlySignal };
//# sourceMappingURL=networkoptix-nx-shared.mjs.map
