'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const core = require('./core-b7b9d752.js');
const utils = require('./utils-2a7c8f6e.js');

const Observer = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
        this.observer = new MutationObserver(this.onChange.bind(this));
        /**
         * Watch attributes
         */
        this.incattrs = true;
        /**
         * How long to delay the event
         */
        this.debounce = 0;
        this.anjContentChange = core.createEvent(this, "anjContentChange", 7);
    }
    connectedCallback() {
        if (this.debounce) {
            this.anjContentChange = utils.debounceEvent(this.anjContentChange, this.debounce);
        }
        this.observer.observe(this.element, { attributes: this.incattrs, childList: true, subtree: true });
    }
    disconnectedCallback() {
        this.observer.disconnect();
    }
    onChange(mutations) {
        this.anjContentChange.emit(mutations);
    }
    get element() { return core.getElement(this); }
};

exports.anj_observer = Observer;
