import { h, Host } from "@stencil/core";
import { UtilBreakpointObserverBreakpoints } from "./util-breakpoint-observer-breakpoints.enum";
/**
 * @componentType utility
 * @slot default - Kan innehålla vad som helst
 * @enums UtilBreakpointObserverBreakpoints - util-breakpoint-observer-breakpoints.enum.ts
 * @swedishName Breakpoint Observer
 *
 */
export class UtilBreakpointObserver {
    componentDidLoad() {
        this.handleBreakpoint();
    }
    handleBreakpoint(e) {
        const observerCSSVariables = window.getComputedStyle(this._observer);
        const value = observerCSSVariables.getPropertyValue('--digi--util-breakpoint-observer--breakpoint');
        this.afOnChange.emit({ value, e });
        switch (value) {
            case UtilBreakpointObserverBreakpoints.SMALL:
                this.afOnSmall.emit({ value, e });
                break;
            case UtilBreakpointObserverBreakpoints.MEDIUM:
                this.afOnMedium.emit({ value, e });
                break;
            case UtilBreakpointObserverBreakpoints.LARGE:
                this.afOnLarge.emit({ value, e });
                break;
            case UtilBreakpointObserverBreakpoints.XLARGE:
                this.afOnXLarge.emit({ value, e });
        }
    }
    render() {
        return (h(Host, { key: '2401a348a719b634b60ef6b186da7cf297c16743' }, h("div", { key: '06625da48adae31e39f21e78d27987f6a595b808', class: "digi-util-breakpoint-observer" }, h("div", { key: 'd925d3ce668b84f45f85666becfd66196979c304', ref: (el) => (this._observer = el), onTransitionEnd: (e) => this.handleBreakpoint(e), class: "digi-util-breakpoint-observer__observer" }), h("slot", { key: '20f02ba8824f6c6d9c44f417670fc3e19c3a1e4b' }))));
    }
    static get is() { return "digi-util-breakpoint-observer"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "$": ["util-breakpoint-observer.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["util-breakpoint-observer.css"]
        };
    }
    static get events() {
        return [{
                "method": "afOnChange",
                "name": "afOnChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "At page load and at change of breakpoint on page"
                        }],
                    "text": "Vid inl\u00E4sning av sida samt vid uppdatering av brytpunkt"
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }, {
                "method": "afOnSmall",
                "name": "afOnSmall",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "At breakpoint 'small'"
                        }],
                    "text": "Vid brytpunkt 'small'"
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }, {
                "method": "afOnMedium",
                "name": "afOnMedium",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "At breakpoint 'medium'"
                        }],
                    "text": "Vid brytpunkt 'medium'"
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }, {
                "method": "afOnLarge",
                "name": "afOnLarge",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "At breakpoint 'large'"
                        }],
                    "text": "Vid brytpunkt 'large'"
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }, {
                "method": "afOnXLarge",
                "name": "afOnXLarge",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "At breakpoint 'xlarge'"
                        }],
                    "text": "Vid brytpunkt 'xlarge'"
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "hostElement"; }
}
