import { h } from "@stencil/core";
/**
 * @componentType utility
 * @slot default - Kan innehålla vad som helst
 * @swedishName Resize Observer
 */
export class UtilResizeObserver {
    constructor() {
        this._observer = null;
    }
    componentWillLoad() {
        this.initObserver();
    }
    disconnectedCallback() {
        this.removeObserver();
    }
    initObserver() {
        this._observer = new ResizeObserver(([entry]) => {
            this.afOnChange.emit(entry);
        });
        this._observer.observe(this.hostElement);
    }
    removeObserver() {
        if (this._observer)
            this._observer.disconnect();
    }
    changeHandler(e) {
        this.afOnChange.emit(e);
    }
    render() {
        return h("slot", { key: '1428211db620bf886a98eb908958a7d7ffb0eac1' });
    }
    static get is() { return "digi-util-resize-observer"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "$": ["util-resize-observer.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["util-resize-observer.css"]
        };
    }
    static get events() {
        return [{
                "method": "afOnChange",
                "name": "afOnChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "en",
                            "text": "When the component changes size"
                        }],
                    "text": "N\u00E4r komponenten \u00E4ndrar storlek"
                },
                "complexType": {
                    "original": "ResizeObserverEntry",
                    "resolved": "ResizeObserverEntry",
                    "references": {
                        "ResizeObserverEntry": {
                            "location": "global",
                            "id": "global::ResizeObserverEntry"
                        }
                    }
                }
            }];
    }
    static get elementRef() { return "hostElement"; }
}
