import { html } from 'lit';
import ApiResourceDocumentElement from './ApiResourceDocument.element.js';
import '../../define/amf/api-operation-document.js';
import '../../define/amf/api-parameter-document.js';
/**
 * A web component that renders the async API Channel documentation page
 */
export default class ApiChannelDocument extends ApiResourceDocumentElement {
    /**
     * Computes the URL value for the current serves, selected server, and endpoint's path.
     */
    computeUrlValue() {
        const { server, protocol = '' } = this;
        let url = '';
        if (server) {
            url = server.url;
            if (url.endsWith('/')) {
                url = url.substring(0, url.length - 1);
            }
        }
        let result = '';
        if (protocol && !url.includes('://')) {
            result = `${protocol}://`;
        }
        result += url;
        if (!result) {
            result = '(unknown server)';
        }
        this.urlValue = result;
    }
    /**
     * @returns The template for the Operation title.
     */
    renderTitle() {
        const endPoint = this.endpointValue;
        if (!endPoint) {
            return '';
        }
        const { name, path } = endPoint;
        const label = name || path;
        if (!label) {
            return '';
        }
        return html `
      <div class="endpoint-header">
        <div class="endpoint-title">
          <span class="label">${label}</span>
        </div>
        <p class="sub-header">API channel</p>
      </div>
    `;
    }
    /**
     * @returns The template for the operation's URL.
     */
    renderUrl() {
        const url = this.urlValue;
        return html `
      <div class="endpoint-url">
        <div class="url-value text-selectable">${url}</div>
      </div>
    `;
    }
    /**
     * @param operation The graph id of the operation.
     * @returns The template for the API operation.
     */
    renderOperation(endpoint, operation) {
        const { serverId, baseUri } = this;
        return html `<api-operation-document
      .domainId="${operation.id}"
      .operation="${operation}"
      .endpoint="${endpoint}"
      .endpointId="${endpoint.id}"
      .serverId="${serverId}"
      .baseUri="${baseUri}"
      data-domain-id="${operation.id}"
      responsesOpened
      showSecurity
      asyncApi
      class="operation"
    ></api-operation-document>`;
    }
}
//# sourceMappingURL=ApiChannelDocument.element.js.map