import { E as head, r as escape_html, p as ensure_array_like, e as attr_class, d as attr, o as derived } from './dev-B6xUe35c.js';
import 'node:module';
import { N as Navbar, e as endpointsService } from './Navbar-y0AyDpcy.js';
import './client-BVhtM1mG.js';
import './internal-DQFuMtuQ.js';
import './utils-BSRjJDrZ.js';
import './chunk-CLZ62Ad-.js';
import './theme-state.svelte-BsNoJAjT.js';
import './state2-boKye0ZJ.js';
import './Spinner-Bk6e83RX.js';

//#region src/routes/admin/endpoints/+page.svelte
function _page($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		let deletingId = null;
		const endpoints = derived(() => endpointsService.endpoints);
		const active = derived(() => endpointsService.active);
		head("m7qpzt", $$renderer, ($$renderer) => {
			$$renderer.title(($$renderer) => {
				$$renderer.push(`<title>Assistant Endpoints — OpenPalm</title>`);
			});
		});
		Navbar($$renderer);
		$$renderer.push(`<!----> <main class="page svelte-m7qpzt"><header class="page-header svelte-m7qpzt"><h1 class="svelte-m7qpzt">Assistant Endpoints</h1> <p class="lede svelte-m7qpzt">Connect to local or remote OpenPalm assistants. The <strong>Default</strong> entry comes
        from the environment (set by the launcher) and cannot be deleted. Add more endpoints to
        switch between stacks at any time.</p></header> `);
		if (endpointsService.error) {
			$$renderer.push("<!--[0-->");
			$$renderer.push(`<div class="alert error svelte-m7qpzt" role="alert">${escape_html(endpointsService.error)}</div>`);
		} else $$renderer.push("<!--[-1-->");
		$$renderer.push(`<!--]--> <section class="endpoints-list svelte-m7qpzt" aria-label="Configured endpoints"><!--[-->`);
		const each_array = ensure_array_like(endpoints());
		for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
			let ep = each_array[$$index];
			$$renderer.push(`<article${attr_class("endpoint-card svelte-m7qpzt", void 0, { "active": ep.id === active()?.id })}><div class="endpoint-main svelte-m7qpzt"><div class="endpoint-title svelte-m7qpzt"><span class="endpoint-label svelte-m7qpzt">${escape_html(ep.label)}</span> `);
			if (ep.isDefault) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<span class="badge default svelte-m7qpzt">Default</span>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--> `);
			if (ep.id === active()?.id) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<span class="badge active svelte-m7qpzt">Active</span>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--> `);
			if (ep.hasPassword) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<span class="badge password svelte-m7qpzt" title="Server password configured">🔒</span>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--></div> <div class="endpoint-url svelte-m7qpzt">${escape_html(ep.url)}</div></div> <div class="endpoint-actions svelte-m7qpzt">`);
			if (ep.id !== active()?.id) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<button type="button" class="btn btn-primary btn-sm">Use this</button>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--> `);
			if (!ep.isDefault) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<button type="button" class="btn btn-secondary btn-sm">Edit</button> <button type="button" class="btn btn-danger btn-sm svelte-m7qpzt"${attr("disabled", deletingId === ep.id, true)}>${escape_html(deletingId === ep.id ? "Removing…" : "Remove")}</button>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--></div></article>`);
		}
		$$renderer.push(`<!--]--></section> `);
		$$renderer.push("<!--[0-->");
		$$renderer.push(`<button type="button" class="btn btn-primary">+ Add endpoint</button>`);
		$$renderer.push(`<!--]--></main>`);
	});
}

export { _page as default };
//# sourceMappingURL=_page.svelte-DbVLfUMo.js.map
