/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { addClass, removeClass } from '@tylertech/forge-core';
import { RIPPLE_CONSTANTS } from './ripple-constants';
import { ForgeRipple } from './forge-ripple';
export class RippleAdapter {
    constructor(_component) {
        this._component = _component;
    }
    _tryFindTarget() {
        return this._component.parentElement;
    }
    initialize(target, unbounded) {
        if (target) {
            this._target = (this._component.ownerDocument || document).querySelector(target);
        }
        if (!this._target) {
            this._target = this._tryFindTarget();
        }
        if (this._target) {
            this._ripple = new ForgeRipple(this._target);
            this._ripple.unbounded = unbounded;
            addClass(RIPPLE_CONSTANTS.classes.SURFACE, this._target);
        }
    }
    destroy() {
        if (this._ripple) {
            this._ripple.destroy();
            this._ripple = undefined;
        }
        if (this._target) {
            removeClass(RIPPLE_CONSTANTS.classes.SURFACE, this._target);
        }
        this._target = undefined;
    }
    activate() {
        var _a;
        (_a = this._ripple) === null || _a === void 0 ? void 0 : _a.activate();
    }
    deactivate() {
        var _a;
        (_a = this._ripple) === null || _a === void 0 ? void 0 : _a.deactivate();
    }
}
