var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _FormEffectHandler_queryString, _FormEffectHandler_parentWindowInfo, _FormEffectHandler_dialog;
import { EffectHandler, postEffectToWindow } from './effect-handler.js';
export class FormEffectHandler extends EffectHandler {
    constructor(host, queryString = 'devvit-form-dialog', parentWindowInfo) {
        super(host);
        _FormEffectHandler_queryString.set(this, void 0);
        _FormEffectHandler_parentWindowInfo.set(this, void 0);
        _FormEffectHandler_dialog.set(this, void 0);
        __classPrivateFieldSet(this, _FormEffectHandler_queryString, queryString, "f");
        __classPrivateFieldSet(this, _FormEffectHandler_parentWindowInfo, parentWindowInfo, "f");
    }
    hostUpdated() {
        __classPrivateFieldSet(this, _FormEffectHandler_dialog, this.host.renderRoot.querySelector(__classPrivateFieldGet(this, _FormEffectHandler_queryString, "f")), "f");
    }
    onEvent(ev) {
        const { showForm } = ev.detail.effect;
        if (!showForm?.form)
            return;
        if (__classPrivateFieldGet(this, _FormEffectHandler_parentWindowInfo, "f")) {
            postEffectToWindow(__classPrivateFieldGet(this, _FormEffectHandler_parentWindowInfo, "f"), {
                form: showForm.form,
                onEvent: ev.detail.onEvent,
                effectName: 'devvit:formEffect',
            });
            return;
        }
        __classPrivateFieldGet(this, _FormEffectHandler_dialog, "f")?.showForm(showForm.form, ev.detail.onEvent);
    }
}
_FormEffectHandler_queryString = new WeakMap(), _FormEffectHandler_parentWindowInfo = new WeakMap(), _FormEffectHandler_dialog = new WeakMap();
//# sourceMappingURL=form-effect-handler.js.map