import { __esDecorate, __runInitializers } from "tslib";
import { DEFAULT_URL_CONFIG } from '@api-client/core/modeling/definitions/URL.js';
import { TaxonomyDialog } from './TaxonomyDialog.js';
import { SemanticType } from '@api-client/core/modeling/Semantics.js';
import { bound } from '../../decorators/bound.js';
import { html } from 'lit';
import { renderHelp } from '../../help/render.js';
let UrlTaxonomy = (() => {
    let _classSuper = TaxonomyDialog;
    let _instanceExtraInitializers = [];
    let _render_decorators;
    return class UrlTaxonomy extends _classSuper {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
            _render_decorators = [bound];
            __esDecorate(this, null, _render_decorators, { kind: "method", name: "render", static: false, private: false, access: { has: obj => "render" in obj, get: obj => obj.render }, metadata: _metadata }, null, _instanceExtraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        domainElement = __runInitializers(this, _instanceExtraInitializers);
        static title = `Configure URL Taxonomy`;
        constructor(domainElement) {
            let config;
            const semantic = domainElement.semantics.find((s) => s.id === SemanticType.URL);
            if (semantic && semantic.config) {
                config = structuredClone(semantic.config);
            }
            else {
                config = {};
            }
            super(config);
            this.domainElement = domainElement;
        }
        formCallback(event) {
            const semantic = this.domainElement.semantics.find((s) => s.id === SemanticType.URL);
            if (semantic) {
                semantic.config = this.config;
            }
            else {
                this.domainElement.semantics.push({
                    id: SemanticType.URL,
                    config: this.config,
                });
            }
            this.domainElement.domain.notifyChange();
            return super.formCallback(event);
        }
        render() {
            return html `
      <div class="checkbox-group">
        ${this.renderRequireHttps()} ${this.renderAllowQueryParams()} ${this.renderAllowFragments()}
        ${this.renderAllowInternational()} ${this.renderAllowIPAddresses()} ${this.renderAllowPorts()}
        ${this.renderAllowAuthentication()}
      </div>
    `;
        }
        renderRequireHttps() {
            const enabled = this.config?.requireHttps ?? DEFAULT_URL_CONFIG.requireHttps;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="require-https"
            name="requireHttps"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="require-https" class="body-medium">Require HTTPS</label>
            <span class="body-small meta">Users must include HTTPS in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:requireHttps')}
      </div>
    `;
        }
        renderAllowQueryParams() {
            const enabled = this.config?.allowQueryParams ?? DEFAULT_URL_CONFIG.allowQueryParams;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="allow-query-params"
            name="allowQueryParams"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="allow-query-params" class="body-medium">Allow Query Parameters</label>
            <span class="body-small meta">Users can include query parameters in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:allowQueryParams')}
      </div>
    `;
        }
        renderAllowFragments() {
            const enabled = this.config?.allowFragments ?? DEFAULT_URL_CONFIG.allowFragments;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="allow-fragments"
            name="allowFragments"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="allow-fragments" class="body-medium">Allow Fragments</label>
            <span class="body-small meta">Users can include fragments (hashes) in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:allowFragments')}
      </div>
    `;
        }
        renderAllowInternational() {
            const enabled = this.config?.allowInternational ?? DEFAULT_URL_CONFIG.allowInternational;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="allow-international"
            name="allowInternational"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="allow-international" class="body-medium">Allow International Characters</label>
            <span class="body-small meta">Users can include non-ASCII characters in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:allowInternational')}
      </div>
    `;
        }
        renderAllowIPAddresses() {
            const enabled = this.config?.allowIP ?? DEFAULT_URL_CONFIG.allowIP;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="allow-ip"
            name="allowIP"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="allow-ip" class="body-medium">Allow IP Address</label>
            <span class="body-small meta">Users can include an IP address in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:allowIP')}
      </div>
    `;
        }
        renderAllowPorts() {
            const enabled = this.config?.allowPort ?? DEFAULT_URL_CONFIG.allowPort;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="allow-port"
            name="allowPort"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="allow-port" class="body-medium">Allow Port</label>
            <span class="body-small meta">Users can include a port number in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:allowPort')}
      </div>
    `;
        }
        renderAllowAuthentication() {
            const enabled = this.config?.allowAuthentication ?? DEFAULT_URL_CONFIG.allowAuthentication;
            return html `
      <div class="row">
        <div class="input checkbox metadata">
          <ui-checkbox
            id="allow-authentication"
            name="allowAuthentication"
            .checked="${enabled}"
            @change="${this.handleBooleanChange}"
          ></ui-checkbox>
          <div class="label">
            <label for="allow-authentication" class="body-medium">Allow Authentication</label>
            <span class="body-small meta">Users can include authentication credentials in their URLs.</span>
          </div>
        </div>
        ${renderHelp('taxonomy', 'url:allowAuthentication')}
      </div>
    `;
        }
    };
})();
export { UrlTaxonomy };
//# sourceMappingURL=UrlTaxonomy.js.map