import { __esDecorate, __runInitializers } from "tslib";
import { html } from 'lit';
import { property } from 'lit/decorators.js';
import { live } from 'lit/directives/live.js';
import { classMap } from 'lit/directives/class-map.js';
import UiDialog from '../../../md/dialog/internals/Dialog.js';
import '../../../md/text-field/ui-filled-text-field.js';
import { DeleteCookieStep, } from '@api-client/core/models/http-flows/steps/data/DeleteCookieStep.js';
let DeleteCookieAction = (() => {
    let _classSuper = UiDialog;
    let _step_decorators;
    let _step_initializers = [];
    let _step_extraInitializers = [];
    return class DeleteCookieAction extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _step_decorators = [property({ type: Object })];
            __esDecorate(this, null, _step_decorators, { kind: "accessor", name: "step", static: false, private: false, access: { has: obj => "step" in obj, get: obj => obj.step, set: (obj, value) => { obj.step = value; } }, metadata: _metadata }, _step_initializers, _step_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        #step_accessor_storage = __runInitializers(this, _step_initializers, void 0);
        get step() { return this.#step_accessor_storage; }
        set step(value) { this.#step_accessor_storage = value; }
        dialogValue = (__runInitializers(this, _step_extraInitializers), new DeleteCookieStep().toJSON());
        constructor() {
            super();
            this.dismissLabel = 'Cancel';
            this.confirmLabel = 'Save';
        }
        willUpdate(cp) {
            if (cp.has('step')) {
                this.setupDialogValue();
            }
            super.willUpdate(cp);
        }
        setupDialogValue() {
            const { step } = this;
            if (!step) {
                this.dialogValue = new DeleteCookieStep().toJSON();
            }
            else {
                this.dialogValue = new DeleteCookieStep(step).toJSON();
            }
        }
        handleUrlChange(e) {
            const input = e.target;
            this.dialogValue.url = input.value;
        }
        handleNameChange(e) {
            const input = e.target;
            this.dialogValue.name = input.value;
        }
        renderIcon() {
            const classes = {
                'icon': true,
                'with-icon': true,
            };
            return html `
      <div class="${classMap(classes)}" part="icon"><ui-icon icon="tune" role="presentation"></ui-icon></div>
    `;
        }
        renderTitle() {
            const classes = {
                'title': true,
                'with-title': true,
            };
            return html ` <div class="${classMap(classes)}" part="title"><span>Configure Delete Cookie Action</span></div> `;
        }
        renderBody() {
            const { name = '', url = '' } = this.dialogValue;
            return html `
      <div class="content">
        <div class="param-row">
          <ui-filled-text-field
            name="name"
            label="Cookie name"
            type="text"
            .value="${live(name)}"
            @change="${this.handleNameChange}"
            class="input"
            supportingText="Leave empty to delete all cookies for the URL."
          ></ui-filled-text-field>
        </div>
        <div class="param-row">
          <ui-filled-text-field
            name="url"
            label="Cookie URL"
            type="url"
            .value="${live(url)}"
            @change="${this.handleUrlChange}"
            class="input"
            supportingText="When the URL is not set then the request URL is used."
          ></ui-filled-text-field>
        </div>
      </div>
    `;
        }
    };
})();
/**
 * A dialog used by the Flow builder to configure the Delete Cookie action.
 */
export default DeleteCookieAction;
//# sourceMappingURL=DeleteCookieAction.element.js.map