`;
}
// Called by rapi-doc after navigating in focused mode.
// In focused mode, the single element instance is reused across operations.
// We reset selections back to the default status code and MIME type of the active endpoint,
// preventing user selections from a prior endpoint (e.g., status 400) from carrying over or hiding panels.
resetSelection() {
this.selectedStatus =
this.defaultStatus ||
(this.responses ? Object.keys(this.responses).find((k) => k !== "$$ref") || "" : "");
if (this.selectedStatus && this.mimeResponsesForEachStatus?.[this.selectedStatus]) {
this.selectedMimeType =
Object.keys(this.mimeResponsesForEachStatus[this.selectedStatus])[0] || "";
} else {
this.selectedMimeType = this.defaultMimeType || "";
}
}
responseTemplate() {
if (!this.responses) {
return "";
}
// Fallback guard: Ensure selectedStatus and selectedMimeType always point to valid options
// for this endpoint, even if resetSelection was called or responses have not re-rendered yet.
if (!this.selectedStatus || !this.responses[this.selectedStatus]) {
this.selectedStatus =
this.defaultStatus ||
Object.keys(this.responses).find((k) => k !== "$$ref") ||
Object.keys(this.responses)[0] ||
"";
}
if (
!this.selectedMimeType &&
this.selectedStatus &&
this.mimeResponsesForEachStatus?.[this.selectedStatus]
) {
this.selectedMimeType =
Object.keys(this.mimeResponsesForEachStatus[this.selectedStatus])[0] ||
this.defaultMimeType ||
"";
}
return html`
${
Object.keys(this.responses).length > 1
? html`