diff --git a/i18n/en.msg b/i18n/en.msg index c4bd2af856..b6533e4939 100644 --- a/i18n/en.msg +++ b/i18n/en.msg @@ -4474,6 +4474,7 @@ mobile.pill.waiting = Waiting mobile.snooze.wakes = Wakes in {time} mobile.bench.all = All projects mobile.snooze.for = Snooze for +mobile.conn.reconnecting = Reconnecting… # ---- end ---- # the sidebar's sections (docs/ALWAYS-ON.md section 8): the hub's words, and the window's sidebar.sections.needs = Needs you diff --git a/i18n/es.msg b/i18n/es.msg index a7cc0f503f..354ce057ae 100644 --- a/i18n/es.msg +++ b/i18n/es.msg @@ -4476,6 +4476,7 @@ mobile.pill.waiting = En espera mobile.snooze.wakes = Vuelve en {time} mobile.bench.all = Todos los proyectos mobile.snooze.for = Posponer +mobile.conn.reconnecting = Reconectando… # ---- end ---- # the sidebar's sections (docs/ALWAYS-ON.md section 8): the hub's words, and the window's sidebar.sections.needs = Te necesita diff --git a/i18n/ja.msg b/i18n/ja.msg index dd5954add5..d79dea00b3 100644 --- a/i18n/ja.msg +++ b/i18n/ja.msg @@ -4497,6 +4497,7 @@ mobile.pill.waiting = 待機中 mobile.snooze.wakes = {time}後に再開 mobile.bench.all = すべてのプロジェクト mobile.snooze.for = スヌーズする期間 +mobile.conn.reconnecting = 再接続中… # ---- end ---- # the sidebar's sections (docs/ALWAYS-ON.md section 8): the hub's words, and the window's sidebar.sections.needs = 対応が必要 diff --git a/mobile/android/app/src/main/java/dev/backplane/mobile/DataClient.kt b/mobile/android/app/src/main/java/dev/backplane/mobile/DataClient.kt index 81a8cf8b72..c05a110d97 100644 --- a/mobile/android/app/src/main/java/dev/backplane/mobile/DataClient.kt +++ b/mobile/android/app/src/main/java/dev/backplane/mobile/DataClient.kt @@ -169,12 +169,16 @@ object DataClient { legacyCacheFile().delete() setHome(""); leaveHome(); keepOutbox(Outbox()); links = emptyList(); adding = false; prefs().edit().remove("link").remove("links").apply(); reset(clearDisk = true); close(); conn = Conn.OFFLINE; needsRepair = false; pairingError = ""; askLink = null; pairEpoch++ } + private var sectionsJson: JSONArray? = null + private var groupsToJson: JSONArray? = null + private fun reset(clearDisk: Boolean = false) { saveJob?.cancel() shellHashes.clear(); threadHashes.clear(); threadIds.clear(); subEntriesById.clear(); subEntryIds = emptyList() - Swarms.reset(); restarting = null; hubBack = null; notice = HubNotice(); star = null; telemetryNotice = null; noProvider = null; migrating = null; migrateOpen = false; projects = emptyList(); threads = emptyList(); entries = emptyMap(); older = emptyMap(); listsLoaded = false; open = null + Swarms.reset(); restarting = null; hubBack = null; notice = HubNotice(); star = null; telemetryNotice = null; noProvider = null; migrating = null; migrateOpen = false + projects = emptyList(); threads = emptyList(); entries = emptyMap(); older = emptyMap(); listsLoaded = false; open = null + sections = emptyList(); groupsTo = emptyList(); sectionsJson = null; groupsToJson = null; features = emptySet(); bots = emptyList(); rooms = emptyList() home = null - Swarms.reset(); notice = HubNotice(); star = null; telemetryNotice = null; noProvider = null; migrating = null; migrateOpen = false; projects = emptyList(); threads = emptyList(); entries = emptyMap(); older = emptyMap(); listsLoaded = false; open = null if (clearDisk) link?.let { Pairing.key(it) }?.let { cacheFile(it).delete() } } @@ -395,8 +399,14 @@ object DataClient { private suspend fun synchronise(g: Int) { try { if (has("shell") && machine.isEmpty()) { - val have = JSONObject().also { h -> shellHashes.forEach { (k, v) -> h.put(k, v) } } - val r = call("shell.sync", JSONObject().put("have", have).put("settled", 25)) + if (sectionsOpen.isEmpty()) sectionsOpen = prefs().getStringSet("sections.open", emptySet())?.toSet() ?: emptySet() + val have = JSONObject().also { h -> + shellHashes.forEach { (k, v) -> + if ((k == "@sections" && sections.isEmpty()) || (k.startsWith("p:") && projects.isEmpty())) return@forEach + h.put(k, v) + } + } + val r = call("shell.sync", JSONObject().put("have", have).put("settled", 25).put("open", openArr())) if (g != gen) return listSub = r.optInt("sub") val removed = r.optJSONArray("removed")?.let { a -> (0 until a.length()).map { a.optString(it) }.toSet() } ?: emptySet() @@ -415,20 +425,25 @@ object DataClient { } } r.optJSONObject("sections")?.let { s -> - sections = DSection.list(s.optJSONArray("sections")) - groupsTo = DSection.groups(s.optJSONArray("groupsTo")) - } ?: r.optJSONArray("sections")?.let { a -> sections = DSection.list(a) } + sectionsJson = s.optJSONArray("sections") + groupsToJson = s.optJSONArray("groupsTo") + sections = DSection.list(sectionsJson) + groupsTo = DSection.groups(groupsToJson) + } ?: r.optJSONArray("sections")?.let { a -> + sectionsJson = a + sections = DSection.list(a) + } r.optJSONObject("h")?.let { h -> val next = HashMap() h.keys().forEach { k -> next[k] = h.optString(k) } shellHashes = next } listsLoaded = true; save() - coroutineScope { launch { runCatching { loadLocks() } }; launch { runCatching { loadStar() } }; launch { runCatching { loadTelemetryNotice() } }; launch { loadHistory() }; launch { Swarms.load() } } + coroutineScope { launch { runCatching { if (has("bots")) loadBots() } }; launch { runCatching { loadLocks() } }; launch { runCatching { loadStar() } }; launch { runCatching { loadTelemetryNotice() } }; launch { loadHistory() }; launch { Swarms.load() } } } else { listSub = call("subscribe", JSONObject().put("topic", "lists")).optInt("sub") if (g != gen) return - coroutineScope { launch { loadProjects(g) }; launch { loadThreads(g) }; launch { runCatching { loadLocks() } }; launch { runCatching { loadStar() } }; launch { runCatching { loadTelemetryNotice() } }; launch { loadHistory() }; launch { Swarms.load() }; launch { loadSections() } } + coroutineScope { launch { loadProjects(g) }; launch { loadThreads(g) }; launch { runCatching { if (has("bots")) loadBots() } }; launch { runCatching { loadLocks() } }; launch { runCatching { loadStar() } }; launch { runCatching { loadTelemetryNotice() } }; launch { loadHistory() }; launch { Swarms.load() }; launch { loadSections() } } } syncPush() open?.let { if (has("open")) openThreadBundled(it, g) else { subscribeThread(it, g); refreshThread(it) } } @@ -446,7 +461,9 @@ object DataClient { if (!has("sections")) return if (sectionsOpen.isEmpty()) sectionsOpen = prefs().getStringSet("sections.open", emptySet())?.toSet() ?: emptySet() val r = runCatching { call("sidebar.sections", JSONObject().put("open", openArr())) }.getOrNull() ?: return - sections = DSection.list(r.optJSONArray("sections")); groupsTo = DSection.groups(r.optJSONArray("groupsTo")) + sectionsJson = r.optJSONArray("sections"); groupsToJson = r.optJSONArray("groupsTo") + sections = DSection.list(sectionsJson); groupsTo = DSection.groups(groupsToJson) + save() } fun toggleSection(t: String) { sectionsOpen = if (t in sectionsOpen) sectionsOpen - t else sectionsOpen + t; prefs().edit().putStringSet("sections.open", sectionsOpen).apply(); scope.launch { loadSections() } } fun sidebarAct(action: String, value: String) { scope.launch { runCatching { call("sidebar.act", JSONObject().put("action", action).put("value", value)) }; loadSections() } } @@ -1117,6 +1134,7 @@ object DataClient { } rooms = r.optJSONArray("rooms")?.let { a -> (0 until a.length()).mapNotNull { a.optJSONObject(it) }.map { Room(it.optString("id"), it.optString("name"), it.optJSONObject("mark")?.optString("short") ?: "", it.optBoolean("delete")) } } ?: emptyList() if (uberAfterPair) bots.firstOrNull { it.uber && it.thread.isNotEmpty() }?.let { uberAfterPair = false; linkTarget = LinkTarget(LinkTarget.Kind.THREAD, it.thread) } + save() } data class Post(val from: String, val text: String, val at: Long, val copy: List? = null) suspend fun roomPosts(room: String): List = call("room.posts", JSONObject().put("room", room).put("limit", 60)).optJSONArray("posts")?.let { a -> (0 until a.length()).mapNotNull { a.optJSONObject(it) }.map { Post(it.optString("from"), it.optString("text"), it.optLong("at"), parseCopy(it.optJSONArray("copy"))) } } ?: emptyList() @@ -1374,7 +1392,24 @@ object DataClient { val c = JSONObject(f.readText()); if (c.optString("hub") != hub) return projects = parseProjects(c.optJSONArray("projects")); threads = parseThreads(c.optJSONArray("threads")) val e = c.optJSONObject("entries"); entries = e?.keys()?.asSequence()?.associateWith { parseEntries(e.optJSONArray(it)) } ?: emptyMap() - listsLoaded = threads.isNotEmpty() || projects.isNotEmpty() + c.optJSONArray("features")?.let { a -> features = (0 until a.length()).mapNotNull { a.optString(it).takeIf(String::isNotEmpty) }.toSet() } + c.optJSONArray("sections")?.let { a -> sectionsJson = a; sections = DSection.list(a) } + c.optJSONArray("groupsTo")?.let { a -> groupsToJson = a; groupsTo = DSection.groups(a) } + c.optJSONArray("bots")?.let { a -> + bots = (0 until a.length()).mapNotNull { a.optJSONObject(it) }.map { + Bot(it.optString("id"), it.optString("name"), it.optString("thread"), it.optBoolean("uber"), it.optString("markShort"), it.optString("note"), it.optBoolean("delete"), it.optInt("look"), it.optString("color"), + it.optJSONObject("ask")?.let { ak -> Ask(ak.optString("title"), ak.optString("body"), ak.optString("yes")) } ?: Ask()) + } + } + c.optJSONArray("rooms")?.let { a -> + rooms = (0 until a.length()).mapNotNull { a.optJSONObject(it) }.map { Room(it.optString("id"), it.optString("name"), it.optString("markShort"), it.optBoolean("delete")) } + } + c.optJSONObject("shellHashes")?.let { h -> + val next = HashMap() + h.keys().forEach { k -> next[k] = h.optString(k) } + shellHashes = next + } + listsLoaded = threads.isNotEmpty() || projects.isNotEmpty() || sections.isNotEmpty() } } private fun save() { @@ -1383,6 +1418,10 @@ object DataClient { delay(1000) val hub = link?.let { Pairing.key(it) } ?: return@launch val ps = projects; val ts = threads + val fs = features.sorted() + val sec = sectionsJson; val gto = groupsToJson + val bs = bots; val rs = rooms + val sh = HashMap(shellHashes) val recent = ts.take(20).map { it.id }.toSet() val es = entries.filterKeys { it in recent }.mapValues { (_, v) -> v.filter { !it.sending && !it.failed }.takeLast(40) } withContext(Dispatchers.IO) { @@ -1390,6 +1429,11 @@ object DataClient { .put("projects", JSONArray(ps.map { JSONObject().put("id", it.id).put("title", it.title).put("root", it.root).put("threadCount", it.threadCount).apply { it.settledCount?.let { n -> put("settledCount", n) } }.put("updatedAt", it.updatedAt).put("waiting", it.waiting).put("also", it.also).put("mark", markJson(it.mark)) })) .put("threads", JSONArray(ts.map { JSONObject().put("id", it.id).put("project", it.project).put("title", it.title).put("state", it.state).put("updatedAt", it.updatedAt).put("pinned", it.pinned).put("pinOrder", it.pinOrder).put("settled", it.settled).put("settledAt", it.settledAt).put("archived", it.archived).put("provider", it.provider).put("model", it.model).put("effort", it.effort).put("runtime", it.runtime).put("chip", it.chip).put("preview", it.preview).put("waiting", it.waiting).put("mark", markJson(it.mark)).put("swarm", it.swarm).apply { it.planMode?.let { pm -> put("planMode", planModeJson(pm)) } } })) .put("entries", JSONObject().also { o -> es.forEach { (k, v) -> o.put(k, JSONArray(v.map(::J))) } }) + .put("features", JSONArray(fs)) + .apply { if (sec != null) put("sections", sec); if (gto != null) put("groupsTo", gto) } + .put("bots", JSONArray(bs.map { JSONObject().put("id", it.id).put("name", it.name).put("thread", it.thread).put("uber", it.uber).put("markShort", it.mark).put("note", it.note).put("delete", it.delete).put("look", it.look).put("color", it.color).put("ask", JSONObject().put("title", it.ask.title).put("body", it.ask.body).put("yes", it.ask.yes)) })) + .put("rooms", JSONArray(rs.map { JSONObject().put("id", it.id).put("name", it.name).put("markShort", it.mark).put("delete", it.delete) })) + .put("shellHashes", JSONObject().also { o -> sh.forEach { (k, v) -> o.put(k, v) } }) runCatching { cacheFile(hub).writeText(j.toString()) } } } diff --git a/mobile/android/app/src/main/java/dev/backplane/mobile/DataViews.kt b/mobile/android/app/src/main/java/dev/backplane/mobile/DataViews.kt index d90ef9b75d..285b2e8ada 100644 --- a/mobile/android/app/src/main/java/dev/backplane/mobile/DataViews.kt +++ b/mobile/android/app/src/main/java/dev/backplane/mobile/DataViews.kt @@ -198,7 +198,9 @@ private fun ConnBanner(hub: () -> Unit, settings: () -> Unit) { // the hub's restart (RestartStrip.kt) says itself here in place of the usual look: while it is away, and its crash note as we join val online = DataClient.conn == DataClient.Conn.ONLINE val restart = DataClient.restartText + val hasCached = DataClient.listsLoaded || DataClient.sections.isNotEmpty() || DataClient.projects.isNotEmpty() if (online && restart == null) return + if (!online && restart == null && DataClient.conn == DataClient.Conn.CONNECTING && hasCached) return Row(Modifier.fillMaxWidth().background(dcs.surfaceContainerHigh).padding(horizontal = 12.dp, vertical = 6.dp).testTag("conn.strip"), verticalAlignment = Alignment.CenterVertically) { DDot(if (online) dcs.primary else if (restart != null || DataClient.conn == DataClient.Conn.CONNECTING) dwarn else dcs.error, 8); Spacer(Modifier.width(8.dp)) DMono(restart?.let { Tr.t(it) } ?: if (DataClient.conn == DataClient.Conn.CONNECTING) Msg.android_conn_connecting(DataClient.hubName) else Msg.android_conn_offline, dcs.onSurface, 12, Modifier.weight(1f)) @@ -344,7 +346,6 @@ private fun HomeScreen(open: (String) -> Unit, settings: () -> Unit, hub: () -> var shut by remember { mutableStateOf(prefs.getStringSet("projects.shut", emptySet())!!.toSet()) } var treeOpen by remember { mutableStateOf(prefs.getStringSet("tree.open", emptySet())!!.toSet()) } // parents whose subthreads show val termsOpen = LocalTermsOpen.current - LaunchedEffect(DataClient.conn) { DataClient.refresh(); if (DataClient.conn == DataClient.Conn.ONLINE && DataClient.has("bots")) runCatching { DataClient.loadBots() } } val listState = androidx.compose.foundation.lazy.rememberLazyListState() var flash by remember { mutableStateOf("") } val rowOf = remember { mutableMapOf() } // a project's header row in the list @@ -557,6 +558,21 @@ private fun HomeScreen(open: (String) -> Unit, settings: () -> Unit, hub: () -> } } } + if (DataClient.conn == DataClient.Conn.CONNECTING && DataClient.restartText == null && (DataClient.listsLoaded || DataClient.sections.isNotEmpty() || DataClient.projects.isNotEmpty())) { + Row( + Modifier + .align(Alignment.BottomCenter) + .padding(bottom = 10.dp) + .background(dcs.surfaceContainerHigh, RectangleShape) + .border(BorderStroke(1.dp, dcs.outlineVariant), RectangleShape) + .padding(horizontal = 10.dp, vertical = 5.dp) + .testTag("conn.reconnecting"), + verticalAlignment = Alignment.CenterVertically, + ) { + DDot(dwarn, 6); Spacer(Modifier.width(6.dp)) + DMono(Msg.mobile_conn_reconnecting, dcs.onSurfaceVariant, 11) + } + } } } DLine() diff --git a/mobile/android/app/src/main/java/dev/backplane/mobile/Msg.kt b/mobile/android/app/src/main/java/dev/backplane/mobile/Msg.kt index 3614dce998..7859232275 100644 --- a/mobile/android/app/src/main/java/dev/backplane/mobile/Msg.kt +++ b/mobile/android/app/src/main/java/dev/backplane/mobile/Msg.kt @@ -4386,6 +4386,7 @@ object Msg { "mobile.snooze.wakes", "mobile.bench.all", "mobile.snooze.for", + "mobile.conn.reconnecting", "sidebar.sections.needs", "sidebar.sections.pinned", "sidebar.sections.active", @@ -4537,9 +4538,9 @@ object Msg { "gpui.mgmt.plan.reference", "gpui.mgmt.plan.nets", "gpui.mgmt.plan.tab", - "gpui.mgmt.plan.before", ) private fun keys18(): Array = arrayOf( + "gpui.mgmt.plan.before", "gpui.mgmt.plan.onwords", "gpui.mgmt.plan.offwords", "gpui.mgmt.plan.elsewhere", @@ -4789,9 +4790,9 @@ object Msg { "viewer.layout.refusal.duplicateid", "viewer.layout.refusal.unknownframe", "viewer.layout.refusal.invalidinput", - "viewer.layout.refusal.toomany", ) private fun keys19(): Array = arrayOf( + "viewer.layout.refusal.toomany", "viewer.layout.refusal.toomanysources", "viewer.layout.refusal.unresolvedversion", "viewer.layout.refusal.nohistory", @@ -9388,6 +9389,7 @@ object Msg { "Wakes in {time}", "All projects", "Snooze for", + "Reconnecting…", "Needs you", "Pinned", "Active", @@ -9539,9 +9541,9 @@ object Msg { "over {layer}", "{n, plural, one {# net} other {# nets}}", "Plan", - "Plan before routing", ) private fun en18(): Array = arrayOf( + "Plan before routing", "Before routing a board with 4 or more copper layers or more than 60 nets, the agent proposes corridors and plane regions here. It routes only what you approve.", "Agents route as you ask. Turn it on to have them propose a routing plan first and route only what you approve here.", "A routing plan for {board} awaits your approval", @@ -9791,9 +9793,9 @@ object Msg { "Tile already exists", "Unknown KiCad frame", "Invalid layout request", - "Too many tiles open", ) private fun en19(): Array = arrayOf( + "Too many tiles open", "Too many sources in one layout", "That version is not in this project's history", "This page has no history", @@ -14390,6 +14392,7 @@ object Msg { "{time}後に再開", "すべてのプロジェクト", "スヌーズする期間", + "再接続中…", "対応が必要", "ピン留め", "進行中", @@ -14541,9 +14544,9 @@ object Msg { "基準 {layer}", "ネット{n}本", "計画", - "配線前に計画する", ) private fun ja18(): Array = arrayOf( + "配線前に計画する", "銅箔層が4層以上、またはネットが60本を超える基板では、配線の前にエージェントがここで配線経路とプレーン領域を提案します。承認したものだけを配線します。", "エージェントは指示どおりに配線します。オンにすると、まず配線計画を提案し、ここで承認したものだけを配線します。", "{board}の配線計画が承認を待っています", @@ -14793,9 +14796,9 @@ object Msg { "タイルは既に存在します", "不明な KiCad フレームです", "無効なレイアウト要求です", - "タイルが多すぎます", ) private fun ja19(): Array = arrayOf( + "タイルが多すぎます", "レイアウトのソースが多すぎます", "このバージョンはこのプロジェクトの履歴にありません", "このページには履歴がありません", @@ -19392,6 +19395,7 @@ object Msg { "Vuelve en {time}", "Todos los proyectos", "Posponer", + "Reconectando…", "Te necesita", "Fijados", "Activos", @@ -19543,9 +19547,9 @@ object Msg { "sobre {layer}", "{n, plural, one {# red} other {# redes}}", "Plan", - "Planificar antes de rutear", ) private fun es18(): Array = arrayOf( + "Planificar antes de rutear", "Antes de rutear una placa con 4 o más capas de cobre o más de 60 redes, el agente propone aquí corredores y regiones de plano. Solo rutea lo que apruebes.", "Los agentes rutean como les pidas. Actívalo para que primero propongan un plan de ruteo y ruteen solo lo que apruebes aquí.", "Un plan de ruteo para {board} espera tu aprobación", @@ -19795,9 +19799,9 @@ object Msg { "El panel ya existe", "Marco de KiCad desconocido", "Solicitud de diseño no válida", - "Demasiados mosaicos abiertos", ) private fun es19(): Array = arrayOf( + "Demasiados mosaicos abiertos", "Demasiadas fuentes en un diseño", "Esa versión no está en el historial de este proyecto", "Esta página no tiene historial", @@ -22990,6 +22994,7 @@ object Msg { "Waiting", "All projects", "Snooze for", + "Reconnecting…", "Quiet", "Nothing for two weeks", "Recent", @@ -23033,9 +23038,9 @@ object Msg { "Preferences", "Handover", "none waiting", - "Session", ) private fun exactText12(): Array = arrayOf( + "Session", "Last handover", "Mailroom triage", "Back office", @@ -23285,9 +23290,9 @@ object Msg { "Too small for KiCad", "Only one KiCad tile", "Those views cannot be overlaid", - "That tile is no longer open", ) private fun exactText13(): Array = arrayOf( + "That tile is no longer open", "That tile has no overlay", "That file is outside this project", "Choose two different tiles", @@ -23453,9 +23458,9 @@ object Msg { "(no words)", ) internal val exactText: Array by lazy { arrayOf(*exactText0(), *exactText1(), *exactText2(), *exactText3(), *exactText4(), *exactText5(), *exactText6(), *exactText7(), *exactText8(), *exactText9(), *exactText10(), *exactText11(), *exactText12(), *exactText13()) } - internal val exactKey: IntArray by lazy { intArrayOf(0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3169, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 3737, 61, 62, 63, 64, 66, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84, 85, 3776, 87, 88, 98, 99, 3098, 3775, 102, 103, 105, 106, 107, 109, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 159, 161, 162, 163, 3218, 165, 166, 3220, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 3179, 183, 187, 189, 193, 194, 195, 197, 198, 199, 200, 201, 202, 206, 209, 213, 215, 216, 217, 219, 220, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 234, 235, 2985, 237, 238, 239, 240, 3736, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 260, 262, 263, 264, 265, 266, 267, 270, 271, 272, 273, 275, 279, 280, 281, 282, 286, 287, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 300, 301, 3190, 305, 306, 307, 308, 309, 310, 311, 313, 314, 315, 317, 319, 333, 3784, 336, 3783, 3786, 340, 3796, 342, 343, 344, 345, 354, 3167, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 2988, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 2980, 2981, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 453, 454, 455, 3197, 457, 458, 459, 460, 461, 2970, 463, 464, 465, 3100, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 556, 557, 558, 559, 560, 561, 562, 563, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 592, 628, 629, 630, 3205, 3206, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 651, 652, 3849, 654, 656, 657, 659, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 686, 687, 689, 690, 692, 693, 694, 695, 698, 704, 724, 728, 729, 730, 731, 732, 3781, 734, 735, 736, 737, 3204, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 3764, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 843, 844, 845, 847, 848, 3200, 850, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 3774, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 3851, 903, 904, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 3170, 964, 965, 966, 967, 968, 969, 3799, 971, 3025, 3082, 974, 975, 976, 978, 979, 987, 988, 989, 991, 992, 993, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 3802, 1020, 1021, 1022, 1025, 1029, 1030, 1031, 2977, 3051, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1045, 1046, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1082, 1083, 1086, 1087, 1088, 1090, 1091, 1092, 3816, 1094, 1095, 1098, 1099, 1100, 3199, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 3801, 1120, 1123, 1124, 1125, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1150, 1151, 1152, 1153, 1154, 1155, 1158, 1162, 1163, 1165, 1170, 1171, 1172, 1173, 1176, 1178, 1180, 1181, 1182, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1220, 1222, 1223, 2979, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1240, 1241, 1244, 1245, 1246, 1247, 1248, 1250, 1253, 1254, 1255, 1256, 1257, 1258, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1277, 1278, 1279, 1280, 1281, 1288, 1289, 1290, 1291, 1294, 1296, 1297, 1298, 1299, 1301, 1305, 1306, 1308, 1309, 1310, 1311, 1315, 1316, 1318, 1319, 1320, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1335, 1338, 1339, 1340, 1341, 1344, 1347, 1348, 1356, 1357, 3514, 1361, 1362, 1363, 1364, 1365, 1366, 3581, 1373, 1375, 1380, 1384, 1385, 3055, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 2982, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 3099, 3592, 1436, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 3594, 1473, 1474, 1475, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1493, 1494, 3739, 1496, 1497, 1498, 3751, 3757, 1501, 1502, 1503, 1504, 1505, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1523, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1573, 1574, 1575, 1576, 1578, 1579, 1580, 1581, 1582, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 3058, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 3468, 1670, 1671, 1672, 1673, 3469, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 2991, 1692, 1694, 1696, 1698, 1702, 1706, 1712, 1714, 1715, 1716, 1718, 1719, 1720, 1721, 1722, 1723, 1725, 1727, 1728, 1729, 1730, 1731, 1733, 1734, 3763, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1744, 1745, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1826, 1827, 3034, 1836, 1838, 1842, 3016, 1844, 1845, 3017, 1847, 1848, 1852, 3081, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1864, 1869, 1871, 1872, 1873, 1874, 1875, 1876, 3096, 1878, 1879, 1882, 1883, 1893, 1894, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1942, 1943, 1945, 1946, 1956, 1958, 1959, 1962, 1963, 1966, 1967, 1968, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1988, 1994, 1995, 1996, 1997, 2001, 3157, 2007, 2008, 2010, 2011, 2012, 2013, 3809, 3810, 2022, 2024, 2025, 2026, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2039, 2040, 2042, 2043, 2046, 2047, 3142, 3143, 3144, 2055, 3370, 2057, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2074, 2075, 2076, 2077, 2078, 2079, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2112, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2127, 2128, 2129, 3084, 2133, 2134, 2135, 2137, 2139, 2140, 2141, 2142, 3007, 3132, 3133, 3134, 3135, 3136, 2149, 2150, 2151, 2153, 3009, 3010, 3000, 2999, 2159, 3001, 2161, 3005, 2163, 3368, 2168, 2172, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 3035, 2188, 2189, 2190, 2191, 3068, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2204, 3381, 2206, 2207, 2208, 2209, 3050, 2211, 2212, 2213, 2214, 2998, 2216, 3113, 2219, 2223, 2224, 3658, 2226, 2227, 3745, 3746, 2231, 3195, 2234, 3734, 2237, 2238, 2239, 2240, 2241, 3794, 2243, 3165, 2245, 3164, 2247, 2249, 2251, 2252, 2253, 2257, 2260, 2262, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2279, 2280, 2281, 3752, 2283, 2284, 2286, 3042, 3040, 3044, 2292, 2294, 2295, 2301, 2302, 2303, 2304, 3080, 2309, 2310, 2312, 2317, 2318, 3024, 3593, 2987, 2986, 2989, 3109, 3112, 2331, 2332, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 3813, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2374, 2376, 2377, 2378, 2382, 2383, 2386, 2387, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2408, 2409, 2410, 2411, 2412, 2413, 2435, 2436, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2455, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2469, 2470, 2471, 2472, 2474, 2475, 2476, 2478, 2481, 2482, 2483, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2546, 2547, 2548, 2549, 3146, 2551, 2553, 2554, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2565, 2566, 2567, 2568, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2587, 2588, 2589, 2590, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2614, 2616, 2617, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2630, 2631, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2645, 2647, 2650, 2652, 3742, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2667, 2668, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2678, 2679, 2680, 2685, 2686, 2687, 2689, 2690, 2691, 2692, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 3715, 2708, 2709, 2711, 3712, 2713, 2714, 3716, 3713, 2726, 2730, 3723, 3219, 3724, 2734, 3725, 2736, 2738, 3727, 2740, 3728, 2742, 2744, 3732, 3710, 3703, 3711, 2763, 2764, 2766, 2767, 2777, 2778, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2792, 2795, 2798, 2800, 2802, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 3390, 2822, 2823, 2824, 2825, 2826, 2828, 2830, 2831, 3422, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2850, 2851, 2852, 2853, 2856, 2857, 2859, 2860, 2861, 2862, 3014, 2864, 2866, 2867, 2869, 2870, 2871, 2872, 2873, 2875, 2876, 2880, 2883, 2884, 2885, 2887, 2888, 2889, 2891, 2892, 2893, 2894, 2896, 2897, 2900, 2903, 2904, 2905, 2906, 2907, 2909, 2911, 2912, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2948, 2949, 2950, 2952, 2953, 2954, 2958, 2959, 2960, 2961, 2962, 2966, 2967, 2971, 2972, 2973, 2974, 2975, 2976, 2978, 2983, 2984, 2990, 2995, 2997, 3002, 3003, 3004, 3006, 3008, 3011, 3012, 3013, 3015, 3019, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3036, 3037, 3038, 3039, 3043, 3045, 3046, 3047, 3048, 3052, 3053, 3057, 3059, 3060, 3061, 3063, 3064, 3065, 3066, 3067, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3085, 3086, 3087, 3088, 3093, 3094, 3095, 3097, 3101, 3102, 3103, 3104, 3105, 3108, 3110, 3111, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3124, 3126, 3127, 3128, 3129, 3130, 3131, 3137, 3138, 3139, 3140, 3141, 3145, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3155, 3156, 3159, 3161, 3162, 3163, 3166, 3171, 3172, 3173, 3175, 3178, 3180, 3181, 3183, 3184, 3185, 3187, 3188, 3189, 3191, 3192, 3193, 3194, 3198, 3203, 3208, 3209, 3210, 3211, 3212, 3213, 3214, 3216, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3236, 3237, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3263, 3264, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3364, 3365, 3369, 3371, 3372, 3373, 3375, 3376, 3377, 3380, 3382, 3383, 3384, 3385, 3386, 3389, 3391, 3394, 3396, 3397, 3402, 3403, 3404, 3405, 3408, 3415, 3416, 3417, 3418, 3419, 3420, 3423, 3424, 3425, 3426, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3438, 3440, 3441, 3442, 3443, 3444, 3445, 3447, 3448, 3450, 3451, 3452, 3453, 3454, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3470, 3473, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3513, 3518, 3524, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3542, 3543, 3544, 3545, 3546, 3547, 3551, 3552, 3556, 3557, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3573, 3574, 3575, 3576, 3579, 3580, 3582, 3583, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3614, 3615, 3616, 3620, 3621, 3622, 3623, 3629, 3630, 3631, 3632, 3636, 3638, 3639, 3640, 3642, 3645, 3646, 3650, 3657, 3659, 3662, 3664, 3665, 3666, 3667, 3668, 3669, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, 3701, 3702, 3720, 3735, 3738, 3740, 3741, 3743, 3747, 3749, 3753, 3762, 3765, 3766, 3767, 3768, 3769, 3770, 3772, 3778, 3779, 3782, 3785, 3787, 3788, 3789, 3790, 3791, 3792, 3795, 3798, 3800, 3804, 3805, 3806, 3807, 3808, 3811, 3812, 3814, 3815, 3817, 3818, 3819, 3820, 3821, 3822, 3823, 3824, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3846, 3848, 3850, 3859, 3860, 3862, 3863, 3872, 3878, 3884, 3893, 3895, 3896, 3897, 3898, 3901, 3902, 3904, 3910, 3914, 3918, 3923, 3924, 3926, 3927, 3928, 3930, 3931, 3932, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3948, 3949, 3950, 3995, 3996, 4001, 4003, 4004, 4006, 4012, 4015, 4030, 4031, 4032, 4033, 4034, 4035, 4037, 4038, 4040, 4041, 4043, 4045, 4046, 4059, 4062, 4063, 4065, 4066, 4070, 4075, 4078, 4079, 4081, 4082, 4088, 4090, 4091, 4094, 4096, 4101, 4102, 4103, 4108, 4119, 4142, 4158, 4166, 4175, 4176, 4180, 4185, 4201, 4202, 4203, 4204, 4206, 4208, 4209, 4211, 4214, 4218, 4221, 4224, 4225, 4226, 4227, 4231, 4232, 4233, 4234, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4260, 4268, 4271, 4272, 4278, 4283, 4284, 4285, 4286, 4290, 4294, 4296, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4305, 4306, 4307, 4308, 4310, 4311, 4312, 4313, 4314, 4315, 4316, 4326, 4335, 4336, 4337, 4338, 4339, 4340, 4341, 4342, 4343, 4344, 4346, 4347, 4351, 4352, 4354, 4355, 4356, 4357, 4361, 4362, 4363, 4364, 4365, 4366, 4368, 4369, 4370, 4376, 4377, 4378, 4379, 4380, 4381, 4385, 4389, 4390, 4392, 4393, 4394, 4395, 4396, 4398, 4408, 4410, 4415, 4416, 4417, 4418, 4419, 4420, 4421, 4422, 4423, 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4432, 4433, 4434, 4435, 4436, 4437, 4438, 4443, 4446, 4447, 4448, 4449, 4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4458, 4459, 4460, 4461, 4462, 4463, 4464, 4465, 4466, 4468, 4469, 4470, 4472, 4473, 4474, 4475, 4478, 4479, 4480, 4482, 4483, 4484, 4486, 4487, 4488, 4489, 4490, 4491, 4493, 4495, 4498, 4499, 4500, 4501, 4503, 4504, 4505, 4506, 4507, 4508, 4509, 4510, 4511, 4512, 4513, 4517, 4519, 4520, 4521, 4522, 4523, 4527, 4528, 4532, 4533, 4534, 4536, 4538, 4539, 4540, 4541, 4542, 4543, 4544, 4546, 4547, 4548, 4549, 4550, 4551, 4552, 4559, 4560, 4561, 4562, 4563, 4564, 4565, 4566, 4567, 4568, 4569, 4570, 4576, 4577, 4579, 4580, 4581, 4582, 4583, 4584, 4585, 4586, 4587, 4588, 4589, 4590, 4591, 4592, 4593, 4594, 4598, 4599, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4611, 4612, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, 4628, 4630, 4631, 4632, 4633, 4642, 4643, 4644, 4645, 4646, 4647, 4649, 4652, 4653, 4654, 4656, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, 4680, 4681, 4682, 4683, 4684, 4685, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4731, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4762, 4763, 4764, 4770, 4783, 4787, 4788, 4789, 4790, 4791, 4792, 4793, 4794, 4795, 4796, 4797, 4798, 4799, 4800, 4801, 4802, 4804, 4805, 4806, 4807, 4808, 4810, 4811, 4812, 4813, 4814, 4815, 4816, 4819, 4820, 4822, 4823, 4824, 4827, 4828, 4829, 4830, 4831, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840, 4841, 4842, 4843, 4844, 4845, 4846, 4847, 4848, 4849, 4850, 4851, 4852, 4853, 4855, 4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865, 4866, 4867, 4868, 4869, 4870, 4871, 4872, 4873, 4874, 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4888, 4889, 4890, 4892, 4894, 4896, 4897, 4898, 4899, 4902, 4904, 4905, 4906, 4907, 4909, 4910, 4911, 4912, 4913, 4914, 4915, 4916, 4919, 4923, 4924, 4928, 4929, 4930, 4931, 4932, 4934, 4935, 4938, 4939, 4940, 4941, 4942, 4944, 4945, 4946, 4947, 4949, 4951, 4952, 4955, 4956, 4957, 4958, 4959, 4960) } - internal val templates: IntArray by lazy { intArrayOf(2375, 2854, 2666, 2665, 2664, 2886, 2908, 3388, 2629, 418, 2799, 2797, 2693, 2384, 2390, 2801, 2898, 2613, 2612, 285, 2342, 2803, 2910, 3238, 4190, 2552, 4933, 2602, 2050, 2380, 3722, 2115, 2729, 2385, 3239, 1336, 4210, 4230, 3721, 2570, 2727, 1867, 4205, 2126, 2167, 2173, 4572, 283, 2116, 4514, 3400, 3421, 2073, 2353, 3718, 452, 2761, 2793, 2794, 3401, 3717, 2762, 3649, 609, 1711, 3726, 1868, 2737, 3729, 2743, 3392, 616, 617, 2779, 3090, 3704, 1659, 2796, 3648, 303, 614, 69, 711, 621, 2352, 4228, 1121, 2494, 3471, 3844, 1242, 2202, 2581, 3393, 2165, 3733, 714, 1763, 1964, 2749, 2758, 2969, 4235, 3395, 3407, 136, 594, 596, 2569, 2724, 1865, 4223, 3041, 610, 2289, 2592, 3881, 1302, 4222, 3517, 3654, 3655, 158, 2080, 2082, 2117, 2849, 4371, 2171, 2379, 2522, 3643, 214, 284, 1276, 2014, 4803, 3512, 3521, 3522, 67, 83, 218, 619, 4608, 3541, 1360, 4317, 3366, 3731, 726, 1023, 1372, 2393, 2485, 2747, 4373, 89, 2392, 2407, 2922, 624, 1657, 1954, 2836, 4502, 3414, 1577, 2101, 2293, 2583, 4554, 3409, 3475, 3525, 650, 1888, 3936, 3174, 3516, 3562, 3626, 3845, 1317, 1866, 2045, 2431, 2718, 3864, 4573, 3428, 3474, 1841, 1863, 3363, 593, 1292, 1346, 1371, 1953, 3503, 3705, 221, 1701, 2750, 2947, 3092, 3160, 3449, 258, 591, 1026, 1379, 1965, 1989, 4143, 3446, 3572, 655, 1342, 1717, 2051, 3168, 3367, 3628, 3647, 710, 1283, 1370, 1382, 1658, 1732, 1895, 2381, 2484, 2582, 3951, 4229, 4439, 3427, 3495, 3641, 649, 699, 1044, 2618, 3186, 3305, 3708, 108, 184, 606, 721, 1081, 1969, 2049, 2111, 2169, 2417, 2498, 2754, 2790, 2834, 3956, 4485, 4826, 3387, 3458, 3619, 160, 623, 701, 1332, 1333, 1345, 1520, 1660, 2166, 2170, 2263, 2416, 2644, 4198, 4515, 3123, 3215, 3262, 3340, 3554, 3709, 3719, 703, 1183, 1572, 1897, 2258, 2261, 2497, 2755, 2775, 2776, 2944, 2945, 3966, 3986, 4219, 4476, 4809, 4825, 3627, 3644, 3750, 1378, 1492, 1584, 1703, 1955, 2437, 2449, 2774, 4162, 4220, 4516, 4607, 3089, 3091, 3106, 3624, 3637, 3803, 723, 1024, 1832, 2138, 2203, 2427, 2770, 2771, 3971, 4217, 4293, 4304, 3293, 3413, 91, 93, 595, 715, 1027, 1350, 1355, 2020, 2333, 2432, 2717, 2769, 2773, 3933, 4555, 4887, 3020, 3021, 3523, 3587, 3730, 94, 1251, 1259, 1353, 1377, 1519, 1583, 1880, 2186, 2218, 2477, 2495, 2745, 3873, 3874, 4216, 4382, 4445, 4891, 3339, 3378, 3379, 3457, 3613, 299, 599, 618, 700, 1109, 1117, 1175, 1367, 1518, 1626, 1948, 2130, 2136, 2154, 2221, 2447, 2452, 2454, 2677, 2710, 2768, 2946, 2963, 2964, 4187, 4213, 4330, 3022, 3176, 3553, 3586, 3755, 211, 585, 590, 605, 717, 720, 906, 990, 1084, 1159, 1334, 1470, 1524, 1705, 1886, 1906, 1926, 1961, 1991, 2072, 2316, 2430, 2496, 2951, 3900, 3952, 4170, 4556, 4574, 4575, 4774, 4936, 3083, 3439, 3634, 3635, 92, 96, 269, 603, 648, 712, 980, 1331, 1707, 1887, 1944, 2114, 2425, 2451, 2453, 2456, 2545, 2683, 2719, 2901, 2913, 4261, 4558, 4786, 2996, 3261, 3294, 3374, 3472, 3591, 3625, 208, 277, 316, 329, 330, 1287, 1352, 1376, 1521, 1522, 1949, 2019, 2044, 2113, 2220, 2248, 2299, 2419, 2434, 2446, 2720, 2723, 2804, 2805, 3871, 4571, 4769, 4943, 3018, 3406, 3410, 3459, 3515, 3670, 3707, 3760, 6, 244, 304, 600, 604, 1047, 1221, 1286, 1354, 1359, 1708, 1709, 1884, 1957, 1960, 2018, 2021, 2152, 2187, 2235, 2418, 2426, 2646, 2752, 2791, 2868, 3868, 3869, 3929, 4186, 4772, 4784, 4785, 4954, 3456, 3578, 3585, 3590, 3652, 3660, 268, 318, 322, 331, 583, 707, 722, 1076, 1160, 1164, 1284, 1285, 1312, 1517, 1710, 1828, 1889, 2009, 2222, 2228, 2389, 2415, 2421, 2448, 2580, 2681, 3934, 4159, 4212, 4275, 4374, 4444, 4655, 4773, 4948, 3069, 3154, 3519, 3520, 3618, 3651, 65, 210, 274, 587, 608, 613, 708, 713, 984, 1075, 1167, 1369, 1713, 1743, 1829, 1834, 1849, 1885, 2048, 2081, 2278, 2296, 2305, 2414, 2468, 2480, 2772, 4197, 3049, 3399, 3584, 3653, 3661, 3706, 90, 207, 288, 320, 323, 324, 349, 597, 607, 709, 855, 905, 1166, 1169, 1252, 1437, 1890, 2005, 2015, 2420, 2429, 2473, 2751, 2789, 2943, 2957, 3906, 4817, 4818, 4821, 4917, 3023, 3054, 3107, 3177, 3235, 3248, 3249, 3412, 3560, 3561, 3633, 3656, 3663, 3714, 110, 186, 190, 191, 212, 321, 327, 328, 352, 375, 580, 582, 589, 625, 727, 851, 977, 1077, 1118, 1147, 1243, 1304, 1314, 1746, 1830, 1831, 1839, 1950, 1951, 1952, 2041, 2254, 2256, 2285, 2297, 2298, 2320, 2388, 2422, 2423, 2479, 2585, 2586, 2669, 2684, 2716, 2721, 2722, 2759, 2806, 2807, 3852, 3870, 3916, 3970, 4215, 4309, 4327, 4345, 4372, 4442, 4477, 4529, 4553, 4614, 4854, 4937, 4953, 3056, 3158, 3182, 3196, 3217, 3398, 3411, 3555, 3559, 3589, 3617, 3748, 3758, 3759, 3771, 3773, 3780, 5, 8, 82, 185, 188, 192, 257, 276, 325, 326, 348, 351, 356, 598, 620, 658, 696, 705, 856, 985, 1048, 1122, 1148, 1149, 1168, 1179, 1239, 1383, 1491, 1649, 1693, 1704, 1850, 1881, 1947, 1993, 2006, 2027, 2250, 2255, 2308, 2314, 2315, 2322, 2433, 2619, 2655, 2829, 3917, 3925, 3955, 3972, 4139, 4174, 4188, 4236, 4276, 4328, 4367, 4530, 4557, 4950, 3079, 3125, 3201, 3202, 3207, 3265, 3549, 154, 259, 261, 347, 350, 353, 579, 602, 612, 702, 706, 982, 1078, 1381, 1593, 1833, 1925, 1987, 1990, 2306, 2319, 2391, 2438, 2584, 2632, 2874, 3875, 3922, 3988, 4155, 4526, 4613, 3455, 3548, 3550, 3558, 3577, 3588, 3756, 3777, 3797, 95, 196, 203, 204, 205, 242, 243, 346, 581, 586, 601, 615, 622, 626, 627, 691, 716, 725, 983, 986, 1085, 1089, 1161, 1174, 1204, 1349, 1471, 1506, 1688, 1689, 1691, 1726, 1851, 1891, 2233, 2311, 2321, 2428, 2450, 2458, 2965, 4141, 4171, 4172, 4262, 4287, 4325, 4440, 4496, 4537, 4893, 4918) } - internal val argNames: Map> by lazy { mapOf(5 to arrayOf("n"), 6 to arrayOf("n"), 7 to arrayOf("who"), 8 to arrayOf("title"), 65 to arrayOf("state"), 67 to arrayOf("listen"), 69 to arrayOf("listen"), 82 to arrayOf("version"), 83 to arrayOf("count", "plural"), 89 to arrayOf("size", "limit"), 90 to arrayOf("name"), 91 to arrayOf("dir"), 92 to arrayOf("dir"), 93 to arrayOf("name"), 94 to arrayOf("name"), 95 to arrayOf("path"), 96 to arrayOf("path"), 97 to arrayOf("name"), 108 to arrayOf("first"), 110 to arrayOf("n"), 136 to arrayOf("count", "plural"), 154 to arrayOf("tool"), 158 to arrayOf("n"), 160 to arrayOf("name"), 184 to arrayOf("pid", "cmd"), 185 to arrayOf("title", "ago"), 186 to arrayOf("name", "who", "n"), 188 to arrayOf("line"), 190 to arrayOf("n"), 191 to arrayOf("n"), 192 to arrayOf("n"), 196 to arrayOf("name"), 203 to arrayOf("when"), 204 to arrayOf("text", "when"), 205 to arrayOf("when"), 207 to arrayOf("count", "plural"), 208 to arrayOf("count", "plural"), 210 to arrayOf("took", "ago"), 211 to arrayOf("ago"), 212 to arrayOf("kind"), 214 to arrayOf("kind", "code", "why"), 218 to arrayOf("clock"), 221 to arrayOf("build"), 242 to arrayOf("step"), 243 to arrayOf("turn"), 244 to arrayOf("branch"), 257 to arrayOf("step", "total"), 258 to arrayOf("step", "total"), 259 to arrayOf("when"), 261 to arrayOf("tool"), 268 to arrayOf("count", "plural"), 269 to arrayOf("count", "total"), 274 to arrayOf("old", "new"), 276 to arrayOf("version"), 277 to arrayOf("count"), 278 to arrayOf("tag"), 283 to arrayOf("version"), 284 to arrayOf("old", "version"), 285 to arrayOf("version"), 288 to arrayOf("version"), 299 to arrayOf("project", "location"), 303 to arrayOf("account"), 304 to arrayOf("account"), 316 to arrayOf("n"), 318 to arrayOf("n"), 320 to arrayOf("minute"), 321 to arrayOf("time"), 322 to arrayOf("time"), 323 to arrayOf("clock"), 324 to arrayOf("clock", "took"), 325 to arrayOf("clock"), 326 to arrayOf("clock", "took"), 327 to arrayOf("clock"), 328 to arrayOf("clock", "took"), 329 to arrayOf("clock"), 330 to arrayOf("clock", "took"), 331 to arrayOf("clock"), 346 to arrayOf("target"), 347 to arrayOf("target"), 348 to arrayOf("target"), 349 to arrayOf("target"), 350 to arrayOf("target"), 351 to arrayOf("target"), 352 to arrayOf("target"), 353 to arrayOf("target"), 356 to arrayOf("name"), 375 to arrayOf("t"), 418 to arrayOf("minutes", "plural"), 452 to arrayOf("path"), 579 to arrayOf("count"), 580 to arrayOf("count"), 581 to arrayOf("title"), 582 to arrayOf("path"), 583 to arrayOf("path", "error"), 584 to arrayOf("first", "last", "count"), 585 to arrayOf("task", "step"), 586 to arrayOf("count"), 587 to arrayOf("path"), 588 to arrayOf("count", "plural"), 589 to arrayOf("label"), 590 to arrayOf("provider"), 591 to arrayOf("version"), 593 to arrayOf("key"), 594 to arrayOf("device"), 595 to arrayOf("kind", "device"), 596 to arrayOf("status"), 597 to arrayOf("kind", "title"), 598 to arrayOf("layer"), 599 to arrayOf("error"), 600 to arrayOf("page"), 601 to arrayOf("page", "kind", "total"), 602 to arrayOf("reason"), 603 to arrayOf("tag"), 604 to arrayOf("tag"), 605 to arrayOf("title"), 606 to arrayOf("title"), 607 to arrayOf("text", "time"), 608 to arrayOf("kind", "device"), 609 to arrayOf("device"), 610 to arrayOf("device"), 611 to arrayOf("word"), 612 to arrayOf("word", "kind", "count"), 613 to arrayOf("error"), 614 to arrayOf("count"), 615 to arrayOf("time", "relative", "rel", "zoned", "zone"), 616 to arrayOf("zone"), 617 to arrayOf("zone"), 618 to arrayOf("id", "state", "count", "age"), 619 to arrayOf("id"), 620 to arrayOf("name"), 621 to arrayOf("name"), 622 to arrayOf("clock", "count", "plural"), 623 to arrayOf("name"), 624 to arrayOf("name"), 625 to arrayOf("name"), 626 to arrayOf("count"), 627 to arrayOf("count"), 631 to arrayOf("name", "state"), 632 to arrayOf("author", "place", "state"), 633 to arrayOf("title", "state"), 648 to arrayOf("error"), 649 to arrayOf("error"), 650 to arrayOf("host"), 655 to arrayOf("email"), 658 to arrayOf("version"), 660 to arrayOf("first", "last", "count"), 661 to arrayOf("n"), 662 to arrayOf("n"), 691 to arrayOf("ref"), 696 to arrayOf("name"), 697 to arrayOf("name"), 699 to arrayOf("name"), 700 to arrayOf("name"), 701 to arrayOf("action"), 702 to arrayOf("label"), 703 to arrayOf("count", "plural"), 705 to arrayOf("path"), 706 to arrayOf("word", "kind", "count"), 707 to arrayOf("name"), 708 to arrayOf("name"), 709 to arrayOf("name"), 710 to arrayOf("name"), 711 to arrayOf("url"), 712 to arrayOf("count"), 713 to arrayOf("count"), 714 to arrayOf("device"), 715 to arrayOf("device"), 716 to arrayOf("count"), 717 to arrayOf("label"), 718 to arrayOf("label"), 719 to arrayOf("label"), 720 to arrayOf("title"), 721 to arrayOf("title"), 722 to arrayOf("state"), 723 to arrayOf("open", "kind"), 725 to arrayOf("count"), 726 to arrayOf("email"), 727 to arrayOf("email"), 851 to arrayOf("at", "count"), 855 to arrayOf("name"), 856 to arrayOf("name"), 905 to arrayOf("name"), 906 to arrayOf("name"), 977 to arrayOf("count"), 980 to arrayOf("name"), 981 to arrayOf("name", "count"), 982 to arrayOf("label", "n"), 983 to arrayOf("action"), 984 to arrayOf("count", "plural"), 985 to arrayOf("count"), 986 to arrayOf("waiting", "busy", "done"), 990 to arrayOf("count", "plural"), 1023 to arrayOf("name"), 1024 to arrayOf("name"), 1026 to arrayOf("seconds", "long"), 1027 to arrayOf("size", "triangles", "delayed", "waited", "built"), 1028 to arrayOf("size", "delayed", "waited"), 1044 to arrayOf("name"), 1047 to arrayOf("name"), 1048 to arrayOf("count"), 1075 to arrayOf("state"), 1076 to arrayOf("bytes"), 1077 to arrayOf("count"), 1078 to arrayOf("when"), 1079 to arrayOf("state", "name"), 1080 to arrayOf("name", "state"), 1081 to arrayOf("reason", "code"), 1084 to arrayOf("kind", "code"), 1085 to arrayOf("number"), 1089 to arrayOf("x", "y"), 1096 to arrayOf("state"), 1097 to arrayOf("label", "example"), 1109 to arrayOf("text"), 1117 to arrayOf("error"), 1118 to arrayOf("kind", "count"), 1121 to arrayOf("name"), 1122 to arrayOf("n"), 1147 to arrayOf("ago"), 1148 to arrayOf("name"), 1149 to arrayOf("kind", "place", "hub"), 1159 to arrayOf("label"), 1160 to arrayOf("word"), 1161 to arrayOf("count"), 1164 to arrayOf("hub"), 1166 to arrayOf("count"), 1167 to arrayOf("state"), 1168 to arrayOf("label"), 1169 to arrayOf("label"), 1174 to arrayOf("state", "text"), 1175 to arrayOf("text"), 1177 to arrayOf("question"), 1179 to arrayOf("label"), 1183 to arrayOf("title"), 1204 to arrayOf("count"), 1205 to arrayOf("name", "counts"), 1219 to arrayOf("n"), 1221 to arrayOf("mode"), 1238 to arrayOf("first", "last", "total"), 1239 to arrayOf("count"), 1242 to arrayOf("n"), 1243 to arrayOf("who", "name"), 1251 to arrayOf("name"), 1252 to arrayOf("when"), 1259 to arrayOf("why"), 1276 to arrayOf("name"), 1283 to arrayOf("kind"), 1284 to arrayOf("title"), 1285 to arrayOf("title"), 1286 to arrayOf("title"), 1287 to arrayOf("title"), 1292 to arrayOf("name"), 1302 to arrayOf("heard"), 1303 to arrayOf("out", "heard"), 1304 to arrayOf("heard"), 1312 to arrayOf("name", "mb"), 1314 to arrayOf("name"), 1317 to arrayOf("platform"), 1321 to arrayOf("heard", "out", "yes"), 1331 to arrayOf("name", "done", "total", "percent"), 1332 to arrayOf("name", "done"), 1333 to arrayOf("name"), 1334 to arrayOf("error"), 1336 to arrayOf("mb"), 1342 to arrayOf("mb"), 1345 to arrayOf("n"), 1346 to arrayOf("n"), 1349 to arrayOf("n"), 1350 to arrayOf("pct"), 1351 to arrayOf("px"), 1352 to arrayOf("version"), 1353 to arrayOf("tag"), 1354 to arrayOf("tag"), 1355 to arrayOf("hub"), 1359 to arrayOf("tag"), 1360 to arrayOf("tag"), 1367 to arrayOf("when"), 1369 to arrayOf("tag"), 1370 to arrayOf("tag", "when"), 1371 to arrayOf("tag"), 1372 to arrayOf("tag", "when"), 1376 to arrayOf("channel"), 1377 to arrayOf("tag"), 1378 to arrayOf("app", "hub"), 1379 to arrayOf("hub", "app"), 1381 to arrayOf("key"), 1382 to arrayOf("key"), 1383 to arrayOf("why"), 1437 to arrayOf("n"), 1470 to arrayOf("title"), 1471 to arrayOf("note"), 1491 to arrayOf("title"), 1492 to arrayOf("more"), 1506 to arrayOf("bots"), 1517 to arrayOf("name"), 1518 to arrayOf("name", "time"), 1519 to arrayOf("name", "n"), 1520 to arrayOf("name", "time", "n"), 1521 to arrayOf("to"), 1522 to arrayOf("to", "step"), 1524 to arrayOf("note"), 1572 to arrayOf("why"), 1577 to arrayOf("e"), 1583 to arrayOf("max"), 1584 to arrayOf("secs", "max", "mib"), 1593 to arrayOf("path"), 1626 to arrayOf("secs"), 1649 to arrayOf("pct", "scope"), 1657 to arrayOf("n"), 1658 to arrayOf("n"), 1659 to arrayOf("n"), 1660 to arrayOf("n"), 1688 to arrayOf("d", "h"), 1689 to arrayOf("h", "m"), 1690 to arrayOf("m"), 1691 to arrayOf("window", "pct"), 1693 to arrayOf("when"), 1695 to arrayOf("label", "e"), 1697 to arrayOf("from", "to", "total"), 1701 to arrayOf("messages", "lines", "left"), 1703 to arrayOf("pct", "view", "max"), 1704 to arrayOf("pct"), 1705 to arrayOf("done", "total"), 1707 to arrayOf("n"), 1708 to arrayOf("n"), 1709 to arrayOf("time"), 1710 to arrayOf("view", "max"), 1711 to arrayOf("view", "max"), 1713 to arrayOf("more"), 1717 to arrayOf("n"), 1726 to arrayOf("n"), 1732 to arrayOf("page"), 1743 to arrayOf("title"), 1746 to arrayOf("n"), 1763 to arrayOf("name"), 1828 to arrayOf("line"), 1829 to arrayOf("quote"), 1830 to arrayOf("n"), 1831 to arrayOf("n"), 1832 to arrayOf("n"), 1833 to arrayOf("n"), 1834 to arrayOf("n"), 1839 to arrayOf("held"), 1840 to arrayOf("machine"), 1841 to arrayOf("machine"), 1849 to arrayOf("count", "total"), 1850 to arrayOf("count"), 1851 to arrayOf("n"), 1863 to arrayOf("name"), 1865 to arrayOf("n", "c", "total"), 1866 to arrayOf("n", "c"), 1867 to arrayOf("n", "c", "total", "before"), 1868 to arrayOf("n", "c", "before"), 1880 to arrayOf("name"), 1881 to arrayOf("path"), 1884 to arrayOf("file"), 1885 to arrayOf("path", "n"), 1886 to arrayOf("why"), 1887 to arrayOf("n"), 1888 to arrayOf("name"), 1889 to arrayOf("name"), 1890 to arrayOf("name"), 1891 to arrayOf("n"), 1892 to arrayOf("shown", "n"), 1895 to arrayOf("path"), 1897 to arrayOf("n"), 1906 to arrayOf("status"), 1923 to arrayOf("name", "pct"), 1924 to arrayOf("name", "mb"), 1925 to arrayOf("name"), 1926 to arrayOf("name", "why"), 1944 to arrayOf("machine"), 1947 to arrayOf("n"), 1948 to arrayOf("ref"), 1949 to arrayOf("ref", "sheet"), 1950 to arrayOf("name"), 1951 to arrayOf("name"), 1952 to arrayOf("file", "folder"), 1953 to arrayOf("name", "error"), 1954 to arrayOf("name", "status"), 1955 to arrayOf("name", "error"), 1957 to arrayOf("name"), 1960 to arrayOf("code"), 1961 to arrayOf("error"), 1964 to arrayOf("error"), 1965 to arrayOf("error"), 1969 to arrayOf("error"), 1987 to arrayOf("done", "of"), 1989 to arrayOf("why"), 1990 to arrayOf("path"), 1991 to arrayOf("error"), 1992 to arrayOf("secs"), 1993 to arrayOf("secs"), 2005 to arrayOf("code"), 2006 to arrayOf("code"), 2009 to arrayOf("state"), 2014 to arrayOf("hide", "copy", "paste"), 2015 to arrayOf("n"), 2018 to arrayOf("name"), 2019 to arrayOf("name", "folder"), 2020 to arrayOf("name"), 2021 to arrayOf("name", "percent"), 2027 to arrayOf("folder"), 2037 to arrayOf("w", "h"), 2041 to arrayOf("path"), 2044 to arrayOf("why"), 2045 to arrayOf("mb"), 2048 to arrayOf("n"), 2049 to arrayOf("delete", "undo"), 2050 to arrayOf("delete", "undo"), 2051 to arrayOf("undo"), 2072 to arrayOf("what", "secs"), 2073 to arrayOf("file", "holder"), 2080 to arrayOf("what"), 2081 to arrayOf("what"), 2082 to arrayOf("editor", "why"), 2101 to arrayOf("files"), 2111 to arrayOf("why"), 2113 to arrayOf("title"), 2114 to arrayOf("title"), 2115 to arrayOf("version"), 2116 to arrayOf("version", "size", "folder"), 2117 to arrayOf("version", "size", "folder"), 2126 to arrayOf("title"), 2130 to arrayOf("dir", "files"), 2136 to arrayOf("why"), 2138 to arrayOf("code"), 2152 to arrayOf("origin"), 2154 to arrayOf("why"), 2165 to arrayOf("dir"), 2166 to arrayOf("path"), 2167 to arrayOf("home", "other"), 2169 to arrayOf("path"), 2170 to arrayOf("code", "log"), 2171 to arrayOf("log"), 2173 to arrayOf("addr"), 2186 to arrayOf("home"), 2187 to arrayOf("addr"), 2202 to arrayOf("dir", "why"), 2203 to arrayOf("dir"), 2218 to arrayOf("phase"), 2220 to arrayOf("why"), 2221 to arrayOf("what"), 2222 to arrayOf("code"), 2228 to arrayOf("label"), 2233 to arrayOf("kind"), 2235 to arrayOf("project"), 2248 to arrayOf("what"), 2250 to arrayOf("when"), 2254 to arrayOf("n"), 2255 to arrayOf("n"), 2256 to arrayOf("n"), 2258 to arrayOf("agent"), 2259 to arrayOf("effort"), 2261 to arrayOf("n"), 2263 to arrayOf("model"), 2278 to arrayOf("word"), 2285 to arrayOf("more", "step"), 2289 to arrayOf("name"), 2293 to arrayOf("max", "skipped"), 2296 to arrayOf("name"), 2297 to arrayOf("n"), 2298 to arrayOf("name"), 2299 to arrayOf("name"), 2305 to arrayOf("n"), 2306 to arrayOf("name"), 2308 to arrayOf("price"), 2311 to arrayOf("name"), 2313 to arrayOf("name"), 2314 to arrayOf("name"), 2315 to arrayOf("name"), 2316 to arrayOf("text"), 2319 to arrayOf("key"), 2320 to arrayOf("key"), 2321 to arrayOf("pct"), 2322 to arrayOf("when"), 2333 to arrayOf("n", "upstream"), 2342 to arrayOf("mb"), 2352 to arrayOf("path"), 2353 to arrayOf("path"), 2375 to arrayOf("id"), 2379 to arrayOf("model"), 2380 to arrayOf("platform"), 2381 to arrayOf("version"), 2384 to arrayOf("version", "from", "into"), 2385 to arrayOf("version", "from"), 2388 to arrayOf("version", "path"), 2389 to arrayOf("version", "path"), 2390 to arrayOf("version", "pin", "from"), 2391 to arrayOf("path"), 2392 to arrayOf("version", "path"), 2393 to arrayOf("version", "path", "set"), 2407 to arrayOf("turns", "input", "cread", "cwrite", "output", "cost"), 2414 to arrayOf("tool"), 2415 to arrayOf("tool"), 2416 to arrayOf("tool", "word"), 2417 to arrayOf("tool", "word"), 2418 to arrayOf("tool"), 2419 to arrayOf("tool"), 2420 to arrayOf("due"), 2421 to arrayOf("due"), 2422 to arrayOf("due"), 2423 to arrayOf("due"), 2424 to arrayOf("zone"), 2425 to arrayOf("zone"), 2426 to arrayOf("zone"), 2427 to arrayOf("zone"), 2428 to arrayOf("n"), 2429 to arrayOf("who"), 2430 to arrayOf("n", "who"), 2431 to arrayOf("harness"), 2432 to arrayOf("path"), 2433 to arrayOf("path"), 2434 to arrayOf("path"), 2437 to arrayOf("error", "line"), 2438 to arrayOf("label"), 2446 to arrayOf("who"), 2447 to arrayOf("who"), 2448 to arrayOf("label", "left", "when"), 2449 to arrayOf("left"), 2450 to arrayOf("name", "left"), 2451 to arrayOf("used"), 2452 to arrayOf("used", "limit"), 2453 to arrayOf("used", "reason"), 2454 to arrayOf("used", "limit", "reason"), 2456 to arrayOf("provider"), 2457 to arrayOf("used", "window", "pct"), 2458 to arrayOf("rate"), 2468 to arrayOf("n", "r"), 2473 to arrayOf("time", "n"), 2477 to arrayOf("n", "m"), 2479 to arrayOf("pct"), 2480 to arrayOf("cost", "n"), 2484 to arrayOf("in", "out", "cread", "cwrite"), 2485 to arrayOf("in", "out", "cread", "cwrite", "n"), 2494 to arrayOf("turns", "input", "cread", "cwrite", "output"), 2495 to arrayOf("left", "when"), 2496 to arrayOf("left", "when"), 2497 to arrayOf("left", "when"), 2498 to arrayOf("left", "when"), 2522 to arrayOf("n"), 2545 to arrayOf("when"), 2552 to arrayOf("phrase", "now"), 2563 to arrayOf("s"), 2569 to arrayOf("now"), 2570 to arrayOf("now", "nudge", "sent", "undone"), 2580 to arrayOf("e"), 2581 to arrayOf("a", "ams", "b", "bms"), 2582 to arrayOf("ms"), 2583 to arrayOf("e"), 2584 to arrayOf("t"), 2585 to arrayOf("t"), 2586 to arrayOf("t"), 2592 to arrayOf("why"), 2602 to arrayOf("apps"), 2612 to arrayOf("n"), 2613 to arrayOf("n", "k"), 2618 to arrayOf("stt", "conf"), 2619 to arrayOf("words"), 2629 to arrayOf("into"), 2632 to arrayOf("origin"), 2644 to arrayOf("url"), 2646 to arrayOf("url"), 2654 to arrayOf("i", "n"), 2655 to arrayOf("d", "n"), 2664 to arrayOf("version"), 2665 to arrayOf("version"), 2666 to arrayOf("version"), 2669 to arrayOf("path"), 2677 to arrayOf("addr"), 2681 to arrayOf("label"), 2683 to arrayOf("label"), 2684 to arrayOf("label"), 2688 to arrayOf("label"), 2693 to arrayOf("from"), 2710 to arrayOf("done", "of"), 2716 to arrayOf("n"), 2717 to arrayOf("t", "m"), 2718 to arrayOf("m"), 2719 to arrayOf("b", "m"), 2720 to arrayOf("r", "p"), 2721 to arrayOf("n"), 2722 to arrayOf("n"), 2723 to arrayOf("n"), 2724 to arrayOf("n"), 2727 to arrayOf("n"), 2729 to arrayOf("n"), 2737 to arrayOf("n"), 2743 to arrayOf("name", "gb", "path"), 2745 to arrayOf("path", "why"), 2747 to arrayOf("names"), 2749 to arrayOf("why"), 2750 to arrayOf("p", "pn", "t", "tn", "e", "en"), 2751 to arrayOf("done", "total"), 2752 to arrayOf("n"), 2753 to arrayOf("what"), 2754 to arrayOf("n"), 2755 to arrayOf("n"), 2758 to arrayOf("what"), 2759 to arrayOf("n"), 2761 to arrayOf("why", "from"), 2762 to arrayOf("why"), 2768 to arrayOf("path"), 2769 to arrayOf("path", "who"), 2770 to arrayOf("path"), 2771 to arrayOf("path", "cmd"), 2772 to arrayOf("version", "path"), 2773 to arrayOf("version", "path"), 2774 to arrayOf("version", "path", "who"), 2775 to arrayOf("version", "path"), 2776 to arrayOf("version", "path", "cmd"), 2779 to arrayOf("cmd"), 2789 to arrayOf("name", "version", "path"), 2790 to arrayOf("path", "why"), 2791 to arrayOf("name"), 2793 to arrayOf("version", "cli"), 2794 to arrayOf("cli"), 2796 to arrayOf("version"), 2797 to arrayOf("version"), 2799 to arrayOf("version"), 2801 to arrayOf("version"), 2803 to arrayOf("computer"), 2804 to arrayOf("version", "cli"), 2805 to arrayOf("cli"), 2806 to arrayOf("version", "cli"), 2807 to arrayOf("cli"), 2829 to arrayOf("n"), 2834 to arrayOf("code"), 2836 to arrayOf("e"), 2849 to arrayOf("n"), 2854 to arrayOf("channel"), 2868 to arrayOf("project"), 2874 to arrayOf("n"), 2886 to arrayOf("m"), 2898 to arrayOf("m"), 2901 to arrayOf("m"), 2908 to arrayOf("pages"), 2910 to arrayOf("name"), 2913 to arrayOf("name"), 2922 to arrayOf("d", "n"), 2943 to arrayOf("n", "tools"), 2944 to arrayOf("n", "tools", "d"), 2945 to arrayOf("n", "d"), 2946 to arrayOf("n", "what"), 2947 to arrayOf("n", "d", "what"), 2951 to arrayOf("head"), 2957 to arrayOf("name", "path"), 2963 to arrayOf("page", "net", "near"), 2964 to arrayOf("page", "what"), 2965 to arrayOf("ref"), 2969 to arrayOf("page"), 2992 to arrayOf("n"), 2993 to arrayOf("n"), 2994 to arrayOf("n"), 2996 to arrayOf("hub"), 3018 to arrayOf("project"), 3020 to arrayOf("n"), 3021 to arrayOf("n"), 3022 to arrayOf("word"), 3023 to arrayOf("n"), 3041 to arrayOf("name"), 3049 to arrayOf("answer"), 3054 to arrayOf("why"), 3056 to arrayOf("hub"), 3062 to arrayOf("from", "to"), 3069 to arrayOf("project"), 3079 to arrayOf("name"), 3083 to arrayOf("n"), 3089 to arrayOf("code"), 3090 to arrayOf("hub"), 3091 to arrayOf("hub"), 3092 to arrayOf("hub"), 3106 to arrayOf("n"), 3107 to arrayOf("n"), 3123 to arrayOf("status"), 3125 to arrayOf("status"), 3154 to arrayOf("project"), 3158 to arrayOf("code"), 3160 to arrayOf("why"), 3168 to arrayOf("title"), 3174 to arrayOf("title"), 3176 to arrayOf("q"), 3177 to arrayOf("title"), 3182 to arrayOf("room"), 3186 to arrayOf("q"), 3196 to arrayOf("title"), 3201 to arrayOf("n"), 3202 to arrayOf("n"), 3207 to arrayOf("at"), 3215 to arrayOf("size"), 3217 to arrayOf("n", "total"), 3234 to arrayOf("n"), 3235 to arrayOf("what"), 3238 to arrayOf("device"), 3239 to arrayOf("device"), 3248 to arrayOf("word", "count"), 3249 to arrayOf("heard"), 3261 to arrayOf("files"), 3262 to arrayOf("files"), 3265 to arrayOf("name"), 3293 to arrayOf("n"), 3294 to arrayOf("n"), 3305 to arrayOf("n"), 3339 to arrayOf("root"), 3340 to arrayOf("path"), 3363 to arrayOf("name"), 3366 to arrayOf("until"), 3367 to arrayOf("error"), 3374 to arrayOf("url"), 3378 to arrayOf("name"), 3379 to arrayOf("name"), 3387 to arrayOf("code", "hub", "until"), 3388 to arrayOf("url"), 3392 to arrayOf("kinds"), 3393 to arrayOf("address"), 3395 to arrayOf("address"), 3398 to arrayOf("url"), 3399 to arrayOf("url"), 3400 to arrayOf("url"), 3401 to arrayOf("url", "via"), 3406 to arrayOf("name"), 3407 to arrayOf("url", "check", "left"), 3409 to arrayOf("check"), 3410 to arrayOf("address"), 3411 to arrayOf("name"), 3412 to arrayOf("error"), 3413 to arrayOf("url"), 3414 to arrayOf("url"), 3421 to arrayOf("code", "address", "left"), 3427 to arrayOf("name"), 3428 to arrayOf("name"), 3439 to arrayOf("address"), 3446 to arrayOf("code", "body"), 3449 to arrayOf("code", "body"), 3455 to arrayOf("window", "used"), 3456 to arrayOf("window", "used", "when"), 3457 to arrayOf("window", "used"), 3458 to arrayOf("window", "used", "when"), 3459 to arrayOf("provider"), 3471 to arrayOf("label"), 3472 to arrayOf("when"), 3474 to arrayOf("provider"), 3475 to arrayOf("provider", "title", "why"), 3495 to arrayOf("reason"), 3503 to arrayOf("code"), 3512 to arrayOf("name"), 3515 to arrayOf("version"), 3516 to arrayOf("version"), 3517 to arrayOf("version"), 3519 to arrayOf("version"), 3520 to arrayOf("version"), 3521 to arrayOf("version"), 3522 to arrayOf("version", "why"), 3523 to arrayOf("version"), 3525 to arrayOf("code"), 3541 to arrayOf("name"), 3548 to arrayOf("count"), 3549 to arrayOf("title"), 3550 to arrayOf("name"), 3553 to arrayOf("n", "holder"), 3554 to arrayOf("n", "title"), 3555 to arrayOf("title"), 3558 to arrayOf("n"), 3559 to arrayOf("n"), 3560 to arrayOf("n"), 3561 to arrayOf("n"), 3562 to arrayOf("harness", "typed", "type", "remote", "host", "wt", "branch"), 3572 to arrayOf("pid"), 3577 to arrayOf("left"), 3578 to arrayOf("left"), 3584 to arrayOf("left"), 3585 to arrayOf("left"), 3586 to arrayOf("left"), 3587 to arrayOf("left"), 3588 to arrayOf("label", "left"), 3589 to arrayOf("when"), 3590 to arrayOf("used"), 3591 to arrayOf("used", "limit"), 3613 to arrayOf("tracking"), 3617 to arrayOf("total"), 3618 to arrayOf("price"), 3619 to arrayOf("price"), 3624 to arrayOf("n"), 3625 to arrayOf("parts"), 3626 to arrayOf("note"), 3627 to arrayOf("error"), 3628 to arrayOf("error", "parts"), 3633 to arrayOf("state"), 3634 to arrayOf("name", "path"), 3635 to arrayOf("name", "path", "why"), 3637 to arrayOf("code"), 3641 to arrayOf("detail"), 3643 to arrayOf("why"), 3644 to arrayOf("parts"), 3647 to arrayOf("build", "to"), 3648 to arrayOf("build"), 3649 to arrayOf("build", "skip"), 3651 to arrayOf("why"), 3652 to arrayOf("why"), 3653 to arrayOf("build"), 3654 to arrayOf("build", "why"), 3655 to arrayOf("build"), 3656 to arrayOf("build"), 3660 to arrayOf("build"), 3661 to arrayOf("build"), 3663 to arrayOf("build"), 3670 to arrayOf("build"), 3704 to arrayOf("step"), 3705 to arrayOf("p", "pt", "t", "tt", "e", "et"), 3706 to arrayOf("done", "total"), 3707 to arrayOf("n"), 3708 to arrayOf("n"), 3709 to arrayOf("n"), 3714 to arrayOf("n"), 3717 to arrayOf("why"), 3718 to arrayOf("why", "from"), 3719 to arrayOf("error"), 3721 to arrayOf("n"), 3722 to arrayOf("n"), 3726 to arrayOf("n"), 3729 to arrayOf("name", "gb", "path"), 3730 to arrayOf("path", "why"), 3731 to arrayOf("names"), 3733 to arrayOf("why"), 3744 to arrayOf("n", "total"), 3748 to arrayOf("title"), 3750 to arrayOf("n"), 3754 to arrayOf("name"), 3755 to arrayOf("title"), 3756 to arrayOf("note"), 3758 to arrayOf("machine"), 3759 to arrayOf("machines"), 3760 to arrayOf("machine"), 3771 to arrayOf("n"), 3773 to arrayOf("n"), 3777 to arrayOf("name"), 3780 to arrayOf("name"), 3797 to arrayOf("why"), 3803 to arrayOf("project"), 3844 to arrayOf("path"), 3845 to arrayOf("path"), 3847 to arrayOf("have", "total"), 3852 to arrayOf("n"), 3861 to arrayOf("hub"), 3864 to arrayOf("title"), 3868 to arrayOf("project"), 3869 to arrayOf("project"), 3870 to arrayOf("n"), 3871 to arrayOf("hub"), 3873 to arrayOf("n"), 3874 to arrayOf("n"), 3875 to arrayOf("model"), 3881 to arrayOf("name"), 3900 to arrayOf("word"), 3906 to arrayOf("answer"), 3916 to arrayOf("version", "build"), 3917 to arrayOf("hub"), 3922 to arrayOf("name"), 3925 to arrayOf("when", "who", "mark"), 3929 to arrayOf("who"), 3933 to arrayOf("time"), 3934 to arrayOf("address"), 3936 to arrayOf("kind", "name"), 3951 to arrayOf("title"), 3952 to arrayOf("query"), 3955 to arrayOf("room"), 3956 to arrayOf("query"), 3958 to arrayOf("n"), 3959 to arrayOf("n"), 3960 to arrayOf("n"), 3966 to arrayOf("size"), 3970 to arrayOf("n"), 3971 to arrayOf("n"), 3972 to arrayOf("n"), 3986 to arrayOf("status"), 3988 to arrayOf("status"), 4139 to arrayOf("code"), 4141 to arrayOf("n"), 4143 to arrayOf("why"), 4155 to arrayOf("done", "of"), 4159 to arrayOf("thread"), 4162 to arrayOf("n"), 4170 to arrayOf("title"), 4171 to arrayOf("note"), 4172 to arrayOf("label"), 4173 to arrayOf("machine"), 4174 to arrayOf("machine"), 4181 to arrayOf("at", "total"), 4182 to arrayOf("at", "total"), 4186 to arrayOf("machine"), 4187 to arrayOf("machine"), 4188 to arrayOf("machines"), 4190 to arrayOf("device"), 4197 to arrayOf("price"), 4198 to arrayOf("price"), 4205 to arrayOf("home"), 4210 to arrayOf("from"), 4212 to arrayOf("note"), 4213 to arrayOf("note"), 4215 to arrayOf("v"), 4216 to arrayOf("v"), 4217 to arrayOf("v", "who"), 4219 to arrayOf("who"), 4220 to arrayOf("v"), 4222 to arrayOf("v", "cmd"), 4223 to arrayOf("cmd"), 4228 to arrayOf("v", "path"), 4229 to arrayOf("v", "note"), 4230 to arrayOf("v"), 4235 to arrayOf("tool"), 4236 to arrayOf("tool"), 4261 to arrayOf("n", "w"), 4262 to arrayOf("why"), 4263 to arrayOf("state", "why"), 4275 to arrayOf("project"), 4276 to arrayOf("n"), 4287 to arrayOf("why"), 4293 to arrayOf("name"), 4304 to arrayOf("project"), 4309 to arrayOf("n"), 4317 to arrayOf("names"), 4325 to arrayOf("dest"), 4327 to arrayOf("repo"), 4328 to arrayOf("repo"), 4330 to arrayOf("url"), 4345 to arrayOf("time"), 4367 to arrayOf("group"), 4371 to arrayOf("project"), 4372 to arrayOf("n"), 4373 to arrayOf("n"), 4374 to arrayOf("n"), 4382 to arrayOf("n"), 4439 to arrayOf("n"), 4440 to arrayOf("n"), 4441 to arrayOf("a", "b"), 4442 to arrayOf("n"), 4444 to arrayOf("parts", "lines"), 4445 to arrayOf("n"), 4476 to arrayOf("what", "project", "fab"), 4477 to arrayOf("rev", "day"), 4485 to arrayOf("n"), 4496 to arrayOf("layer"), 4497 to arrayOf("n"), 4502 to arrayOf("board"), 4514 to arrayOf("others"), 4515 to arrayOf("must", "should", "notes"), 4516 to arrayOf("id", "w"), 4526 to arrayOf("what"), 4529 to arrayOf("why"), 4530 to arrayOf("why"), 4537 to arrayOf("n"), 4553 to arrayOf("price", "n"), 4554 to arrayOf("n", "need"), 4555 to arrayOf("n"), 4556 to arrayOf("n"), 4557 to arrayOf("cost"), 4558 to arrayOf("cost"), 4571 to arrayOf("day", "n"), 4572 to arrayOf("day"), 4573 to arrayOf("cost", "n", "lines"), 4574 to arrayOf("stock", "price"), 4575 to arrayOf("lines"), 4596 to arrayOf("host"), 4607 to arrayOf("n"), 4608 to arrayOf("a", "b"), 4609 to arrayOf("n"), 4610 to arrayOf("n"), 4613 to arrayOf("day"), 4614 to arrayOf("n"), 4655 to arrayOf("turn"), 4769 to arrayOf("text"), 4772 to arrayOf("repo", "dest"), 4773 to arrayOf("repo", "dest"), 4774 to arrayOf("repo"), 4779 to arrayOf("dir"), 4780 to arrayOf("dir"), 4784 to arrayOf("editor", "job", "secs"), 4785 to arrayOf("editor", "secs"), 4786 to arrayOf("editor"), 4803 to arrayOf("time"), 4809 to arrayOf("status"), 4817 to arrayOf("time"), 4818 to arrayOf("time", "dur"), 4821 to arrayOf("answer"), 4825 to arrayOf("type"), 4826 to arrayOf("max"), 4854 to arrayOf("bytes", "tokens"), 4887 to arrayOf("what"), 4891 to arrayOf("n"), 4893 to arrayOf("n"), 4917 to arrayOf("n"), 4918 to arrayOf("done", "total"), 4926 to arrayOf("v"), 4927 to arrayOf("x", "y"), 4933 to arrayOf("machine"), 4936 to arrayOf("days"), 4937 to arrayOf("warnings"), 4943 to arrayOf("n"), 4948 to arrayOf("n"), 4950 to arrayOf("found", "total", "q"), 4953 to arrayOf("model"), 4954 to arrayOf("model", "conf")) } + internal val exactKey: IntArray by lazy { intArrayOf(0, 1, 2, 3, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3169, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 3737, 61, 62, 63, 64, 66, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84, 85, 3776, 87, 88, 98, 99, 3098, 3775, 102, 103, 105, 106, 107, 109, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 155, 156, 157, 159, 161, 162, 163, 3218, 165, 166, 3220, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 3179, 183, 187, 189, 193, 194, 195, 197, 198, 199, 200, 201, 202, 206, 209, 213, 215, 216, 217, 219, 220, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 234, 235, 2985, 237, 238, 239, 240, 3736, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 260, 262, 263, 264, 265, 266, 267, 270, 271, 272, 273, 275, 279, 280, 281, 282, 286, 287, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 300, 301, 3190, 305, 306, 307, 308, 309, 310, 311, 313, 314, 315, 317, 319, 333, 3784, 336, 3783, 3786, 340, 3796, 342, 343, 344, 345, 354, 3167, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 2988, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 2980, 2981, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 453, 454, 455, 3197, 457, 458, 459, 460, 461, 2970, 463, 464, 465, 3100, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 556, 557, 558, 559, 560, 561, 562, 563, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 592, 628, 629, 630, 3205, 3206, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 651, 652, 3849, 654, 656, 657, 659, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 680, 681, 682, 683, 684, 686, 687, 689, 690, 692, 693, 694, 695, 698, 704, 724, 728, 729, 730, 731, 732, 3781, 734, 735, 736, 737, 3204, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 3764, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 843, 844, 845, 847, 848, 3200, 850, 852, 853, 854, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 3774, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 3851, 903, 904, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 3170, 964, 965, 966, 967, 968, 969, 3799, 971, 3025, 3082, 974, 975, 976, 978, 979, 987, 988, 989, 991, 992, 993, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 3802, 1020, 1021, 1022, 1025, 1029, 1030, 1031, 2977, 3051, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1045, 1046, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1074, 1082, 1083, 1086, 1087, 1088, 1090, 1091, 1092, 3816, 1094, 1095, 1098, 1099, 1100, 3199, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 3801, 1120, 1123, 1124, 1125, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1150, 1151, 1152, 1153, 1154, 1155, 1158, 1162, 1163, 1165, 1170, 1171, 1172, 1173, 1176, 1178, 1180, 1181, 1182, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1220, 1222, 1223, 2979, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1240, 1241, 1244, 1245, 1246, 1247, 1248, 1250, 1253, 1254, 1255, 1256, 1257, 1258, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1277, 1278, 1279, 1280, 1281, 1288, 1289, 1290, 1291, 1294, 1296, 1297, 1298, 1299, 1301, 1305, 1306, 1308, 1309, 1310, 1311, 1315, 1316, 1318, 1319, 1320, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1335, 1338, 1339, 1340, 1341, 1344, 1347, 1348, 1356, 1357, 3514, 1361, 1362, 1363, 1364, 1365, 1366, 3581, 1373, 1375, 1380, 1384, 1385, 3055, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 2982, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 3099, 3592, 1436, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 3594, 1473, 1474, 1475, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1493, 1494, 3739, 1496, 1497, 1498, 3751, 3757, 1501, 1502, 1503, 1504, 1505, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1523, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1573, 1574, 1575, 1576, 1578, 1579, 1580, 1581, 1582, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 3058, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 3468, 1670, 1671, 1672, 1673, 3469, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 2991, 1692, 1694, 1696, 1698, 1702, 1706, 1712, 1714, 1715, 1716, 1718, 1719, 1720, 1721, 1722, 1723, 1725, 1727, 1728, 1729, 1730, 1731, 1733, 1734, 3763, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1744, 1745, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1826, 1827, 3034, 1836, 1838, 1842, 3016, 1844, 1845, 3017, 1847, 1848, 1852, 3081, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1864, 1869, 1871, 1872, 1873, 1874, 1875, 1876, 3096, 1878, 1879, 1882, 1883, 1893, 1894, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1942, 1943, 1945, 1946, 1956, 1958, 1959, 1962, 1963, 1966, 1967, 1968, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1988, 1994, 1995, 1996, 1997, 2001, 3157, 2007, 2008, 2010, 2011, 2012, 2013, 3809, 3810, 2022, 2024, 2025, 2026, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2039, 2040, 2042, 2043, 2046, 2047, 3142, 3143, 3144, 2055, 3370, 2057, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2074, 2075, 2076, 2077, 2078, 2079, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2112, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2127, 2128, 2129, 3084, 2133, 2134, 2135, 2137, 2139, 2140, 2141, 2142, 3007, 3132, 3133, 3134, 3135, 3136, 2149, 2150, 2151, 2153, 3009, 3010, 3000, 2999, 2159, 3001, 2161, 3005, 2163, 3368, 2168, 2172, 2174, 2175, 2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 3035, 2188, 2189, 2190, 2191, 3068, 2193, 2194, 2195, 2196, 2197, 2198, 2199, 2200, 2201, 2204, 3381, 2206, 2207, 2208, 2209, 3050, 2211, 2212, 2213, 2214, 2998, 2216, 3113, 2219, 2223, 2224, 3658, 2226, 2227, 3745, 3746, 2231, 3195, 2234, 3734, 2237, 2238, 2239, 2240, 2241, 3794, 2243, 3165, 2245, 3164, 2247, 2249, 2251, 2252, 2253, 2257, 2260, 2262, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2279, 2280, 2281, 3752, 2283, 2284, 2286, 3042, 3040, 3044, 2292, 2294, 2295, 2301, 2302, 2303, 2304, 3080, 2309, 2310, 2312, 2317, 2318, 3024, 3593, 2987, 2986, 2989, 3109, 3112, 2331, 2332, 2334, 2335, 2336, 2337, 2338, 2339, 2340, 2341, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, 3813, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2374, 2376, 2377, 2378, 2382, 2383, 2386, 2387, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2408, 2409, 2410, 2411, 2412, 2413, 2435, 2436, 2439, 2440, 2441, 2442, 2443, 2444, 2445, 2455, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2469, 2470, 2471, 2472, 2474, 2475, 2476, 2478, 2481, 2482, 2483, 2486, 2487, 2488, 2489, 2490, 2491, 2492, 2493, 2499, 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 2523, 2524, 2525, 2526, 2527, 2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537, 2538, 2539, 2540, 2541, 2542, 2543, 2544, 2546, 2547, 2548, 2549, 3146, 2551, 2553, 2554, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2565, 2566, 2567, 2568, 2571, 2572, 2573, 2574, 2575, 2576, 2577, 2578, 2579, 2587, 2588, 2589, 2590, 2593, 2594, 2595, 2596, 2597, 2598, 2599, 2600, 2601, 2603, 2604, 2605, 2606, 2607, 2608, 2609, 2610, 2611, 2614, 2616, 2617, 2620, 2621, 2622, 2623, 2624, 2625, 2626, 2627, 2628, 2630, 2631, 2633, 2634, 2635, 2636, 2637, 2638, 2639, 2640, 2641, 2642, 2643, 2645, 2647, 2650, 2652, 3742, 2657, 2658, 2659, 2660, 2661, 2662, 2663, 2667, 2668, 2670, 2671, 2672, 2673, 2674, 2675, 2676, 2678, 2679, 2680, 2685, 2686, 2687, 2689, 2690, 2691, 2692, 2694, 2695, 2696, 2697, 2698, 2699, 2700, 2701, 2702, 2703, 2704, 2705, 2706, 3715, 2708, 2709, 2711, 3712, 2713, 2714, 3716, 3713, 2726, 2730, 3723, 3219, 3724, 2734, 3725, 2736, 2738, 3727, 2740, 3728, 2742, 2744, 3732, 3710, 3703, 3711, 2763, 2764, 2766, 2767, 2777, 2778, 2780, 2781, 2782, 2783, 2784, 2785, 2786, 2787, 2788, 2792, 2795, 2798, 2800, 2802, 2808, 2809, 2810, 2811, 2812, 2813, 2814, 2815, 2816, 2817, 2818, 2819, 2820, 3390, 2822, 2823, 2824, 2825, 2826, 2828, 2830, 2831, 3422, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2850, 2851, 2852, 2853, 2856, 2857, 2859, 2860, 2861, 2862, 3014, 2864, 2866, 2867, 2869, 2870, 2871, 2872, 2873, 2875, 2876, 2880, 2883, 2884, 2885, 2887, 2888, 2889, 2891, 2892, 2893, 2894, 2896, 2897, 2900, 2903, 2904, 2905, 2906, 2907, 2909, 2911, 2912, 2914, 2915, 2916, 2917, 2918, 2919, 2920, 2921, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2939, 2940, 2941, 2942, 2948, 2949, 2950, 2952, 2953, 2954, 2958, 2959, 2960, 2961, 2962, 2966, 2967, 2971, 2972, 2973, 2974, 2975, 2976, 2978, 2983, 2984, 2990, 2995, 2997, 3002, 3003, 3004, 3006, 3008, 3011, 3012, 3013, 3015, 3019, 3026, 3027, 3028, 3029, 3030, 3031, 3032, 3033, 3036, 3037, 3038, 3039, 3043, 3045, 3046, 3047, 3048, 3052, 3053, 3057, 3059, 3060, 3061, 3063, 3064, 3065, 3066, 3067, 3070, 3071, 3072, 3073, 3074, 3075, 3076, 3077, 3078, 3085, 3086, 3087, 3088, 3093, 3094, 3095, 3097, 3101, 3102, 3103, 3104, 3105, 3108, 3110, 3111, 3114, 3115, 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3124, 3126, 3127, 3128, 3129, 3130, 3131, 3137, 3138, 3139, 3140, 3141, 3145, 3147, 3148, 3149, 3150, 3151, 3152, 3153, 3155, 3156, 3159, 3161, 3162, 3163, 3166, 3171, 3172, 3173, 3175, 3178, 3180, 3181, 3183, 3184, 3185, 3187, 3188, 3189, 3191, 3192, 3193, 3194, 3198, 3203, 3208, 3209, 3210, 3211, 3212, 3213, 3214, 3216, 3221, 3222, 3223, 3224, 3225, 3226, 3227, 3228, 3229, 3230, 3231, 3232, 3233, 3236, 3237, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3263, 3264, 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, 3286, 3287, 3288, 3289, 3290, 3291, 3292, 3295, 3296, 3297, 3298, 3299, 3300, 3301, 3302, 3303, 3304, 3306, 3307, 3308, 3309, 3310, 3311, 3312, 3313, 3314, 3315, 3316, 3317, 3318, 3319, 3320, 3321, 3322, 3323, 3324, 3325, 3326, 3327, 3328, 3329, 3330, 3331, 3332, 3333, 3334, 3335, 3336, 3337, 3338, 3341, 3342, 3343, 3344, 3345, 3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360, 3361, 3362, 3364, 3365, 3369, 3371, 3372, 3373, 3375, 3376, 3377, 3380, 3382, 3383, 3384, 3385, 3386, 3389, 3391, 3394, 3396, 3397, 3402, 3403, 3404, 3405, 3408, 3415, 3416, 3417, 3418, 3419, 3420, 3423, 3424, 3425, 3426, 3429, 3430, 3431, 3432, 3433, 3434, 3435, 3436, 3437, 3438, 3440, 3441, 3442, 3443, 3444, 3445, 3447, 3448, 3450, 3451, 3452, 3453, 3454, 3460, 3461, 3462, 3463, 3464, 3465, 3466, 3467, 3470, 3473, 3476, 3477, 3478, 3479, 3480, 3481, 3482, 3483, 3484, 3485, 3486, 3487, 3488, 3489, 3490, 3491, 3492, 3493, 3494, 3496, 3497, 3498, 3499, 3500, 3501, 3502, 3504, 3505, 3506, 3507, 3508, 3509, 3510, 3511, 3513, 3518, 3524, 3526, 3527, 3528, 3529, 3530, 3531, 3532, 3533, 3534, 3535, 3536, 3537, 3538, 3539, 3540, 3542, 3543, 3544, 3545, 3546, 3547, 3551, 3552, 3556, 3557, 3563, 3564, 3565, 3566, 3567, 3568, 3569, 3570, 3571, 3573, 3574, 3575, 3576, 3579, 3580, 3582, 3583, 3595, 3596, 3597, 3598, 3599, 3600, 3601, 3602, 3603, 3604, 3605, 3606, 3607, 3608, 3609, 3610, 3611, 3612, 3614, 3615, 3616, 3620, 3621, 3622, 3623, 3629, 3630, 3631, 3632, 3636, 3638, 3639, 3640, 3642, 3645, 3646, 3650, 3657, 3659, 3662, 3664, 3665, 3666, 3667, 3668, 3669, 3671, 3672, 3673, 3674, 3675, 3676, 3677, 3678, 3679, 3680, 3681, 3682, 3683, 3684, 3685, 3686, 3687, 3688, 3689, 3690, 3691, 3692, 3693, 3694, 3695, 3696, 3697, 3698, 3699, 3700, 3701, 3702, 3720, 3735, 3738, 3740, 3741, 3743, 3747, 3749, 3753, 3762, 3765, 3766, 3767, 3768, 3769, 3770, 3772, 3778, 3779, 3782, 3785, 3787, 3788, 3789, 3790, 3791, 3792, 3795, 3798, 3800, 3804, 3805, 3806, 3807, 3808, 3811, 3812, 3814, 3815, 3817, 3818, 3819, 3820, 3821, 3822, 3823, 3824, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3836, 3837, 3838, 3839, 3840, 3841, 3842, 3843, 3846, 3848, 3850, 3859, 3860, 3862, 3863, 3872, 3878, 3884, 3893, 3895, 3896, 3897, 3898, 3901, 3902, 3904, 3910, 3914, 3918, 3923, 3924, 3926, 3927, 3928, 3930, 3931, 3932, 3937, 3938, 3939, 3940, 3941, 3942, 3943, 3944, 3945, 3948, 3949, 3950, 3995, 3996, 4001, 4003, 4004, 4006, 4012, 4015, 4030, 4031, 4032, 4033, 4034, 4035, 4037, 4038, 4040, 4041, 4043, 4045, 4046, 4059, 4062, 4063, 4065, 4066, 4070, 4075, 4078, 4079, 4081, 4082, 4088, 4090, 4091, 4094, 4096, 4101, 4102, 4103, 4108, 4119, 4142, 4158, 4166, 4175, 4176, 4180, 4185, 4201, 4202, 4203, 4204, 4206, 4208, 4209, 4211, 4214, 4218, 4221, 4224, 4225, 4226, 4227, 4231, 4232, 4233, 4234, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4260, 4268, 4271, 4272, 4278, 4283, 4284, 4285, 4286, 4290, 4294, 4296, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4305, 4306, 4307, 4308, 4310, 4311, 4312, 4313, 4314, 4315, 4316, 4326, 4335, 4336, 4337, 4338, 4339, 4340, 4341, 4342, 4343, 4344, 4346, 4347, 4348, 4352, 4353, 4355, 4356, 4357, 4358, 4362, 4363, 4364, 4365, 4366, 4367, 4369, 4370, 4371, 4377, 4378, 4379, 4380, 4381, 4382, 4386, 4390, 4391, 4393, 4394, 4395, 4396, 4397, 4399, 4409, 4411, 4416, 4417, 4418, 4419, 4420, 4421, 4422, 4423, 4424, 4425, 4426, 4427, 4428, 4429, 4430, 4431, 4433, 4434, 4435, 4436, 4437, 4438, 4439, 4444, 4447, 4448, 4449, 4450, 4451, 4452, 4453, 4454, 4455, 4456, 4457, 4458, 4459, 4460, 4461, 4462, 4463, 4464, 4465, 4466, 4467, 4469, 4470, 4471, 4473, 4474, 4475, 4476, 4479, 4480, 4481, 4483, 4484, 4485, 4487, 4488, 4489, 4490, 4491, 4492, 4494, 4496, 4499, 4500, 4501, 4502, 4504, 4505, 4506, 4507, 4508, 4509, 4510, 4511, 4512, 4513, 4514, 4518, 4520, 4521, 4522, 4523, 4524, 4528, 4529, 4533, 4534, 4535, 4537, 4539, 4540, 4541, 4542, 4543, 4544, 4545, 4547, 4548, 4549, 4550, 4551, 4552, 4553, 4560, 4561, 4562, 4563, 4564, 4565, 4566, 4567, 4568, 4569, 4570, 4571, 4577, 4578, 4580, 4581, 4582, 4583, 4584, 4585, 4586, 4587, 4588, 4589, 4590, 4591, 4592, 4593, 4594, 4595, 4599, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4612, 4613, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, 4628, 4629, 4631, 4632, 4633, 4634, 4643, 4644, 4645, 4646, 4647, 4648, 4650, 4653, 4654, 4655, 4657, 4658, 4659, 4660, 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, 4680, 4681, 4682, 4683, 4684, 4685, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4731, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, 4763, 4764, 4765, 4771, 4784, 4788, 4789, 4790, 4791, 4792, 4793, 4794, 4795, 4796, 4797, 4798, 4799, 4800, 4801, 4802, 4803, 4805, 4806, 4807, 4808, 4809, 4811, 4812, 4813, 4814, 4815, 4816, 4817, 4820, 4821, 4823, 4824, 4825, 4828, 4829, 4830, 4831, 4832, 4833, 4834, 4835, 4836, 4837, 4838, 4839, 4840, 4841, 4842, 4843, 4844, 4845, 4846, 4847, 4848, 4849, 4850, 4851, 4852, 4853, 4854, 4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865, 4866, 4867, 4868, 4869, 4870, 4871, 4872, 4873, 4874, 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4887, 4889, 4890, 4891, 4893, 4895, 4897, 4898, 4899, 4900, 4903, 4905, 4906, 4907, 4908, 4910, 4911, 4912, 4913, 4914, 4915, 4916, 4917, 4920, 4924, 4925, 4929, 4930, 4931, 4932, 4933, 4935, 4936, 4939, 4940, 4941, 4942, 4943, 4945, 4946, 4947, 4948, 4950, 4952, 4953, 4956, 4957, 4958, 4959, 4960, 4961) } + internal val templates: IntArray by lazy { intArrayOf(2375, 2854, 2666, 2665, 2664, 2886, 2908, 3388, 2629, 418, 2799, 2797, 2693, 2384, 2390, 2801, 2898, 2613, 2612, 285, 2342, 2803, 2910, 3238, 4190, 2552, 4934, 2602, 2050, 2380, 3722, 2115, 2729, 2385, 3239, 1336, 4210, 4230, 3721, 2570, 2727, 1867, 4205, 2126, 2167, 2173, 4573, 283, 2116, 4515, 3400, 3421, 2073, 2353, 3718, 452, 2761, 2793, 2794, 3401, 3717, 2762, 3649, 609, 1711, 3726, 1868, 2737, 3729, 2743, 3392, 616, 617, 2779, 3090, 3704, 1659, 2796, 3648, 303, 614, 69, 711, 621, 2352, 4228, 1121, 2494, 3471, 3844, 1242, 2202, 2581, 3393, 2165, 3733, 714, 1763, 1964, 2749, 2758, 2969, 4235, 3395, 3407, 136, 594, 596, 2569, 2724, 1865, 4223, 3041, 610, 2289, 2592, 3881, 1302, 4222, 3517, 3654, 3655, 158, 2080, 2082, 2117, 2849, 4372, 2171, 2379, 2522, 3643, 214, 284, 1276, 2014, 4804, 3512, 3521, 3522, 67, 83, 218, 619, 4609, 3541, 1360, 4317, 3366, 3731, 726, 1023, 1372, 2393, 2485, 2747, 4374, 89, 2392, 2407, 2922, 624, 1657, 1954, 2836, 4503, 3414, 1577, 2101, 2293, 2583, 4555, 3409, 3475, 3525, 650, 1888, 3936, 3174, 3516, 3562, 3626, 3845, 1317, 1866, 2045, 2431, 2718, 3864, 4574, 3428, 3474, 1841, 1863, 3363, 593, 1292, 1346, 1371, 1953, 3503, 3705, 221, 1701, 2750, 2947, 3092, 3160, 3449, 258, 591, 1026, 1379, 1965, 1989, 4143, 3446, 3572, 655, 1342, 1717, 2051, 3168, 3367, 3628, 3647, 710, 1283, 1370, 1382, 1658, 1732, 1895, 2381, 2484, 2582, 3951, 4229, 4440, 3427, 3495, 3641, 649, 699, 1044, 2618, 3186, 3305, 3708, 108, 184, 606, 721, 1081, 1969, 2049, 2111, 2169, 2417, 2498, 2754, 2790, 2834, 3956, 4486, 4827, 3387, 3458, 3619, 160, 623, 701, 1332, 1333, 1345, 1520, 1660, 2166, 2170, 2263, 2416, 2644, 4198, 4516, 3123, 3215, 3262, 3340, 3554, 3709, 3719, 703, 1183, 1572, 1897, 2258, 2261, 2497, 2755, 2775, 2776, 2944, 2945, 3966, 3986, 4219, 4477, 4810, 4826, 3627, 3644, 3750, 1378, 1492, 1584, 1703, 1955, 2437, 2449, 2774, 4162, 4220, 4517, 4608, 3089, 3091, 3106, 3624, 3637, 3803, 723, 1024, 1832, 2138, 2203, 2427, 2770, 2771, 3971, 4217, 4293, 4304, 3293, 3413, 91, 93, 595, 715, 1027, 1350, 1355, 2020, 2333, 2432, 2717, 2769, 2773, 3933, 4556, 4888, 3020, 3021, 3523, 3587, 3730, 94, 1251, 1259, 1353, 1377, 1519, 1583, 1880, 2186, 2218, 2477, 2495, 2745, 3873, 3874, 4216, 4383, 4446, 4892, 3339, 3378, 3379, 3457, 3613, 299, 599, 618, 700, 1109, 1117, 1175, 1367, 1518, 1626, 1948, 2130, 2136, 2154, 2221, 2447, 2452, 2454, 2677, 2710, 2768, 2946, 2963, 2964, 4187, 4213, 4330, 3022, 3176, 3553, 3586, 3755, 211, 585, 590, 605, 717, 720, 906, 990, 1084, 1159, 1334, 1470, 1524, 1705, 1886, 1906, 1926, 1961, 1991, 2072, 2316, 2430, 2496, 2951, 3900, 3952, 4170, 4557, 4575, 4576, 4775, 4937, 3083, 3439, 3634, 3635, 92, 96, 269, 603, 648, 712, 980, 1331, 1707, 1887, 1944, 2114, 2425, 2451, 2453, 2456, 2545, 2683, 2719, 2901, 2913, 4261, 4559, 4787, 2996, 3261, 3294, 3374, 3472, 3591, 3625, 208, 277, 316, 329, 330, 1287, 1352, 1376, 1521, 1522, 1949, 2019, 2044, 2113, 2220, 2248, 2299, 2419, 2434, 2446, 2720, 2723, 2804, 2805, 3871, 4572, 4770, 4944, 3018, 3406, 3410, 3459, 3515, 3670, 3707, 3760, 6, 244, 304, 600, 604, 1047, 1221, 1286, 1354, 1359, 1708, 1709, 1884, 1957, 1960, 2018, 2021, 2152, 2187, 2235, 2418, 2426, 2646, 2752, 2791, 2868, 3868, 3869, 3929, 4186, 4773, 4785, 4786, 4955, 3456, 3578, 3585, 3590, 3652, 3660, 268, 318, 322, 331, 583, 707, 722, 1076, 1160, 1164, 1284, 1285, 1312, 1517, 1710, 1828, 1889, 2009, 2222, 2228, 2389, 2415, 2421, 2448, 2580, 2681, 3934, 4159, 4212, 4275, 4375, 4445, 4656, 4774, 4949, 3069, 3154, 3519, 3520, 3618, 3651, 65, 210, 274, 587, 608, 613, 708, 713, 984, 1075, 1167, 1369, 1713, 1743, 1829, 1834, 1849, 1885, 2048, 2081, 2278, 2296, 2305, 2414, 2468, 2480, 2772, 4197, 3049, 3399, 3584, 3653, 3661, 3706, 90, 207, 288, 320, 323, 324, 349, 597, 607, 709, 855, 905, 1166, 1169, 1252, 1437, 1890, 2005, 2015, 2420, 2429, 2473, 2751, 2789, 2943, 2957, 3906, 4818, 4819, 4822, 4918, 3023, 3054, 3107, 3177, 3235, 3248, 3249, 3412, 3560, 3561, 3633, 3656, 3663, 3714, 110, 186, 190, 191, 212, 321, 327, 328, 352, 375, 580, 582, 589, 625, 727, 851, 977, 1077, 1118, 1147, 1243, 1304, 1314, 1746, 1830, 1831, 1839, 1950, 1951, 1952, 2041, 2254, 2256, 2285, 2297, 2298, 2320, 2388, 2422, 2423, 2479, 2585, 2586, 2669, 2684, 2716, 2721, 2722, 2759, 2806, 2807, 3852, 3870, 3916, 3970, 4215, 4309, 4327, 4345, 4373, 4443, 4478, 4530, 4554, 4615, 4855, 4938, 4954, 3056, 3158, 3182, 3196, 3217, 3398, 3411, 3555, 3559, 3589, 3617, 3748, 3758, 3759, 3771, 3773, 3780, 5, 8, 82, 185, 188, 192, 257, 276, 325, 326, 348, 351, 356, 598, 620, 658, 696, 705, 856, 985, 1048, 1122, 1148, 1149, 1168, 1179, 1239, 1383, 1491, 1649, 1693, 1704, 1850, 1881, 1947, 1993, 2006, 2027, 2250, 2255, 2308, 2314, 2315, 2322, 2433, 2619, 2655, 2829, 3917, 3925, 3955, 3972, 4139, 4174, 4188, 4236, 4276, 4328, 4368, 4531, 4558, 4951, 3079, 3125, 3201, 3202, 3207, 3265, 3549, 154, 259, 261, 347, 350, 353, 579, 602, 612, 702, 706, 982, 1078, 1381, 1593, 1833, 1925, 1987, 1990, 2306, 2319, 2391, 2438, 2584, 2632, 2874, 3875, 3922, 3988, 4155, 4527, 4614, 3455, 3548, 3550, 3558, 3577, 3588, 3756, 3777, 3797, 95, 196, 203, 204, 205, 242, 243, 346, 581, 586, 601, 615, 622, 626, 627, 691, 716, 725, 983, 986, 1085, 1089, 1161, 1174, 1204, 1349, 1471, 1506, 1688, 1689, 1691, 1726, 1851, 1891, 2233, 2311, 2321, 2428, 2450, 2458, 2965, 4141, 4171, 4172, 4262, 4287, 4325, 4441, 4497, 4538, 4894, 4919) } + internal val argNames: Map> by lazy { mapOf(5 to arrayOf("n"), 6 to arrayOf("n"), 7 to arrayOf("who"), 8 to arrayOf("title"), 65 to arrayOf("state"), 67 to arrayOf("listen"), 69 to arrayOf("listen"), 82 to arrayOf("version"), 83 to arrayOf("count", "plural"), 89 to arrayOf("size", "limit"), 90 to arrayOf("name"), 91 to arrayOf("dir"), 92 to arrayOf("dir"), 93 to arrayOf("name"), 94 to arrayOf("name"), 95 to arrayOf("path"), 96 to arrayOf("path"), 97 to arrayOf("name"), 108 to arrayOf("first"), 110 to arrayOf("n"), 136 to arrayOf("count", "plural"), 154 to arrayOf("tool"), 158 to arrayOf("n"), 160 to arrayOf("name"), 184 to arrayOf("pid", "cmd"), 185 to arrayOf("title", "ago"), 186 to arrayOf("name", "who", "n"), 188 to arrayOf("line"), 190 to arrayOf("n"), 191 to arrayOf("n"), 192 to arrayOf("n"), 196 to arrayOf("name"), 203 to arrayOf("when"), 204 to arrayOf("text", "when"), 205 to arrayOf("when"), 207 to arrayOf("count", "plural"), 208 to arrayOf("count", "plural"), 210 to arrayOf("took", "ago"), 211 to arrayOf("ago"), 212 to arrayOf("kind"), 214 to arrayOf("kind", "code", "why"), 218 to arrayOf("clock"), 221 to arrayOf("build"), 242 to arrayOf("step"), 243 to arrayOf("turn"), 244 to arrayOf("branch"), 257 to arrayOf("step", "total"), 258 to arrayOf("step", "total"), 259 to arrayOf("when"), 261 to arrayOf("tool"), 268 to arrayOf("count", "plural"), 269 to arrayOf("count", "total"), 274 to arrayOf("old", "new"), 276 to arrayOf("version"), 277 to arrayOf("count"), 278 to arrayOf("tag"), 283 to arrayOf("version"), 284 to arrayOf("old", "version"), 285 to arrayOf("version"), 288 to arrayOf("version"), 299 to arrayOf("project", "location"), 303 to arrayOf("account"), 304 to arrayOf("account"), 316 to arrayOf("n"), 318 to arrayOf("n"), 320 to arrayOf("minute"), 321 to arrayOf("time"), 322 to arrayOf("time"), 323 to arrayOf("clock"), 324 to arrayOf("clock", "took"), 325 to arrayOf("clock"), 326 to arrayOf("clock", "took"), 327 to arrayOf("clock"), 328 to arrayOf("clock", "took"), 329 to arrayOf("clock"), 330 to arrayOf("clock", "took"), 331 to arrayOf("clock"), 346 to arrayOf("target"), 347 to arrayOf("target"), 348 to arrayOf("target"), 349 to arrayOf("target"), 350 to arrayOf("target"), 351 to arrayOf("target"), 352 to arrayOf("target"), 353 to arrayOf("target"), 356 to arrayOf("name"), 375 to arrayOf("t"), 418 to arrayOf("minutes", "plural"), 452 to arrayOf("path"), 579 to arrayOf("count"), 580 to arrayOf("count"), 581 to arrayOf("title"), 582 to arrayOf("path"), 583 to arrayOf("path", "error"), 584 to arrayOf("first", "last", "count"), 585 to arrayOf("task", "step"), 586 to arrayOf("count"), 587 to arrayOf("path"), 588 to arrayOf("count", "plural"), 589 to arrayOf("label"), 590 to arrayOf("provider"), 591 to arrayOf("version"), 593 to arrayOf("key"), 594 to arrayOf("device"), 595 to arrayOf("kind", "device"), 596 to arrayOf("status"), 597 to arrayOf("kind", "title"), 598 to arrayOf("layer"), 599 to arrayOf("error"), 600 to arrayOf("page"), 601 to arrayOf("page", "kind", "total"), 602 to arrayOf("reason"), 603 to arrayOf("tag"), 604 to arrayOf("tag"), 605 to arrayOf("title"), 606 to arrayOf("title"), 607 to arrayOf("text", "time"), 608 to arrayOf("kind", "device"), 609 to arrayOf("device"), 610 to arrayOf("device"), 611 to arrayOf("word"), 612 to arrayOf("word", "kind", "count"), 613 to arrayOf("error"), 614 to arrayOf("count"), 615 to arrayOf("time", "relative", "rel", "zoned", "zone"), 616 to arrayOf("zone"), 617 to arrayOf("zone"), 618 to arrayOf("id", "state", "count", "age"), 619 to arrayOf("id"), 620 to arrayOf("name"), 621 to arrayOf("name"), 622 to arrayOf("clock", "count", "plural"), 623 to arrayOf("name"), 624 to arrayOf("name"), 625 to arrayOf("name"), 626 to arrayOf("count"), 627 to arrayOf("count"), 631 to arrayOf("name", "state"), 632 to arrayOf("author", "place", "state"), 633 to arrayOf("title", "state"), 648 to arrayOf("error"), 649 to arrayOf("error"), 650 to arrayOf("host"), 655 to arrayOf("email"), 658 to arrayOf("version"), 660 to arrayOf("first", "last", "count"), 661 to arrayOf("n"), 662 to arrayOf("n"), 691 to arrayOf("ref"), 696 to arrayOf("name"), 697 to arrayOf("name"), 699 to arrayOf("name"), 700 to arrayOf("name"), 701 to arrayOf("action"), 702 to arrayOf("label"), 703 to arrayOf("count", "plural"), 705 to arrayOf("path"), 706 to arrayOf("word", "kind", "count"), 707 to arrayOf("name"), 708 to arrayOf("name"), 709 to arrayOf("name"), 710 to arrayOf("name"), 711 to arrayOf("url"), 712 to arrayOf("count"), 713 to arrayOf("count"), 714 to arrayOf("device"), 715 to arrayOf("device"), 716 to arrayOf("count"), 717 to arrayOf("label"), 718 to arrayOf("label"), 719 to arrayOf("label"), 720 to arrayOf("title"), 721 to arrayOf("title"), 722 to arrayOf("state"), 723 to arrayOf("open", "kind"), 725 to arrayOf("count"), 726 to arrayOf("email"), 727 to arrayOf("email"), 851 to arrayOf("at", "count"), 855 to arrayOf("name"), 856 to arrayOf("name"), 905 to arrayOf("name"), 906 to arrayOf("name"), 977 to arrayOf("count"), 980 to arrayOf("name"), 981 to arrayOf("name", "count"), 982 to arrayOf("label", "n"), 983 to arrayOf("action"), 984 to arrayOf("count", "plural"), 985 to arrayOf("count"), 986 to arrayOf("waiting", "busy", "done"), 990 to arrayOf("count", "plural"), 1023 to arrayOf("name"), 1024 to arrayOf("name"), 1026 to arrayOf("seconds", "long"), 1027 to arrayOf("size", "triangles", "delayed", "waited", "built"), 1028 to arrayOf("size", "delayed", "waited"), 1044 to arrayOf("name"), 1047 to arrayOf("name"), 1048 to arrayOf("count"), 1075 to arrayOf("state"), 1076 to arrayOf("bytes"), 1077 to arrayOf("count"), 1078 to arrayOf("when"), 1079 to arrayOf("state", "name"), 1080 to arrayOf("name", "state"), 1081 to arrayOf("reason", "code"), 1084 to arrayOf("kind", "code"), 1085 to arrayOf("number"), 1089 to arrayOf("x", "y"), 1096 to arrayOf("state"), 1097 to arrayOf("label", "example"), 1109 to arrayOf("text"), 1117 to arrayOf("error"), 1118 to arrayOf("kind", "count"), 1121 to arrayOf("name"), 1122 to arrayOf("n"), 1147 to arrayOf("ago"), 1148 to arrayOf("name"), 1149 to arrayOf("kind", "place", "hub"), 1159 to arrayOf("label"), 1160 to arrayOf("word"), 1161 to arrayOf("count"), 1164 to arrayOf("hub"), 1166 to arrayOf("count"), 1167 to arrayOf("state"), 1168 to arrayOf("label"), 1169 to arrayOf("label"), 1174 to arrayOf("state", "text"), 1175 to arrayOf("text"), 1177 to arrayOf("question"), 1179 to arrayOf("label"), 1183 to arrayOf("title"), 1204 to arrayOf("count"), 1205 to arrayOf("name", "counts"), 1219 to arrayOf("n"), 1221 to arrayOf("mode"), 1238 to arrayOf("first", "last", "total"), 1239 to arrayOf("count"), 1242 to arrayOf("n"), 1243 to arrayOf("who", "name"), 1251 to arrayOf("name"), 1252 to arrayOf("when"), 1259 to arrayOf("why"), 1276 to arrayOf("name"), 1283 to arrayOf("kind"), 1284 to arrayOf("title"), 1285 to arrayOf("title"), 1286 to arrayOf("title"), 1287 to arrayOf("title"), 1292 to arrayOf("name"), 1302 to arrayOf("heard"), 1303 to arrayOf("out", "heard"), 1304 to arrayOf("heard"), 1312 to arrayOf("name", "mb"), 1314 to arrayOf("name"), 1317 to arrayOf("platform"), 1321 to arrayOf("heard", "out", "yes"), 1331 to arrayOf("name", "done", "total", "percent"), 1332 to arrayOf("name", "done"), 1333 to arrayOf("name"), 1334 to arrayOf("error"), 1336 to arrayOf("mb"), 1342 to arrayOf("mb"), 1345 to arrayOf("n"), 1346 to arrayOf("n"), 1349 to arrayOf("n"), 1350 to arrayOf("pct"), 1351 to arrayOf("px"), 1352 to arrayOf("version"), 1353 to arrayOf("tag"), 1354 to arrayOf("tag"), 1355 to arrayOf("hub"), 1359 to arrayOf("tag"), 1360 to arrayOf("tag"), 1367 to arrayOf("when"), 1369 to arrayOf("tag"), 1370 to arrayOf("tag", "when"), 1371 to arrayOf("tag"), 1372 to arrayOf("tag", "when"), 1376 to arrayOf("channel"), 1377 to arrayOf("tag"), 1378 to arrayOf("app", "hub"), 1379 to arrayOf("hub", "app"), 1381 to arrayOf("key"), 1382 to arrayOf("key"), 1383 to arrayOf("why"), 1437 to arrayOf("n"), 1470 to arrayOf("title"), 1471 to arrayOf("note"), 1491 to arrayOf("title"), 1492 to arrayOf("more"), 1506 to arrayOf("bots"), 1517 to arrayOf("name"), 1518 to arrayOf("name", "time"), 1519 to arrayOf("name", "n"), 1520 to arrayOf("name", "time", "n"), 1521 to arrayOf("to"), 1522 to arrayOf("to", "step"), 1524 to arrayOf("note"), 1572 to arrayOf("why"), 1577 to arrayOf("e"), 1583 to arrayOf("max"), 1584 to arrayOf("secs", "max", "mib"), 1593 to arrayOf("path"), 1626 to arrayOf("secs"), 1649 to arrayOf("pct", "scope"), 1657 to arrayOf("n"), 1658 to arrayOf("n"), 1659 to arrayOf("n"), 1660 to arrayOf("n"), 1688 to arrayOf("d", "h"), 1689 to arrayOf("h", "m"), 1690 to arrayOf("m"), 1691 to arrayOf("window", "pct"), 1693 to arrayOf("when"), 1695 to arrayOf("label", "e"), 1697 to arrayOf("from", "to", "total"), 1701 to arrayOf("messages", "lines", "left"), 1703 to arrayOf("pct", "view", "max"), 1704 to arrayOf("pct"), 1705 to arrayOf("done", "total"), 1707 to arrayOf("n"), 1708 to arrayOf("n"), 1709 to arrayOf("time"), 1710 to arrayOf("view", "max"), 1711 to arrayOf("view", "max"), 1713 to arrayOf("more"), 1717 to arrayOf("n"), 1726 to arrayOf("n"), 1732 to arrayOf("page"), 1743 to arrayOf("title"), 1746 to arrayOf("n"), 1763 to arrayOf("name"), 1828 to arrayOf("line"), 1829 to arrayOf("quote"), 1830 to arrayOf("n"), 1831 to arrayOf("n"), 1832 to arrayOf("n"), 1833 to arrayOf("n"), 1834 to arrayOf("n"), 1839 to arrayOf("held"), 1840 to arrayOf("machine"), 1841 to arrayOf("machine"), 1849 to arrayOf("count", "total"), 1850 to arrayOf("count"), 1851 to arrayOf("n"), 1863 to arrayOf("name"), 1865 to arrayOf("n", "c", "total"), 1866 to arrayOf("n", "c"), 1867 to arrayOf("n", "c", "total", "before"), 1868 to arrayOf("n", "c", "before"), 1880 to arrayOf("name"), 1881 to arrayOf("path"), 1884 to arrayOf("file"), 1885 to arrayOf("path", "n"), 1886 to arrayOf("why"), 1887 to arrayOf("n"), 1888 to arrayOf("name"), 1889 to arrayOf("name"), 1890 to arrayOf("name"), 1891 to arrayOf("n"), 1892 to arrayOf("shown", "n"), 1895 to arrayOf("path"), 1897 to arrayOf("n"), 1906 to arrayOf("status"), 1923 to arrayOf("name", "pct"), 1924 to arrayOf("name", "mb"), 1925 to arrayOf("name"), 1926 to arrayOf("name", "why"), 1944 to arrayOf("machine"), 1947 to arrayOf("n"), 1948 to arrayOf("ref"), 1949 to arrayOf("ref", "sheet"), 1950 to arrayOf("name"), 1951 to arrayOf("name"), 1952 to arrayOf("file", "folder"), 1953 to arrayOf("name", "error"), 1954 to arrayOf("name", "status"), 1955 to arrayOf("name", "error"), 1957 to arrayOf("name"), 1960 to arrayOf("code"), 1961 to arrayOf("error"), 1964 to arrayOf("error"), 1965 to arrayOf("error"), 1969 to arrayOf("error"), 1987 to arrayOf("done", "of"), 1989 to arrayOf("why"), 1990 to arrayOf("path"), 1991 to arrayOf("error"), 1992 to arrayOf("secs"), 1993 to arrayOf("secs"), 2005 to arrayOf("code"), 2006 to arrayOf("code"), 2009 to arrayOf("state"), 2014 to arrayOf("hide", "copy", "paste"), 2015 to arrayOf("n"), 2018 to arrayOf("name"), 2019 to arrayOf("name", "folder"), 2020 to arrayOf("name"), 2021 to arrayOf("name", "percent"), 2027 to arrayOf("folder"), 2037 to arrayOf("w", "h"), 2041 to arrayOf("path"), 2044 to arrayOf("why"), 2045 to arrayOf("mb"), 2048 to arrayOf("n"), 2049 to arrayOf("delete", "undo"), 2050 to arrayOf("delete", "undo"), 2051 to arrayOf("undo"), 2072 to arrayOf("what", "secs"), 2073 to arrayOf("file", "holder"), 2080 to arrayOf("what"), 2081 to arrayOf("what"), 2082 to arrayOf("editor", "why"), 2101 to arrayOf("files"), 2111 to arrayOf("why"), 2113 to arrayOf("title"), 2114 to arrayOf("title"), 2115 to arrayOf("version"), 2116 to arrayOf("version", "size", "folder"), 2117 to arrayOf("version", "size", "folder"), 2126 to arrayOf("title"), 2130 to arrayOf("dir", "files"), 2136 to arrayOf("why"), 2138 to arrayOf("code"), 2152 to arrayOf("origin"), 2154 to arrayOf("why"), 2165 to arrayOf("dir"), 2166 to arrayOf("path"), 2167 to arrayOf("home", "other"), 2169 to arrayOf("path"), 2170 to arrayOf("code", "log"), 2171 to arrayOf("log"), 2173 to arrayOf("addr"), 2186 to arrayOf("home"), 2187 to arrayOf("addr"), 2202 to arrayOf("dir", "why"), 2203 to arrayOf("dir"), 2218 to arrayOf("phase"), 2220 to arrayOf("why"), 2221 to arrayOf("what"), 2222 to arrayOf("code"), 2228 to arrayOf("label"), 2233 to arrayOf("kind"), 2235 to arrayOf("project"), 2248 to arrayOf("what"), 2250 to arrayOf("when"), 2254 to arrayOf("n"), 2255 to arrayOf("n"), 2256 to arrayOf("n"), 2258 to arrayOf("agent"), 2259 to arrayOf("effort"), 2261 to arrayOf("n"), 2263 to arrayOf("model"), 2278 to arrayOf("word"), 2285 to arrayOf("more", "step"), 2289 to arrayOf("name"), 2293 to arrayOf("max", "skipped"), 2296 to arrayOf("name"), 2297 to arrayOf("n"), 2298 to arrayOf("name"), 2299 to arrayOf("name"), 2305 to arrayOf("n"), 2306 to arrayOf("name"), 2308 to arrayOf("price"), 2311 to arrayOf("name"), 2313 to arrayOf("name"), 2314 to arrayOf("name"), 2315 to arrayOf("name"), 2316 to arrayOf("text"), 2319 to arrayOf("key"), 2320 to arrayOf("key"), 2321 to arrayOf("pct"), 2322 to arrayOf("when"), 2333 to arrayOf("n", "upstream"), 2342 to arrayOf("mb"), 2352 to arrayOf("path"), 2353 to arrayOf("path"), 2375 to arrayOf("id"), 2379 to arrayOf("model"), 2380 to arrayOf("platform"), 2381 to arrayOf("version"), 2384 to arrayOf("version", "from", "into"), 2385 to arrayOf("version", "from"), 2388 to arrayOf("version", "path"), 2389 to arrayOf("version", "path"), 2390 to arrayOf("version", "pin", "from"), 2391 to arrayOf("path"), 2392 to arrayOf("version", "path"), 2393 to arrayOf("version", "path", "set"), 2407 to arrayOf("turns", "input", "cread", "cwrite", "output", "cost"), 2414 to arrayOf("tool"), 2415 to arrayOf("tool"), 2416 to arrayOf("tool", "word"), 2417 to arrayOf("tool", "word"), 2418 to arrayOf("tool"), 2419 to arrayOf("tool"), 2420 to arrayOf("due"), 2421 to arrayOf("due"), 2422 to arrayOf("due"), 2423 to arrayOf("due"), 2424 to arrayOf("zone"), 2425 to arrayOf("zone"), 2426 to arrayOf("zone"), 2427 to arrayOf("zone"), 2428 to arrayOf("n"), 2429 to arrayOf("who"), 2430 to arrayOf("n", "who"), 2431 to arrayOf("harness"), 2432 to arrayOf("path"), 2433 to arrayOf("path"), 2434 to arrayOf("path"), 2437 to arrayOf("error", "line"), 2438 to arrayOf("label"), 2446 to arrayOf("who"), 2447 to arrayOf("who"), 2448 to arrayOf("label", "left", "when"), 2449 to arrayOf("left"), 2450 to arrayOf("name", "left"), 2451 to arrayOf("used"), 2452 to arrayOf("used", "limit"), 2453 to arrayOf("used", "reason"), 2454 to arrayOf("used", "limit", "reason"), 2456 to arrayOf("provider"), 2457 to arrayOf("used", "window", "pct"), 2458 to arrayOf("rate"), 2468 to arrayOf("n", "r"), 2473 to arrayOf("time", "n"), 2477 to arrayOf("n", "m"), 2479 to arrayOf("pct"), 2480 to arrayOf("cost", "n"), 2484 to arrayOf("in", "out", "cread", "cwrite"), 2485 to arrayOf("in", "out", "cread", "cwrite", "n"), 2494 to arrayOf("turns", "input", "cread", "cwrite", "output"), 2495 to arrayOf("left", "when"), 2496 to arrayOf("left", "when"), 2497 to arrayOf("left", "when"), 2498 to arrayOf("left", "when"), 2522 to arrayOf("n"), 2545 to arrayOf("when"), 2552 to arrayOf("phrase", "now"), 2563 to arrayOf("s"), 2569 to arrayOf("now"), 2570 to arrayOf("now", "nudge", "sent", "undone"), 2580 to arrayOf("e"), 2581 to arrayOf("a", "ams", "b", "bms"), 2582 to arrayOf("ms"), 2583 to arrayOf("e"), 2584 to arrayOf("t"), 2585 to arrayOf("t"), 2586 to arrayOf("t"), 2592 to arrayOf("why"), 2602 to arrayOf("apps"), 2612 to arrayOf("n"), 2613 to arrayOf("n", "k"), 2618 to arrayOf("stt", "conf"), 2619 to arrayOf("words"), 2629 to arrayOf("into"), 2632 to arrayOf("origin"), 2644 to arrayOf("url"), 2646 to arrayOf("url"), 2654 to arrayOf("i", "n"), 2655 to arrayOf("d", "n"), 2664 to arrayOf("version"), 2665 to arrayOf("version"), 2666 to arrayOf("version"), 2669 to arrayOf("path"), 2677 to arrayOf("addr"), 2681 to arrayOf("label"), 2683 to arrayOf("label"), 2684 to arrayOf("label"), 2688 to arrayOf("label"), 2693 to arrayOf("from"), 2710 to arrayOf("done", "of"), 2716 to arrayOf("n"), 2717 to arrayOf("t", "m"), 2718 to arrayOf("m"), 2719 to arrayOf("b", "m"), 2720 to arrayOf("r", "p"), 2721 to arrayOf("n"), 2722 to arrayOf("n"), 2723 to arrayOf("n"), 2724 to arrayOf("n"), 2727 to arrayOf("n"), 2729 to arrayOf("n"), 2737 to arrayOf("n"), 2743 to arrayOf("name", "gb", "path"), 2745 to arrayOf("path", "why"), 2747 to arrayOf("names"), 2749 to arrayOf("why"), 2750 to arrayOf("p", "pn", "t", "tn", "e", "en"), 2751 to arrayOf("done", "total"), 2752 to arrayOf("n"), 2753 to arrayOf("what"), 2754 to arrayOf("n"), 2755 to arrayOf("n"), 2758 to arrayOf("what"), 2759 to arrayOf("n"), 2761 to arrayOf("why", "from"), 2762 to arrayOf("why"), 2768 to arrayOf("path"), 2769 to arrayOf("path", "who"), 2770 to arrayOf("path"), 2771 to arrayOf("path", "cmd"), 2772 to arrayOf("version", "path"), 2773 to arrayOf("version", "path"), 2774 to arrayOf("version", "path", "who"), 2775 to arrayOf("version", "path"), 2776 to arrayOf("version", "path", "cmd"), 2779 to arrayOf("cmd"), 2789 to arrayOf("name", "version", "path"), 2790 to arrayOf("path", "why"), 2791 to arrayOf("name"), 2793 to arrayOf("version", "cli"), 2794 to arrayOf("cli"), 2796 to arrayOf("version"), 2797 to arrayOf("version"), 2799 to arrayOf("version"), 2801 to arrayOf("version"), 2803 to arrayOf("computer"), 2804 to arrayOf("version", "cli"), 2805 to arrayOf("cli"), 2806 to arrayOf("version", "cli"), 2807 to arrayOf("cli"), 2829 to arrayOf("n"), 2834 to arrayOf("code"), 2836 to arrayOf("e"), 2849 to arrayOf("n"), 2854 to arrayOf("channel"), 2868 to arrayOf("project"), 2874 to arrayOf("n"), 2886 to arrayOf("m"), 2898 to arrayOf("m"), 2901 to arrayOf("m"), 2908 to arrayOf("pages"), 2910 to arrayOf("name"), 2913 to arrayOf("name"), 2922 to arrayOf("d", "n"), 2943 to arrayOf("n", "tools"), 2944 to arrayOf("n", "tools", "d"), 2945 to arrayOf("n", "d"), 2946 to arrayOf("n", "what"), 2947 to arrayOf("n", "d", "what"), 2951 to arrayOf("head"), 2957 to arrayOf("name", "path"), 2963 to arrayOf("page", "net", "near"), 2964 to arrayOf("page", "what"), 2965 to arrayOf("ref"), 2969 to arrayOf("page"), 2992 to arrayOf("n"), 2993 to arrayOf("n"), 2994 to arrayOf("n"), 2996 to arrayOf("hub"), 3018 to arrayOf("project"), 3020 to arrayOf("n"), 3021 to arrayOf("n"), 3022 to arrayOf("word"), 3023 to arrayOf("n"), 3041 to arrayOf("name"), 3049 to arrayOf("answer"), 3054 to arrayOf("why"), 3056 to arrayOf("hub"), 3062 to arrayOf("from", "to"), 3069 to arrayOf("project"), 3079 to arrayOf("name"), 3083 to arrayOf("n"), 3089 to arrayOf("code"), 3090 to arrayOf("hub"), 3091 to arrayOf("hub"), 3092 to arrayOf("hub"), 3106 to arrayOf("n"), 3107 to arrayOf("n"), 3123 to arrayOf("status"), 3125 to arrayOf("status"), 3154 to arrayOf("project"), 3158 to arrayOf("code"), 3160 to arrayOf("why"), 3168 to arrayOf("title"), 3174 to arrayOf("title"), 3176 to arrayOf("q"), 3177 to arrayOf("title"), 3182 to arrayOf("room"), 3186 to arrayOf("q"), 3196 to arrayOf("title"), 3201 to arrayOf("n"), 3202 to arrayOf("n"), 3207 to arrayOf("at"), 3215 to arrayOf("size"), 3217 to arrayOf("n", "total"), 3234 to arrayOf("n"), 3235 to arrayOf("what"), 3238 to arrayOf("device"), 3239 to arrayOf("device"), 3248 to arrayOf("word", "count"), 3249 to arrayOf("heard"), 3261 to arrayOf("files"), 3262 to arrayOf("files"), 3265 to arrayOf("name"), 3293 to arrayOf("n"), 3294 to arrayOf("n"), 3305 to arrayOf("n"), 3339 to arrayOf("root"), 3340 to arrayOf("path"), 3363 to arrayOf("name"), 3366 to arrayOf("until"), 3367 to arrayOf("error"), 3374 to arrayOf("url"), 3378 to arrayOf("name"), 3379 to arrayOf("name"), 3387 to arrayOf("code", "hub", "until"), 3388 to arrayOf("url"), 3392 to arrayOf("kinds"), 3393 to arrayOf("address"), 3395 to arrayOf("address"), 3398 to arrayOf("url"), 3399 to arrayOf("url"), 3400 to arrayOf("url"), 3401 to arrayOf("url", "via"), 3406 to arrayOf("name"), 3407 to arrayOf("url", "check", "left"), 3409 to arrayOf("check"), 3410 to arrayOf("address"), 3411 to arrayOf("name"), 3412 to arrayOf("error"), 3413 to arrayOf("url"), 3414 to arrayOf("url"), 3421 to arrayOf("code", "address", "left"), 3427 to arrayOf("name"), 3428 to arrayOf("name"), 3439 to arrayOf("address"), 3446 to arrayOf("code", "body"), 3449 to arrayOf("code", "body"), 3455 to arrayOf("window", "used"), 3456 to arrayOf("window", "used", "when"), 3457 to arrayOf("window", "used"), 3458 to arrayOf("window", "used", "when"), 3459 to arrayOf("provider"), 3471 to arrayOf("label"), 3472 to arrayOf("when"), 3474 to arrayOf("provider"), 3475 to arrayOf("provider", "title", "why"), 3495 to arrayOf("reason"), 3503 to arrayOf("code"), 3512 to arrayOf("name"), 3515 to arrayOf("version"), 3516 to arrayOf("version"), 3517 to arrayOf("version"), 3519 to arrayOf("version"), 3520 to arrayOf("version"), 3521 to arrayOf("version"), 3522 to arrayOf("version", "why"), 3523 to arrayOf("version"), 3525 to arrayOf("code"), 3541 to arrayOf("name"), 3548 to arrayOf("count"), 3549 to arrayOf("title"), 3550 to arrayOf("name"), 3553 to arrayOf("n", "holder"), 3554 to arrayOf("n", "title"), 3555 to arrayOf("title"), 3558 to arrayOf("n"), 3559 to arrayOf("n"), 3560 to arrayOf("n"), 3561 to arrayOf("n"), 3562 to arrayOf("harness", "typed", "type", "remote", "host", "wt", "branch"), 3572 to arrayOf("pid"), 3577 to arrayOf("left"), 3578 to arrayOf("left"), 3584 to arrayOf("left"), 3585 to arrayOf("left"), 3586 to arrayOf("left"), 3587 to arrayOf("left"), 3588 to arrayOf("label", "left"), 3589 to arrayOf("when"), 3590 to arrayOf("used"), 3591 to arrayOf("used", "limit"), 3613 to arrayOf("tracking"), 3617 to arrayOf("total"), 3618 to arrayOf("price"), 3619 to arrayOf("price"), 3624 to arrayOf("n"), 3625 to arrayOf("parts"), 3626 to arrayOf("note"), 3627 to arrayOf("error"), 3628 to arrayOf("error", "parts"), 3633 to arrayOf("state"), 3634 to arrayOf("name", "path"), 3635 to arrayOf("name", "path", "why"), 3637 to arrayOf("code"), 3641 to arrayOf("detail"), 3643 to arrayOf("why"), 3644 to arrayOf("parts"), 3647 to arrayOf("build", "to"), 3648 to arrayOf("build"), 3649 to arrayOf("build", "skip"), 3651 to arrayOf("why"), 3652 to arrayOf("why"), 3653 to arrayOf("build"), 3654 to arrayOf("build", "why"), 3655 to arrayOf("build"), 3656 to arrayOf("build"), 3660 to arrayOf("build"), 3661 to arrayOf("build"), 3663 to arrayOf("build"), 3670 to arrayOf("build"), 3704 to arrayOf("step"), 3705 to arrayOf("p", "pt", "t", "tt", "e", "et"), 3706 to arrayOf("done", "total"), 3707 to arrayOf("n"), 3708 to arrayOf("n"), 3709 to arrayOf("n"), 3714 to arrayOf("n"), 3717 to arrayOf("why"), 3718 to arrayOf("why", "from"), 3719 to arrayOf("error"), 3721 to arrayOf("n"), 3722 to arrayOf("n"), 3726 to arrayOf("n"), 3729 to arrayOf("name", "gb", "path"), 3730 to arrayOf("path", "why"), 3731 to arrayOf("names"), 3733 to arrayOf("why"), 3744 to arrayOf("n", "total"), 3748 to arrayOf("title"), 3750 to arrayOf("n"), 3754 to arrayOf("name"), 3755 to arrayOf("title"), 3756 to arrayOf("note"), 3758 to arrayOf("machine"), 3759 to arrayOf("machines"), 3760 to arrayOf("machine"), 3771 to arrayOf("n"), 3773 to arrayOf("n"), 3777 to arrayOf("name"), 3780 to arrayOf("name"), 3797 to arrayOf("why"), 3803 to arrayOf("project"), 3844 to arrayOf("path"), 3845 to arrayOf("path"), 3847 to arrayOf("have", "total"), 3852 to arrayOf("n"), 3861 to arrayOf("hub"), 3864 to arrayOf("title"), 3868 to arrayOf("project"), 3869 to arrayOf("project"), 3870 to arrayOf("n"), 3871 to arrayOf("hub"), 3873 to arrayOf("n"), 3874 to arrayOf("n"), 3875 to arrayOf("model"), 3881 to arrayOf("name"), 3900 to arrayOf("word"), 3906 to arrayOf("answer"), 3916 to arrayOf("version", "build"), 3917 to arrayOf("hub"), 3922 to arrayOf("name"), 3925 to arrayOf("when", "who", "mark"), 3929 to arrayOf("who"), 3933 to arrayOf("time"), 3934 to arrayOf("address"), 3936 to arrayOf("kind", "name"), 3951 to arrayOf("title"), 3952 to arrayOf("query"), 3955 to arrayOf("room"), 3956 to arrayOf("query"), 3958 to arrayOf("n"), 3959 to arrayOf("n"), 3960 to arrayOf("n"), 3966 to arrayOf("size"), 3970 to arrayOf("n"), 3971 to arrayOf("n"), 3972 to arrayOf("n"), 3986 to arrayOf("status"), 3988 to arrayOf("status"), 4139 to arrayOf("code"), 4141 to arrayOf("n"), 4143 to arrayOf("why"), 4155 to arrayOf("done", "of"), 4159 to arrayOf("thread"), 4162 to arrayOf("n"), 4170 to arrayOf("title"), 4171 to arrayOf("note"), 4172 to arrayOf("label"), 4173 to arrayOf("machine"), 4174 to arrayOf("machine"), 4181 to arrayOf("at", "total"), 4182 to arrayOf("at", "total"), 4186 to arrayOf("machine"), 4187 to arrayOf("machine"), 4188 to arrayOf("machines"), 4190 to arrayOf("device"), 4197 to arrayOf("price"), 4198 to arrayOf("price"), 4205 to arrayOf("home"), 4210 to arrayOf("from"), 4212 to arrayOf("note"), 4213 to arrayOf("note"), 4215 to arrayOf("v"), 4216 to arrayOf("v"), 4217 to arrayOf("v", "who"), 4219 to arrayOf("who"), 4220 to arrayOf("v"), 4222 to arrayOf("v", "cmd"), 4223 to arrayOf("cmd"), 4228 to arrayOf("v", "path"), 4229 to arrayOf("v", "note"), 4230 to arrayOf("v"), 4235 to arrayOf("tool"), 4236 to arrayOf("tool"), 4261 to arrayOf("n", "w"), 4262 to arrayOf("why"), 4263 to arrayOf("state", "why"), 4275 to arrayOf("project"), 4276 to arrayOf("n"), 4287 to arrayOf("why"), 4293 to arrayOf("name"), 4304 to arrayOf("project"), 4309 to arrayOf("n"), 4317 to arrayOf("names"), 4325 to arrayOf("dest"), 4327 to arrayOf("repo"), 4328 to arrayOf("repo"), 4330 to arrayOf("url"), 4345 to arrayOf("time"), 4368 to arrayOf("group"), 4372 to arrayOf("project"), 4373 to arrayOf("n"), 4374 to arrayOf("n"), 4375 to arrayOf("n"), 4383 to arrayOf("n"), 4440 to arrayOf("n"), 4441 to arrayOf("n"), 4442 to arrayOf("a", "b"), 4443 to arrayOf("n"), 4445 to arrayOf("parts", "lines"), 4446 to arrayOf("n"), 4477 to arrayOf("what", "project", "fab"), 4478 to arrayOf("rev", "day"), 4486 to arrayOf("n"), 4497 to arrayOf("layer"), 4498 to arrayOf("n"), 4503 to arrayOf("board"), 4515 to arrayOf("others"), 4516 to arrayOf("must", "should", "notes"), 4517 to arrayOf("id", "w"), 4527 to arrayOf("what"), 4530 to arrayOf("why"), 4531 to arrayOf("why"), 4538 to arrayOf("n"), 4554 to arrayOf("price", "n"), 4555 to arrayOf("n", "need"), 4556 to arrayOf("n"), 4557 to arrayOf("n"), 4558 to arrayOf("cost"), 4559 to arrayOf("cost"), 4572 to arrayOf("day", "n"), 4573 to arrayOf("day"), 4574 to arrayOf("cost", "n", "lines"), 4575 to arrayOf("stock", "price"), 4576 to arrayOf("lines"), 4597 to arrayOf("host"), 4608 to arrayOf("n"), 4609 to arrayOf("a", "b"), 4610 to arrayOf("n"), 4611 to arrayOf("n"), 4614 to arrayOf("day"), 4615 to arrayOf("n"), 4656 to arrayOf("turn"), 4770 to arrayOf("text"), 4773 to arrayOf("repo", "dest"), 4774 to arrayOf("repo", "dest"), 4775 to arrayOf("repo"), 4780 to arrayOf("dir"), 4781 to arrayOf("dir"), 4785 to arrayOf("editor", "job", "secs"), 4786 to arrayOf("editor", "secs"), 4787 to arrayOf("editor"), 4804 to arrayOf("time"), 4810 to arrayOf("status"), 4818 to arrayOf("time"), 4819 to arrayOf("time", "dur"), 4822 to arrayOf("answer"), 4826 to arrayOf("type"), 4827 to arrayOf("max"), 4855 to arrayOf("bytes", "tokens"), 4888 to arrayOf("what"), 4892 to arrayOf("n"), 4894 to arrayOf("n"), 4918 to arrayOf("n"), 4919 to arrayOf("done", "total"), 4927 to arrayOf("v"), 4928 to arrayOf("x", "y"), 4934 to arrayOf("machine"), 4937 to arrayOf("days"), 4938 to arrayOf("warnings"), 4944 to arrayOf("n"), 4949 to arrayOf("n"), 4951 to arrayOf("found", "total", "q"), 4954 to arrayOf("model"), 4955 to arrayOf("model", "conf")) } val common_cancel: String get() = Tr.s(0) val common_delete: String get() = Tr.s(1) @@ -27805,617 +27810,618 @@ object Msg { fun mobile_snooze_wakes(time: Any): String = Tr.f(4345, arrayOf(time)) val mobile_bench_all: String get() = Tr.s(4346) val mobile_snooze_for: String get() = Tr.s(4347) - val sidebar_sections_needs: String get() = Tr.s(4348) - val sidebar_sections_pinned: String get() = Tr.s(4349) - val sidebar_sections_active: String get() = Tr.s(4350) - val sidebar_sections_quiet: String get() = Tr.s(4351) - val sidebar_sections_quiet_hint: String get() = Tr.s(4352) - val sidebar_sections_running_word: String get() = Tr.s(4353) - val sidebar_sections_recent: String get() = Tr.s(4354) - val sidebar_sections_limit: String get() = Tr.s(4355) - val sidebar_sections_cut: String get() = Tr.s(4356) - val sidebar_sections_monitoring: String get() = Tr.s(4357) - val sidebar_sections_stopped: String get() = Tr.s(4358) - val sidebar_sections_done: String get() = Tr.s(4359) - val sidebar_sections_failed: String get() = Tr.s(4360) - val sidebar_sections_rename: String get() = Tr.s(4361) - val sidebar_sections_pin: String get() = Tr.s(4362) - val sidebar_sections_unpin: String get() = Tr.s(4363) - val sidebar_sections_quiet_make: String get() = Tr.s(4364) - val sidebar_sections_quiet_back: String get() = Tr.s(4365) - val sidebar_sections_quiet_hint2: String get() = Tr.s(4366) - fun gpui_sections_move_to(group: Any): String = Tr.f(4367, arrayOf(group)) - val sidebar_sections_move: String get() = Tr.s(4368) - val sidebar_sections_new_group: String get() = Tr.s(4369) - val sidebar_sections_new_group_title: String get() = Tr.s(4370) - fun sidebar_sections_remove_ask(project: Any): String = Tr.f(4371, arrayOf(project)) - fun gpui_sections_running(n: Number): String = Tr.f(4372, arrayOf(n)) - fun gpui_sections_rest(n: Number): String = Tr.f(4373, arrayOf(n)) - fun gpui_projects_mech(n: Any): String = Tr.f(4374, arrayOf(n)) - val gpui_open_folder: String get() = Tr.s(4375) - val gpui_picker_none: String get() = Tr.s(4376) - val gpui_picker_key_select: String get() = Tr.s(4377) - val gpui_picker_key_into: String get() = Tr.s(4378) - val gpui_picker_key_complete: String get() = Tr.s(4379) - val gpui_picker_key_open: String get() = Tr.s(4380) - val gpui_picker_added: String get() = Tr.s(4381) - fun gpui_picker_more_typed(n: Any): String = Tr.f(4382, arrayOf(n)) - val gpui_clone_tab: String get() = Tr.s(4383) - val gpui_clone_change: String get() = Tr.s(4384) - val gpui_clone_thread: String get() = Tr.s(4385) - val gpui_clone_retry: String get() = Tr.s(4386) - val gpui_clone_signin: String get() = Tr.s(4387) - val gpui_clone_back: String get() = Tr.s(4388) - val gpui_clone_open_thread: String get() = Tr.s(4389) - val gpui_clone_open_project: String get() = Tr.s(4390) - val gpui_clone_private: String get() = Tr.s(4391) - val gpui_clone_loading: String get() = Tr.s(4392) - val gpui_clone_signin_list: String get() = Tr.s(4393) - val gpui_clone_signin_code: String get() = Tr.s(4394) - val gpui_clone_signin_asking: String get() = Tr.s(4395) - val gpui_clone_signin_done: String get() = Tr.s(4396) - val gpui_clone_cancel: String get() = Tr.s(4397) - val gpui_picker_key_pick: String get() = Tr.s(4398) - val gpui_clone_phase_connecting: String get() = Tr.s(4399) - val gpui_clone_phase_receiving: String get() = Tr.s(4400) - val gpui_clone_phase_resolving: String get() = Tr.s(4401) - val gpui_clone_phase_updating: String get() = Tr.s(4402) - val gpui_clone_phase_counting: String get() = Tr.s(4403) - val gpui_clone_phase_compressing: String get() = Tr.s(4404) - val gpui_clone_phase_lfs: String get() = Tr.s(4405) - val gpui_clone_phase_adding: String get() = Tr.s(4406) - val gpui_clone_phase_starting: String get() = Tr.s(4407) - val gpui_assembly: String get() = Tr.s(4408) - val gpui_mech: String get() = Tr.s(4409) - val gpui_readme: String get() = Tr.s(4410) - val gpui_board: String get() = Tr.s(4411) - val gpui_schematic: String get() = Tr.s(4412) - val gpui_view_three_d: String get() = Tr.s(4413) - val gpui_files: String get() = Tr.s(4414) - val gpui_usage_bot: String get() = Tr.s(4415) - val gpui_usage_tokens: String get() = Tr.s(4416) - val gpui_usage_accounts_tip: String get() = Tr.s(4417) - val gpui_usage_feeds: String get() = Tr.s(4418) - val gpui_usage_lanes: String get() = Tr.s(4419) - val gpui_usage_turn_live: String get() = Tr.s(4420) - val gpui_usage_chat: String get() = Tr.s(4421) - val gpui_usage_today: String get() = Tr.s(4422) - val gpui_usage_prefs: String get() = Tr.s(4423) - val gpui_usage_handover: String get() = Tr.s(4424) - val gpui_usage_none_waiting: String get() = Tr.s(4425) - val gpui_usage_session: String get() = Tr.s(4426) - val gpui_usage_last_handover: String get() = Tr.s(4427) - val gpui_usage_triage: String get() = Tr.s(4428) - val gpui_usage_office: String get() = Tr.s(4429) - val gpui_usage_office_lower: String get() = Tr.s(4430) - val gpui_usage_compact: String get() = Tr.s(4431) - val gpui_usage_switch: String get() = Tr.s(4432) - val gpui_usage_note: String get() = Tr.s(4433) - val gpui_usage_lanes_note: String get() = Tr.s(4434) - val gpui_usage_lanes_routines: String get() = Tr.s(4435) - val gpui_usage_turns_many: String get() = Tr.s(4436) - val gpui_usage_turns_full: String get() = Tr.s(4437) - val gpui_usage_turns_one: String get() = Tr.s(4438) - fun gpui_usage_turns_n(n: Any): String = Tr.f(4439, arrayOf(n)) - fun gpui_usage_left(n: Any): String = Tr.f(4440, arrayOf(n)) - fun gpui_usage_of(a: Any, b: Any): String = Tr.f(4441, arrayOf(a, b)) - fun gpui_usage_context(n: Any): String = Tr.f(4442, arrayOf(n)) - val gpui_usage_noread: String get() = Tr.s(4443) - fun gpui_mgmt_bom_summary(parts: Number, lines: Number): String = Tr.f(4444, arrayOf(parts, lines)) - fun gpui_mgmt_bom_more(n: Number): String = Tr.f(4445, arrayOf(n)) - val gpui_mgmt_dock_right: String get() = Tr.s(4446) - val gpui_mgmt_dock_bottom: String get() = Tr.s(4447) - val gpui_mgmt_close: String get() = Tr.s(4448) - val gpui_mgmt_bom_saved: String get() = Tr.s(4449) - val gpui_mgmt_bom_reading: String get() = Tr.s(4450) - val gpui_mgmt_bom_nomatch: String get() = Tr.s(4451) - val gpui_mgmt_bom_nompn: String get() = Tr.s(4452) - val gpui_mgmt_filter: String get() = Tr.s(4453) - val gpui_mgmt_bom_noparts: String get() = Tr.s(4454) - val gpui_mgmt_bom_dnp: String get() = Tr.s(4455) - val gpui_mgmt_fab_tab: String get() = Tr.s(4456) - val gpui_mgmt_fab_drc_current: String get() = Tr.s(4457) - val gpui_mgmt_fab_drc_stale: String get() = Tr.s(4458) - val gpui_mgmt_fab_drc_update: String get() = Tr.s(4459) - val gpui_mgmt_fab_drc_none: String get() = Tr.s(4460) - val gpui_mgmt_fab_drc_write: String get() = Tr.s(4461) - val gpui_mgmt_fab_drc_noproject: String get() = Tr.s(4462) - val gpui_mgmt_fab_tier_extra: String get() = Tr.s(4463) - val gpui_mgmt_fab_tier_free: String get() = Tr.s(4464) - val gpui_mgmt_fab_reading: String get() = Tr.s(4465) - val gpui_mgmt_fab_thefab: String get() = Tr.s(4466) - val gpui_mgmt_fab_refresh: String get() = Tr.s(4467) - val gpui_mgmt_fab_apply: String get() = Tr.s(4468) - val gpui_mgmt_fab_changed: String get() = Tr.s(4469) - val gpui_mgmt_fab_seen: String get() = Tr.s(4470) - val gpui_mgmt_fab_limit: String get() = Tr.s(4471) - val gpui_mgmt_fab_free: String get() = Tr.s(4472) - val gpui_mgmt_fab_extra: String get() = Tr.s(4473) - val gpui_mgmt_fab_readcol: String get() = Tr.s(4474) - val gpui_mgmt_fab_derived: String get() = Tr.s(4475) - fun gpui_mgmt_fab_suggestion(what: Any, project: Any, fab: Any): String = Tr.f(4476, arrayOf(what, project, fab)) - fun gpui_mgmt_fab_read(rev: Any, day: Any): String = Tr.f(4477, arrayOf(rev, day)) - val gpui_mgmt_fab_reviewing: String get() = Tr.s(4478) - val gpui_mgmt_fab_noreview: String get() = Tr.s(4479) - val gpui_mgmt_fab_findings: String get() = Tr.s(4480) - val gpui_mgmt_fab_reviewbtn: String get() = Tr.s(4481) - val gpui_mgmt_fab_judge: String get() = Tr.s(4482) - val gpui_mgmt_plan_reading: String get() = Tr.s(4483) - val gpui_mgmt_plan_none: String get() = Tr.s(4484) - fun gpui_mgmt_plan_awaiting(n: Number): String = Tr.f(4485, arrayOf(n)) - val gpui_mgmt_plan_nothing: String get() = Tr.s(4486) - val gpui_mgmt_plan_saved: String get() = Tr.s(4487) - val gpui_mgmt_plan_all: String get() = Tr.s(4488) - val gpui_mgmt_plan_stop: String get() = Tr.s(4489) - val gpui_mgmt_plan_hide: String get() = Tr.s(4490) - val gpui_mgmt_plan_show: String get() = Tr.s(4491) - val gpui_mgmt_plan_done: String get() = Tr.s(4492) - val gpui_mgmt_plan_layer: String get() = Tr.s(4493) - val gpui_mgmt_plan_reject: String get() = Tr.s(4494) - val gpui_mgmt_plan_keysnote: String get() = Tr.s(4495) - fun gpui_mgmt_plan_reference(layer: Any): String = Tr.f(4496, arrayOf(layer)) - fun gpui_mgmt_plan_nets(n: Number): String = Tr.f(4497, arrayOf(n)) - val gpui_mgmt_plan_tab: String get() = Tr.s(4498) - val gpui_mgmt_plan_before: String get() = Tr.s(4499) - val gpui_mgmt_plan_onwords: String get() = Tr.s(4500) - val gpui_mgmt_plan_offwords: String get() = Tr.s(4501) - fun gpui_mgmt_plan_elsewhere(board: Any): String = Tr.f(4502, arrayOf(board)) - val gpui_mgmt_plan_openboard: String get() = Tr.s(4503) - val gpui_mgmt_plan_noboard: String get() = Tr.s(4504) - val gpui_mgmt_plan_drawn: String get() = Tr.s(4505) - val gpui_pick_planonce: String get() = Tr.s(4506) - val gpui_pick_planonce_note: String get() = Tr.s(4507) - val hub_view_board_unlisted: String get() = Tr.s(4508) - val gpui_mgmt_bom_stocknote: String get() = Tr.s(4509) - val hub_order_pick_more: String get() = Tr.s(4510) - val hub_order_pick_phone: String get() = Tr.s(4511) - val hub_order_pick_go: String get() = Tr.s(4512) - val gpui_plan_before_routing_desc: String get() = Tr.s(4513) - fun gpui_mgmt_bom_shared(others: Any): String = Tr.f(4514, arrayOf(others)) - fun gpui_mgmt_fab_review(must: Any, should: Any, notes: Any): String = Tr.f(4515, arrayOf(must, should, notes)) - fun gpui_mgmt_fab_stackup(id: Any, w: Any): String = Tr.f(4516, arrayOf(id, w)) - val gpui_mgmt_fab_proposed: String get() = Tr.s(4517) - val gpui_mgmt_fab_use: String get() = Tr.s(4518) - val gpui_keys_mgmt_bom: String get() = Tr.s(4519) - val gpui_keys_mgmt_checks: String get() = Tr.s(4520) - val gpui_keys_mgmt_life: String get() = Tr.s(4521) - val gpui_mgmt_checks_reading: String get() = Tr.s(4522) - val gpui_mgmt_checks_searching: String get() = Tr.s(4523) - val gpui_mgmt_checks_run: String get() = Tr.s(4524) - val gpui_mgmt_checks_running: String get() = Tr.s(4525) - fun gpui_mgmt_checks_behind(what: Any): String = Tr.f(4526, arrayOf(what)) - val gpui_mgmt_checks_stale: String get() = Tr.s(4527) - val gpui_mgmt_checks_liveunsaved: String get() = Tr.s(4528) - fun gpui_mgmt_checks_waiting(why: Any): String = Tr.f(4529, arrayOf(why)) - fun gpui_mgmt_checks_failed(why: Any): String = Tr.f(4530, arrayOf(why)) - val gpui_mgmt_checks_all: String get() = Tr.s(4531) - val gpui_mgmt_checks_errors: String get() = Tr.s(4532) - val gpui_mgmt_checks_warnings: String get() = Tr.s(4533) - val gpui_mgmt_checks_excluded: String get() = Tr.s(4534) - val gpui_mgmt_checks_fix: String get() = Tr.s(4535) - val gpui_mgmt_checks_reexport: String get() = Tr.s(4536) - fun gpui_mgmt_checks_more(n: Number): String = Tr.f(4537, arrayOf(n)) - val gpui_mgmt_checks_fewer: String get() = Tr.s(4538) - val gpui_mgmt_checks_none: String get() = Tr.s(4539) - val gpui_mgmt_checks_nomatch: String get() = Tr.s(4540) - val gpui_mgmt_checks_library: String get() = Tr.s(4541) - val gpui_mgmt_checks_withlib: String get() = Tr.s(4542) - val gpui_mgmt_checks_fullrun: String get() = Tr.s(4543) - val gpui_mgmt_checks_allsources: String get() = Tr.s(4544) - val gpui_mgmt_checks_judged: String get() = Tr.s(4545) - val gpui_mgmt_bom_dnp_tip: String get() = Tr.s(4546) - val gpui_mgmt_bom_writing: String get() = Tr.s(4547) - val gpui_mgmt_bom_inkicad: String get() = Tr.s(4548) - val gpui_mgmt_bom_saved_file: String get() = Tr.s(4549) - val gpui_mgmt_bom_fab: String get() = Tr.s(4550) - val gpui_mgmt_bom_mpn_ph: String get() = Tr.s(4551) - val gpui_mgmt_bom_fab_ph: String get() = Tr.s(4552) - fun gpui_mgmt_bom_each(price: Any, n: Any): String = Tr.f(4553, arrayOf(price, n)) - fun gpui_mgmt_bom_out(n: Any, need: Any): String = Tr.f(4554, arrayOf(n, need)) - fun gpui_mgmt_bom_low(n: Any): String = Tr.f(4555, arrayOf(n)) - fun gpui_mgmt_bom_in(n: Any): String = Tr.f(4556, arrayOf(n)) - fun gpui_mgmt_bom_cost(cost: Any): String = Tr.f(4557, arrayOf(cost)) - fun gpui_mgmt_bom_cost_least(cost: Any): String = Tr.f(4558, arrayOf(cost)) - val gpui_mgmt_bom_checking: String get() = Tr.s(4559) - val gpui_mgmt_bom_notknown: String get() = Tr.s(4560) - val gpui_mgmt_bom_stock: String get() = Tr.s(4561) - val gpui_mgmt_bom_alts: String get() = Tr.s(4562) - val gpui_mgmt_bom_alts_looking: String get() = Tr.s(4563) - val gpui_mgmt_bom_alts_none: String get() = Tr.s(4564) - val gpui_mgmt_bom_alts_use: String get() = Tr.s(4565) - val gpui_mgmt_bom_class_basic: String get() = Tr.s(4566) - val gpui_mgmt_bom_class_extended: String get() = Tr.s(4567) - val gpui_mgmt_bom_class_preferred: String get() = Tr.s(4568) - val gpui_mgmt_bom_notinstock: String get() = Tr.s(4569) - val gpui_mgmt_bom_off: String get() = Tr.s(4570) - fun gpui_mgmt_life_since(day: Any, n: Number): String = Tr.f(4571, arrayOf(day, n)) - fun gpui_mgmt_life_one(day: Any): String = Tr.f(4572, arrayOf(day)) - fun gpui_mgmt_life_now(cost: Any, n: Any, lines: Any): String = Tr.f(4573, arrayOf(cost, n, lines)) - fun gpui_mgmt_life_part_now(stock: Any, price: Any): String = Tr.f(4574, arrayOf(stock, price)) - fun gpui_mgmt_life_instock(lines: Any): String = Tr.f(4575, arrayOf(lines)) - val gpui_mgmt_life_board: String get() = Tr.s(4576) - val gpui_mgmt_life_price: String get() = Tr.s(4577) - val gpui_mgmt_life_active: String get() = Tr.s(4578) - val gpui_mgmt_life_nrnd: String get() = Tr.s(4579) - val gpui_mgmt_life_eol: String get() = Tr.s(4580) - val gpui_mgmt_life_unknown: String get() = Tr.s(4581) - val gpui_mgmt_life_nolines: String get() = Tr.s(4582) - val gpui_mgmt_life_noread: String get() = Tr.s(4583) - val gpui_mgmt_life_reading: String get() = Tr.s(4584) - val gpui_mgmt_life_nopart: String get() = Tr.s(4585) - val gpui_mgmt_life_tab: String get() = Tr.s(4586) - val gpui_mgmt_bom_paused: String get() = Tr.s(4587) - val gpui_mgmt_bom_paused_tip: String get() = Tr.s(4588) - val gpui_keys_mgmt_fab: String get() = Tr.s(4589) - val gpui_mgmt_bom_putback: String get() = Tr.s(4590) - val gpui_mgmt_bom_nochange: String get() = Tr.s(4591) - val gpui_mgmt_bom_deferred: String get() = Tr.s(4592) - val gpui_mgmt_bom_inkicad_save: String get() = Tr.s(4593) - val gpui_mgmt_bom_undo_tip: String get() = Tr.s(4594) - val gpui_mgmt_bom_undo: String get() = Tr.s(4595) - fun gpui_mgmt_checks_on(host: Any): String = Tr.f(4596, arrayOf(host)) - val gpui_gerbers: String get() = Tr.s(4597) - val gpui_gerbers_vs: String get() = Tr.s(4598) - val gpui_gerbers_vs_tip: String get() = Tr.s(4599) - val gpui_gerbers_gerbview: String get() = Tr.s(4600) - val gpui_gerbers_gerbview_tip: String get() = Tr.s(4601) - val gpui_mgmt_bom_saved_state: String get() = Tr.s(4602) - val gpui_mgmt_bom_live_tip: String get() = Tr.s(4603) - val gpui_mgmt_bom_saved_tip: String get() = Tr.s(4604) - val gpui_mgmt_bom_price: String get() = Tr.s(4605) - val gpui_mgmt_bom_class: String get() = Tr.s(4606) - fun gpui_mgmt_life_unknown_n(n: Any): String = Tr.f(4607, arrayOf(n)) - fun gpui_mgmt_life_unknown_tip(a: Any, b: Any): String = Tr.f(4608, arrayOf(a, b)) - fun gpui_mgmt_bom_stock_out(n: Any): String = Tr.f(4609, arrayOf(n)) - fun gpui_mgmt_bom_stock_low(n: Any): String = Tr.f(4610, arrayOf(n)) - val gpui_gerbers_boardonly: String get() = Tr.s(4611) - val gpui_gerbers_gerbersonly: String get() = Tr.s(4612) - fun gpui_mgmt_life_price_since(day: Any): String = Tr.f(4613, arrayOf(day)) - fun gpui_streamer_account(n: Any): String = Tr.f(4614, arrayOf(n)) - val gpui_streamer_mode: String get() = Tr.s(4615) - val gpui_streamer_section: String get() = Tr.s(4616) - val gpui_streamer_off: String get() = Tr.s(4617) - val gpui_streamer_on: String get() = Tr.s(4618) - val gpui_streamer_tip: String get() = Tr.s(4619) - val gpui_streamer_shared: String get() = Tr.s(4620) - val gpui_streamer_qr: String get() = Tr.s(4621) - val gpui_streamer_note: String get() = Tr.s(4622) - val gpui_streamer_share: String get() = Tr.s(4623) - val gpui_streamer_apps: String get() = Tr.s(4624) - val gpui_streamer_apps_note: String get() = Tr.s(4625) - val gpui_streamer_linux: String get() = Tr.s(4626) - val gpui_streamer_mac: String get() = Tr.s(4627) - val gpui_streamer_win: String get() = Tr.s(4628) - val gpui_f2_uber_title: String get() = Tr.s(4629) - val gpui_f2_uber_body: String get() = Tr.s(4630) - val gpui_f2_uber_say: String get() = Tr.s(4631) - val gpui_f2_uber_here: String get() = Tr.s(4632) - val gpui_f2_uber_err_name: String get() = Tr.s(4633) - val gpui_f2_uber_err_color: String get() = Tr.s(4634) - val gpui_f2_uber_color: String get() = Tr.s(4635) - val gpui_f2_uber_own: String get() = Tr.s(4636) - val gpui_f2_uber_custom: String get() = Tr.s(4637) - val gpui_f2_uber_hex: String get() = Tr.s(4638) - val gpui_f2_uber_use: String get() = Tr.s(4639) - val gpui_f2_uber_shuffle: String get() = Tr.s(4640) - val gpui_f2_uber_auto: String get() = Tr.s(4641) - val gpui_f2_uber_savename: String get() = Tr.s(4642) - val gpui_f2_uber_p_ginger: String get() = Tr.s(4643) - val gpui_f2_uber_p_cream: String get() = Tr.s(4644) - val gpui_f2_uber_p_smoke: String get() = Tr.s(4645) - val gpui_f2_uber_p_midnight: String get() = Tr.s(4646) - val gpui_f2_uber_p_cocoa: String get() = Tr.s(4647) - val gpui_f2_uber_p_sky: String get() = Tr.s(4648) - val gpui_f2_uber_p_lilac: String get() = Tr.s(4649) - val gpui_f2_uber_p_rose: String get() = Tr.s(4650) - val gpui_f2_uber_p_mint: String get() = Tr.s(4651) - val gpui_f2_uber_p_cherry: String get() = Tr.s(4652) - val gpui_simulation: String get() = Tr.s(4653) - val gpui_c_sheets_find: String get() = Tr.s(4654) - fun history_snap(turn: Any): String = Tr.f(4655, arrayOf(turn)) - val history_ref_snap: String get() = Tr.s(4656) - val thread_restore_action: String get() = Tr.s(4657) - val thread_restore_ask: String get() = Tr.s(4658) - val thread_restore_note: String get() = Tr.s(4659) - val thread_restore_go: String get() = Tr.s(4660) - val mouse_mouseandtrackpad0: String get() = Tr.s(4661) - val mouse_zoomdirection1: String get() = Tr.s(4662) - val mouse_appliestothewheelandatrackpads2: String get() = Tr.s(4663) - val mouse_normal3: String get() = Tr.s(4664) - val mouse_inverted4: String get() = Tr.s(4665) - val mouse_boardandschematic5: String get() = Tr.s(4666) - val mouse_k3dandstep6: String get() = Tr.s(4667) - val mouse_changedfromitspreseteachinputd7: String get() = Tr.s(4668) - val mouse_apresetsetseveryinputbeloweach8: String get() = Tr.s(4669) - val mouse_legacy10: String get() = Tr.s(4670) - val mouse_leftdrag11: String get() = Tr.s(4671) - val mouse_middledrag12: String get() = Tr.s(4672) - val mouse_rightdrag13: String get() = Tr.s(4673) - val mouse_shiftleftdrag14: String get() = Tr.s(4674) - val mouse_ctrlleftdrag15: String get() = Tr.s(4675) - val mouse_altleftdrag16: String get() = Tr.s(4676) - val mouse_wheel17: String get() = Tr.s(4677) - val mouse_shiftwheel18: String get() = Tr.s(4678) - val mouse_ctrlwheel19: String get() = Tr.s(4679) - val mouse_altwheel20: String get() = Tr.s(4680) - val mouse_nothing21: String get() = Tr.s(4681) - val mouse_pan22: String get() = Tr.s(4682) - val mouse_pansideways23: String get() = Tr.s(4683) - val mouse_panupanddown24: String get() = Tr.s(4684) - val mouse_zoom25: String get() = Tr.s(4685) - val mouse_rotate26: String get() = Tr.s(4686) - val mouse_roll27: String get() = Tr.s(4687) - val mouse_select28: String get() = Tr.s(4688) - val mouse_aclickwithoutmovingwithnokeyhe29: String get() = Tr.s(4689) - val mouse_leftbutton30: String get() = Tr.s(4690) - val mouse_middlebutton31: String get() = Tr.s(4691) - val mouse_rightbutton32: String get() = Tr.s(4692) - val mouse_twofingerscroll33: String get() = Tr.s(4693) - val mouse_atrackpadstwofingerswithctrlhe34: String get() = Tr.s(4694) - val mouse_pans35: String get() = Tr.s(4695) - val mouse_isthewheel36: String get() = Tr.s(4696) - val mouse_pinch37: String get() = Tr.s(4697) - val mouse_atrackpadpinch38: String get() = Tr.s(4698) - val mouse_zooms39: String get() = Tr.s(4699) - val mouse_chooseaninputforitabove41: String get() = Tr.s(4700) - val mouse_nothingissettopan42: String get() = Tr.s(4701) - val mouse_nothingissettozoom43: String get() = Tr.s(4702) - val mouse_nothingissettorotate44: String get() = Tr.s(4703) - val gpui_review_mark: String get() = Tr.s(4704) - val gpui_review_mark_tip: String get() = Tr.s(4705) - val gpui_review_why: String get() = Tr.s(4706) - val gpui_review_allow: String get() = Tr.s(4707) - val gpui_review_allow_tip: String get() = Tr.s(4708) - val gpui_review_off: String get() = Tr.s(4709) - val gpui_review_again: String get() = Tr.s(4710) - val gpui_review_again_tip: String get() = Tr.s(4711) - val gpui_rail_no_board: String get() = Tr.s(4712) - val gpui_rail_no_schematic: String get() = Tr.s(4713) - val gpui_rail_split_needs_both: String get() = Tr.s(4714) - val gpui_rail_no_mech: String get() = Tr.s(4715) - val gpui_panestate_next_board: String get() = Tr.s(4716) - val gpui_panestate_next_schematic: String get() = Tr.s(4717) - val gpui_panestate_next_solid: String get() = Tr.s(4718) - val gpui_panestate_empty_gerbers: String get() = Tr.s(4719) - val gpui_panestate_next_gerbers: String get() = Tr.s(4720) - val gpui_panestate_gerbers_noboard: String get() = Tr.s(4721) - val gpui_panestate_gerbers_noboard_next: String get() = Tr.s(4722) - val gpui_panestate_empty_mech: String get() = Tr.s(4723) - val gpui_panestate_next_mech: String get() = Tr.s(4724) - val gpui_panestate_loading_split: String get() = Tr.s(4725) - val gpui_panestate_retrying: String get() = Tr.s(4726) - val gpui_hub_view_notready: String get() = Tr.s(4727) - val gpui_hub_view_staleconn: String get() = Tr.s(4728) - val gpui_hub_view_unavailable: String get() = Tr.s(4729) - val settings_designmode_label: String get() = Tr.s(4730) - val settings_designmode_viewer: String get() = Tr.s(4731) - val settings_designmode_kicad: String get() = Tr.s(4732) - val settings_designmode_note: String get() = Tr.s(4733) - val review_empty_title: String get() = Tr.s(4734) - val review_empty_next: String get() = Tr.s(4735) - val viewer_diff_threadchanges: String get() = Tr.s(4736) - val viewer_layout_refusal_locked: String get() = Tr.s(4737) - val viewer_layout_refusal_toosmall: String get() = Tr.s(4738) - val viewer_layout_refusal_onekicad: String get() = Tr.s(4739) - val viewer_layout_refusal_incompatibleoverlay: String get() = Tr.s(4740) - val viewer_layout_refusal_notfound: String get() = Tr.s(4741) - val viewer_layout_refusal_nooverlay: String get() = Tr.s(4742) - val viewer_layout_refusal_invalidsource: String get() = Tr.s(4743) - val viewer_layout_refusal_sametile: String get() = Tr.s(4744) - val viewer_layout_refusal_invalidratio: String get() = Tr.s(4745) - val viewer_layout_refusal_duplicateid: String get() = Tr.s(4746) - val viewer_layout_refusal_unknownframe: String get() = Tr.s(4747) - val viewer_layout_refusal_invalidinput: String get() = Tr.s(4748) - val viewer_layout_refusal_toomany: String get() = Tr.s(4749) - val viewer_layout_refusal_toomanysources: String get() = Tr.s(4750) - val viewer_layout_refusal_unresolvedversion: String get() = Tr.s(4751) - val viewer_layout_refusal_nohistory: String get() = Tr.s(4752) - val viewer_layout_refusal_linked: String get() = Tr.s(4753) - val viewer_layout_refusal_notondevice: String get() = Tr.s(4754) - val viewer_layout_refusal_starting: String get() = Tr.s(4755) - val viewer_footprinteditor: String get() = Tr.s(4756) - val viewer_symboleditor: String get() = Tr.s(4757) - val web_clone_tab: String get() = Tr.s(4758) - val web_clone_repo_placeholder: String get() = Tr.s(4759) - val web_clone_private: String get() = Tr.s(4760) - val web_clone_signin: String get() = Tr.s(4761) - val web_clone_signin_wait: String get() = Tr.s(4762) - val web_clone_signin_enter: String get() = Tr.s(4763) - val web_clone_signin_done: String get() = Tr.s(4764) - val web_clone_copied: String get() = Tr.s(4765) - val web_clone_change_folder: String get() = Tr.s(4766) - val web_clone_folder_name: String get() = Tr.s(4767) - val web_clone_start_thread: String get() = Tr.s(4768) - fun web_clone_first(text: Any): String = Tr.f(4769, arrayOf(text)) - val web_clone_same: String get() = Tr.s(4770) - val web_clone_go: String get() = Tr.s(4771) - fun web_clone_cloning(repo: Any, dest: Any): String = Tr.f(4772, arrayOf(repo, dest)) - fun web_clone_cloned(repo: Any, dest: Any): String = Tr.f(4773, arrayOf(repo, dest)) - fun web_clone_stopped(repo: Any): String = Tr.f(4774, arrayOf(repo)) - val web_clone_retry: String get() = Tr.s(4775) - val web_clone_back: String get() = Tr.s(4776) - val web_clone_open_thread: String get() = Tr.s(4777) - val web_clone_open_project: String get() = Tr.s(4778) - fun web_clone_add_dir(dir: Any): String = Tr.f(4779, arrayOf(dir)) - fun web_clone_use_dir(dir: Any): String = Tr.f(4780, arrayOf(dir)) - val web_clone_up: String get() = Tr.s(4781) - val web_clone_loading: String get() = Tr.s(4782) - val web_clone_no_folders: String get() = Tr.s(4783) - fun gpui_c_kicad_opening(editor: Any, job: Any, secs: Any): String = Tr.f(4784, arrayOf(editor, job, secs)) - fun gpui_c_kicad_openingbare(editor: Any, secs: Any): String = Tr.f(4785, arrayOf(editor, secs)) - fun gpui_c_kicad_openfailed(editor: Any): String = Tr.f(4786, arrayOf(editor)) - val viewer_tile_rail_add: String get() = Tr.s(4787) - val viewer_tile_add: String get() = Tr.s(4788) - val viewer_tile_maximize: String get() = Tr.s(4789) - val viewer_tile_restore: String get() = Tr.s(4790) - val viewer_tile_focus: String get() = Tr.s(4791) - val viewer_tile_embedded: String get() = Tr.s(4792) - val viewer_tile_simulation_single: String get() = Tr.s(4793) - val viewer_tile_add_tip: String get() = Tr.s(4794) - val viewer_tile_left: String get() = Tr.s(4795) - val viewer_tile_right: String get() = Tr.s(4796) - val viewer_tile_top: String get() = Tr.s(4797) - val viewer_tile_bottom: String get() = Tr.s(4798) - val web_pair_subtitle: String get() = Tr.s(4799) - val web_pair_name: String get() = Tr.s(4800) - val web_pair_request: String get() = Tr.s(4801) - val web_pair_code: String get() = Tr.s(4802) - fun web_pair_approve_in(time: Any): String = Tr.f(4803, arrayOf(time)) - val web_pair_expired: String get() = Tr.s(4804) - val web_pair_approved: String get() = Tr.s(4805) - val web_pair_denied: String get() = Tr.s(4806) - val web_pair_cancelled: String get() = Tr.s(4807) - val web_pair_requesting: String get() = Tr.s(4808) - fun web_pair_failed(status: Any): String = Tr.f(4809, arrayOf(status)) - val web_pair_ratelimited: String get() = Tr.s(4810) - val web_pair_nocode: String get() = Tr.s(4811) - val web_pair_unreachable: String get() = Tr.s(4812) - val web_chat_loading: String get() = Tr.s(4813) - val web_chat_choose: String get() = Tr.s(4814) - val web_chat_empty: String get() = Tr.s(4815) - val web_chat_streaming: String get() = Tr.s(4816) - fun web_chat_finished(time: Any): String = Tr.f(4817, arrayOf(time)) - fun web_chat_finished_dur(time: Any, dur: Any): String = Tr.f(4818, arrayOf(time, dur)) - val web_chat_answer_placeholder: String get() = Tr.s(4819) - val web_chat_answer_btn: String get() = Tr.s(4820) - fun web_chat_answered(answer: Any): String = Tr.f(4821, arrayOf(answer)) - val web_chat_review_mode: String get() = Tr.s(4822) - val web_composer_attach: String get() = Tr.s(4823) - val web_composer_voice: String get() = Tr.s(4824) - fun web_composer_unsupported(type: Any): String = Tr.f(4825, arrayOf(type)) - fun web_composer_maximages(max: Any): String = Tr.f(4826, arrayOf(max)) - val web_logout_failed: String get() = Tr.s(4827) - val thread_context_title: String get() = Tr.s(4828) - val thread_context_instructions: String get() = Tr.s(4829) - val thread_context_system: String get() = Tr.s(4830) - val thread_context_skills: String get() = Tr.s(4831) - val thread_context_mcp: String get() = Tr.s(4832) - val thread_context_mcp_short: String get() = Tr.s(4833) - val thread_context_reading: String get() = Tr.s(4834) - val thread_context_none_instructions: String get() = Tr.s(4835) - val thread_context_none_mcp: String get() = Tr.s(4836) - val thread_context_native_note: String get() = Tr.s(4837) - val thread_context_copy: String get() = Tr.s(4838) - val thread_context_copied: String get() = Tr.s(4839) - val thread_context_base: String get() = Tr.s(4840) - val thread_context_injected_label: String get() = Tr.s(4841) - val thread_context_index: String get() = Tr.s(4842) - val thread_context_scope_user: String get() = Tr.s(4843) - val thread_context_scope_bundled: String get() = Tr.s(4844) - val thread_context_native: String get() = Tr.s(4845) - val thread_context_injected: String get() = Tr.s(4846) - val thread_context_cross: String get() = Tr.s(4847) - val thread_context_explicit: String get() = Tr.s(4848) - val thread_context_untrusted: String get() = Tr.s(4849) - val thread_context_invalid: String get() = Tr.s(4850) - val thread_context_trust: String get() = Tr.s(4851) - val thread_context_enable: String get() = Tr.s(4852) - val thread_context_disable: String get() = Tr.s(4853) - fun thread_context_size(bytes: Any, tokens: Any): String = Tr.f(4854, arrayOf(bytes, tokens)) - val thread_context_unreachable: String get() = Tr.s(4855) - val gpui_planmode_top_once: String get() = Tr.s(4856) - val gpui_planmode_top_planning: String get() = Tr.s(4857) - val gpui_planmode_top_pending: String get() = Tr.s(4858) - val gpui_planmode_top_executing: String get() = Tr.s(4859) - val gpui_planmode_tip: String get() = Tr.s(4860) - val gpui_planmode_chip_building: String get() = Tr.s(4861) - val gpui_planmode_chip_once: String get() = Tr.s(4862) - val gpui_planmode_bar_once: String get() = Tr.s(4863) - val gpui_planmode_bar_always: String get() = Tr.s(4864) - val gpui_planmode_bar_planning: String get() = Tr.s(4865) - val gpui_planmode_bar_pending: String get() = Tr.s(4866) - val gpui_planmode_bar_executing: String get() = Tr.s(4867) - val gpui_planmode_scope_once: String get() = Tr.s(4868) - val gpui_planmode_scope_always: String get() = Tr.s(4869) - val gpui_ask_plan_ready: String get() = Tr.s(4870) - val gpui_ask_plan_revise: String get() = Tr.s(4871) - val gpui_ask_plan_sendrev: String get() = Tr.s(4872) - val gpui_ask_plan_reviseph: String get() = Tr.s(4873) - val gpui_mgmt_plan_st_blocked: String get() = Tr.s(4874) - val gpui_mgmt_plan_st_routing: String get() = Tr.s(4875) - val gpui_mgmt_plan_st_awaiting: String get() = Tr.s(4876) - val gpui_mgmt_plan_st_verified: String get() = Tr.s(4877) - val gpui_mgmt_plan_st_routed: String get() = Tr.s(4878) - val gpui_mgmt_plan_st_approved: String get() = Tr.s(4879) - val gpui_mgmt_plan_st_partial: String get() = Tr.s(4880) - val gpui_mgmt_plan_st_rejected: String get() = Tr.s(4881) - val gpui_mgmt_plan_st_empty: String get() = Tr.s(4882) - val gpui_mgmt_plan_refused: String get() = Tr.s(4883) - val gpui_mgmt_plan_emptysub: String get() = Tr.s(4884) - val gpui_mgmt_plan_verify: String get() = Tr.s(4885) - val gpui_mgmt_plan_reqplain: String get() = Tr.s(4886) - fun gpui_mgmt_plan_requested(what: Any): String = Tr.f(4887, arrayOf(what)) - val gpui_mgmt_plan_stackup: String get() = Tr.s(4888) - val gpui_keys_planmode: String get() = Tr.s(4889) - val gpui_keys_mgmt_plan: String get() = Tr.s(4890) - fun web_plan_awaiting(n: Any): String = Tr.f(4891, arrayOf(n)) - val web_plan_net_one: String get() = Tr.s(4892) - fun web_plan_nets(n: Any): String = Tr.f(4893, arrayOf(n)) - val gpui_mgmt_plan_view_canvas: String get() = Tr.s(4894) - val gpui_mgmt_plan_view_split: String get() = Tr.s(4895) - val gpui_mgmt_plan_view_list: String get() = Tr.s(4896) - val gpui_mgmt_plan_grid_all: String get() = Tr.s(4897) - val gpui_mgmt_plan_grid_pair: String get() = Tr.s(4898) - val gpui_mgmt_plan_grid_single: String get() = Tr.s(4899) - val gpui_mgmt_plan_expand: String get() = Tr.s(4900) - val gpui_mgmt_plan_compact: String get() = Tr.s(4901) - val gpui_mgmt_plan_sync: String get() = Tr.s(4902) - val gpui_mgmt_plan_fit: String get() = Tr.s(4903) - val gpui_mgmt_plan_lock: String get() = Tr.s(4904) - val gpui_mgmt_plan_unlock: String get() = Tr.s(4905) - val gpui_mgmt_plan_layer_move: String get() = Tr.s(4906) - val gpui_mgmt_plan_width: String get() = Tr.s(4907) - val gpui_mgmt_plan_addnote: String get() = Tr.s(4908) - val gpui_mgmt_plan_note_placeholder: String get() = Tr.s(4909) - val gpui_mgmt_plan_hint: String get() = Tr.s(4910) - val gpui_mgmt_plan_rejectlayer: String get() = Tr.s(4911) - val gpui_mgmt_plan_edited: String get() = Tr.s(4912) - val gpui_mgmt_plan_locked: String get() = Tr.s(4913) - val gpui_mgmt_plan_noitems: String get() = Tr.s(4914) - val gpui_mgmt_plan_stackup_short: String get() = Tr.s(4915) - val gpui_mgmt_plan_layer_short: String get() = Tr.s(4916) - fun gpui_mgmt_plan_awaiting_short(n: Any): String = Tr.f(4917, arrayOf(n)) - fun gpui_mgmt_plan_done_of(done: Any, total: Any): String = Tr.f(4918, arrayOf(done, total)) - val gpui_planmode_chip_review: String get() = Tr.s(4919) - val mobile_plan_steer: String get() = Tr.s(4920) - val mobile_plan_details: String get() = Tr.s(4921) - val mobile_plan_reset: String get() = Tr.s(4922) - val mobile_plan_removepoint: String get() = Tr.s(4923) - val mobile_plan_touchhint: String get() = Tr.s(4924) - val mobile_plan_copied: String get() = Tr.s(4925) - fun mobile_plan_widthmm(v: Any): String = Tr.f(4926, arrayOf(v)) - fun mobile_plan_coord(x: Any, y: Any): String = Tr.f(4927, arrayOf(x, y)) - val provider_notice_head: String get() = Tr.s(4928) - val provider_notice_text_none: String get() = Tr.s(4929) - val provider_notice_text_signedout: String get() = Tr.s(4930) - val provider_notice_button: String get() = Tr.s(4931) - val provider_notice_senderr: String get() = Tr.s(4932) - fun provider_notice_senderr_remote(machine: Any): String = Tr.f(4933, arrayOf(machine)) - val web_settings_providers: String get() = Tr.s(4934) - val web_settings_providers_browser: String get() = Tr.s(4935) - fun order_lead_days(days: Number): String = Tr.f(4936, arrayOf(days)) - fun order_estimate_warnings(warnings: Any): String = Tr.f(4937, arrayOf(warnings)) - val web_home_open: String get() = Tr.s(4938) - val web_home_fold: String get() = Tr.s(4939) - val web_home_unfold: String get() = Tr.s(4940) - val web_home_loading: String get() = Tr.s(4941) - val web_home_error: String get() = Tr.s(4942) - fun web_home_lead(n: Any): String = Tr.f(4943, arrayOf(n)) - val web_home_lead_one: String get() = Tr.s(4944) - val web_ring_unavailable: String get() = Tr.s(4945) - val web_ring_loading: String get() = Tr.s(4946) - val web_ring_error: String get() = Tr.s(4947) - fun web_ring_count(n: Any): String = Tr.f(4948, arrayOf(n)) - val web_ring_count_one: String get() = Tr.s(4949) - fun web_ring_found(found: Any, total: Any, q: Any): String = Tr.f(4950, arrayOf(found, total, q)) - val web_ring_not_heard: String get() = Tr.s(4951) - val web_ring_app_words: String get() = Tr.s(4952) - fun web_ring_heard_by(model: Any): String = Tr.f(4953, arrayOf(model)) - fun web_ring_heard_by_sure(model: Any, conf: Any): String = Tr.f(4954, arrayOf(model, conf)) - val web_ring_state_sent: String get() = Tr.s(4955) - val web_ring_state_new: String get() = Tr.s(4956) - val web_ring_state_heard: String get() = Tr.s(4957) - val web_ring_state_failed: String get() = Tr.s(4958) - val web_ring_state_busy: String get() = Tr.s(4959) - val web_ring_no_words: String get() = Tr.s(4960) + val mobile_conn_reconnecting: String get() = Tr.s(4348) + val sidebar_sections_needs: String get() = Tr.s(4349) + val sidebar_sections_pinned: String get() = Tr.s(4350) + val sidebar_sections_active: String get() = Tr.s(4351) + val sidebar_sections_quiet: String get() = Tr.s(4352) + val sidebar_sections_quiet_hint: String get() = Tr.s(4353) + val sidebar_sections_running_word: String get() = Tr.s(4354) + val sidebar_sections_recent: String get() = Tr.s(4355) + val sidebar_sections_limit: String get() = Tr.s(4356) + val sidebar_sections_cut: String get() = Tr.s(4357) + val sidebar_sections_monitoring: String get() = Tr.s(4358) + val sidebar_sections_stopped: String get() = Tr.s(4359) + val sidebar_sections_done: String get() = Tr.s(4360) + val sidebar_sections_failed: String get() = Tr.s(4361) + val sidebar_sections_rename: String get() = Tr.s(4362) + val sidebar_sections_pin: String get() = Tr.s(4363) + val sidebar_sections_unpin: String get() = Tr.s(4364) + val sidebar_sections_quiet_make: String get() = Tr.s(4365) + val sidebar_sections_quiet_back: String get() = Tr.s(4366) + val sidebar_sections_quiet_hint2: String get() = Tr.s(4367) + fun gpui_sections_move_to(group: Any): String = Tr.f(4368, arrayOf(group)) + val sidebar_sections_move: String get() = Tr.s(4369) + val sidebar_sections_new_group: String get() = Tr.s(4370) + val sidebar_sections_new_group_title: String get() = Tr.s(4371) + fun sidebar_sections_remove_ask(project: Any): String = Tr.f(4372, arrayOf(project)) + fun gpui_sections_running(n: Number): String = Tr.f(4373, arrayOf(n)) + fun gpui_sections_rest(n: Number): String = Tr.f(4374, arrayOf(n)) + fun gpui_projects_mech(n: Any): String = Tr.f(4375, arrayOf(n)) + val gpui_open_folder: String get() = Tr.s(4376) + val gpui_picker_none: String get() = Tr.s(4377) + val gpui_picker_key_select: String get() = Tr.s(4378) + val gpui_picker_key_into: String get() = Tr.s(4379) + val gpui_picker_key_complete: String get() = Tr.s(4380) + val gpui_picker_key_open: String get() = Tr.s(4381) + val gpui_picker_added: String get() = Tr.s(4382) + fun gpui_picker_more_typed(n: Any): String = Tr.f(4383, arrayOf(n)) + val gpui_clone_tab: String get() = Tr.s(4384) + val gpui_clone_change: String get() = Tr.s(4385) + val gpui_clone_thread: String get() = Tr.s(4386) + val gpui_clone_retry: String get() = Tr.s(4387) + val gpui_clone_signin: String get() = Tr.s(4388) + val gpui_clone_back: String get() = Tr.s(4389) + val gpui_clone_open_thread: String get() = Tr.s(4390) + val gpui_clone_open_project: String get() = Tr.s(4391) + val gpui_clone_private: String get() = Tr.s(4392) + val gpui_clone_loading: String get() = Tr.s(4393) + val gpui_clone_signin_list: String get() = Tr.s(4394) + val gpui_clone_signin_code: String get() = Tr.s(4395) + val gpui_clone_signin_asking: String get() = Tr.s(4396) + val gpui_clone_signin_done: String get() = Tr.s(4397) + val gpui_clone_cancel: String get() = Tr.s(4398) + val gpui_picker_key_pick: String get() = Tr.s(4399) + val gpui_clone_phase_connecting: String get() = Tr.s(4400) + val gpui_clone_phase_receiving: String get() = Tr.s(4401) + val gpui_clone_phase_resolving: String get() = Tr.s(4402) + val gpui_clone_phase_updating: String get() = Tr.s(4403) + val gpui_clone_phase_counting: String get() = Tr.s(4404) + val gpui_clone_phase_compressing: String get() = Tr.s(4405) + val gpui_clone_phase_lfs: String get() = Tr.s(4406) + val gpui_clone_phase_adding: String get() = Tr.s(4407) + val gpui_clone_phase_starting: String get() = Tr.s(4408) + val gpui_assembly: String get() = Tr.s(4409) + val gpui_mech: String get() = Tr.s(4410) + val gpui_readme: String get() = Tr.s(4411) + val gpui_board: String get() = Tr.s(4412) + val gpui_schematic: String get() = Tr.s(4413) + val gpui_view_three_d: String get() = Tr.s(4414) + val gpui_files: String get() = Tr.s(4415) + val gpui_usage_bot: String get() = Tr.s(4416) + val gpui_usage_tokens: String get() = Tr.s(4417) + val gpui_usage_accounts_tip: String get() = Tr.s(4418) + val gpui_usage_feeds: String get() = Tr.s(4419) + val gpui_usage_lanes: String get() = Tr.s(4420) + val gpui_usage_turn_live: String get() = Tr.s(4421) + val gpui_usage_chat: String get() = Tr.s(4422) + val gpui_usage_today: String get() = Tr.s(4423) + val gpui_usage_prefs: String get() = Tr.s(4424) + val gpui_usage_handover: String get() = Tr.s(4425) + val gpui_usage_none_waiting: String get() = Tr.s(4426) + val gpui_usage_session: String get() = Tr.s(4427) + val gpui_usage_last_handover: String get() = Tr.s(4428) + val gpui_usage_triage: String get() = Tr.s(4429) + val gpui_usage_office: String get() = Tr.s(4430) + val gpui_usage_office_lower: String get() = Tr.s(4431) + val gpui_usage_compact: String get() = Tr.s(4432) + val gpui_usage_switch: String get() = Tr.s(4433) + val gpui_usage_note: String get() = Tr.s(4434) + val gpui_usage_lanes_note: String get() = Tr.s(4435) + val gpui_usage_lanes_routines: String get() = Tr.s(4436) + val gpui_usage_turns_many: String get() = Tr.s(4437) + val gpui_usage_turns_full: String get() = Tr.s(4438) + val gpui_usage_turns_one: String get() = Tr.s(4439) + fun gpui_usage_turns_n(n: Any): String = Tr.f(4440, arrayOf(n)) + fun gpui_usage_left(n: Any): String = Tr.f(4441, arrayOf(n)) + fun gpui_usage_of(a: Any, b: Any): String = Tr.f(4442, arrayOf(a, b)) + fun gpui_usage_context(n: Any): String = Tr.f(4443, arrayOf(n)) + val gpui_usage_noread: String get() = Tr.s(4444) + fun gpui_mgmt_bom_summary(parts: Number, lines: Number): String = Tr.f(4445, arrayOf(parts, lines)) + fun gpui_mgmt_bom_more(n: Number): String = Tr.f(4446, arrayOf(n)) + val gpui_mgmt_dock_right: String get() = Tr.s(4447) + val gpui_mgmt_dock_bottom: String get() = Tr.s(4448) + val gpui_mgmt_close: String get() = Tr.s(4449) + val gpui_mgmt_bom_saved: String get() = Tr.s(4450) + val gpui_mgmt_bom_reading: String get() = Tr.s(4451) + val gpui_mgmt_bom_nomatch: String get() = Tr.s(4452) + val gpui_mgmt_bom_nompn: String get() = Tr.s(4453) + val gpui_mgmt_filter: String get() = Tr.s(4454) + val gpui_mgmt_bom_noparts: String get() = Tr.s(4455) + val gpui_mgmt_bom_dnp: String get() = Tr.s(4456) + val gpui_mgmt_fab_tab: String get() = Tr.s(4457) + val gpui_mgmt_fab_drc_current: String get() = Tr.s(4458) + val gpui_mgmt_fab_drc_stale: String get() = Tr.s(4459) + val gpui_mgmt_fab_drc_update: String get() = Tr.s(4460) + val gpui_mgmt_fab_drc_none: String get() = Tr.s(4461) + val gpui_mgmt_fab_drc_write: String get() = Tr.s(4462) + val gpui_mgmt_fab_drc_noproject: String get() = Tr.s(4463) + val gpui_mgmt_fab_tier_extra: String get() = Tr.s(4464) + val gpui_mgmt_fab_tier_free: String get() = Tr.s(4465) + val gpui_mgmt_fab_reading: String get() = Tr.s(4466) + val gpui_mgmt_fab_thefab: String get() = Tr.s(4467) + val gpui_mgmt_fab_refresh: String get() = Tr.s(4468) + val gpui_mgmt_fab_apply: String get() = Tr.s(4469) + val gpui_mgmt_fab_changed: String get() = Tr.s(4470) + val gpui_mgmt_fab_seen: String get() = Tr.s(4471) + val gpui_mgmt_fab_limit: String get() = Tr.s(4472) + val gpui_mgmt_fab_free: String get() = Tr.s(4473) + val gpui_mgmt_fab_extra: String get() = Tr.s(4474) + val gpui_mgmt_fab_readcol: String get() = Tr.s(4475) + val gpui_mgmt_fab_derived: String get() = Tr.s(4476) + fun gpui_mgmt_fab_suggestion(what: Any, project: Any, fab: Any): String = Tr.f(4477, arrayOf(what, project, fab)) + fun gpui_mgmt_fab_read(rev: Any, day: Any): String = Tr.f(4478, arrayOf(rev, day)) + val gpui_mgmt_fab_reviewing: String get() = Tr.s(4479) + val gpui_mgmt_fab_noreview: String get() = Tr.s(4480) + val gpui_mgmt_fab_findings: String get() = Tr.s(4481) + val gpui_mgmt_fab_reviewbtn: String get() = Tr.s(4482) + val gpui_mgmt_fab_judge: String get() = Tr.s(4483) + val gpui_mgmt_plan_reading: String get() = Tr.s(4484) + val gpui_mgmt_plan_none: String get() = Tr.s(4485) + fun gpui_mgmt_plan_awaiting(n: Number): String = Tr.f(4486, arrayOf(n)) + val gpui_mgmt_plan_nothing: String get() = Tr.s(4487) + val gpui_mgmt_plan_saved: String get() = Tr.s(4488) + val gpui_mgmt_plan_all: String get() = Tr.s(4489) + val gpui_mgmt_plan_stop: String get() = Tr.s(4490) + val gpui_mgmt_plan_hide: String get() = Tr.s(4491) + val gpui_mgmt_plan_show: String get() = Tr.s(4492) + val gpui_mgmt_plan_done: String get() = Tr.s(4493) + val gpui_mgmt_plan_layer: String get() = Tr.s(4494) + val gpui_mgmt_plan_reject: String get() = Tr.s(4495) + val gpui_mgmt_plan_keysnote: String get() = Tr.s(4496) + fun gpui_mgmt_plan_reference(layer: Any): String = Tr.f(4497, arrayOf(layer)) + fun gpui_mgmt_plan_nets(n: Number): String = Tr.f(4498, arrayOf(n)) + val gpui_mgmt_plan_tab: String get() = Tr.s(4499) + val gpui_mgmt_plan_before: String get() = Tr.s(4500) + val gpui_mgmt_plan_onwords: String get() = Tr.s(4501) + val gpui_mgmt_plan_offwords: String get() = Tr.s(4502) + fun gpui_mgmt_plan_elsewhere(board: Any): String = Tr.f(4503, arrayOf(board)) + val gpui_mgmt_plan_openboard: String get() = Tr.s(4504) + val gpui_mgmt_plan_noboard: String get() = Tr.s(4505) + val gpui_mgmt_plan_drawn: String get() = Tr.s(4506) + val gpui_pick_planonce: String get() = Tr.s(4507) + val gpui_pick_planonce_note: String get() = Tr.s(4508) + val hub_view_board_unlisted: String get() = Tr.s(4509) + val gpui_mgmt_bom_stocknote: String get() = Tr.s(4510) + val hub_order_pick_more: String get() = Tr.s(4511) + val hub_order_pick_phone: String get() = Tr.s(4512) + val hub_order_pick_go: String get() = Tr.s(4513) + val gpui_plan_before_routing_desc: String get() = Tr.s(4514) + fun gpui_mgmt_bom_shared(others: Any): String = Tr.f(4515, arrayOf(others)) + fun gpui_mgmt_fab_review(must: Any, should: Any, notes: Any): String = Tr.f(4516, arrayOf(must, should, notes)) + fun gpui_mgmt_fab_stackup(id: Any, w: Any): String = Tr.f(4517, arrayOf(id, w)) + val gpui_mgmt_fab_proposed: String get() = Tr.s(4518) + val gpui_mgmt_fab_use: String get() = Tr.s(4519) + val gpui_keys_mgmt_bom: String get() = Tr.s(4520) + val gpui_keys_mgmt_checks: String get() = Tr.s(4521) + val gpui_keys_mgmt_life: String get() = Tr.s(4522) + val gpui_mgmt_checks_reading: String get() = Tr.s(4523) + val gpui_mgmt_checks_searching: String get() = Tr.s(4524) + val gpui_mgmt_checks_run: String get() = Tr.s(4525) + val gpui_mgmt_checks_running: String get() = Tr.s(4526) + fun gpui_mgmt_checks_behind(what: Any): String = Tr.f(4527, arrayOf(what)) + val gpui_mgmt_checks_stale: String get() = Tr.s(4528) + val gpui_mgmt_checks_liveunsaved: String get() = Tr.s(4529) + fun gpui_mgmt_checks_waiting(why: Any): String = Tr.f(4530, arrayOf(why)) + fun gpui_mgmt_checks_failed(why: Any): String = Tr.f(4531, arrayOf(why)) + val gpui_mgmt_checks_all: String get() = Tr.s(4532) + val gpui_mgmt_checks_errors: String get() = Tr.s(4533) + val gpui_mgmt_checks_warnings: String get() = Tr.s(4534) + val gpui_mgmt_checks_excluded: String get() = Tr.s(4535) + val gpui_mgmt_checks_fix: String get() = Tr.s(4536) + val gpui_mgmt_checks_reexport: String get() = Tr.s(4537) + fun gpui_mgmt_checks_more(n: Number): String = Tr.f(4538, arrayOf(n)) + val gpui_mgmt_checks_fewer: String get() = Tr.s(4539) + val gpui_mgmt_checks_none: String get() = Tr.s(4540) + val gpui_mgmt_checks_nomatch: String get() = Tr.s(4541) + val gpui_mgmt_checks_library: String get() = Tr.s(4542) + val gpui_mgmt_checks_withlib: String get() = Tr.s(4543) + val gpui_mgmt_checks_fullrun: String get() = Tr.s(4544) + val gpui_mgmt_checks_allsources: String get() = Tr.s(4545) + val gpui_mgmt_checks_judged: String get() = Tr.s(4546) + val gpui_mgmt_bom_dnp_tip: String get() = Tr.s(4547) + val gpui_mgmt_bom_writing: String get() = Tr.s(4548) + val gpui_mgmt_bom_inkicad: String get() = Tr.s(4549) + val gpui_mgmt_bom_saved_file: String get() = Tr.s(4550) + val gpui_mgmt_bom_fab: String get() = Tr.s(4551) + val gpui_mgmt_bom_mpn_ph: String get() = Tr.s(4552) + val gpui_mgmt_bom_fab_ph: String get() = Tr.s(4553) + fun gpui_mgmt_bom_each(price: Any, n: Any): String = Tr.f(4554, arrayOf(price, n)) + fun gpui_mgmt_bom_out(n: Any, need: Any): String = Tr.f(4555, arrayOf(n, need)) + fun gpui_mgmt_bom_low(n: Any): String = Tr.f(4556, arrayOf(n)) + fun gpui_mgmt_bom_in(n: Any): String = Tr.f(4557, arrayOf(n)) + fun gpui_mgmt_bom_cost(cost: Any): String = Tr.f(4558, arrayOf(cost)) + fun gpui_mgmt_bom_cost_least(cost: Any): String = Tr.f(4559, arrayOf(cost)) + val gpui_mgmt_bom_checking: String get() = Tr.s(4560) + val gpui_mgmt_bom_notknown: String get() = Tr.s(4561) + val gpui_mgmt_bom_stock: String get() = Tr.s(4562) + val gpui_mgmt_bom_alts: String get() = Tr.s(4563) + val gpui_mgmt_bom_alts_looking: String get() = Tr.s(4564) + val gpui_mgmt_bom_alts_none: String get() = Tr.s(4565) + val gpui_mgmt_bom_alts_use: String get() = Tr.s(4566) + val gpui_mgmt_bom_class_basic: String get() = Tr.s(4567) + val gpui_mgmt_bom_class_extended: String get() = Tr.s(4568) + val gpui_mgmt_bom_class_preferred: String get() = Tr.s(4569) + val gpui_mgmt_bom_notinstock: String get() = Tr.s(4570) + val gpui_mgmt_bom_off: String get() = Tr.s(4571) + fun gpui_mgmt_life_since(day: Any, n: Number): String = Tr.f(4572, arrayOf(day, n)) + fun gpui_mgmt_life_one(day: Any): String = Tr.f(4573, arrayOf(day)) + fun gpui_mgmt_life_now(cost: Any, n: Any, lines: Any): String = Tr.f(4574, arrayOf(cost, n, lines)) + fun gpui_mgmt_life_part_now(stock: Any, price: Any): String = Tr.f(4575, arrayOf(stock, price)) + fun gpui_mgmt_life_instock(lines: Any): String = Tr.f(4576, arrayOf(lines)) + val gpui_mgmt_life_board: String get() = Tr.s(4577) + val gpui_mgmt_life_price: String get() = Tr.s(4578) + val gpui_mgmt_life_active: String get() = Tr.s(4579) + val gpui_mgmt_life_nrnd: String get() = Tr.s(4580) + val gpui_mgmt_life_eol: String get() = Tr.s(4581) + val gpui_mgmt_life_unknown: String get() = Tr.s(4582) + val gpui_mgmt_life_nolines: String get() = Tr.s(4583) + val gpui_mgmt_life_noread: String get() = Tr.s(4584) + val gpui_mgmt_life_reading: String get() = Tr.s(4585) + val gpui_mgmt_life_nopart: String get() = Tr.s(4586) + val gpui_mgmt_life_tab: String get() = Tr.s(4587) + val gpui_mgmt_bom_paused: String get() = Tr.s(4588) + val gpui_mgmt_bom_paused_tip: String get() = Tr.s(4589) + val gpui_keys_mgmt_fab: String get() = Tr.s(4590) + val gpui_mgmt_bom_putback: String get() = Tr.s(4591) + val gpui_mgmt_bom_nochange: String get() = Tr.s(4592) + val gpui_mgmt_bom_deferred: String get() = Tr.s(4593) + val gpui_mgmt_bom_inkicad_save: String get() = Tr.s(4594) + val gpui_mgmt_bom_undo_tip: String get() = Tr.s(4595) + val gpui_mgmt_bom_undo: String get() = Tr.s(4596) + fun gpui_mgmt_checks_on(host: Any): String = Tr.f(4597, arrayOf(host)) + val gpui_gerbers: String get() = Tr.s(4598) + val gpui_gerbers_vs: String get() = Tr.s(4599) + val gpui_gerbers_vs_tip: String get() = Tr.s(4600) + val gpui_gerbers_gerbview: String get() = Tr.s(4601) + val gpui_gerbers_gerbview_tip: String get() = Tr.s(4602) + val gpui_mgmt_bom_saved_state: String get() = Tr.s(4603) + val gpui_mgmt_bom_live_tip: String get() = Tr.s(4604) + val gpui_mgmt_bom_saved_tip: String get() = Tr.s(4605) + val gpui_mgmt_bom_price: String get() = Tr.s(4606) + val gpui_mgmt_bom_class: String get() = Tr.s(4607) + fun gpui_mgmt_life_unknown_n(n: Any): String = Tr.f(4608, arrayOf(n)) + fun gpui_mgmt_life_unknown_tip(a: Any, b: Any): String = Tr.f(4609, arrayOf(a, b)) + fun gpui_mgmt_bom_stock_out(n: Any): String = Tr.f(4610, arrayOf(n)) + fun gpui_mgmt_bom_stock_low(n: Any): String = Tr.f(4611, arrayOf(n)) + val gpui_gerbers_boardonly: String get() = Tr.s(4612) + val gpui_gerbers_gerbersonly: String get() = Tr.s(4613) + fun gpui_mgmt_life_price_since(day: Any): String = Tr.f(4614, arrayOf(day)) + fun gpui_streamer_account(n: Any): String = Tr.f(4615, arrayOf(n)) + val gpui_streamer_mode: String get() = Tr.s(4616) + val gpui_streamer_section: String get() = Tr.s(4617) + val gpui_streamer_off: String get() = Tr.s(4618) + val gpui_streamer_on: String get() = Tr.s(4619) + val gpui_streamer_tip: String get() = Tr.s(4620) + val gpui_streamer_shared: String get() = Tr.s(4621) + val gpui_streamer_qr: String get() = Tr.s(4622) + val gpui_streamer_note: String get() = Tr.s(4623) + val gpui_streamer_share: String get() = Tr.s(4624) + val gpui_streamer_apps: String get() = Tr.s(4625) + val gpui_streamer_apps_note: String get() = Tr.s(4626) + val gpui_streamer_linux: String get() = Tr.s(4627) + val gpui_streamer_mac: String get() = Tr.s(4628) + val gpui_streamer_win: String get() = Tr.s(4629) + val gpui_f2_uber_title: String get() = Tr.s(4630) + val gpui_f2_uber_body: String get() = Tr.s(4631) + val gpui_f2_uber_say: String get() = Tr.s(4632) + val gpui_f2_uber_here: String get() = Tr.s(4633) + val gpui_f2_uber_err_name: String get() = Tr.s(4634) + val gpui_f2_uber_err_color: String get() = Tr.s(4635) + val gpui_f2_uber_color: String get() = Tr.s(4636) + val gpui_f2_uber_own: String get() = Tr.s(4637) + val gpui_f2_uber_custom: String get() = Tr.s(4638) + val gpui_f2_uber_hex: String get() = Tr.s(4639) + val gpui_f2_uber_use: String get() = Tr.s(4640) + val gpui_f2_uber_shuffle: String get() = Tr.s(4641) + val gpui_f2_uber_auto: String get() = Tr.s(4642) + val gpui_f2_uber_savename: String get() = Tr.s(4643) + val gpui_f2_uber_p_ginger: String get() = Tr.s(4644) + val gpui_f2_uber_p_cream: String get() = Tr.s(4645) + val gpui_f2_uber_p_smoke: String get() = Tr.s(4646) + val gpui_f2_uber_p_midnight: String get() = Tr.s(4647) + val gpui_f2_uber_p_cocoa: String get() = Tr.s(4648) + val gpui_f2_uber_p_sky: String get() = Tr.s(4649) + val gpui_f2_uber_p_lilac: String get() = Tr.s(4650) + val gpui_f2_uber_p_rose: String get() = Tr.s(4651) + val gpui_f2_uber_p_mint: String get() = Tr.s(4652) + val gpui_f2_uber_p_cherry: String get() = Tr.s(4653) + val gpui_simulation: String get() = Tr.s(4654) + val gpui_c_sheets_find: String get() = Tr.s(4655) + fun history_snap(turn: Any): String = Tr.f(4656, arrayOf(turn)) + val history_ref_snap: String get() = Tr.s(4657) + val thread_restore_action: String get() = Tr.s(4658) + val thread_restore_ask: String get() = Tr.s(4659) + val thread_restore_note: String get() = Tr.s(4660) + val thread_restore_go: String get() = Tr.s(4661) + val mouse_mouseandtrackpad0: String get() = Tr.s(4662) + val mouse_zoomdirection1: String get() = Tr.s(4663) + val mouse_appliestothewheelandatrackpads2: String get() = Tr.s(4664) + val mouse_normal3: String get() = Tr.s(4665) + val mouse_inverted4: String get() = Tr.s(4666) + val mouse_boardandschematic5: String get() = Tr.s(4667) + val mouse_k3dandstep6: String get() = Tr.s(4668) + val mouse_changedfromitspreseteachinputd7: String get() = Tr.s(4669) + val mouse_apresetsetseveryinputbeloweach8: String get() = Tr.s(4670) + val mouse_legacy10: String get() = Tr.s(4671) + val mouse_leftdrag11: String get() = Tr.s(4672) + val mouse_middledrag12: String get() = Tr.s(4673) + val mouse_rightdrag13: String get() = Tr.s(4674) + val mouse_shiftleftdrag14: String get() = Tr.s(4675) + val mouse_ctrlleftdrag15: String get() = Tr.s(4676) + val mouse_altleftdrag16: String get() = Tr.s(4677) + val mouse_wheel17: String get() = Tr.s(4678) + val mouse_shiftwheel18: String get() = Tr.s(4679) + val mouse_ctrlwheel19: String get() = Tr.s(4680) + val mouse_altwheel20: String get() = Tr.s(4681) + val mouse_nothing21: String get() = Tr.s(4682) + val mouse_pan22: String get() = Tr.s(4683) + val mouse_pansideways23: String get() = Tr.s(4684) + val mouse_panupanddown24: String get() = Tr.s(4685) + val mouse_zoom25: String get() = Tr.s(4686) + val mouse_rotate26: String get() = Tr.s(4687) + val mouse_roll27: String get() = Tr.s(4688) + val mouse_select28: String get() = Tr.s(4689) + val mouse_aclickwithoutmovingwithnokeyhe29: String get() = Tr.s(4690) + val mouse_leftbutton30: String get() = Tr.s(4691) + val mouse_middlebutton31: String get() = Tr.s(4692) + val mouse_rightbutton32: String get() = Tr.s(4693) + val mouse_twofingerscroll33: String get() = Tr.s(4694) + val mouse_atrackpadstwofingerswithctrlhe34: String get() = Tr.s(4695) + val mouse_pans35: String get() = Tr.s(4696) + val mouse_isthewheel36: String get() = Tr.s(4697) + val mouse_pinch37: String get() = Tr.s(4698) + val mouse_atrackpadpinch38: String get() = Tr.s(4699) + val mouse_zooms39: String get() = Tr.s(4700) + val mouse_chooseaninputforitabove41: String get() = Tr.s(4701) + val mouse_nothingissettopan42: String get() = Tr.s(4702) + val mouse_nothingissettozoom43: String get() = Tr.s(4703) + val mouse_nothingissettorotate44: String get() = Tr.s(4704) + val gpui_review_mark: String get() = Tr.s(4705) + val gpui_review_mark_tip: String get() = Tr.s(4706) + val gpui_review_why: String get() = Tr.s(4707) + val gpui_review_allow: String get() = Tr.s(4708) + val gpui_review_allow_tip: String get() = Tr.s(4709) + val gpui_review_off: String get() = Tr.s(4710) + val gpui_review_again: String get() = Tr.s(4711) + val gpui_review_again_tip: String get() = Tr.s(4712) + val gpui_rail_no_board: String get() = Tr.s(4713) + val gpui_rail_no_schematic: String get() = Tr.s(4714) + val gpui_rail_split_needs_both: String get() = Tr.s(4715) + val gpui_rail_no_mech: String get() = Tr.s(4716) + val gpui_panestate_next_board: String get() = Tr.s(4717) + val gpui_panestate_next_schematic: String get() = Tr.s(4718) + val gpui_panestate_next_solid: String get() = Tr.s(4719) + val gpui_panestate_empty_gerbers: String get() = Tr.s(4720) + val gpui_panestate_next_gerbers: String get() = Tr.s(4721) + val gpui_panestate_gerbers_noboard: String get() = Tr.s(4722) + val gpui_panestate_gerbers_noboard_next: String get() = Tr.s(4723) + val gpui_panestate_empty_mech: String get() = Tr.s(4724) + val gpui_panestate_next_mech: String get() = Tr.s(4725) + val gpui_panestate_loading_split: String get() = Tr.s(4726) + val gpui_panestate_retrying: String get() = Tr.s(4727) + val gpui_hub_view_notready: String get() = Tr.s(4728) + val gpui_hub_view_staleconn: String get() = Tr.s(4729) + val gpui_hub_view_unavailable: String get() = Tr.s(4730) + val settings_designmode_label: String get() = Tr.s(4731) + val settings_designmode_viewer: String get() = Tr.s(4732) + val settings_designmode_kicad: String get() = Tr.s(4733) + val settings_designmode_note: String get() = Tr.s(4734) + val review_empty_title: String get() = Tr.s(4735) + val review_empty_next: String get() = Tr.s(4736) + val viewer_diff_threadchanges: String get() = Tr.s(4737) + val viewer_layout_refusal_locked: String get() = Tr.s(4738) + val viewer_layout_refusal_toosmall: String get() = Tr.s(4739) + val viewer_layout_refusal_onekicad: String get() = Tr.s(4740) + val viewer_layout_refusal_incompatibleoverlay: String get() = Tr.s(4741) + val viewer_layout_refusal_notfound: String get() = Tr.s(4742) + val viewer_layout_refusal_nooverlay: String get() = Tr.s(4743) + val viewer_layout_refusal_invalidsource: String get() = Tr.s(4744) + val viewer_layout_refusal_sametile: String get() = Tr.s(4745) + val viewer_layout_refusal_invalidratio: String get() = Tr.s(4746) + val viewer_layout_refusal_duplicateid: String get() = Tr.s(4747) + val viewer_layout_refusal_unknownframe: String get() = Tr.s(4748) + val viewer_layout_refusal_invalidinput: String get() = Tr.s(4749) + val viewer_layout_refusal_toomany: String get() = Tr.s(4750) + val viewer_layout_refusal_toomanysources: String get() = Tr.s(4751) + val viewer_layout_refusal_unresolvedversion: String get() = Tr.s(4752) + val viewer_layout_refusal_nohistory: String get() = Tr.s(4753) + val viewer_layout_refusal_linked: String get() = Tr.s(4754) + val viewer_layout_refusal_notondevice: String get() = Tr.s(4755) + val viewer_layout_refusal_starting: String get() = Tr.s(4756) + val viewer_footprinteditor: String get() = Tr.s(4757) + val viewer_symboleditor: String get() = Tr.s(4758) + val web_clone_tab: String get() = Tr.s(4759) + val web_clone_repo_placeholder: String get() = Tr.s(4760) + val web_clone_private: String get() = Tr.s(4761) + val web_clone_signin: String get() = Tr.s(4762) + val web_clone_signin_wait: String get() = Tr.s(4763) + val web_clone_signin_enter: String get() = Tr.s(4764) + val web_clone_signin_done: String get() = Tr.s(4765) + val web_clone_copied: String get() = Tr.s(4766) + val web_clone_change_folder: String get() = Tr.s(4767) + val web_clone_folder_name: String get() = Tr.s(4768) + val web_clone_start_thread: String get() = Tr.s(4769) + fun web_clone_first(text: Any): String = Tr.f(4770, arrayOf(text)) + val web_clone_same: String get() = Tr.s(4771) + val web_clone_go: String get() = Tr.s(4772) + fun web_clone_cloning(repo: Any, dest: Any): String = Tr.f(4773, arrayOf(repo, dest)) + fun web_clone_cloned(repo: Any, dest: Any): String = Tr.f(4774, arrayOf(repo, dest)) + fun web_clone_stopped(repo: Any): String = Tr.f(4775, arrayOf(repo)) + val web_clone_retry: String get() = Tr.s(4776) + val web_clone_back: String get() = Tr.s(4777) + val web_clone_open_thread: String get() = Tr.s(4778) + val web_clone_open_project: String get() = Tr.s(4779) + fun web_clone_add_dir(dir: Any): String = Tr.f(4780, arrayOf(dir)) + fun web_clone_use_dir(dir: Any): String = Tr.f(4781, arrayOf(dir)) + val web_clone_up: String get() = Tr.s(4782) + val web_clone_loading: String get() = Tr.s(4783) + val web_clone_no_folders: String get() = Tr.s(4784) + fun gpui_c_kicad_opening(editor: Any, job: Any, secs: Any): String = Tr.f(4785, arrayOf(editor, job, secs)) + fun gpui_c_kicad_openingbare(editor: Any, secs: Any): String = Tr.f(4786, arrayOf(editor, secs)) + fun gpui_c_kicad_openfailed(editor: Any): String = Tr.f(4787, arrayOf(editor)) + val viewer_tile_rail_add: String get() = Tr.s(4788) + val viewer_tile_add: String get() = Tr.s(4789) + val viewer_tile_maximize: String get() = Tr.s(4790) + val viewer_tile_restore: String get() = Tr.s(4791) + val viewer_tile_focus: String get() = Tr.s(4792) + val viewer_tile_embedded: String get() = Tr.s(4793) + val viewer_tile_simulation_single: String get() = Tr.s(4794) + val viewer_tile_add_tip: String get() = Tr.s(4795) + val viewer_tile_left: String get() = Tr.s(4796) + val viewer_tile_right: String get() = Tr.s(4797) + val viewer_tile_top: String get() = Tr.s(4798) + val viewer_tile_bottom: String get() = Tr.s(4799) + val web_pair_subtitle: String get() = Tr.s(4800) + val web_pair_name: String get() = Tr.s(4801) + val web_pair_request: String get() = Tr.s(4802) + val web_pair_code: String get() = Tr.s(4803) + fun web_pair_approve_in(time: Any): String = Tr.f(4804, arrayOf(time)) + val web_pair_expired: String get() = Tr.s(4805) + val web_pair_approved: String get() = Tr.s(4806) + val web_pair_denied: String get() = Tr.s(4807) + val web_pair_cancelled: String get() = Tr.s(4808) + val web_pair_requesting: String get() = Tr.s(4809) + fun web_pair_failed(status: Any): String = Tr.f(4810, arrayOf(status)) + val web_pair_ratelimited: String get() = Tr.s(4811) + val web_pair_nocode: String get() = Tr.s(4812) + val web_pair_unreachable: String get() = Tr.s(4813) + val web_chat_loading: String get() = Tr.s(4814) + val web_chat_choose: String get() = Tr.s(4815) + val web_chat_empty: String get() = Tr.s(4816) + val web_chat_streaming: String get() = Tr.s(4817) + fun web_chat_finished(time: Any): String = Tr.f(4818, arrayOf(time)) + fun web_chat_finished_dur(time: Any, dur: Any): String = Tr.f(4819, arrayOf(time, dur)) + val web_chat_answer_placeholder: String get() = Tr.s(4820) + val web_chat_answer_btn: String get() = Tr.s(4821) + fun web_chat_answered(answer: Any): String = Tr.f(4822, arrayOf(answer)) + val web_chat_review_mode: String get() = Tr.s(4823) + val web_composer_attach: String get() = Tr.s(4824) + val web_composer_voice: String get() = Tr.s(4825) + fun web_composer_unsupported(type: Any): String = Tr.f(4826, arrayOf(type)) + fun web_composer_maximages(max: Any): String = Tr.f(4827, arrayOf(max)) + val web_logout_failed: String get() = Tr.s(4828) + val thread_context_title: String get() = Tr.s(4829) + val thread_context_instructions: String get() = Tr.s(4830) + val thread_context_system: String get() = Tr.s(4831) + val thread_context_skills: String get() = Tr.s(4832) + val thread_context_mcp: String get() = Tr.s(4833) + val thread_context_mcp_short: String get() = Tr.s(4834) + val thread_context_reading: String get() = Tr.s(4835) + val thread_context_none_instructions: String get() = Tr.s(4836) + val thread_context_none_mcp: String get() = Tr.s(4837) + val thread_context_native_note: String get() = Tr.s(4838) + val thread_context_copy: String get() = Tr.s(4839) + val thread_context_copied: String get() = Tr.s(4840) + val thread_context_base: String get() = Tr.s(4841) + val thread_context_injected_label: String get() = Tr.s(4842) + val thread_context_index: String get() = Tr.s(4843) + val thread_context_scope_user: String get() = Tr.s(4844) + val thread_context_scope_bundled: String get() = Tr.s(4845) + val thread_context_native: String get() = Tr.s(4846) + val thread_context_injected: String get() = Tr.s(4847) + val thread_context_cross: String get() = Tr.s(4848) + val thread_context_explicit: String get() = Tr.s(4849) + val thread_context_untrusted: String get() = Tr.s(4850) + val thread_context_invalid: String get() = Tr.s(4851) + val thread_context_trust: String get() = Tr.s(4852) + val thread_context_enable: String get() = Tr.s(4853) + val thread_context_disable: String get() = Tr.s(4854) + fun thread_context_size(bytes: Any, tokens: Any): String = Tr.f(4855, arrayOf(bytes, tokens)) + val thread_context_unreachable: String get() = Tr.s(4856) + val gpui_planmode_top_once: String get() = Tr.s(4857) + val gpui_planmode_top_planning: String get() = Tr.s(4858) + val gpui_planmode_top_pending: String get() = Tr.s(4859) + val gpui_planmode_top_executing: String get() = Tr.s(4860) + val gpui_planmode_tip: String get() = Tr.s(4861) + val gpui_planmode_chip_building: String get() = Tr.s(4862) + val gpui_planmode_chip_once: String get() = Tr.s(4863) + val gpui_planmode_bar_once: String get() = Tr.s(4864) + val gpui_planmode_bar_always: String get() = Tr.s(4865) + val gpui_planmode_bar_planning: String get() = Tr.s(4866) + val gpui_planmode_bar_pending: String get() = Tr.s(4867) + val gpui_planmode_bar_executing: String get() = Tr.s(4868) + val gpui_planmode_scope_once: String get() = Tr.s(4869) + val gpui_planmode_scope_always: String get() = Tr.s(4870) + val gpui_ask_plan_ready: String get() = Tr.s(4871) + val gpui_ask_plan_revise: String get() = Tr.s(4872) + val gpui_ask_plan_sendrev: String get() = Tr.s(4873) + val gpui_ask_plan_reviseph: String get() = Tr.s(4874) + val gpui_mgmt_plan_st_blocked: String get() = Tr.s(4875) + val gpui_mgmt_plan_st_routing: String get() = Tr.s(4876) + val gpui_mgmt_plan_st_awaiting: String get() = Tr.s(4877) + val gpui_mgmt_plan_st_verified: String get() = Tr.s(4878) + val gpui_mgmt_plan_st_routed: String get() = Tr.s(4879) + val gpui_mgmt_plan_st_approved: String get() = Tr.s(4880) + val gpui_mgmt_plan_st_partial: String get() = Tr.s(4881) + val gpui_mgmt_plan_st_rejected: String get() = Tr.s(4882) + val gpui_mgmt_plan_st_empty: String get() = Tr.s(4883) + val gpui_mgmt_plan_refused: String get() = Tr.s(4884) + val gpui_mgmt_plan_emptysub: String get() = Tr.s(4885) + val gpui_mgmt_plan_verify: String get() = Tr.s(4886) + val gpui_mgmt_plan_reqplain: String get() = Tr.s(4887) + fun gpui_mgmt_plan_requested(what: Any): String = Tr.f(4888, arrayOf(what)) + val gpui_mgmt_plan_stackup: String get() = Tr.s(4889) + val gpui_keys_planmode: String get() = Tr.s(4890) + val gpui_keys_mgmt_plan: String get() = Tr.s(4891) + fun web_plan_awaiting(n: Any): String = Tr.f(4892, arrayOf(n)) + val web_plan_net_one: String get() = Tr.s(4893) + fun web_plan_nets(n: Any): String = Tr.f(4894, arrayOf(n)) + val gpui_mgmt_plan_view_canvas: String get() = Tr.s(4895) + val gpui_mgmt_plan_view_split: String get() = Tr.s(4896) + val gpui_mgmt_plan_view_list: String get() = Tr.s(4897) + val gpui_mgmt_plan_grid_all: String get() = Tr.s(4898) + val gpui_mgmt_plan_grid_pair: String get() = Tr.s(4899) + val gpui_mgmt_plan_grid_single: String get() = Tr.s(4900) + val gpui_mgmt_plan_expand: String get() = Tr.s(4901) + val gpui_mgmt_plan_compact: String get() = Tr.s(4902) + val gpui_mgmt_plan_sync: String get() = Tr.s(4903) + val gpui_mgmt_plan_fit: String get() = Tr.s(4904) + val gpui_mgmt_plan_lock: String get() = Tr.s(4905) + val gpui_mgmt_plan_unlock: String get() = Tr.s(4906) + val gpui_mgmt_plan_layer_move: String get() = Tr.s(4907) + val gpui_mgmt_plan_width: String get() = Tr.s(4908) + val gpui_mgmt_plan_addnote: String get() = Tr.s(4909) + val gpui_mgmt_plan_note_placeholder: String get() = Tr.s(4910) + val gpui_mgmt_plan_hint: String get() = Tr.s(4911) + val gpui_mgmt_plan_rejectlayer: String get() = Tr.s(4912) + val gpui_mgmt_plan_edited: String get() = Tr.s(4913) + val gpui_mgmt_plan_locked: String get() = Tr.s(4914) + val gpui_mgmt_plan_noitems: String get() = Tr.s(4915) + val gpui_mgmt_plan_stackup_short: String get() = Tr.s(4916) + val gpui_mgmt_plan_layer_short: String get() = Tr.s(4917) + fun gpui_mgmt_plan_awaiting_short(n: Any): String = Tr.f(4918, arrayOf(n)) + fun gpui_mgmt_plan_done_of(done: Any, total: Any): String = Tr.f(4919, arrayOf(done, total)) + val gpui_planmode_chip_review: String get() = Tr.s(4920) + val mobile_plan_steer: String get() = Tr.s(4921) + val mobile_plan_details: String get() = Tr.s(4922) + val mobile_plan_reset: String get() = Tr.s(4923) + val mobile_plan_removepoint: String get() = Tr.s(4924) + val mobile_plan_touchhint: String get() = Tr.s(4925) + val mobile_plan_copied: String get() = Tr.s(4926) + fun mobile_plan_widthmm(v: Any): String = Tr.f(4927, arrayOf(v)) + fun mobile_plan_coord(x: Any, y: Any): String = Tr.f(4928, arrayOf(x, y)) + val provider_notice_head: String get() = Tr.s(4929) + val provider_notice_text_none: String get() = Tr.s(4930) + val provider_notice_text_signedout: String get() = Tr.s(4931) + val provider_notice_button: String get() = Tr.s(4932) + val provider_notice_senderr: String get() = Tr.s(4933) + fun provider_notice_senderr_remote(machine: Any): String = Tr.f(4934, arrayOf(machine)) + val web_settings_providers: String get() = Tr.s(4935) + val web_settings_providers_browser: String get() = Tr.s(4936) + fun order_lead_days(days: Number): String = Tr.f(4937, arrayOf(days)) + fun order_estimate_warnings(warnings: Any): String = Tr.f(4938, arrayOf(warnings)) + val web_home_open: String get() = Tr.s(4939) + val web_home_fold: String get() = Tr.s(4940) + val web_home_unfold: String get() = Tr.s(4941) + val web_home_loading: String get() = Tr.s(4942) + val web_home_error: String get() = Tr.s(4943) + fun web_home_lead(n: Any): String = Tr.f(4944, arrayOf(n)) + val web_home_lead_one: String get() = Tr.s(4945) + val web_ring_unavailable: String get() = Tr.s(4946) + val web_ring_loading: String get() = Tr.s(4947) + val web_ring_error: String get() = Tr.s(4948) + fun web_ring_count(n: Any): String = Tr.f(4949, arrayOf(n)) + val web_ring_count_one: String get() = Tr.s(4950) + fun web_ring_found(found: Any, total: Any, q: Any): String = Tr.f(4951, arrayOf(found, total, q)) + val web_ring_not_heard: String get() = Tr.s(4952) + val web_ring_app_words: String get() = Tr.s(4953) + fun web_ring_heard_by(model: Any): String = Tr.f(4954, arrayOf(model)) + fun web_ring_heard_by_sure(model: Any, conf: Any): String = Tr.f(4955, arrayOf(model, conf)) + val web_ring_state_sent: String get() = Tr.s(4956) + val web_ring_state_new: String get() = Tr.s(4957) + val web_ring_state_heard: String get() = Tr.s(4958) + val web_ring_state_failed: String get() = Tr.s(4959) + val web_ring_state_busy: String get() = Tr.s(4960) + val web_ring_no_words: String get() = Tr.s(4961) } diff --git a/mobile/ios/Backplane/DataClient.swift b/mobile/ios/Backplane/DataClient.swift index 04d1c8a34d..6b112869e9 100644 --- a/mobile/ios/Backplane/DataClient.swift +++ b/mobile/ios/Backplane/DataClient.swift @@ -83,6 +83,7 @@ final class DataClient { // what is shown private(set) var conn: Conn = .offline { didSet { restartStrip() } } + private(set) var hasAttemptedConnect = false // the hub's restarts (feature `restarting`, HubRestart): what the connection strip shows, kept current by one timer private(set) var restartLine: HubRestart.Line = .usual @ObservationIgnored private var restarting: HubRestart.Note? // the last hub.restarting since the last hello @@ -97,6 +98,7 @@ final class DataClient { private(set) var older: [String: String] = [:] private(set) var loadedThreads: Set = [] private(set) var listsLoaded = false + var hasCachedSidebar: Bool { listsLoaded || !sections.isEmpty || !projects.isEmpty } // the projects whose "Settled (N)" row is open, kept on the device; their settled threads are read from the hub when it opens (feature `settled`) private(set) var settledOpen = Set(UserDefaults.standard.stringArray(forKey: "data.settled.open") ?? []) private(set) var settledMore: [String: String] = [:] // a project's next page of settled threads @@ -327,6 +329,7 @@ final class DataClient { notice = HubNotice(); star = nil; telemetryNotice = nil; noProvider = nil; migration = DMigration(); migrationOpen = false; migrationError = "" dueThreads = []; dueProjects = [] projects = []; threads = []; entries = [:]; older = [:]; loadedThreads = []; listsLoaded = false; open = nil; queues = [:]; queueError = [:] + features = []; sections = []; groupsTo = []; bots = []; rooms = []; swarms = [] mgmt = [:]; mgmtDigest = ""; mgmtProject = ""; mgmtAsked = ""; mgmtRev += 1 if clearDisk, let k = link.flatMap({ Pairing.key($0) }) { try? FileManager.default.removeItem(at: Self.cacheURL(for: k)) } } @@ -338,8 +341,15 @@ final class DataClient { } func heardNotice(_ n: HubNotice) { notice = n } + private func syncPushChain() async { + await enablePush() + await registerPush() + await syncPush() + } + // MARK: connection func connect() { + hasAttemptedConnect = true guard let link, let base = Pairing.socket(link), var c = URLComponents(url: base, resolvingAgainstBaseURL: false) else { return } c.queryItems = (c.queryItems ?? []) + [URLQueryItem(name: "data", value: "1"), URLQueryItem(name: "enc", value: "json"), URLQueryItem(name: "z", value: "deflate")] guard let url = c.url else { return } @@ -605,7 +615,10 @@ final class DataClient { private func synchronise(_ g: Int) async { do { if has("shell") && machine.isEmpty { - let r: DShellSyncReply = try await call("shell.sync", ["have": shellHashes, "settled": 25]) + var have = shellHashes + if sections.isEmpty { have.removeValue(forKey: "@sections") } + if projects.isEmpty { have = have.filter { !$0.key.hasPrefix("p:") } } + let r: DShellSyncReply = try await call("shell.sync", ["have": have, "settled": 25, "open": Array(sectionsOpen)]) guard g == gen else { return } listSub = r.sub Task { await self.flushOutbox(g) } @@ -613,31 +626,38 @@ final class DataClient { let removed = Set(r.removed ?? []) let changedPids = Set((r.projects ?? []).map(\.id)) if !removed.isEmpty || !changedPids.isEmpty { - projects = (projects.filter { !removed.contains($0.id) && !changedPids.contains($0.id) } + (r.projects ?? [])).sorted { $0.updatedAt > $1.updatedAt } - threads = (threads.filter { !removed.contains($0.project) && !changedPids.contains($0.project) } + (r.threads ?? [])).sorted { $0.updatedAt > $1.updatedAt } + let nextProjects = (projects.filter { !removed.contains($0.id) && !changedPids.contains($0.id) } + (r.projects ?? [])).sorted { $0.updatedAt > $1.updatedAt } + let nextThreads = (threads.filter { !removed.contains($0.project) && !changedPids.contains($0.project) } + (r.threads ?? [])).sorted { $0.updatedAt > $1.updatedAt } + if nextProjects != projects { projects = nextProjects } + if nextThreads != threads { threads = nextThreads } } else if let gotThreads = r.threads, !gotThreads.isEmpty { var byId = Dictionary(uniqueKeysWithValues: threads.map { ($0.id, $0) }) for t in gotThreads { byId[t.id] = t } - threads = Array(byId.values).sorted { $0.updatedAt > $1.updatedAt } + let nextThreads = Array(byId.values).sorted { $0.updatedAt > $1.updatedAt } + if nextThreads != threads { threads = nextThreads } + } + if let s = r.sections { + if s.sections != sections { sections = s.sections } + if s.groupsTo != groupsTo { groupsTo = s.groupsTo } } - if let s = r.sections { sections = s.sections; groupsTo = s.groupsTo } if let h = r.h { shellHashes = h } listsLoaded = true; scheduleSave() - await loadHistory() } else { let s: DSubReply = try await call("subscribe", ["topic": "lists"]); guard g == gen else { return }; listSub = s.sub Task { await self.flushOutbox(g) } - async let p = loadProjects(g), t = loadThreads(g), h: Void = loadHistory() - _ = try await (p, t, h) - await loadSections() // the sidebar's sections (feature sections): the list draws them once they come + async let p = loadProjects(g), t = loadThreads(g), sec: Void = loadSections() + _ = try await (p, t, sec) } - await loadBots() - await loadSwarms() - await voice.resync() - await enablePush(); await registerPush(); await syncPush() - await loadLocks() - await loadStar() - await loadTelemetryNotice() + async let hist: Void = loadHistory() + async let botsTask: Void = loadBots() + async let swarmsTask: Void = loadSwarms() + async let voiceTask: Void = voice.resync() + async let pushTask: Void = syncPushChain() + async let locksTask: Void = loadLocks() + async let starTask: Void = loadStar() + async let telTask: Void = loadTelemetryNotice() + _ = await (hist, botsTask, swarmsTask, voiceTask, pushTask, locksTask, starTask, telTask) + guard g == gen else { return } terms.resync() if let open { if has("open") { await openThreadBundled(open, g) } @@ -653,7 +673,10 @@ final class DataClient { private(set) var sectionsOpen = Set(UserDefaults.standard.stringArray(forKey: "data.sections.open") ?? []) func loadSections() async { guard has("sections"), let r: DSections = try? await call("sidebar.sections", ["open": Array(sectionsOpen)]) else { return } - sections = r.sections; groupsTo = r.groupsTo + var changed = false + if r.sections != sections { sections = r.sections; changed = true } + if r.groupsTo != groupsTo { groupsTo = r.groupsTo; changed = true } + if changed { scheduleSave() } } func toggleSection(_ toggle: String) { if sectionsOpen.contains(toggle) { sectionsOpen.remove(toggle) } else { sectionsOpen.insert(toggle) } @@ -1433,7 +1456,10 @@ final class DataClient { func loadBots() async { guard has("bots"), let r: DDirectory = try? await call("bots.list") else { return } if let o = open, let b = bots.first(where: { $0.thread == o }) { openBot = b } - bots = r.bots; rooms = r.rooms + var changed = false + if bots != r.bots { bots = r.bots; changed = true } + if rooms != r.rooms { rooms = r.rooms; changed = true } + if changed { scheduleSave() } if uberAfterPair, let u = bots.first(where: { $0.uber && !$0.thread.isEmpty }) { uberAfterPair = false; pendingThread = u.thread } // the uberbot's chat follows a home move: the same row, the same thread, now drawn from the machine that holds it if let o = open { if let b = bots.first(where: { $0.thread == o }) { openBot = b } else if let to = DBot.followed(o, openBot, r.bots) { openBot = nil @@ -1448,7 +1474,7 @@ final class DataClient { func roomPost(_ room: String, _ text: String) async throws { _ = try await call("room.post", ["room": room, "text": text, "clientId": UUID().uuidString], as: DEmpty.self) } // MARK: swarms (feature swarm, docs/SWARM.md Client data) - func loadSwarms() async { guard has("swarm"), let r: DSwarmList = try? await call("swarm.list", ["project": ""]) else { return }; swarms = r.swarms } + func loadSwarms() async { guard has("swarm"), let r: DSwarmList = try? await call("swarm.list", ["project": ""]) else { return }; if swarms != r.swarms { swarms = r.swarms; scheduleSave() } } @ObservationIgnored private var swarmsDue = false /// a board, state or member turn changed: the list's rows again, once for a burst private func swarmsMoved() { guard !swarmsDue else { return }; swarmsDue = true; Task { try? await Task.sleep(nanoseconds: 400_000_000); swarmsDue = false; await loadSwarms() } } @@ -1555,7 +1581,10 @@ final class DataClient { var viewing: String? { open } // MARK: cache (per-hub disk cache: paints at launch and on hub switch, replaced as soon as the hub answers) - private struct Cache: Codable { var hub: String; var projects: [DProject]; var threads: [DThread]; var entries: [String: [DEntry]]; var older: [String: String] } + private struct Cache: Codable { + var hub: String; var projects: [DProject]; var threads: [DThread]; var entries: [String: [DEntry]]; var older: [String: String] + var features: [String]?; var sections: [DSection]?; var groupsTo: [DGroupTo]?; var bots: [DBot]?; var rooms: [DRoom]?; var swarms: [DSwarmRow]?; var shellHashes: [String: String]? + } private static var legacyCacheURL: URL { let d = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0] try? FileManager.default.createDirectory(at: d, withIntermediateDirectories: true) @@ -1571,7 +1600,10 @@ final class DataClient { guard let hub = link.flatMap({ Pairing.key($0) }) else { return } let d = (try? Data(contentsOf: Self.cacheURL(for: hub))) ?? (try? Data(contentsOf: Self.legacyCacheURL)) guard let d, let c = try? JSONDecoder().decode(Cache.self, from: d), c.hub == hub else { return } - projects = c.projects; threads = c.threads; entries = c.entries; older = c.older; listsLoaded = !c.threads.isEmpty || !c.projects.isEmpty + projects = c.projects; threads = c.threads; entries = c.entries; older = c.older + features = Set(c.features ?? []); sections = c.sections ?? []; groupsTo = c.groupsTo ?? [] + bots = c.bots ?? []; rooms = c.rooms ?? []; swarms = c.swarms ?? []; shellHashes = c.shellHashes ?? [:] + listsLoaded = !c.threads.isEmpty || !c.projects.isEmpty || !sections.isEmpty } private func scheduleSave() { saveTask?.cancel() @@ -1582,7 +1614,10 @@ final class DataClient { let recent = Set(self.threads.prefix(20).map(\.id)) var e: [String: [DEntry]] = [:] for (k, v) in self.entries where recent.contains(k) { e[k] = Array(v.filter { !$0.sending && !$0.failed }.suffix(40)) } - let c = Cache(hub: hub, projects: self.projects, threads: self.threads, entries: e, older: self.older.filter { recent.contains($0.key) }) + let c = Cache( + hub: hub, projects: self.projects, threads: self.threads, entries: e, older: self.older.filter { recent.contains($0.key) }, + features: Array(self.features).sorted(), sections: self.sections, groupsTo: self.groupsTo, bots: self.bots, rooms: self.rooms, swarms: self.swarms, shellHashes: self.shellHashes + ) let url = Self.cacheURL(for: hub) await Task.detached(priority: .utility) { if let d = try? JSONEncoder().encode(c) { try? d.write(to: url, options: .atomic) } }.value } diff --git a/mobile/ios/Backplane/DataSections.swift b/mobile/ios/Backplane/DataSections.swift index 0b4823f484..127e4bb5a4 100644 --- a/mobile/ios/Backplane/DataSections.swift +++ b/mobile/ios/Backplane/DataSections.swift @@ -4,13 +4,14 @@ import SwiftUI // Active, the groups (by git owner, then folder) and Quiet. The hub decides what is in each; the app draws them as they come. /// One row of a section: a thread (kind "threads") or a project with its visible threads under it (kind "projects"). -struct DSecRow: Decodable, Identifiable, Equatable { +struct DSecRow: Codable, Identifiable, Equatable { var id: String; var title: String // a thread's var word: String; var say: String; var want: String; var ago: String; var machine: String; var mark: DMark?; var project: String; var projectKey: String; var off: Bool; var nav: String; var pinned: Bool; var hide: String // a project's var kind: String - var key: String; var projOff: Bool; var running: Int; var needsCount: Int; var threads: [DSecRow]; var icon: String; var css: String; var dots: [DSecDot]; var more: Int + var key: String; var running: Int; var needsCount: Int; var threads: [DSecRow]; var icon: String; var css: String; var dots: [DSecDot]; var more: Int + var projOff: Bool { off } /// a project's threads with no row under it (finished ones, on its page): counted on its row so none seems lost var rest: Int = 0 /// its menu (SectionMenu.swift), the hub's; an older hub sends none @@ -27,17 +28,17 @@ struct DSecRow: Decodable, Identifiable, Equatable { var hasBoard: Bool /// thread provider id (e.g. claude, codex, antigravity) var provider: String - enum CodingKeys: String, CodingKey { case id, title, word, say, want, ago, machine, mark, project, projectKey, off, nav, pinned, hide, kind, key, running, needsCount, threads, icon, css, dots, more, rest, menu, fold, folded, under, need, label, tone, snooze, settle, wake, hasBoard, provider } + enum CodingKeys: String, CodingKey { case id, title, word, say, want, ago, machine, mark, project, projectKey, off, nav, pinned, hide, kind, key, running, needsCount, threads, icon, css, dots, more, rest, menu, fold, folded, under, need, label, badgeTone = "tone", snooze, settle, wake, hasBoard, provider } init(from d: Decoder) throws { let c = try d.container(keyedBy: CodingKeys.self) id = c.str(.id); title = c.str(.title); word = c.str(.word); say = c.str(.say); want = c.str(.want); ago = c.str(.ago); machine = c.str(.machine) mark = try? c.decode(DMark.self, forKey: .mark); project = c.str(.project); projectKey = c.str(.projectKey); off = c.bool(.off); nav = c.str(.nav); pinned = c.bool(.pinned); hide = c.str(.hide) - kind = c.str(.kind); key = c.str(.key); projOff = (try? c.decode(Bool.self, forKey: .off)) ?? false; running = c.int(.running); needsCount = c.int(.needsCount); threads = (try? c.decode([DSecRow].self, forKey: .threads)) ?? [] + kind = c.str(.kind); key = c.str(.key); running = c.int(.running); needsCount = c.int(.needsCount); threads = (try? c.decode([DSecRow].self, forKey: .threads)) ?? [] icon = c.str(.icon); css = c.str(.css); dots = (try? c.decode([DSecDot].self, forKey: .dots)) ?? []; more = c.int(.more); rest = c.int(.rest) menu = (try? c.decode([DMenuItem].self, forKey: .menu)) ?? [] fold = c.str(.fold); folded = c.bool(.folded); under = c.int(.under) need = kind == "swarm" ? DSwarmNeed.of(c, .need) : nil - label = c.str(.label); badgeTone = c.str(.tone); snooze = (try? c.decode([DSnoozeOpt].self, forKey: .snooze)) ?? []; settle = c.str(.settle); wake = c.str(.wake) + label = c.str(.label); badgeTone = c.str(.badgeTone); snooze = (try? c.decode([DSnoozeOpt].self, forKey: .snooze)) ?? []; settle = c.str(.settle); wake = c.str(.wake) hasBoard = c.bool(.hasBoard); provider = c.str(.provider) } var isProject: Bool { !key.isEmpty } @@ -48,10 +49,10 @@ struct DSecRow: Decodable, Identifiable, Equatable { /// the row's status, a word with its icon; nil for a thread with nothing to say var pill: HomePill? { isProject ? nil : Home.pill(label: label, tone: badgeTone, word: word, want: want) } } -struct DSecDot: Decodable, Equatable { var short: String; var here: Bool; var dim: Bool +struct DSecDot: Codable, Equatable { var short: String; var here: Bool; var dim: Bool enum CodingKeys: String, CodingKey { case short, here, dim } init(from d: Decoder) throws { let c = try d.container(keyedBy: CodingKeys.self); short = c.str(.short); here = c.bool(.here); dim = c.bool(.dim) } } -struct DSection: Decodable, Identifiable, Equatable { +struct DSection: Codable, Identifiable, Equatable { var id: String; var kind: String; var title: String; var count: Int; var fold: Bool; var open: Bool; var toggle: String; var group: String; var rename: Bool; var rows: [DSecRow] enum CodingKeys: String, CodingKey { case id, kind, title, count, fold, open, toggle, group, rename, rows } init(from d: Decoder) throws { @@ -60,7 +61,7 @@ struct DSection: Decodable, Identifiable, Equatable { group = c.str(.group); rename = c.bool(.rename); rows = (try? c.decode([DSecRow].self, forKey: .rows)) ?? [] } } -struct DGroupTo: Decodable, Equatable { var value: String; var label: String +struct DGroupTo: Codable, Equatable { var value: String; var label: String enum CodingKeys: String, CodingKey { case value, label } init(from d: Decoder) throws { let c = try d.container(keyedBy: CodingKeys.self); value = c.str(.value); label = c.str(.label) } } struct DProjectPage: Decodable, Equatable { var key: String; var sections: [DSection] diff --git a/mobile/ios/Backplane/DataViews.swift b/mobile/ios/Backplane/DataViews.swift index 4035abe6bc..978e0198bb 100644 --- a/mobile/ios/Backplane/DataViews.swift +++ b/mobile/ios/Backplane/DataViews.swift @@ -155,6 +155,14 @@ struct DataThreadsView: View { @State private var searching = false @FocusState private var searchFocus: Bool private var sectioned: Bool { client.has("sections") && !client.sections.isEmpty } + private var showBanner: Bool { + guard client.restartLine != .none else { return false } + if case .note = client.restartLine { return true } + return !client.hasCachedSidebar || (client.conn == .offline && client.hasAttemptedConnect) + } + private var showReconnectingPill: Bool { + !showBanner && client.conn != .online && client.hasCachedSidebar + } private var bub: DBot? { client.bots.first { $0.uber && !$0.thread.isEmpty } } private var inboxSections: [DSection] { client.sections.filter { Home.tab(section: $0.id, kind: $0.kind) == .inbox } } private var benchSections: [DSection] { client.sections.filter { Home.tab(section: $0.id, kind: $0.kind) == .bench && !($0.id == "active" && $0.rows.isEmpty) } } @@ -177,7 +185,7 @@ struct DataThreadsView: View { DataStarBanner(client: client) DataAlertsBanner(client: client) DataNoProviderBanner(client: client) - if client.restartLine != .none { DataConnectionBanner(client: client) } + if showBanner { DataConnectionBanner(client: client) } // the tabs keep the list's whole height: Search is a button of the bar, its field here only while it is used; Add project is on the Bench if !sectioned || searching { HStack(spacing: 8) { @@ -199,8 +207,24 @@ struct DataThreadsView: View { if !client.locks.isEmpty && !sectioned { DataLocksStrip(client: client, path: $path) } // (the sections leave the hub's locks out: backend work) if client.has("search"), !query.trimmingCharacters(in: .whitespaces).isEmpty { DataSearchResults(client: client, query: query, open: { path.append($0) }, openAt: { path.append($0) }) + } else if !client.hasCachedSidebar && client.failure.isEmpty { + DLoading(text: Tr.t(client.conn == .online ? "Loading…" : "Connecting to the hub…")) } else if sectioned { tabs } else { list } } + .overlay(alignment: .bottom) { + if showReconnectingPill { + HStack(spacing: 6) { + DDot(color: BackplaneDesign.warn, size: 6) + Text(Tr.k("mobile.conn.reconnecting")).dmono(11).foregroundStyle(BackplaneDesign.dim) + } + .padding(.horizontal, 10).padding(.vertical, 5) + .background(BackplaneDesign.raised) + .overlay(Rectangle().strokeBorder(BackplaneDesign.line, lineWidth: 1)) + .padding(.bottom, sectioned ? 58 : 14) + .allowsHitTesting(false) + .accessibilityIdentifier("data.connection.reconnecting") + } + } .background(BackplaneDesign.panel) .navigationBarTitleDisplayMode(.inline) .toolbarBackground(BackplaneDesign.panel, for: .navigationBar).toolbarBackground(.visible, for: .navigationBar) diff --git a/mobile/ios/Backplane/HomeModel.swift b/mobile/ios/Backplane/HomeModel.swift index e7697f3296..088c311adc 100644 --- a/mobile/ios/Backplane/HomeModel.swift +++ b/mobile/ios/Backplane/HomeModel.swift @@ -8,7 +8,7 @@ import Foundation enum HomeTab: String, CaseIterable { case inbox, crew, bench } /// One span a row can be snoozed for, the hub's (`snooze`): `value` goes back as it came (`sidebar.act` `row-snooze`). -struct DSnoozeOpt: Decodable, Equatable, Identifiable { +struct DSnoozeOpt: Codable, Equatable, Identifiable { var label: String; var value: String var id: String { value } enum CodingKeys: String, CodingKey { case label, value } diff --git a/mobile/ios/Backplane/SectionMenu.swift b/mobile/ios/Backplane/SectionMenu.swift index 2e0752c5fe..a6c3c49f86 100644 --- a/mobile/ios/Backplane/SectionMenu.swift +++ b/mobile/ios/Backplane/SectionMenu.swift @@ -4,7 +4,7 @@ import Foundation // Move to group (the other groups, then New group…), Archive, Remove project. The hub decides the items and their order; the app draws them. /// One item: `id` says what it does here, `value` what it acts on, `sub` Move to group's list; `confirm` asks first (Remove). -struct DMenuItem: Decodable, Equatable, Identifiable { +struct DMenuItem: Codable, Equatable, Identifiable { var id: String; var label: String; var action: String; var value: String; var confirm: Bool; var sub: [DMenuItem] enum CodingKeys: String, CodingKey { case id, label, action, value, confirm, sub } init(id: String, label: String, action: String = "", value: String = "", confirm: Bool = false, sub: [DMenuItem] = []) { diff --git a/mobile/ios/Backplane/SwarmModel.swift b/mobile/ios/Backplane/SwarmModel.swift index 5d392e380a..457accf51d 100644 --- a/mobile/ios/Backplane/SwarmModel.swift +++ b/mobile/ios/Backplane/SwarmModel.swift @@ -180,7 +180,7 @@ enum Swarm { /// One button of a need: `act` board (the swarm's page), open (the member's thread), or resume, raise, retry, move, signin (`swarm.act`). /// `room` and `thread` carry the hub's prefix ("|") as the row's own id has it; `thread` is empty for a swarm-wide act. -struct DSwarmNeedAct: Decodable, Equatable, Hashable, Identifiable { +struct DSwarmNeedAct: Codable, Equatable, Hashable, Identifiable { var label = "", act = "", room = "", thread = "" var id: String { act + "\u{1f}" + thread } enum CodingKeys: String, CodingKey { case label, act, room, thread } @@ -191,7 +191,7 @@ struct DSwarmNeedAct: Decodable, Equatable, Hashable, Identifiable { } } /// A row's `need`: null on a swarm that wants nothing; a need with no line is none. -struct DSwarmNeed: Decodable, Equatable, Hashable { +struct DSwarmNeed: Codable, Equatable, Hashable { var line = "", why = "", actions: [DSwarmNeedAct] = [] enum CodingKeys: String, CodingKey { case line, why, actions } init(line: String, why: String, actions: [DSwarmNeedAct]) { self.line = line; self.why = why; self.actions = actions } diff --git a/mobile/ios/Shared/TrCatalog.swift b/mobile/ios/Shared/TrCatalog.swift index 9b27fc6f07..f973ead42c 100644 --- a/mobile/ios/Shared/TrCatalog.swift +++ b/mobile/ios/Shared/TrCatalog.swift @@ -499,6 +499,7 @@ mobile.pill.waiting Waiting 待機中 En espera mobile.snooze.wakes Wakes in {time} {time}後に再開 Vuelve en {time} mobile.bench.all All projects すべてのプロジェクト Todos los proyectos mobile.snooze.for Snooze for スヌーズする期間 Posponer +mobile.conn.reconnecting Reconnecting… 再接続中… Reconectando… common.cancel Cancel キャンセル Cancelar common.delete Delete 削除 Eliminar common.save Save 保存 Guardar diff --git a/native/host/src/data/machines.rs b/native/host/src/data/machines.rs index d8c92c5941..f8f7eadfa0 100644 --- a/native/host/src/data/machines.rs +++ b/native/host/src/data/machines.rs @@ -29,12 +29,18 @@ fn ms(at: u64) -> u64 { super::ms(at) } /// A linked machine's thread as the list rows have it. `project` is the id the phone files it under (this hub's project when the repository is one). pub fn thread_json(id: &str, st: &State, project: &str, mark: &Value, preview: &str) -> Option { + let signals = crate::signal::index(st); + thread_json_with_signals(id, st, project, mark, preview, &signals) +} + +/// Same as `thread_json`, reusing a precomputed `crate::signal::index(st)` across a batch of threads. +pub fn thread_json_with_signals(id: &str, st: &State, project: &str, mark: &Value, preview: &str, signals: &HashMap) -> Option { let t = st.threads.get(id).filter(|t| !t.deleted)?; let waiting = st.asks.values().filter(|(th, open)| *open && th == id).count() as u64; let state = if waiting > 0 { "asking" } else { match t.turn { Turn::Running => "working", Turn::Failed => "failed", _ => "idle" } }; let (pinned, settled, settled_at) = super::shelf_flags(t); // the sidebar dot's word as that machine's own state gives it (signal.rs, as data/mod.rs `thread_json` does for this hub's): a turn done reads finished there too - let signal = crate::signal::index(st).get(id).map_or(String::new(), |n| crate::signal::display_name(st, *n, id).to_string()); + let signal = signals.get(id).map_or(String::new(), |n| crate::signal::display_name(st, *n, id).to_string()); let status = if !signal.is_empty() { signal.as_str() } else if waiting > 0 { "waiting" } else if t.turn == Turn::Running { "active" } else if settled { "settled" } else { "" }; let runtime = st.runtime.get(id).cloned().unwrap_or_default(); Some(json!({"id":id,"project":project,"title":t.title,"state":state,"updatedAt":ms(t.activity.max(t.created)),"pinned":pinned,"settled":settled,"settledAt":settled_at,"archived":t.archived, @@ -156,6 +162,25 @@ pub fn thread_keys(far: &Far, pick: &str, join: &HashMap, projec } out } +/// Same as `thread_keys`, bucketed by project (`project_shown` and `t.project`) in one pass for both active and settled shelves. +pub fn thread_keys_by_project(far: &Far, pick: &str, join: &HashMap, archived: bool) -> HashMap, Vec<(u64, String)>)> { + let mut out: HashMap, Vec<(u64, String)>)> = HashMap::new(); + for (_, st) in shown_far(far, pick) { + for (id, t) in &st.threads { + if t.deleted || st.run_hidden(id) || t.archived != archived || t.project == crate::sidebar::SCRATCH || crate::sidebar::is_chats(&t.project) { continue } + let shown = project_shown(&t.project, join); + let (_, settled, at) = super::shelf_flags(t); + let key = (if settled { at } else { ms(t.activity.max(t.created)) }, id.clone()); + let push = |out: &mut HashMap, Vec<(u64, String)>)>, proj: &str| { + let entry = out.entry(proj.to_string()).or_default(); + if settled { entry.1.push(key.clone()); } else { entry.0.push(key.clone()); } + }; + push(&mut out, &shown); + if t.project != shown { push(&mut out, &t.project); } + } + } + out +} /// The project a linked thread is filed under: this hub's when it is the same repository, else its own. pub fn project_shown(far_project: &str, join: &HashMap) -> String { join.get(far_project).cloned().unwrap_or_else(|| far_project.to_string()) } diff --git a/native/host/src/data/mod.rs b/native/host/src/data/mod.rs index 65efab7d51..70a10942af 100644 --- a/native/host/src/data/mod.rs +++ b/native/host/src/data/mod.rs @@ -30,7 +30,7 @@ const ASK_SCAN: usize = 4000; fn now_ms() -> u64 { std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map_or(0, |d| d.as_millis() as u64) } /// Event times are seconds (older logs) or milliseconds. -fn ms(at: u64) -> u64 { if at < 100_000_000_000 { at * 1000 } else { at } } +pub(super) fn ms(at: u64) -> u64 { if at < 100_000_000_000 { at * 1000 } else { at } } fn clip(s: &str, n: usize) -> String { let t: String = s.chars().take(n).collect(); t.replace('\n', " ") } fn s<'a>(v: &'a Value, k: &str) -> &'a str { v.get(k).and_then(Value::as_str).unwrap_or("") } fn err(e: T) -> Value { json!(e.to_string()) } @@ -112,7 +112,7 @@ fn open_ask_index(hub: &Hub) -> Vec<(String, String, usize)> { pub fn ask_thread(hub: &Hub, ask: &str) -> Option { open_ask_index(hub).into_iter().find(|(a, ..)| a == ask).map(|(_, t, _)| t) } /// Whether `thread` currently has any open ask in the tail. pub fn thread_has_open_ask(hub: &Hub, thread: &str) -> bool { open_ask_index(hub).into_iter().any(|(_, t, _)| t == thread) } -fn open_ask_counts(hub: &Hub) -> HashMap { +pub(super) fn open_ask_counts(hub: &Hub) -> HashMap { let mut m = HashMap::new(); for (_, th, _) in open_ask_index(hub) { *m.entry(th).or_insert(0) += 1 } m @@ -126,7 +126,7 @@ pub(crate) fn shelf_flags(t: &crate::state::Thread) -> (bool, bool, u64) { let settled = crate::shelf::shelf_of(t) == crate::shelf::Shelf::Settled; (t.pinned, settled, if settled { ms(t.settled_at) } else { 0 }) } -fn flags_of(id: &str) -> (bool, bool, u64) { crate::statehost::policies().and_then(|p| p.with_state(|st| st.threads.get(id).map(shelf_flags))).flatten().unwrap_or((false, false, 0)) } +pub(super) fn flags_of(id: &str) -> (bool, bool, u64) { crate::statehost::policies().and_then(|p| p.with_state(|st| st.threads.get(id).map(shelf_flags))).flatten().unwrap_or((false, false, 0)) } /// A setting of the policy state ("" when unset or the state is not up). fn setting_of(k: &str) -> String { crate::statehost::policies().and_then(|p| p.with_state(|st| st.settings.get(k).cloned())).flatten().unwrap_or_default() } /// Why `thread.create` refuses the Scratch project: its chats are kept (Conversation history) and open as they were, but no new one starts there. @@ -140,6 +140,87 @@ fn preview_of(hub: &Hub, m: &crate::model::Model, id: &str) -> String { let p = m.page(&hub.store, id, 0, 8).ok().and_then(|p| p.rows.iter().find(|r| r.kind == "msg" && !r.text.trim().is_empty()).map(|r| clip(&shown_text(&r.text), PREVIEW))).unwrap_or_default(); let mut c = PREVIEWS.lock().unwrap(); if c.len() > 20_000 { c.clear() } c.insert(key, (tip, p.clone())); p } +#[derive(Default)] +pub(super) struct ThreadRowState { + pinned: bool, + settled: bool, + settled_at: u64, + model: String, + effort: String, + runtime: String, + plan_mode: Value, + combo_short: String, + status: String, + pin_order: u64, + swarm: String, + speed: String, + parent: String, +} + +#[derive(Default)] +pub(super) struct ThreadRowBatch { + rows: HashMap, + models_info: Option>, +} + +impl ThreadRowBatch { + /// Reads per-thread policy/signal/combo state for all local `ids` under one state lock pass. + pub(super) fn build(hub: &Hub, ids: &[String]) -> Self { + let models_info = Some(crate::settings::models::info_value()); + if ids.is_empty() { + return Self { rows: HashMap::new(), models_info }; + } + let now_s = crate::hub::now_ms() / 1000; + let build_st = |st: &crate::state::State| { + let signals = crate::signal::index(st); + let mut combo = crate::present::keys::ComboCache::new(st, now_s); + let mut rows = HashMap::with_capacity(ids.len()); + for id in ids { + if rows.contains_key(id) { continue } + let (pinned, settled, settled_at) = st.threads.get(id).map(shelf_flags).unwrap_or((false, false, 0)); + let model = st.threads.get(id).map_or(String::new(), |t| t.model.clone()); + let effort = st.settings.get(&format!("effort.{id}")).cloned().unwrap_or_default(); + let runtime = st.runtime.get(id).cloned().unwrap_or_default(); + let plan_mode = crate::present::keys::plan_mode(st, id); + let combo_v = combo.combo_for(st, id); + let combo_short = combo_v["short"].as_str().unwrap_or("").to_string(); + let status = signals.get(id).map_or("", |n| crate::signal::display_name(st, *n, id)).to_string(); + let pin_order = if pinned { crate::sidebar::pin_place(st, id) } else { 0 }; + let swarm = st.swarm_of.get(id).cloned().unwrap_or_default(); + let speed = st.settings.get(&format!("speed.{id}")).cloned().unwrap_or_default(); + let parent = st.settings.get(&format!("thread.parent.{id}")).cloned().unwrap_or_default(); + rows.insert(id.clone(), ThreadRowState { pinned, settled, settled_at, model, effort, runtime, plan_mode, combo_short, status, pin_order, swarm, speed, parent }); + } + rows + }; + let rows = crate::statehost::with_state_of(hub, build_st) + .or_else(|| crate::statehost::policies().and_then(|p| p.with_state(build_st))) + .unwrap_or_default(); + Self { rows, models_info } + } +} + +pub(super) fn thread_json_batched(hub: &Hub, m: &crate::model::Model, id: &str, asks: &HashMap, batch: &ThreadRowBatch) -> Option { + let t = m.threads.get(id).filter(|t| !t.deleted)?; + let waiting = asks.get(id).copied().unwrap_or(0); + let state = if waiting > 0 { "asking" } else { match t.turn.as_str() { "running" => "working", "failed" => "failed", _ => "idle" } }; + let preview = preview_of(hub, m, id); + let st = batch.rows.get(id); + let (pinned, settled, settled_at) = st.map_or((false, false, 0), |s| (s.pinned, s.settled, s.settled_at)); + let raw_model = st.filter(|s| !s.model.is_empty()).map_or_else(|| t.model.clone(), |s| s.model.clone()); + let model = crate::settings::models::sanitize_model(&t.provider, &raw_model, batch.models_info.as_deref()); + let effort = st.map_or("", |s| s.effort.as_str()); + let runtime = st.map_or("", |s| s.runtime.as_str()); + let chip = st.map(|s| s.combo_short.as_str()).filter(|c| !c.is_empty()).map(str::to_string).unwrap_or_else(|| ext::chip(&t.provider, &model, effort)); + let mut row = json!({"id":id,"project":t.project,"title":t.title,"state":state,"updatedAt":ms(t.activity.max(t.created)),"pinned":pinned,"pinOrder":st.map_or(0, |s| s.pin_order),"settled":settled,"settledAt":settled_at,"archived":t.archived, + "provider":t.provider,"model":model,"effort":effort,"speed":st.map_or("", |s| s.speed.as_str()),"runtime":runtime,"chip":chip,"preview":preview,"waiting":waiting,"status":st.map_or("", |s| s.status.as_str()),"parent":st.map_or("", |s| s.parent.as_str()),"history":t.project == crate::sidebar::SCRATCH,"chat":t.project == crate::sidebar::CHATS,"swarm":st.map_or("", |s| s.swarm.as_str()), + "memory":crate::bots::recall::progress::shown(&hub.cfg.home, id).unwrap_or(Value::Null)}); + if let Some(pm) = st.map(|s| &s.plan_mode) { + if !pm.is_null() && pm["phase"] != "off" { row["planMode"] = pm.clone(); } + } + Some(row) +} + fn thread_json(hub: &Hub, m: &crate::model::Model, id: &str, asks: &HashMap) -> Option { let t = m.threads.get(id).filter(|t| !t.deleted)?; let waiting = asks.get(id).copied().unwrap_or(0); @@ -173,7 +254,7 @@ fn thread_json(hub: &Hub, m: &crate::model::Model, id: &str, asks: &HashMap bool { +pub(super) fn run_hidden(thread: &str) -> bool { crate::state::is_mail_run_id(thread) || crate::statehost::policies().and_then(|p| p.with_state(|st| st.run_hidden(thread))).unwrap_or(false) } @@ -192,7 +273,7 @@ fn project_json(m: &crate::model::Model, id: &str, asks: &HashMap) } /// The linked machines' projects and threads next to this hub's: `f(shown machines, unified marks and join map, the pick)` (docs/PHONE-DATA.md, Your machines). -fn with_far(hub: &Hub, want: &str, f: impl FnOnce(&machines::Far, &crate::present::screen::Unified, &str) -> R) -> R { +pub(super) fn with_far(hub: &Hub, want: &str, f: impl FnOnce(&machines::Far, &crate::present::screen::Unified, &str) -> R) -> R { let m = hub.mirrors(); let here = m.here(); m.shown(|far| { let pick = machines::pick_of(want, far); @@ -216,6 +297,47 @@ fn merged_rows(g: &crate::model::Model, asks: &HashMap, far: &machi fn merged_row(hub: &Hub, g: &crate::model::Model, asks: &HashMap, id: &str) -> Option { with_far(hub, "", |far, un, _| merged_rows(g, asks, far, un).into_iter().find(|x| x.1 == id).map(|x| x.2)) } +/// Builds a batch of local and far thread rows, computing `signal::index` and `ComboCache` once per state. +pub(super) fn thread_rows_batch(hub: &Hub, g: &crate::model::Model, ids: &[String], asks: &HashMap, join: &HashMap) -> HashMap { + let mut local_ids: Vec = Vec::new(); + let mut far_ids: Vec = Vec::new(); + for id in ids { + if !id.contains('~') || g.threads.contains_key(id) { + local_ids.push(id.clone()); + } else { + far_ids.push(id.clone()); + } + } + let batch = ThreadRowBatch::build(hub, &local_ids); + let mut out = HashMap::with_capacity(ids.len()); + for id in &local_ids { + if let Some(v) = thread_json_batched(hub, g, id, asks, &batch) { + out.insert(id.clone(), v); + } + } + if !far_ids.is_empty() { + let far = hub.far(); + let previews: HashMap = far_ids.iter().map(|id| { + let p = far.as_ref().and_then(|f| f.page(id, 0, 8)) + .and_then(|pg| pg.rows.iter().filter(|r| r.thread == *id).find(|r| r.kind == "msg" && !r.text.trim().is_empty()).map(|r| clip(&shown_text(&r.text), PREVIEW))) + .unwrap_or_default(); + (id.clone(), p) + }).collect(); + hub.mirrors().shown(|fars| { + let mut signals: HashMap> = HashMap::new(); + for id in &far_ids { + let Some((mname, st)) = machines::holder(fars, id) else { continue }; + let Some(t) = st.threads.get(id) else { continue }; + let sig = signals.entry(mname.clone()).or_insert_with(|| crate::signal::index(st)); + let preview = previews.get(id).map(String::as_str).unwrap_or(""); + if let Some(v) = machines::thread_json_with_signals(id, st, &machines::project_shown(&t.project, join), &hub.mirrors().mark(mname), preview, sig) { + out.insert(id.clone(), v); + } + } + }); + } + out +} /// A thread row of this hub or of a linked machine (`~`, built from its mirror: no log to read, so its preview is the mirror's last words). fn thread_row(hub: &Hub, m: &crate::model::Model, id: &str, asks: &HashMap, join: &HashMap) -> Option { if !id.contains('~') || m.threads.contains_key(id) { return thread_json(hub, m, id, asks) } @@ -661,8 +783,10 @@ async fn call(hub: &Arc, c: &mut Conn, m: &str, p: &Value, is_browser: bool if let Some((a, i)) = s(p, "before").split_once(':') { if let Ok(a) = a.parse::() { keyed.retain(|x| x.0 < a || (x.0 == a && x.1.as_str() > i)) } } let more = keyed.len() > lim; keyed.truncate(lim); // only the page's threads are built in full (the preview reads the log) + let page_ids: Vec = keyed.iter().map(|(_, i)| i.clone()).collect(); + let mut built = thread_rows_batch(hub, &g, &page_ids, &asks, &join); let mut items = vec![]; - for (at, i) in &keyed { if let Some(v) = thread_row(hub, &g, i, &asks, &join) { items.push((*at, i.clone(), v)) } } + for (at, i) in &keyed { if let Some(v) = built.remove(i) { items.push((*at, i.clone(), v)) } } let next = if more { keyed.last().map(|x| json!(format!("{}:{}", x.0, x.1))).unwrap_or(Value::Null) } else { Value::Null }; Ok(json!({"threads":items.into_iter().map(|x| x.2).collect::>(),"next":next,"machines":chips})) } "thread.entries" => entries(hub, p).await, diff --git a/native/host/src/data/open.rs b/native/host/src/data/open.rs index ada8a52ce5..0dacffcaa0 100644 --- a/native/host/src/data/open.rs +++ b/native/host/src/data/open.rs @@ -46,12 +46,12 @@ pub(super) async fn thread_open(hub: &Arc, c: &mut Conn, subs: &mut Subs, p Ok(Value::Object(out)) } -/// `shell.sync {have?, settled?=25}` → `{projects?, threads?, sections?, removed?, h, sub}`: the sidebar in one reply, and a `lists` subscription. Per project its active and +/// `shell.sync {have?, settled?=25, open?}` → `{projects?, threads?, sections?, removed?, h, sub}`: the sidebar in one reply, and a `lists` subscription. Per project its active and /// pinned threads and its newest `settled` settled ones; an idle child (a subagent, a subthread) only with its parent listed. A project goes again, with all of its listed /// threads, only when the hash of the two together differs from the client's (`have["p:"]`); `removed` names the held projects that are gone. pub(super) async fn shell_sync(hub: &Arc, c: &mut Conn, subs: &mut Subs, p: &Value, is_browser: bool) -> Result { let have = p.get("have").filter(|h| h.is_object()).cloned().unwrap_or(json!({})); - let settled_n = p["settled"].as_u64().unwrap_or(25).min(200); + let settled_n = p["settled"].as_u64().unwrap_or(25).min(200) as usize; let mut projects: Vec = vec![]; let mut before = Value::Null; loop { // every project, a page at a time let mut q = json!({"limit": 200}); if !before.is_null() { q["before"] = before.clone(); } @@ -59,14 +59,67 @@ pub(super) async fn shell_sync(hub: &Arc, c: &mut Conn, subs: &mut Subs, p: projects.extend(r["projects"].as_array().cloned().unwrap_or_default()); before = r["next"].clone(); if before.is_null() || projects.len() > 2000 { break } } - let sections = call(hub, c, "sidebar.sections", &json!({}), is_browser).await.unwrap_or(Value::Null); + let mut sec_q = json!({}); + if p.get("open").is_some_and(Value::is_array) { sec_q["open"] = p["open"].clone(); } + let sections = call(hub, c, "sidebar.sections", &sec_q, is_browser).await.unwrap_or(Value::Null); subs.next += 1; subs.subs.push((subs.next, Topic::Lists)); - let (mut out, mut h) = (serde_json::Map::new(), serde_json::Map::new()); - let (mut rows, mut threads, mut seen) = (vec![], vec![], HashSet::new()); + + let at = hub.setting("home.at").await.unwrap_or_default(); + let farv = hub.far(); + let moved = |id: &str, project: &str| crate::net::homemove::moved_thread(&at, id, Some(project), &|x| farv.as_ref().map_or(false, |f| f.has(x))).is_some(); + let g = hub.model().await; + let asks = open_ask_counts(hub); + + // Collect local active/settled thread keys per project in one state pass instead of 2xN threads.list calls. + let mut local_by_proj: HashMap, Vec<(u64, String)>)> = HashMap::new(); + let mut collect_local = |st: Option<&crate::state::State>| { + for (id, t) in &g.threads { + if t.deleted || t.archived || t.project == crate::sidebar::SCRATCH || crate::state::is_mail_run_id(id) || moved(id, &t.project) { continue } + if st.is_some_and(|s| s.run_hidden(id)) { continue } + let (_, settled, settled_at) = st.and_then(|s| s.threads.get(id)).map(shelf_flags).unwrap_or((false, false, 0)); + let entry = local_by_proj.entry(t.project.clone()).or_default(); + if settled { + entry.1.push((settled_at, id.clone())); + } else { + entry.0.push((ms(t.activity.max(t.created)), id.clone())); + } + } + }; + if crate::statehost::policies().and_then(|pol| pol.with_state(|st| collect_local(Some(st)))).is_none() { + collect_local(None); + } + + let (join, mut far_by_proj) = with_far(hub, "", |far, un, _| (un.far.clone(), machines::thread_keys_by_project(far, "", un.far, false))); + + let mut per_project: Vec<(Value, String, Vec)> = Vec::with_capacity(projects.len()); + let mut all_ids: Vec = Vec::new(); + let mut all_seen: HashSet = HashSet::new(); for pr in projects { let id = pr["id"].as_str().unwrap_or("").to_string(); if id.is_empty() { continue } - let mut ts = call(hub, c, "threads.list", &json!({"project": id, "settled": false, "limit": 200}), is_browser).await.map(|r| r["threads"].as_array().cloned().unwrap_or_default()).unwrap_or_default(); - ts.extend(call(hub, c, "threads.list", &json!({"project": id, "settled": true, "limit": settled_n}), is_browser).await.map(|r| r["threads"].as_array().cloned().unwrap_or_default()).unwrap_or_default()); + let (mut active, mut settled) = local_by_proj.remove(&id).unwrap_or_default(); + if let Some((fa, fs)) = far_by_proj.remove(&id) { + active.extend(fa); + settled.extend(fs); + } + active.sort_by(|a, b| b.0.cmp(&a.0).then(a.1.cmp(&b.1))); + active.truncate(200); + settled.sort_by(|a, b| b.0.cmp(&a.0).then(a.1.cmp(&b.1))); + settled.truncate(settled_n); + let mut ids: Vec = Vec::with_capacity(active.len() + settled.len()); + for (_, tid) in active.into_iter().chain(settled.into_iter()) { + if all_seen.insert(tid.clone()) { all_ids.push(tid.clone()); } + ids.push(tid); + } + per_project.push((pr, id, ids)); + } + + let built = thread_rows_batch(hub, &g, &all_ids, &asks, &join); + drop(g); + + let (mut out, mut h) = (serde_json::Map::new(), serde_json::Map::new()); + let (mut rows, mut threads, mut seen) = (vec![], vec![], HashSet::new()); + for (pr, id, ids) in per_project { + let mut ts: Vec = ids.iter().filter_map(|tid| built.get(tid).cloned()).collect(); let listed: HashSet = ts.iter().filter_map(|t| t["id"].as_str().map(str::to_string)).collect(); // an idle child whose parent is not listed would stand alone among the project's threads: it comes with its parent's shelf ts.retain(|t| { let parent = t["parent"].as_str().unwrap_or(""); parent.is_empty() || listed.contains(parent) || t["state"] != "idle" || t["pinned"] == true }); diff --git a/native/host/src/data/tests.rs b/native/host/src/data/tests.rs index 120096dbad..87b6f93fe1 100644 --- a/native/host/src/data/tests.rs +++ b/native/host/src/data/tests.rs @@ -1502,6 +1502,30 @@ async fn viewer_layout_over_a_socket_is_per_device_pushed_and_refuses_in_code_ke assert_eq!(r["removed"], json!(["p2"]), "{r}"); assert!(r.get("projects").is_none(), "p1 is as held"); } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn threads_list_batched_matches_single_thread_json() { + let (h, port) = up("batched-threads").await; + h.commit(&json!({"$":"ThreadPinned","id":"t1","pinned":true,"at":1700000050})).await.unwrap(); + h.commit(&json!({"$":"ModesSet","id":"t1","runtime":"full-access","interaction":"plan","model":"claude-opus-5-5","at":1700000051})).await.unwrap(); + let mut ws = open(port, "&enc=json").await; let _ = next(&mut ws).await; + let listed = ask(&mut ws, 1, "threads.list", json!({})).await; + assert_eq!(listed["ok"], true, "{listed}"); + let g = h.hub.model().await; + let asks = open_ask_counts(&h.hub); + for row in listed["result"]["threads"].as_array().unwrap() { + let id = row["id"].as_str().unwrap(); + let single = thread_json(&h.hub, &g, id, &asks).unwrap(); + assert_eq!(row, &single, "batched threads.list row differs from thread_json for {id}"); + } +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn shell_sync_forwards_open_section_folds() { + let (_h, port) = up("shell-open").await; + let mut ws = open(port, "&enc=json").await; let _ = next(&mut ws).await; + let r = ask(&mut ws, 1, "shell.sync", json!({"open":["sec:quiet","sec:all"]})).await; + assert_eq!(r["ok"], true, "{r}"); + assert!(r["result"]["h"]["@sections"].is_string(), "{r}"); +} + /// The home (feature `home`): `hello.home` says where the uberbot lives as this hub sees it, and a lists subscription is told when that changes (`k:"home"`). #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn the_hello_says_where_the_home_is_and_a_move_of_it_is_pushed() { let (h, port) = up("homepush").await; diff --git a/native/host/src/present/keys.rs b/native/host/src/present/keys.rs index f6e7fb9e7f..042eedc854 100644 --- a/native/host/src/present/keys.rs +++ b/native/host/src/present/keys.rs @@ -207,6 +207,71 @@ pub fn combo(snapshot: &Value, provider: &str, model: &str, effort: &str, speed: json!({"model":m,"effort":e,"speed":speed,"account":if accounts { account.0 } else { "" },"email":account.1,"saved":account.2,"left":left,"tone":tone(left), "full":full.join(" · "),"mid":mid.join(" · "),"short":short.join(" · "),"windows":windows,"extra":extra,"note":note,"tip":tip.join("\n")}) } +/// Batch cache for `combo_of` across many threads of the same `State`: parses `accounts.inventory`, `allowance.`, `person_zone`, and `speed::info_now()` once per batch. +pub struct ComboCache { + pub info: Value, + zone: super::tz::Rule, + now_s: u64, + profiles: std::collections::HashMap, + default_allowances: std::collections::HashMap, +} + +impl ComboCache { + /// Builds a cache for one `State` snapshot at `now_s`. + pub fn new(st: &State, now_s: u64) -> Self { + let info = crate::agents::speed::info_now(); + let zone = super::thread::person_zone(st).unwrap_or_else(super::tz::Rule::utc); + let mut profiles = std::collections::HashMap::new(); + if let Some(raw) = st.settings.get("accounts.inventory") { + if let Ok(v) = serde_json::from_str::(raw) { + if let Some(arr) = v["profiles"].as_array() { + for p in arr { + if let Some(id) = p["id"].as_str() { + profiles.entry(id.to_string()).or_insert_with(|| p.clone()); + } + } + } + } + } + Self { info, zone, now_s, profiles, default_allowances: std::collections::HashMap::new() } + } + + /// Computes the combined chip JSON for `id`, identical to `combo_of(st, id, now_s)`. + pub fn combo_for(&mut self, st: &State, id: &str) -> Value { + let Some(t) = st.threads.get(id) else { return Value::Null }; + let model = crate::settings::models::sanitize_model(&t.provider, &t.model, self.info.is_object().then_some(&self.info)); + let get = |k: &str| st.settings.get(k).map(String::as_str).unwrap_or(""); + let bound = serde_json::from_str::(get(&format!("account.thread.{id}.{}", t.provider))) + .ok().and_then(|b| b["id"].as_str().map(str::to_string)).unwrap_or_default(); + let snap = if bound.is_empty() { + if let Some(v) = self.default_allowances.get(&t.provider) { + v.clone() + } else { + let v: Value = serde_json::from_str(get(&format!("allowance.{}", t.provider))).unwrap_or(Value::Null); + self.default_allowances.insert(t.provider.clone(), v.clone()); + v + } + } else { + let p = self.profiles.get(&bound).unwrap_or(&Value::Null); + profile_allowance(p, &t.provider) + }; + let short = |s: &str| s.split('@').next().unwrap_or("").to_string(); + let acct: (String, String, bool) = if bound.is_empty() { + let e = snap["email"].as_str().unwrap_or(""); + (if e.is_empty() { "default".into() } else { short(e) }, e.to_string(), false) + } else { + let p = self.profiles.get(&bound).unwrap_or(&Value::Null); + let (label, email) = (p["label"].as_str().unwrap_or(""), p["identity"]["email"].as_str().unwrap_or("")); + let name = if label.is_empty() { short(email) } else if label.contains('@') { short(label) } else { label.to_string() }; + (if name.is_empty() { "account".into() } else { name }, email.to_string(), true) + }; + let effort = get(&format!("effort.{id}")); + let want = get(&format!("speed.{id}")); + let speed = if want.is_empty() { "" } else { crate::agents::speed::effective(&self.info, &t.provider, &model, want) }; + combo(&snap, &t.provider, &model, effort, speed, (&acct.0, &acct.1, acct.2), &self.zone, self.now_s) + } +} + /// The combined chip of a thread (`combo`), from the state. pub fn combo_of(st: &State, id: &str, now_s: u64) -> Value { let Some(t) = st.threads.get(id) else { return Value::Null }; @@ -787,4 +852,20 @@ mod tests { assert_eq!(mn[mv_pos]["sub"][0]["value"], "c1\u{1f}p1"); assert_eq!(mn[mv_pos]["sub"][1]["value"], "c1\u{1f}p2"); } + #[test] fn combo_cache_matches_combo_of_for_default_and_bound_accounts() { + let mut st = State::new(); + for l in [ + r#"{"$":"ProjectCreated","id":"p1","title":"P","folder":"/p","at":1}"#, + r#"{"$":"ThreadCreated","id":"t1","project":"p1","title":"Default","provider":"claude","model":"claude-opus-5-5","at":1}"#, + r#"{"$":"ThreadCreated","id":"t2","project":"p1","title":"Bound","provider":"claude","model":"claude-sonnet-4-5","at":1}"#, + r#"{"$":"SettingSet","key":"effort.t1","value":"high","at":2}"#, + r#"{"$":"SettingSet","key":"allowance.claude","value":"{\"email\":\"alex@example.com\",\"windows\":[{\"scope\":\"five_hour\",\"used_permille\":250}]}","at":2}"#, + r#"{"$":"SettingSet","key":"accounts.inventory","value":"{\"profiles\":[{\"id\":\"prof1\",\"provider\":\"claude\",\"label\":\"Work\",\"identity\":{\"email\":\"sam@example.com\"},\"allowance\":{\"windows\":[{\"scope\":\"seven_day\",\"used_permille\":400}]}}]}","at":2}"#, + r#"{"$":"SettingSet","key":"account.thread.t2.claude","value":"{\"id\":\"prof1\"}","at":2}"#, + ] { st.apply_line(l); } + let mut cache = ComboCache::new(&st, 1_700_000_000); + for id in ["t1", "t2"] { + assert_eq!(cache.combo_for(&st, id), combo_of(&st, id, 1_700_000_000), "mismatch for {id}"); + } + } } diff --git a/web/dist/assets/app.js b/web/dist/assets/app.js index 10afd868c0..bc7db00a63 100644 --- a/web/dist/assets/app.js +++ b/web/dist/assets/app.js @@ -1,17 +1,17 @@ -function En(e=Date.now(),t=Math.random){let n=Math.floor(t()*1099511627776).toString(36);return`w${e}-${n}`.replace(/[^A-Za-z0-9_-]/g,"").slice(0,64)}function Pi(e){return e==="done"||e==="failed"||e==="cancelled"}function Si(e,t){if(!e||e.id!==t.id)return!0;let n=Pi(e.state),i=Pi(t.state);if(n!==i)return i;return(t.ended??0)>=(e.ended??0)}function Li(e){if(e.state!=="done")return!1;if(typeof e.hold==="boolean")return!e.hold;return(e.notes??[]).length===0}var Ft={en:{"agy.signout":"Sign out","android.hub.machines.approve":"Approve","android.load.earlier":"load earlier","approval.dismiss":"Dismiss","approval.implement":"Implement","ask.plan":"Proposed plan","bots.new":"New bot","bots.rooms":"Rooms","bots.tab.browser":"Browser","chats.move":"Move to project…","chats.move.none":"No project to move it to. Add a project first.","chats.new.noproject":"New chat (no project)","chats.title":"Chats","common.cancel":"Cancel","common.close":"Close","common.copy":"Copy","common.delete":"Delete","common.refresh":"Refresh","common.remove":"Remove","common.save":"Save","common.search":"Search","composer.model.tip":"Choose the model and effort","composer.placeholder":"Ask anything: @bot, >thread, %project, #room, $skill, /btw","composer.send":"Send","composer.stop":"Stop","gpui.acct.connected":"Connected","gpui.acct.not.connected":"Not connected","gpui.acct.sign.in.expired":"Sign-in expired","gpui.ask.plan.ready":"Ready for review","gpui.ask.plan.revise":"Revise","gpui.ask.plan.reviseph":"What should change in the plan?","gpui.ask.plan.sendrev":"Send revision","gpui.assembly":"Assembly","gpui.b.in.reply.to":"↩ In reply to: {quote}","gpui.b.replying.to":"↩ Replying to: {line}","gpui.bots.recall.off":"Off","gpui.bots.recall.on":"On","gpui.c.solid.big.next":"Loading it may take a while and a lot of memory.","gpui.c.solid.load.big":"Load it anyway","gpui.c.solid.loading.big":"Loading it anyway…","gpui.c.term.collapse":"Collapse","gpui.c.term.expand":"Expand","gpui.commands":"Commands","gpui.e.open.folder":"Open folder","gpui.filter.projects.and.threads":"Filter projects and threads","gpui.fold.or.unfold.the.sidebar":"Fold or unfold the sidebar","gpui.follow.paused":"Following paused","gpui.follow.wait":"Following: waiting for the agent's next edit","gpui.gerbers":"Gerbers","gpui.goal.notes":"GOAL & NOTES","gpui.improvements":"Improvements","gpui.jump.to.a.thread.run":"Jump to a thread, run a command or find what was said","gpui.mgmt.bom.dnp":"DNP","gpui.mgmt.bom.nompn":"no MPN","gpui.mgmt.checks.all":"All","gpui.mgmt.checks.fix":"Fix with agent","gpui.mgmt.checks.run":"Run","gpui.mgmt.close":"Close the panel","gpui.mgmt.fab.apply":"Apply","gpui.mgmt.fab.changed":"Changed since you last looked","gpui.mgmt.fab.derived":"* worked out from the fab's page (a mil in mm, a ring from a diameter). Dimmed: the rigid board's value, where this board's page says nothing else. A date opens the page it was read from.","gpui.mgmt.fab.extra":"Costs more","gpui.mgmt.fab.findings":"Findings","gpui.mgmt.fab.free":"Base price","gpui.mgmt.fab.judge":"Datasheets","gpui.mgmt.fab.limit":"Limit","gpui.mgmt.fab.readcol":"Read","gpui.mgmt.fab.refresh":"Refresh","gpui.mgmt.fab.reviewbtn":"Review","gpui.mgmt.fab.seen":"Seen","gpui.mgmt.fab.thefab":"The fab","gpui.mgmt.fab.use":"Use","gpui.mgmt.life.nopart":"No reading of this part yet.","gpui.mgmt.life.reading":"Reading its history…","gpui.mgmt.plan.addnote":"Add note","gpui.mgmt.plan.all":"Approve all","gpui.mgmt.plan.before":"Plan before routing","gpui.mgmt.plan.compact":"Compact","gpui.mgmt.plan.done":"done","gpui.mgmt.plan.drawn":"The plan's corridors and planes are drawn on the board while this panel is open. Close it to hide them.","gpui.mgmt.plan.edited":"Edited","gpui.mgmt.plan.elsewhere":"A routing plan for {board} awaits your approval","gpui.mgmt.plan.emptysub":"Layers, corridors, and planes appear here once a plan is proposed.","gpui.mgmt.plan.expand":"Expand","gpui.mgmt.plan.fit":"Fit","gpui.mgmt.plan.grid.all":"All layers","gpui.mgmt.plan.grid.pair":"Side by side","gpui.mgmt.plan.grid.single":"Single","gpui.mgmt.plan.hide":"Hide done","gpui.mgmt.plan.hint":"Drag waypoints to steer · Click + on edge to insert · Right-click vertex to remove","gpui.mgmt.plan.keysnote":"On this KiCad version, approve from this panel: in plan view KiCad's A, R and W keys aren't the plan's yet (A opens Add Footprint). Update KiCad.","gpui.mgmt.plan.layer":"Approve layer","gpui.mgmt.plan.layer.short":"Layer","gpui.mgmt.plan.lock":"Lock","gpui.mgmt.plan.locked":"Locked","gpui.mgmt.plan.noboard":"No routing plan for this board.","gpui.mgmt.plan.noitems":"No corridors or planes on this layer","gpui.mgmt.plan.note.placeholder":"Steering note for router…","gpui.mgmt.plan.nothing":"Nothing awaits your approval","gpui.mgmt.plan.offwords":"Agents route as you ask. Turn it on to have them propose a routing plan first and route only what you approve here.","gpui.mgmt.plan.onwords":"Before routing a board with 4 or more copper layers or more than 60 nets, the agent proposes corridors and plane regions here. It routes only what you approve.","gpui.mgmt.plan.reading":"Reading the routing plan…","gpui.mgmt.plan.reference":"over {layer}","gpui.mgmt.plan.refused":"KiCad refused","gpui.mgmt.plan.reject":"Reject","gpui.mgmt.plan.rejectlayer":"Reject layer","gpui.mgmt.plan.reqplain":"Approval requested","gpui.mgmt.plan.requested":"Approval requested: {what}","gpui.mgmt.plan.saved":"saved plan","gpui.mgmt.plan.show":"Show done","gpui.mgmt.plan.st.approved":"Approved","gpui.mgmt.plan.st.awaiting":"Awaiting review","gpui.mgmt.plan.st.blocked":"Blocked","gpui.mgmt.plan.st.empty":"Empty","gpui.mgmt.plan.st.partial":"Partial","gpui.mgmt.plan.st.rejected":"Rejected","gpui.mgmt.plan.st.routed":"Routed","gpui.mgmt.plan.st.routing":"Routing","gpui.mgmt.plan.st.verified":"Verified","gpui.mgmt.plan.stackup.short":"Stackup","gpui.mgmt.plan.stop":"Stop routing","gpui.mgmt.plan.sync":"Link zoom","gpui.mgmt.plan.tab":"Plan","gpui.mgmt.plan.unlock":"Unlock","gpui.mgmt.plan.verify":"Verify","gpui.mgmt.plan.view.canvas":"Canvas","gpui.mgmt.plan.view.list":"List","gpui.mgmt.plan.view.split":"Split","gpui.mgmt.plan.width":"Width","gpui.next.thread":"Next thread","gpui.no.goal.yet.ask.an":"No goal yet. Ask an agent to write what this project is for, or edit .backplane/intent.md.","gpui.no.models":"No models","gpui.no.threads.yet":"No threads yet.","gpui.nothing.matches":"Nothing matches","gpui.picker.favorite.add":"Add to favorites","gpui.picker.favorite.remove":"Remove from favorites","gpui.picker.favorites":"Favorites","gpui.planmode.bar.always":"Plan mode — explores and proposes a plan before editing","gpui.planmode.bar.executing":"Building the approved plan","gpui.planmode.bar.once":"Plan mode (1 turn) — explores and proposes a plan before editing","gpui.planmode.bar.pending":"Proposed plan awaits review below","gpui.planmode.bar.planning":"Planning — drafting a plan before edits","gpui.planmode.chip.building":"Building","gpui.planmode.chip.once":"Plan · 1t","gpui.planmode.scope.always":"Always","gpui.planmode.scope.once":"1 turn","gpui.planmode.tip":"Plan before acting (1 turn, always, or off)","gpui.planmode.top.executing":"Building plan","gpui.planmode.top.once":"Plan (1 turn)","gpui.planmode.top.pending":"Review plan","gpui.planmode.top.planning":"Planning","gpui.previous.thread":"Previous thread","gpui.projects.boards":"BOARDS ({n})","gpui.projects.mech":"MECHANICAL ({n})","gpui.projects.threads":"THREADS ({n})","gpui.projects.to.order":"TO ORDER ({n})","gpui.rail.no.board":"No board in this project","gpui.rail.no.mech":"No mechanical parts in this project","gpui.rail.no.schematic":"No schematic in this project","gpui.rail.split.needs.both":"Split needs a board and a schematic","gpui.search.models":"Search models","gpui.settings.group.agents":"Agents and tools","gpui.settings.group.general":"General","home.away":"Home ({name}) is away","home.away.queued":"Home ({name}) is away · {n} queued","home.away.since":"Home ({name}) is away since {time}","home.away.since.queued":"Home ({name}) is away since {time} · {n} queued","home.machine":"Home machine","home.move.failed":"Home move failed","home.move.failed.note":"Home move failed: {note}","home.move.here":"Make this machine the home","home.moving":"Moving home to {to}…","home.moving.step":"Moving home to {to}: {step}","hub.back.crash":"Backplane is back after it stopped unexpectedly","hub.restarting":"Restarting Backplane…","hub.restarting.build":"Restarting Backplane… (new build {build})","hub.stopped":"Backplane stopped","ios.hub.address.field":"Hub address","menu.pin":"Pin","menu.settle":"Settle","menu.unpin":"Unpin","menu.wake":"Wake","model.col.agent":"Agent","model.col.effort":"Effort","native.pair.connect":"Connect","native.thread.model":"Model","notify.settled":"Settled","palette.archive":"Archive thread","palette.command.placeholder":"Type a command or a thread","palette.diff":"Diff: what this thread changed","palette.newthread":"New thread","palette.settings":"Settings","palette.terminal":"Terminal","palette.unarchive":"Unarchive thread","phone.unsettle":"Unsettle","provider.notice.button":"Open Settings → Accounts","provider.notice.head":"No AI provider connected","provider.notice.senderr":"No AI provider connected yet. Open Settings → Accounts to connect Claude, Codex, Antigravity, or another provider.","provider.notice.senderr.remote":"No AI provider connected on {machine}. Open Settings → Accounts on {machine} to connect Claude, Codex, Antigravity, or another provider.","provider.notice.text.none":"Connect Claude, Codex, Antigravity, or another provider to start chatting.","provider.notice.text.signedout":"Sign in to Claude, Codex, or another provider in Settings → Accounts to start chatting.","reply.action":"Reply","reply.cancel":"Cancel reply","reply.to":"In reply to:","ring.hear.again.local":"Hear again (local)","ring.hear.again.openai":"Hear again (OpenAI)","ring.no.recordings.yet":"No recordings yet.","ring.recordings":"Recordings","ring.ring":"Ring","ring.search.what.you.said":"Search what you said","ring.show.all":"Show all","ring.what.happened":"What happened","rooms.new":"New room","secret.you":"You","settings.appearance":"Appearance","settings.lang":"Language","settings.lang.auto":"Automatic","settings.lang.en":"English","settings.lang.es":"Español","settings.lang.ja":"日本語","settings.theme":"Theme","settings.theme.dark":"Dark","settings.theme.light":"Light","sheet.rename":"Rename thread","sidebar.add.project":"Add project","sidebar.search.projects":"Search projects","thread.context.base":"Backplane","thread.context.copied":"Prompt copied.","thread.context.copy":"Copy prompt","thread.context.disable":"Disable","thread.context.enable":"Enable","thread.context.index":"Available skills index","thread.context.injected.label":"Injected project instructions","thread.context.instructions":"Instructions","thread.context.mcp":"Project MCPs","thread.context.native.note":"Backplane’s launch prompt. Native files are loaded by the provider.","thread.context.none.instructions":"No project instructions found.","thread.context.none.mcp":"No project MCP configurations found.","thread.context.reading":"Reading thread context…","thread.context.size":"{bytes} B · ≈{tokens} tokens","thread.context.skills":"Skills","thread.context.system":"System Prompt","thread.context.title":"Context & Prompt","thread.context.trust":"Trust and enable","thread.new":"New thread","tools.pinned":"Pinned","tools.retry":"Retry","tour.title.bots":"Bots","viewer.board":"Board","viewer.diff":"Diff","viewer.files":"Files","viewer.mech":"Mech","viewer.review":"Review","viewer.schematic":"Schematic","viewer.solid":"3D","web.chat.answer.btn":"Answer","web.chat.answer.placeholder":"Type answer…","web.chat.answered":"Answered: {answer}","web.chat.choose":"Choose a project thread on the left to begin.","web.chat.empty":"No messages yet. Type below to start a turn.","web.chat.finished":"Finished {time}","web.chat.finished.dur":"Finished {time} · {dur}","web.chat.loading":"Loading messages…","web.chat.review.mode":"Review mode","web.chat.streaming":"Streaming…","web.clone.add.dir":"Add {dir}","web.clone.back":"Back","web.clone.change.folder":"Change folder","web.clone.cloned":"Cloned {repo} into {dest}","web.clone.cloning":"Cloning {repo} into {dest}","web.clone.copied":"Copied","web.clone.first":"First message: {text}","web.clone.folder.name":"Folder name","web.clone.go":"Clone","web.clone.loading":"Loading…","web.clone.no.folders":"No folders here","web.clone.open.project":"Open the project","web.clone.open.thread":"Open the thread","web.clone.private":"private","web.clone.repo.placeholder":"https or ssh URL, or owner/repo","web.clone.retry":"Try again","web.clone.same":"Already cloned there: it is added as it is.","web.clone.signin":"Sign in to GitHub","web.clone.signin.done":"Signed in to GitHub","web.clone.signin.enter":"Enter this code on GitHub:","web.clone.signin.wait":"Starting GitHub sign-in…","web.clone.start.thread":"Start a thread","web.clone.stopped":"Stopped cloning {repo}","web.clone.tab":"Clone from git","web.clone.up":"Up","web.clone.use.dir":"Use {dir}","web.composer.attach":"Attach image","web.composer.maximages":"At most {max} images per message.","web.composer.unsupported":"Unsupported image type: {type}","web.composer.voice":"Voice dictation","web.home.error":"Could not load this project.","web.home.fold":"Hide threads","web.home.lead":"Lead time: {n} days","web.home.lead.one":"Lead time: 1 day","web.home.loading":"Loading project…","web.home.open":"Open project home","web.home.unfold":"Show threads","web.logout.failed":"Could not confirm sign-out. Try again.","web.pair.approve.in":"Approve on desktop or paired phone · expires in {time}","web.pair.approved":"Approved. Opening Backplane…","web.pair.cancelled":"Cancelled.","web.pair.code":"Comparison code","web.pair.denied":"Pairing request was denied.","web.pair.expired":"Pairing code expired. Request a new code to try again.","web.pair.failed":"Pairing request failed ({status})","web.pair.name":"Browser name","web.pair.nocode":"Hub did not return a comparison code.","web.pair.ratelimited":"Too many pairing attempts. Wait a moment and try again.","web.pair.request":"Request pairing","web.pair.requesting":"Requesting pairing code…","web.pair.subtitle":"Pair this browser with your hub. Approve the 6-digit code in Backplane › Settings › Devices.","web.pair.unreachable":"Could not reach the hub. Check your tailnet connection.","web.plan.awaiting":"{n} awaiting approval","web.plan.net.one":"1 net","web.plan.nets":"{n} nets","web.ring.app.words":"The Pebble app's words","web.ring.count":"{n} recordings","web.ring.count.one":"1 recording","web.ring.error":"Could not load recordings.","web.ring.found":"{found} of {total} have “{q}”.","web.ring.heard.by":"Heard by {model}","web.ring.heard.by.sure":"Heard by {model}, {conf}% sure","web.ring.loading":"Loading recordings…","web.ring.no.words":"(no words)","web.ring.not.heard":"Not heard","web.ring.state.busy":"being heard now","web.ring.state.failed":"not given to Pebble","web.ring.state.heard":"waiting to go to Pebble","web.ring.state.new":"waiting to be heard","web.ring.state.sent":"given to Pebble","web.ring.unavailable":"This hub does not show ring notes to a browser yet. Update it, or open Settings › Ring in the desktop app.","web.settings.providers":"AI providers","web.settings.providers.browser":"Connect a provider in the Backplane desktop or mobile app under Settings → Accounts."},es:{"agy.signout":"Cerrar sesión","android.hub.machines.approve":"Aprobar","android.load.earlier":"cargar anteriores","approval.dismiss":"Descartar","approval.implement":"Implementar","ask.plan":"Plan propuesto","bots.new":"Nuevo bot","bots.rooms":"Salas","bots.tab.browser":"Navegador","chats.move":"Mover a un proyecto…","chats.move.none":"No hay ningún proyecto al que moverlo. Añade uno primero.","chats.new.noproject":"Chat nuevo (sin proyecto)","chats.title":"Chats","common.cancel":"Cancelar","common.close":"Cerrar","common.copy":"Copiar","common.delete":"Eliminar","common.refresh":"Actualizar","common.remove":"Quitar","common.save":"Guardar","common.search":"Buscar","composer.model.tip":"Elegir el modelo y el esfuerzo","composer.placeholder":"Pregunta lo que sea: @bot, >hilo, %proyecto, #sala, $skill, /btw","composer.send":"Enviar","composer.stop":"Detener","gpui.acct.connected":"Conectado","gpui.acct.not.connected":"No conectado","gpui.acct.sign.in.expired":"Sesión caducada","gpui.ask.plan.ready":"Listo para revisar","gpui.ask.plan.revise":"Revisar","gpui.ask.plan.reviseph":"¿Qué debería cambiar en el plan?","gpui.ask.plan.sendrev":"Enviar revisión","gpui.assembly":"Ensamblaje","gpui.b.in.reply.to":"↩ En respuesta a: {quote}","gpui.b.replying.to":"↩ Respondiendo a: {line}","gpui.bots.recall.off":"Desactivado","gpui.bots.recall.on":"Activado","gpui.c.solid.big.next":"Cargarlo puede tardar y usar mucha memoria.","gpui.c.solid.load.big":"Cargarlo de todos modos","gpui.c.solid.loading.big":"Cargándolo de todos modos…","gpui.c.term.collapse":"Contraer","gpui.c.term.expand":"Expandir","gpui.commands":"Comandos","gpui.e.open.folder":"Abrir carpeta","gpui.filter.projects.and.threads":"Filtrar proyectos e hilos","gpui.fold.or.unfold.the.sidebar":"Plegar o desplegar la barra lateral","gpui.follow.paused":"Seguimiento en pausa","gpui.follow.wait":"Siguiendo: esperando la próxima edición del agente","gpui.gerbers":"Gerbers","gpui.goal.notes":"OBJETIVO Y NOTAS","gpui.improvements":"Mejoras","gpui.jump.to.a.thread.run":"Saltar a un hilo, ejecutar un comando o buscar lo dicho","gpui.mgmt.bom.dnp":"DNP","gpui.mgmt.bom.nompn":"sin MPN","gpui.mgmt.checks.all":"Todas","gpui.mgmt.checks.fix":"Corregir con agente","gpui.mgmt.checks.run":"Ejecutar","gpui.mgmt.close":"Cerrar el panel","gpui.mgmt.fab.apply":"Aplicar","gpui.mgmt.fab.changed":"Cambió desde la última vez que miraste","gpui.mgmt.fab.derived":"* calculado desde la página del fabricante (un mil en mm, un anillo desde un diámetro). Atenuado: el valor de la placa rígida, cuando la página de esta placa no dice otra cosa. Una fecha abre la página de la que se leyó.","gpui.mgmt.fab.extra":"Cuesta más","gpui.mgmt.fab.findings":"Hallazgos","gpui.mgmt.fab.free":"Precio base","gpui.mgmt.fab.judge":"Hojas de datos","gpui.mgmt.fab.limit":"Límite","gpui.mgmt.fab.readcol":"Leído","gpui.mgmt.fab.refresh":"Actualizar","gpui.mgmt.fab.reviewbtn":"Revisar","gpui.mgmt.fab.seen":"Visto","gpui.mgmt.fab.thefab":"El fabricante","gpui.mgmt.fab.use":"Usar","gpui.mgmt.life.nopart":"Sin lectura de esta pieza aún.","gpui.mgmt.life.reading":"Leyendo su historial…","gpui.mgmt.plan.addnote":"Añadir nota","gpui.mgmt.plan.all":"Aprobar todo","gpui.mgmt.plan.before":"Planificar antes de rutear","gpui.mgmt.plan.compact":"Compacto","gpui.mgmt.plan.done":"hecho","gpui.mgmt.plan.drawn":"Los corredores y planos del plan se dibujan en la placa mientras este panel está abierto. Ciérralo para ocultarlos.","gpui.mgmt.plan.edited":"Editado","gpui.mgmt.plan.elsewhere":"Un plan de ruteo para {board} espera tu aprobación","gpui.mgmt.plan.emptysub":"Las capas, corredores y planos aparecerán aquí cuando se proponga un plan.","gpui.mgmt.plan.expand":"Expandir","gpui.mgmt.plan.fit":"Ajustar","gpui.mgmt.plan.grid.all":"Todas las capas","gpui.mgmt.plan.grid.pair":"Lado a lado","gpui.mgmt.plan.grid.single":"Única","gpui.mgmt.plan.hide":"Ocultar hechos","gpui.mgmt.plan.hint":"Arrastra vértices para guiar · Clic en + del borde para insertar · Clic derecho en vértice para quitar","gpui.mgmt.plan.keysnote":"En esta versión de KiCad, aprueba desde este panel: en la vista de plan las teclas A, R y W de KiCad aún no son del plan (A abre Añadir Huella). Actualiza KiCad.","gpui.mgmt.plan.layer":"Aprobar capa","gpui.mgmt.plan.layer.short":"Capa","gpui.mgmt.plan.lock":"Bloquear","gpui.mgmt.plan.locked":"Bloqueado","gpui.mgmt.plan.noboard":"No hay plan de ruteo para esta placa.","gpui.mgmt.plan.noitems":"Sin corredores ni planos en esta capa","gpui.mgmt.plan.note.placeholder":"Nota de guiado para el router…","gpui.mgmt.plan.nothing":"Nada espera tu aprobación","gpui.mgmt.plan.offwords":"Los agentes rutean como les pidas. Actívalo para que primero propongan un plan de ruteo y ruteen solo lo que apruebes aquí.","gpui.mgmt.plan.onwords":"Antes de rutear una placa con 4 o más capas de cobre o más de 60 redes, el agente propone aquí corredores y regiones de plano. Solo rutea lo que apruebes.","gpui.mgmt.plan.reading":"Leyendo el plan de ruteo…","gpui.mgmt.plan.reference":"sobre {layer}","gpui.mgmt.plan.refused":"KiCad lo rechazó","gpui.mgmt.plan.reject":"Rechazar","gpui.mgmt.plan.rejectlayer":"Rechazar capa","gpui.mgmt.plan.reqplain":"Aprobación solicitada","gpui.mgmt.plan.requested":"Aprobación solicitada: {what}","gpui.mgmt.plan.saved":"plan guardado","gpui.mgmt.plan.show":"Mostrar hechos","gpui.mgmt.plan.st.approved":"Aprobado","gpui.mgmt.plan.st.awaiting":"Esperando revisión","gpui.mgmt.plan.st.blocked":"Bloqueado","gpui.mgmt.plan.st.empty":"Vacío","gpui.mgmt.plan.st.partial":"Parcial","gpui.mgmt.plan.st.rejected":"Rechazado","gpui.mgmt.plan.st.routed":"Ruteado","gpui.mgmt.plan.st.routing":"Ruteando","gpui.mgmt.plan.st.verified":"Verificado","gpui.mgmt.plan.stackup.short":"Apilamiento","gpui.mgmt.plan.stop":"Detener ruteo","gpui.mgmt.plan.sync":"Vincular zoom","gpui.mgmt.plan.tab":"Plan","gpui.mgmt.plan.unlock":"Desbloquear","gpui.mgmt.plan.verify":"Verificar","gpui.mgmt.plan.view.canvas":"Lienzo","gpui.mgmt.plan.view.list":"Lista","gpui.mgmt.plan.view.split":"Dividido","gpui.mgmt.plan.width":"Ancho","gpui.next.thread":"Hilo siguiente","gpui.no.goal.yet.ask.an":"Sin objetivo aún. Pide a un agente que escriba para qué es este proyecto, o edita .backplane/intent.md.","gpui.no.models":"Sin modelos","gpui.no.threads.yet":"Sin hilos aún.","gpui.nothing.matches":"Nada coincide","gpui.picker.favorite.add":"Añadir a favoritos","gpui.picker.favorite.remove":"Quitar de favoritos","gpui.picker.favorites":"Favoritos","gpui.planmode.bar.always":"Modo plan — explora y propone un plan antes de editar","gpui.planmode.bar.executing":"Ejecutando el plan aprobado","gpui.planmode.bar.once":"Modo plan (1 turno) — explora y propone un plan antes de editar","gpui.planmode.bar.pending":"El plan propuesto espera revisión abajo","gpui.planmode.bar.planning":"Planificando — redactando un plan antes de editar","gpui.planmode.chip.building":"Ejecutando","gpui.planmode.chip.once":"Plan · 1t","gpui.planmode.scope.always":"Siempre","gpui.planmode.scope.once":"1 turno","gpui.planmode.tip":"Planificar antes de actuar (1 turno, siempre u off)","gpui.planmode.top.executing":"Ejecutando plan","gpui.planmode.top.once":"Plan (1 turno)","gpui.planmode.top.pending":"Revisar plan","gpui.planmode.top.planning":"Planificando","gpui.previous.thread":"Hilo anterior","gpui.projects.boards":"PLACAS ({n})","gpui.projects.mech":"MECÁNICO ({n})","gpui.projects.threads":"HILOS ({n})","gpui.projects.to.order":"POR PEDIR ({n})","gpui.rail.no.board":"Este proyecto no tiene placa","gpui.rail.no.mech":"Este proyecto no tiene piezas mecánicas","gpui.rail.no.schematic":"Este proyecto no tiene esquema","gpui.rail.split.needs.both":"La vista dividida requiere una placa y un esquema","gpui.search.models":"Buscar modelos","gpui.settings.group.agents":"Agentes y herramientas","gpui.settings.group.general":"General","home.away":"El inicio ({name}) no está disponible","home.away.queued":"El inicio ({name}) no está disponible · {n} en cola","home.away.since":"El inicio ({name}) no está disponible desde las {time}","home.away.since.queued":"El inicio ({name}) no está disponible desde las {time} · {n} en cola","home.machine":"Máquina de inicio","home.move.failed":"No se pudo mover el inicio","home.move.failed.note":"No se pudo mover el inicio: {note}","home.move.here":"Hacer de esta máquina el inicio","home.moving":"Moviendo el inicio a {to}…","home.moving.step":"Moviendo el inicio a {to}: {step}","hub.back.crash":"Backplane volvió tras detenerse de forma inesperada","hub.restarting":"Reiniciando Backplane…","hub.restarting.build":"Reiniciando Backplane… (nueva compilación {build})","hub.stopped":"Backplane se detuvo","ios.hub.address.field":"Dirección del hub","menu.pin":"Fijar","menu.settle":"Cerrar","menu.unpin":"Desfijar","menu.wake":"Despertar","model.col.agent":"Agente","model.col.effort":"Esfuerzo","native.pair.connect":"Conectar","native.thread.model":"Modelo","notify.settled":"Cerrado","palette.archive":"Archivar hilo","palette.command.placeholder":"Escribe un comando o un hilo","palette.diff":"Diff: qué cambió este hilo","palette.newthread":"Nuevo hilo","palette.settings":"Ajustes","palette.terminal":"Terminal","palette.unarchive":"Desarchivar hilo","phone.unsettle":"Reabrir","provider.notice.button":"Abrir Configuración → Cuentas","provider.notice.head":"No hay ningún proveedor de IA conectado","provider.notice.senderr":"Aún no hay ningún proveedor de IA conectado. Abre Configuración → Cuentas para conectar Claude, Codex, Antigravity u otro proveedor.","provider.notice.senderr.remote":"No hay ningún proveedor de IA conectado en {machine}. Abre Configuración → Cuentas en {machine} para conectar Claude, Codex, Antigravity u otro proveedor.","provider.notice.text.none":"Conecta Claude, Codex, Antigravity u otro proveedor para empezar a chatear.","provider.notice.text.signedout":"Inicia sesión en Claude, Codex u otro proveedor en Configuración → Cuentas para empezar a chatear.","reply.action":"Responder","reply.cancel":"Cancelar respuesta","reply.to":"En respuesta a:","ring.hear.again.local":"Escuchar de nuevo (local)","ring.hear.again.openai":"Escuchar de nuevo (OpenAI)","ring.no.recordings.yet":"Sin grabaciones aún.","ring.recordings":"Grabaciones","ring.ring":"Anillo","ring.search.what.you.said":"Buscar lo que dijiste","ring.show.all":"Mostrar todo","ring.what.happened":"Qué ocurrió","rooms.new":"Nueva sala","secret.you":"Tú","settings.appearance":"Apariencia","settings.lang":"Idioma","settings.lang.auto":"Automático","settings.lang.en":"English","settings.lang.es":"Español","settings.lang.ja":"日本語","settings.theme":"Tema","settings.theme.dark":"Oscuro","settings.theme.light":"Claro","sheet.rename":"Renombrar hilo","sidebar.add.project":"Añadir proyecto","sidebar.search.projects":"Buscar proyectos","thread.context.base":"Backplane","thread.context.copied":"Se copiaron las instrucciones.","thread.context.copy":"Copiar instrucciones","thread.context.disable":"Desactivar","thread.context.enable":"Activar","thread.context.index":"Índice de habilidades disponibles","thread.context.injected.label":"Instrucciones del proyecto añadidas","thread.context.instructions":"Instrucciones","thread.context.mcp":"MCP del proyecto","thread.context.native.note":"Instrucciones de inicio de Backplane. El proveedor carga los archivos nativos.","thread.context.none.instructions":"No se encontraron instrucciones del proyecto.","thread.context.none.mcp":"No se encontraron configuraciones MCP del proyecto.","thread.context.reading":"Leyendo el contexto del hilo…","thread.context.size":"{bytes} B · ≈{tokens} tokens","thread.context.skills":"Habilidades","thread.context.system":"Instrucciones del sistema","thread.context.title":"Contexto e instrucciones","thread.context.trust":"Confiar y activar","thread.new":"Nuevo hilo","tools.pinned":"Fijado","tools.retry":"Reintentar","tour.title.bots":"Bots","viewer.board":"Placa","viewer.diff":"Diff","viewer.files":"Archivos","viewer.mech":"Mech","viewer.review":"Revisión","viewer.schematic":"Esquemático","viewer.solid":"3D","web.chat.answer.btn":"Responder","web.chat.answer.placeholder":"Escribe una respuesta…","web.chat.answered":"Respondido: {answer}","web.chat.choose":"Elige un hilo de proyecto a la izquierda para empezar.","web.chat.empty":"Aún no hay mensajes. Escribe abajo para iniciar un turno.","web.chat.finished":"Terminado {time}","web.chat.finished.dur":"Terminado {time} · {dur}","web.chat.loading":"Cargando mensajes…","web.chat.review.mode":"Modo de revisión","web.chat.streaming":"Transmitiendo…","web.clone.add.dir":"Añadir {dir}","web.clone.back":"Atrás","web.clone.change.folder":"Cambiar carpeta","web.clone.cloned":"{repo} clonado en {dest}","web.clone.cloning":"Clonando {repo} en {dest}","web.clone.copied":"Copiado","web.clone.first":"Primer mensaje: {text}","web.clone.folder.name":"Nombre de la carpeta","web.clone.go":"Clonar","web.clone.loading":"Cargando…","web.clone.no.folders":"No hay carpetas aquí","web.clone.open.project":"Abrir el proyecto","web.clone.open.thread":"Abrir el hilo","web.clone.private":"privado","web.clone.repo.placeholder":"URL https o ssh, o propietario/repositorio","web.clone.retry":"Reintentar","web.clone.same":"Ya está clonado ahí: se añade tal cual.","web.clone.signin":"Iniciar sesión en GitHub","web.clone.signin.done":"Sesión iniciada en GitHub","web.clone.signin.enter":"Introduce este código en GitHub:","web.clone.signin.wait":"Iniciando sesión en GitHub…","web.clone.start.thread":"Empezar un hilo","web.clone.stopped":"Se detuvo la clonación de {repo}","web.clone.tab":"Clonar desde git","web.clone.up":"Subir","web.clone.use.dir":"Usar {dir}","web.composer.attach":"Adjuntar imagen","web.composer.maximages":"Como máximo {max} imágenes por mensaje.","web.composer.unsupported":"Tipo de imagen no compatible: {type}","web.composer.voice":"Dictado por voz","web.home.error":"No se pudo cargar este proyecto.","web.home.fold":"Ocultar hilos","web.home.lead":"Plazo de entrega: {n} días","web.home.lead.one":"Plazo de entrega: 1 día","web.home.loading":"Cargando el proyecto…","web.home.open":"Abrir la página del proyecto","web.home.unfold":"Mostrar hilos","web.logout.failed":"No se pudo confirmar el cierre de sesión. Inténtalo de nuevo.","web.pair.approve.in":"Aprueba en el escritorio o en un teléfono vinculado · caduca en {time}","web.pair.approved":"Aprobado. Abriendo Backplane…","web.pair.cancelled":"Cancelado.","web.pair.code":"Código de comparación","web.pair.denied":"Se rechazó la solicitud de vinculación.","web.pair.expired":"El código de vinculación caducó. Solicita uno nuevo para intentarlo otra vez.","web.pair.failed":"Falló la solicitud de vinculación ({status})","web.pair.name":"Nombre del navegador","web.pair.nocode":"El hub no devolvió un código de comparación.","web.pair.ratelimited":"Demasiados intentos de vinculación. Espera un momento e inténtalo de nuevo.","web.pair.request":"Solicitar vinculación","web.pair.requesting":"Solicitando código de vinculación…","web.pair.subtitle":"Vincula este navegador con tu hub. Aprueba el código de 6 dígitos en Backplane › Ajustes › Dispositivos.","web.pair.unreachable":"No se pudo conectar con el hub. Comprueba tu conexión de tailnet.","web.plan.awaiting":"{n} esperando aprobación","web.plan.net.one":"1 red","web.plan.nets":"{n} redes","web.ring.app.words":"Las palabras de la aplicación Pebble","web.ring.count":"{n} grabaciones","web.ring.count.one":"1 grabación","web.ring.error":"No se pudieron cargar las grabaciones.","web.ring.found":"{found} de {total} contienen “{q}”.","web.ring.heard.by":"Transcrito por {model}","web.ring.heard.by.sure":"Transcrito por {model}, {conf}% de certeza","web.ring.loading":"Cargando grabaciones…","web.ring.no.words":"(sin palabras)","web.ring.not.heard":"Sin transcribir","web.ring.state.busy":"transcribiéndose ahora","web.ring.state.failed":"no entregada a Pebble","web.ring.state.heard":"en espera de entrega a Pebble","web.ring.state.new":"en espera de transcripción","web.ring.state.sent":"entregada a Pebble","web.ring.unavailable":"Este hub aún no muestra las notas del anillo en un navegador. Actualízalo o abre Configuración › Anillo en la aplicación de escritorio.","web.settings.providers":"Proveedores de IA","web.settings.providers.browser":"Conecta un proveedor en la aplicación de escritorio o móvil de Backplane en Configuración → Cuentas."},ja:{"agy.signout":"サインアウト","android.hub.machines.approve":"承認","android.load.earlier":"以前のメッセージを読み込む","approval.dismiss":"閉じる","approval.implement":"実装","ask.plan":"提案されたプラン","bots.new":"新しいボット","bots.rooms":"ルーム","bots.tab.browser":"ブラウザ","chats.move":"プロジェクトに移動…","chats.move.none":"移動先のプロジェクトがありません。先にプロジェクトを追加してください。","chats.new.noproject":"新しいチャット(プロジェクトなし)","chats.title":"チャット","common.cancel":"キャンセル","common.close":"閉じる","common.copy":"コピー","common.delete":"削除","common.refresh":"更新","common.remove":"削除","common.save":"保存","common.search":"検索","composer.model.tip":"モデルと推論の強さを選択","composer.placeholder":"何でも質問:@bot、>thread、%project、#room、$skill、/btw","composer.send":"送信","composer.stop":"停止","gpui.acct.connected":"接続済み","gpui.acct.not.connected":"未接続","gpui.acct.sign.in.expired":"サインインの期限切れ","gpui.ask.plan.ready":"確認待ち","gpui.ask.plan.revise":"修正","gpui.ask.plan.reviseph":"計画のどこを変更しますか?","gpui.ask.plan.sendrev":"修正を送る","gpui.assembly":"アセンブリ","gpui.b.in.reply.to":"↩ 返信先:{quote}","gpui.b.replying.to":"↩ 返信中:{line}","gpui.bots.recall.off":"オフ","gpui.bots.recall.on":"オン","gpui.c.solid.big.next":"読み込みには時間と多くのメモリがかかることがあります。","gpui.c.solid.load.big":"それでも読み込む","gpui.c.solid.loading.big":"それでも読み込み中…","gpui.c.term.collapse":"折りたたむ","gpui.c.term.expand":"展開","gpui.commands":"コマンド","gpui.e.open.folder":"フォルダを開く","gpui.filter.projects.and.threads":"プロジェクトとスレッドを絞り込む","gpui.fold.or.unfold.the.sidebar":"サイドバーを折りたたむ/開く","gpui.follow.paused":"追従を一時停止中","gpui.follow.wait":"追従中: エージェントの次の編集を待っています","gpui.gerbers":"ガーバー","gpui.goal.notes":"目標とメモ","gpui.improvements":"改善","gpui.jump.to.a.thread.run":"スレッドへ移動、コマンドを実行、または発言を検索","gpui.mgmt.bom.dnp":"実装しない","gpui.mgmt.bom.nompn":"MPNなし","gpui.mgmt.checks.all":"すべて","gpui.mgmt.checks.fix":"エージェントに直してもらう","gpui.mgmt.checks.run":"実行","gpui.mgmt.close":"パネルを閉じる","gpui.mgmt.fab.apply":"適用","gpui.mgmt.fab.changed":"前回見てから変わったところ","gpui.mgmt.fab.derived":"* 製造元のページから計算した値です(milをmmに、径からランドを)。薄い色の項目はリジッド基板の値です(この基板のページに記載がないもの)。日付を押すと読んだページが開きます。","gpui.mgmt.fab.extra":"追加料金","gpui.mgmt.fab.findings":"指摘","gpui.mgmt.fab.free":"基本料金","gpui.mgmt.fab.judge":"データシート","gpui.mgmt.fab.limit":"項目","gpui.mgmt.fab.readcol":"読んだ日","gpui.mgmt.fab.refresh":"再読み込み","gpui.mgmt.fab.reviewbtn":"レビュー","gpui.mgmt.fab.seen":"確認済み","gpui.mgmt.fab.thefab":"製造元","gpui.mgmt.fab.use":"使う","gpui.mgmt.life.nopart":"この部品の記録はまだありません。","gpui.mgmt.life.reading":"履歴を読んでいます…","gpui.mgmt.plan.addnote":"メモを追加","gpui.mgmt.plan.all":"すべて承認","gpui.mgmt.plan.before":"配線前に計画する","gpui.mgmt.plan.compact":"標準","gpui.mgmt.plan.done":"完了","gpui.mgmt.plan.drawn":"計画の配線経路とプレーンは、このパネルを開いている間だけ基板上に表示されます。閉じると消えます。","gpui.mgmt.plan.edited":"編集済み","gpui.mgmt.plan.elsewhere":"{board}の配線計画が承認を待っています","gpui.mgmt.plan.emptysub":"計画が提案されると、レイヤー・コリドー・ベタ領域がここに表示されます。","gpui.mgmt.plan.expand":"拡大","gpui.mgmt.plan.fit":"全体表示","gpui.mgmt.plan.grid.all":"全レイヤー","gpui.mgmt.plan.grid.pair":"並べて表示","gpui.mgmt.plan.grid.single":"単一","gpui.mgmt.plan.hide":"完了を隠す","gpui.mgmt.plan.hint":"頂点をドラッグして誘導 · 辺の + をクリックで追加 · 頂点を右クリックで削除","gpui.mgmt.plan.keysnote":"このバージョンのKiCadでは、このパネルから承認してください。プランビューでのKiCadのA・R・Wキーはまだ計画のものではありません(Aはフットプリントの追加を開きます)。KiCadを更新してください。","gpui.mgmt.plan.layer":"層を承認","gpui.mgmt.plan.layer.short":"レイヤー","gpui.mgmt.plan.lock":"ロック","gpui.mgmt.plan.locked":"ロック中","gpui.mgmt.plan.noboard":"この基板の配線計画はありません。","gpui.mgmt.plan.noitems":"このレイヤーにコリドーまたはプレーンがありません","gpui.mgmt.plan.note.placeholder":"ルーターへの指示メモ…","gpui.mgmt.plan.nothing":"承認待ちはありません","gpui.mgmt.plan.offwords":"エージェントは指示どおりに配線します。オンにすると、まず配線計画を提案し、ここで承認したものだけを配線します。","gpui.mgmt.plan.onwords":"銅箔層が4層以上、またはネットが60本を超える基板では、配線の前にエージェントがここで配線経路とプレーン領域を提案します。承認したものだけを配線します。","gpui.mgmt.plan.reading":"配線計画を読んでいます…","gpui.mgmt.plan.reference":"基準 {layer}","gpui.mgmt.plan.refused":"KiCad が拒否しました","gpui.mgmt.plan.reject":"却下","gpui.mgmt.plan.rejectlayer":"レイヤーを却下","gpui.mgmt.plan.reqplain":"承認が求められています","gpui.mgmt.plan.requested":"承認が求められています: {what}","gpui.mgmt.plan.saved":"保存された計画","gpui.mgmt.plan.show":"完了を表示","gpui.mgmt.plan.st.approved":"承認済み","gpui.mgmt.plan.st.awaiting":"承認待ち","gpui.mgmt.plan.st.blocked":"ブロック","gpui.mgmt.plan.st.empty":"空","gpui.mgmt.plan.st.partial":"一部完了","gpui.mgmt.plan.st.rejected":"却下","gpui.mgmt.plan.st.routed":"配線済み","gpui.mgmt.plan.st.routing":"配線中","gpui.mgmt.plan.st.verified":"検証済み","gpui.mgmt.plan.stackup.short":"スタックアップ","gpui.mgmt.plan.stop":"配線を止める","gpui.mgmt.plan.sync":"ズーム連動","gpui.mgmt.plan.tab":"計画","gpui.mgmt.plan.unlock":"ロック解除","gpui.mgmt.plan.verify":"検証","gpui.mgmt.plan.view.canvas":"キャンバス","gpui.mgmt.plan.view.list":"リスト","gpui.mgmt.plan.view.split":"分割","gpui.mgmt.plan.width":"幅","gpui.next.thread":"次のスレッド","gpui.no.goal.yet.ask.an":"目標はまだありません。このプロジェクトの目的をエージェントに書いてもらうか、.backplane/intent.md を編集してください。","gpui.no.models":"モデルがありません","gpui.no.threads.yet":"スレッドはまだありません。","gpui.nothing.matches":"一致するものはありません","gpui.picker.favorite.add":"お気に入りに追加","gpui.picker.favorite.remove":"お気に入りから外す","gpui.picker.favorites":"お気に入り","gpui.planmode.bar.always":"計画モード — 編集前に調査して計画を提案します","gpui.planmode.bar.executing":"承認された計画を実行しています","gpui.planmode.bar.once":"計画モード (1回) — 編集前に調査して計画を提案します","gpui.planmode.bar.pending":"提案された計画が下のレビューを待っています","gpui.planmode.bar.planning":"計画中 — 編集前の計画を作成しています","gpui.planmode.chip.building":"実行中","gpui.planmode.chip.once":"計画 · 1回","gpui.planmode.scope.always":"常時","gpui.planmode.scope.once":"1回","gpui.planmode.tip":"実行前に計画を作成 (1回・常時・オフ)","gpui.planmode.top.executing":"計画を実行中","gpui.planmode.top.once":"計画 (1回)","gpui.planmode.top.pending":"計画を確認","gpui.planmode.top.planning":"計画中","gpui.previous.thread":"前のスレッド","gpui.projects.boards":"基板({n})","gpui.projects.mech":"機構部品({n})","gpui.projects.threads":"スレッド({n})","gpui.projects.to.order":"注文するもの({n})","gpui.rail.no.board":"このプロジェクトには基板がありません","gpui.rail.no.mech":"このプロジェクトには機械部品がありません","gpui.rail.no.schematic":"このプロジェクトには回路図がありません","gpui.rail.split.needs.both":"分割表示には基板と回路図が必要です","gpui.search.models":"モデルを検索","gpui.settings.group.agents":"エージェントとツール","gpui.settings.group.general":"一般","home.away":"ホーム({name})はオフラインです","home.away.queued":"ホーム({name})はオフラインです · {n} 件待機中","home.away.since":"ホーム({name})は {time} からオフラインです","home.away.since.queued":"ホーム({name})は {time} からオフラインです · {n} 件待機中","home.machine":"ホームマシン","home.move.failed":"ホームの移動に失敗しました","home.move.failed.note":"ホームの移動に失敗しました: {note}","home.move.here":"このマシンをホームにする","home.moving":"ホームを {to} へ移動中…","home.moving.step":"ホームを {to} へ移動中: {step}","hub.back.crash":"予期せず停止したBackplaneが戻りました","hub.restarting":"Backplaneを再起動しています…","hub.restarting.build":"Backplaneを再起動しています…(新しいビルド {build})","hub.stopped":"Backplaneは停止しました","ios.hub.address.field":"ハブのアドレス","menu.pin":"ピン留め","menu.settle":"完了","menu.unpin":"ピン留めを解除","menu.wake":"再開","model.col.agent":"エージェント","model.col.effort":"推論の強さ","native.pair.connect":"接続","native.thread.model":"モデル","notify.settled":"完了","palette.archive":"スレッドをアーカイブ","palette.command.placeholder":"コマンドまたはスレッドを入力","palette.diff":"差分:このスレッドの変更","palette.newthread":"新しいスレッド","palette.settings":"設定","palette.terminal":"ターミナル","palette.unarchive":"スレッドのアーカイブを解除","phone.unsettle":"未完了に戻す","provider.notice.button":"設定 → アカウントを開く","provider.notice.head":"AI プロバイダーが接続されていません","provider.notice.senderr":"AI プロバイダーがまだ接続されていません。設定 → アカウントを開いて、Claude、Codex、Antigravity などのプロバイダーを接続してください。","provider.notice.senderr.remote":"{machine} に AI プロバイダーが接続されていません。{machine} で設定 → アカウントを開いて、Claude、Codex、Antigravity などのプロバイダーを接続してください。","provider.notice.text.none":"チャットを始めるには、Claude、Codex、Antigravity などのプロバイダーを接続してください。","provider.notice.text.signedout":"チャットを始めるには、設定 → アカウントで Claude、Codex などのプロバイダーにサインインしてください。","reply.action":"返信","reply.cancel":"返信をやめる","reply.to":"返信先:","ring.hear.again.local":"もう一度聞き取る (ローカル)","ring.hear.again.openai":"もう一度聞き取る (OpenAI)","ring.no.recordings.yet":"録音はまだありません。","ring.recordings":"録音","ring.ring":"リング","ring.search.what.you.said":"話した内容を検索","ring.show.all":"すべて表示","ring.what.happened":"どうなったか","rooms.new":"新しいルーム","secret.you":"あなた","settings.appearance":"外観","settings.lang":"言語","settings.lang.auto":"自動","settings.lang.en":"English","settings.lang.es":"Español","settings.lang.ja":"日本語","settings.theme":"テーマ","settings.theme.dark":"ダーク","settings.theme.light":"ライト","sheet.rename":"スレッド名を変更","sidebar.add.project":"プロジェクトを追加","sidebar.search.projects":"プロジェクトを検索","thread.context.base":"Backplane","thread.context.copied":"プロンプトをコピーしました。","thread.context.copy":"プロンプトをコピー","thread.context.disable":"無効にする","thread.context.enable":"有効にする","thread.context.index":"利用可能なスキルの一覧","thread.context.injected.label":"追加されたプロジェクトの指示","thread.context.instructions":"指示","thread.context.mcp":"プロジェクトの MCP","thread.context.native.note":"Backplane が起動時に渡すプロンプトです。ネイティブファイルはプロバイダーが読み込みます。","thread.context.none.instructions":"プロジェクトの指示が見つかりません。","thread.context.none.mcp":"プロジェクトの MCP 設定が見つかりません。","thread.context.reading":"スレッドのコンテキストを読み込み中…","thread.context.size":"{bytes} B・約{tokens}トークン","thread.context.skills":"スキル","thread.context.system":"システムプロンプト","thread.context.title":"コンテキストとプロンプト","thread.context.trust":"承認して有効にする","thread.new":"新しいスレッド","tools.pinned":"固定中","tools.retry":"再試行","tour.title.bots":"ボット","viewer.board":"基板","viewer.diff":"差分","viewer.files":"ファイル","viewer.mech":"Mech","viewer.review":"レビュー","viewer.schematic":"回路図","viewer.solid":"3D","web.chat.answer.btn":"回答","web.chat.answer.placeholder":"回答を入力…","web.chat.answered":"回答済み: {answer}","web.chat.choose":"左側からプロジェクトのスレッドを選んで開始してください。","web.chat.empty":"まだメッセージはありません。下に入力して開始してください。","web.chat.finished":"完了 {time}","web.chat.finished.dur":"完了 {time} · {dur}","web.chat.loading":"メッセージを読み込んでいます…","web.chat.review.mode":"レビューモード","web.chat.streaming":"受信中…","web.clone.add.dir":"{dir} を追加","web.clone.back":"戻る","web.clone.change.folder":"フォルダを変更","web.clone.cloned":"{repo} を {dest} にクローンしました","web.clone.cloning":"{repo} を {dest} にクローン中","web.clone.copied":"コピーしました","web.clone.first":"最初のメッセージ: {text}","web.clone.folder.name":"フォルダ名","web.clone.go":"クローン","web.clone.loading":"読み込み中…","web.clone.no.folders":"フォルダがありません","web.clone.open.project":"プロジェクトを開く","web.clone.open.thread":"スレッドを開く","web.clone.private":"非公開","web.clone.repo.placeholder":"https / ssh の URL、または owner/repo","web.clone.retry":"もう一度","web.clone.same":"すでにそこにクローンされています: そのまま追加します。","web.clone.signin":"GitHub にサインイン","web.clone.signin.done":"GitHub にサインインしました","web.clone.signin.enter":"このコードを GitHub に入力してください:","web.clone.signin.wait":"GitHub のサインインを開始しています…","web.clone.start.thread":"スレッドを開始","web.clone.stopped":"{repo} のクローンを中止しました","web.clone.tab":"git からクローン","web.clone.up":"上へ","web.clone.use.dir":"{dir} を使う","web.composer.attach":"画像を添付","web.composer.maximages":"1 件のメッセージに添付できる画像は最大 {max} 枚です。","web.composer.unsupported":"未対応の画像形式です: {type}","web.composer.voice":"音声入力","web.home.error":"このプロジェクトを読み込めませんでした。","web.home.fold":"スレッドを隠す","web.home.lead":"リードタイム: {n} 日","web.home.lead.one":"リードタイム: 1 日","web.home.loading":"プロジェクトを読み込み中…","web.home.open":"プロジェクトホームを開く","web.home.unfold":"スレッドを表示","web.logout.failed":"サインアウトを確認できませんでした。もう一度お試しください。","web.pair.approve.in":"デスクトップまたはペアリング済みの端末で承認してください · 有効期限 {time}","web.pair.approved":"承認されました。Backplane を開いています…","web.pair.cancelled":"キャンセルしました。","web.pair.code":"確認コード","web.pair.denied":"ペアリングのリクエストが拒否されました。","web.pair.expired":"ペアリングコードの有効期限が切れました。新しいコードをリクエストしてください。","web.pair.failed":"ペアリングのリクエストに失敗しました ({status})","web.pair.name":"ブラウザー名","web.pair.nocode":"ハブから確認コードが返されませんでした。","web.pair.ratelimited":"ペアリングの試行回数が多すぎます。しばらく待ってからやり直してください。","web.pair.request":"ペアリングをリクエスト","web.pair.requesting":"ペアリングコードをリクエストしています…","web.pair.subtitle":"このブラウザーをハブとペアリングします。Backplane › 設定 › デバイス で 6 桁のコードを承認してください。","web.pair.unreachable":"ハブに接続できませんでした。tailnet の接続を確認してください。","web.plan.awaiting":"{n} 件が承認待ち","web.plan.net.one":"1 ネット","web.plan.nets":"{n} ネット","web.ring.app.words":"Pebble アプリの文字起こし","web.ring.count":"録音 {n} 件","web.ring.count.one":"録音 1 件","web.ring.error":"録音を読み込めませんでした。","web.ring.found":"{total} 件中 {found} 件に「{q}」があります。","web.ring.heard.by":"{model} が認識","web.ring.heard.by.sure":"{model} が認識、確度 {conf}%","web.ring.loading":"録音を読み込み中…","web.ring.no.words":"(言葉なし)","web.ring.not.heard":"未認識","web.ring.state.busy":"認識中","web.ring.state.failed":"Pebble に渡せませんでした","web.ring.state.heard":"Pebble への受け渡し待ち","web.ring.state.new":"認識待ち","web.ring.state.sent":"Pebble に渡しました","web.ring.unavailable":"このハブはまだブラウザーにリングのメモを表示しません。ハブを更新するか、デスクトップアプリの設定 › リングを開いてください。","web.settings.providers":"AI プロバイダー","web.settings.providers.browser":"Backplane のデスクトップまたはモバイルアプリの設定 → アカウントからプロバイダーを接続してください。"}};function Ai(e,t){if(!t)return e;return e.replace(/\{([a-zA-Z0-9_.-]+)\}/g,(n,i)=>Object.prototype.hasOwnProperty.call(t,i)?String(t[i]):n)}var Ct=Br(),Cn=new Set,kn=new Map;for(let[e,t]of Object.entries(Ft.en||{}))if(typeof t==="string"&&!kn.has(t))kn.set(t,e);function Br(){let e=typeof navigator<"u"&&navigator.language?navigator.language.toLowerCase():"en";if(e.startsWith("ja"))return"ja";if(e.startsWith("es"))return"es";return"en"}function Ni(){if(typeof document<"u"&&document.documentElement)document.documentElement.lang=Ct}Ni();function rn(e){return Cn.add(e),()=>{Cn.delete(e)}}function kt(e){if(!e)return!1;let t=e.toLowerCase(),n=t.startsWith("ja")?"ja":t.startsWith("es")?"es":t.startsWith("en")?"en":"";if(!n)return!1;let i=n!==Ct;if(Ct=n,Ni(),i)for(let s of Cn)s(Ct);return i}function Mi(){return Ct}function m(e,t,n){let s=(Ft[Ct]||Ft.en||{})[e]??Ft.en?.[e]??t??e;return Ai(s,n)}function he(e){if(!e)return"";let t=kn.get(e);if(!t)return e;return m(t,e)}function X(e,t="",n=""){let i=document.createElement(e);if(t)i.className=t;if(n)i.textContent=n;return i}function _e(e,t="",n){let i=X("button",t,e);if(i.type="button",n)i.addEventListener("click",n);return i}function Ir(e){let t=e.replace(/[\\/]+$/,"");if(!t)return e||"/";let n=t.split(/[\\/]/);return n[n.length-1]||t}function Rr(e,t){let n=e.includes("\\")&&!e.includes("/")?"\\":"/";return e.endsWith(n)?e+t:e+n+t}class xn{hub;actionLabel;action;root;pathInput;upBtn;listEl;errEl;actBtn;path="";parent=null;gen=0;busy=!1;constructor(e,t,n,i=[]){this.hub=e;this.actionLabel=t;this.action=n;this.root=X("div","bp-fb"),this.root.setAttribute("data-testid","folder-browser");let s=X("div","bp-fb-head");this.upBtn=_e("↑","bp-btn-ghost bp-fb-up",()=>{if(this.parent)this.go(this.parent)}),this.upBtn.title=m("web.clone.up","Up"),this.upBtn.setAttribute("aria-label",m("web.clone.up","Up")),this.pathInput=X("input","bp-input bp-fb-path"),this.pathInput.spellcheck=!1,this.pathInput.setAttribute("data-testid","folder-path"),this.pathInput.addEventListener("keydown",(o)=>{if(o.key==="Enter"){o.preventDefault();let a=this.pathInput.value.trim();if(a)this.go(a)}}),s.append(this.upBtn,this.pathInput),this.listEl=X("div","bp-fb-list"),this.errEl=X("div","bp-ap-err bp-hidden");let r=X("div","bp-ap-foot");this.actBtn=_e("","primary",()=>{this.run()}),this.actBtn.setAttribute("data-testid","folder-act"),r.append(...i,this.actBtn),this.root.append(s,this.listEl,this.errEl,r)}currentPath(){return this.path}async go(e){let t=++this.gen;this.setError(""),this.listEl.replaceChildren(X("div","bp-fb-empty",m("web.clone.loading","Loading…")));try{let n=await this.hub.rpc("dirs.list",{path:e});if(t!==this.gen)return;this.path=n.path,this.parent=n.parent??null,this.render(n.dirs??[])}catch(n){if(t!==this.gen)return;this.setError(he(n instanceof Error?n.message:String(n))),this.render(null)}}refreshLocale(){this.upBtn.title=m("web.clone.up","Up"),this.updateAct()}render(e){if(this.pathInput.value=this.path,this.upBtn.disabled=!this.parent,this.updateAct(),e===null){this.listEl.replaceChildren();return}if(e.length===0){this.listEl.replaceChildren(X("div","bp-fb-empty",m("web.clone.no.folders","No folders here")));return}let t=document.createDocumentFragment();for(let n of e){let i=_e("","bp-fb-row",()=>{this.go(Rr(this.path,n))});i.append(X("span","bp-fb-icon","▸"),X("span","bp-fb-name",n)),t.appendChild(i)}this.listEl.replaceChildren(t),this.listEl.scrollTop=0}updateAct(){this.actBtn.textContent=this.path?this.actionLabel(Ir(this.path)):this.actionLabel("…"),this.actBtn.disabled=!this.path||this.busy}async run(){if(!this.path||this.busy)return;this.busy=!0,this.updateAct(),this.setError("");try{await this.action(this.path)}catch(e){this.setError(he(e instanceof Error?e.message:String(e)))}finally{this.busy=!1,this.updateAct()}}setError(e){this.errEl.textContent=e,this.errEl.classList.toggle("bp-hidden",!e)}}class Pn{container;host;backdrop=null;bodyEl=null;tabsEl=null;mode="folder";repoText="";repoValue="";firstText="";wantThread=!0;userParent="";nameText="";nameTouched=!1;dest=null;destGen=0;destPending=!1;destTimer=null;repos=null;reposGen=0;reposTimer=null;showSuggest=!1;suggestIdx=-1;startErr="";starting=!1;picking=!1;jobId="";job=null;specs=new Map;signin=null;copied=!1;repoInput=null;suggestEl=null;destEl=null;signinEl=null;cloneBtn=null;jobEl=null;constructor(e,t){this.container=e;this.host=t}isOpen(){return this.backdrop!==null}open(e={}){let t=this.host.hub.hasFeature("clone"),n=!e.repo&&Boolean(this.jobId)&&(!this.job||this.job.state==="running"||this.job.state==="done");if(!this.backdrop)this.build();if(!n)this.jobId="",this.job=null,this.resetForm();if(e.repo!==void 0||e.text!==void 0)this.repoText=(e.repo??"").trim(),this.repoValue="",this.firstText=(e.text??"").trim();if(this.mode=t&&(e.mode==="clone"||n)?"clone":"folder",this.render(),n){if(this.job)this.maybeGo(this.job);this.reconcile()}else if(this.mode==="clone"&&this.repoText)this.askDest()}reconcile(){let e=this.jobId;if(!e)return;this.host.hub.rpc("clone.status",{id:e}).then((t)=>this.apply(t)).catch(()=>{})}close(){if(this.reposTimer!==null)window.clearTimeout(this.reposTimer);if(this.destTimer!==null)window.clearTimeout(this.destTimer);this.reposTimer=null,this.destTimer=null,this.backdrop?.remove(),this.backdrop=null,this.bodyEl=null,this.tabsEl=null}escape(){if(this.picking){this.picking=!1,this.render();return}if(this.showSuggest){this.showSuggest=!1,this.renderSuggest();return}this.close()}refreshLocale(){if(this.backdrop)this.render()}handleFrame(e){if(e.k==="clone"){let t=e.clone;if(t)this.apply(t)}else if(e.k==="clone.repos"){if(this.isOpen()&&this.mode==="clone"&&!this.jobId)this.askRepos(0)}else if(e.k==="clone.signin"){if(!this.signin)return;let t=this.signin.state;if(this.signin=e.signin??null,this.signin?.state==="cancelled")this.signin=null;if(t!=="done"&&this.signin?.state==="done")this.askRepos(0);this.renderSignin()}}build(){let e=X("div","bp-modal-backdrop");e.setAttribute("data-testid","add-project");let t=X("div","bp-modal bp-ap"),n=X("div","bp-modal-head"),i=X("h2","",m("sidebar.add.project","Add project")),s=_e("×","icon",()=>this.close());s.title=m("common.close","Close"),s.setAttribute("aria-label",m("common.close","Close")),n.append(i,s),this.tabsEl=X("div","bp-ap-tabs"),this.bodyEl=X("div","bp-modal-body bp-ap-body"),t.append(n,this.tabsEl,this.bodyEl),e.appendChild(t),e.addEventListener("mousedown",(r)=>{if(r.target===e)this.close()}),this.container.appendChild(e),this.backdrop=e}resetForm(){this.repoText="",this.repoValue="",this.firstText="",this.wantThread=!0,this.userParent="",this.nameText="",this.nameTouched=!1,this.dest=null,this.destPending=!1,this.repos=null,this.showSuggest=!1,this.suggestIdx=-1,this.startErr="",this.starting=!1,this.picking=!1,this.signin=null,this.copied=!1}render(){if(!this.bodyEl||!this.tabsEl||!this.backdrop)return;let e=this.backdrop.querySelector(".bp-modal-head h2");if(e)e.textContent=m("sidebar.add.project","Add project");if(this.renderTabs(),this.repoInput=null,this.suggestEl=null,this.destEl=null,this.signinEl=null,this.cloneBtn=null,this.jobEl=null,this.mode==="folder")this.renderFolder();else if(this.jobId&&this.job)this.renderJobView();else if(this.picking)this.renderPickParent();else this.renderCloneForm()}renderTabs(){if(!this.tabsEl)return;if(!this.host.hub.hasFeature("clone")){this.tabsEl.classList.add("bp-hidden");return}this.tabsEl.classList.remove("bp-hidden");let e=(t,n)=>{let i=_e(n,"bp-ap-tab"+(this.mode===t?" on":""),()=>{if(this.mode===t)return;if(this.mode=t,this.render(),t==="clone"&&!this.jobId&&this.repos===null)this.askRepos(0)});return i.setAttribute("data-testid",`ap-tab-${t}`),i.setAttribute("aria-pressed",String(this.mode===t)),i};this.tabsEl.replaceChildren(e("folder",m("gpui.e.open.folder","Open folder")),e("clone",m("web.clone.tab","Clone from git")))}renderFolder(){let e=new xn(this.host.hub,(t)=>m("web.clone.add.dir","Add {dir}",{dir:t}),async(t)=>{let n=await this.host.hub.rpc("project.add",{path:t},30000);if(this.close(),n.project)this.host.onProjectAdded(n.project)});this.bodyEl.replaceChildren(e.root),e.go("")}renderCloneForm(){let e=this.bodyEl,t=X("div","bp-ap-form"),n=X("div","bp-ap-repo"),i=X("input","bp-input");i.type="text",i.spellcheck=!1,i.autocomplete="off",i.placeholder=m("web.clone.repo.placeholder","https or ssh URL, or owner/repo"),i.setAttribute("aria-label",m("web.clone.repo.placeholder","https or ssh URL, or owner/repo")),i.setAttribute("data-testid","clone-repo"),i.value=this.repoText,i.addEventListener("input",()=>{if(this.repoText=i.value,this.repoValue="",this.showSuggest=!0,this.suggestIdx=-1,this.startErr="",!this.nameTouched)this.nameText="";this.askRepos(200),this.askDest(250)}),i.addEventListener("focus",()=>{if(this.showSuggest=!0,this.repos===null)this.askRepos(0);else this.renderSuggest()}),i.addEventListener("blur",()=>{window.setTimeout(()=>{if(document.activeElement!==i)this.showSuggest=!1,this.renderSuggest()},120)}),i.addEventListener("keydown",(p)=>this.repoKey(p)),this.repoInput=i,this.suggestEl=X("div","bp-ap-suggest bp-hidden"),this.suggestEl.setAttribute("data-testid","clone-suggest"),n.append(i,this.suggestEl),this.signinEl=X("div","bp-ap-signin bp-hidden"),this.signinEl.setAttribute("data-testid","clone-signin"),this.destEl=X("div","bp-ap-dest"),this.destEl.setAttribute("data-testid","clone-dest");let s=X("label","bp-ap-check"),r=X("input");r.type="checkbox",r.checked=this.wantThread,r.setAttribute("data-testid","clone-thread"),r.addEventListener("change",()=>{this.wantThread=r.checked}),s.append(r,X("span","",m("web.clone.start.thread","Start a thread")));let o=[n,this.signinEl,this.destEl,s];if(this.firstText)o.push(X("div","bp-ap-first bp-dim",m("web.clone.first","First message: {text}",{text:this.firstText})));let a=X("div","bp-ap-err"+(this.startErr?"":" bp-hidden"),this.startErr);a.setAttribute("data-testid","clone-start-error");let c=X("div","bp-ap-foot");this.cloneBtn=_e(m("web.clone.go","Clone"),"primary",()=>{this.startClone()}),this.cloneBtn.setAttribute("data-testid","clone-go"),c.append(this.cloneBtn),o.push(a,c),t.append(...o),e.replaceChildren(t),this.renderSuggest(),this.renderSignin(),this.renderDest(),window.setTimeout(()=>{if(this.repoInput===i&&!this.repoText)i.focus()},0)}repoKey(e){let t=this.repos?.repos??[],n=this.showSuggest&&t.length>0;if(e.key==="ArrowDown"&&n)e.preventDefault(),this.suggestIdx=Math.min(t.length-1,this.suggestIdx+1),this.renderSuggest();else if(e.key==="ArrowUp"&&n)e.preventDefault(),this.suggestIdx=Math.max(-1,this.suggestIdx-1),this.renderSuggest();else if(e.key==="Enter"){e.preventDefault();let i=n&&this.suggestIdx>=0?t[this.suggestIdx]:void 0;if(i)this.pickRepo(i);else if(this.canStart())this.startClone()}}pickRepo(e){if(this.repoText=e.name,this.repoValue=e.value,this.showSuggest=!1,this.suggestIdx=-1,this.startErr="",!this.nameTouched)this.nameText="";if(this.repoInput)this.repoInput.value=e.name;this.renderSuggest(),this.askDest()}repoArg(){return this.repoValue||this.repoText.trim()}askRepos(e){if(this.reposTimer!==null)window.clearTimeout(this.reposTimer);this.reposTimer=window.setTimeout(()=>{this.reposTimer=null;let t=++this.reposGen,n=this.repoValue?"":this.repoText.trim();this.host.hub.rpc("clone.repos",{q:n,limit:12},30000).then((i)=>{if(t!==this.reposGen)return;this.repos=i,this.renderSuggest(),this.renderSignin()}).catch(()=>{if(t!==this.reposGen)return;this.repos={repos:[],state:"error",hint:"Couldn't list your GitHub repositories."},this.renderSuggest()})},e)}renderSuggest(){let e=this.suggestEl;if(!e)return;let t=this.repos,n=t?.repos??[],i=[];if(this.showSuggest&&!this.repoValue){if(n.forEach((s,r)=>{let o=_e("","bp-ap-sug"+(r===this.suggestIdx?" active":""));o.setAttribute("data-testid","clone-suggestion"),o.addEventListener("mousedown",(c)=>c.preventDefault()),o.addEventListener("click",()=>this.pickRepo(s));let a=X("div","bp-ap-sug-top");if(a.append(X("span","bp-ap-sug-name",s.name)),s.private)a.append(X("span","bp-ap-tag",m("web.clone.private","private")));if(o.append(a),s.description)o.append(X("div","bp-ap-sug-desc",s.description));i.push(o)}),n.length===0&&t){if(t.loading)i.push(X("div","bp-ap-sug-note",m("web.clone.loading","Loading…")));else if(t.hint){let s=X("div","bp-ap-sug-note");if(s.append(X("span","",he(t.hint))),t.state==="signedout"){let r=_e(m("web.clone.signin","Sign in to GitHub"),"bp-btn-line",()=>{this.startSignin()});r.addEventListener("mousedown",(o)=>o.preventDefault()),r.setAttribute("data-testid","clone-signin-btn"),s.append(r)}i.push(s)}}}e.replaceChildren(...i),e.classList.toggle("bp-hidden",i.length===0)}askDest(e=0){if(this.destTimer!==null)window.clearTimeout(this.destTimer);this.destPending=!0,this.updateCloneBtn(),this.destTimer=window.setTimeout(()=>{this.destTimer=null;let t=++this.destGen,n=this.repoArg();if(!n){this.dest=null,this.destPending=!1,this.renderDest();return}let i={repo:n};if(this.userParent)i.parent=this.userParent;if(this.nameTouched&&this.nameText.trim())i.name=this.nameText.trim();else if(this.userParent)i.name="";this.host.hub.rpc("clone.dest",i).then((s)=>{if(t!==this.destGen)return;if(this.dest=s,this.destPending=!1,!this.nameTouched&&s.folder)this.nameText=s.folder;this.renderDest()}).catch((s)=>{if(t!==this.destGen)return;this.dest={ok:!1,error:s instanceof Error?s.message:String(s)},this.destPending=!1,this.renderDest()})},e)}renderDest(){let e=this.destEl;if(!e)return;let t=this.dest,n=[];if(t&&!t.repo){if(t.error&&this.repoText.trim())n.push(this.errLine(he(t.error)))}else if(t){let o=X("div","bp-ap-where"),a=X("span","bp-ap-dest-path",t.destShown||t.dest||t.defaultParentShown||"");a.setAttribute("data-testid","clone-dest-shown");let c=_e(m("web.clone.change.folder","Change folder"),"bp-btn-line",()=>{this.picking=!0,this.render()});c.setAttribute("data-testid","clone-change-folder"),o.append(a,c),n.push(o);let p=X("label","bp-ap-name");p.append(X("span","bp-ap-lbl",m("web.clone.folder.name","Folder name")));let l=X("input","bp-input");if(l.type="text",l.spellcheck=!1,l.value=this.nameText,l.setAttribute("data-testid","clone-name"),l.addEventListener("input",()=>{this.nameText=l.value,this.nameTouched=l.value.trim()!=="",this.startErr="",this.askDest(250)}),l.addEventListener("keydown",(h)=>{if(h.key==="Enter"&&this.canStart())h.preventDefault(),this.startClone()}),p.append(l),n.push(p),!t.ok&&t.error)n.push(this.errLine(he(t.error)));else if(t.same)n.push(X("div","bp-ap-note bp-dim",m("web.clone.same","Already cloned there: it is added as it is.")))}let i=document.activeElement,s=i&&e.contains(i)&&i.getAttribute("data-testid")==="clone-name",r=s?i.selectionStart:null;if(e.replaceChildren(...n),e.classList.toggle("bp-hidden",n.length===0),s){let o=e.querySelector('[data-testid="clone-name"]');if(o){if(o.focus(),r!==null)o.setSelectionRange(r,r)}}this.updateCloneBtn()}errLine(e){let t=X("div","bp-ap-err",e);return t.setAttribute("data-testid","clone-dest-error"),t}canStart(){return Boolean(this.dest?.ok&&this.dest.repo&&!this.destPending&&!this.starting&&this.repoArg())}updateCloneBtn(){if(this.cloneBtn)this.cloneBtn.disabled=!this.canStart()}renderPickParent(){let e=this.dest?.parent||this.userParent||this.dest?.defaultParent||"",t=_e(m("web.clone.back","Back"),"bp-btn-line",()=>{this.picking=!1,this.render()}),n=new xn(this.host.hub,(i)=>m("web.clone.use.dir","Use {dir}",{dir:i}),async(i)=>{this.userParent=i,this.picking=!1,this.render(),this.askDest()},[t]);this.bodyEl.replaceChildren(n.root),n.go(e)}async startClone(){if(!this.canStart()||!this.dest)return;this.starting=!0,this.startErr="",this.updateCloneBtn();let e={repo:this.repoArg(),thread:this.wantThread,text:this.firstText},t=En();this.jobId=t,this.job=null,this.specs.set(t,e);try{let n=await this.host.hub.rpc("clone.start",{id:t,repo:e.repo,parent:this.dest.parent??"",name:this.dest.folder??this.nameText.trim(),thread:e.thread,text:e.text});this.starting=!1,this.apply(n)}catch(n){this.starting=!1;let i=he(n instanceof Error?n.message:String(n));if(this.jobId===t&&!this.job){let s=await this.host.hub.rpc("clone.status",{id:t}).catch(()=>null);if(s&&s.id===t){this.apply(s);return}}if(this.jobId===t&&!this.job){if(this.jobId="",this.startErr=i,this.mode==="clone")this.render()}}}async retry(e,t){let n=this.specs.get(e.id)??{repo:e.origin||e.repo||"",thread:!0,text:""},i=En(),s=this.jobId;this.jobId=i,this.specs.set(i,n),t.disabled=!0;try{let r=await this.host.hub.rpc("clone.start",{id:i,repo:n.repo,dest:e.dest??"",thread:n.thread,text:n.text});this.apply(r)}catch(r){let o=he(r instanceof Error?r.message:String(r));if(this.jobId!==i)return;if(!this.job||this.job.id!==i){let a=await this.host.hub.rpc("clone.status",{id:i}).catch(()=>null);if(a&&a.id===i){this.apply(a);return}}if(this.jobId===i&&(!this.job||this.job.id!==i))this.jobId=s,t.disabled=!1,this.showJobError(o)}}apply(e){if(!e||e.id!==this.jobId)return;if(!Si(this.job,e))return;if(this.job=e,this.copied=!1,this.isOpen()&&this.mode==="clone")if(this.jobEl&&this.jobEl.isConnected)this.renderJob();else this.render();this.maybeGo(e)}maybeGo(e){if(this.isOpen()&&e.id===this.jobId&&Li(e))this.goTo(e)}renderJobView(){this.jobEl=X("div","bp-ap-job"),this.jobEl.setAttribute("data-testid","clone-job"),this.signinEl=X("div","bp-ap-signin bp-hidden"),this.signinEl.setAttribute("data-testid","clone-signin"),this.bodyEl.replaceChildren(this.jobEl,this.signinEl),this.renderJob(),this.renderSignin()}renderJob(){let e=this.jobEl,t=this.job;if(!e||!t)return;let n=t.destShown||t.dest||"",i=t.repo||"",s=t.state==="done"?m("web.clone.cloned","Cloned {repo} into {dest}",{repo:i,dest:n}):t.state==="cancelled"?m("web.clone.stopped","Stopped cloning {repo}",{repo:i}):m("web.clone.cloning","Cloning {repo} into {dest}",{repo:i,dest:n}),r=[X("div","bp-ap-job-title",s)];if(t.state==="running"){let o=X("div","bp-ap-phase",he(t.phase||""));o.setAttribute("data-testid","clone-phase");let a=X("div","bp-ap-bar"+(typeof t.pct==="number"?"":" indeterminate")),c=X("div","bp-ap-bar-fill");if(typeof t.pct==="number")c.style.width=`${Math.max(0,Math.min(100,t.pct))}%`;if(a.appendChild(c),a.setAttribute("role","progressbar"),typeof t.pct==="number")a.setAttribute("aria-valuenow",String(t.pct));if(r.push(o,a),t.detail)r.push(X("div","bp-ap-detail bp-dim",t.detail));let p=X("div","bp-ap-foot"),l=_e(m("common.cancel","Cancel"),"bp-btn-line",()=>{this.host.hub.rpc("clone.cancel",{id:t.id}).then((h)=>this.apply(h)).catch(()=>{})});l.setAttribute("data-testid","clone-cancel"),p.append(l),r.push(p)}else if(t.state==="failed"||t.state==="cancelled"){if(t.state==="failed"&&t.error){let p=X("div","bp-ap-err",he(t.error));p.setAttribute("data-testid","clone-error"),r.push(p)}let o=X("div","bp-ap-foot"),a=_e(m("web.clone.back","Back"),"bp-btn-line",()=>{this.jobId="",this.job=null,this.signin=null,this.render(),this.askDest()});if(o.append(a),t.signin){let p=_e(m("web.clone.signin","Sign in to GitHub"),"bp-btn-line",()=>{this.startSignin()});p.setAttribute("data-testid","clone-signin-btn"),o.append(p)}let c=_e(m("web.clone.retry","Try again"),"primary",()=>{this.retry(t,c)});c.setAttribute("data-testid","clone-retry"),o.append(c),r.push(o)}else if(t.state==="done"){let o=t.notes??[];if(o.length>0){let l=X("ul","bp-ap-notes");l.setAttribute("data-testid","clone-notes");for(let h of o)l.appendChild(X("li","",he(h)));r.push(l)}let a=X("div","bp-ap-foot"),c=t.thread?m("web.clone.open.thread","Open the thread"):m("web.clone.open.project","Open the project"),p=_e(c,"primary",()=>this.goTo(t));p.setAttribute("data-testid","clone-open"),a.append(p),r.push(a)}e.replaceChildren(...r)}showJobError(e){if(!this.jobEl)return;this.jobEl.querySelector(".bp-ap-job-err")?.remove();let t=X("div","bp-ap-err bp-ap-job-err",e);this.jobEl.appendChild(t)}goTo(e){this.jobId="",this.job=null,this.close(),this.host.onCloneDone(e)}async startSignin(){this.signin={state:"starting"},this.copied=!1,this.renderSignin();try{let e=await this.host.hub.rpc("clone.signin",{restart:!0},30000);if(!this.signin||this.signin.state==="starting")this.signin=e}catch(e){this.signin={state:"failed",error:e instanceof Error?e.message:String(e)}}if(this.signin?.state==="done")this.askRepos(0);this.renderSignin()}renderSignin(){let e=this.signinEl;if(!e)return;let t=this.signin,n=[];if(t&&t.state){if(t.state==="starting"||t.state==="waiting"&&!t.code)n.push(X("div","bp-dim",m("web.clone.signin.wait","Starting GitHub sign-in…")));else if(t.state==="waiting"){n.push(X("div","",m("web.clone.signin.enter","Enter this code on GitHub:")));let i=X("div","bp-ap-code-row"),s=X("span","bp-ap-code",t.code||"");s.setAttribute("data-testid","clone-signin-code");let r=_e(this.copied?m("web.clone.copied","Copied"):m("common.copy","Copy"),"bp-btn-line",()=>{navigator.clipboard?.writeText(t.code||"").then(()=>{this.copied=!0,this.renderSignin()}).catch(()=>{})});if(i.append(s,r),n.push(i),t.url){let o=X("a","bp-ap-link",t.url);o.href=t.url,o.target="_blank",o.rel="noopener noreferrer",o.setAttribute("data-testid","clone-signin-url"),n.push(o)}}else if(t.state==="done")n.push(X("div","bp-ok",m("web.clone.signin.done","Signed in to GitHub")));else if(t.state==="failed")n.push(X("div","bp-ap-err",he(t.error||"")))}e.replaceChildren(...n),e.classList.toggle("bp-hidden",n.length===0)}}function jr(e){try{let t=new URL(e,window.location.origin);if(t.protocol==="https:"||t.protocol==="http:")return t.href}catch{}return null}function $t(e,t){let n=/(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[([^\]]+)\]\(([^)]+)\))/g,i=0,s;while((s=n.exec(t))!==null){if(s.index>i)e.appendChild(document.createTextNode(t.slice(i,s.index)));let r=s[0];if(r.startsWith("`")&&r.endsWith("`")){let o=document.createElement("code");o.className="bp-code-inline",o.textContent=r.slice(1,-1),e.appendChild(o)}else if(r.startsWith("**")&&r.endsWith("**")){let o=document.createElement("strong");o.textContent=r.slice(2,-2),e.appendChild(o)}else if(r.startsWith("*")&&r.endsWith("*")){let o=document.createElement("em");o.textContent=r.slice(1,-1),e.appendChild(o)}else if(r.startsWith("[")){let o=s[2]??"",a=jr(s[3]??"");if(a){let c=document.createElement("a");c.href=a,c.target="_blank",c.rel="noopener noreferrer",c.textContent=o,e.appendChild(c)}else e.appendChild(document.createTextNode(o))}i=n.lastIndex}if(i=(e.ended??0)}function Mi(e){if(e.state!=="done")return!1;if(typeof e.hold==="boolean")return!e.hold;return(e.notes??[]).length===0}var Gt={en:{"agy.signout":"Sign out","android.hub.machines.approve":"Approve","android.load.earlier":"load earlier","approval.dismiss":"Dismiss","approval.implement":"Implement","ask.plan":"Proposed plan","bots.new":"New bot","bots.rooms":"Rooms","bots.tab.browser":"Browser","chats.move":"Move to project…","chats.move.none":"No project to move it to. Add a project first.","chats.new.noproject":"New chat (no project)","chats.title":"Chats","common.cancel":"Cancel","common.close":"Close","common.copy":"Copy","common.delete":"Delete","common.refresh":"Refresh","common.remove":"Remove","common.save":"Save","common.search":"Search","composer.model.tip":"Choose the model and effort","composer.placeholder":"Ask anything: @bot, >thread, %project, #room, $skill, /btw","composer.send":"Send","composer.stop":"Stop","gpui.acct.connected":"Connected","gpui.acct.not.connected":"Not connected","gpui.acct.sign.in.expired":"Sign-in expired","gpui.ask.plan.ready":"Ready for review","gpui.ask.plan.revise":"Revise","gpui.ask.plan.reviseph":"What should change in the plan?","gpui.ask.plan.sendrev":"Send revision","gpui.assembly":"Assembly","gpui.b.in.reply.to":"↩ In reply to: {quote}","gpui.b.replying.to":"↩ Replying to: {line}","gpui.bots.recall.off":"Off","gpui.bots.recall.on":"On","gpui.c.solid.big.next":"Loading it may take a while and a lot of memory.","gpui.c.solid.load.big":"Load it anyway","gpui.c.solid.loading.big":"Loading it anyway…","gpui.c.term.collapse":"Collapse","gpui.c.term.expand":"Expand","gpui.commands":"Commands","gpui.e.open.folder":"Open folder","gpui.filter.projects.and.threads":"Filter projects and threads","gpui.fold.or.unfold.the.sidebar":"Fold or unfold the sidebar","gpui.follow.paused":"Following paused","gpui.follow.wait":"Following: waiting for the agent's next edit","gpui.gerbers":"Gerbers","gpui.goal.notes":"GOAL & NOTES","gpui.improvements":"Improvements","gpui.jump.to.a.thread.run":"Jump to a thread, run a command or find what was said","gpui.mgmt.bom.dnp":"DNP","gpui.mgmt.bom.nompn":"no MPN","gpui.mgmt.checks.all":"All","gpui.mgmt.checks.fix":"Fix with agent","gpui.mgmt.checks.run":"Run","gpui.mgmt.close":"Close the panel","gpui.mgmt.fab.apply":"Apply","gpui.mgmt.fab.changed":"Changed since you last looked","gpui.mgmt.fab.derived":"* worked out from the fab's page (a mil in mm, a ring from a diameter). Dimmed: the rigid board's value, where this board's page says nothing else. A date opens the page it was read from.","gpui.mgmt.fab.extra":"Costs more","gpui.mgmt.fab.findings":"Findings","gpui.mgmt.fab.free":"Base price","gpui.mgmt.fab.judge":"Datasheets","gpui.mgmt.fab.limit":"Limit","gpui.mgmt.fab.readcol":"Read","gpui.mgmt.fab.refresh":"Refresh","gpui.mgmt.fab.reviewbtn":"Review","gpui.mgmt.fab.seen":"Seen","gpui.mgmt.fab.thefab":"The fab","gpui.mgmt.fab.use":"Use","gpui.mgmt.life.nopart":"No reading of this part yet.","gpui.mgmt.life.reading":"Reading its history…","gpui.mgmt.plan.addnote":"Add note","gpui.mgmt.plan.all":"Approve all","gpui.mgmt.plan.before":"Plan before routing","gpui.mgmt.plan.compact":"Compact","gpui.mgmt.plan.done":"done","gpui.mgmt.plan.drawn":"The plan's corridors and planes are drawn on the board while this panel is open. Close it to hide them.","gpui.mgmt.plan.edited":"Edited","gpui.mgmt.plan.elsewhere":"A routing plan for {board} awaits your approval","gpui.mgmt.plan.emptysub":"Layers, corridors, and planes appear here once a plan is proposed.","gpui.mgmt.plan.expand":"Expand","gpui.mgmt.plan.fit":"Fit","gpui.mgmt.plan.grid.all":"All layers","gpui.mgmt.plan.grid.pair":"Side by side","gpui.mgmt.plan.grid.single":"Single","gpui.mgmt.plan.hide":"Hide done","gpui.mgmt.plan.hint":"Drag waypoints to steer · Click + on edge to insert · Right-click vertex to remove","gpui.mgmt.plan.keysnote":"On this KiCad version, approve from this panel: in plan view KiCad's A, R and W keys aren't the plan's yet (A opens Add Footprint). Update KiCad.","gpui.mgmt.plan.layer":"Approve layer","gpui.mgmt.plan.layer.short":"Layer","gpui.mgmt.plan.lock":"Lock","gpui.mgmt.plan.locked":"Locked","gpui.mgmt.plan.noboard":"No routing plan for this board.","gpui.mgmt.plan.noitems":"No corridors or planes on this layer","gpui.mgmt.plan.note.placeholder":"Steering note for router…","gpui.mgmt.plan.nothing":"Nothing awaits your approval","gpui.mgmt.plan.offwords":"Agents route as you ask. Turn it on to have them propose a routing plan first and route only what you approve here.","gpui.mgmt.plan.onwords":"Before routing a board with 4 or more copper layers or more than 60 nets, the agent proposes corridors and plane regions here. It routes only what you approve.","gpui.mgmt.plan.reading":"Reading the routing plan…","gpui.mgmt.plan.reference":"over {layer}","gpui.mgmt.plan.refused":"KiCad refused","gpui.mgmt.plan.reject":"Reject","gpui.mgmt.plan.rejectlayer":"Reject layer","gpui.mgmt.plan.reqplain":"Approval requested","gpui.mgmt.plan.requested":"Approval requested: {what}","gpui.mgmt.plan.saved":"saved plan","gpui.mgmt.plan.show":"Show done","gpui.mgmt.plan.st.approved":"Approved","gpui.mgmt.plan.st.awaiting":"Awaiting review","gpui.mgmt.plan.st.blocked":"Blocked","gpui.mgmt.plan.st.empty":"Empty","gpui.mgmt.plan.st.partial":"Partial","gpui.mgmt.plan.st.rejected":"Rejected","gpui.mgmt.plan.st.routed":"Routed","gpui.mgmt.plan.st.routing":"Routing","gpui.mgmt.plan.st.verified":"Verified","gpui.mgmt.plan.stackup.short":"Stackup","gpui.mgmt.plan.stop":"Stop routing","gpui.mgmt.plan.sync":"Link zoom","gpui.mgmt.plan.tab":"Plan","gpui.mgmt.plan.unlock":"Unlock","gpui.mgmt.plan.verify":"Verify","gpui.mgmt.plan.view.canvas":"Canvas","gpui.mgmt.plan.view.list":"List","gpui.mgmt.plan.view.split":"Split","gpui.mgmt.plan.width":"Width","gpui.next.thread":"Next thread","gpui.no.goal.yet.ask.an":"No goal yet. Ask an agent to write what this project is for, or edit .backplane/intent.md.","gpui.no.models":"No models","gpui.no.threads.yet":"No threads yet.","gpui.nothing.matches":"Nothing matches","gpui.picker.favorite.add":"Add to favorites","gpui.picker.favorite.remove":"Remove from favorites","gpui.picker.favorites":"Favorites","gpui.planmode.bar.always":"Plan mode — explores and proposes a plan before editing","gpui.planmode.bar.executing":"Building the approved plan","gpui.planmode.bar.once":"Plan mode (1 turn) — explores and proposes a plan before editing","gpui.planmode.bar.pending":"Proposed plan awaits review below","gpui.planmode.bar.planning":"Planning — drafting a plan before edits","gpui.planmode.chip.building":"Building","gpui.planmode.chip.once":"Plan · 1t","gpui.planmode.scope.always":"Always","gpui.planmode.scope.once":"1 turn","gpui.planmode.tip":"Plan before acting (1 turn, always, or off)","gpui.planmode.top.executing":"Building plan","gpui.planmode.top.once":"Plan (1 turn)","gpui.planmode.top.pending":"Review plan","gpui.planmode.top.planning":"Planning","gpui.previous.thread":"Previous thread","gpui.projects.boards":"BOARDS ({n})","gpui.projects.mech":"MECHANICAL ({n})","gpui.projects.threads":"THREADS ({n})","gpui.projects.to.order":"TO ORDER ({n})","gpui.rail.no.board":"No board in this project","gpui.rail.no.mech":"No mechanical parts in this project","gpui.rail.no.schematic":"No schematic in this project","gpui.rail.split.needs.both":"Split needs a board and a schematic","gpui.search.models":"Search models","gpui.settings.group.agents":"Agents and tools","gpui.settings.group.general":"General","home.away":"Home ({name}) is away","home.away.queued":"Home ({name}) is away · {n} queued","home.away.since":"Home ({name}) is away since {time}","home.away.since.queued":"Home ({name}) is away since {time} · {n} queued","home.machine":"Home machine","home.move.failed":"Home move failed","home.move.failed.note":"Home move failed: {note}","home.move.here":"Make this machine the home","home.moving":"Moving home to {to}…","home.moving.step":"Moving home to {to}: {step}","hub.back.crash":"Backplane is back after it stopped unexpectedly","hub.restarting":"Restarting Backplane…","hub.restarting.build":"Restarting Backplane… (new build {build})","hub.stopped":"Backplane stopped","ios.hub.address.field":"Hub address","menu.pin":"Pin","menu.settle":"Settle","menu.unpin":"Unpin","menu.wake":"Wake","model.col.agent":"Agent","model.col.effort":"Effort","native.pair.connect":"Connect","native.thread.model":"Model","notify.settled":"Settled","palette.archive":"Archive thread","palette.command.placeholder":"Type a command or a thread","palette.diff":"Diff: what this thread changed","palette.newthread":"New thread","palette.settings":"Settings","palette.terminal":"Terminal","palette.unarchive":"Unarchive thread","phone.unsettle":"Unsettle","provider.notice.button":"Open Settings → Accounts","provider.notice.head":"No AI provider connected","provider.notice.senderr":"No AI provider connected yet. Open Settings → Accounts to connect Claude, Codex, Antigravity, or another provider.","provider.notice.senderr.remote":"No AI provider connected on {machine}. Open Settings → Accounts on {machine} to connect Claude, Codex, Antigravity, or another provider.","provider.notice.text.none":"Connect Claude, Codex, Antigravity, or another provider to start chatting.","provider.notice.text.signedout":"Sign in to Claude, Codex, or another provider in Settings → Accounts to start chatting.","reply.action":"Reply","reply.cancel":"Cancel reply","reply.to":"In reply to:","ring.hear.again.local":"Hear again (local)","ring.hear.again.openai":"Hear again (OpenAI)","ring.no.recordings.yet":"No recordings yet.","ring.recordings":"Recordings","ring.ring":"Ring","ring.search.what.you.said":"Search what you said","ring.show.all":"Show all","ring.what.happened":"What happened","rooms.new":"New room","secret.you":"You","settings.appearance":"Appearance","settings.lang":"Language","settings.lang.auto":"Automatic","settings.lang.en":"English","settings.lang.es":"Español","settings.lang.ja":"日本語","settings.theme":"Theme","settings.theme.dark":"Dark","settings.theme.light":"Light","sheet.rename":"Rename thread","sidebar.add.project":"Add project","sidebar.search.projects":"Search projects","thread.context.base":"Backplane","thread.context.copied":"Prompt copied.","thread.context.copy":"Copy prompt","thread.context.disable":"Disable","thread.context.enable":"Enable","thread.context.index":"Available skills index","thread.context.injected.label":"Injected project instructions","thread.context.instructions":"Instructions","thread.context.mcp":"Project MCPs","thread.context.native.note":"Backplane’s launch prompt. Native files are loaded by the provider.","thread.context.none.instructions":"No project instructions found.","thread.context.none.mcp":"No project MCP configurations found.","thread.context.reading":"Reading thread context…","thread.context.size":"{bytes} B · ≈{tokens} tokens","thread.context.skills":"Skills","thread.context.system":"System Prompt","thread.context.title":"Context & Prompt","thread.context.trust":"Trust and enable","thread.new":"New thread","tools.pinned":"Pinned","tools.retry":"Retry","tour.title.bots":"Bots","viewer.board":"Board","viewer.diff":"Diff","viewer.files":"Files","viewer.mech":"Mech","viewer.review":"Review","viewer.schematic":"Schematic","viewer.solid":"3D","web.chat.answer.btn":"Answer","web.chat.answer.placeholder":"Type answer…","web.chat.answered":"Answered: {answer}","web.chat.choose":"Choose a project thread on the left to begin.","web.chat.empty":"No messages yet. Type below to start a turn.","web.chat.finished":"Finished {time}","web.chat.finished.dur":"Finished {time} · {dur}","web.chat.loading":"Loading messages…","web.chat.review.mode":"Review mode","web.chat.streaming":"Streaming…","web.clone.add.dir":"Add {dir}","web.clone.back":"Back","web.clone.change.folder":"Change folder","web.clone.cloned":"Cloned {repo} into {dest}","web.clone.cloning":"Cloning {repo} into {dest}","web.clone.copied":"Copied","web.clone.first":"First message: {text}","web.clone.folder.name":"Folder name","web.clone.go":"Clone","web.clone.loading":"Loading…","web.clone.no.folders":"No folders here","web.clone.open.project":"Open the project","web.clone.open.thread":"Open the thread","web.clone.private":"private","web.clone.repo.placeholder":"https or ssh URL, or owner/repo","web.clone.retry":"Try again","web.clone.same":"Already cloned there: it is added as it is.","web.clone.signin":"Sign in to GitHub","web.clone.signin.done":"Signed in to GitHub","web.clone.signin.enter":"Enter this code on GitHub:","web.clone.signin.wait":"Starting GitHub sign-in…","web.clone.start.thread":"Start a thread","web.clone.stopped":"Stopped cloning {repo}","web.clone.tab":"Clone from git","web.clone.up":"Up","web.clone.use.dir":"Use {dir}","web.composer.attach":"Attach image","web.composer.maximages":"At most {max} images per message.","web.composer.unsupported":"Unsupported image type: {type}","web.composer.voice":"Voice dictation","web.home.error":"Could not load this project.","web.home.fold":"Hide threads","web.home.lead":"Lead time: {n} days","web.home.lead.one":"Lead time: 1 day","web.home.loading":"Loading project…","web.home.open":"Open project home","web.home.unfold":"Show threads","web.logout.failed":"Could not confirm sign-out. Try again.","web.pair.approve.in":"Approve on desktop or paired phone · expires in {time}","web.pair.approved":"Approved. Opening Backplane…","web.pair.cancelled":"Cancelled.","web.pair.code":"Comparison code","web.pair.denied":"Pairing request was denied.","web.pair.expired":"Pairing code expired. Request a new code to try again.","web.pair.failed":"Pairing request failed ({status})","web.pair.name":"Browser name","web.pair.nocode":"Hub did not return a comparison code.","web.pair.ratelimited":"Too many pairing attempts. Wait a moment and try again.","web.pair.request":"Request pairing","web.pair.requesting":"Requesting pairing code…","web.pair.subtitle":"Pair this browser with your hub. Approve the 6-digit code in Backplane › Settings › Devices.","web.pair.unreachable":"Could not reach the hub. Check your tailnet connection.","web.plan.awaiting":"{n} awaiting approval","web.plan.net.one":"1 net","web.plan.nets":"{n} nets","web.ring.app.words":"The Pebble app's words","web.ring.count":"{n} recordings","web.ring.count.one":"1 recording","web.ring.error":"Could not load recordings.","web.ring.found":"{found} of {total} have “{q}”.","web.ring.heard.by":"Heard by {model}","web.ring.heard.by.sure":"Heard by {model}, {conf}% sure","web.ring.loading":"Loading recordings…","web.ring.no.words":"(no words)","web.ring.not.heard":"Not heard","web.ring.state.busy":"being heard now","web.ring.state.failed":"not given to Pebble","web.ring.state.heard":"waiting to go to Pebble","web.ring.state.new":"waiting to be heard","web.ring.state.sent":"given to Pebble","web.ring.unavailable":"This hub does not show ring notes to a browser yet. Update it, or open Settings › Ring in the desktop app.","web.settings.providers":"AI providers","web.settings.providers.browser":"Connect a provider in the Backplane desktop or mobile app under Settings → Accounts."},es:{"agy.signout":"Cerrar sesión","android.hub.machines.approve":"Aprobar","android.load.earlier":"cargar anteriores","approval.dismiss":"Descartar","approval.implement":"Implementar","ask.plan":"Plan propuesto","bots.new":"Nuevo bot","bots.rooms":"Salas","bots.tab.browser":"Navegador","chats.move":"Mover a un proyecto…","chats.move.none":"No hay ningún proyecto al que moverlo. Añade uno primero.","chats.new.noproject":"Chat nuevo (sin proyecto)","chats.title":"Chats","common.cancel":"Cancelar","common.close":"Cerrar","common.copy":"Copiar","common.delete":"Eliminar","common.refresh":"Actualizar","common.remove":"Quitar","common.save":"Guardar","common.search":"Buscar","composer.model.tip":"Elegir el modelo y el esfuerzo","composer.placeholder":"Pregunta lo que sea: @bot, >hilo, %proyecto, #sala, $skill, /btw","composer.send":"Enviar","composer.stop":"Detener","gpui.acct.connected":"Conectado","gpui.acct.not.connected":"No conectado","gpui.acct.sign.in.expired":"Sesión caducada","gpui.ask.plan.ready":"Listo para revisar","gpui.ask.plan.revise":"Revisar","gpui.ask.plan.reviseph":"¿Qué debería cambiar en el plan?","gpui.ask.plan.sendrev":"Enviar revisión","gpui.assembly":"Ensamblaje","gpui.b.in.reply.to":"↩ En respuesta a: {quote}","gpui.b.replying.to":"↩ Respondiendo a: {line}","gpui.bots.recall.off":"Desactivado","gpui.bots.recall.on":"Activado","gpui.c.solid.big.next":"Cargarlo puede tardar y usar mucha memoria.","gpui.c.solid.load.big":"Cargarlo de todos modos","gpui.c.solid.loading.big":"Cargándolo de todos modos…","gpui.c.term.collapse":"Contraer","gpui.c.term.expand":"Expandir","gpui.commands":"Comandos","gpui.e.open.folder":"Abrir carpeta","gpui.filter.projects.and.threads":"Filtrar proyectos e hilos","gpui.fold.or.unfold.the.sidebar":"Plegar o desplegar la barra lateral","gpui.follow.paused":"Seguimiento en pausa","gpui.follow.wait":"Siguiendo: esperando la próxima edición del agente","gpui.gerbers":"Gerbers","gpui.goal.notes":"OBJETIVO Y NOTAS","gpui.improvements":"Mejoras","gpui.jump.to.a.thread.run":"Saltar a un hilo, ejecutar un comando o buscar lo dicho","gpui.mgmt.bom.dnp":"DNP","gpui.mgmt.bom.nompn":"sin MPN","gpui.mgmt.checks.all":"Todas","gpui.mgmt.checks.fix":"Corregir con agente","gpui.mgmt.checks.run":"Ejecutar","gpui.mgmt.close":"Cerrar el panel","gpui.mgmt.fab.apply":"Aplicar","gpui.mgmt.fab.changed":"Cambió desde la última vez que miraste","gpui.mgmt.fab.derived":"* calculado desde la página del fabricante (un mil en mm, un anillo desde un diámetro). Atenuado: el valor de la placa rígida, cuando la página de esta placa no dice otra cosa. Una fecha abre la página de la que se leyó.","gpui.mgmt.fab.extra":"Cuesta más","gpui.mgmt.fab.findings":"Hallazgos","gpui.mgmt.fab.free":"Precio base","gpui.mgmt.fab.judge":"Hojas de datos","gpui.mgmt.fab.limit":"Límite","gpui.mgmt.fab.readcol":"Leído","gpui.mgmt.fab.refresh":"Actualizar","gpui.mgmt.fab.reviewbtn":"Revisar","gpui.mgmt.fab.seen":"Visto","gpui.mgmt.fab.thefab":"El fabricante","gpui.mgmt.fab.use":"Usar","gpui.mgmt.life.nopart":"Sin lectura de esta pieza aún.","gpui.mgmt.life.reading":"Leyendo su historial…","gpui.mgmt.plan.addnote":"Añadir nota","gpui.mgmt.plan.all":"Aprobar todo","gpui.mgmt.plan.before":"Planificar antes de rutear","gpui.mgmt.plan.compact":"Compacto","gpui.mgmt.plan.done":"hecho","gpui.mgmt.plan.drawn":"Los corredores y planos del plan se dibujan en la placa mientras este panel está abierto. Ciérralo para ocultarlos.","gpui.mgmt.plan.edited":"Editado","gpui.mgmt.plan.elsewhere":"Un plan de ruteo para {board} espera tu aprobación","gpui.mgmt.plan.emptysub":"Las capas, corredores y planos aparecerán aquí cuando se proponga un plan.","gpui.mgmt.plan.expand":"Expandir","gpui.mgmt.plan.fit":"Ajustar","gpui.mgmt.plan.grid.all":"Todas las capas","gpui.mgmt.plan.grid.pair":"Lado a lado","gpui.mgmt.plan.grid.single":"Única","gpui.mgmt.plan.hide":"Ocultar hechos","gpui.mgmt.plan.hint":"Arrastra vértices para guiar · Clic en + del borde para insertar · Clic derecho en vértice para quitar","gpui.mgmt.plan.keysnote":"En esta versión de KiCad, aprueba desde este panel: en la vista de plan las teclas A, R y W de KiCad aún no son del plan (A abre Añadir Huella). Actualiza KiCad.","gpui.mgmt.plan.layer":"Aprobar capa","gpui.mgmt.plan.layer.short":"Capa","gpui.mgmt.plan.lock":"Bloquear","gpui.mgmt.plan.locked":"Bloqueado","gpui.mgmt.plan.noboard":"No hay plan de ruteo para esta placa.","gpui.mgmt.plan.noitems":"Sin corredores ni planos en esta capa","gpui.mgmt.plan.note.placeholder":"Nota de guiado para el router…","gpui.mgmt.plan.nothing":"Nada espera tu aprobación","gpui.mgmt.plan.offwords":"Los agentes rutean como les pidas. Actívalo para que primero propongan un plan de ruteo y ruteen solo lo que apruebes aquí.","gpui.mgmt.plan.onwords":"Antes de rutear una placa con 4 o más capas de cobre o más de 60 redes, el agente propone aquí corredores y regiones de plano. Solo rutea lo que apruebes.","gpui.mgmt.plan.reading":"Leyendo el plan de ruteo…","gpui.mgmt.plan.reference":"sobre {layer}","gpui.mgmt.plan.refused":"KiCad lo rechazó","gpui.mgmt.plan.reject":"Rechazar","gpui.mgmt.plan.rejectlayer":"Rechazar capa","gpui.mgmt.plan.reqplain":"Aprobación solicitada","gpui.mgmt.plan.requested":"Aprobación solicitada: {what}","gpui.mgmt.plan.saved":"plan guardado","gpui.mgmt.plan.show":"Mostrar hechos","gpui.mgmt.plan.st.approved":"Aprobado","gpui.mgmt.plan.st.awaiting":"Esperando revisión","gpui.mgmt.plan.st.blocked":"Bloqueado","gpui.mgmt.plan.st.empty":"Vacío","gpui.mgmt.plan.st.partial":"Parcial","gpui.mgmt.plan.st.rejected":"Rechazado","gpui.mgmt.plan.st.routed":"Ruteado","gpui.mgmt.plan.st.routing":"Ruteando","gpui.mgmt.plan.st.verified":"Verificado","gpui.mgmt.plan.stackup.short":"Apilamiento","gpui.mgmt.plan.stop":"Detener ruteo","gpui.mgmt.plan.sync":"Vincular zoom","gpui.mgmt.plan.tab":"Plan","gpui.mgmt.plan.unlock":"Desbloquear","gpui.mgmt.plan.verify":"Verificar","gpui.mgmt.plan.view.canvas":"Lienzo","gpui.mgmt.plan.view.list":"Lista","gpui.mgmt.plan.view.split":"Dividido","gpui.mgmt.plan.width":"Ancho","gpui.next.thread":"Hilo siguiente","gpui.no.goal.yet.ask.an":"Sin objetivo aún. Pide a un agente que escriba para qué es este proyecto, o edita .backplane/intent.md.","gpui.no.models":"Sin modelos","gpui.no.threads.yet":"Sin hilos aún.","gpui.nothing.matches":"Nada coincide","gpui.picker.favorite.add":"Añadir a favoritos","gpui.picker.favorite.remove":"Quitar de favoritos","gpui.picker.favorites":"Favoritos","gpui.planmode.bar.always":"Modo plan — explora y propone un plan antes de editar","gpui.planmode.bar.executing":"Ejecutando el plan aprobado","gpui.planmode.bar.once":"Modo plan (1 turno) — explora y propone un plan antes de editar","gpui.planmode.bar.pending":"El plan propuesto espera revisión abajo","gpui.planmode.bar.planning":"Planificando — redactando un plan antes de editar","gpui.planmode.chip.building":"Ejecutando","gpui.planmode.chip.once":"Plan · 1t","gpui.planmode.scope.always":"Siempre","gpui.planmode.scope.once":"1 turno","gpui.planmode.tip":"Planificar antes de actuar (1 turno, siempre u off)","gpui.planmode.top.executing":"Ejecutando plan","gpui.planmode.top.once":"Plan (1 turno)","gpui.planmode.top.pending":"Revisar plan","gpui.planmode.top.planning":"Planificando","gpui.previous.thread":"Hilo anterior","gpui.projects.boards":"PLACAS ({n})","gpui.projects.mech":"MECÁNICO ({n})","gpui.projects.threads":"HILOS ({n})","gpui.projects.to.order":"POR PEDIR ({n})","gpui.rail.no.board":"Este proyecto no tiene placa","gpui.rail.no.mech":"Este proyecto no tiene piezas mecánicas","gpui.rail.no.schematic":"Este proyecto no tiene esquema","gpui.rail.split.needs.both":"La vista dividida requiere una placa y un esquema","gpui.search.models":"Buscar modelos","gpui.settings.group.agents":"Agentes y herramientas","gpui.settings.group.general":"General","home.away":"El inicio ({name}) no está disponible","home.away.queued":"El inicio ({name}) no está disponible · {n} en cola","home.away.since":"El inicio ({name}) no está disponible desde las {time}","home.away.since.queued":"El inicio ({name}) no está disponible desde las {time} · {n} en cola","home.machine":"Máquina de inicio","home.move.failed":"No se pudo mover el inicio","home.move.failed.note":"No se pudo mover el inicio: {note}","home.move.here":"Hacer de esta máquina el inicio","home.moving":"Moviendo el inicio a {to}…","home.moving.step":"Moviendo el inicio a {to}: {step}","hub.back.crash":"Backplane volvió tras detenerse de forma inesperada","hub.restarting":"Reiniciando Backplane…","hub.restarting.build":"Reiniciando Backplane… (nueva compilación {build})","hub.stopped":"Backplane se detuvo","ios.hub.address.field":"Dirección del hub","menu.pin":"Fijar","menu.settle":"Cerrar","menu.unpin":"Desfijar","menu.wake":"Despertar","model.col.agent":"Agente","model.col.effort":"Esfuerzo","native.pair.connect":"Conectar","native.thread.model":"Modelo","notify.settled":"Cerrado","palette.archive":"Archivar hilo","palette.command.placeholder":"Escribe un comando o un hilo","palette.diff":"Diff: qué cambió este hilo","palette.newthread":"Nuevo hilo","palette.settings":"Ajustes","palette.terminal":"Terminal","palette.unarchive":"Desarchivar hilo","phone.unsettle":"Reabrir","provider.notice.button":"Abrir Configuración → Cuentas","provider.notice.head":"No hay ningún proveedor de IA conectado","provider.notice.senderr":"Aún no hay ningún proveedor de IA conectado. Abre Configuración → Cuentas para conectar Claude, Codex, Antigravity u otro proveedor.","provider.notice.senderr.remote":"No hay ningún proveedor de IA conectado en {machine}. Abre Configuración → Cuentas en {machine} para conectar Claude, Codex, Antigravity u otro proveedor.","provider.notice.text.none":"Conecta Claude, Codex, Antigravity u otro proveedor para empezar a chatear.","provider.notice.text.signedout":"Inicia sesión en Claude, Codex u otro proveedor en Configuración → Cuentas para empezar a chatear.","reply.action":"Responder","reply.cancel":"Cancelar respuesta","reply.to":"En respuesta a:","ring.hear.again.local":"Escuchar de nuevo (local)","ring.hear.again.openai":"Escuchar de nuevo (OpenAI)","ring.no.recordings.yet":"Sin grabaciones aún.","ring.recordings":"Grabaciones","ring.ring":"Anillo","ring.search.what.you.said":"Buscar lo que dijiste","ring.show.all":"Mostrar todo","ring.what.happened":"Qué ocurrió","rooms.new":"Nueva sala","secret.you":"Tú","settings.appearance":"Apariencia","settings.lang":"Idioma","settings.lang.auto":"Automático","settings.lang.en":"English","settings.lang.es":"Español","settings.lang.ja":"日本語","settings.theme":"Tema","settings.theme.dark":"Oscuro","settings.theme.light":"Claro","sheet.rename":"Renombrar hilo","sidebar.add.project":"Añadir proyecto","sidebar.search.projects":"Buscar proyectos","thread.context.base":"Backplane","thread.context.copied":"Se copiaron las instrucciones.","thread.context.copy":"Copiar instrucciones","thread.context.disable":"Desactivar","thread.context.enable":"Activar","thread.context.index":"Índice de habilidades disponibles","thread.context.injected.label":"Instrucciones del proyecto añadidas","thread.context.instructions":"Instrucciones","thread.context.mcp":"MCP del proyecto","thread.context.native.note":"Instrucciones de inicio de Backplane. El proveedor carga los archivos nativos.","thread.context.none.instructions":"No se encontraron instrucciones del proyecto.","thread.context.none.mcp":"No se encontraron configuraciones MCP del proyecto.","thread.context.reading":"Leyendo el contexto del hilo…","thread.context.size":"{bytes} B · ≈{tokens} tokens","thread.context.skills":"Habilidades","thread.context.system":"Instrucciones del sistema","thread.context.title":"Contexto e instrucciones","thread.context.trust":"Confiar y activar","thread.new":"Nuevo hilo","tools.pinned":"Fijado","tools.retry":"Reintentar","tour.title.bots":"Bots","viewer.board":"Placa","viewer.diff":"Diff","viewer.files":"Archivos","viewer.mech":"Mech","viewer.review":"Revisión","viewer.schematic":"Esquemático","viewer.solid":"3D","web.chat.answer.btn":"Responder","web.chat.answer.placeholder":"Escribe una respuesta…","web.chat.answered":"Respondido: {answer}","web.chat.choose":"Elige un hilo de proyecto a la izquierda para empezar.","web.chat.empty":"Aún no hay mensajes. Escribe abajo para iniciar un turno.","web.chat.finished":"Terminado {time}","web.chat.finished.dur":"Terminado {time} · {dur}","web.chat.loading":"Cargando mensajes…","web.chat.review.mode":"Modo de revisión","web.chat.streaming":"Transmitiendo…","web.clone.add.dir":"Añadir {dir}","web.clone.back":"Atrás","web.clone.change.folder":"Cambiar carpeta","web.clone.cloned":"{repo} clonado en {dest}","web.clone.cloning":"Clonando {repo} en {dest}","web.clone.copied":"Copiado","web.clone.first":"Primer mensaje: {text}","web.clone.folder.name":"Nombre de la carpeta","web.clone.go":"Clonar","web.clone.loading":"Cargando…","web.clone.no.folders":"No hay carpetas aquí","web.clone.open.project":"Abrir el proyecto","web.clone.open.thread":"Abrir el hilo","web.clone.private":"privado","web.clone.repo.placeholder":"URL https o ssh, o propietario/repositorio","web.clone.retry":"Reintentar","web.clone.same":"Ya está clonado ahí: se añade tal cual.","web.clone.signin":"Iniciar sesión en GitHub","web.clone.signin.done":"Sesión iniciada en GitHub","web.clone.signin.enter":"Introduce este código en GitHub:","web.clone.signin.wait":"Iniciando sesión en GitHub…","web.clone.start.thread":"Empezar un hilo","web.clone.stopped":"Se detuvo la clonación de {repo}","web.clone.tab":"Clonar desde git","web.clone.up":"Subir","web.clone.use.dir":"Usar {dir}","web.composer.attach":"Adjuntar imagen","web.composer.maximages":"Como máximo {max} imágenes por mensaje.","web.composer.unsupported":"Tipo de imagen no compatible: {type}","web.composer.voice":"Dictado por voz","web.home.error":"No se pudo cargar este proyecto.","web.home.fold":"Ocultar hilos","web.home.lead":"Plazo de entrega: {n} días","web.home.lead.one":"Plazo de entrega: 1 día","web.home.loading":"Cargando el proyecto…","web.home.open":"Abrir la página del proyecto","web.home.unfold":"Mostrar hilos","web.logout.failed":"No se pudo confirmar el cierre de sesión. Inténtalo de nuevo.","web.pair.approve.in":"Aprueba en el escritorio o en un teléfono vinculado · caduca en {time}","web.pair.approved":"Aprobado. Abriendo Backplane…","web.pair.cancelled":"Cancelado.","web.pair.code":"Código de comparación","web.pair.denied":"Se rechazó la solicitud de vinculación.","web.pair.expired":"El código de vinculación caducó. Solicita uno nuevo para intentarlo otra vez.","web.pair.failed":"Falló la solicitud de vinculación ({status})","web.pair.name":"Nombre del navegador","web.pair.nocode":"El hub no devolvió un código de comparación.","web.pair.ratelimited":"Demasiados intentos de vinculación. Espera un momento e inténtalo de nuevo.","web.pair.request":"Solicitar vinculación","web.pair.requesting":"Solicitando código de vinculación…","web.pair.subtitle":"Vincula este navegador con tu hub. Aprueba el código de 6 dígitos en Backplane › Ajustes › Dispositivos.","web.pair.unreachable":"No se pudo conectar con el hub. Comprueba tu conexión de tailnet.","web.plan.awaiting":"{n} esperando aprobación","web.plan.net.one":"1 red","web.plan.nets":"{n} redes","web.ring.app.words":"Las palabras de la aplicación Pebble","web.ring.count":"{n} grabaciones","web.ring.count.one":"1 grabación","web.ring.error":"No se pudieron cargar las grabaciones.","web.ring.found":"{found} de {total} contienen “{q}”.","web.ring.heard.by":"Transcrito por {model}","web.ring.heard.by.sure":"Transcrito por {model}, {conf}% de certeza","web.ring.loading":"Cargando grabaciones…","web.ring.no.words":"(sin palabras)","web.ring.not.heard":"Sin transcribir","web.ring.state.busy":"transcribiéndose ahora","web.ring.state.failed":"no entregada a Pebble","web.ring.state.heard":"en espera de entrega a Pebble","web.ring.state.new":"en espera de transcripción","web.ring.state.sent":"entregada a Pebble","web.ring.unavailable":"Este hub aún no muestra las notas del anillo en un navegador. Actualízalo o abre Configuración › Anillo en la aplicación de escritorio.","web.settings.providers":"Proveedores de IA","web.settings.providers.browser":"Conecta un proveedor en la aplicación de escritorio o móvil de Backplane en Configuración → Cuentas."},ja:{"agy.signout":"サインアウト","android.hub.machines.approve":"承認","android.load.earlier":"以前のメッセージを読み込む","approval.dismiss":"閉じる","approval.implement":"実装","ask.plan":"提案されたプラン","bots.new":"新しいボット","bots.rooms":"ルーム","bots.tab.browser":"ブラウザ","chats.move":"プロジェクトに移動…","chats.move.none":"移動先のプロジェクトがありません。先にプロジェクトを追加してください。","chats.new.noproject":"新しいチャット(プロジェクトなし)","chats.title":"チャット","common.cancel":"キャンセル","common.close":"閉じる","common.copy":"コピー","common.delete":"削除","common.refresh":"更新","common.remove":"削除","common.save":"保存","common.search":"検索","composer.model.tip":"モデルと推論の強さを選択","composer.placeholder":"何でも質問:@bot、>thread、%project、#room、$skill、/btw","composer.send":"送信","composer.stop":"停止","gpui.acct.connected":"接続済み","gpui.acct.not.connected":"未接続","gpui.acct.sign.in.expired":"サインインの期限切れ","gpui.ask.plan.ready":"確認待ち","gpui.ask.plan.revise":"修正","gpui.ask.plan.reviseph":"計画のどこを変更しますか?","gpui.ask.plan.sendrev":"修正を送る","gpui.assembly":"アセンブリ","gpui.b.in.reply.to":"↩ 返信先:{quote}","gpui.b.replying.to":"↩ 返信中:{line}","gpui.bots.recall.off":"オフ","gpui.bots.recall.on":"オン","gpui.c.solid.big.next":"読み込みには時間と多くのメモリがかかることがあります。","gpui.c.solid.load.big":"それでも読み込む","gpui.c.solid.loading.big":"それでも読み込み中…","gpui.c.term.collapse":"折りたたむ","gpui.c.term.expand":"展開","gpui.commands":"コマンド","gpui.e.open.folder":"フォルダを開く","gpui.filter.projects.and.threads":"プロジェクトとスレッドを絞り込む","gpui.fold.or.unfold.the.sidebar":"サイドバーを折りたたむ/開く","gpui.follow.paused":"追従を一時停止中","gpui.follow.wait":"追従中: エージェントの次の編集を待っています","gpui.gerbers":"ガーバー","gpui.goal.notes":"目標とメモ","gpui.improvements":"改善","gpui.jump.to.a.thread.run":"スレッドへ移動、コマンドを実行、または発言を検索","gpui.mgmt.bom.dnp":"実装しない","gpui.mgmt.bom.nompn":"MPNなし","gpui.mgmt.checks.all":"すべて","gpui.mgmt.checks.fix":"エージェントに直してもらう","gpui.mgmt.checks.run":"実行","gpui.mgmt.close":"パネルを閉じる","gpui.mgmt.fab.apply":"適用","gpui.mgmt.fab.changed":"前回見てから変わったところ","gpui.mgmt.fab.derived":"* 製造元のページから計算した値です(milをmmに、径からランドを)。薄い色の項目はリジッド基板の値です(この基板のページに記載がないもの)。日付を押すと読んだページが開きます。","gpui.mgmt.fab.extra":"追加料金","gpui.mgmt.fab.findings":"指摘","gpui.mgmt.fab.free":"基本料金","gpui.mgmt.fab.judge":"データシート","gpui.mgmt.fab.limit":"項目","gpui.mgmt.fab.readcol":"読んだ日","gpui.mgmt.fab.refresh":"再読み込み","gpui.mgmt.fab.reviewbtn":"レビュー","gpui.mgmt.fab.seen":"確認済み","gpui.mgmt.fab.thefab":"製造元","gpui.mgmt.fab.use":"使う","gpui.mgmt.life.nopart":"この部品の記録はまだありません。","gpui.mgmt.life.reading":"履歴を読んでいます…","gpui.mgmt.plan.addnote":"メモを追加","gpui.mgmt.plan.all":"すべて承認","gpui.mgmt.plan.before":"配線前に計画する","gpui.mgmt.plan.compact":"標準","gpui.mgmt.plan.done":"完了","gpui.mgmt.plan.drawn":"計画の配線経路とプレーンは、このパネルを開いている間だけ基板上に表示されます。閉じると消えます。","gpui.mgmt.plan.edited":"編集済み","gpui.mgmt.plan.elsewhere":"{board}の配線計画が承認を待っています","gpui.mgmt.plan.emptysub":"計画が提案されると、レイヤー・コリドー・ベタ領域がここに表示されます。","gpui.mgmt.plan.expand":"拡大","gpui.mgmt.plan.fit":"全体表示","gpui.mgmt.plan.grid.all":"全レイヤー","gpui.mgmt.plan.grid.pair":"並べて表示","gpui.mgmt.plan.grid.single":"単一","gpui.mgmt.plan.hide":"完了を隠す","gpui.mgmt.plan.hint":"頂点をドラッグして誘導 · 辺の + をクリックで追加 · 頂点を右クリックで削除","gpui.mgmt.plan.keysnote":"このバージョンのKiCadでは、このパネルから承認してください。プランビューでのKiCadのA・R・Wキーはまだ計画のものではありません(Aはフットプリントの追加を開きます)。KiCadを更新してください。","gpui.mgmt.plan.layer":"層を承認","gpui.mgmt.plan.layer.short":"レイヤー","gpui.mgmt.plan.lock":"ロック","gpui.mgmt.plan.locked":"ロック中","gpui.mgmt.plan.noboard":"この基板の配線計画はありません。","gpui.mgmt.plan.noitems":"このレイヤーにコリドーまたはプレーンがありません","gpui.mgmt.plan.note.placeholder":"ルーターへの指示メモ…","gpui.mgmt.plan.nothing":"承認待ちはありません","gpui.mgmt.plan.offwords":"エージェントは指示どおりに配線します。オンにすると、まず配線計画を提案し、ここで承認したものだけを配線します。","gpui.mgmt.plan.onwords":"銅箔層が4層以上、またはネットが60本を超える基板では、配線の前にエージェントがここで配線経路とプレーン領域を提案します。承認したものだけを配線します。","gpui.mgmt.plan.reading":"配線計画を読んでいます…","gpui.mgmt.plan.reference":"基準 {layer}","gpui.mgmt.plan.refused":"KiCad が拒否しました","gpui.mgmt.plan.reject":"却下","gpui.mgmt.plan.rejectlayer":"レイヤーを却下","gpui.mgmt.plan.reqplain":"承認が求められています","gpui.mgmt.plan.requested":"承認が求められています: {what}","gpui.mgmt.plan.saved":"保存された計画","gpui.mgmt.plan.show":"完了を表示","gpui.mgmt.plan.st.approved":"承認済み","gpui.mgmt.plan.st.awaiting":"承認待ち","gpui.mgmt.plan.st.blocked":"ブロック","gpui.mgmt.plan.st.empty":"空","gpui.mgmt.plan.st.partial":"一部完了","gpui.mgmt.plan.st.rejected":"却下","gpui.mgmt.plan.st.routed":"配線済み","gpui.mgmt.plan.st.routing":"配線中","gpui.mgmt.plan.st.verified":"検証済み","gpui.mgmt.plan.stackup.short":"スタックアップ","gpui.mgmt.plan.stop":"配線を止める","gpui.mgmt.plan.sync":"ズーム連動","gpui.mgmt.plan.tab":"計画","gpui.mgmt.plan.unlock":"ロック解除","gpui.mgmt.plan.verify":"検証","gpui.mgmt.plan.view.canvas":"キャンバス","gpui.mgmt.plan.view.list":"リスト","gpui.mgmt.plan.view.split":"分割","gpui.mgmt.plan.width":"幅","gpui.next.thread":"次のスレッド","gpui.no.goal.yet.ask.an":"目標はまだありません。このプロジェクトの目的をエージェントに書いてもらうか、.backplane/intent.md を編集してください。","gpui.no.models":"モデルがありません","gpui.no.threads.yet":"スレッドはまだありません。","gpui.nothing.matches":"一致するものはありません","gpui.picker.favorite.add":"お気に入りに追加","gpui.picker.favorite.remove":"お気に入りから外す","gpui.picker.favorites":"お気に入り","gpui.planmode.bar.always":"計画モード — 編集前に調査して計画を提案します","gpui.planmode.bar.executing":"承認された計画を実行しています","gpui.planmode.bar.once":"計画モード (1回) — 編集前に調査して計画を提案します","gpui.planmode.bar.pending":"提案された計画が下のレビューを待っています","gpui.planmode.bar.planning":"計画中 — 編集前の計画を作成しています","gpui.planmode.chip.building":"実行中","gpui.planmode.chip.once":"計画 · 1回","gpui.planmode.scope.always":"常時","gpui.planmode.scope.once":"1回","gpui.planmode.tip":"実行前に計画を作成 (1回・常時・オフ)","gpui.planmode.top.executing":"計画を実行中","gpui.planmode.top.once":"計画 (1回)","gpui.planmode.top.pending":"計画を確認","gpui.planmode.top.planning":"計画中","gpui.previous.thread":"前のスレッド","gpui.projects.boards":"基板({n})","gpui.projects.mech":"機構部品({n})","gpui.projects.threads":"スレッド({n})","gpui.projects.to.order":"注文するもの({n})","gpui.rail.no.board":"このプロジェクトには基板がありません","gpui.rail.no.mech":"このプロジェクトには機械部品がありません","gpui.rail.no.schematic":"このプロジェクトには回路図がありません","gpui.rail.split.needs.both":"分割表示には基板と回路図が必要です","gpui.search.models":"モデルを検索","gpui.settings.group.agents":"エージェントとツール","gpui.settings.group.general":"一般","home.away":"ホーム({name})はオフラインです","home.away.queued":"ホーム({name})はオフラインです · {n} 件待機中","home.away.since":"ホーム({name})は {time} からオフラインです","home.away.since.queued":"ホーム({name})は {time} からオフラインです · {n} 件待機中","home.machine":"ホームマシン","home.move.failed":"ホームの移動に失敗しました","home.move.failed.note":"ホームの移動に失敗しました: {note}","home.move.here":"このマシンをホームにする","home.moving":"ホームを {to} へ移動中…","home.moving.step":"ホームを {to} へ移動中: {step}","hub.back.crash":"予期せず停止したBackplaneが戻りました","hub.restarting":"Backplaneを再起動しています…","hub.restarting.build":"Backplaneを再起動しています…(新しいビルド {build})","hub.stopped":"Backplaneは停止しました","ios.hub.address.field":"ハブのアドレス","menu.pin":"ピン留め","menu.settle":"完了","menu.unpin":"ピン留めを解除","menu.wake":"再開","model.col.agent":"エージェント","model.col.effort":"推論の強さ","native.pair.connect":"接続","native.thread.model":"モデル","notify.settled":"完了","palette.archive":"スレッドをアーカイブ","palette.command.placeholder":"コマンドまたはスレッドを入力","palette.diff":"差分:このスレッドの変更","palette.newthread":"新しいスレッド","palette.settings":"設定","palette.terminal":"ターミナル","palette.unarchive":"スレッドのアーカイブを解除","phone.unsettle":"未完了に戻す","provider.notice.button":"設定 → アカウントを開く","provider.notice.head":"AI プロバイダーが接続されていません","provider.notice.senderr":"AI プロバイダーがまだ接続されていません。設定 → アカウントを開いて、Claude、Codex、Antigravity などのプロバイダーを接続してください。","provider.notice.senderr.remote":"{machine} に AI プロバイダーが接続されていません。{machine} で設定 → アカウントを開いて、Claude、Codex、Antigravity などのプロバイダーを接続してください。","provider.notice.text.none":"チャットを始めるには、Claude、Codex、Antigravity などのプロバイダーを接続してください。","provider.notice.text.signedout":"チャットを始めるには、設定 → アカウントで Claude、Codex などのプロバイダーにサインインしてください。","reply.action":"返信","reply.cancel":"返信をやめる","reply.to":"返信先:","ring.hear.again.local":"もう一度聞き取る (ローカル)","ring.hear.again.openai":"もう一度聞き取る (OpenAI)","ring.no.recordings.yet":"録音はまだありません。","ring.recordings":"録音","ring.ring":"リング","ring.search.what.you.said":"話した内容を検索","ring.show.all":"すべて表示","ring.what.happened":"どうなったか","rooms.new":"新しいルーム","secret.you":"あなた","settings.appearance":"外観","settings.lang":"言語","settings.lang.auto":"自動","settings.lang.en":"English","settings.lang.es":"Español","settings.lang.ja":"日本語","settings.theme":"テーマ","settings.theme.dark":"ダーク","settings.theme.light":"ライト","sheet.rename":"スレッド名を変更","sidebar.add.project":"プロジェクトを追加","sidebar.search.projects":"プロジェクトを検索","thread.context.base":"Backplane","thread.context.copied":"プロンプトをコピーしました。","thread.context.copy":"プロンプトをコピー","thread.context.disable":"無効にする","thread.context.enable":"有効にする","thread.context.index":"利用可能なスキルの一覧","thread.context.injected.label":"追加されたプロジェクトの指示","thread.context.instructions":"指示","thread.context.mcp":"プロジェクトの MCP","thread.context.native.note":"Backplane が起動時に渡すプロンプトです。ネイティブファイルはプロバイダーが読み込みます。","thread.context.none.instructions":"プロジェクトの指示が見つかりません。","thread.context.none.mcp":"プロジェクトの MCP 設定が見つかりません。","thread.context.reading":"スレッドのコンテキストを読み込み中…","thread.context.size":"{bytes} B・約{tokens}トークン","thread.context.skills":"スキル","thread.context.system":"システムプロンプト","thread.context.title":"コンテキストとプロンプト","thread.context.trust":"承認して有効にする","thread.new":"新しいスレッド","tools.pinned":"固定中","tools.retry":"再試行","tour.title.bots":"ボット","viewer.board":"基板","viewer.diff":"差分","viewer.files":"ファイル","viewer.mech":"Mech","viewer.review":"レビュー","viewer.schematic":"回路図","viewer.solid":"3D","web.chat.answer.btn":"回答","web.chat.answer.placeholder":"回答を入力…","web.chat.answered":"回答済み: {answer}","web.chat.choose":"左側からプロジェクトのスレッドを選んで開始してください。","web.chat.empty":"まだメッセージはありません。下に入力して開始してください。","web.chat.finished":"完了 {time}","web.chat.finished.dur":"完了 {time} · {dur}","web.chat.loading":"メッセージを読み込んでいます…","web.chat.review.mode":"レビューモード","web.chat.streaming":"受信中…","web.clone.add.dir":"{dir} を追加","web.clone.back":"戻る","web.clone.change.folder":"フォルダを変更","web.clone.cloned":"{repo} を {dest} にクローンしました","web.clone.cloning":"{repo} を {dest} にクローン中","web.clone.copied":"コピーしました","web.clone.first":"最初のメッセージ: {text}","web.clone.folder.name":"フォルダ名","web.clone.go":"クローン","web.clone.loading":"読み込み中…","web.clone.no.folders":"フォルダがありません","web.clone.open.project":"プロジェクトを開く","web.clone.open.thread":"スレッドを開く","web.clone.private":"非公開","web.clone.repo.placeholder":"https / ssh の URL、または owner/repo","web.clone.retry":"もう一度","web.clone.same":"すでにそこにクローンされています: そのまま追加します。","web.clone.signin":"GitHub にサインイン","web.clone.signin.done":"GitHub にサインインしました","web.clone.signin.enter":"このコードを GitHub に入力してください:","web.clone.signin.wait":"GitHub のサインインを開始しています…","web.clone.start.thread":"スレッドを開始","web.clone.stopped":"{repo} のクローンを中止しました","web.clone.tab":"git からクローン","web.clone.up":"上へ","web.clone.use.dir":"{dir} を使う","web.composer.attach":"画像を添付","web.composer.maximages":"1 件のメッセージに添付できる画像は最大 {max} 枚です。","web.composer.unsupported":"未対応の画像形式です: {type}","web.composer.voice":"音声入力","web.home.error":"このプロジェクトを読み込めませんでした。","web.home.fold":"スレッドを隠す","web.home.lead":"リードタイム: {n} 日","web.home.lead.one":"リードタイム: 1 日","web.home.loading":"プロジェクトを読み込み中…","web.home.open":"プロジェクトホームを開く","web.home.unfold":"スレッドを表示","web.logout.failed":"サインアウトを確認できませんでした。もう一度お試しください。","web.pair.approve.in":"デスクトップまたはペアリング済みの端末で承認してください · 有効期限 {time}","web.pair.approved":"承認されました。Backplane を開いています…","web.pair.cancelled":"キャンセルしました。","web.pair.code":"確認コード","web.pair.denied":"ペアリングのリクエストが拒否されました。","web.pair.expired":"ペアリングコードの有効期限が切れました。新しいコードをリクエストしてください。","web.pair.failed":"ペアリングのリクエストに失敗しました ({status})","web.pair.name":"ブラウザー名","web.pair.nocode":"ハブから確認コードが返されませんでした。","web.pair.ratelimited":"ペアリングの試行回数が多すぎます。しばらく待ってからやり直してください。","web.pair.request":"ペアリングをリクエスト","web.pair.requesting":"ペアリングコードをリクエストしています…","web.pair.subtitle":"このブラウザーをハブとペアリングします。Backplane › 設定 › デバイス で 6 桁のコードを承認してください。","web.pair.unreachable":"ハブに接続できませんでした。tailnet の接続を確認してください。","web.plan.awaiting":"{n} 件が承認待ち","web.plan.net.one":"1 ネット","web.plan.nets":"{n} ネット","web.ring.app.words":"Pebble アプリの文字起こし","web.ring.count":"録音 {n} 件","web.ring.count.one":"録音 1 件","web.ring.error":"録音を読み込めませんでした。","web.ring.found":"{total} 件中 {found} 件に「{q}」があります。","web.ring.heard.by":"{model} が認識","web.ring.heard.by.sure":"{model} が認識、確度 {conf}%","web.ring.loading":"録音を読み込み中…","web.ring.no.words":"(言葉なし)","web.ring.not.heard":"未認識","web.ring.state.busy":"認識中","web.ring.state.failed":"Pebble に渡せませんでした","web.ring.state.heard":"Pebble への受け渡し待ち","web.ring.state.new":"認識待ち","web.ring.state.sent":"Pebble に渡しました","web.ring.unavailable":"このハブはまだブラウザーにリングのメモを表示しません。ハブを更新するか、デスクトップアプリの設定 › リングを開いてください。","web.settings.providers":"AI プロバイダー","web.settings.providers.browser":"Backplane のデスクトップまたはモバイルアプリの設定 → アカウントからプロバイダーを接続してください。"}};function Ti(e,t){if(!t)return e;return e.replace(/\{([a-zA-Z0-9_.-]+)\}/g,(n,i)=>Object.prototype.hasOwnProperty.call(t,i)?String(t[i]):n)}var Pt=Fr(),kn=new Set,xn=new Map;for(let[e,t]of Object.entries(Gt.en||{}))if(typeof t==="string"&&!xn.has(t))xn.set(t,e);function Fr(){let e=typeof navigator<"u"&&navigator.language?navigator.language.toLowerCase():"en";if(e.startsWith("ja"))return"ja";if(e.startsWith("es"))return"es";return"en"}function Ii(){if(typeof document<"u"&&document.documentElement)document.documentElement.lang=Pt}Ii();function on(e){return kn.add(e),()=>{kn.delete(e)}}function St(e){if(!e)return!1;let t=e.toLowerCase(),n=t.startsWith("ja")?"ja":t.startsWith("es")?"es":t.startsWith("en")?"en":"";if(!n)return!1;let i=n!==Pt;if(Pt=n,Ii(),i)for(let s of kn)s(Pt);return i}function Bi(){return Pt}function m(e,t,n){let s=(Gt[Pt]||Gt.en||{})[e]??Gt.en?.[e]??t??e;return Ti(s,n)}function fe(e){if(!e)return"";let t=xn.get(e);if(!t)return e;return m(t,e)}function Y(e,t="",n=""){let i=document.createElement(e);if(t)i.className=t;if(n)i.textContent=n;return i}function We(e,t="",n){let i=Y("button",t,e);if(i.type="button",n)i.addEventListener("click",n);return i}function $r(e){let t=e.replace(/[\\/]+$/,"");if(!t)return e||"/";let n=t.split(/[\\/]/);return n[n.length-1]||t}function Or(e,t){let n=e.includes("\\")&&!e.includes("/")?"\\":"/";return e.endsWith(n)?e+t:e+n+t}class Pn{hub;actionLabel;action;root;pathInput;upBtn;listEl;errEl;actBtn;path="";parent=null;gen=0;busy=!1;constructor(e,t,n,i=[]){this.hub=e;this.actionLabel=t;this.action=n;this.root=Y("div","bp-fb"),this.root.setAttribute("data-testid","folder-browser");let s=Y("div","bp-fb-head");this.upBtn=We("↑","bp-btn-ghost bp-fb-up",()=>{if(this.parent)this.go(this.parent)}),this.upBtn.title=m("web.clone.up","Up"),this.upBtn.setAttribute("aria-label",m("web.clone.up","Up")),this.pathInput=Y("input","bp-input bp-fb-path"),this.pathInput.spellcheck=!1,this.pathInput.setAttribute("data-testid","folder-path"),this.pathInput.addEventListener("keydown",(o)=>{if(o.key==="Enter"){o.preventDefault();let a=this.pathInput.value.trim();if(a)this.go(a)}}),s.append(this.upBtn,this.pathInput),this.listEl=Y("div","bp-fb-list"),this.errEl=Y("div","bp-ap-err bp-hidden");let r=Y("div","bp-ap-foot");this.actBtn=We("","primary",()=>{this.run()}),this.actBtn.setAttribute("data-testid","folder-act"),r.append(...i,this.actBtn),this.root.append(s,this.listEl,this.errEl,r)}currentPath(){return this.path}async go(e){let t=++this.gen;this.setError(""),this.listEl.replaceChildren(Y("div","bp-fb-empty",m("web.clone.loading","Loading…")));try{let n=await this.hub.rpc("dirs.list",{path:e});if(t!==this.gen)return;this.path=n.path,this.parent=n.parent??null,this.render(n.dirs??[])}catch(n){if(t!==this.gen)return;this.setError(fe(n instanceof Error?n.message:String(n))),this.render(null)}}refreshLocale(){this.upBtn.title=m("web.clone.up","Up"),this.updateAct()}render(e){if(this.pathInput.value=this.path,this.upBtn.disabled=!this.parent,this.updateAct(),e===null){this.listEl.replaceChildren();return}if(e.length===0){this.listEl.replaceChildren(Y("div","bp-fb-empty",m("web.clone.no.folders","No folders here")));return}let t=document.createDocumentFragment();for(let n of e){let i=We("","bp-fb-row",()=>{this.go(Or(this.path,n))});i.append(Y("span","bp-fb-icon","▸"),Y("span","bp-fb-name",n)),t.appendChild(i)}this.listEl.replaceChildren(t),this.listEl.scrollTop=0}updateAct(){this.actBtn.textContent=this.path?this.actionLabel($r(this.path)):this.actionLabel("…"),this.actBtn.disabled=!this.path||this.busy}async run(){if(!this.path||this.busy)return;this.busy=!0,this.updateAct(),this.setError("");try{await this.action(this.path)}catch(e){this.setError(fe(e instanceof Error?e.message:String(e)))}finally{this.busy=!1,this.updateAct()}}setError(e){this.errEl.textContent=e,this.errEl.classList.toggle("bp-hidden",!e)}}class Sn{container;host;backdrop=null;bodyEl=null;tabsEl=null;mode="folder";repoText="";repoValue="";firstText="";wantThread=!0;userParent="";nameText="";nameTouched=!1;dest=null;destGen=0;destPending=!1;destTimer=null;repos=null;reposGen=0;reposTimer=null;showSuggest=!1;suggestIdx=-1;startErr="";starting=!1;picking=!1;jobId="";job=null;specs=new Map;signin=null;copied=!1;repoInput=null;suggestEl=null;destEl=null;signinEl=null;cloneBtn=null;jobEl=null;constructor(e,t){this.container=e;this.host=t}isOpen(){return this.backdrop!==null}open(e={}){let t=this.host.hub.hasFeature("clone"),n=!e.repo&&Boolean(this.jobId)&&(!this.job||this.job.state==="running"||this.job.state==="done");if(!this.backdrop)this.build();if(!n)this.jobId="",this.job=null,this.resetForm();if(e.repo!==void 0||e.text!==void 0)this.repoText=(e.repo??"").trim(),this.repoValue="",this.firstText=(e.text??"").trim();if(this.mode=t&&(e.mode==="clone"||n)?"clone":"folder",this.render(),n){if(this.job)this.maybeGo(this.job);this.reconcile()}else if(this.mode==="clone"&&this.repoText)this.askDest()}reconcile(){let e=this.jobId;if(!e)return;this.host.hub.rpc("clone.status",{id:e}).then((t)=>this.apply(t)).catch(()=>{})}close(){if(this.reposTimer!==null)window.clearTimeout(this.reposTimer);if(this.destTimer!==null)window.clearTimeout(this.destTimer);this.reposTimer=null,this.destTimer=null,this.backdrop?.remove(),this.backdrop=null,this.bodyEl=null,this.tabsEl=null}escape(){if(this.picking){this.picking=!1,this.render();return}if(this.showSuggest){this.showSuggest=!1,this.renderSuggest();return}this.close()}refreshLocale(){if(this.backdrop)this.render()}handleFrame(e){if(e.k==="clone"){let t=e.clone;if(t)this.apply(t)}else if(e.k==="clone.repos"){if(this.isOpen()&&this.mode==="clone"&&!this.jobId)this.askRepos(0)}else if(e.k==="clone.signin"){if(!this.signin)return;let t=this.signin.state;if(this.signin=e.signin??null,this.signin?.state==="cancelled")this.signin=null;if(t!=="done"&&this.signin?.state==="done")this.askRepos(0);this.renderSignin()}}build(){let e=Y("div","bp-modal-backdrop");e.setAttribute("data-testid","add-project");let t=Y("div","bp-modal bp-ap"),n=Y("div","bp-modal-head"),i=Y("h2","",m("sidebar.add.project","Add project")),s=We("×","icon",()=>this.close());s.title=m("common.close","Close"),s.setAttribute("aria-label",m("common.close","Close")),n.append(i,s),this.tabsEl=Y("div","bp-ap-tabs"),this.bodyEl=Y("div","bp-modal-body bp-ap-body"),t.append(n,this.tabsEl,this.bodyEl),e.appendChild(t),e.addEventListener("mousedown",(r)=>{if(r.target===e)this.close()}),this.container.appendChild(e),this.backdrop=e}resetForm(){this.repoText="",this.repoValue="",this.firstText="",this.wantThread=!0,this.userParent="",this.nameText="",this.nameTouched=!1,this.dest=null,this.destPending=!1,this.repos=null,this.showSuggest=!1,this.suggestIdx=-1,this.startErr="",this.starting=!1,this.picking=!1,this.signin=null,this.copied=!1}render(){if(!this.bodyEl||!this.tabsEl||!this.backdrop)return;let e=this.backdrop.querySelector(".bp-modal-head h2");if(e)e.textContent=m("sidebar.add.project","Add project");if(this.renderTabs(),this.repoInput=null,this.suggestEl=null,this.destEl=null,this.signinEl=null,this.cloneBtn=null,this.jobEl=null,this.mode==="folder")this.renderFolder();else if(this.jobId&&this.job)this.renderJobView();else if(this.picking)this.renderPickParent();else this.renderCloneForm()}renderTabs(){if(!this.tabsEl)return;if(!this.host.hub.hasFeature("clone")){this.tabsEl.classList.add("bp-hidden");return}this.tabsEl.classList.remove("bp-hidden");let e=(t,n)=>{let i=We(n,"bp-ap-tab"+(this.mode===t?" on":""),()=>{if(this.mode===t)return;if(this.mode=t,this.render(),t==="clone"&&!this.jobId&&this.repos===null)this.askRepos(0)});return i.setAttribute("data-testid",`ap-tab-${t}`),i.setAttribute("aria-pressed",String(this.mode===t)),i};this.tabsEl.replaceChildren(e("folder",m("gpui.e.open.folder","Open folder")),e("clone",m("web.clone.tab","Clone from git")))}renderFolder(){let e=new Pn(this.host.hub,(t)=>m("web.clone.add.dir","Add {dir}",{dir:t}),async(t)=>{let n=await this.host.hub.rpc("project.add",{path:t},30000);if(this.close(),n.project)this.host.onProjectAdded(n.project)});this.bodyEl.replaceChildren(e.root),e.go("")}renderCloneForm(){let e=this.bodyEl,t=Y("div","bp-ap-form"),n=Y("div","bp-ap-repo"),i=Y("input","bp-input");i.type="text",i.spellcheck=!1,i.autocomplete="off",i.placeholder=m("web.clone.repo.placeholder","https or ssh URL, or owner/repo"),i.setAttribute("aria-label",m("web.clone.repo.placeholder","https or ssh URL, or owner/repo")),i.setAttribute("data-testid","clone-repo"),i.value=this.repoText,i.addEventListener("input",()=>{if(this.repoText=i.value,this.repoValue="",this.showSuggest=!0,this.suggestIdx=-1,this.startErr="",!this.nameTouched)this.nameText="";this.askRepos(200),this.askDest(250)}),i.addEventListener("focus",()=>{if(this.showSuggest=!0,this.repos===null)this.askRepos(0);else this.renderSuggest()}),i.addEventListener("blur",()=>{window.setTimeout(()=>{if(document.activeElement!==i)this.showSuggest=!1,this.renderSuggest()},120)}),i.addEventListener("keydown",(p)=>this.repoKey(p)),this.repoInput=i,this.suggestEl=Y("div","bp-ap-suggest bp-hidden"),this.suggestEl.setAttribute("data-testid","clone-suggest"),n.append(i,this.suggestEl),this.signinEl=Y("div","bp-ap-signin bp-hidden"),this.signinEl.setAttribute("data-testid","clone-signin"),this.destEl=Y("div","bp-ap-dest"),this.destEl.setAttribute("data-testid","clone-dest");let s=Y("label","bp-ap-check"),r=Y("input");r.type="checkbox",r.checked=this.wantThread,r.setAttribute("data-testid","clone-thread"),r.addEventListener("change",()=>{this.wantThread=r.checked}),s.append(r,Y("span","",m("web.clone.start.thread","Start a thread")));let o=[n,this.signinEl,this.destEl,s];if(this.firstText)o.push(Y("div","bp-ap-first bp-dim",m("web.clone.first","First message: {text}",{text:this.firstText})));let a=Y("div","bp-ap-err"+(this.startErr?"":" bp-hidden"),this.startErr);a.setAttribute("data-testid","clone-start-error");let c=Y("div","bp-ap-foot");this.cloneBtn=We(m("web.clone.go","Clone"),"primary",()=>{this.startClone()}),this.cloneBtn.setAttribute("data-testid","clone-go"),c.append(this.cloneBtn),o.push(a,c),t.append(...o),e.replaceChildren(t),this.renderSuggest(),this.renderSignin(),this.renderDest(),window.setTimeout(()=>{if(this.repoInput===i&&!this.repoText)i.focus()},0)}repoKey(e){let t=this.repos?.repos??[],n=this.showSuggest&&t.length>0;if(e.key==="ArrowDown"&&n)e.preventDefault(),this.suggestIdx=Math.min(t.length-1,this.suggestIdx+1),this.renderSuggest();else if(e.key==="ArrowUp"&&n)e.preventDefault(),this.suggestIdx=Math.max(-1,this.suggestIdx-1),this.renderSuggest();else if(e.key==="Enter"){e.preventDefault();let i=n&&this.suggestIdx>=0?t[this.suggestIdx]:void 0;if(i)this.pickRepo(i);else if(this.canStart())this.startClone()}}pickRepo(e){if(this.repoText=e.name,this.repoValue=e.value,this.showSuggest=!1,this.suggestIdx=-1,this.startErr="",!this.nameTouched)this.nameText="";if(this.repoInput)this.repoInput.value=e.name;this.renderSuggest(),this.askDest()}repoArg(){return this.repoValue||this.repoText.trim()}askRepos(e){if(this.reposTimer!==null)window.clearTimeout(this.reposTimer);this.reposTimer=window.setTimeout(()=>{this.reposTimer=null;let t=++this.reposGen,n=this.repoValue?"":this.repoText.trim();this.host.hub.rpc("clone.repos",{q:n,limit:12},30000).then((i)=>{if(t!==this.reposGen)return;this.repos=i,this.renderSuggest(),this.renderSignin()}).catch(()=>{if(t!==this.reposGen)return;this.repos={repos:[],state:"error",hint:"Couldn't list your GitHub repositories."},this.renderSuggest()})},e)}renderSuggest(){let e=this.suggestEl;if(!e)return;let t=this.repos,n=t?.repos??[],i=[];if(this.showSuggest&&!this.repoValue){if(n.forEach((s,r)=>{let o=We("","bp-ap-sug"+(r===this.suggestIdx?" active":""));o.setAttribute("data-testid","clone-suggestion"),o.addEventListener("mousedown",(c)=>c.preventDefault()),o.addEventListener("click",()=>this.pickRepo(s));let a=Y("div","bp-ap-sug-top");if(a.append(Y("span","bp-ap-sug-name",s.name)),s.private)a.append(Y("span","bp-ap-tag",m("web.clone.private","private")));if(o.append(a),s.description)o.append(Y("div","bp-ap-sug-desc",s.description));i.push(o)}),n.length===0&&t){if(t.loading)i.push(Y("div","bp-ap-sug-note",m("web.clone.loading","Loading…")));else if(t.hint){let s=Y("div","bp-ap-sug-note");if(s.append(Y("span","",fe(t.hint))),t.state==="signedout"){let r=We(m("web.clone.signin","Sign in to GitHub"),"bp-btn-line",()=>{this.startSignin()});r.addEventListener("mousedown",(o)=>o.preventDefault()),r.setAttribute("data-testid","clone-signin-btn"),s.append(r)}i.push(s)}}}e.replaceChildren(...i),e.classList.toggle("bp-hidden",i.length===0)}askDest(e=0){if(this.destTimer!==null)window.clearTimeout(this.destTimer);this.destPending=!0,this.updateCloneBtn(),this.destTimer=window.setTimeout(()=>{this.destTimer=null;let t=++this.destGen,n=this.repoArg();if(!n){this.dest=null,this.destPending=!1,this.renderDest();return}let i={repo:n};if(this.userParent)i.parent=this.userParent;if(this.nameTouched&&this.nameText.trim())i.name=this.nameText.trim();else if(this.userParent)i.name="";this.host.hub.rpc("clone.dest",i).then((s)=>{if(t!==this.destGen)return;if(this.dest=s,this.destPending=!1,!this.nameTouched&&s.folder)this.nameText=s.folder;this.renderDest()}).catch((s)=>{if(t!==this.destGen)return;this.dest={ok:!1,error:s instanceof Error?s.message:String(s)},this.destPending=!1,this.renderDest()})},e)}renderDest(){let e=this.destEl;if(!e)return;let t=this.dest,n=[];if(t&&!t.repo){if(t.error&&this.repoText.trim())n.push(this.errLine(fe(t.error)))}else if(t){let o=Y("div","bp-ap-where"),a=Y("span","bp-ap-dest-path",t.destShown||t.dest||t.defaultParentShown||"");a.setAttribute("data-testid","clone-dest-shown");let c=We(m("web.clone.change.folder","Change folder"),"bp-btn-line",()=>{this.picking=!0,this.render()});c.setAttribute("data-testid","clone-change-folder"),o.append(a,c),n.push(o);let p=Y("label","bp-ap-name");p.append(Y("span","bp-ap-lbl",m("web.clone.folder.name","Folder name")));let l=Y("input","bp-input");if(l.type="text",l.spellcheck=!1,l.value=this.nameText,l.setAttribute("data-testid","clone-name"),l.addEventListener("input",()=>{this.nameText=l.value,this.nameTouched=l.value.trim()!=="",this.startErr="",this.askDest(250)}),l.addEventListener("keydown",(h)=>{if(h.key==="Enter"&&this.canStart())h.preventDefault(),this.startClone()}),p.append(l),n.push(p),!t.ok&&t.error)n.push(this.errLine(fe(t.error)));else if(t.same)n.push(Y("div","bp-ap-note bp-dim",m("web.clone.same","Already cloned there: it is added as it is.")))}let i=document.activeElement,s=i&&e.contains(i)&&i.getAttribute("data-testid")==="clone-name",r=s?i.selectionStart:null;if(e.replaceChildren(...n),e.classList.toggle("bp-hidden",n.length===0),s){let o=e.querySelector('[data-testid="clone-name"]');if(o){if(o.focus(),r!==null)o.setSelectionRange(r,r)}}this.updateCloneBtn()}errLine(e){let t=Y("div","bp-ap-err",e);return t.setAttribute("data-testid","clone-dest-error"),t}canStart(){return Boolean(this.dest?.ok&&this.dest.repo&&!this.destPending&&!this.starting&&this.repoArg())}updateCloneBtn(){if(this.cloneBtn)this.cloneBtn.disabled=!this.canStart()}renderPickParent(){let e=this.dest?.parent||this.userParent||this.dest?.defaultParent||"",t=We(m("web.clone.back","Back"),"bp-btn-line",()=>{this.picking=!1,this.render()}),n=new Pn(this.host.hub,(i)=>m("web.clone.use.dir","Use {dir}",{dir:i}),async(i)=>{this.userParent=i,this.picking=!1,this.render(),this.askDest()},[t]);this.bodyEl.replaceChildren(n.root),n.go(e)}async startClone(){if(!this.canStart()||!this.dest)return;this.starting=!0,this.startErr="",this.updateCloneBtn();let e={repo:this.repoArg(),thread:this.wantThread,text:this.firstText},t=Cn();this.jobId=t,this.job=null,this.specs.set(t,e);try{let n=await this.host.hub.rpc("clone.start",{id:t,repo:e.repo,parent:this.dest.parent??"",name:this.dest.folder??this.nameText.trim(),thread:e.thread,text:e.text});this.starting=!1,this.apply(n)}catch(n){this.starting=!1;let i=fe(n instanceof Error?n.message:String(n));if(this.jobId===t&&!this.job){let s=await this.host.hub.rpc("clone.status",{id:t}).catch(()=>null);if(s&&s.id===t){this.apply(s);return}}if(this.jobId===t&&!this.job){if(this.jobId="",this.startErr=i,this.mode==="clone")this.render()}}}async retry(e,t){let n=this.specs.get(e.id)??{repo:e.origin||e.repo||"",thread:!0,text:""},i=Cn(),s=this.jobId;this.jobId=i,this.specs.set(i,n),t.disabled=!0;try{let r=await this.host.hub.rpc("clone.start",{id:i,repo:n.repo,dest:e.dest??"",thread:n.thread,text:n.text});this.apply(r)}catch(r){let o=fe(r instanceof Error?r.message:String(r));if(this.jobId!==i)return;if(!this.job||this.job.id!==i){let a=await this.host.hub.rpc("clone.status",{id:i}).catch(()=>null);if(a&&a.id===i){this.apply(a);return}}if(this.jobId===i&&(!this.job||this.job.id!==i))this.jobId=s,t.disabled=!1,this.showJobError(o)}}apply(e){if(!e||e.id!==this.jobId)return;if(!Ni(this.job,e))return;if(this.job=e,this.copied=!1,this.isOpen()&&this.mode==="clone")if(this.jobEl&&this.jobEl.isConnected)this.renderJob();else this.render();this.maybeGo(e)}maybeGo(e){if(this.isOpen()&&e.id===this.jobId&&Mi(e))this.goTo(e)}renderJobView(){this.jobEl=Y("div","bp-ap-job"),this.jobEl.setAttribute("data-testid","clone-job"),this.signinEl=Y("div","bp-ap-signin bp-hidden"),this.signinEl.setAttribute("data-testid","clone-signin"),this.bodyEl.replaceChildren(this.jobEl,this.signinEl),this.renderJob(),this.renderSignin()}renderJob(){let e=this.jobEl,t=this.job;if(!e||!t)return;let n=t.destShown||t.dest||"",i=t.repo||"",s=t.state==="done"?m("web.clone.cloned","Cloned {repo} into {dest}",{repo:i,dest:n}):t.state==="cancelled"?m("web.clone.stopped","Stopped cloning {repo}",{repo:i}):m("web.clone.cloning","Cloning {repo} into {dest}",{repo:i,dest:n}),r=[Y("div","bp-ap-job-title",s)];if(t.state==="running"){let o=Y("div","bp-ap-phase",fe(t.phase||""));o.setAttribute("data-testid","clone-phase");let a=Y("div","bp-ap-bar"+(typeof t.pct==="number"?"":" indeterminate")),c=Y("div","bp-ap-bar-fill");if(typeof t.pct==="number")c.style.width=`${Math.max(0,Math.min(100,t.pct))}%`;if(a.appendChild(c),a.setAttribute("role","progressbar"),typeof t.pct==="number")a.setAttribute("aria-valuenow",String(t.pct));if(r.push(o,a),t.detail)r.push(Y("div","bp-ap-detail bp-dim",t.detail));let p=Y("div","bp-ap-foot"),l=We(m("common.cancel","Cancel"),"bp-btn-line",()=>{this.host.hub.rpc("clone.cancel",{id:t.id}).then((h)=>this.apply(h)).catch(()=>{})});l.setAttribute("data-testid","clone-cancel"),p.append(l),r.push(p)}else if(t.state==="failed"||t.state==="cancelled"){if(t.state==="failed"&&t.error){let p=Y("div","bp-ap-err",fe(t.error));p.setAttribute("data-testid","clone-error"),r.push(p)}let o=Y("div","bp-ap-foot"),a=We(m("web.clone.back","Back"),"bp-btn-line",()=>{this.jobId="",this.job=null,this.signin=null,this.render(),this.askDest()});if(o.append(a),t.signin){let p=We(m("web.clone.signin","Sign in to GitHub"),"bp-btn-line",()=>{this.startSignin()});p.setAttribute("data-testid","clone-signin-btn"),o.append(p)}let c=We(m("web.clone.retry","Try again"),"primary",()=>{this.retry(t,c)});c.setAttribute("data-testid","clone-retry"),o.append(c),r.push(o)}else if(t.state==="done"){let o=t.notes??[];if(o.length>0){let l=Y("ul","bp-ap-notes");l.setAttribute("data-testid","clone-notes");for(let h of o)l.appendChild(Y("li","",fe(h)));r.push(l)}let a=Y("div","bp-ap-foot"),c=t.thread?m("web.clone.open.thread","Open the thread"):m("web.clone.open.project","Open the project"),p=We(c,"primary",()=>this.goTo(t));p.setAttribute("data-testid","clone-open"),a.append(p),r.push(a)}e.replaceChildren(...r)}showJobError(e){if(!this.jobEl)return;this.jobEl.querySelector(".bp-ap-job-err")?.remove();let t=Y("div","bp-ap-err bp-ap-job-err",e);this.jobEl.appendChild(t)}goTo(e){this.jobId="",this.job=null,this.close(),this.host.onCloneDone(e)}async startSignin(){this.signin={state:"starting"},this.copied=!1,this.renderSignin();try{let e=await this.host.hub.rpc("clone.signin",{restart:!0},30000);if(!this.signin||this.signin.state==="starting")this.signin=e}catch(e){this.signin={state:"failed",error:e instanceof Error?e.message:String(e)}}if(this.signin?.state==="done")this.askRepos(0);this.renderSignin()}renderSignin(){let e=this.signinEl;if(!e)return;let t=this.signin,n=[];if(t&&t.state){if(t.state==="starting"||t.state==="waiting"&&!t.code)n.push(Y("div","bp-dim",m("web.clone.signin.wait","Starting GitHub sign-in…")));else if(t.state==="waiting"){n.push(Y("div","",m("web.clone.signin.enter","Enter this code on GitHub:")));let i=Y("div","bp-ap-code-row"),s=Y("span","bp-ap-code",t.code||"");s.setAttribute("data-testid","clone-signin-code");let r=We(this.copied?m("web.clone.copied","Copied"):m("common.copy","Copy"),"bp-btn-line",()=>{navigator.clipboard?.writeText(t.code||"").then(()=>{this.copied=!0,this.renderSignin()}).catch(()=>{})});if(i.append(s,r),n.push(i),t.url){let o=Y("a","bp-ap-link",t.url);o.href=t.url,o.target="_blank",o.rel="noopener noreferrer",o.setAttribute("data-testid","clone-signin-url"),n.push(o)}}else if(t.state==="done")n.push(Y("div","bp-ok",m("web.clone.signin.done","Signed in to GitHub")));else if(t.state==="failed")n.push(Y("div","bp-ap-err",fe(t.error||"")))}e.replaceChildren(...n),e.classList.toggle("bp-hidden",n.length===0)}}function Gr(e){try{let t=new URL(e,window.location.origin);if(t.protocol==="https:"||t.protocol==="http:")return t.href}catch{}return null}function Vt(e,t){let n=/(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[([^\]]+)\]\(([^)]+)\))/g,i=0,s;while((s=n.exec(t))!==null){if(s.index>i)e.appendChild(document.createTextNode(t.slice(i,s.index)));let r=s[0];if(r.startsWith("`")&&r.endsWith("`")){let o=document.createElement("code");o.className="bp-code-inline",o.textContent=r.slice(1,-1),e.appendChild(o)}else if(r.startsWith("**")&&r.endsWith("**")){let o=document.createElement("strong");o.textContent=r.slice(2,-2),e.appendChild(o)}else if(r.startsWith("*")&&r.endsWith("*")){let o=document.createElement("em");o.textContent=r.slice(1,-1),e.appendChild(o)}else if(r.startsWith("[")){let o=s[2]??"",a=Gr(s[3]??"");if(a){let c=document.createElement("a");c.href=a,c.target="_blank",c.rel="noopener noreferrer",c.textContent=o,e.appendChild(c)}else e.appendChild(document.createTextNode(o))}i=n.lastIndex}if(i{navigator.clipboard?.writeText(l).then(()=>{f.textContent="✓",window.setTimeout(()=>{f.textContent=b},1200)}).catch(()=>{})}),d.append(u,f);let v=document.createElement("pre"),w=document.createElement("code");w.textContent=l,v.appendChild(w),h.append(d,v),t.appendChild(h);continue}if(!s.trim()){i++;continue}let r=/^(#{1,4})\s+(.+)$/.exec(s);if(r){let c=document.createElement(`h${Math.min(4,r[1].length+1)}`);c.className="bp-md-h",$t(c,r[2]),t.appendChild(c),i++;continue}if(s.startsWith("> ")){let c=document.createElement("blockquote");c.className="bp-md-quote";let p=[];while(i "))p.push(n[i].slice(2)),i++;$t(c,p.join(` -`)),t.appendChild(c);continue}if(/^\s*[-*]\s+/.test(s)){let c=document.createElement("ul");c.className="bp-md-list";while(i ")&&!/^\s*[-*]\s+/.test(n[i])&&!/^\s*\d+\.\s+/.test(n[i]))o.push(n[i]),i++;let a=document.createElement("p");a.className="bp-md-p";for(let c=0;c0)a.appendChild(document.createElement("br"));$t(a,o[c])}t.appendChild(a)}return t}var Hr=new Set(["(","[",'"',"'","`"]);function Dr(e){return/[\p{L}\p{N}\-_\/+\[]/u.test(e)}function Fr(e){return/[\p{L}\p{N}\-_\/]/u.test(e)}function $r(e){return/[\p{L}\p{N}]/u.test(e)}function Ti(e,t){if(!e)return[];let n=(t??[]).filter((r)=>r.kind==="model"&&r.word&&r.label);if(n.length===0)return[{kind:"text",text:e}];let i=[],s=0;while(so)r=l,o=h,a=c;break}p=l+1}}if(a===null)break;if(r>s)i.push({kind:"text",text:e.slice(s,r)});i.push({kind:"model",word:a.word,label:a.label}),s=o}if(s3600000)return"";let t=Math.max(1,Math.round(e/1000));if(t<60)return`${t}s`;let n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Vr(e,t){let n=document.createDocumentFragment(),i=Ti(e,t),s=m("native.thread.model","Model").toLowerCase();for(let r of i){if(r.kind==="text"){n.appendChild(document.createTextNode(r.text));continue}let o=document.createElement("span");o.className="bp-ref-chip bp-ref-model",o.title=r.word,o.setAttribute("data-ref-word",r.word);let a=document.createElement("span");a.className="bp-ref-sigil",a.textContent="&";let c=document.createElement("span");c.className="bp-ref-label",c.textContent=r.label;let p=document.createElement("span");p.className="bp-ref-kind",p.textContent=s,o.append(a,c,p),n.appendChild(o)}return n}function Ur(e){e.addEventListener("copy",(t)=>{let n=typeof window<"u"?window.getSelection():null;if(!n||n.rangeCount===0||n.isCollapsed)return;let i=n.getRangeAt(0);if(!e.contains(i.commonAncestorContainer))return;let s=i.commonAncestorContainer,a=(s.nodeType===Node.ELEMENT_NODE?s:s.parentElement)?.closest(".bp-ref-chip[data-ref-word]")?.getAttribute("data-ref-word"),c;if(a)c=a;else{let p=i.cloneContents(),l=p.querySelectorAll(".bp-ref-chip[data-ref-word]");if(l.length===0)return;for(let d of l){let u=d.getAttribute("data-ref-word")||d.textContent||"";d.replaceWith(document.createTextNode(u))}let h=p.querySelectorAll(".bp-entry");for(let d=1;d{if(!this.loadingOlder&&this.hasMore)this.loadingOlder=!0,this.cb.onLoadOlder()}),this.scrollEl.addEventListener("scroll",()=>{if(this.pinnedToBottom=this.isNearBottom(),this.hasMore&&!this.loadingOlder&&this.scrollEl.scrollTop<48)this.loadingOlder=!0,this.cb.onLoadOlder()}),typeof ResizeObserver<"u"){let n=0;new ResizeObserver(()=>{let s=this.scrollEl.clientHeight;if(n>0&&s!==n&&this.pinnedToBottom)this.scrollToBottom();n=s}).observe(this.scrollEl)}this.listEl=document.createElement("div"),this.listEl.className="bp-timeline-list",Ur(this.scrollEl),this.scrollEl.append(this.olderBtn,this.listEl),e.append(this.bannerEl,this.scrollEl)}setLoading(e){this.thread=e,this.entries=[],this.hasMore=!1,this.loadingOlder=!1,this.review=null,this.unanswered=null,this.btwNote=null,this.liveNodes.clear(),this.planExpanded.clear(),this.planRevisingId="",this.planReviseDrafts.clear(),this.renderBanners(),this.olderBtn.classList.add("bp-hidden");let t=document.createElement("div");t.className="bp-empty-state",t.textContent=m("web.chat.loading","Loading messages…"),this.listEl.replaceChildren(t)}setError(e,t,n){this.thread=e,this.entries=[],this.hasMore=!1,this.loadingOlder=!1,this.review=null,this.unanswered=null,this.btwNote=null,this.liveNodes.clear(),this.planExpanded.clear(),this.planRevisingId="",this.planReviseDrafts.clear(),this.renderBanners(),this.olderBtn.classList.add("bp-hidden");let i=document.createElement("div");i.className="bp-empty-state";let s=document.createElement("div");s.className="bp-bad",s.textContent=t;let r=document.createElement("button");r.type="button",r.textContent=m("tools.retry","Retry"),r.addEventListener("click",n),i.append(s,r),this.listEl.replaceChildren(i)}getEntries(){return this.entries.slice()}refreshLocale(){let e=this.scrollEl.scrollTop;if(this.olderBtn.textContent=m("android.load.earlier","Load earlier"),this.renderBanners(),this.thread&&this.entries.length>0)this.renderEntries(!1);this.scrollEl.scrollTop=e}setThread(e,t,n,i,s){if((this.thread?.id??"")!==(e?.id??""))this.planExpanded.clear(),this.planRevisingId="",this.planReviseDrafts.clear();this.thread=e,this.entries=t.filter((r)=>!Sn(r)),this.hasMore=n,this.loadingOlder=!1,this.review=i,this.unanswered=s,this.btwNote=null,this.renderBanners(),this.renderEntries(!0)}updateThreadMeta(e){if(!this.thread||this.thread.id!==e.id)return;this.thread=e}setReview(e){this.review=e,this.renderBanners()}setUnanswered(e){this.unanswered=e,this.renderBanners()}setNoProvider(e){this.noProvider=e,this.renderBanners()}showBtw(e,t){this.btwNote={q:e,a:t},this.renderBanners()}prependEntries(e,t){this.loadingOlder=!1;let n=this.scrollEl.scrollHeight,i=new Set(this.entries.map((r)=>r.id)),s=e.filter((r)=>!Sn(r)&&!i.has(r.id));this.entries=[...s,...this.entries],this.hasMore=t,this.renderEntries(!1),this.scrollEl.scrollTop+=this.scrollEl.scrollHeight-n}clearLoadingOlder(){this.loadingOlder=!1}upsertEntry(e){if(Sn(e))return;let t=this.isNearBottom()||e.kind==="user"&&Boolean(e.clientId),n=this.entries.findIndex((i)=>i.id===e.id);if(n<0&&e.clientId)n=this.entries.findIndex((i)=>i.clientId&&i.clientId===e.clientId);if(n>=0)this.entries[n]=e;else this.entries.push(e);this.renderEntries(t)}goTo(e){let t=this.scrollEl.querySelector(`[data-entry-id="${CSS.escape(e)}"]`);if(!t)return!1;return t.scrollIntoView({block:"center",behavior:"smooth"}),t.classList.remove("bp-entry-flash"),t.offsetWidth,t.classList.add("bp-entry-flash"),window.setTimeout(()=>t.classList.remove("bp-entry-flash"),1200),!0}removeEntry(e){let t=this.entries.filter((n)=>n.id!==e);if(t.length!==this.entries.length)this.entries=t,this.renderEntries(!1)}appendLiveText(e,t,n){let i=this.isNearBottom(),s=this.entries.find((o)=>o.id===e);if(!s){s={id:e,kind:"assistant",text:t,at:n,live:!0},this.entries.push(s),this.renderEntries(i);return}s.text+=t,s.live=!0;let r=this.liveNodes.get(e);if(r){if(r.replaceChildren(Ot(s.text)),i)this.scrollToBottom()}else this.renderEntries(i)}isNearBottom(){let e=this.scrollEl;return e.scrollHeight-e.scrollTop-e.clientHeight<80}scrollToBottom(){this.pinnedToBottom=!0,this.scrollEl.scrollTop=this.scrollEl.scrollHeight}renderBanners(){let e=document.createDocumentFragment();if(this.noProvider&&!this.thread?.id.includes("~")){let t=document.createElement("div");t.className="bp-banner bp-no-provider",t.setAttribute("data-testid","no-provider-banner");let n=document.createElement("div");n.className="bp-no-provider-body";let i=document.createElement("strong");if(i.textContent=he(this.noProvider.head),n.appendChild(i),this.noProvider.text){let o=document.createElement("span");o.className="bp-dim",o.textContent=he(this.noProvider.text),n.appendChild(o)}let s=document.createElement("div");s.className="bp-banner-actions";let r=document.createElement("button");r.type="button",r.className="primary",r.setAttribute("data-testid","no-provider-accounts-btn"),r.textContent=he(this.noProvider.button),r.addEventListener("click",()=>this.cb.onOpenAccounts?.()),s.appendChild(r),t.append(n,s),e.appendChild(t)}if(this.review&&(this.review.text||this.review.button)){let t=document.createElement("div");t.className="bp-banner bp-review-bar",t.setAttribute("data-testid","review-bar");let n=document.createElement("span");if(n.textContent=this.review.text||m("web.chat.review.mode","Review mode"),t.appendChild(n),this.review.button){let i=document.createElement("button");i.type="button",i.textContent=this.review.button,i.addEventListener("click",()=>this.cb.onToggleReview(!(this.review?.on??!0))),t.appendChild(i)}e.appendChild(t)}if(this.unanswered&&(this.unanswered.head||this.unanswered.text)){let t=document.createElement("div");t.className="bp-banner bp-unanswered",t.setAttribute("data-testid","unanswered-notice");let n=document.createElement("div");if(n.className="bp-unanswered-body",this.unanswered.head){let i=document.createElement("strong");i.textContent=this.unanswered.head,n.appendChild(i)}if(this.unanswered.text){let i=document.createElement("span");i.textContent=this.unanswered.text,n.appendChild(i)}if(t.appendChild(n),this.unanswered.buttons?.length){let i=document.createElement("div");i.className="bp-banner-actions";for(let s of this.unanswered.buttons){let r=document.createElement("button");if(r.type="button",s.primary)r.className="primary";r.textContent=s.label,r.addEventListener("click",()=>this.cb.onUnansweredAction(s.action,s.value)),i.appendChild(r)}t.appendChild(i)}e.appendChild(t)}if(this.btwNote){let t=document.createElement("div");t.className="bp-banner bp-btw-banner";let n=document.createElement("div"),i=document.createElement("div");i.className="bp-dim",i.textContent=`/btw ${this.btwNote.q}`;let s=document.createElement("div");s.appendChild(Ot(this.btwNote.a)),n.append(i,s);let r=document.createElement("button");r.type="button",r.className="icon",r.textContent="×",r.addEventListener("click",()=>{this.btwNote=null,this.renderBanners()}),t.append(n,r),e.appendChild(t)}this.bannerEl.replaceChildren(e)}makeEntryActions(e,t,n){let i=document.createElement("div");i.className="bp-entry-foot"+(t?" user":"");let s=document.createElement("button");s.type="button",s.className="bp-entry-act";let r=m("common.copy","Copy"),o=document.createElement("span");o.textContent=r,s.append(Gt(["M9 9h11v11H9z","M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1"]),o),s.addEventListener("click",()=>{navigator.clipboard?.writeText(e.text||"").then(()=>{o.textContent="✓",window.setTimeout(()=>{o.textContent=r},1000)}).catch(()=>{})});let a=document.createElement("button");a.type="button",a.className="bp-entry-act";let c=document.createElement("span");c.textContent=m("reply.action","Reply"),a.append(Gt(["M9 17l-5-5 5-5","M20 18v-2a4 4 0 0 0-4-4H4"]),c),a.addEventListener("click",()=>this.cb.onReplyEntry(e));let p=!e.live&&!e.id.startsWith("local-")&&!e.id.startsWith("live:"),l=document.createElement("span");l.className="bp-entry-time";let h=Or(e.at);if(t)l.textContent=h,i.append(s,...p?[a]:[],l);else{let d=n&&e.at?Gr(Ln(e.at)-Ln(n)):"",u=h?d?m("web.chat.finished.dur","Finished {time} · {dur}",{time:h,dur:d}):m("web.chat.finished","Finished {time}",{time:h}):"";l.textContent=e.live?m("web.chat.streaming","Streaming…"):u,i.append(l,s,...p?[a]:[])}return i}closePlanRevise(){let e=this.planRevisingId;if(!e)return!1;this.planRevisingId="";let t=this.scrollEl.scrollTop;return this.renderEntries(!1),this.scrollEl.scrollTop=t,this.listEl.querySelector(`[data-testid="ask-${CSS.escape(e)}"] [data-testid="plan-revise"]`)?.focus(),!0}renderEntries(e){let t=null,n=typeof document<"u"?document.activeElement:null;if(n instanceof HTMLTextAreaElement&&n.classList.contains("bp-plan-revise-input")&&this.listEl.contains(n)&&this.planRevisingId)this.planReviseDrafts.set(this.planRevisingId,n.value),t={askId:this.planRevisingId,start:n.selectionStart,end:n.selectionEnd,dir:n.selectionDirection};this.olderBtn.classList.toggle("bp-hidden",!this.hasMore),this.liveNodes.clear();let i=document.createDocumentFragment();if(!this.thread){let r=document.createElement("div");r.className="bp-empty-state",r.textContent=m("web.chat.choose","Choose a project thread on the left to begin."),i.appendChild(r),this.listEl.replaceChildren(i);return}if(this.entries.length===0){let r=document.createElement("div");r.className="bp-empty-state",r.textContent=m("web.chat.empty","No messages yet. Type below to start a turn."),i.appendChild(r),this.listEl.replaceChildren(i);return}let s=0;for(let r of this.entries){if(r.kind==="user"&&r.at)s=r.at;let o=document.createElement("article");if(o.className=`bp-entry bp-entry-${r.kind}`+(r.live?" is-live":""),o.setAttribute("data-entry-id",r.id),r.kind==="tool"&&r.tool){let l=document.createElement("div");l.className=`bp-tool-pill bp-tool-${r.tool.state||"done"}`;let h=document.createElement("span");if(h.className="bp-tool-name",h.textContent=r.tool.name,l.appendChild(h),r.tool.summary){let d=document.createElement("span");d.className="bp-tool-summary",d.textContent=r.tool.summary,l.appendChild(d)}o.appendChild(l),i.appendChild(o);continue}if(r.kind==="ask"&&r.ask){let l=r.ask;if(l.kind==="plan"){o.appendChild(this.renderPlanAsk(l)),i.appendChild(o);continue}let h=document.createElement("div");h.className="bp-ask-card",h.setAttribute("data-testid",`ask-${l.id}`);let d=document.createElement("div");if(d.className="bp-ask-q",d.textContent=l.question,h.appendChild(d),l.state==="open"){let u=document.createElement("div");if(u.className="bp-ask-opts",l.options&&l.options.length>0)for(let f of l.options){let b=document.createElement("button");b.type="button",b.textContent=f.label,b.addEventListener("click",()=>this.cb.onAnswerAsk(l.id,f.id)),u.appendChild(b)}else{let f=document.createElement("input");f.type="text",f.className="bp-input",f.placeholder=m("web.chat.answer.placeholder","Type answer…");let b=document.createElement("button");b.type="button",b.className="primary",b.textContent=m("web.chat.answer.btn","Answer"),b.addEventListener("click",()=>{if(f.value.trim())this.cb.onAnswerAsk(l.id,f.value.trim())}),u.append(f,b)}h.appendChild(u)}else{let u=document.createElement("div");u.className="bp-ask-answered",u.textContent=m("web.chat.answered","Answered: {answer}",{answer:l.answered??""}),h.appendChild(u)}o.appendChild(h),i.appendChild(o);continue}let a=Boolean(r.text&&r.text.trim().length>0),c=Boolean(r.images&&r.images.length>0),p=Boolean(r.attachments&&r.attachments.length>0);if(!a&&!c&&!p&&!r.live)continue;if(r.replyTo?.quote){let l=document.createElement("div");l.className="bp-reply-quote",l.textContent=m("gpui.b.in.reply.to","↩ In reply to: {quote}",{quote:r.replyTo.quote});let h=r.replyTo.id;l.setAttribute("role","button"),l.tabIndex=0,l.setAttribute("data-testid","entry-reply-quote");let d=()=>{if(this.cb.onGoToEntry)this.cb.onGoToEntry(h);else this.goTo(h)};l.addEventListener("click",d),l.addEventListener("keydown",(u)=>{if(u.key==="Enter"||u.key===" ")u.preventDefault(),d()}),o.appendChild(l)}if(a||r.live){let l=document.createElement("div");if(l.className="bp-entry-body",r.kind==="user")l.appendChild(Vr(r.text||"",r.refs));else l.appendChild(Ot(r.text||""));if(r.live)this.liveNodes.set(r.id,l);o.appendChild(l)}if(p&&r.attachments){let l=document.createElement("div");l.className="bp-entry-images";for(let h of r.attachments)if(h.previewUrl){let d=document.createElement("img");d.className="bp-reply-img",d.src=h.previewUrl,d.alt=h.name||"attachment",l.appendChild(d)}else if(h.path||h.name){let d=document.createElement("span");d.className="bp-tool-pill",d.textContent=h.name||h.path||"image",l.appendChild(d)}if(l.childElementCount>0)o.appendChild(l)}if(r.images&&r.images.length>0){let l=document.createElement("div");l.className="bp-entry-images";for(let h of r.images){let d=document.createElement("img");d.className="bp-reply-img",d.alt=h;let u=`${r.id}|${h}`,f=this.imageCache.get(u);if(f)d.src=f;else this.cb.onLoadImage(r.id,h).then((b)=>{if(!b)return;let v=b.url??(b.mime&&b.data?`data:${b.mime};base64,${b.data}`:"");if(!v)return;this.imageCache.set(u,v),d.src=v});l.appendChild(d)}o.appendChild(l)}o.appendChild(this.makeEntryActions(r,r.kind==="user",r.kind==="assistant"?s:void 0)),i.appendChild(o)}if(this.listEl.replaceChildren(i),t&&this.planRevisingId===t.askId){let r=this.listEl.querySelector(`[data-testid="ask-${CSS.escape(t.askId)}"] .bp-plan-revise-input`);if(r){if(r.focus({preventScroll:!0}),t.start!==null&&t.end!==null)r.setSelectionRange(t.start,t.end,t.dir??void 0)}}if(e&&!t)this.scrollToBottom()}renderPlanAsk(e){let t=this.planExpanded.has(e.id),n=e.state==="open"&&this.planRevisingId===e.id,i=document.createElement("div");i.className="bp-ask-card bp-ask-plan",i.setAttribute("data-testid",`ask-${e.id}`);let s=document.createElement("div");s.className="bp-plan-head";let r=Gt(["M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z","M14 2v6h6","M16 13H8","M16 17H8","M10 9H8"]);r.classList.add("bp-plan-head-ic");let o=document.createElement("span");if(o.className="bp-plan-title",o.textContent=!e.head||e.head==="Proposed plan"?m("ask.plan","Proposed plan"):he(e.head),s.append(r,o),e.state==="open"){let l=document.createElement("span");l.className="bp-plan-badge",l.textContent=m("gpui.ask.plan.ready","Ready for review"),s.appendChild(l)}let a=document.createElement("span");if(a.className="bp-mgmt-flex1",s.appendChild(a),e.question){let l=document.createElement("button");l.type="button",l.className="bp-plan-head-btn";let h=m("common.copy","Copy"),d=document.createElement("span");d.textContent=h,l.append(Gt(["M9 9h11v11H9z","M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1"]),d),l.addEventListener("click",()=>{navigator.clipboard?.writeText(e.question).then(()=>{l.classList.add("copied"),d.textContent=m("web.clone.copied","Copied"),window.setTimeout(()=>{l.classList.remove("copied"),d.textContent=h},1200)}).catch(()=>{})}),s.appendChild(l)}let c=document.createElement("button");c.type="button",c.className="bp-plan-head-btn",c.setAttribute("data-testid","plan-expand"),c.textContent=t?m("gpui.c.term.collapse","Collapse"):m("gpui.c.term.expand","Expand"),c.addEventListener("click",()=>{if(this.planExpanded.has(e.id))this.planExpanded.delete(e.id);else this.planExpanded.add(e.id);let l=this.scrollEl.scrollTop;this.renderEntries(!1),this.scrollEl.scrollTop=l}),s.appendChild(c),i.appendChild(s);let p=document.createElement("div");if(p.className="bp-plan-body"+(t?" is-expanded":""),p.setAttribute("data-testid","plan-body"),p.appendChild(Ot(e.question||"")),i.appendChild(p),e.state==="open"){let l=document.createElement("div");l.className="bp-plan-actions";let h=e.options?.find((b)=>b.id==="implement"||b.id.endsWith("|implement")),d=document.createElement("button");if(d.type="button",d.className="primary",d.setAttribute("data-testid","plan-implement"),d.textContent=h?.label&&h.label!=="Implement"?he(h.label):m("approval.implement","Implement"),d.addEventListener("click",()=>{this.planRevisingId="",this.planReviseDrafts.delete(e.id),this.cb.onAnswerAsk(e.id,h?.id??"implement")}),l.appendChild(d),e.revise!==!1){let b=document.createElement("button");b.type="button",b.className="bp-plan-revise-btn"+(n?" active":""),b.setAttribute("data-testid","plan-revise"),b.append(Gt(["M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7","M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"]),document.createTextNode(m("gpui.ask.plan.revise","Revise"))),b.addEventListener("click",()=>{let v=this.planRevisingId!==e.id;this.planRevisingId=v?e.id:"";let w=this.scrollEl.scrollTop;if(this.renderEntries(!1),this.scrollEl.scrollTop=w,v)this.listEl.querySelector(`[data-testid="ask-${CSS.escape(e.id)}"] .bp-plan-revise-input`)?.focus()}),l.appendChild(b)}let u=e.options?.find((b)=>b.id==="dismiss"||b.id.endsWith("|dismiss")),f=document.createElement("button");if(f.type="button",f.className="bp-plan-dismiss-btn",f.setAttribute("data-testid","plan-dismiss"),f.textContent=u?.label&&u.label!=="Dismiss"?he(u.label):m("approval.dismiss","Dismiss"),f.addEventListener("click",()=>{this.planRevisingId="",this.planReviseDrafts.delete(e.id),this.cb.onAnswerAsk(e.id,u?.id??"dismiss")}),l.appendChild(f),i.appendChild(l),n){let b=document.createElement("div");b.className="bp-plan-revise",b.setAttribute("data-testid","plan-revise-drawer");let v=document.createElement("textarea");v.rows=2,v.className="bp-input bp-plan-revise-input",v.placeholder=m("gpui.ask.plan.reviseph","What should change in the plan?"),v.value=this.planReviseDrafts.get(e.id)??"";let w=document.createElement("button");w.type="button",w.className="bp-plan-revise-send",w.setAttribute("data-testid","plan-revise-send"),w.textContent=m("gpui.ask.plan.sendrev","Send revision"),w.disabled=v.value.trim().length===0;let E=()=>{let M=v.value.trim();if(!M)return;this.planRevisingId="",this.planReviseDrafts.delete(e.id),this.cb.onAnswerAsk(e.id,`revise:${M}`)},k=()=>{this.closePlanRevise()};b.addEventListener("keydown",(M)=>{if(M.key==="Escape")M.preventDefault(),M.stopPropagation(),k()}),v.addEventListener("input",()=>{this.planReviseDrafts.set(e.id,v.value),w.disabled=v.value.trim().length===0}),v.addEventListener("keydown",(M)=>{if(M.key==="Enter"&&!M.shiftKey)M.preventDefault(),E()}),w.addEventListener("click",E);let L=document.createElement("button");L.type="button",L.className="bp-btn-ghost",L.textContent=m("common.cancel","Cancel"),L.addEventListener("click",k),b.append(v,w,L),i.appendChild(b)}}else{let l=document.createElement("div");l.className="bp-ask-answered",l.textContent=m("web.chat.answered","Answered: {answer}",{answer:e.answered??""}),i.appendChild(l)}return i}}var Wr={claude:"Claude Code",codex:"Codex CLI",grok:"Grok CLI",muse:"Muse Code",antigravity:"Google Antigravity",opencode:"OpenCode",pi:"Pi",omp:"Oh My Pi"};var Ii=/[\x00-\x1f\x7f]/,_r=/\s/;function Pt(e){return e.trim().replace(/^@+/,"").toLowerCase()}function ft(e,t){if(Ii.test(e)||Ii.test(t))return"";let n=Pt(e),i=t.trim();if(!n||!i||n.includes("/")||_r.test(n))return"";if(n.length+1+i.length>200)return"";return`${n}/${i}`}function Ri(e){let t=e.indexOf("/");if(t<=0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!ft(n,i))return null;return{provider:Pt(n),model:i.trim()}}function dt(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let i of e){if(typeof i!=="string")continue;let s=Ri(i);if(!s)continue;let r=`${s.provider}/${s.model}`;if(!n.has(r)){if(n.add(r),t.push(r),t.length>=64)break}}return t}function Nn(e,t,n,i){let s=ft(t,n),r=dt(e);if(!s)return{keys:r,starred:!1};let o=r.indexOf(s),a=i!==void 0?i:o<0;if(a&&o<0){if(r.length>=64)return{keys:r,starred:!1};r.push(s)}else if(!a&&o>=0)r.splice(o,1);return{keys:r,starred:a}}function nt(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:null}function xt(e){return Array.isArray(e)?e:[]}function Se(e){return typeof e==="string"?e:""}function zr(e){return Wr[e]??e}function ji(e,t,n,i){let s=new Map;for(let o of e)s.set(o.provider,o);let r=[];for(let o of dt(t)){let a=Ri(o);if(!a)continue;let c=s.get(a.provider),p=Boolean(c&&c.models.some((u)=>u.value!=="")),l=c?.models.find((u)=>u.value===a.model),h=l?l.ok&&(c?.ok??!0):c?.ok??!0,d=l?.why||c?.why||"";if(h&&p&&!l)h=!1,d="not available on this machine";r.push({key:o,provider:a.provider,model:a.model,label:l?.label||a.model,note:l?.note||"",on:a.provider===n&&a.model===i,ok:h,why:d})}return r}function Hi(e,t=[]){let n=nt(e),i=nt(n?.picker)??n??{},s=xt(i.sections).map(nt).filter((P)=>Boolean(P)),r=(P)=>s.find((Y)=>Se(Y.action)===P),o=r("provider"),a=r("model"),c=r("effort"),p=xt(o?.choices).map(nt).filter((P)=>Boolean(P)),l=xt(a?.choices).map(nt).filter((P)=>Boolean(P)),h=xt(c?.choices).map(nt).filter((P)=>Boolean(P)),d=Se(i.chip),u=Se(p.find((P)=>P.on===!0)?.value)||d.split("/")[0]?.trim()||"claude",f=Pt(u)||"claude",b=Se(l.find((P)=>P.on===!0)?.value),v=Se(h.find((P)=>P.on===!0)?.value),w=h.map((P)=>({value:Se(P.value),label:Se(P.label)||"auto",on:P.on===!0})),E=nt(i.agents),k=[],L=new Set,M=(P)=>{let Y=Pt(P);if(Y&&!L.has(Y))L.add(Y),k.push(Y)};for(let P of p)M(Se(P.value)||Se(P.label));if(E)for(let P of Object.keys(E))M(P);M(f);let A=k.map((P)=>{let Y=p.find((te)=>Pt(Se(te.value)||Se(te.label))===P),re=nt(E?.[P]),ie=re?re.ok!==!1:Y?Y.ok!==!1:!0,me=Se(re?.why)||Se(Y?.why),Pe=xt(re?.models).map(nt).filter((te)=>Boolean(te)),Ce;if(Pe.length>0)Ce=Pe.map((te)=>{let oe=Se(te.value),R=Se(te.label)||(oe===""?"default":oe),ue=Se(te.note);return{value:oe,label:R,note:ue,on:P===f&&oe===b,ok:te.ok!==!1&&ie,why:Se(te.why)||me}});else if(P===f&&l.length>0)Ce=l.map((te)=>{let oe=Se(te.value),R=Se(te.label);return{value:oe,label:oe===""?"default":oe,note:R&&R!==oe?R:"",on:te.on===!0,ok:te.ok!==!1&&ie,why:Se(te.why)||me}});else if(ie)Ce=[{value:"",label:"default",note:"",on:P===f&&b==="",ok:!0,why:""}];else Ce=[];if(P===f&&b&&!Ce.some((te)=>te.value===b)){let te=l.find((R)=>Se(R.value)===b),oe=Se(te?.label);Ce.push({value:b,label:b,note:oe&&oe!==b?oe:"",on:!0,ok:!0,why:""})}return{provider:P,label:zr(P),ok:ie,why:me,models:Ce}}),B=Array.isArray(i.favoriteKeys),T=xt(i.favorites).map(nt).filter((P)=>Boolean(P)),H=B?dt(i.favoriteKeys):T.length>0?dt(T.map((P)=>Se(P.key)||ft(Se(P.provider),Se(P.model)))):dt(t),O=T.length>0?T.map((P)=>{let Y=Pt(Se(P.provider)),re=Se(P.model).trim(),ie=ft(Y,re);if(!ie)return null;return{key:ie,provider:Y,model:re,label:Se(P.label)||re,note:Se(P.note),on:P.on===!0||Y===f&&re===b,ok:P.ok!==!1,why:Se(P.why)}}).filter((P)=>Boolean(P)):ji(A,H,f,b);return{chip:d,provider:f,model:b,effort:v,efforts:w,providers:A,favoriteKeys:H,favorites:O}}function Vt(e,t){let n=dt(t);return{...e,favoriteKeys:n,favorites:ji(e.providers,n,e.provider,e.model)}}function Di(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),i=(a)=>{if(n.length===0)return!0;let c=a.toLowerCase();return n.every((p)=>c.includes(p))},s=new Set(e.favoriteKeys),r=e.favorites.filter((a)=>i(`${a.provider} ${a.model} ${a.label} ${a.note}`)),o=[];for(let a of e.providers){let c=a.models.filter((p)=>i(`${a.provider} ${a.label} ${p.value} ${p.label} ${p.note}`)).map((p)=>{let l=p.value?ft(a.provider,p.value):"";return{...p,provider:a.provider,starrable:p.value!=="",starred:Boolean(l&&s.has(l))}});if(c.length>0||n.length===0&&!a.ok&&a.why)o.push({provider:a.provider,label:a.label,ok:a.ok,why:a.why,models:c})}return{favorites:r,groups:o,efforts:e.efforts}}var Fi={claude:{viewBox:"0 0 24 24",d:"m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"},codex:{viewBox:"0 0 256 260",d:"M239.184 106.203a64.716 64.716 0 0 0-5.576-53.103C219.452 28.459 191 15.784 163.213 21.74A65.586 65.586 0 0 0 52.096 45.22a64.716 64.716 0 0 0-43.23 31.36c-14.31 24.602-11.061 55.634 8.033 76.74a64.665 64.665 0 0 0 5.525 53.102c14.174 24.65 42.644 37.324 70.446 31.36a64.72 64.72 0 0 0 48.754 21.744c28.481.025 53.714-18.361 62.414-45.481a64.767 64.767 0 0 0 43.229-31.36c14.137-24.558 10.875-55.423-8.083-76.483Zm-97.56 136.338a48.397 48.397 0 0 1-31.105-11.255l1.535-.87l51.67-29.825a8.595 8.595 0 0 0 4.247-7.367v-72.85l21.845 12.636c.218.111.37.32.409.563v60.367c-.056 26.818-21.783 48.545-48.601 48.601Zm-104.466-44.61a48.345 48.345 0 0 1-5.781-32.589l1.534.921l51.722 29.826a8.339 8.339 0 0 0 8.441 0l63.181-36.425v25.221a.87.87 0 0 1-.358.665l-52.335 30.184c-23.257 13.398-52.97 5.431-66.404-17.803ZM23.549 85.38a48.499 48.499 0 0 1 25.58-21.333v61.39a8.288 8.288 0 0 0 4.195 7.316l62.874 36.272l-21.845 12.636a.819.819 0 0 1-.767 0L41.353 151.53c-23.211-13.454-31.171-43.144-17.804-66.405v.256Zm179.466 41.695l-63.08-36.63L161.73 77.86a.819.819 0 0 1 .768 0l52.233 30.184a48.6 48.6 0 0 1-7.316 87.635v-61.391a8.544 8.544 0 0 0-4.4-7.213Zm21.742-32.69l-1.535-.922l-51.619-30.081a8.39 8.39 0 0 0-8.492 0L99.98 99.808V74.587a.716.716 0 0 1 .307-.665l52.233-30.133a48.652 48.652 0 0 1 72.236 50.391v.205ZM88.061 139.097l-21.845-12.585a.87.87 0 0 1-.41-.614V65.685a48.652 48.652 0 0 1 79.757-37.346l-1.535.87l-51.67 29.825a8.595 8.595 0 0 0-4.246 7.367l-.051 72.697Zm11.868-25.58L128.067 97.3l28.188 16.218v32.434l-28.086 16.218l-28.188-16.218l-.052-32.434Z"},grok:{viewBox:"0 0 24 24",d:"M9.497 15.122 L16.811 9.491 C17.169 9.215 17.682 9.323 17.852 9.751 C18.752 12.013 18.35 14.73 16.561 16.596 C14.772 18.462 12.283 18.871 10.007 17.939 L7.522 19.139 C11.087 21.68 15.416 21.052 18.121 18.229 C20.267 15.991 20.931 12.941 20.31 10.19 L20.315 10.196 C19.414 6.155 20.537 4.54 22.837 1.237 C22.891 1.159 22.946 1.08 23 1 L19.974 4.156 L19.974 4.146 L9.495 15.124 M7.987 16.49 C5.429 13.941 5.87 9.996 8.053 7.721 C9.667 6.037 12.313 5.35 14.622 6.361 L17.102 5.166 C16.655 4.829 16.082 4.467 15.425 4.213 C12.455 2.938 8.9 3.573 6.485 6.088 C4.163 8.51 3.433 12.234 4.687 15.411 C5.624 17.786 4.088 19.466 2.541 21.162 C1.993 21.763 1.443 22.364 1 23 L7.985 16.492"},muse:{viewBox:"0 0 24 24",d:"M10.73.032c-1.333 0-2.032 1.016-2.032 2.285 0 2.223 2.127 4.953 4.318 4.953 1.301 0 2-.953 2-2.254 0-2.254-2.095-4.984-4.286-4.984m8.413 2.984c-1.968 0-3.397 2.73-3.397 4.825 0 1.556.794 3.016 2.254 3.016 2 0 3.365-2.762 3.365-4.794 0-1.523-.762-3.047-2.222-3.047M4.857 4.159c-1.968 0-3.778 1.016-3.778 2.54 0 1.65 2.16 2.793 4.254 2.793 1.873 0 3.778-.92 3.778-2.508 0-1.682-2.159-2.825-4.254-2.825m-.222 6.476C2.413 10.635 0 13.175 0 15.397c0 1.301.825 2.159 2.095 2.159 2.19 0 4.603-2.508 4.603-4.794 0-1.27-.761-2.127-2.063-2.127m16.667.698c-2.223 0-5.016 1.62-5.016 3.651 0 1.238 1.047 2.19 2.698 2.19 2.159 0 5.016-1.587 5.016-3.682 0-1.302-1.08-2.159-2.698-2.159M7.619 16c-1.524 0-2.38 1.746-2.38 3.429 0 2.063 1.269 4.54 3.047 4.54 1.524 0 2.38-1.81 2.38-3.461C10.667 18.57 9.46 16 7.62 16m6.571 1.016c-1.333 0-2.476.667-2.476 2.032 0 2.095 2.667 4.063 4.92 4.063 1.366 0 2.54-.73 2.54-2.063 0-2.032-2.698-4.032-4.984-4.032"},antigravity:{viewBox:"0 0 24 24",d:"M20.197 20.618 C21.318 21.459 23 20.898 21.459 19.357 C16.834 14.873 17.815 2.541 12.07 2.541 C6.325 2.541 7.306 14.873 2.682 19.357 C1 21.038 2.822 21.459 3.943 20.618 C8.287 17.675 8.006 12.49 12.07 12.49 C16.134 12.49 15.853 17.675 20.197 20.618 Z"},opencode:{viewBox:"0 0 24 24",d:"M22 24H2V0h20zM17 4.8H7v14.4h10z"},pi:{viewBox:"0 0 24 24",d:"M0 0v24h6v-6h6v-6H6V6h6v6h6V0Zm18 12v12h6V12Z"},omp:{viewBox:"0 0 24 24",d:"M1.44 3.86 L22.56 3.86 C23 3.86 23 3.86 23 4.3 L23 6.06 C23 6.5 23 6.5 22.56 6.5 L1.44 6.5 C1 6.5 1 6.5 1 6.06 L1 4.3 C1 3.86 1 3.86 1.44 3.86 Z M4.74 6.5 L6.5 6.5 C6.94 6.5 6.94 6.5 6.94 6.94 L6.94 19.7 C6.94 20.14 6.94 20.14 6.5 20.14 L4.74 20.14 C4.3 20.14 4.3 20.14 4.3 19.7 L4.3 6.94 C4.3 6.5 4.3 6.5 4.74 6.5 Z M15.74 6.5 L17.5 6.5 C17.94 6.5 17.94 6.5 17.94 6.94 L17.94 13.32 C17.94 13.76 17.94 13.76 17.5 13.76 L15.74 13.76 C15.3 13.76 15.3 13.76 15.3 13.32 L15.3 6.94 C15.3 6.5 15.3 6.5 15.74 6.5 Z M15.08 14.64 L18.16 14.64 C18.82 14.64 18.82 14.64 18.82 15.3 L18.82 17.5 C18.82 18.16 18.82 18.16 18.16 18.16 L15.08 18.16 C14.42 18.16 14.42 18.16 14.42 17.5 L14.42 15.3 C14.42 14.64 14.42 14.64 15.08 14.64 Z"}};var St="http://www.w3.org/2000/svg",$i=4,Oi=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function on(e){let t=document.createElementNS(St,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","15"),t.setAttribute("height","15"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("aria-hidden","true");for(let n of e){let i=document.createElementNS(St,"path");i.setAttribute("d",n),t.appendChild(i)}return t}function Mn(){return on(["M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z","M14 2v6h6","M16 13H8","M16 17H8","M10 9H8"])}function Gi(){return on(["M6 4l14 8-14 8z"])}function Vi(e){let t=document.createElementNS(St,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","13"),t.setAttribute("height","13"),t.setAttribute("fill",e?"currentColor":"none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");let n=document.createElementNS(St,"path");return n.setAttribute("d","M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5-4.8-4.6 6.6-.9z"),t.appendChild(n),t}function Ui(e){let t=(e||"").toLowerCase();if(t.includes("claude")||t.includes("anthropic"))return{mark:"claude",glyph:"A",color:"#d97757",title:"Claude"};if(t.includes("codex")||t.includes("openai"))return{mark:"codex",glyph:"O",color:"#10a37f",title:"Codex"};if(t.includes("gemini")||t.includes("antigravity")||t==="agy")return{mark:"antigravity",glyph:"G",color:"#4285f4",title:"Antigravity"};if(t.includes("grok"))return{mark:"grok",glyph:"X",color:"#6b7280",title:"Grok"};if(t.includes("muse"))return{mark:"muse",glyph:"M",color:"#8b5cf6",title:"Muse"};if(t.includes("opencode"))return{mark:"opencode",glyph:"C",color:"#2563eb",title:"OpenCode"};if(t.includes("omp")||t.includes("oh-my-pi"))return{mark:"omp",glyph:"Ω",color:"#c026d3",title:"Oh My Pi"};if(t==="pi"||t.startsWith("pi/")||t.startsWith("@pi"))return{mark:"pi",glyph:"π",color:"#db2777",title:"Pi"};return{glyph:"●",color:"var(--accent)",title:e||"Model"}}function Wi(e){let t=Fi[e];if(!t||!t.d)return null;let n=document.createElementNS(St,"svg");n.setAttribute("viewBox",t.viewBox||"0 0 24 24"),n.setAttribute("width","14"),n.setAttribute("height","14"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");let i=document.createElementNS(St,"path");return i.setAttribute("d",t.d),n.appendChild(i),n}class Tn{popupEl;attachStripEl;planBarEl;fileInput;textarea;memoryEl;memoryFill;memoryText;modelBtn;providerMarkEl;modelTextEl;ctxEl;modelPickerEl;modelSearchInput;modelPickerBodyEl;modelPickerEffortsEl;modelPickerOpen=!1;modelPickerLoading=!1;modelPickerSnap=null;modelPickerQuery="";modelPickerFocusIdx=-1;onDocMouseDown;planChipBtn;planChipIconHost;planChipLbl;attachBtn;voiceBtn;sendBtn;stopBtn;errorEl;replyEl;cb;commands=[];popupMode="none";filteredSlash=[];mentionItems=[];popupIdx=0;enabled=!1;attachments=[];planMode=null;constructor(e,t){this.cb=t;let n=document.createElement("div");n.className="bp-composer",n.setAttribute("data-testid","composer");let i=document.createElement("div");i.className="bp-composer-inner",this.popupEl=document.createElement("div"),this.popupEl.className="bp-composer-popup bp-hidden",this.popupEl.setAttribute("data-testid","slash-menu"),this.errorEl=document.createElement("div"),this.errorEl.className="bp-composer-err bp-hidden",this.replyEl=document.createElement("div"),this.replyEl.className="bp-reply-strip bp-hidden",this.replyEl.setAttribute("data-testid","composer-reply"),this.attachStripEl=document.createElement("div"),this.attachStripEl.className="bp-attach-strip bp-hidden",this.attachStripEl.setAttribute("data-testid","composer-attachments"),this.planBarEl=document.createElement("div"),this.planBarEl.className="bp-plan-bar bp-hidden",this.planBarEl.setAttribute("data-testid","composer-plan-bar"),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="image/png,image/jpeg,image/webp,image/gif",this.fileInput.multiple=!0,this.fileInput.className="bp-hidden",this.fileInput.setAttribute("data-testid","composer-file-input"),this.fileInput.addEventListener("change",()=>{if(this.fileInput.files)this.addFiles(Array.from(this.fileInput.files));this.fileInput.value=""}),this.textarea=document.createElement("textarea"),this.textarea.className="bp-composer-input",this.textarea.rows=2,this.textarea.placeholder=m("composer.placeholder","Ask anything: @bot, >thread, %project, #room, $skill, /btw"),this.textarea.setAttribute("data-testid","composer-input");let s=document.createElement("div");s.className="bp-composer-bar";let r=document.createElement("button");r.type="button",r.className="bp-composer-model",r.setAttribute("data-testid","composer-model-chip"),r.setAttribute("aria-haspopup","dialog"),r.setAttribute("aria-expanded","false"),r.title=m("composer.model.tip","Choose the model and effort"),this.modelBtn=r,this.providerMarkEl=document.createElement("span"),this.providerMarkEl.className="bp-provider-mark",this.providerMarkEl.textContent="●",this.modelTextEl=document.createElement("span"),this.modelTextEl.className="bp-model-text",this.modelTextEl.textContent="default",this.ctxEl=document.createElement("span"),this.ctxEl.className="bp-ctx-pct bp-hidden",this.ctxEl.setAttribute("data-testid","composer-ctx");let o=document.createElement("span");o.className="bp-model-caret",o.textContent="▾",r.append(this.providerMarkEl,this.modelTextEl,this.ctxEl,o),r.addEventListener("click",()=>{this.toggleModelPicker()}),this.modelPickerEl=document.createElement("div"),this.modelPickerEl.className="bp-model-picker bp-hidden",this.modelPickerEl.setAttribute("data-testid","model-picker"),this.modelPickerEl.setAttribute("role","dialog");let a=document.createElement("div");a.className="bp-mp-search-wrap",this.modelSearchInput=document.createElement("input"),this.modelSearchInput.type="search",this.modelSearchInput.className="bp-mp-search",this.modelSearchInput.placeholder=m("gpui.search.models","Search models"),this.modelSearchInput.setAttribute("data-testid","model-picker-search"),this.modelSearchInput.addEventListener("input",()=>{this.modelPickerQuery=this.modelSearchInput.value,this.modelPickerFocusIdx=-1,this.renderModelPicker()}),this.modelSearchInput.addEventListener("keydown",(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),this.closeModelPicker(),this.textarea.focus();return}if(l.key==="ArrowDown"||l.key==="ArrowUp"){let h=this.modelPickerFocusableButtons();if(h.length===0)return;l.preventDefault();let d=l.key==="ArrowDown"?1:-1;this.modelPickerFocusIdx=this.modelPickerFocusIdx<0?d>0?0:h.length-1:(this.modelPickerFocusIdx+d+h.length)%h.length,this.updateModelPickerKbdFocus(h);return}if(l.key==="Enter"){let h=this.modelPickerFocusableButtons(),d=this.modelPickerFocusIdx>=0&&this.modelPickerFocusIdxthis.cb.onCyclePlanMode?.()),this.memoryEl=document.createElement("div"),this.memoryEl.className="bp-composer-memory bp-hidden",this.memoryEl.setAttribute("data-testid","composer-memory");let c=document.createElement("div");c.className="bp-memory-meter",this.memoryFill=document.createElement("div"),this.memoryFill.className="bp-memory-fill",c.appendChild(this.memoryFill),this.memoryText=document.createElement("span"),this.memoryEl.append(c,this.memoryText);let p=document.createElement("div");p.className="bp-composer-btns",this.attachBtn=document.createElement("button"),this.attachBtn.type="button",this.attachBtn.className="icon bp-composer-tool",this.attachBtn.title=m("web.composer.attach","Attach image"),this.attachBtn.setAttribute("aria-label",m("web.composer.attach","Attach image")),this.attachBtn.setAttribute("data-testid","composer-attach"),this.attachBtn.appendChild(on(["M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"])),this.attachBtn.addEventListener("click",()=>this.fileInput.click()),this.voiceBtn=document.createElement("button"),this.voiceBtn.type="button",this.voiceBtn.className="icon bp-composer-tool",this.voiceBtn.title=m("web.composer.voice","Voice dictation"),this.voiceBtn.setAttribute("aria-label",m("web.composer.voice","Voice dictation")),this.voiceBtn.setAttribute("data-testid","composer-voice"),this.voiceBtn.appendChild(on(["M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z","M19 10v2a7 7 0 0 1-14 0v-2","M12 19v4","M8 23h8"])),this.voiceBtn.addEventListener("click",()=>this.cb.onToggleVoice?.()),this.stopBtn=document.createElement("button"),this.stopBtn.type="button",this.stopBtn.className="primary stop bp-hidden",this.stopBtn.textContent=m("composer.stop","Stop"),this.stopBtn.setAttribute("data-testid","composer-stop"),this.stopBtn.addEventListener("click",()=>this.cb.onInterrupt()),this.sendBtn=document.createElement("button"),this.sendBtn.type="button",this.sendBtn.className="primary bp-send-btn",this.sendBtn.textContent=m("composer.send","Send"),this.sendBtn.setAttribute("data-testid","composer-send"),this.sendBtn.addEventListener("click",()=>this.submit()),p.append(this.attachBtn,this.voiceBtn,this.stopBtn,this.sendBtn),s.append(r,this.planChipBtn,this.memoryEl,p),i.append(this.modelPickerEl,this.popupEl,this.errorEl,this.replyEl,this.attachStripEl,this.planBarEl,this.fileInput,this.textarea,s),n.appendChild(i),e.appendChild(n),this.onDocMouseDown=(l)=>{if(!this.modelPickerEl.isConnected){document.removeEventListener("mousedown",this.onDocMouseDown);return}if(!this.modelPickerOpen)return;let h=l.target;if(h&&(this.modelPickerEl.contains(h)||this.modelBtn.contains(h)))return;this.closeModelPicker()},document.addEventListener("mousedown",this.onDocMouseDown),this.textarea.addEventListener("paste",(l)=>{let h=l.clipboardData?.items;if(!h)return;let d=[];for(let u=0;u0)l.preventDefault(),this.addFiles(d)}),this.textarea.addEventListener("input",()=>{this.autoGrow(),this.clearError(),this.updatePopups()}),this.textarea.addEventListener("keydown",(l)=>{if(this.popupMode!=="none"){let h=this.popupMode==="slash"?this.filteredSlash.length:this.mentionItems.length;if(l.key==="ArrowDown"){l.preventDefault(),this.popupIdx=(this.popupIdx+1)%Math.max(1,h),this.renderPopup();return}if(l.key==="ArrowUp"){l.preventDefault(),this.popupIdx=(this.popupIdx-1+Math.max(1,h))%Math.max(1,h),this.renderPopup();return}if(l.key==="Tab"||l.key==="Enter"&&!l.shiftKey&&this.shouldCompleteOnEnter()){l.preventDefault(),this.applyPopupChoice(this.popupIdx);return}if(l.key==="Escape"){l.preventDefault(),this.closePopup();return}}if(l.key==="Tab"&&l.shiftKey&&this.planMode!==null){l.preventDefault(),this.cb.onCyclePlanMode?.();return}if(l.key==="Enter"&&!l.shiftKey)l.preventDefault(),this.submit()})}setCommands(e){this.commands=e.map((t)=>({...t,word:t.word.replace(/^\//,"")}))}setModelChip(e,t,n){let i=Ui(t),s=i.mark?Wi(i.mark):null;if(s)this.providerMarkEl.replaceChildren(s);else this.providerMarkEl.textContent=i.glyph;if(this.providerMarkEl.style.color=i.color,this.providerMarkEl.title=i.title,this.modelTextEl.textContent=e||"default",typeof n==="number"&&Number.isFinite(n)&&n>=0)this.ctxEl.textContent=`ctx ${Math.round(n)}%`,this.ctxEl.classList.remove("bp-hidden");else this.ctxEl.textContent="",this.ctxEl.classList.add("bp-hidden")}setFeatures(e,t){this.attachBtn.classList.toggle("bp-hidden",!e),this.voiceBtn.classList.toggle("bp-hidden",!t)}setVoiceRecording(e){this.voiceBtn.classList.toggle("recording",e),this.voiceBtn.setAttribute("aria-pressed",e?"true":"false")}setVoiceLevel(e){this.voiceBtn.setAttribute("data-level",String(e))}getDraft(){return this.textarea.value}getCaret(){return this.textarea.selectionStart??this.textarea.value.length}setMemory(e){if(this.memoryEl.classList.toggle("bp-hidden",!e),!e)return;let t=e.total??0,n=t>0?Math.min(1,(e.done??0)/t):1;this.memoryFill.style.width=`${Math.round(n*100)}%`,this.memoryFill.dataset.state=e.state??"",this.memoryText.textContent=e.line??"",this.memoryEl.title=[e.status,e.lines,e.viewLine].filter(Boolean).join(` -`)}setPlanMode(e){if(this.planMode=e,this.textarea.classList.remove("is-plan","is-plan-exec"),this.sendBtn.classList.remove("is-plan","is-plan-exec"),this.planChipBtn.classList.remove("is-plan","is-exec"),this.planBarEl.classList.remove("is-exec"),!e){this.planChipBtn.classList.add("bp-hidden"),this.planChipBtn.setAttribute("aria-pressed","false"),this.planBarEl.classList.add("bp-hidden"),this.planBarEl.replaceChildren(),this.sendBtn.textContent=m("composer.send","Send");return}let t=e.phase,n=t!=="off",i=t==="armed"||t==="planning"||t==="pending",s=t==="executing";this.planChipBtn.classList.remove("bp-hidden"),this.planChipBtn.classList.toggle("is-plan",i),this.planChipBtn.classList.toggle("is-exec",s),this.planChipBtn.setAttribute("aria-pressed",n?"true":"false");let r=`${m("gpui.planmode.tip","Plan before acting (1 turn, always, or off)")} · Shift+Tab`;if(this.planChipBtn.title=r,this.planChipBtn.setAttribute("aria-label",r),this.planChipIconHost.replaceChildren(s?Gi():Mn()),this.planChipLbl.textContent=s?m("gpui.planmode.chip.building","Building"):t==="pending"?m("gpui.mgmt.fab.reviewbtn","Review"):i&&e.once?m("gpui.planmode.chip.once","Plan · 1t"):m("gpui.mgmt.plan.tab","Plan"),this.textarea.classList.toggle("is-plan",i),this.textarea.classList.toggle("is-plan-exec",s),this.sendBtn.classList.toggle("is-plan",i),this.sendBtn.classList.toggle("is-plan-exec",s),this.sendBtn.textContent=i?m("gpui.mgmt.plan.tab","Plan"):m("composer.send","Send"),!n){this.planBarEl.classList.add("bp-hidden"),this.planBarEl.replaceChildren();return}this.planBarEl.classList.remove("bp-hidden"),this.planBarEl.classList.toggle("is-exec",s);let o=document.createElement("span");o.className="bp-plan-bar-ic",o.appendChild(s?Gi():Mn());let a=document.createElement("span");a.className="bp-plan-bar-text",a.textContent=t==="armed"&&e.once?m("gpui.planmode.bar.once","Plan mode (1 turn) — explores and proposes a plan before editing"):t==="armed"?m("gpui.planmode.bar.always","Plan mode — explores and proposes a plan before editing"):t==="planning"?m("gpui.planmode.bar.planning","Planning — drafting a plan before edits"):t==="pending"?m("gpui.planmode.bar.pending","Proposed plan awaits review below"):m("gpui.planmode.bar.executing","Building the approved plan");let c=[o,a];if(t==="armed"||t==="planning"){let p=document.createElement("div");p.className="bp-plan-scopes";let l=(h,d,u,f)=>{let b=document.createElement("button");return b.type="button",b.className="bp-plan-scope-btn"+(d?" active":""),b.textContent=h,b.disabled=!this.enabled,b.setAttribute("data-testid",f),b.addEventListener("click",()=>this.cb.onSetPlanMode?.(u)),b};p.append(l(m("gpui.planmode.scope.once","1 turn"),e.once,"once","plan-scope-once"),l(m("gpui.planmode.scope.always","Always"),!e.once,"always","plan-scope-always"),l(m("gpui.bots.recall.off","Off"),!1,"off","plan-scope-off")),c.push(p)}this.planBarEl.replaceChildren(...c)}setState(e,t){if(this.enabled=e,this.textarea.disabled=!e,this.sendBtn.disabled=!e,this.attachBtn.disabled=!e,this.voiceBtn.disabled=!e,this.modelBtn.disabled=!e,!e)this.closeModelPicker();this.planChipBtn.disabled=!e,this.planBarEl.querySelectorAll(".bp-plan-scope-btn").forEach((n)=>{n.disabled=!e}),this.stopBtn.classList.toggle("bp-hidden",!t)}destroy(){document.removeEventListener("mousedown",this.onDocMouseDown)}isModelPickerOpen(){return this.modelPickerOpen}closeModelPicker(){if(!this.modelPickerOpen)return;this.modelPickerOpen=!1,this.modelPickerFocusIdx=-1,this.modelPickerEl.classList.add("bp-hidden"),this.modelBtn.classList.remove("is-open"),this.modelBtn.setAttribute("aria-expanded","false")}modelPickerFocusableButtons(){return Array.from(this.modelPickerBodyEl.querySelectorAll(".bp-mp-row-main:not(:disabled)"))}updateModelPickerKbdFocus(e){e.forEach((t,n)=>{let i=n===this.modelPickerFocusIdx;if(t.classList.toggle("is-kbd",i),i)t.scrollIntoView({block:"nearest"})})}updateFavoriteModels(e){if(!this.modelPickerSnap)return;if(this.modelPickerSnap=Vt(this.modelPickerSnap,e),this.modelPickerOpen)this.renderModelPicker()}async toggleModelPicker(){if(!this.enabled)return;if(this.modelPickerOpen){this.closeModelPicker();return}this.closePopup(),this.modelPickerOpen=!0,this.modelPickerQuery="",this.modelPickerFocusIdx=-1,this.modelSearchInput.value="",this.modelPickerEl.classList.remove("bp-hidden"),this.modelBtn.classList.add("is-open"),this.modelBtn.setAttribute("aria-expanded","true"),this.modelPickerLoading=!0,this.renderModelPicker(),this.modelSearchInput.focus(),await this.reloadModelPicker()}async reloadModelPicker(){if(!this.cb.onLoadModelPicker){this.modelPickerLoading=!1,this.renderModelPicker();return}try{let e=await this.cb.onLoadModelPicker();if(!this.modelPickerOpen)return;this.modelPickerSnap=Hi(e,this.cb.getFavoriteModels?.()??[])}catch{}finally{if(this.modelPickerLoading=!1,this.modelPickerOpen)this.renderModelPicker()}}async toggleFavoriteInPicker(e,t){if(!this.modelPickerSnap)return;let n=this.modelPickerSnap,i=ft(e,t);if(!i)return;let s=n.favoriteKeys.includes(i),r=Nn(n.favoriteKeys,e,t);if(r.keys.length===n.favoriteKeys.length&&r.starred===s)return;if(this.modelPickerSnap=Vt(n,r.keys),this.renderModelPicker(),!this.cb.onToggleFavorite)return;try{let o=await this.cb.onToggleFavorite(e,t,r.starred);if(Array.isArray(o)&&this.modelPickerSnap){if(this.modelPickerSnap=Vt(this.modelPickerSnap,dt(o)),this.modelPickerOpen)this.renderModelPicker()}}catch(o){if(this.modelPickerSnap){let a=this.cb.getFavoriteModels?.(),c=Array.isArray(a)?dt(a):Nn(this.modelPickerSnap.favoriteKeys,e,t,!r.starred).keys;if(this.modelPickerSnap=Vt(this.modelPickerSnap,c),this.modelPickerOpen)this.renderModelPicker()}this.showError(o instanceof Error&&o.message?o.message:"Could not update favorite model")}}renderProviderGlyph(e){let t=Ui(e),n=document.createElement("span");n.className="bp-mp-mark",n.style.color=t.color,n.title=t.title;let i=t.mark?Wi(t.mark):null;if(i)n.appendChild(i);else n.textContent=t.glyph;return n}makeStarButton(e,t,n,i="model-star"){let s=document.createElement("button");s.type="button",s.className="bp-mp-star"+(n?" is-starred":"");let r=n?m("gpui.picker.favorite.remove","Remove from favorites"):m("gpui.picker.favorite.add","Add to favorites");return s.title=r,s.setAttribute("aria-label",r),s.setAttribute("aria-pressed",n?"true":"false"),s.setAttribute("data-testid",`${i}-${e}-${t}`),s.appendChild(Vi(n)),s.addEventListener("click",(o)=>{o.preventDefault(),o.stopPropagation(),this.toggleFavoriteInPicker(e,t)}),s}renderModelPicker(){if(!this.modelPickerOpen)return;if(this.modelPickerFocusIdx=-1,!this.modelPickerSnap){let i=document.createElement("div");i.className="bp-mp-empty",i.textContent=this.modelPickerLoading?"…":m("gpui.no.models","No models"),this.modelPickerBodyEl.replaceChildren(i),this.modelPickerEffortsEl.classList.add("bp-hidden"),this.modelPickerEffortsEl.replaceChildren();return}let e=Di(this.modelPickerSnap,this.modelPickerQuery),t=document.createDocumentFragment();if(e.favorites.length>0){let i=document.createElement("div");i.className="bp-mp-section bp-mp-favorites",i.setAttribute("data-testid","model-picker-favorites");let s=document.createElement("div");s.className="bp-mp-head";let r=document.createElement("span");r.className="bp-mp-head-star",r.appendChild(Vi(!0));let o=document.createElement("span");o.textContent=m("gpui.picker.favorites","Favorites"),s.append(r,o),i.appendChild(s);for(let a of e.favorites){let c=document.createElement("div");c.className="bp-mp-row"+(a.on?" is-active":"")+(!a.ok?" is-disabled":""),c.setAttribute("data-testid",`model-fav-row-${a.provider}-${a.model}`);let p=document.createElement("button");if(p.type="button",p.className="bp-mp-row-main",p.disabled=!a.ok,!a.ok&&a.why)p.title=a.why;let l=document.createElement("span");l.className="bp-mp-check",l.textContent=a.on?"✓":"";let h=document.createElement("span");h.className="bp-mp-name",h.textContent=a.label;let d=document.createElement("span");d.className="bp-mp-note",d.textContent=!a.ok&&a.why?he(a.why):a.note&&a.note!==a.label?he(a.note):a.provider,p.append(l,this.renderProviderGlyph(a.provider),h,d),p.addEventListener("click",()=>{if(!a.ok)return;this.closeModelPicker(),this.textarea.focus(),this.cb.onSelectModel?.(a.provider,a.model)}),c.append(p,this.makeStarButton(a.provider,a.model,!0,"model-fav-star")),i.appendChild(c)}t.appendChild(i)}let n=document.createElement("div");if(n.className="bp-mp-groups",n.setAttribute("data-testid","model-picker-groups"),e.groups.length===0){let i=document.createElement("div");i.className="bp-mp-empty",i.textContent=this.modelPickerQuery.trim()?m("gpui.nothing.matches","Nothing matches"):m("gpui.no.models","No models"),n.appendChild(i)}else for(let i of e.groups){let s=document.createElement("div");s.className="bp-mp-group";let r=document.createElement("div");r.className="bp-mp-group-head";let o=document.createElement("span");if(o.className="bp-mp-group-title",o.textContent=i.label,r.append(this.renderProviderGlyph(i.provider),o),!i.ok&&i.why){let a=document.createElement("span");a.className="bp-mp-group-why",a.textContent=he(i.why),r.appendChild(a)}s.appendChild(r);for(let a of i.models){let c=document.createElement("div");c.className="bp-mp-row"+(a.on?" is-active":"")+(!a.ok?" is-disabled":""),c.setAttribute("data-testid",`model-row-${i.provider}-${a.value||"default"}`);let p=document.createElement("button");if(p.type="button",p.className="bp-mp-row-main",p.disabled=!a.ok,!a.ok&&a.why)p.title=a.why;let l=document.createElement("span");l.className="bp-mp-check",l.textContent=a.on?"✓":"";let h=document.createElement("span");h.className="bp-mp-name",h.textContent=a.label;let d=document.createElement("span");if(d.className="bp-mp-note",d.textContent=a.note&&a.note!==a.label?he(a.note):"",p.append(l,h,d),p.addEventListener("click",()=>{if(!a.ok)return;this.closeModelPicker(),this.textarea.focus(),this.cb.onSelectModel?.(i.provider,a.value)}),c.appendChild(p),a.starrable)c.appendChild(this.makeStarButton(i.provider,a.value,a.starred));s.appendChild(c)}n.appendChild(s)}if(t.appendChild(n),this.modelPickerBodyEl.replaceChildren(t),e.efforts.length>0){let i=document.createDocumentFragment(),s=document.createElement("span");s.className="bp-mp-efforts-lbl",s.textContent=m("model.col.effort","Effort"),i.appendChild(s);for(let r of e.efforts){let o=document.createElement("button");o.type="button",o.className="bp-mp-effort"+(r.on?" active":""),o.textContent=r.label,o.addEventListener("click",()=>{Promise.resolve(this.cb.onSelectEffort?.(r.value)).then(()=>{if(this.modelPickerOpen)this.reloadModelPicker()})}),i.appendChild(o)}this.modelPickerEffortsEl.replaceChildren(i),this.modelPickerEffortsEl.classList.remove("bp-hidden")}else this.modelPickerEffortsEl.classList.add("bp-hidden"),this.modelPickerEffortsEl.replaceChildren()}setDraft(e){this.textarea.value=e,this.autoGrow(),this.textarea.focus()}setReply(e,t,n){if(!e){this.replyEl.replaceChildren(),this.replyEl.classList.add("bp-hidden");return}let i=document.createElement("button");i.type="button",i.className="bp-reply-strip-body",i.setAttribute("data-testid","composer-reply-go");let s=document.createElement("span");s.className="bp-reply-strip-who",s.textContent=e.who;let r=document.createElement("span");if(r.className="bp-reply-strip-line",r.textContent=m("gpui.b.replying.to","↩ Replying to: {line}",{line:e.line}),i.append(s,r),t)i.addEventListener("click",t);let o=document.createElement("button");o.type="button",o.className="icon bp-reply-strip-drop",o.textContent="×";let a=m("reply.cancel","Cancel reply");if(o.title=a,o.setAttribute("aria-label",a),o.setAttribute("data-testid","composer-reply-drop"),n)o.addEventListener("click",n);this.replyEl.replaceChildren(i,o),this.replyEl.classList.remove("bp-hidden"),this.textarea.focus()}prependDraft(e){let t=this.textarea.value;this.textarea.value=t?`${e} -${t}`:e,this.autoGrow(),this.textarea.focus()}showError(e,t){let n=document.createElement("span");if(n.textContent=he(e),t){let i=document.createElement("button");i.type="button",i.className="bp-composer-err-act",i.setAttribute("data-testid","composer-err-accounts"),i.textContent=t.label,i.addEventListener("click",t.onClick),this.errorEl.replaceChildren(n,i)}else this.errorEl.replaceChildren(n);this.errorEl.classList.remove("bp-hidden")}clearError(){this.errorEl.replaceChildren(),this.errorEl.classList.add("bp-hidden")}focus(){this.textarea.focus()}refreshLocale(){if(this.textarea.placeholder=m("composer.placeholder","Ask anything: @bot, >thread, %project, #room, $skill, /btw"),this.attachBtn.title=m("web.composer.attach","Attach image"),this.attachBtn.setAttribute("aria-label",m("web.composer.attach","Attach image")),this.voiceBtn.title=m("web.composer.voice","Voice dictation"),this.voiceBtn.setAttribute("aria-label",m("web.composer.voice","Voice dictation")),this.modelBtn.title=m("composer.model.tip","Choose the model and effort"),this.modelSearchInput.placeholder=m("gpui.search.models","Search models"),this.sendBtn.textContent=m("composer.send","Send"),this.stopBtn.textContent=m("composer.stop","Stop"),this.setPlanMode(this.planMode),this.modelPickerOpen)this.renderModelPicker()}autoGrow(){this.textarea.style.height="auto",this.textarea.style.height=`${Math.min(180,Math.max(54,this.textarea.scrollHeight))}px`}shouldCompleteOnEnter(){if(this.popupMode==="mention")return!0;if(this.popupMode==="slash"){let e=this.textarea.value;return e.startsWith("/")&&!e.includes(" ")}return!1}updatePopups(){let e=this.textarea.value;if(e.startsWith("/")&&!e.includes(" ")&&!e.includes(` -`)){let n=e.slice(1).toLowerCase();if(this.filteredSlash=this.commands.filter((i)=>i.word.toLowerCase().startsWith(n)),this.filteredSlash.length>0){this.popupMode="slash",this.popupIdx=Math.min(this.popupIdx,this.filteredSlash.length-1),this.renderPopup();return}}let t=/(?:^|\s)([@>%#])([a-zA-Z0-9._-]{1,32})$/.exec(e.slice(0,this.textarea.selectionStart));if(t){let n=t[1],i=t[2];this.cb.onQueryMentions(i,n).then((s)=>{if(s.length>0)this.mentionItems=s,this.popupMode="mention",this.popupIdx=0,this.renderPopup();else if(this.popupMode==="mention")this.closePopup()});return}this.closePopup()}closePopup(){this.popupMode="none",this.popupEl.classList.add("bp-hidden"),this.popupEl.replaceChildren()}renderPopup(){let e=document.createDocumentFragment();if(this.popupMode==="slash")this.filteredSlash.forEach((t,n)=>{let i=document.createElement("button");i.type="button",i.className="bp-popup-row"+(n===this.popupIdx?" active":""),i.setAttribute("data-testid",`slash-item-${t.word}`);let s=document.createElement("span");s.className="bp-popup-name",s.textContent=`/${t.word}`;let r=document.createElement("span");r.className="bp-popup-desc",r.textContent=t.desc||t.label,i.append(s,r),i.addEventListener("mousedown",(o)=>{o.preventDefault(),this.applyPopupChoice(n)}),e.appendChild(i)});else if(this.popupMode==="mention")this.mentionItems.forEach((t,n)=>{let i=document.createElement("button");i.type="button",i.className="bp-popup-row"+(n===this.popupIdx?" active":"");let s=document.createElement("span");s.className="bp-popup-name",s.textContent=t.word||`${t.sigil}${t.label}`;let r=document.createElement("span");r.className="bp-popup-desc",r.textContent=t.detail||t.label,i.append(s,r),i.addEventListener("mousedown",(o)=>{o.preventDefault(),this.applyPopupChoice(n)}),e.appendChild(i)});this.popupEl.replaceChildren(e),this.popupEl.classList.remove("bp-hidden")}applyPopupChoice(e){if(this.popupMode==="slash"){let t=this.filteredSlash[e];if(t)this.textarea.value=`/${t.word} `,this.autoGrow(),this.textarea.focus();this.closePopup()}else if(this.popupMode==="mention"){let t=this.mentionItems[e];if(t){let n=this.textarea.selectionStart,i=this.textarea.value.slice(0,n),s=this.textarea.value.slice(n),r=i.replace(/([@>%#][a-zA-Z0-9._-]{1,32})$/,`${t.word} `);this.textarea.value=r+s,this.textarea.selectionStart=this.textarea.selectionEnd=r.length,this.textarea.focus()}this.closePopup()}}async addFiles(e){this.clearError();for(let t of e){if(!Oi.has(t.type)){this.showError(m("web.composer.unsupported","Unsupported image type: {type}",{type:t.type||t.name}));continue}if(this.attachments.length>=$i){this.showError(m("web.composer.maximages","At most {max} images per message.",{max:$i}));break}let n=await new Promise((s,r)=>{let o=new FileReader;o.onload=()=>s(String(o.result||"")),o.onerror=()=>r(Error("read failed")),o.readAsDataURL(t)}).catch(()=>""),i=n.indexOf(",");if(i<0)continue;this.attachments.push({name:t.name||`image-${this.attachments.length+1}.png`,mime:t.type,data:n.slice(i+1),previewUrl:n})}this.renderAttachments()}renderAttachments(){if(this.attachments.length===0){this.attachStripEl.classList.add("bp-hidden"),this.attachStripEl.replaceChildren();return}let e=document.createDocumentFragment();this.attachments.forEach((t,n)=>{let i=document.createElement("div");i.className="bp-attach-chip";let s=document.createElement("img");s.src=t.previewUrl,s.alt=t.name,s.className="bp-attach-thumb";let r=document.createElement("button");r.type="button",r.className="icon bp-attach-rm",r.textContent="×",r.title=m("common.remove","Remove"),r.addEventListener("click",()=>{this.attachments.splice(n,1),this.renderAttachments()}),i.append(s,r),e.appendChild(i)}),this.attachStripEl.replaceChildren(e),this.attachStripEl.classList.remove("bp-hidden")}submit(){if(!this.enabled)return;let e=this.textarea.value.trim();if(!e&&this.attachments.length===0)return;if(this.closePopup(),this.clearError(),e.startsWith("/")&&this.attachments.length===0){let n=e.slice(1).split(/\s+/)[0]?.toLowerCase()??"";if(this.commands.some((i)=>i.word.toLowerCase()===n)){this.textarea.value="",this.autoGrow(),this.cb.onRunCommand(e);return}}let t=this.attachments.map(({name:n,mime:i,data:s})=>({name:n,mime:i,data:s}));this.attachments=[],this.renderAttachments(),this.textarea.value="",this.autoGrow(),this.cb.onSend(e,t)}}async function _i(e,t=fetch){let n=await t("/auth/web/logout",{method:"POST",credentials:"same-origin",redirect:"error",headers:{"Content-Type":"application/json"},body:"{}"});if(n.status!==200||(await n.json()).state!=="revoked")throw Error("Logout was not confirmed");e()}var qr=new Set(["bom","checks","life","plan","fab"]);function an(e){if(!e||!Array.isArray(e.panels))return[];return e.panels.filter((t)=>t&&typeof t.id==="string"&&qr.has(t.id))}function Xi(e){let t=e?.badge?.n??0;if(!Number.isFinite(t)||t<=0)return null;return{text:t>99?"99+":String(Math.floor(t)),tone:e?.badge?.tone==="bad"?"bad":"warn"}}function ln(e,t=22){let n=e.join(", ");if(n.length<=t)return n;let i="";for(let s=0;s0?` +${a}`.length:0)>t)return i?`${i} +${e.length-s}`:`${e[0]} +${e.length-1}`;i=o}return i}function Lt(e){if(!Number.isFinite(e)||e<0)return"?";if(e<1000)return String(Math.round(e));if(e<1e6){let n=e/1000;return n<10?`${n.toFixed(1).replace(/\.0$/,"")}k`:`${Math.round(n)}k`}let t=e/1e6;return t<10?`${t.toFixed(1).replace(/\.0$/,"")}M`:`${Math.round(t)}M`}function At(e){if(!Number.isFinite(e))return"";if(e>=1)return`$${e.toFixed(2)}`;let t=e.toFixed(4).replace(/0+$/,"");return(t.split(".")[1]??"").length<2?`$${e.toFixed(2)}`:`$${t}`}var Kr=new Set(["0201","0402","0603","0805","1206","1210","1812","2010","2512"]),Jr=new Set(["QFN","DFN","SOT","SOIC","SOP","SSOP","TSSOP","MSOP","QFP","LQFP","TQFP","BGA","WLCSP","SOD","TO","SON","LGA"]);function Qi(e){if(!e)return"";let t=e.indexOf(":"),i=(t>=0?e.slice(t+1):e).split("_");for(let o of i)if(Kr.has(o))return o;let s=i[0]??"",r=s.replace(/[^a-zA-Z].*$/,"").toUpperCase();if(Jr.has(r)){let o=s.split("-");if(o.length>=2&&/^\d+$/.test(o[1]))return`${o[0]}-${o[1]}`;return o[0]}return i.slice(0,2).join("_")}function Zi(e){let t=e?.status??"";if(!t)return null;let n=typeof e?.stock==="number"?e.stock:-1;if(t==="checking")return{text:"…",tone:"faint"};if(t==="unknown")return{text:"?",tone:"faint"};if(t==="out")return{text:`out ${Lt(Math.max(n,0))}`,tone:"bad"};if(t==="low")return{text:`low ${Lt(n)}`,tone:"warn"};return{text:Lt(n),tone:"ok"}}function es(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;return e.filter((i)=>{let s=[(i.refs??[]).join(" "),i.value??"",i.footprint??"",i.mpn??"",i.fab??""].join(" ").toLowerCase();return n.every((r)=>r==="dnp"&&Boolean(i.dnp)||s.includes(r))})}function ts(e,t){if(!t)return e;return e.filter((n)=>n.source===t)}function In(e){if(e==="active")return{label:"Active",tone:"ok"};if(e==="nrnd")return{label:"NRND",tone:"warn"};if(e==="eol")return{label:"EOL",tone:"bad"};return{label:"Unknown",tone:"faint"}}function cn(e){if(!Number.isFinite(e)||e<=0)return"";let t=new Date(e*1000),n=t.getUTCFullYear(),i=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0");return`${n}-${i}-${s}`}function ns(e){return e.state==="routed"||e.state==="verified"}function is(e){switch(e.state){case"approved":return"✓";case"edited":return"✎";case"verified":return"✓✓";case"routed":return"100%";case"rejected":case"failed":return"✗";case"routing":return typeof e.routed==="number"&&typeof e.total==="number"&&e.total>0?`${e.routed}/${e.total}`:"…";case"blocked":return`⚠ ${Math.max(1,e.problems??1)}`;default:return""}}function ss(e){switch(e.status){case"blocked":return{key:"gpui.mgmt.plan.st.blocked",label:"Blocked",tone:"bad"};case"routing":return{key:"gpui.mgmt.plan.st.routing",label:"Routing",tone:"accent"};case"awaiting":return{key:"gpui.mgmt.plan.st.awaiting",label:"Awaiting review",tone:"warn"};case"verified":return{key:"gpui.mgmt.plan.st.verified",label:"Verified",tone:"ok"};case"routed":return{key:"gpui.mgmt.plan.st.routed",label:"Routed",tone:"ok"};case"ready":return{key:"gpui.mgmt.plan.st.approved",label:"Approved",tone:"accent"};case"partial":return{key:"gpui.mgmt.plan.st.partial",label:"Partial",tone:"warn"};case"rejected":return{key:"gpui.mgmt.plan.st.rejected",label:"Rejected",tone:"bad"};default:if((e.blocked??0)>0)return{key:"gpui.mgmt.plan.st.blocked",label:"Blocked",tone:"bad"};if(e.routing)return{key:"gpui.mgmt.plan.st.routing",label:"Routing",tone:"accent"};if((e.awaiting??0)>0)return{key:"gpui.mgmt.plan.st.awaiting",label:"Awaiting review",tone:"warn"};return{key:"gpui.mgmt.plan.st.empty",label:"Empty",tone:"faint"}}}function rs(e){let t=e.done??0,n=e.approved??0,i=e.awaiting??0,s=e.blocked??0,r=0;if(typeof e.total!=="number"){for(let o of e.layers??[])for(let a of o.items??[])if(a.state==="routed"||a.state==="verified")t+=1;else if(a.state==="routing")r+=1;else if(a.state==="approved")n+=1}else if(e.routing)r=Math.max(0,e.total-(t+n+i+s));return[{count:t,tone:"ok"},{count:r,tone:"accent"},{count:n,tone:"input"},{count:i,tone:"warn"},{count:s,tone:"bad"}]}function os(e){switch(e){case"current":return{text:"The fab's limits are in the DRC rules",button:null};case"stale":return{text:"The DRC rules have older fab limits",button:"Update"};case"none":return{text:"The fab's limits are not in the DRC rules",button:"Write"};default:return{text:"No KiCad project for DRC rules",button:null}}}function as(e){return e==="extra"?"costs-more limits":"base-price limits"}function Rn(e,t){return e.watchGen===t.watchGen&&e.editGen===t.editGen&&e.project!==""&&e.project===t.project&&e.editId!==""&&e.editId===t.editId}function ls(e){return{project:e.project,refs:e.refs.slice(),field:e.field,value:e.was}}function jn(e,t){return e.watchGen===t.watchGen&&e.project!==""&&e.project===t.project&&e.threadId!==""&&e.threadId===t.threadId&&e.threadGen===t.threadGen}var zi=["#f59e0b","#38bdf8","#c084fc","#2dd4bf","#ef4444","#a3e635","#f97316","#ec4899"],qi=["#14b8a6","#f59e0b","#c084fc","#22c55e","#38bdf8","#ef4444","#e879f9","#84cc16"];function cs(e){let t=2166136261;for(let n=0;n>>0;return t}function Ut(e,t=""){let n=t.trim().toLowerCase();if(n&&n!=="#5a7a9a"&&n!=="#8a8a8a")return t;let i=e.toUpperCase();if(i.includes("3V3A")||i.includes("AVDD")||i.includes("VDDA"))return"#38bdf8";if(i.includes("1V8")||i.includes("1.8V"))return"#c084fc";if(i.includes("2V5")||i.includes("2.5V"))return"#a3e635";if(i.includes("3V3")||i.includes("3.3V")||i.includes("VCC"))return"#f59e0b";if(i.includes("5V")||i.startsWith("+5"))return"#ef4444";if(i.includes("12V")||i.includes("24V"))return"#f97316";if(i.includes("VBAT")||i.includes("VIN"))return"#ec4899";if(i.includes("GND"))return"#2dd4bf";return zi[cs(i)%zi.length]}function Nt(e,t=""){let n=t.trim().toLowerCase();if(n&&n!=="#8a8a8a")return t;return qi[cs(e)%qi.length]}function ds(e,t,n,i=14){let s=Math.max(1,Math.abs(e[2]-e[0])),r=Math.max(1,Math.abs(e[3]-e[1])),o=Math.max(20,t-i*2),a=Math.max(20,n-i*2),c=Math.max(0.05,Math.min(200,Math.min(o/s,a/r)));return{cx:(e[0]+e[2])*0.5,cy:(e[1]+e[3])*0.5,scale:c,fitted:c,touched:!1}}function Ke(e,t,n,i,s){return[i*0.5+(t-e.cx)*e.scale,s*0.5+(n-e.cy)*e.scale]}function dn(e,t,n,i,s){let r=Math.max(0.0001,e.scale);return[e.cx+(t-i*0.5)/r,e.cy+(n-s*0.5)/r]}function ps(e,t,n){let i=Math.max(0.0001,e.scale);return{...e,cx:e.cx-t/i,cy:e.cy-n/i,touched:!0}}function hs(e,t,n,i,s,r){let o=Math.max(0.02,e.fitted*0.35),a=Math.max(40,e.fitted*24),c=Math.max(o,Math.min(a,e.scale*t)),[p,l]=dn(e,n,i,s,r);return{...e,cx:p-(n-s*0.5)/c,cy:l-(i-r*0.5)/c,scale:c,touched:!0}}function ms(e,t,n,i){let s=e.map((o)=>[o[0],o[1]]);if(s.length===0)return[n];let r=i&&t+1>=s.length?s.length:Math.min(t+1,s.length);return s.splice(r,0,[n[0],n[1]]),s}function Hn(e,t,n){let i=n?3:2;if(e.length<=i||t<0||t>=e.length)return null;let s=e.map((r)=>[r[0],r[1]]);return s.splice(t,1),s}function Yr(e,t,n,i,s,r){let o=s-n,a=r-i,c=o*o+a*a;if(c<0.000001)return(e-n)*(e-n)+(t-i)*(t-i);let p=Math.max(0,Math.min(1,((e-n)*o+(t-i)*a)/c)),l=n+p*o,h=i+p*a;return(e-l)*(e-l)+(t-h)*(t-h)}function Ki(e,t,n){if(n.length<3)return!1;let i=!1;for(let s=0,r=n.length-1;st!==p>t&&e<(c-o)*(t-a)/(p-a+0.000000000001)+o)i=!i}return i}function Dn(e,t){return Math.max(5,Math.min(32,e*t))}function pn(e,t,n,i,s,r,o,a,c){if(i){for(let d of e){if(d.layer!==n||d.id!==i||d.locked)continue;let u=d.path??[];for(let f=0;f=3)for(let f=0;f=0;d--){let u=t[d];if(u.layer!==n)continue;let f=u.outline??[];if(!Ki(l,h,f))continue;if(!(u.holes??[]).some((v)=>Ki(l,h,v)))return{kind:"region",id:u.id}}return null}function Mt(e){let t=null,n=null,i=[];for(let r of e){if(!r.layer)continue;i.push(r.layer);let o=r.items??[],a=o.filter((p)=>p.kind==="corridor").length,c=o.filter((p)=>p.kind==="plane").length;if((a>0||r.role==="signal")&&(!t||a>t.count))t={count:a,layer:r.layer};if((c>0||r.role==="power"||r.role==="plane")&&(!n||c>n.count))n={count:c,layer:r.layer}}let s=[];if(t)s.push(t.layer);if(n&&!s.includes(n.layer))s.push(n.layer);for(let r of i){if(s.length>=2)break;if(!s.includes(r))s.push(r)}return s}function Ji(e,t){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=Math.max(0,Math.min(1,t)),i=0;for(let o=1;o=s&&a>0.000000001){let c=(s-r)/a;return[e[o-1][0]+(e[o][0]-e[o-1][0])*c,e[o-1][1]+(e[o][1]-e[o-1][1])*c]}r+=a}return e[e.length-1]}function vt(e,t,n){for(let i of t??[])if(i.layer===e&&i.title)return i.title;for(let i of n??[])if(i.layer===e&&i.title)return i.title;return e}function us(e,t,n){if(e==="split"&&n.length>0)return t.filter((i)=>n.includes(i.layer));return t}function Bn(e,t){return!(e[2]<=t[0]||e[0]>=t[2]||e[3]<=t[1]||e[1]>=t[3])}function Yi(e,t,n){if(n.length<3)return!1;let i=!1;for(let s=0,r=n.length-1;st!==p>t&&e<(c-o)*(t-a)/(p-a+0.000000000001)+o)i=!i}return i}function bs(e,t){if(e.length<3)return null;let n=1/0,i=1/0,s=-1/0,r=-1/0,o=0,a=0;for(let p of e)n=Math.min(n,p[0]),i=Math.min(i,p[1]),s=Math.max(s,p[0]),r=Math.max(r,p[1]),o+=p[0],a+=p[1];let c=[[(n+s)*0.5,(i+r)*0.5],[o/e.length,a/e.length]];for(let p of[0.5,0.25,0.75,0.125,0.875])for(let l of[0.5,0.25,0.75,0.125,0.875])c.push([n+(s-n)*l,i+(r-i)*p]);for(let p of c)if(Yi(p[0],p[1],e)&&!t.some((l)=>Yi(p[0],p[1],l)))return p;return null}function gs(e,t,n,i,s,r){let o=[];for(let l of e){let h=l.nets??0,d=l.path??[];if(h<=0||d.length<2)continue;let u=0;for(let f=1;f{let d=l.sel||l.hov?1:0,u=h.sel||h.hov?1:0;if(u!==d)return u-d;if(h.nets!==l.nets)return h.nets-l.nets;return l.b.id.localeCompare(h.b.id)});let a=[],c=[],p=(l,h,d,u,f)=>[l-d*0.5-f,h-u*0.5-f,l+d*0.5+f,h+u*0.5+f];for(let l of o){let h=l.b.name||"",d=String(l.nets),u=h?`${h} · ${l.nets}`:d,f=(l.sel||l.hov||l.pxLen>=95)&&h?[u,d]:[d],b=null,v=(E,k)=>Math.max(k*0.5+3,Math.min(Math.max(k*0.5+3,n-k*0.5-3),E)),w=(E,k)=>Math.max(k*0.5+3,Math.min(Math.max(k*0.5+3,i-k*0.5-3),E));e:for(let E of f){let k=Math.max(16,E.length*5.9+10),L=15;for(let M of[0.5,0.35,0.65,0.22,0.78]){let A=Ji(l.pts,M);if(!A)continue;let[B,T]=Ke(t,A[0],A[1],n,i),H=v(B,k),O=w(T,15),P=p(H,O,k,15,2);if(!a.some((Y)=>Bn(P,Y))){b={id:l.b.id,text:E,cx:H,cy:O,pw:k,ph:15,col:l.col,sel:l.sel};break e}}}if(!b){let E=Ji(l.pts,0.5);if(E){let[k,L]=Ke(t,E[0],E[1],n,i),M=Math.max(16,d.length*6.5+8),A=15,B=v(k,M);for(let T of[-18,18]){let H=w(L+T,15);if(!a.some((O)=>Bn(p(B,H,M,15,2),O))){b={id:l.b.id,text:d,cx:B,cy:H,pw:M,ph:15,col:l.col,sel:l.sel};break}}}}if(b)a.push(p(b.cx,b.cy,b.pw,b.ph,2)),c.push(b)}return c}function fs(e,t,n,i,s,r=[]){let o=new Set(s),a=[];for(let l of e){if(!l.r||!l.b||l.b.length!==4)continue;let[h,d]=Ke(t,l.b[0],l.b[1],n,i),[u,f]=Ke(t,l.b[2],l.b[3],n,i),b=Math.abs(u-h),v=Math.abs(f-d);if(b<13||v<9)continue;let w=(h+u)*0.5,E=(d+f)*0.5;if(w<8||w>n-8||E<8||E>i-8)continue;a.push({text:l.r,cx:w,cy:E,bw:l.r.length*5.8+4,bh:11,score:b*v+(o.has(l.r)?1e4:0)})}a.sort((l,h)=>h.score-l.score);let c=[...r],p=[];for(let l of a){let h=[l.cx-l.bw*0.5,l.cy-l.bh*0.5,l.cx+l.bw*0.5,l.cy+l.bh*0.5];if(!c.some((u)=>Bn(h,u)))c.push(h),p.push({text:l.text,cx:l.cx,cy:l.cy})}return p}function vs(e){if(!e||typeof e!=="object")return null;let t=e;if(t.panel&&typeof t.panel==="object")return t.panel;if(t.result&&typeof t.result==="object"){let n=t.result.panel;if(n&&typeof n==="object")return n}return null}function hn(e,t){if(!t||t.length===0)return e;let n=new Map;for(let r of e)if(r.layer)n.set(r.layer,r);let i=[],s=new Set;for(let r of t){if(!r.layer)continue;s.add(r.layer);let o=n.get(r.layer);if(o)i.push(o);else i.push({layer:r.layer,index:r.index,title:r.title||`L${r.index} · ${r.layer}`,subtitle:r.subtitle||"",role:r.role,status:"proposed",done:0,approved:0,total:0,items:[]})}for(let r of e)if(r.layer&&!s.has(r.layer))i.push(r);return i}function ws(e,t,n,i,s,r,o,a){return e===t&&n===i&&s===r&&(a===void 0||o>=a)}var ys="#111917",Xr="#16201d",Qr="rgba(212, 224, 219, 0.92)",Zr="rgba(61, 80, 73, 0.72)",eo="rgba(82, 107, 97, 0.85)";var Es="#f59e0b",to="#eef5f2",Cs="#ef4444";function wt(e,t){let n=e.trim().replace(/^#/,"");if(n.length===6){let i=parseInt(n.slice(0,2),16),s=parseInt(n.slice(2,4),16),r=parseInt(n.slice(4,6),16);if(!Number.isNaN(i)&&!Number.isNaN(s)&&!Number.isNaN(r))return`rgba(${i}, ${s}, ${r}, ${t})`}return`rgba(20, 184, 166, ${t})`}function no(e,t,n){let i=0.14,s=0.45,r=0.85,o=!1;switch(e){case"approved":case"routing":i=0.16,s=0.51,r=0.91;break;case"edited":i=0.2,s=0.56,r=0.95;break;case"routed":case"verified":i=0.08,s=0.26,r=0.59;break;case"rejected":case"failed":i=0.05,s=0.13,r=0.27;break;case"blocked":i=0.18,s=0.48,r=0.88,o=!0;break}if(t)i=Math.min(0.35,i+0.1),s=Math.min(0.71,s+0.12),r=1;else if(n)i=Math.min(0.28,i+0.06),s=Math.min(0.63,s+0.07);return{glow:i,body:s,core:r,bad:o}}function io(e,t,n){let i=0.27,s=0.83,r=!1;switch(e){case"approved":case"routing":i=0.36,s=0.91;break;case"edited":i=0.38,s=0.95;break;case"routed":case"verified":i=0.16,s=0.54;break;case"rejected":case"failed":i=0.08,s=0.27;break;case"blocked":i=0.31,s=0.94,r=!0;break}if(t)i=Math.min(0.53,i+0.12),s=1;else if(n)i=Math.min(0.45,i+0.06),s=Math.min(1,s+0.1);return{fill:i,edge:s,bad:r}}function so(e){let t=e.items??[];if(t.some((n)=>n.state==="blocked"||n.state==="failed"))return{key:"gpui.mgmt.plan.st.blocked",label:"Blocked",tone:"bad"};if(t.some((n)=>n.state==="routing"))return{key:"gpui.mgmt.plan.st.routing",label:"Routing",tone:"accent"};if(t.some((n)=>n.state==="proposed"||n.state==="edited"))return{key:"gpui.mgmt.plan.st.awaiting",label:"Awaiting review",tone:"warn"};if(t.length>0&&t.every((n)=>n.state==="routed"||n.state==="verified"))return{key:"gpui.mgmt.plan.st.routed",label:"Routed",tone:"ok"};if(t.length>0&&t.every((n)=>n.state==="approved"||n.state==="routed"||n.state==="verified"))return{key:"gpui.mgmt.plan.st.approved",label:"Approved",tone:"accent"};return{key:"gpui.mgmt.plan.st.empty",label:"Empty",tone:"faint"}}class Fn{root;cb;state=null;cards=new Map;renderedLayerKey="";sharedCam=null;layerCams=new Map;hover=null;selectedVertex=null;drag=null;downPos=null;rafPending=0;constructor(e){this.cb=e,this.root=document.createElement("div"),this.root.className="bp-plan-canvas-grid",this.root.tabIndex=0,this.root.setAttribute("data-testid","mgmt-plan-canvas-grid"),this.root.addEventListener("keydown",(t)=>this.onKeyDown(t))}isDragging(){return this.drag!==null}fitAll(){this.sharedCam=null,this.layerCams.clear(),this.scheduleDraw()}destroy(){if(this.rafPending)cancelAnimationFrame(this.rafPending),this.rafPending=0;for(let e of this.cards.values())e.ro.disconnect();this.cards.clear(),this.root.replaceChildren()}visibleLayers(e){let t=hn(e.layers,e.copperLayers);if(t.length===0)return[];if(e.gridMode==="all")return t;if(e.gridMode==="single"){let s=e.shownLayers.find((o)=>t.some((a)=>a.layer===o))??Mt(t)[0]??t[0]?.layer,r=t.find((o)=>o.layer===s);return r?[r]:[]}let n=e.shownLayers.length>0&&e.shownLayers.every((s)=>t.some((r)=>r.layer===s))?e.shownLayers.slice(0,2):Mt(t),i=[];for(let s of n){let r=t.find((o)=>o.layer===s);if(r)i.push(r)}return i.length>0?i:t.slice(0,2)}update(e,t){this.state=e;let n=this.visibleLayers(e);this.root.classList.toggle("two-cols",t&&n.length>1);let i=n.map((s)=>s.layer).join("|");if(i!==this.renderedLayerKey){this.renderedLayerKey=i;for(let s of this.cards.values())s.ro.disconnect();this.cards.clear(),this.root.replaceChildren();for(let s of n){let r=this.buildCard(s);this.cards.set(s.layer,r),this.root.appendChild(r.el)}}else for(let s of n){let r=this.cards.get(s.layer);if(r)this.syncCardHeaderAndLegend(r,s)}this.scheduleDraw()}effectiveBbox(e){let t=e.bbox;if(!t||t.length!==4||Math.abs(t[2]-t[0])<0.5||Math.abs(t[3]-t[1])<0.5)return[0,0,100,70];return t}getCam(e,t,n){let i=this.state,s=i?.syncZoom?this.sharedCam:this.layerCams.get(e)??null;if(s&&s.touched)return s;return ds(i?this.effectiveBbox(i.board):[0,0,100,70],t,n,14)}setCam(e,t){if(this.state?.syncZoom)this.sharedCam=t;else this.layerCams.set(e,t)}buildCard(e){let t=document.createElement("section");t.className="bp-plan-card",t.setAttribute("data-testid",`mgmt-plan-card-${e.layer}`);let n=document.createElement("div");n.className="bp-plan-card-head";let i=document.createElement("div");i.className="bp-plan-card-head-top";let s=document.createElement("span"),r=e.role==="power"||(e.items?.length??0)>0&&(e.items??[]).every((E)=>E.kind==="plane");s.className="bp-plan-card-bar "+(r?"pwr":"sig");let o=document.createElement("span");o.className="bp-plan-card-title";let a=document.createElement("span");a.className="bp-plan-status-badge";let c=document.createElement("button");c.type="button",c.className="bp-mgmt-btn bp-plan-mini-btn",c.textContent="✓",c.title=m("gpui.mgmt.plan.layer","Approve layer"),c.addEventListener("click",(E)=>{E.stopPropagation(),this.cb.onApproveLayer(e.layer,!0)});let p=document.createElement("button");p.type="button",p.className="bp-mgmt-btn bp-plan-mini-btn",p.textContent="✗",p.title=m("gpui.mgmt.plan.rejectlayer","Reject layer"),p.addEventListener("click",(E)=>{E.stopPropagation(),this.cb.onApproveLayer(e.layer,!1)}),i.append(s,o,a,c,p);let l=document.createElement("div");l.className="bp-plan-card-sub",n.append(i,l);let h=document.createElement("div");h.className="bp-plan-card-canvas-wrap";let d=document.createElement("canvas");d.className="bp-plan-card-canvas",d.setAttribute("data-testid",`mgmt-plan-canvas-${e.layer}`);let u=document.createElement("div");u.className="bp-plan-hover-hud bp-hidden",h.append(d,u);let f=document.createElement("div");f.className="bp-plan-legend bp-hidden",t.append(n,h,f);let b=d.getContext("2d"),v=new ResizeObserver(()=>this.scheduleDraw());v.observe(h),this.attachPointerListeners(d,e.layer);let w={layer:e.layer,el:t,canvas:d,ctx:b,legendEl:f,okBtn:c,noBtn:p,statusEl:a,titleEl:o,subtitleEl:l,hoverHudEl:u,ro:v};return this.syncCardHeaderAndLegend(w,e),w}syncCardHeaderAndLegend(e,t){e.titleEl.textContent=vt(t.layer,this.state?.copperLayers,this.state?.layers)||t.title||t.layer;let n=t.subtitle||t.stackup||"";e.subtitleEl.textContent=n,e.subtitleEl.classList.toggle("bp-hidden",!n);let i=t.items??[],s=so(t);e.statusEl.className=`bp-plan-card-status tone-${s.tone==="warn"?"dim":s.tone}`,e.statusEl.textContent=i.length>0?m(s.key,s.label):"",e.statusEl.classList.toggle("bp-hidden",i.length===0);let r=i.some((a)=>a.state==="proposed"||a.state==="edited");if(e.okBtn)e.okBtn.classList.toggle("bp-hidden",!r);if(e.noBtn)e.noBtn.classList.toggle("bp-hidden",!r);let o=(this.state?.regions??[]).filter((a)=>a.layer===t.layer);if(o.length===0)e.legendEl.classList.add("bp-hidden"),e.legendEl.replaceChildren();else{e.legendEl.classList.remove("bp-hidden");let a=document.createDocumentFragment();for(let c of o){let p=document.createElement("button");p.type="button";let l=this.state?.selectedId===c.id;p.className="bp-plan-legend-chip"+(l?" active":"");let h=document.createElement("span");h.className="bp-plan-legend-sw",h.style.background=Ut(c.net||c.id,c.color||"");let d=document.createElement("span");d.textContent=c.net||c.id,p.append(h,d),p.addEventListener("click",()=>{this.cb.onSelect(c.id),this.cb.onFocusItem(c.id)}),a.appendChild(p)}e.legendEl.replaceChildren(a)}}attachPointerListeners(e,t){e.addEventListener("contextmenu",(i)=>i.preventDefault()),e.addEventListener("dblclick",()=>this.fitAll()),e.addEventListener("pointerdown",(i)=>{let s=this.state;if(!s)return;this.root.focus({preventScroll:!0});let r=e.getBoundingClientRect(),o=i.clientX-r.left,a=i.clientY-r.top,c=Math.max(1,r.width),p=Math.max(1,r.height),l=this.getCam(t,c,p),h=pn(s.bands,s.regions,t,s.selectedId,l,c,p,o,a);if(i.button===2){if(h?.kind==="vertex"){let d=this.getItemPts(h.id,h.isPlane),u=Hn(d,h.idx,h.isPlane);if(u)this.selectedVertex=null,this.cb.onCommitFields(h.id,{[h.isPlane?"outline":"path"]:u})}return}if(i.button!==0)return;if(e.setPointerCapture(i.pointerId),this.downPos={x:i.clientX,y:i.clientY},h?.kind==="vertex"){let d=this.getItemPts(h.id,h.isPlane),u=d.map((f)=>[f[0],f[1]]);this.selectedVertex={id:h.id,idx:h.idx},this.drag={layer:t,kind:"vertex",id:h.id,isPlane:h.isPlane,idx:h.idx,pts:d.map((f)=>[f[0],f[1]]),origPts:u,moved:!1},this.scheduleDraw()}else if(h?.kind==="midpoint"){let d=this.getItemPts(h.id,h.isPlane),u=d.map((v)=>[v[0],v[1]]),f=ms(d,h.segIdx,h.pos,h.isPlane),b=h.isPlane&&h.segIdx+1>=d.length?f.length-1:Math.min(h.segIdx+1,f.length-1);this.selectedVertex={id:h.id,idx:b},this.patchLocalItem(h.id,h.isPlane,f),this.drag={layer:t,kind:"vertex",id:h.id,isPlane:h.isPlane,idx:b,pts:f,origPts:u,moved:!0},this.scheduleDraw()}else this.selectedVertex=null,this.drag={layer:t,kind:"pan",lastX:o,lastY:a}}),e.addEventListener("pointermove",(i)=>{let s=this.state;if(!s)return;let r=e.getBoundingClientRect(),o=i.clientX-r.left,a=i.clientY-r.top,c=Math.max(1,r.width),p=Math.max(1,r.height);if(this.drag&&this.drag.layer===t){if(this.drag.kind==="pan"){let L=this.getCam(t,c,p);this.setCam(t,ps(L,o-this.drag.lastX,a-this.drag.lastY)),this.drag.lastX=o,this.drag.lastY=a,this.scheduleDraw();return}if(this.downPos&&Math.hypot(i.clientX-this.downPos.x,i.clientY-this.downPos.y)<1.5&&!this.drag.moved)return;let b=this.getCam(t,c,p),[v,w]=dn(b,o,a,c,p),E=[Math.round(v*1000)/1000,Math.round(w*1000)/1000];this.drag.moved=!0,this.drag.pts[this.drag.idx]=E;let k=this.drag.pts.map((L)=>[L[0],L[1]]);this.patchLocalItem(this.drag.id,this.drag.isPlane,k),this.scheduleDraw();return}let l=this.getCam(t,c,p),h=pn(s.bands,s.regions,t,s.selectedId,l,c,p,o,a),d=this.hover?.hit?"id"in this.hover.hit?this.hover.hit.id:"":"",u=this.hover?.hit.kind??"",f=h?h.id:"";if(this.hover=h?{layer:t,hit:h}:null,e.style.cursor=h?"pointer":"crosshair",d!==f||(h?.kind??"")!==u)this.syncHoverHud(t),this.scheduleDraw()}),e.addEventListener("pointerleave",()=>{if(this.hover?.layer===t)this.hover=null,this.syncHoverHud(t),this.scheduleDraw()});let n=()=>{let i=this.drag;if(!i||i.layer!==t)return;if(this.drag=null,this.downPos=null,i.kind==="vertex"&&i.moved){let s=i.origPts.map((r)=>[r[0],r[1]]);this.patchLocalItem(i.id,i.isPlane,s)}this.cb.onDragEnd?.(),this.scheduleDraw()};e.addEventListener("pointercancel",n),e.addEventListener("lostpointercapture",n),e.addEventListener("pointerup",(i)=>{let s=this.state,r=this.drag,o=this.downPos;if(this.drag=null,this.downPos=null,e.hasPointerCapture(i.pointerId))e.releasePointerCapture(i.pointerId);if(r&&r.kind==="vertex"&&r.layer===t){if(r.moved)this.cb.onCommitFields(r.id,{[r.isPlane?"outline":"path"]:r.pts});else this.cb.onDragEnd?.(),this.scheduleDraw();return}if(s&&o&&Math.hypot(i.clientX-o.x,i.clientY-o.y)<4.5){let a=e.getBoundingClientRect(),c=i.clientX-a.left,p=i.clientY-a.top,l=Math.max(1,a.width),h=Math.max(1,a.height),d=this.getCam(t,l,h),u=pn(s.bands,s.regions,t,s.selectedId,d,l,h,c,p);if(u&&(u.kind==="band"||u.kind==="region")){this.cb.onSelect(u.id),this.cb.onFocusItem(u.id);return}if(!u&&s.selectedId){this.cb.onSelect("");return}}this.cb.onDragEnd?.()}),e.addEventListener("wheel",(i)=>{i.preventDefault();let s=e.getBoundingClientRect(),r=i.clientX-s.left,o=i.clientY-s.top,a=Math.max(1,s.width),c=Math.max(1,s.height),p=this.getCam(t,a,c),l=Math.max(0.65,Math.min(1.55,1-i.deltaY*0.002));this.setCam(t,hs(p,l,r,o,a,c)),this.scheduleDraw()},{passive:!1})}patchLocalItem(e,t,n){let i=this.state;if(!i)return;if(t){let s=i.regions.find((r)=>r.id===e);if(s){if(s.outline=n,s.edited=!0,s.state==="proposed")s.state="edited"}}else{let s=i.bands.find((r)=>r.id===e);if(s){if(s.path=n,s.edited=!0,s.state==="proposed")s.state="edited"}}}getItemPts(e,t){let n=this.state;if(!n)return[];if(t)return(n.regions.find((i)=>i.id===e)?.outline??[]).map((i)=>[i[0],i[1]]);return(n.bands.find((i)=>i.id===e)?.path??[]).map((i)=>[i[0],i[1]])}syncHoverHud(e){let t=this.cards.get(e),n=this.state;if(!t||!n)return;if(!this.hover||this.hover.layer!==e){t.hoverHudEl.classList.add("bp-hidden"),t.hoverHudEl.textContent="";return}let i=this.hover.hit.id,s=n.bands.find((a)=>a.id===i),r=n.regions.find((a)=>a.id===i),o="";if(s)o=`${s.name||i} · ${s.nets??0}n · ${(s.width??1.5).toFixed(2)}mm`;else if(r)o=r.reference?`${r.net||i} · ${r.reference}`:r.net||i;if(!o)t.hoverHudEl.classList.add("bp-hidden");else t.hoverHudEl.classList.remove("bp-hidden"),t.hoverHudEl.textContent=o}onKeyDown(e){let t=this.state;if(!t)return;if(e.key==="0"||e.key==="Home"){e.preventDefault(),this.fitAll();return}if(e.key==="Escape"){this.selectedVertex=null,this.cb.onSelect("");return}if(!t.selectedId)return;let n=t.bands.find((o)=>o.id===t.selectedId),i=t.regions.find((o)=>o.id===t.selectedId),s=Boolean(n?.locked??i?.locked),r=e.key.toLowerCase();if(r==="a")e.preventDefault(),this.cb.onQuickApprove([t.selectedId],!0);else if(r==="r")e.preventDefault(),this.cb.onQuickApprove([t.selectedId],!1);else if(r==="l")e.preventDefault(),this.cb.onCommitFields(t.selectedId,{locked:!s});else if(r==="w"&&n&&!s){e.preventDefault();let o=e.shiftKey?-0.25:0.25,a=Math.round(Math.max(0.15,Math.min(25,(n.width??1.5)+o))*100)/100;this.cb.onCommitFields(t.selectedId,{width:a})}else if((e.key==="Delete"||e.key==="Backspace")&&!s&&this.selectedVertex?.id===t.selectedId){e.preventDefault();let o=Boolean(i),a=this.getItemPts(t.selectedId,o),c=Hn(a,this.selectedVertex.idx,o);if(c)this.selectedVertex=null,this.cb.onCommitFields(t.selectedId,{[o?"outline":"path"]:c})}}scheduleDraw(){if(this.rafPending)return;this.rafPending=requestAnimationFrame(()=>{this.rafPending=0,this.drawAll()})}drawAll(){let e=this.state;if(!e)return;let t=Math.max(0.45,Math.min(1.25,Math.abs(this.effectiveBbox(e.board)[3]-this.effectiveBbox(e.board)[1])/Math.max(1,Math.abs(this.effectiveBbox(e.board)[2]-this.effectiveBbox(e.board)[0]))));for(let n of this.cards.values()){let i=n.canvas.parentElement;if(!i)continue;let s=Math.max(120,Math.round(i.clientWidth)),r=Math.max(165,Math.min(250,Math.round(s*t)));n.canvas.style.height=`${r}px`;let o=Math.max(1,window.devicePixelRatio||1),a=Math.round(s*o),c=Math.round(r*o);if(n.canvas.width!==a||n.canvas.height!==c)n.canvas.width=a,n.canvas.height=c;n.ctx.setTransform(o,0,0,o,0,0),this.drawLayer(n.ctx,n.layer,s,r,e)}}drawLayer(e,t,n,i,s){let r=this.getCam(t,n,i),o=(b,v)=>Ke(r,b,v,n,i);e.fillStyle=ys,e.fillRect(0,0,n,i);let a=(s.board.outline??[]).filter((b)=>b.length>=3);if(e.fillStyle=Xr,a.length>0){e.beginPath();for(let b of a){for(let v=0;vb.layer===t),p=this.hover?.layer===t?this.hover.hit:null;for(let b of c){let v=b.outline??[];if(v.length<3)continue;let w=s.selectedId===b.id,E=p?.id===b.id,k=io(b.state||"proposed",w,E),L=Ut(b.net||b.id,b.color||"");e.beginPath();for(let A=0;AT)T=P;if(Y>H)H=Y}if(Math.abs(T-A)>=38&&Math.abs(H-B)>=18){let O=bs(v,b.holes??[]);if(O){let[P,Y]=o(O[0],O[1]);e.fillStyle=wt(L,w?0.91:0.67),e.font="bold 10px ui-monospace, 'SFMono-Regular', Menlo, monospace",e.textAlign="center",e.textBaseline="middle",e.fillText(M,P,Y)}}}}if(e.strokeStyle=Qr,e.lineWidth=1.25,e.lineCap="round",e.lineJoin="round",a.length>0){e.beginPath();for(let b of a){for(let v=0;vb.layer===t),d=gs(h,r,n,i,s.selectedId,p?.id??""),u=d.map((b)=>[b.cx-b.pw*0.5-1,b.cy-b.ph*0.5-1,b.cx+b.pw*0.5+1,b.cy+b.ph*0.5+1]),f=[];for(let b of h){for(let v of b.from??[])f.push(v);for(let v of b.to??[])f.push(v)}e.fillStyle="rgba(143, 163, 155, 0.72)",e.font="9.5px ui-monospace, 'SFMono-Regular', Menlo, monospace",e.textAlign="center",e.textBaseline="middle";for(let b of fs(l,r,n,i,f,u))e.fillText(b.text,b.cx,b.cy);for(let b of h){let v=b.guides??[];if(v.length===0)continue;let w=s.selectedId===b.id||p?.id===b.id,E=Nt(b.name||b.id,b.color||"");e.strokeStyle=wt(E,w?0.38:0.17),e.lineWidth=w?1:0.7,e.beginPath();for(let k of v){let[L,M]=o(k[0],k[1]),[A,B]=o(k[2],k[3]);e.moveTo(L,M),e.lineTo(A,B)}e.stroke()}for(let b of h){let v=b.path??[];if(v.length<2)continue;let w=s.selectedId===b.id,E=p?.id===b.id,k=no(b.state||"proposed",w,E),L=Nt(b.name||b.id,b.color||""),M=Dn(b.width??1.5,r.scale),A=()=>{e.beginPath();for(let B=0;B{let E=w?v.length:Math.max(0,v.length-1);for(let k=0;kn.id===e))return;if(this.openPanel!==e)this.togglePanel(e)}getTabs(){return an(this.getStateInfo())}isOpen(){return this.openPanel!==""}closePanel(){if(!this.openPanel)return;if(this.openPanel="",this.project)this.cb.hub.rpc("mgmt.panel",{project:this.project,open:""}).catch(()=>{});this.render()}clear(){this.watchGen++,this.bomEditGen++,this.askedProject="",this.digest="",this.project="",this.openPanel="",this.errorMsg="",this.bomEditingId="",this.bomLastUndo=null,this.bomEditStatus="",this.checksStatus="",this.planStatus="",this.planSelectedId="",this.planStackupOpen=!1,this.planShownLayers=[],this.planOptimistic.clear(),this.planOptimisticRev=void 0,this.planHydratedKey="",this.planHydrateAskedKey="",this.planHydrateGen++,this.planHydratedRev=void 0,this.planRenderDeferred=!1,this.planHydratedBoard=null,this.planHydratedDraw=null,this.planNoteOpen=!1,this.planMoveLayerOpen=!1,this.planCanvas?.destroy(),this.planCanvas=null,this.planCommitFields=null,this.fabStatus="",this.render()}async watchProject(e){if(!e||!this.cb.hub.hasFeature("mgmt")){this.clear();return}if(e===this.askedProject&&this.digest){this.render();return}let t=++this.watchGen;if(this.askedProject=e,this.project!==e)this.bomEditGen++,this.digest="",this.project="",this.openPanel="",this.errorMsg="",this.bomSelectedId="",this.bomEditingId="",this.bomEditStatus="",this.bomLastUndo=null,this.checksSelectedId="",this.checksStatus="",this.planStatus="",this.planSelectedId="",this.planStackupOpen=!1,this.planShownLayers=[],this.planOptimistic.clear(),this.planOptimisticRev=void 0,this.planHydratedKey="",this.planHydrateAskedKey="",this.planHydrateGen++,this.planHydratedRev=void 0,this.planRenderDeferred=!1,this.planHydratedBoard=null,this.planHydratedDraw=null,this.planNoteOpen=!1,this.planMoveLayerOpen=!1,this.planCanvas?.destroy(),this.planCanvas=null,this.planCommitFields=null,this.fabStatus="",this.lifeSelectedKey="",this.lifePartSamples=null,this.render();try{let n=await this.cb.hub.rpc("mgmt.watch",{project:e});if(t!==this.watchGen)return;let i=typeof n.digest==="string"?n.digest:"";if(!i){this.render();return}if(this.digest=i,this.project=typeof n.project==="string"&&n.project?n.project:e,n.state&&typeof n.state==="object")this.infos.set(`mgmt.state.${i}`,n.state);if(n.data&&typeof n.data==="object"){for(let[s,r]of Object.entries(n.data))if(r&&typeof r==="object")this.infos.set(`mgmt.${s}.${i}`,r)}this.errorMsg="",this.render()}catch{if(t===this.watchGen)this.render()}}handleInfo(e){let t=!1;for(let[n,i]of Object.entries(e)){if(!n.startsWith("mgmt.")&&!n.startsWith("kicad.checks."))continue;if(i===""||i===null||i===void 0){if(this.infos.delete(n))t=!0;continue}if(typeof i==="string")try{let s=JSON.parse(i);if(s&&typeof s==="object")this.infos.set(n,s),t=!0}catch{}else if(typeof i==="object")this.infos.set(n,i),t=!0}if(t)this.render()}getStateInfo(){if(!this.digest)return null;return this.infos.get(`mgmt.state.${this.digest}`)??null}getPanelData(e){if(!this.digest)return null;return this.infos.get(`mgmt.${e}.${this.digest}`)??null}togglePanel(e){let t=this.openPanel===e?"":e;if(this.openPanel=t,this.errorMsg="",this.render(),this.project)this.cb.hub.rpc("mgmt.panel",{project:this.project,open:t}).catch((n)=>{this.errorMsg=n instanceof Error?n.message:"Could not update panel",this.render()})}render(){if(this.openPanel==="plan"&&this.planCanvas?.isDragging()){this.planRenderDeferred=!0;return}this.planRenderDeferred=!1;let e=this.getStateInfo(),t=an(e);if(!this.digest||t.length===0){this.planCanvas?.destroy(),this.planCanvas=null,this.panelEl.classList.remove("bp-plan-expanded"),this.stripEl.classList.add("bp-hidden"),this.panelEl.classList.add("bp-hidden"),this.panelEl.removeAttribute("data-testid"),this.panelEl.replaceChildren(),this.stripEl.replaceChildren(),this.cb.onOpenChange?.(!1);return}this.stripEl.classList.remove("bp-hidden");let n=document.createDocumentFragment(),i=document.createElement("div");i.className="bp-mgmt-tabs";for(let o of t){let a=document.createElement("button");a.type="button";let c=this.openPanel===o.id;a.className="bp-mgmt-tab"+(c?" active":""),a.setAttribute("data-testid",`mgmt-tab-${o.id}`),a.setAttribute("aria-pressed",c?"true":"false");let p=document.createElement("span");p.textContent=he(o.label),a.appendChild(p);let l=this.getPanelData(o.id),h=Xi(l);if(h){let d=document.createElement("span");d.className=`bp-mgmt-badge bp-tone-${h.tone}`,d.textContent=h.text,a.appendChild(d)}a.addEventListener("click",()=>this.togglePanel(o.id)),i.appendChild(a)}if(n.appendChild(i),this.openPanel){let o=document.createElement("button");o.type="button",o.className="icon bp-mgmt-close",o.textContent="×",o.title=m("gpui.mgmt.close","Close the panel"),o.setAttribute("aria-label",m("gpui.mgmt.close","Close the panel")),o.setAttribute("data-testid","mgmt-close"),o.addEventListener("click",()=>this.closePanel()),n.appendChild(o)}if(this.stripEl.replaceChildren(n),!this.openPanel){this.planCanvas?.destroy(),this.planCanvas=null,this.panelEl.classList.remove("bp-plan-expanded"),this.panelEl.classList.add("bp-hidden"),this.panelEl.removeAttribute("data-testid"),this.panelEl.replaceChildren(),this.cb.onOpenChange?.(!1);return}if(this.openPanel!=="plan")this.planCanvas?.destroy(),this.planCanvas=null,this.panelEl.classList.remove("bp-plan-expanded");else this.panelEl.classList.toggle("bp-plan-expanded",this.planExpanded);this.panelEl.classList.remove("bp-hidden"),this.panelEl.setAttribute("data-testid",`mgmt-panel-${this.openPanel}`),this.cb.onOpenChange?.(!0);let s=this.openPanel==="plan"&&this.planCanvas!==null&&document.activeElement instanceof HTMLElement&&this.panelEl.contains(document.activeElement)&&(document.activeElement===this.planCanvas.root||this.planCanvas.root.contains(document.activeElement)),r=document.createDocumentFragment();if(this.errorMsg){let o=document.createElement("div");o.className="bp-mgmt-note bp-tone-bad",o.textContent=this.errorMsg,r.appendChild(o)}switch(this.openPanel){case"bom":r.appendChild(this.renderBom());break;case"checks":r.appendChild(this.renderChecks());break;case"life":r.appendChild(this.renderLife());break;case"plan":r.appendChild(this.renderPlan());break;case"fab":r.appendChild(this.renderFab());break}if(this.panelEl.replaceChildren(r),s)this.planCanvas?.root.focus({preventScroll:!0})}renderBom(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("bom");if(!t)return e.appendChild(this.makeEmpty("Reading the schematic…")),e;let n=Array.isArray(t.lines)?t.lines:[],i=document.createElement("div");i.className="bp-mgmt-head";let s=document.createElement("span");s.className="bp-dim",s.textContent=`${t.parts??0} parts · ${n.length} lines`;let r=document.createElement("span"),o=t.source==="kicad";if(r.className="bp-mgmt-pill"+(o?" accent":""),r.textContent=o?"live":"saved",i.append(s,r),(t.priced??0)>0&&(t.checking??0)===0&&typeof t.cost==="number"){let p=document.createElement("span");p.className="bp-dim",p.textContent=(t.priced??0)<(t.lookups??0)?`≥ ${At(t.cost)}/board`:`${At(t.cost)}/board`,i.appendChild(p)}if(t.paused){let p=document.createElement("span");p.className="bp-mgmt-faint",p.textContent="Stock check paused",i.appendChild(p)}if(e.appendChild(i),t.stock_note){let p=document.createElement("div");p.className="bp-mgmt-note bp-mgmt-faint",p.textContent=he(t.stock_note),e.appendChild(p)}let a=this.bomEditingId?n.find((p)=>p.id===this.bomEditingId)??null:null;if(a)e.appendChild(this.renderBomEditor(a));else{let p=document.createElement("div");p.className="bp-mgmt-filter-row";let l=document.createElement("input");l.type="text",l.className="bp-mgmt-filter",l.placeholder="Filter BOM (ref, value, footprint, MPN, dnp)…",l.value=this.bomFilter,l.setAttribute("data-testid","mgmt-bom-filter"),l.addEventListener("input",()=>{this.bomFilter=l.value,this.renderBomRows(c,n)}),p.appendChild(l),e.appendChild(p)}let c=document.createElement("div");return c.className="bp-mgmt-rows",c.setAttribute("data-testid","mgmt-bom-rows"),this.renderBomRows(c,n),e.appendChild(c),e}renderBomRows(e,t){let n=es(t,this.bomFilter);if(n.length===0){e.replaceChildren(this.makeEmpty(t.length===0?"No parts found.":"No matching lines."));return}let i=t.some((r)=>Boolean(r.mpn)||Boolean(r.fab)),s=document.createDocumentFragment();for(let r of n){let o=Array.isArray(r.refs)?r.refs:[],a=document.createElement("div");a.className="bp-mgmt-row"+(this.bomSelectedId===r.id?" active":"")+(r.dnp?" faint":""),a.setAttribute("data-testid",`mgmt-bom-row-${r.id}`);let c=document.createElement("div");c.className="bp-mgmt-row-line";let p=document.createElement("span");if(p.className="bp-mgmt-strong bp-mgmt-flex1",p.textContent=ln(o,24),c.appendChild(p),r.dnp){let b=document.createElement("span");b.className="bp-mgmt-pill",b.textContent=m("gpui.mgmt.bom.dnp","DNP"),c.appendChild(b)}else{let b=Zi(r.stock);if(b){let v=document.createElement("span");v.className=`bp-tone-${b.tone}`,v.textContent=b.text,c.appendChild(v)}}let l=document.createElement("button");l.type="button",l.className="bp-mgmt-btn",l.textContent="Edit",l.addEventListener("click",(b)=>{b.stopPropagation(),this.bomEditGen++,this.bomEditingId=r.id,this.bomEditDraft=r.mpn??"",this.bomEditStatus="",this.bomLastUndo=null,this.render()}),c.appendChild(l);let h=document.createElement("div");h.className="bp-mgmt-row-sub";let d=[`${r.qty??o.length}×`,r.value??"",Qi(r.footprint??"")].filter(Boolean).join(" · "),u=document.createElement("span");u.className="bp-dim",u.textContent=d;let f=document.createElement("span");if(f.className="bp-mgmt-flex1",r.mpn)f.textContent=r.mpn;else if(i&&!r.dnp)f.className+=" bp-tone-warn",f.textContent=m("gpui.mgmt.bom.nompn","no MPN");if(h.append(u,f),!r.dnp&&typeof r.stock?.price==="number"){let b=document.createElement("span");b.className="bp-dim",b.textContent=At(r.stock.price),h.appendChild(b)}if(!r.dnp&&r.stock?.class){let b=document.createElement("span");b.className="bp-mgmt-faint",b.textContent=he(r.stock.class),h.appendChild(b)}a.append(c,h),a.addEventListener("click",()=>{this.bomSelectedId=r.id,this.renderBomRows(e,t)}),s.appendChild(a)}e.replaceChildren(s)}renderBomEditor(e){let t=document.createElement("div");t.className="bp-mgmt-editor",t.setAttribute("data-testid","mgmt-bom-edit");let n=Array.isArray(e.refs)?e.refs:[],i=document.createElement("div");i.className="bp-mgmt-row-line";let s=document.createElement("span");s.className="bp-mgmt-strong",s.textContent=ln(n,30);let r=document.createElement("button");r.type="button",r.className="icon",r.textContent="×",r.addEventListener("click",()=>{this.bomEditGen++,this.bomEditingId="",this.bomLastUndo=null,this.bomEditStatus="",this.render()}),i.append(s,r);let o=document.createElement("input");o.type="text",o.className="bp-mgmt-filter",o.placeholder="MPN",o.value=this.bomEditDraft,o.addEventListener("input",()=>{this.bomEditDraft=o.value});let a=()=>({watchGen:this.watchGen,editGen:this.bomEditGen,project:this.project,editId:this.bomEditingId}),c=async(d,u=!1)=>{let f=a();this.bomEditStatus="Writing…",this.render();try{let b=await this.cb.hub.rpc("mgmt.bom.edit",d);if(!Rn(f,a()))return;this.bomLastUndo=!u&&(b.changed??0)>0?{project:d.project,editId:f.editId,refs:d.refs.slice(),field:d.field,was:typeof b.was==="string"?b.was:d.field==="mpn"?e.mpn??"":e.dnp?"yes":"no"}:null,this.bomEditStatus=u?"Restored":(b.changed??0)===0?"No change":b.via==="kicad"?"Updated in KiCad":"Saved to schematic"}catch(b){if(!Rn(f,a()))return;this.bomEditStatus=b instanceof Error?b.message:"Could not save edit"}this.render()},p=document.createElement("div");p.className="bp-mgmt-btn-row";let l=document.createElement("button");l.type="button",l.className="primary bp-mgmt-btn",l.textContent="Save MPN",l.addEventListener("click",()=>{c({project:this.project,refs:n.slice(),field:"mpn",value:this.bomEditDraft.trim()})});let h=document.createElement("button");if(h.type="button",h.className="bp-mgmt-btn",h.textContent=e.dnp?"Clear DNP":"Mark DNP",h.addEventListener("click",()=>{c({project:this.project,refs:n.slice(),field:"dnp",value:e.dnp?"no":"yes"})}),p.append(l,h),this.bomLastUndo&&this.bomLastUndo.project===this.project&&this.bomLastUndo.editId===this.bomEditingId){let d=this.bomLastUndo,u=document.createElement("button");u.type="button",u.className="bp-mgmt-btn",u.textContent="Undo",u.addEventListener("click",()=>{c(ls(d),!0)}),p.appendChild(u)}if(t.append(i,o,p),this.bomEditStatus){let d=document.createElement("div");d.className="bp-mgmt-faint",d.textContent=this.bomEditStatus,t.appendChild(d)}return t}renderChecks(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("checks");if(!t)return e.appendChild(this.makeEmpty("Reading checks…")),e;let n=Array.isArray(t.groups)?t.groups:[],i=Array.from(new Set(n.map((d)=>d.source).filter(Boolean))),s=(d)=>t.sources?.[d]?.label||d.toUpperCase(),r=(d)=>t.sources?.[d]?.judged===!0,o=document.createElement("div");o.className="bp-mgmt-head bp-mgmt-scroll-x";let a=document.createElement("button");a.type="button",a.className="bp-mgmt-btn"+(this.checksSource===""?" active":""),a.textContent=m("gpui.mgmt.checks.all","All"),a.addEventListener("click",()=>{this.checksSource="",this.render()}),o.appendChild(a);for(let d of i){let u=document.createElement("button");u.type="button",u.className="bp-mgmt-btn"+(this.checksSource===d?" active":""),u.textContent=s(d)+(r(d)?" · judged":""),u.addEventListener("click",()=>{this.checksSource=this.checksSource===d?"":d,this.render()}),o.appendChild(u)}let c=document.createElement("span");c.className="bp-mgmt-flex1";let p=document.createElement("button");if(p.type="button",p.className="bp-mgmt-btn",p.textContent=m("gpui.mgmt.checks.run","Run"),p.addEventListener("click",()=>{let d=this.watchGen,u=this.project;this.checksStatus="Running checks…",this.render(),this.cb.hub.rpc("kicad.checks.run",{project:u}).then(()=>{if(d!==this.watchGen||u!==this.project)return;this.checksStatus="",this.render()}).catch((f)=>{if(d!==this.watchGen||u!==this.project)return;this.checksStatus=f instanceof Error?f.message:"Could not run checks",this.render()})}),o.append(c,p),e.appendChild(o),this.checksStatus){let d=document.createElement("div");d.className="bp-mgmt-note bp-dim",d.textContent=this.checksStatus,e.appendChild(d)}let l=document.createElement("div");l.className="bp-mgmt-rows",l.setAttribute("data-testid","mgmt-checks-rows");let h=ts(n,this.checksSource);if(h.length===0)l.appendChild(this.makeEmpty("No check findings."));else for(let d of h){let u=d.severity==="error"?"bad":d.severity==="warning"?"warn":"faint",f=document.createElement("div");f.className="bp-mgmt-group-head";let b=document.createElement("span");b.className=`bp-mgmt-dot bp-tone-bg-${u}`;let v=document.createElement("span");v.className="bp-mgmt-flex1",v.textContent=`${s(d.source)} · ${d.rule}`;let w=document.createElement("span");w.className=`bp-tone-${u}`,w.textContent=String(d.n),f.append(b,v,w),l.appendChild(f);for(let E of d.rows??[]){let k=document.createElement("div");k.className="bp-mgmt-row"+(this.checksSelectedId===E.id?" active":"");let L=document.createElement("div");if(L.textContent=he(E.title??""),k.appendChild(L),E.names||this.checksSelectedId===E.id){let M=document.createElement("div");M.className="bp-mgmt-row-sub";let A=document.createElement("span");if(A.className="bp-dim bp-mgmt-flex1",A.textContent=E.names??"",M.appendChild(A),this.checksSelectedId===E.id){let B=document.createElement("button");B.type="button",B.className="bp-mgmt-btn accent",B.textContent=m("gpui.mgmt.checks.fix","Fix with agent"),B.addEventListener("click",(T)=>{T.stopPropagation();let H={watchGen:this.watchGen,project:this.project,threadId:this.cb.getThreadId(),threadGen:this.cb.getThreadGen()};this.cb.hub.rpc("kicad.checks.fix",{project:H.project,id:E.id}).then((O)=>{let P={watchGen:this.watchGen,project:this.project,threadId:this.cb.getThreadId(),threadGen:this.cb.getThreadGen()};if(!jn(H,P))return;if(O.text)this.cb.onSendText(O.text),this.checksStatus="Sent to agent",this.render()}).catch((O)=>{let P={watchGen:this.watchGen,project:this.project,threadId:this.cb.getThreadId(),threadGen:this.cb.getThreadGen()};if(!jn(H,P))return;this.checksStatus=O instanceof Error?O.message:"Could not send finding",this.render()})}),M.appendChild(B)}k.appendChild(M)}k.addEventListener("click",()=>{this.checksSelectedId=E.id,this.cb.hub.rpc("kicad.checks.focus",{project:this.project,id:E.id}).catch(()=>{}),this.render()}),l.appendChild(k)}}return e.appendChild(l),e}renderLife(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("life");if(!t)return e.appendChild(this.makeEmpty("Reading lifecycle…")),e;let n=document.createElement("div");n.className="bp-mgmt-head";let i=t.counts??{};for(let c of["active","nrnd","eol"]){let p=i[c]??0,l=In(c),h=document.createElement("span");h.className=p>0?`bp-tone-${l.tone}`:"bp-mgmt-faint",h.textContent=`${l.label} ${p}`,n.appendChild(h)}if((i.unknown??0)>0){let c=document.createElement("span");c.className="bp-mgmt-faint",c.textContent=`${i.unknown} unknown`,n.appendChild(c)}if(t.since){let c=document.createElement("span");c.className="bp-mgmt-flex1";let p=document.createElement("span");p.className="bp-mgmt-faint",p.textContent=`since ${cn(t.since)} (${t.samples??0})`,n.append(c,p)}e.appendChild(n);let s=document.createElement("div");s.className="bp-mgmt-rows",s.setAttribute("data-testid","mgmt-life-rows");let r=t.bom?.cost??[],o=t.bom?.instock??[],a=t.bom?.lines??0;if(r.length===0)s.appendChild(this.makeEmpty(a===0?"No line has an MPN or fab part number to follow yet.":"No reading of the fab's stock yet: the BOM panel's lookups start it."));else{let c=r[r.length-1],p=o[o.length-1],l=document.createElement("div");l.className="bp-mgmt-note bp-dim",l.textContent=`Parts/board: ${At(c[1])} · ${Math.round(p?.[1]??0)}/${a} lines in stock (${cn(c[0])})`,s.appendChild(l)}for(let c of t.parts??[]){let p=this.lifeSelectedKey===c.key,l=In(c.lifecycle??"unknown"),h=document.createElement("div");h.className="bp-mgmt-row"+(p?" active":"");let d=document.createElement("div");d.className="bp-mgmt-row-line";let u=document.createElement("span");u.className="bp-mgmt-strong",u.textContent=ln(c.refs??[],14);let f=document.createElement("span");f.className="bp-mgmt-flex1 bp-dim",f.textContent=c.mpn||c.key;let b=document.createElement("span");if(b.className=`bp-tone-${l.tone}`,b.textContent=l.label,d.append(u,f,b),typeof c.stock==="number"){let v=document.createElement("span");v.className="bp-dim",v.textContent=Lt(c.stock),d.appendChild(v)}if(h.appendChild(d),p){let v=document.createElement("div");if(v.className="bp-mgmt-row-sub bp-mgmt-faint",this.lifePartLoading)v.textContent=m("gpui.mgmt.life.reading","Reading its history…");else if(this.lifePartSamples&&this.lifePartSamples.length>0){let w=this.lifePartSamples[this.lifePartSamples.length-1];v.textContent=`${this.lifePartSamples.length} samples · latest ${w.at?cn(w.at):""}`+(typeof w.stock==="number"?` · stock ${Lt(w.stock)}`:"")+(typeof w.price==="number"?` · ${At(w.price)}`:"")}else v.textContent=m("gpui.mgmt.life.nopart","No reading of this part yet.");h.appendChild(v)}h.addEventListener("click",()=>{if(this.lifeSelectedKey===c.key){this.lifeSelectedKey="",this.lifePartSamples=null,this.render();return}this.lifeSelectedKey=c.key,this.lifePartSamples=null,this.lifePartLoading=!0,this.render(),this.cb.hub.rpc("mgmt.life.part",{project:this.project,key:c.key}).then((v)=>{if(this.lifeSelectedKey!==c.key)return;this.lifePartLoading=!1,this.lifePartSamples=Array.isArray(v.samples)?v.samples:[],this.render()}).catch(()=>{if(this.lifeSelectedKey!==c.key)return;this.lifePartLoading=!1,this.lifePartSamples=[],this.render()})}),s.appendChild(h)}return e.appendChild(s),e}renderPlan(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("plan");if(!t)return e.appendChild(this.makeEmpty(m("gpui.mgmt.plan.reading","Reading the routing plan…"))),e;let n=(C,x)=>{let F=this.watchGen,I=this.project;this.planStatus="",this.cb.hub.rpc(C,{pro:I,...x}).catch((J)=>{if(F!==this.watchGen||I!==this.project)return;this.planOptimistic.clear(),this.planStatus=J instanceof Error?J.message:m("gpui.mgmt.plan.refused","KiCad refused"),this.render()})};if(t.revision!==this.planOptimisticRev)this.planOptimisticRev=t.revision,this.planOptimistic.clear();let i=`${this.project}:${t.revision??0}`;if(t.board_trimmed&&this.planHydrateAskedKey!==i&&this.project){this.planHydrateAskedKey=i;let C=this.watchGen,x=++this.planHydrateGen,F=this.project,I=t.revision??0;this.cb.hub.rpc("plan.get",{pro:F,board:!0}).then((J)=>{let se=vs(J);if(!se)return;let Ee=typeof se.revision==="number"?se.revision:I;if(!ws(C,this.watchGen,x,this.planHydrateGen,F,this.project,Ee,this.planHydratedRev))return;this.planHydratedRev=Ee,this.planHydratedKey=`${F}:${Ee}`,this.planHydratedBoard=se.board??null,this.planHydratedDraw=se.draw??null,this.render()}).catch(()=>{})}let s=t.on===!0,r=document.createElement("div");r.className="bp-plan-header";let o=document.createElement("div");o.className="bp-plan-toggle";let a=document.createElement("span");a.className="bp-mgmt-strong",a.textContent=m("gpui.mgmt.plan.before","Plan before routing"),a.title=s?m("gpui.mgmt.plan.onwords","Before routing a board with 4 or more copper layers or more than 60 nets, the agent proposes corridors and plane regions here. It routes only what you approve."):m("gpui.mgmt.plan.offwords","Agents route as you ask. Turn it on to have them propose a routing plan first and route only what you approve here."),o.appendChild(a);let c=t.awaiting??0,p=t.blocked??0,l=t.done??0,h=t.total??0,d=t.revision??0,u=t.empty?[]:rs(t),f=u.reduce((C,x)=>C+x.count,0);if(!t.empty){let C=ss(t),x=document.createElement("span");if(x.className=`bp-plan-status-badge tone-${C.tone}`,x.textContent=m(C.key,C.label),o.appendChild(x),d>0){let I=document.createElement("span");I.className="bp-dim",I.textContent=`v${d}`,o.appendChild(I)}let F=document.createElement("span");if(F.className="bp-plan-header-counts bp-mgmt-flex1 "+(c>0?"bp-tone-warn":p>0?"bp-tone-bad":"bp-dim"),F.textContent=h>0?`${l}/${h} ${m("gpui.mgmt.plan.done","done")}`:c>0?m("web.plan.awaiting","{n} awaiting approval",{n:c}):m("gpui.mgmt.plan.nothing","Nothing awaits your approval"),o.appendChild(F),!t.live){let I=document.createElement("span");I.className="bp-mgmt-pill",I.textContent=m("gpui.mgmt.plan.saved","saved plan"),o.appendChild(I)}}else{let C=document.createElement("span");C.className="bp-mgmt-flex1",o.appendChild(C)}let b=document.createElement("button");b.type="button",b.className="bp-mgmt-btn bp-plan-chip-btn"+(s?" active":""),b.setAttribute("data-testid","mgmt-plan-on"),b.setAttribute("aria-pressed",s?"true":"false"),b.textContent=m("gpui.bots.recall.on","On"),b.addEventListener("click",()=>n("plan.enable",{on:!0}));let v=document.createElement("button");if(v.type="button",v.className="bp-mgmt-btn bp-plan-chip-btn"+(!s?" active":""),v.setAttribute("data-testid","mgmt-plan-off"),v.setAttribute("aria-pressed",!s?"true":"false"),v.textContent=m("gpui.bots.recall.off","Off"),v.addEventListener("click",()=>n("plan.enable",{on:!1})),o.append(b,v),r.appendChild(o),f>0){let C=document.createElement("div");C.className="bp-plan-segbar";for(let x of u){if(x.count<=0)continue;let F=document.createElement("div");F.className=`bp-plan-seg bp-tone-bg-${x.tone}`,F.style.flexGrow=String(x.count),C.appendChild(F)}r.appendChild(C)}e.appendChild(r);for(let C of t.elsewhere??[]){let x=document.createElement("div");x.className="bp-plan-elsewhere";let F=document.createElement("span");F.className="bp-tone-warn bp-mgmt-flex1",F.textContent=m("gpui.mgmt.plan.elsewhere","A routing plan for {board} awaits your approval",{board:C.name||C.rel||""}),x.appendChild(F),e.appendChild(x)}if(t.empty){let C=document.createElement("div");C.className="bp-mgmt-note";let x=document.createElement("div");x.className="bp-dim",x.textContent=m("gpui.mgmt.plan.noboard","No routing plan for this board.");let F=document.createElement("div");return F.className="bp-mgmt-faint",F.textContent=m("gpui.mgmt.plan.emptysub","Layers, corridors, and planes appear here once a plan is proposed."),C.append(x,F),e.appendChild(C),e}let w=t.stackup_summary??"",E=Array.isArray(t.impedances)?t.impedances:[],k=Boolean(w)||E.length>0,L=document.createElement("div");if(L.className="bp-mgmt-head",c>0){let C=document.createElement("button");C.type="button",C.className="primary bp-mgmt-btn",C.setAttribute("data-testid","mgmt-plan-approve-all"),C.textContent=m("gpui.mgmt.plan.all","Approve all"),C.addEventListener("click",()=>n("plan.approve",{layer:"",ids:[],approve:!0})),L.appendChild(C)}if(t.routing){let C=document.createElement("button");C.type="button",C.className="bp-mgmt-btn",C.setAttribute("data-testid","mgmt-plan-stop"),C.textContent=m("gpui.mgmt.plan.stop","Stop routing"),C.addEventListener("click",()=>n("plan.stop",{})),L.appendChild(C)}if(t.live&&l>0){let C=document.createElement("button");C.type="button",C.className="bp-mgmt-btn",C.setAttribute("data-testid","mgmt-plan-verify"),C.textContent=m("gpui.mgmt.plan.verify","Verify"),C.addEventListener("click",()=>n("plan.verify",{})),L.appendChild(C)}let M=document.createElement("span");if(M.className="bp-mgmt-flex1",L.appendChild(M),k){let C=document.createElement("button");C.type="button",C.className="bp-mgmt-btn bp-plan-chip-btn"+(this.planStackupOpen?" active":""),C.setAttribute("data-testid","mgmt-plan-stackup-toggle"),C.setAttribute("aria-expanded",this.planStackupOpen?"true":"false"),C.textContent=`${m("gpui.mgmt.plan.stackup.short","Stackup")} ${this.planStackupOpen?"▾":"▸"}`,C.addEventListener("click",()=>{this.planStackupOpen=!this.planStackupOpen,this.render()}),L.appendChild(C)}let A=document.createElement("button");A.type="button",A.className="bp-mgmt-btn",A.setAttribute("data-testid","mgmt-plan-hide"),A.textContent=this.planHideDone?m("gpui.mgmt.plan.show","Show done"):m("gpui.mgmt.plan.hide","Hide done"),A.addEventListener("click",()=>{this.planHideDone=!this.planHideDone,this.render()}),L.appendChild(A),e.appendChild(L);let B=Array.isArray(t.asks)?t.asks:[];if(B.length>0){let C=B.map((se)=>se.what||"").filter(Boolean).join(", "),x=B[0]?.note||"",F=document.createElement("div");F.className="bp-plan-elsewhere";let I=document.createElement("div");I.className="bp-plan-ask-col";let J=document.createElement("div");if(J.className="bp-tone-warn",J.textContent=C?m("gpui.mgmt.plan.requested","Approval requested: {what}",{what:C}):m("gpui.mgmt.plan.reqplain","Approval requested"),I.appendChild(J),x){let se=document.createElement("div");se.className="bp-dim",se.textContent=x,I.appendChild(se)}F.appendChild(I),e.appendChild(F)}if(this.planStatus){let C=document.createElement("div");C.className="bp-mgmt-note bp-plan-err bp-tone-bad";let x=document.createElement("span");x.className="bp-mgmt-flex1",x.textContent=this.planStatus==="KiCad refused"?m("gpui.mgmt.plan.refused","KiCad refused"):he(this.planStatus);let F=document.createElement("button");F.type="button",F.className="icon",F.textContent="×",F.title=m("common.close","Close"),F.addEventListener("click",()=>{this.planStatus="",this.render()}),C.append(x,F),e.appendChild(C)}if(t.keys_note){let C=document.createElement("div");C.className="bp-mgmt-note bp-dim";let x="On this KiCad version, approve from this panel: in plan view KiCad's A, R and W keys aren't the plan's yet (A opens Add Footprint). Update KiCad.";C.textContent=t.keys_note===x?m("gpui.mgmt.plan.keysnote",x):he(t.keys_note),e.appendChild(C)}if(k&&this.planStackupOpen){let C=document.createElement("div");if(C.className="bp-plan-stackup-body",C.setAttribute("data-testid","mgmt-plan-stackup-body"),w){let x=document.createElement("div");x.className="bp-dim",x.textContent=w,C.appendChild(x)}for(let x of E){let F=document.createElement("div");F.className="bp-mgmt-faint",F.textContent=`· ${x}`,C.appendChild(F)}e.appendChild(C)}let T=(C,x,F,I)=>{let J=document.createElement("button");return J.type="button",J.className="bp-mgmt-btn bp-plan-chip-btn"+(x?" active":""),J.setAttribute("data-testid",F),J.setAttribute("aria-pressed",x?"true":"false"),J.textContent=C,J.addEventListener("click",I),J},H=document.createElement("div");if(H.className="bp-plan-viewbar",H.append(T(m("gpui.mgmt.plan.view.canvas","Canvas"),this.planViewMode==="canvas","mgmt-plan-view-canvas",()=>{this.planViewMode="canvas",this.render()}),T(m("gpui.mgmt.plan.view.split","Split"),this.planViewMode==="split","mgmt-plan-view-split",()=>{this.planViewMode="split",this.render()}),T(m("gpui.mgmt.plan.view.list","List"),this.planViewMode==="list","mgmt-plan-view-list",()=>{this.planViewMode="list",this.render()})),this.planViewMode!=="list"){let C=document.createElement("span");C.className="bp-plan-sep";let x=document.createElement("span");x.className="bp-plan-sep";let F=document.createElement("button");F.type="button",F.className="bp-mgmt-btn bp-plan-mini-btn",F.setAttribute("data-testid","mgmt-plan-fit"),F.textContent=m("gpui.mgmt.plan.fit","Fit"),F.addEventListener("click",()=>this.planCanvas?.fitAll()),H.append(C,T(m("gpui.mgmt.plan.grid.pair","Side by side"),this.planGridMode==="pair","mgmt-plan-grid-pair",()=>{this.planGridMode="pair",this.render()}),T(m("gpui.mgmt.plan.grid.all","All layers"),this.planGridMode==="all","mgmt-plan-grid-all",()=>{this.planGridMode="all",this.render()}),T(m("gpui.mgmt.plan.grid.single","Single"),this.planGridMode==="single","mgmt-plan-grid-single",()=>{this.planGridMode="single",this.render()}),x,T(m("gpui.mgmt.plan.sync","Link zoom"),this.planSyncZoom,"mgmt-plan-sync",()=>{this.planSyncZoom=!this.planSyncZoom,this.render()}),F)}let O=document.createElement("span");O.className="bp-mgmt-flex1";let P=document.createElement("button");P.type="button",P.className="bp-mgmt-btn bp-plan-mini-btn",P.setAttribute("data-testid","mgmt-plan-expand"),P.textContent=this.planExpanded?m("gpui.mgmt.plan.compact","Compact"):m("gpui.mgmt.plan.expand","Expand"),P.addEventListener("click",()=>{this.planExpanded=!this.planExpanded,this.render()}),H.append(O,P),e.appendChild(H);let Y=Boolean(this.planHydratedBoard)&&this.planHydratedKey.startsWith(`${this.project}:`)&&(this.planHydratedKey===i||this.planHydratedRev!==void 0&&this.planHydratedRev>=(t.revision??0)),re=Y&&this.planHydratedBoard?this.planHydratedBoard:t.board??{bbox:[0,0,100,70],outline:[],parts:[]},ie=Y&&this.planHydratedDraw?this.planHydratedDraw:t.draw??{bands:[],regions:[]},me=(ie.bands??[]).map((C)=>{let x=this.planOptimistic.get(C.id);if(!x)return{...C};return{...C,...x,edited:!0,state:C.state==="proposed"?"edited":C.state}}),Pe=(ie.regions??[]).map((C)=>{let x=this.planOptimistic.get(C.id);if(!x)return{...C};return{...C,...x,edited:!0,state:C.state==="proposed"?"edited":C.state}}),Ce=[],te=(t.layers??[]).map((C)=>{let x=[];for(let F of C.items??[]){let I=this.planOptimistic.get(F.id);if(!I){x.push(F);continue}let J={...F,width:typeof I.width==="number"?I.width:F.width,locked:typeof I.locked==="boolean"?I.locked:F.locked,edited:!0,state:F.state==="proposed"?"edited":F.state};if(typeof I.layer==="string"&&I.layer!==C.layer)Ce.push({target:I.layer,item:J});else x.push(J)}return{...C,items:x}});for(let C of Ce){let x=te.find((F)=>F.layer===C.target);if(x)x.items=[...x.items??[],C.item]}let oe=hn(te,t.copper_layers),R=this.planGridMode==="all"?oe.map((C)=>C.layer):this.planGridMode==="single"?[this.planShownLayers.find((C)=>oe.some((x)=>x.layer===C))??Mt(oe)[0]??oe[0]?.layer??""].filter(Boolean):this.planShownLayers.length>0&&this.planShownLayers.every((C)=>oe.some((x)=>x.layer===C))?this.planShownLayers.slice(0,2):Mt(oe);if(this.planViewMode!=="list"&&this.planGridMode!=="all"&&oe.length>1){let C=document.createElement("div");C.className="bp-plan-layerbar";for(let x of oe){let F=R.includes(x.layer),I=(x.items??[]).length,J=vt(x.layer,t.copper_layers,oe)||x.title||x.layer,se=I>0?`${J} · ${I}`:J,Ee=T(se,F,`mgmt-plan-layerpill-${x.layer}`,()=>{if(this.planGridMode==="single")this.planShownLayers=[x.layer];else if(this.planGridMode==="pair"){if(!R.includes(x.layer))this.planShownLayers=R.length>=2?[R[0],x.layer]:[...R,x.layer]}else this.planGridMode="single",this.planShownLayers=[x.layer];this.render()});if(I===0&&!F)Ee.classList.add("empty-layer");C.appendChild(Ee)}e.appendChild(C)}let ue=(C,x)=>{let F=this.planOptimistic.get(C)??{};if(this.planOptimistic.set(C,{...F,...x}),typeof x.layer==="string"){if(this.planGridMode==="single")this.planShownLayers=[x.layer];else if(this.planGridMode==="pair"&&!R.includes(x.layer))this.planShownLayers=R.length>=2?[R[0],x.layer]:[...R,x.layer]}let I=typeof t.revision==="number"?t.revision:void 0;this.render(),n("plan.update",{ops:[{op:"set",id:C,fields:x}],...I!==void 0?{base:I}:{}})};if(this.planCommitFields=ue,this.planSelectedId){let C="",x=null;for(let F of te){let I=(F.items??[]).find((J)=>J.id===this.planSelectedId);if(I){C=F.layer,x=I;break}}if(x){let F=vt(C,t.copper_layers,oe),I=document.createElement("div");I.className="bp-plan-inspector",I.setAttribute("data-testid","mgmt-plan-inspector");let J=document.createElement("div");J.className="bp-plan-ins-row";let se=document.createElement("span");se.className="bp-plan-ins-sw",se.style.background=x.kind==="corridor"?Nt(x.name||x.id,x.color||""):Ut(x.name||x.id,x.color||"");let Ee=document.createElement("span");Ee.className="bp-mgmt-strong",Ee.textContent=x.name||x.id;let D=document.createElement("span");if(D.className="bp-dim",D.textContent=F,J.append(se,Ee,D),x.edited||x.state==="edited"){let K=document.createElement("span");K.className="bp-plan-ins-pill warn",K.textContent=m("gpui.mgmt.plan.edited","Edited"),J.appendChild(K)}if(x.locked){let K=document.createElement("span");K.className="bp-plan-ins-pill",K.textContent=m("gpui.mgmt.plan.locked","Locked"),J.appendChild(K)}let ne=document.createElement("span");ne.className="bp-mgmt-flex1",J.appendChild(ne);let Te=document.createElement("button");if(Te.type="button",Te.className="bp-mgmt-btn bp-plan-mini-btn",Te.setAttribute("data-testid","mgmt-plan-lock"),Te.textContent=x.locked?m("gpui.mgmt.plan.unlock","Unlock"):m("gpui.mgmt.plan.lock","Lock"),Te.addEventListener("click",()=>ue(x.id,{locked:!x.locked})),J.appendChild(Te),x.state==="proposed"||x.state==="edited"){let K=document.createElement("button");K.type="button",K.className="primary bp-mgmt-btn bp-plan-mini-btn",K.textContent=m("android.hub.machines.approve","Approve"),K.addEventListener("click",()=>n("plan.approve",{layer:"",ids:[x.id],approve:!0}));let fe=document.createElement("button");fe.type="button",fe.className="bp-mgmt-btn bp-plan-mini-btn",fe.textContent=m("gpui.mgmt.plan.reject","Reject"),fe.addEventListener("click",()=>n("plan.approve",{layer:"",ids:[x.id],approve:!1})),J.append(K,fe)}let Le=document.createElement("button");Le.type="button",Le.className="bp-mgmt-btn bp-plan-mini-btn",Le.setAttribute("data-testid","mgmt-plan-note-toggle"),Le.textContent=m("gpui.mgmt.plan.addnote","Add note"),Le.addEventListener("click",()=>{this.planNoteOpen=!this.planNoteOpen,this.render()});let Be=document.createElement("button");if(Be.type="button",Be.className="icon",Be.textContent="×",Be.addEventListener("click",()=>{this.planSelectedId="",this.planNoteOpen=!1,this.planMoveLayerOpen=!1,this.render()}),J.append(Le,Be),I.appendChild(J),!x.locked){let K=document.createElement("div");if(K.className="bp-plan-ins-row",x.kind==="corridor"){let le=typeof x.width==="number"?x.width:1.5,He=document.createElement("span");He.className="bp-dim",He.textContent=m("gpui.mgmt.plan.width","Width");let $e=document.createElement("button");$e.type="button",$e.className="bp-mgmt-btn bp-plan-mini-btn",$e.setAttribute("data-testid","mgmt-plan-w-down"),$e.textContent="-",$e.addEventListener("click",()=>{let ze=Math.round(Math.max(0.15,le-0.25)*100)/100;ue(x.id,{width:ze})});let Oe=document.createElement("span");Oe.className="bp-plan-ins-val",Oe.textContent=`${le.toFixed(2)}mm`;let Ne=document.createElement("button");Ne.type="button",Ne.className="bp-mgmt-btn bp-plan-mini-btn",Ne.setAttribute("data-testid","mgmt-plan-w-up"),Ne.textContent="+",Ne.addEventListener("click",()=>{let ze=Math.round(Math.min(25,le+0.25)*100)/100;ue(x.id,{width:ze})});let We=document.createElement("span");We.className="bp-plan-sep",K.append(He,$e,Oe,Ne,We)}let fe=(t.copper_layers??[]).length>0?(t.copper_layers??[]).map((le)=>le.layer):te.map((le)=>le.layer);if(fe.length>0){let le=document.createElement("span");le.className="bp-dim",le.textContent=m("gpui.mgmt.plan.layer.short","Layer"),K.appendChild(le),K.appendChild(T(`${F} ${this.planMoveLayerOpen?"▴":"▾"}`,this.planMoveLayerOpen,"mgmt-plan-move-toggle",()=>{this.planMoveLayerOpen=!this.planMoveLayerOpen,this.render()}))}if(I.appendChild(K),this.planMoveLayerOpen&&fe.length>0){let le=document.createElement("div");le.className="bp-plan-ins-row";for(let He of fe){let $e=vt(He,t.copper_layers,oe);le.appendChild(T($e,He===C,`mgmt-plan-move-${He}`,()=>{if(this.planMoveLayerOpen=!1,He!==C)ue(x.id,{layer:He});else this.render()}))}I.appendChild(le)}}if(this.planNoteOpen){let K=document.createElement("form");K.className="bp-plan-note-form";let fe=document.createElement("input");fe.type="text",fe.className="bp-plan-note-input",fe.setAttribute("data-testid","mgmt-plan-note-input"),fe.placeholder=m("gpui.mgmt.plan.note.placeholder","Steering note for router…");let le=document.createElement("button");le.type="submit",le.className="primary bp-mgmt-btn bp-plan-mini-btn",le.setAttribute("data-testid","mgmt-plan-note-submit"),le.textContent=m("gpui.mgmt.plan.addnote","Add note"),K.append(fe,le),K.addEventListener("submit",(He)=>{He.preventDefault();let $e=fe.value.trim();if(!$e)return;fe.value="",this.planNoteOpen=!1;let Oe=typeof t.revision==="number"?t.revision:void 0;this.render(),n("plan.update",{ops:[{op:"note",target:x.id,text:$e}],...Oe!==void 0?{base:Oe}:{}})}),I.appendChild(K)}if(this.planViewMode!=="list"&&!x.locked){let K=document.createElement("div");K.className="bp-plan-hint",K.textContent=m("gpui.mgmt.plan.hint","Drag waypoints to steer · Click + on edge to insert · Right-click vertex to remove"),I.appendChild(K)}e.appendChild(I)}}let de=document.createElement("div");de.className="bp-mgmt-rows"+(this.planViewMode==="split"?" bp-plan-split-list":""),de.setAttribute("data-testid","mgmt-plan-rows");let ee=m("gpui.mgmt.plan.done","done"),ge=us(this.planViewMode,te,R);if(this.planViewMode==="split"&&ge.length===0){let C=document.createElement("div");C.className="bp-dim",C.style.padding="6px 8px",C.style.fontSize="11px",C.textContent=m("gpui.mgmt.plan.noitems","No corridors or planes on this layer"),de.appendChild(C)}for(let C of ge){let x=C.items??[],F=vt(C.layer,t.copper_layers,oe)||C.layer;if(this.planViewMode==="split"){if(ge.length>1){let I=document.createElement("div");I.className="bp-plan-split-divider";let J=C.role==="power"||C.role==="plane",se=document.createElement("span");se.className="bp-plan-card-bar "+(J?"pwr":"sig");let Ee=document.createElement("span");Ee.className="bp-mgmt-strong",Ee.textContent=F;let D=document.createElement("span");D.className="bp-dim",D.textContent=`${C.done??0}/${x.length} ${ee}`,I.append(se,Ee,D),de.appendChild(I)}}else{let I=document.createElement("div");I.className="bp-mgmt-group-head bp-plan-layer-head";let J=document.createElement("div");J.className="bp-mgmt-row-line";let se=document.createElement("span");se.className="bp-mgmt-strong",se.textContent=F;let Ee=document.createElement("span");if(Ee.className="bp-dim bp-mgmt-flex1",Ee.textContent=`${C.role?`${C.role} · `:""}${C.done??0}/${x.length} ${ee}`,J.append(se,Ee),C.status!=="approved"&&x.length>0){let D=document.createElement("button");D.type="button",D.className="bp-mgmt-btn",D.textContent=m("gpui.mgmt.plan.layer","Approve layer"),D.addEventListener("click",()=>n("plan.approve",{layer:C.layer,ids:[],approve:!0}));let ne=document.createElement("button");ne.type="button",ne.className="bp-mgmt-btn",ne.textContent=m("gpui.mgmt.plan.reject","Reject"),ne.addEventListener("click",()=>n("plan.approve",{layer:C.layer,ids:[],approve:!1})),J.append(D,ne)}if(I.appendChild(J),C.stackup){let D=document.createElement("div");D.className="bp-plan-layer-stackup",D.textContent=C.stackup,I.appendChild(D)}de.appendChild(I)}for(let I of x){if(this.planHideDone&&ns(I))continue;let J=this.planSelectedId===I.id,se=document.createElement("div");se.className="bp-mgmt-row bp-plan-row"+(J?" active":""),se.setAttribute("data-testid",`mgmt-plan-row-${I.id}`);let Ee=document.createElement("div");Ee.className="bp-mgmt-row-line";let D=document.createElement("span");D.className=`bp-plan-swatch bp-plan-st-${I.state||"proposed"}`,D.style.setProperty("--swatch-color",I.color||"#8a8a8a");let ne=document.createElement("span");ne.className="bp-mgmt-flex1"+(I.state==="blocked"||I.state==="failed"?" bp-tone-bad":I.state==="edited"?" bp-tone-warn":I.state==="rejected"||I.state==="routed"||I.state==="verified"?" bp-dim":""),ne.textContent=`${I.name||I.id}${I.locked?" \uD83D\uDD12":""}`;let Te=[];if(I.kind==="plane"){if(I.reference)Te.push(m("gpui.mgmt.plan.reference","over {layer}",{layer:I.reference}))}else{let K=I.nets??0;Te.push(K===1?m("web.plan.net.one","1 net"):m("web.plan.nets","{n} nets",{n:K}))}if(typeof I.width==="number"&&Number.isFinite(I.width))Te.push(`${I.width.toFixed(2)}mm`);if(I.impedance)Te.push(I.impedance);let Le=Te.join(" · "),Be=document.createElement("span");if(Be.className="bp-plan-mark "+(I.state==="blocked"||I.state==="failed"?"bp-tone-bad":I.state==="verified"||I.state==="routed"?"bp-tone-ok":I.state==="approved"?"bp-tone-accent":"bp-dim"),Be.textContent=is(I),Ee.append(D,ne,Be),I.state==="proposed"||I.state==="edited"){let K=document.createElement("button");K.type="button",K.className="bp-mgmt-btn",K.textContent="✓",K.title=m("gpui.mgmt.plan.layer","Approve layer"),K.addEventListener("click",(le)=>{le.stopPropagation(),n("plan.approve",{layer:"",ids:[I.id],approve:!0})});let fe=document.createElement("button");fe.type="button",fe.className="bp-mgmt-btn",fe.textContent="✗",fe.title=m("gpui.mgmt.plan.reject","Reject"),fe.addEventListener("click",(le)=>{le.stopPropagation(),n("plan.approve",{layer:"",ids:[I.id],approve:!1})}),Ee.append(K,fe)}if(se.appendChild(Ee),Le){let K=document.createElement("div");K.className="bp-mgmt-row-sub bp-plan-detail bp-dim",K.textContent=Le,se.appendChild(K)}if(I.state==="routing"&&typeof I.total==="number"&&I.total>0){let K=document.createElement("div");K.className="bp-plan-microbar";let fe=document.createElement("div");fe.className="bp-plan-microbar-fill";let le=Math.max(0,Math.min(100,Math.round((I.routed??0)/I.total*100)));fe.style.width=`${le}%`,K.appendChild(fe),se.appendChild(K)}if(I.problem_text){let K=document.createElement("div");K.className="bp-plan-problem",K.textContent=I.problem_text,se.appendChild(K)}se.addEventListener("click",()=>{this.planSelectedId=I.id,n("plan.focus",{id:I.id}),this.render()}),de.appendChild(se)}}if(this.planViewMode!=="list"){if(!this.planCanvas)this.planCanvas=new Fn({onSelect:(I)=>{if(this.planSelectedId=I,!I)this.planNoteOpen=!1;this.render()},onFocusItem:(I)=>{n("plan.focus",{id:I})},onDragEnd:()=>{if(this.planRenderDeferred)this.planRenderDeferred=!1,this.render()},onCommitFields:(I,J)=>{(this.planCommitFields??ue)(I,J)},onApproveLayer:(I,J)=>{n("plan.approve",{layer:I,ids:[],approve:J})},onQuickApprove:(I,J)=>{n("plan.approve",{layer:"",ids:I,approve:J})}});let C=this.panelEl.parentElement?.classList.contains("bp-has-viewer")===!1,x=this.planExpanded||this.panelEl.clientWidth>=540||C;this.planCanvas.update({gridMode:this.planGridMode,syncZoom:this.planSyncZoom,shownLayers:R,selectedId:this.planSelectedId,board:re,bands:me,regions:Pe,layers:oe,copperLayers:t.copper_layers},x);let F=document.createElement("div");F.className="bp-plan-canvas-scroll",F.appendChild(this.planCanvas.root),e.appendChild(F)}if(this.planViewMode!=="canvas")e.appendChild(de);if((t.draw?.bands?.length??0)>0||(t.draw?.regions?.length??0)>0){let C=document.createElement("div");C.className="bp-plan-footer",C.textContent=m("gpui.mgmt.plan.drawn","The plan's corridors and planes are drawn on the board while this panel is open. Close it to hide them."),e.appendChild(C)}return e}renderFab(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("fab");if(!t)return e.appendChild(this.makeEmpty("Reading the fab's profile…")),e;if(t.error){let E=document.createElement("div");return E.className="bp-mgmt-note bp-tone-warn",E.textContent=t.error,e.appendChild(E),e}let n=(E,k={})=>{let L=this.watchGen,M=this.project;this.fabStatus="",this.cb.hub.rpc("fab.profile",{pro:M,action:E,...k}).catch((A)=>{if(L!==this.watchGen||M!==this.project)return;this.fabStatus=A instanceof Error?A.message:"Fab action failed",this.render()})},i=document.createElement("div");i.className="bp-mgmt-head";let s=document.createElement("span");s.className="bp-mgmt-strong",s.textContent=m("gpui.mgmt.fab.thefab","The fab");let r=document.createElement("span");r.className="bp-dim bp-mgmt-flex1",r.textContent=`rev ${t.rev??0}${t.updated?` · ${t.updated}`:""}${t.board?` · ${t.board}`:""} · ${as(t.tier??"")}`;let o=document.createElement("button");if(o.type="button",o.className="bp-mgmt-btn",o.textContent=m("gpui.mgmt.fab.refresh","Refresh"),o.addEventListener("click",()=>n("refresh")),i.append(s,r,o),e.appendChild(i),this.fabStatus){let E=document.createElement("div");E.className="bp-mgmt-note bp-tone-bad",E.textContent=this.fabStatus,e.appendChild(E)}let a=document.createElement("div");a.className="bp-mgmt-rows",a.setAttribute("data-testid","mgmt-fab-rows");let c=t.review,p=document.createElement("div");p.className="bp-mgmt-row";let l=document.createElement("div");l.className="bp-mgmt-row-line";let h=document.createElement("span"),d=(c?.counts?.error??0)>0;if(h.className="bp-mgmt-flex1 "+(d?"bp-tone-bad":"bp-dim"),h.textContent=c?.running?"Reviewing the design…":c?.at==null?"No design review yet":`${c.counts?.error??0} must-fix · ${c.counts?.warning??0} should-fix · ${c.counts?.info??0} notes${c.scope?` (${c.scope})`:""}`,l.appendChild(h),c?.at!=null){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn",E.textContent=m("gpui.mgmt.fab.findings","Findings"),E.addEventListener("click",()=>this.togglePanel("checks")),l.appendChild(E)}if(!c?.running){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn",E.textContent=m("gpui.mgmt.fab.reviewbtn","Review"),E.addEventListener("click",()=>n("review")),l.appendChild(E)}if(c?.judge){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn",E.textContent=m("gpui.mgmt.fab.judge","Datasheets"),E.addEventListener("click",()=>{if(c.judge)this.cb.onSendText(c.judge)}),l.appendChild(E)}p.appendChild(l),a.appendChild(p);let u=os(t.drc?.state??""),f=document.createElement("div");f.className="bp-mgmt-row";let b=document.createElement("div");b.className="bp-mgmt-row-line";let v=document.createElement("span");if(v.className="bp-mgmt-flex1 "+(u.button?"bp-tone-warn":"bp-dim"),v.textContent=u.text,b.appendChild(v),u.button){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn",E.textContent=u.button,E.addEventListener("click",()=>n("drc")),b.appendChild(E)}f.appendChild(b),a.appendChild(f);for(let E of t.conflicts??[]){let k=document.createElement("div");k.className="bp-mgmt-row bp-tone-bad",k.textContent=E,a.appendChild(k)}for(let E of t.suggestions??[]){let k=document.createElement("div");k.className="bp-mgmt-row";let L=document.createElement("div");L.className="bp-mgmt-row-line";let M=document.createElement("span");M.className="bp-mgmt-flex1 bp-tone-warn",M.textContent=`${E.label||E.key}: board ${E.project??"?"} mm, fab ${E.fab??"?"} mm`;let A=document.createElement("button");A.type="button",A.className="bp-mgmt-btn",A.textContent=m("gpui.mgmt.fab.apply","Apply"),A.addEventListener("click",()=>n("apply",{key:E.key})),L.append(M,A),k.appendChild(L),a.appendChild(k)}if(t.stackup?.chosen){let E=document.createElement("div");E.className="bp-mgmt-row";let k=document.createElement("div");k.className="bp-mgmt-row-line";let L=t.stackup.by==="proposed",M=document.createElement("span");if(M.className="bp-mgmt-flex1 "+(L?"bp-tone-warn":"bp-dim"),M.textContent=`${L?"Proposed: ":""}${t.stackup.chosen}${t.stackup.outer_50_mm?` (50Ω ${t.stackup.outer_50_mm} mm)`:""}`,k.appendChild(M),L){let A=t.stackup.chosen,B=document.createElement("button");B.type="button",B.className="bp-mgmt-btn",B.textContent=m("gpui.mgmt.fab.use","Use"),B.addEventListener("click",()=>n("stackup",{id:A})),k.appendChild(B)}E.appendChild(k),a.appendChild(E)}if(Array.isArray(t.changed)&&t.changed.length>0){let E=document.createElement("div");E.className="bp-mgmt-row";let k=document.createElement("div");k.className="bp-mgmt-row-line";let L=document.createElement("span");L.className="bp-mgmt-flex1 bp-tone-warn",L.textContent=m("gpui.mgmt.fab.changed","Changed since you last looked");let M=document.createElement("button");M.type="button",M.className="bp-mgmt-btn",M.textContent=m("gpui.mgmt.fab.seen","Seen"),M.addEventListener("click",()=>n("seen")),k.append(L,M),E.appendChild(k);for(let A of t.changed.slice(0,12)){let B=document.createElement("div");B.className="bp-mgmt-faint",B.textContent=A,E.appendChild(B)}a.appendChild(E)}let w=Array.isArray(t.limits)?t.limits:[];if(w.length>0){let E=document.createElement("div");E.className="bp-mgmt-group-head";let k=document.createElement("span");k.className="bp-mgmt-flex1",k.textContent=m("gpui.mgmt.fab.limit","Limit");let L=document.createElement("span");L.className="bp-mgmt-col",L.textContent=m("gpui.mgmt.fab.free","Base price");let M=document.createElement("span");M.className="bp-mgmt-col",M.textContent=m("gpui.mgmt.fab.extra","Costs more");let A=document.createElement("span");A.className="bp-mgmt-col bp-mgmt-col-read",A.textContent=m("gpui.mgmt.fab.readcol","Read"),E.append(k,L,M,A),a.appendChild(E);for(let T of w){let H=document.createElement("div");H.className="bp-mgmt-row";let O=document.createElement("div");O.className="bp-mgmt-row-line";let P=document.createElement("span");P.className="bp-mgmt-flex1"+(T.changed?" bp-tone-warn":T.inherited?" bp-dim":""),P.textContent=`${T.changed?"• ":""}${T.label??""}`;let Y=document.createElement("span");Y.className="bp-mgmt-col",Y.textContent=T.free?.text||"—";let re=document.createElement("span");re.className="bp-mgmt-col bp-dim",re.textContent=T.extra?.text||"—";let ie=T.free&&typeof T.free==="object"?T.free:T.extra,me=ie?.fetched??"",Pe=Boolean(me)&&ie?.confidence!=="published",Ce=me?Pe?`${me}*`:me:"—",te=ie?.source??"",oe;if(te.startsWith("https://")&&me){let R=document.createElement("a");R.className="bp-mgmt-col bp-mgmt-col-read bp-mgmt-read-link",R.href=te,R.target="_blank",R.rel="noopener noreferrer",R.textContent=Ce,oe=R}else{let R=document.createElement("span");R.className="bp-mgmt-col bp-mgmt-col-read bp-mgmt-faint",R.textContent=Ce,oe=R}O.append(P,Y,re,oe),H.appendChild(O),a.appendChild(H)}let B=document.createElement("div");B.className="bp-mgmt-note bp-mgmt-faint",B.textContent=m("gpui.mgmt.fab.derived","* worked out from the fab's page. Dimmed: the rigid board's value. A date opens the source page."),a.appendChild(B)}return e.appendChild(a),e}makeEmpty(e){let t=document.createElement("div");return t.className="bp-mgmt-note bp-mgmt-faint",t.textContent=e,t}}var ro={trs:(e)=>e,t:(e,t)=>t},oo=new Set(["/settle"]);function ks(e,t){let n=t.trim().toLowerCase();if(!n)return 1;let i=e.toLowerCase();if(i.startsWith(n))return 3;if(i.split(/[^a-z0-9]+/i).some((o)=>o.startsWith(n)))return 2;let r=0;for(let o=0;o0||e.status==="waiting")return{urgency:3,want:"waiting"};if(e.status==="asking")return{urgency:2,want:"question"};if(e.status==="failed"||e.state==="failed")return{urgency:1,want:"failed"};return{urgency:0,want:""}}function Ps(e){let t=e.status||e.state;if(t==="active"||t==="working")return"bp-dot-work";if(t==="finished")return"bp-dot-done";if(t==="waiting"||t==="asking"||t==="blocked"||t==="failed"||(e.waiting??0)>0)return"bp-dot-need";return"bp-dot-idle"}function Ss(e,t){let n=t.trim().split(/\s+/)[0]?.toLowerCase()??"";if(!n)return null;let i=e.toLowerCase();if(i.length!==e.length)return null;let s=i.indexOf(n);if(s<0)return null;return[s,s+n.length]}function Ls(e,t=ro){let{t:n,trs:i}=t,s=[],r=new Map;for(let a of e.projects)r.set(a.id,a.title||a.id);let o=e.threads.find((a)=>a.id===e.selectedThreadId)??null;for(let a of e.railItems){if(a.state==="disabled"||a.id==="commands")continue;if(!o&&a.id!=="terminal")continue;s.push({label:i(a.label),place:a.id==="terminal"?"":"viewer",kind:"action",shortcut:a.key?a.key.toUpperCase():void 0,action:{type:"rail",id:a.id}})}if(o){if(s.push({label:o.pinned?n("menu.unpin","Unpin"):n("menu.pin","Pin"),place:"",kind:"action",action:{type:"thread-act",action:o.pinned?"unpin":"pin"}}),s.push({label:o.settled?n("phone.unsettle","Unsettle"):n("menu.settle","Settle"),place:"",kind:"action",action:{type:"thread-act",action:o.settled?"unsettle":"settle"}}),s.push({label:o.archived?n("palette.unarchive","Unarchive"):n("palette.archive","Archive"),place:"",kind:"action",action:{type:"thread-act",action:o.archived?"unarchive":"archive"}}),o.project==="chats")s.push({label:n("chats.move","Move to project…"),place:"",kind:"action",action:{type:"move-project"}});s.push({label:n("sheet.rename","Rename thread"),place:"",kind:"action",action:{type:"rename"}}),s.push({label:n("gpui.previous.thread","Previous thread"),place:"",kind:"action",action:{type:"prev-thread"}}),s.push({label:n("gpui.next.thread","Next thread"),place:"",kind:"action",action:{type:"next-thread"}})}if(o)for(let a of e.commands){if(!a.word)continue;let c=oo.has(a.word.toLowerCase());s.push({label:a.label?`${a.word} — ${a.label}`:a.word,place:a.desc||"command",kind:"command",action:{type:"command",word:a.word,runDirectly:c}})}s.push({label:n("gpui.improvements","Improvements"),place:"",kind:"action",action:{type:"improvements"}}),s.push({label:n("palette.settings","Settings"),place:"",kind:"action",action:{type:"settings"}}),s.push({label:n("gpui.fold.or.unfold.the.sidebar","Fold or unfold the sidebar"),place:"",kind:"action",action:{type:"sidebar"}}),s.push({label:n("chats.new.noproject","New chat (no project)"),place:"",kind:"action",action:{type:"new-chat"}});for(let a of e.projects)s.push({label:`New thread in ${a.title||a.id}`,place:"",kind:"action",action:{type:"new-thread",projectId:a.id}});for(let a of e.threads){let{urgency:c,want:p}=xs(a);s.push({label:a.title||"Untitled thread",place:a.project==="chats"?n("chats.title","Chats"):a.project?r.get(a.project)??"":"",kind:"thread",urgency:c,want:p,dotClass:Ps(a),action:{type:"thread",id:a.id}})}for(let a of e.bots){if(!a.name||!a.thread)continue;s.push({label:a.name,place:"",kind:"bot",action:{type:"thread",id:a.thread}})}return s}function As(e,t,n,i=[],s=10,r=14){let o=t.trim(),a=o.length===0,c=e.slice();if(n?.threads&&n.threads.length>0){let d=new Map;for(let f of i)d.set(f.id,f.title||f.id);let u=new Set;for(let f of c)if(f.action.type==="thread")u.add(f.action.id);for(let f of n.threads){if(!f.id||u.has(f.id))continue;u.add(f.id);let{urgency:b,want:v}=xs(f);c.push({label:f.title||"Untitled thread",place:f.project?d.get(f.project)??"":"",kind:"thread",urgency:b,want:v,dotClass:Ps(f),action:{type:"thread",id:f.id}})}}let p=[];for(let d=0;d0)p.push({score:v,index:d,item:u})}p.sort((d,u)=>{if(a){let v=(u.item.urgency??0)-(d.item.urgency??0);if(v!==0)return v}if(u.score!==d.score)return u.score-d.score;let f=d.item.kind==="thread"?0:1,b=u.item.kind==="thread"?0:1;if(f!==b)return f-b;return d.index-u.index});let l=new Set,h=[];for(let d of p){let u=`${d.item.label}\x00${d.item.place}\x00${d.item.kind}`;if(l.has(u))continue;if(l.add(u),h.push(d.item),h.length>=s)break}if(n?.messages&&n.messages.length>0&&h.length{if(o.target===t)this.close()}),s.addEventListener("input",()=>{this.query=s.value,this.activeIdx=0,this.renderList(),this.scheduleSearch()}),s.addEventListener("keydown",(o)=>{if(o.key==="Escape")o.preventDefault(),o.stopPropagation(),this.close();else if(o.key==="ArrowDown"){if(o.preventDefault(),this.listed.length>0)this.activeIdx=(this.activeIdx+1)%this.listed.length,this.renderList(!0)}else if(o.key==="ArrowUp"){if(o.preventDefault(),this.listed.length>0)this.activeIdx=(this.activeIdx-1+this.listed.length)%this.listed.length,this.renderList(!0)}else if(o.key==="Enter")o.preventDefault(),this.runAt(this.activeIdx)}),this.backdrop=t,this.inputEl=s,this.listEl=r,this.root.appendChild(t),this.renderList(),this.query.trim().length>=2)this.scheduleSearch();s.focus()}close(){if(this.searchTimer!==null)window.clearTimeout(this.searchTimer),this.searchTimer=null;if(this.searchGen++,this.backdrop)this.backdrop.remove(),this.backdrop=null,this.inputEl=null,this.listEl=null;this.prevFocus?.focus(),this.prevFocus=null}scheduleSearch(){if(this.searchTimer!==null)window.clearTimeout(this.searchTimer),this.searchTimer=null;let e=this.query.trim();if(e.length<2){this.searchHits=null,this.searchHitsQuery="";return}if(e===this.searchHitsQuery)return;let t=++this.searchGen;this.searchTimer=window.setTimeout(()=>{this.searchTimer=null,this.cb.onSearch(e).then((n)=>{if(t!==this.searchGen||!this.backdrop)return;if(this.query.trim()!==e)return;this.searchHits=n,this.searchHitsQuery=e,this.renderList()}).catch(()=>{})},180)}runAt(e){let t=this.listed[e];if(!t)return;this.close(),this.cb.onExecute(t.action)}renderList(e=!1){if(!this.listEl)return;let t=this.cb.getState(),n=Ls(t,{t:m,trs:he}),i=this.query.trim()===this.searchHitsQuery?this.searchHits:null;if(this.listed=As(n,this.query,i,t.projects),this.activeIdx>=this.listed.length)this.activeIdx=Math.max(0,this.listed.length-1);if(this.listed.length===0){let o=document.createElement("div");o.className="bp-palette-empty",o.textContent=m("gpui.nothing.matches","Nothing matches"),this.listEl.replaceChildren(o);return}let s=document.createDocumentFragment(),r=null;for(let o=0;o0)p.appendChild(document.createTextNode(a.label.slice(0,d)));let f=document.createElement("strong");if(f.className="bp-palette-mark",f.textContent=a.label.slice(d,u),p.appendChild(f),u{if(this.activeIdx!==o)this.activeIdx=o,this.updateActiveClass()}),c.addEventListener("click",()=>this.runAt(o)),o===this.activeIdx)r=c;s.appendChild(c)}if(this.listEl.replaceChildren(s),e&&r)r.scrollIntoView({block:"nearest"})}updateActiveClass(){if(!this.listEl)return;let e=this.listEl.children;for(let t=0;t0?Math.floor(t.leadDays):0,i=[];for(let s of mn(t.warnings)){let r=it(s).trim();if(r&&!i.includes(r))i.push(r)}return{project:it(t.project),root:it(t.root),intent:it(t.intent),parts:mn(t.parts).map((s)=>Gn(s)).map((s)=>({name:it(s.name),kind:it(s.kind),path:it(s.path)})).filter((s)=>s.name||s.path),boards:mn(t.boards).map(it).filter(Boolean),mech:mn(t.mech).map((s)=>Gn(s)).map((s)=>({path:it(s.path),name:it(s.name),size:typeof s.size==="number"&&s.size>0?s.size:0})).filter((s)=>s.name||s.path),leadDays:n,warnings:i}}function Vn(e){let t=[];for(let n of e.split(` -`)){let i=n.trimEnd();if(!i.trim())continue;if(t.length>=60)break;let s=i.trimStart();if(s.startsWith("#"))t.push({kind:"h",text:s.replace(/^#+/,"").trim()});else if(s.startsWith("- ")||s.startsWith("* "))t.push({kind:"li",text:s.slice(2).trim()});else t.push({kind:"p",text:s})}return t}function Ms(e){return!Vn(e).some((t)=>t.kind!=="h"&&t.text.length>0)}function Ts(e){if(!Number.isFinite(e)||e<=0)return"";if(e<1024)return`${Math.floor(e)} B`;if(e<1048576)return`${(e/1024).toFixed(e<10240?1:0)} KB`;return`${(e/1048576).toFixed(1)} MB`}function Un(e){let t=e.lastIndexOf("|");return t>=0?e.slice(t+1):e}function be(e,t,n){let i=document.createElement(e);if(t)i.className=t;if(n!==void 0)i.textContent=n;return i}class Wn{root;titleEl;rootEl;newBtn;newLbl;threadsEl;bodyEl;cb;projectId="";data=null;threads=null;error="";constructor(e,t){this.cb=t,this.root=be("section","bp-project-home bp-hidden"),this.root.setAttribute("data-testid","project-home");let n=be("div","bp-home-inner"),i=be("header","bp-home-head");this.titleEl=be("h1","bp-home-title"),this.titleEl.setAttribute("data-testid","project-home-title"),this.rootEl=be("div","bp-home-root"),i.append(this.titleEl,this.rootEl);let s=be("div","bp-home-bar");this.newBtn=be("button","primary bp-home-new"),this.newBtn.type="button",this.newBtn.setAttribute("data-testid","project-home-new-thread");let r=be("span","bp-home-new-plus","+");r.setAttribute("aria-hidden","true"),this.newLbl=be("span","",m("thread.new","New thread")),this.newBtn.append(r,this.newLbl),this.newBtn.addEventListener("click",()=>{if(this.projectId)this.cb.onNewThread(this.projectId)}),s.appendChild(this.newBtn),this.threadsEl=be("div","bp-home-threads"),this.bodyEl=be("div","bp-home-body"),n.append(i,s,this.threadsEl,this.bodyEl),this.root.appendChild(n),e.appendChild(this.root)}isOpen(){return this.projectId!==""}show(e){if(this.projectId!==e.id)this.data=null,this.threads=null,this.root.scrollTop=0;this.error="",this.projectId=e.id,this.titleEl.textContent=e.title||e.id,this.root.classList.remove("bp-hidden"),this.render()}hide(){this.projectId="",this.root.classList.add("bp-hidden")}setTitle(e){if(e)this.titleEl.textContent=e}setData(e){this.data=e,this.error="",this.render()}setThreads(e){this.threads=e,this.render()}setError(e){this.error=e,this.render()}refreshLocale(){if(this.newLbl.textContent=m("thread.new","New thread"),this.isOpen())this.render()}section(e){return be("h2","bp-home-section",e)}render(){this.rootEl.textContent=this.data?.root??"",this.rootEl.classList.toggle("bp-hidden",!this.data?.root),this.renderThreads(),this.renderBody()}renderThreads(){let e=document.createDocumentFragment(),t=this.threads;if(t){if(e.appendChild(this.section(m("gpui.projects.threads","THREADS ({n})",{n:t.length}))),t.length===0)e.appendChild(be("div","bp-home-empty",m("gpui.no.threads.yet","No threads yet.")));for(let n of t){let i=be("button","bp-home-row bp-home-thread"+(n.settled?" bp-dim":""));i.type="button",i.setAttribute("data-testid",`project-home-thread-${n.id}`);let s=be("span",`bp-dot ${n.dot}`);if(n.status)s.title=n.status;let r=be("span","bp-home-row-main",n.title||"Untitled thread"),o=be("span","bp-home-row-faint",n.age);i.append(s,r,o),i.addEventListener("click",()=>this.cb.onOpenThread(n.id)),e.appendChild(i)}}this.threadsEl.replaceChildren(e)}renderBody(){let e=document.createDocumentFragment(),t=this.data;if(this.error){let s=be("div","bp-home-error");s.setAttribute("data-testid","project-home-error"),s.appendChild(be("span","",this.error));let r=be("button","bp-btn-ghost",m("tools.retry","Retry"));r.type="button";let o=this.projectId;r.addEventListener("click",()=>this.cb.onRetry(o)),s.appendChild(r),e.appendChild(s)}if(!t){if(!this.error)e.appendChild(be("div","bp-home-empty",m("web.home.loading","Loading project…")));this.bodyEl.replaceChildren(e);return}e.appendChild(this.section(m("gpui.goal.notes","GOAL & NOTES")));let n=be("div","bp-home-intent");if(n.setAttribute("data-testid","project-home-intent"),Ms(t.intent))e.appendChild(be("div","bp-home-empty",m("gpui.no.goal.yet.ask.an","No goal yet. Ask an agent to write what this project is for, or edit .backplane/intent.md.")));else{for(let s of Vn(t.intent))if(s.kind==="h")n.appendChild(be("div","bp-home-intent-h",s.text));else if(s.kind==="li"){let r=be("div","bp-home-intent-li"),o=be("span","bp-home-bullet","•");o.setAttribute("aria-hidden","true"),r.append(o,be("span","",s.text)),n.appendChild(r)}else n.appendChild(be("div","",s.text));e.appendChild(n)}let i=this.threads?.[0]?.id??"";if(t.mech.length>0)e.appendChild(this.section(m("gpui.projects.mech","MECHANICAL ({n})",{n:t.mech.length}))),t.mech.forEach((s,r)=>{let o=r===0&&t.mech.length>1,a=this.fileRow(i,"mech",`project-home-mech-${r}`);if(a.title=s.path,a.appendChild(be("span","bp-home-row-main",s.name||s.path)),o)a.appendChild(be("span","bp-home-row-accent",m("gpui.assembly","Assembly")));a.appendChild(be("span","bp-home-row-faint",Ts(s.size))),e.appendChild(a)});if(t.parts.length>0){e.appendChild(this.section(m("gpui.projects.to.order","TO ORDER ({n})",{n:t.parts.length})));let s=be("div","bp-home-order");if(s.setAttribute("data-testid","project-home-order"),t.parts.forEach((r,o)=>{let a=be("div","bp-home-row");a.setAttribute("data-testid",`project-home-part-${o}`),a.append(be("span","bp-home-row-main",r.name||r.path),be("span","bp-home-row-dim",r.kind),be("span","bp-home-row-faint",r.path)),s.appendChild(a)}),t.leadDays>0){let r=be("div","bp-home-order-note",t.leadDays===1?m("web.home.lead.one","Lead time: 1 day"):m("web.home.lead","Lead time: {n} days",{n:t.leadDays}));r.setAttribute("data-testid","project-home-lead"),s.appendChild(r)}for(let r of t.warnings){let o=be("div","bp-home-order-note warn",r);o.setAttribute("data-testid","project-home-warning"),s.appendChild(o)}e.appendChild(s)}if(t.boards.length>0)e.appendChild(this.section(m("gpui.projects.boards","BOARDS ({n})",{n:t.boards.length}))),t.boards.forEach((s,r)=>{let o=this.fileRow(i,"board",`project-home-board-${r}`);o.appendChild(be("span","bp-home-row-main",s)),e.appendChild(o)});this.bodyEl.replaceChildren(e)}fileRow(e,t,n){if(!e){let s=be("div","bp-home-row");return s.setAttribute("data-testid",n),s}let i=be("button","bp-home-row bp-home-open");return i.type="button",i.setAttribute("data-testid",n),i.addEventListener("click",()=>this.cb.onOpenViewer(e,t)),i}}function _n(e){let t=null;if(typeof e==="string"){let i=e.trim();if(!i)return null;try{let s=JSON.parse(i);if(s&&typeof s==="object"&&!Array.isArray(s))t=s}catch{return null}}else if(e&&typeof e==="object"&&!Array.isArray(e))t=e;if(!t)return null;let n=typeof t.head==="string"?t.head.trim():"";if(!n)return null;return{reason:typeof t.reason==="string"?t.reason:"",head:n,text:typeof t.text==="string"?t.text:"",button:typeof t.button==="string"&&t.button.trim()?t.button:"Open Settings → Accounts",url:typeof t.url==="string"&&t.url.trim()?t.url:"backplane://settings/accounts"}}function ao(e){return e.startsWith("No AI provider connected yet.")}function Bs(e,t){if(t==="no_provider")return!0;if(t)return!1;return ao(e)}function st(e){return typeof e==="string"?e:""}function zn(e){return typeof e==="number"&&Number.isFinite(e)?e:0}function Is(e){let t=e&&typeof e==="object"?e:{},n=[];for(let i of Array.isArray(t.notes)?t.notes:[]){if(!i||typeof i!=="object")continue;let s=i,r=st(s.id);if(!r)continue;n.push({id:r,said:zn(s.said),gesture:st(s.gesture),words:st(s.words),model:st(s.model),conf:typeof s.conf==="number"&&Number.isFinite(s.conf)?s.conf:null,unsure:st(s.unsure),state:st(s.state),error:st(s.error),thread:st(s.thread),play:st(s.play),heard:zn(s.heard)})}return{total:Math.max(zn(t.total),n.length),notes:n,busy:st(t.busy)}}function Rs(e){let t=/\/ring\/audio\/(n[0-9a-f]{16})(?:\.m4a)?\?k=([0-9a-fA-F]+)$/.exec(e);return t?`/ring/audio/${t[1]}?k=${t[2]}`:""}function js(e){if(!e.model)return{key:"web.ring.not.heard",fallback:"Not heard"};if(e.model==="ring")return{key:"web.ring.app.words",fallback:"The Pebble app's words"};if(e.conf!==null)return{key:"web.ring.heard.by.sure",fallback:"Heard by {model}, {conf}% sure",vars:{model:e.model,conf:Math.round(e.conf)}};return{key:"web.ring.heard.by",fallback:"Heard by {model}",vars:{model:e.model}}}function Hs(e,t){if(t)return{key:"web.ring.state.busy",fallback:"being heard now"};switch(e){case"sent":return{key:"web.ring.state.sent",fallback:"given to Pebble"};case"new":return{key:"web.ring.state.new",fallback:"waiting to be heard"};case"heard":return{key:"web.ring.state.heard",fallback:"waiting to go to Pebble"};case"failed":return{key:"web.ring.state.failed",fallback:"not given to Pebble"};default:return{key:"",fallback:e}}}function Ds(e,t,n){if(e<=0)return{key:"ring.no.recordings.yet",fallback:"No recordings yet."};if(n.trim())return{key:"web.ring.found",fallback:"{found} of {total} have “{q}”.",vars:{found:t,total:e,q:n.trim()}};return e===1?{key:"web.ring.count.one",fallback:"1 recording"}:{key:"web.ring.count",fallback:"{n} recordings",vars:{n:e}}}var Fs="http://www.w3.org/2000/svg",$s={terminal:["M4 17l6-6-6-6","M12 19h8"],search:["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z","M21 21l-4.3-4.3"],"circuit-board":["M3 3h18v18H3z","M9 3v6h6","M9 21v-6","M15 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4z","M9 15a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"],cpu:["M6 6h12v12H6z","M9 2v4","M15 2v4","M9 18v4","M15 18v4","M2 9h4","M2 15h4","M18 9h4","M18 15h4"],box:["M21 16V8l-9-5-9 5v8l9 5 9-5z","M3.3 7L12 12l8.7-5","M12 22V12"],gauge:["M12 14l4-4","M3.3 19a10 10 0 1 1 17.4 0"],"file-stack":["M16 2H6v12h10V2z","M20 6v12H10","M4 18h10v4H4z"],"layout-panel-left":["M3 3h18v18H3z","M10 3v18"],layers:["M12 2L2 7l10 5 10-5-10-5z","M2 12l10 5 10-5","M2 17l10 5 10-5"],wrench:["M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"],folder:["M3 6h6l2 2h10v11H3z"],diff:["M12 5v10","M7 10h10","M7 19h10"],"circle-check":["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M9 12l2 2 4-4"],globe:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M2 12h20","M12 2a15 15 0 0 1 0 20 15 15 0 0 1 0-20z"]};function lo(e){let t=document.createElementNS(Fs,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.75"),t.setAttribute("stroke-linecap","square"),t.setAttribute("stroke-linejoin","miter"),t.setAttribute("aria-hidden","true");let n=$s[e]??$s.folder;for(let i of n){let s=document.createElementNS(Fs,"path");s.setAttribute("d",i),t.appendChild(s)}return t}class qn{el;items=[];activeId="";onPress;pagesRo=null;constructor(e,t){this.el=e,this.onPress=t,this.render()}setItems(e){this.items=e.slice(),this.render()}setActive(e){this.activeId=e,this.render()}renderButton(e){let t=e.state==="disabled",n=!t&&(e.state==="on"||this.activeId!==""&&e.id===this.activeId),i=he(e.label),s=e.why?he(e.why):"",r=document.createElement("button");if(r.type="button",r.className="bp-rail-btn"+(n?" active":"")+(t?" disabled":""),r.disabled=t,r.setAttribute("aria-pressed",n?"true":"false"),t){if(r.title=s||i,s)r.setAttribute("data-why",s)}else r.title=e.key?`${i} (${e.key.toUpperCase()})`:i;r.setAttribute("data-rail-id",e.id),r.setAttribute("data-testid",`rail-${e.id}`),r.appendChild(lo(e.icon));let o=document.createElement("span");if(o.className="bp-rail-lbl",o.textContent=i,r.appendChild(o),!t)r.addEventListener("click",()=>this.onPress(e.id));return r}render(){let e=this.items.filter((o)=>o.group!=="tools"),t=this.items.filter((o)=>o.group==="tools"),n=document.createElement("div");n.className="bp-rail-pages";let i;for(let o of e){if(i!==void 0&&o.group!==i){let a=document.createElement("div");a.className="bp-rail-rule",n.appendChild(a)}i=o.group,n.appendChild(this.renderButton(o))}let s=()=>{let o=n.scrollLeft>2,a=n.scrollLeft+n.clientWidth0){let o=document.createElement("div");o.className="bp-rail-tools";for(let a of t)o.appendChild(this.renderButton(a));r.appendChild(o)}this.el.replaceChildren(r)}}var co=new Set(["resume","raise","retry","move","signin"]);function Kn(e){if(!e||typeof e!=="object")return null;let t=e,n=(r)=>typeof r==="string"?r:"",i=(Array.isArray(t.actions)?t.actions:[]).filter((r)=>Boolean(r)&&typeof r==="object").map((r)=>({label:n(r.label),act:n(r.act),room:n(r.room),thread:n(r.thread)})),s={line:n(t.line),why:n(t.why),actions:i};return s.line||i.length?s:null}function un(e,t){if(e.act==="board")return t&&e.room?{kind:"board",room:e.room}:null;if(e.act==="open")return e.thread?{kind:"thread",id:e.thread}:null;if(co.has(e.act)){let n={room:e.room,action:e.act};if(e.thread)n.thread=e.thread;return{kind:"call",method:"swarm.act",params:n}}return null}function Os(e){let t=e&&typeof e==="object"?e.open:void 0;if(typeof t!=="string")return null;let n=t.indexOf(":"),i=n<0?"":t.slice(n+1);if(!i)return null;if(t.startsWith("account:"))return{kind:"account",id:i};if(t.startsWith("thread:"))return{kind:"thread",id:i};return null}var Yn=[{id:"general",label:"General"},{id:"ai",label:"Agents and tools"},{id:"connect",label:"Connect"}],Tt=[{id:"appearance",group:"general",title:"Appearance",subtitle:"Kept in this browser only. Never sent to the hub.",icon:"sun",keywords:["theme","dark","light","auto","color","language","locale","english","espanol","japanese"]},{id:"providers",group:"ai",title:"AI providers",subtitle:"Account sign-ins live in the desktop or mobile app.",icon:"cpu",keywords:["accounts","claude","codex","antigravity","grok","openai","anthropic","signin","login","model"]},{id:"ring",group:"ai",title:"Ring",subtitle:"Voice notes from your Pebble ring. Its webhook is set up in the desktop or mobile app.",icon:"mic",keywords:["pebble","index","voice","note","notes","recording","recordings","play","hear","transcribe","search"]},{id:"devices",group:"connect",title:"Devices & browser",subtitle:"This browser session and paired devices on this hub.",icon:"link",keywords:["sign out","logout","session","cookie","revoke","paired","phone","browser","pair"]},{id:"home",group:"connect",title:"Home machine",subtitle:"Which machine hosts your always-on hub and bots.",icon:"globe",keywords:["host","boat","move","online","away","queued","linked"]}];function Gs(e){if(e==="dark"||e==="light"||e==="auto")return e;return"auto"}function Vs(e){if(e==="en"||e==="es"||e==="ja"||e==="auto")return e;return"auto"}function Wt(e,t){if(e==="dark"||e==="light")return e;return t==="light"?"light":"dark"}function Us(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function Jn(e,t){if(t.length===0)return!0;let n=e.toLowerCase();return t.every((i)=>n.includes(i))}function Ws(e,t){let n=Us(t);if(n.length===0)return[];return e.filter((i)=>{let s=[i.groupLabel,i.pageTitle,i.rowTitle,i.rowDetail,...i.keywords??[]].join(" ");return Jn(s,n)})}function Xn(e,t,n){let i=Us(n);if(i.length===0)return e.map((o)=>({page:o,hits:[]}));let s=new Map(Yn.map((o)=>[o.id,o.label])),r=[];for(let o of e){let c=t.filter((l)=>l.pageId===o.id).filter((l)=>Jn([l.rowTitle,l.rowDetail,l.pageTitle,l.groupLabel,...l.keywords??[]].join(" "),i));if(Jn([s.get(o.group)??"",o.title,o.subtitle,...o.keywords].join(" "),i)||c.length>0){let l=[];for(let h of c){if(!l.includes(h.rowTitle))l.push(h.rowTitle);if(l.length>=2)break}r.push({page:o,hits:l})}}return r}function Qn(e){return e.key?m(e.key,e.fallback,e.vars):e.fallback}function po(e){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width","15"),n.setAttribute("height","15"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.75"),n.setAttribute("stroke-linecap","square"),n.setAttribute("stroke-linejoin","miter"),n.setAttribute("aria-hidden","true");let i=(s,r)=>{let o=document.createElementNS("http://www.w3.org/2000/svg",s);for(let[a,c]of Object.entries(r))o.setAttribute(a,c);n.appendChild(o)};switch(e){case"sun":i("circle",{cx:"12",cy:"12",r:"4"}),i("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41M2 12h2m16 0h2M4.93 19.07l1.41-1.41m11.32-11.32 1.41-1.41"});break;case"cpu":i("rect",{x:"5",y:"5",width:"14",height:"14"}),i("rect",{x:"9",y:"9",width:"6",height:"6"}),i("path",{d:"M9 2v3m6-3v3M9 19v3m6-3v3M2 9h3m-3 6h3M19 9h3m-3 6h3"});break;case"link":i("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),i("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"});break;case"mic":i("rect",{x:"9",y:"2",width:"6",height:"12"}),i("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8"});break;case"globe":i("circle",{cx:"12",cy:"12",r:"10"}),i("path",{d:"M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"});break}return n}function ho(){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","13"),t.setAttribute("height","13"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.75"),t.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("cx","11"),n.setAttribute("cy","11"),n.setAttribute("r","7");let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d","m20 20-3.5-3.5"),t.append(n,i),t}function bn(e,t){switch(e){case"general":return m("gpui.settings.group.general",t);case"ai":return m("gpui.settings.group.agents",t);case"connect":return m("native.pair.connect",t)}}function gt(e,t){switch(e){case"appearance":return m("settings.appearance",t);case"providers":return m("web.settings.providers",t);case"ring":return m("ring.ring",t);case"devices":return t;case"home":return m("home.machine",t)}}class Zn{backdrop;titleEl;badgeEl;closeBtn;navListEl;searchInput;searchClearBtn;paneEl;cb;openState=!1;activePage="appearance";forceProviders=!1;query="";searchBrowseAll=!1;devicesLoaded=!1;devicesLoading=!1;devicesRows=[];devicesError="";loadGen=0;ringLoaded=!1;ringLoading=!1;ringList={total:0,notes:[],busy:""};ringCountEl=null;ringErrorEl=null;ringRows=new Map;ringShownQuery="";ringError="";ringQuery="";ringDraft="";ringGen=0;ringBusy=new Set;ringPolls=0;ringTimers=[];constructor(e,t){this.cb=t,this.backdrop=document.createElement("div"),this.backdrop.className="bp-modal-backdrop bp-hidden",this.backdrop.setAttribute("data-testid","settings-modal");let n=document.createElement("div");n.className="bp-modal bp-settings-modal",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-labelledby","bp-settings-title");let i=document.createElement("div");i.className="bp-modal-head";let s=document.createElement("div");s.className="bp-settings-head-title",this.titleEl=document.createElement("h2"),this.titleEl.id="bp-settings-title",this.titleEl.textContent=m("palette.settings","Settings"),this.badgeEl=document.createElement("span"),this.badgeEl.className="bp-settings-badge",this.badgeEl.textContent="Browser",s.append(this.titleEl,this.badgeEl),this.closeBtn=document.createElement("button"),this.closeBtn.type="button",this.closeBtn.className="icon",this.closeBtn.textContent="×",this.closeBtn.setAttribute("aria-label",m("common.close","Close")),this.closeBtn.addEventListener("click",()=>this.close()),i.append(s,this.closeBtn);let r=document.createElement("div");r.className="bp-settings-body";let o=document.createElement("aside");o.className="bp-settings-nav";let a=document.createElement("div");a.className="bp-settings-search";let c=document.createElement("span");c.className="bp-settings-search-icon",c.appendChild(ho()),this.searchInput=document.createElement("input"),this.searchInput.type="text",this.searchInput.className="bp-settings-search-input",this.searchInput.placeholder="Search settings…",this.searchInput.setAttribute("aria-label","Search settings"),this.searchInput.setAttribute("data-testid","settings-search"),this.searchClearBtn=document.createElement("button"),this.searchClearBtn.type="button",this.searchClearBtn.className="bp-settings-search-clear bp-hidden",this.searchClearBtn.textContent="×",this.searchClearBtn.title="Clear search",this.searchClearBtn.setAttribute("aria-label","Clear search"),a.append(c,this.searchInput,this.searchClearBtn),this.navListEl=document.createElement("nav"),this.navListEl.className="bp-settings-nav-list",this.navListEl.setAttribute("aria-label","Settings sections"),o.append(a,this.navListEl),this.paneEl=document.createElement("div"),this.paneEl.className="bp-settings-pane",r.append(o,this.paneEl),n.append(i,r),this.backdrop.appendChild(n),this.backdrop.addEventListener("click",(p)=>{if(p.target===this.backdrop)this.close()}),this.searchInput.addEventListener("input",()=>{this.query=this.searchInput.value,this.searchBrowseAll=this.query.trim().length>0,this.syncSearchClear(),this.render()}),this.searchInput.addEventListener("keydown",(p)=>{if(p.key==="Enter"){let l=Xn(Tt,this.buildSearchItems(),this.query);if(l.length>0)p.preventDefault(),this.activePage=l[0].page.id,this.searchBrowseAll=!1,this.render()}else if(p.key==="Escape"&&this.query.trim().length>0)p.preventDefault(),p.stopPropagation(),this.clearSearch()}),this.searchClearBtn.addEventListener("click",()=>{this.clearSearch(),this.searchInput.focus()}),e.appendChild(this.backdrop)}isOpen(){return this.openState}handleEscape(){if(!this.openState)return;if(this.query.trim().length>0)this.clearSearch(),this.searchInput.focus();else this.close()}async open(e){if(this.openState=!0,e)this.activePage=e;if(this.backdrop.classList.remove("bp-hidden"),this.render(),this.loadDevices(),this.activePage==="ring")this.loadRing();window.setTimeout(()=>{if(this.openState)this.searchInput.focus()},0)}async openToAccounts(){this.forceProviders=!0,this.query="",this.searchInput.value="",this.searchBrowseAll=!1,this.syncSearchClear(),await this.open("providers")}close(){this.openState=!1,this.forceProviders=!1,this.query="",this.searchInput.value="",this.searchBrowseAll=!1,this.syncSearchClear(),this.backdrop.classList.add("bp-hidden");for(let e of this.ringTimers)window.clearTimeout(e);if(this.ringTimers=[],this.ringBusy.clear(),this.ringPolls=0,this.activePage==="ring")this.paneEl.replaceChildren()}refreshLocale(){if(this.titleEl.textContent=m("palette.settings","Settings"),this.closeBtn.setAttribute("aria-label",m("common.close","Close")),this.openState)this.render()}async refresh(){if(!this.openState)return;this.render(),await this.loadDevices()}clearSearch(){this.query="",this.searchInput.value="",this.searchBrowseAll=!1,this.syncSearchClear(),this.render()}syncSearchClear(){this.searchClearBtn.classList.toggle("bp-hidden",this.query.length===0)}async loadDevices(){let e=++this.loadGen;if(this.devicesLoading=!this.devicesLoaded,this.devicesLoading&&this.openState)this.renderPane();try{let t=await this.cb.onLoadDevices();if(e!==this.loadGen)return;this.devicesRows=t,this.devicesError="",this.devicesLoaded=!0}catch(t){if(e!==this.loadGen)return;let n=t instanceof Error&&t.message?t.message:"Not available from a browser";this.devicesError=`${n} — manage paired devices in Backplane › Settings › Devices on desktop or a paired phone.`,this.devicesRows=[],this.devicesLoaded=!0}finally{if(e===this.loadGen){if(this.devicesLoading=!1,this.openState)this.render()}}}async loadRing(){if(!this.cb.onRingList||!(this.cb.hasRing?.()??!1))return;let e=++this.ringGen;if(this.ringLoading=!this.ringLoaded,this.ringLoading)this.showRing();try{let t=await this.cb.onRingList(this.ringQuery);if(e!==this.ringGen)return;if(this.ringList=t,this.ringError="",!t.busy)this.ringBusy.clear();if(t.busy&&this.openState&&this.ringPolls<40)this.ringPolls++,this.ringLater(3000);else if(!t.busy)this.ringPolls=0}catch(t){if(e!==this.ringGen)return;this.ringError=t instanceof Error&&t.message?t.message:m("web.ring.error","Could not load recordings.")}finally{if(e===this.ringGen)this.ringLoaded=!0,this.ringLoading=!1,this.showRing()}}ringLater(e){let t=window.setTimeout(()=>{if(this.ringTimers=this.ringTimers.filter((n)=>n!==t),this.openState)this.loadRing()},e);this.ringTimers.push(t)}ringIsBusy(e){return this.ringBusy.has(e)||this.ringList.busy===e}showRing(){if(!this.openState||this.activePage!=="ring"||this.query.trim()&&this.searchBrowseAll)return;let e=this.ringList.notes.map((i)=>i.id),t=Array.from(this.ringRows.keys());if(!(this.ringCountEl?.isConnected===!0&&this.ringShownQuery===this.ringQuery&&e.length===t.length&&e.every((i,s)=>i===t[s]))){this.renderPane();return}if(this.ringCountEl)this.ringCountEl.textContent=this.ringCountLine();if(this.ringErrorEl)this.ringErrorEl.textContent=this.ringError,this.ringErrorEl.classList.toggle("bp-hidden",!this.ringError);for(let i of this.ringList.notes)this.fillRingNote(i)}ringCountLine(){return this.ringLoading?m("web.ring.loading","Loading recordings…"):Qn(Ds(this.ringList.total,this.ringList.notes.length,this.ringQuery))}fillRingNote(e){let t=this.ringRows.get(e.id);if(!t)return;let n=this.ringIsBusy(e.id);t.state.className="bp-status-pill "+(n?"accent":e.state==="sent"?"ok":e.state==="failed"?"bad":"warn"),t.state.textContent=Qn(Hs(e.state,n)),t.words.className="bp-ring-words"+(e.words?"":" bp-dim"),t.words.textContent=e.words||m("web.ring.no.words","(no words)"),t.meta.textContent=[Qn(js(e)),e.unsure,e.error].filter(Boolean).join(" · ");for(let i of t.hear)i.disabled=n}async hearRing(e,t){if(!this.cb.onRingHear||this.ringIsBusy(e))return;this.ringBusy.add(e),this.ringError="",this.showRing();try{await this.cb.onRingHear(e,t),this.ringPolls=0,this.ringLater(1500)}catch(n){this.ringBusy.delete(e),this.ringError=n instanceof Error&&n.message?n.message:m("web.ring.error","Could not load recordings."),this.showRing()}}buildSearchItems(){let e=this.cb.onGetHome?.()??null,t=this.cb.onGetNoProvider?.()??null,n=bn("general","General"),i=bn("ai","Agents and tools"),s=bn("connect","Connect"),r=gt("appearance","Appearance"),o=gt("providers","AI providers"),a=gt("devices","Devices & browser"),c=gt("home","Home machine"),p=[{pageId:"appearance",pageTitle:r,groupLabel:n,rowTitle:m("settings.theme","Theme"),rowDetail:"Auto (follow hub), Dark, or Light in this browser.",keywords:["theme","dark","light","auto","appearance","colors"]},{pageId:"appearance",pageTitle:r,groupLabel:n,rowTitle:m("settings.lang","Language"),rowDetail:"Interface language for this browser.",keywords:["locale","english","espanol","japanese","language"]},{pageId:"providers",pageTitle:o,groupLabel:i,rowTitle:t?he(t.head):"Provider connections",rowDetail:"Connect Claude, Codex, Antigravity, or other AI providers in Settings → Accounts.",keywords:["accounts","claude","codex","antigravity","grok","openai","signin"]},{pageId:"ring",pageTitle:gt("ring","Ring"),groupLabel:i,rowTitle:m("ring.recordings","Recordings"),rowDetail:"Read, search, play and hear again the voice notes from your Pebble ring.",keywords:["pebble","voice","note","recording","play","hear","transcribe"]},{pageId:"devices",pageTitle:a,groupLabel:s,rowTitle:"This browser",rowDetail:"Sign out and revoke this browser's session cookie.",keywords:["logout","sign out","session","cookie"]},{pageId:"devices",pageTitle:a,groupLabel:s,rowTitle:"Paired devices",rowDetail:this.devicesRows.map((l)=>`${l.title||l.head||""} ${l.detail||l.text||""}`).join(" ")||"Paired phones and browsers on this hub.",keywords:["phone","pair","revoke","browser"]},{pageId:"home",pageTitle:c,groupLabel:s,rowTitle:e?.name?`${e.name}`:c,rowDetail:"Which machine hosts your always-on hub and bots.",keywords:["boat","move","online","away","queued","machine"]}];for(let l of this.devicesRows){let h=l.title||l.head||"";if(h)p.push({pageId:"devices",pageTitle:a,groupLabel:s,rowTitle:h,rowDetail:l.detail||l.text||"",keywords:["paired","device"]})}return p}render(){this.renderNav(),this.renderPane()}renderNav(){let e=document.createDocumentFragment(),t=Xn(Tt,this.buildSearchItems(),this.query),n=this.cb.onGetNoProvider?.()??null,i=this.cb.onGetHome?.()??null;if(t.length===0){let r=document.createElement("div");r.className="bp-settings-nav-empty",r.setAttribute("data-testid","settings-nav-empty"),r.textContent="No matching settings",e.appendChild(r),this.navListEl.replaceChildren(e);return}let s="";for(let r of t){let o=r.page;if(o.group!==s){s=o.group;let d=Yn.find((u)=>u.id===o.group);if(d){let u=document.createElement("div");u.className="bp-settings-group",u.textContent=bn(d.id,d.label),e.appendChild(u)}}let a=document.createElement("button");a.type="button";let c=!this.searchBrowseAll&&o.id===this.activePage;a.className="bp-settings-nav-item"+(c?" active":""),a.setAttribute("data-testid",`settings-nav-${o.id}`);let p=document.createElement("div");p.className="bp-settings-nav-row";let l=document.createElement("span");l.className="bp-settings-nav-icon",l.appendChild(po(o.icon));let h=document.createElement("span");if(h.className="bp-settings-nav-label",h.textContent=gt(o.id,o.title),p.append(l,h),o.id==="providers"&&(n||this.forceProviders)){let d=document.createElement("span");d.className="bp-settings-nav-dot warn",d.title="Action needed",p.appendChild(d)}else if(o.id==="home"&&i){let d=document.createElement("span");d.className="bp-settings-nav-dot "+(i.moving?.state==="failed"?"bad":i.online?"ok":"warn"),p.appendChild(d)}if(a.appendChild(p),r.hits.length>0)for(let d of r.hits){let u=document.createElement("div");u.className="bp-settings-hit",u.textContent=d,a.appendChild(u)}a.addEventListener("click",()=>{if(this.activePage=o.id,this.searchBrowseAll=!1,this.render(),o.id==="ring")this.loadRing()}),e.appendChild(a)}this.navListEl.replaceChildren(e)}renderPane(){let e=document.createDocumentFragment(),t=this.query.trim();if(t&&this.searchBrowseAll){this.renderSearchResults(e,t),this.paneEl.replaceChildren(e);return}let n=Tt.find((o)=>o.id===this.activePage)??Tt[0],i=document.createElement("div");i.className="bp-settings-pane-head";let s=document.createElement("h3");s.textContent=gt(n.id,n.title);let r=document.createElement("div");switch(r.className="bp-settings-pane-sub",r.textContent=n.subtitle,i.append(s,r),e.appendChild(i),n.id){case"appearance":this.renderAppearancePage(e);break;case"providers":this.renderProvidersPage(e);break;case"ring":this.renderRingPage(e);break;case"devices":this.renderDevicesPage(e);break;case"home":this.renderHomePage(e);break}this.paneEl.replaceChildren(e)}renderSearchResults(e,t){let n=Ws(this.buildSearchItems(),t),i=document.createElement("div");i.className="bp-settings-pane-head";let s=document.createElement("h3");s.textContent="Search results";let r=document.createElement("div");if(r.className="bp-settings-pane-sub",r.textContent=n.length===0?`No settings match "${t}".`:`${n.length} matching ${n.length===1?"setting":"settings"} for "${t}"`,i.append(s,r),e.appendChild(i),n.length===0){let a=document.createElement("div");a.className="bp-settings-empty",a.textContent="Try searching for theme, language, providers, sign out, devices, or home.",e.appendChild(a);return}let o=Array.from(new Set(n.map((a)=>a.pageId)));for(let a of o){let c=Tt.find((u)=>u.id===a);if(!c)continue;let p=document.createElement("div");p.className="bp-settings-search-sec";let l=document.createElement("div");l.className="bp-settings-subhead",l.textContent=gt(c.id,c.title);let h=document.createElement("button");h.type="button",h.className="bp-settings-search-open",h.textContent="Open page ›",h.addEventListener("click",()=>{if(this.activePage=a,this.searchBrowseAll=!1,this.render(),a==="ring")this.loadRing()}),p.append(l,h),e.appendChild(p);let d=new Set(n.filter((u)=>u.pageId===a).map((u)=>u.rowTitle));if(a==="appearance")this.renderAppearancePage(e,d);else if(a==="providers")this.renderProvidersPage(e);else if(a==="ring"){let u=document.createElement("div");u.className="bp-settings-empty",u.textContent="Read, search, play and hear again the voice notes from your Pebble ring.",e.appendChild(u)}else if(a==="devices")this.renderDevicesPage(e,d);else if(a==="home")this.renderHomePage(e)}}renderAppearancePage(e,t){let n=this.cb.onGetThemePref?.()??"auto",i=this.cb.onGetHubTheme?.()??"dark",s=Wt(n,i),r=this.cb.onGetLocalePref?.()??"auto",o=m("settings.theme","Theme"),a=m("settings.lang","Language");if(!t||t.has(o)){let c=m("settings.theme.dark","Dark"),p=m("settings.theme.light","Light"),l=n==="auto"?`Following hub theme (${i==="light"?p:c}). Stored in this browser only.`:`Using ${s==="light"?p:c} in this browser. Select Auto to follow the hub.`;e.appendChild(this.makeSegmentedRow(o,l,[{value:"auto",label:"Auto"},{value:"dark",label:c},{value:"light",label:p}],n,"settings-theme",(h)=>{this.cb.onSetThemePref?.(h),this.render()}))}if(!t||t.has(a))e.appendChild(this.makeSegmentedRow(a,"Interface language for this browser. Automatic follows the hub or browser language.",[{value:"auto",label:m("settings.lang.auto","Automatic")},{value:"en",label:m("settings.lang.en","English")},{value:"es",label:m("settings.lang.es","Español")},{value:"ja",label:m("settings.lang.ja","日本語")}],r,"settings-locale",(c)=>{this.cb.onSetLocalePref?.(c),this.render()}))}makeSegmentedRow(e,t,n,i,s,r){let o=document.createElement("div");o.className="bp-settings-row";let a=document.createElement("div");a.className="bp-settings-row-info";let c=document.createElement("div");c.className="bp-settings-row-title",c.textContent=e;let p=document.createElement("div");p.className="bp-settings-row-detail",p.textContent=t,a.append(c,p);let l=document.createElement("div");l.className="bp-chip-group",l.setAttribute("role","group"),l.setAttribute("aria-label",e);for(let h of n){let d=document.createElement("button");d.type="button";let u=h.value===i;d.className="bp-chip"+(u?" active":""),d.textContent=h.label,d.setAttribute("aria-pressed",u?"true":"false"),d.setAttribute("data-testid",`${s}-${h.value}`),d.addEventListener("click",()=>r(h.value)),l.appendChild(d)}return o.append(a,l),o}renderProvidersPage(e){let t=this.cb.onGetNoProvider?.()??null,n=document.createElement("section");if(n.className="bp-settings-section",n.setAttribute("data-testid","settings-providers"),t||this.forceProviders){let i=document.createElement("div");i.className="bp-settings-notice warn";let s=document.createElement("div");s.className="bp-settings-row-info";let r=document.createElement("div");r.className="bp-settings-row-title",r.textContent=t?he(t.head):m("provider.notice.head","No AI provider connected");let o=document.createElement("div");o.className="bp-settings-row-detail",o.textContent=m("web.settings.providers.browser","Connect a provider in the Backplane desktop or mobile app under Settings → Accounts."),s.append(r,o);let a=document.createElement("div");a.className="bp-set-btns";let c=document.createElement("a");c.className="bp-link-btn primary",c.href=t?.url||"backplane://settings/accounts",c.setAttribute("data-testid","settings-open-accounts"),c.textContent=t?he(t.button):m("provider.notice.button","Open Settings → Accounts"),a.appendChild(c),i.append(s,a),n.appendChild(i)}else{let i=document.createElement("div");i.className="bp-settings-row";let s=document.createElement("div");s.className="bp-settings-row-info";let r=document.createElement("div");r.className="bp-settings-row-title-wrap";let o=document.createElement("span");o.className="bp-settings-row-title",o.textContent="Provider connections";let a=document.createElement("span");a.className="bp-status-pill ok",a.textContent=m("gpui.acct.connected","Connected"),r.append(o,a);let c=document.createElement("div");c.className="bp-settings-row-detail",c.textContent="Provider sign-ins, fallback order, API keys, and usage limits are managed in the Backplane desktop or mobile app.",s.append(r,c);let p=document.createElement("div");p.className="bp-set-btns";let l=document.createElement("a");l.className="bp-link-btn",l.href="backplane://settings/accounts",l.setAttribute("data-testid","settings-open-accounts"),l.textContent=m("provider.notice.button","Open Settings → Accounts"),p.appendChild(l),i.append(s,p),n.appendChild(i)}e.appendChild(n)}renderDevicesPage(e,t){let n=!t||t.has("This browser"),i=!t||t.has("Paired devices")||this.devicesRows.some((o)=>t.has(o.title||o.head||""));if(n){let o=document.createElement("div");o.className="bp-settings-subhead",o.textContent="This browser",e.appendChild(o);let a=document.createElement("div");a.className="bp-settings-row";let c=document.createElement("div");c.className="bp-settings-row-info";let p=document.createElement("div");p.className="bp-settings-row-title",p.textContent="Browser session";let l=document.createElement("div");l.className="bp-settings-row-detail",l.textContent="Sign out and revoke this browser's session cookie.",c.append(p,l);let h=document.createElement("button");h.type="button",h.className="primary stop",h.textContent=m("agy.signout","Sign out"),h.setAttribute("data-testid","logout-btn"),h.addEventListener("click",()=>{h.disabled=!0,this.cb.onLogout().catch(()=>{l.setAttribute("role","alert"),l.className="bp-settings-row-detail bp-bad",l.textContent=m("web.logout.failed","Could not confirm sign-out. Try again."),h.disabled=!1})}),a.append(c,h),e.appendChild(a)}if(!i)return;let s=document.createElement("div");if(s.className="bp-settings-subhead",s.textContent="Paired devices",e.appendChild(s),this.devicesLoading){let o=document.createElement("div");o.className="bp-settings-empty",o.textContent="Loading paired devices…",e.appendChild(o);return}if(this.devicesError){let o=document.createElement("div");o.className="bp-settings-notice bad";let a=document.createElement("div");a.className="bp-settings-row-detail",a.textContent=this.devicesError,o.appendChild(a),e.appendChild(o);return}let r=!t||t.has("Paired devices")?this.devicesRows:this.devicesRows.filter((o)=>t.has(o.title||o.head||""));if(r.length===0){let o=document.createElement("div");o.className="bp-settings-empty",o.textContent="No paired devices listed.",e.appendChild(o)}else for(let o of r){let a=document.createElement("div");a.className="bp-settings-row";let c=document.createElement("div");c.className="bp-settings-row-info";let p=document.createElement("div");p.className="bp-settings-row-title-wrap";let l=document.createElement("span");l.className="bp-settings-row-title",l.textContent=o.title||o.head||"",p.appendChild(l);let h=o.detail||o.text||"";if(h){let d=document.createElement("span"),u=h.toLowerCase();d.className="bp-status-pill "+(u.includes("this browser")?"accent":"neutral"),d.textContent=h,p.appendChild(d)}if(c.appendChild(p),a.appendChild(c),o.buttons?.length){let d=document.createElement("div");d.className="bp-set-btns";for(let u of o.buttons){let f=document.createElement("button");if(f.type="button",u.primary)f.className="primary";if(u.danger)f.className="primary stop";f.textContent=u.label||m("common.remove","Remove"),f.addEventListener("click",()=>{f.disabled=!0,this.cb.onDevicesAct(u.action,u.value).finally(()=>{this.refresh()})}),d.appendChild(f)}a.appendChild(d)}e.appendChild(a)}if(!t){let o=document.createElement("div");o.className="bp-settings-footnote",o.textContent="Pair new browsers or phones, configure Tailscale HTTPS forwarding, or revoke access in desktop or mobile Settings → Devices.",e.appendChild(o)}}renderRingPage(e){let t=document.createElement("section");if(t.className="bp-settings-section",t.setAttribute("data-testid","settings-ring"),!this.cb.onRingList||!(this.cb.hasRing?.()??!1)){let a=document.createElement("div");a.className="bp-settings-empty",a.textContent=m("web.ring.unavailable","This hub does not show ring notes to a browser yet. Update it, or open Settings › Ring in the desktop app."),t.appendChild(a),e.appendChild(t);return}let n=document.createElement("form");n.className="bp-ring-search";let i=document.createElement("input");i.type="search",i.className="bp-ring-search-input",i.placeholder=m("ring.search.what.you.said","Search what you said"),i.setAttribute("aria-label",m("ring.search.what.you.said","Search what you said")),i.setAttribute("data-testid","ring-search"),i.value=this.ringDraft,i.addEventListener("input",()=>{this.ringDraft=i.value});let s=document.createElement("button");if(s.type="submit",s.className="primary",s.textContent=m("common.search","Search"),n.append(i,s),this.ringQuery){let a=document.createElement("button");a.type="button",a.className="bp-btn-ghost",a.textContent=m("ring.show.all","Show all"),a.addEventListener("click",()=>{this.ringDraft="",this.ringQuery="",this.loadRing()}),n.appendChild(a)}n.addEventListener("submit",(a)=>{a.preventDefault(),this.ringQuery=this.ringDraft.trim(),this.loadRing()}),t.appendChild(n);let r=document.createElement("div");r.className="bp-settings-notice bad"+(this.ringError?"":" bp-hidden"),r.setAttribute("data-testid","ring-error"),r.textContent=this.ringError,t.appendChild(r),this.ringErrorEl=r;let o=document.createElement("div");o.className="bp-ring-count",o.setAttribute("data-testid","ring-count"),o.textContent=this.ringCountLine(),t.appendChild(o),this.ringCountEl=o,this.ringRows.clear(),this.ringShownQuery=this.ringQuery;for(let a of this.ringList.notes)t.appendChild(this.renderRingNote(a));e.appendChild(t)}renderRingNote(e){let t=document.createElement("div");t.className="bp-ring-note"+(e.state==="failed"?" bad":""),t.setAttribute("data-testid",`ring-note-${e.id}`);let n=document.createElement("div");n.className="bp-ring-note-head";let i=document.createElement("span");i.className="bp-settings-row-title";let s=e.said>0?new Date(e.said*1000).toLocaleString(Mi(),{dateStyle:"medium",timeStyle:"short"}):"";i.textContent=[s,e.gesture].filter(Boolean).join(" · ");let r=document.createElement("span");n.append(i,r);let o=document.createElement("div"),a=document.createElement("div");a.className="bp-settings-row-detail";let c=[],p=document.createElement("div");p.className="bp-ring-acts";let l=Rs(e.play);if(l){let h=document.createElement("audio");h.className="bp-ring-audio",h.controls=!0,h.preload="none",h.src=l,h.setAttribute("data-testid",`ring-audio-${e.id}`),p.appendChild(h);for(let[d,u]of[["local",m("ring.hear.again.local","Hear again (local)")],["openai",m("ring.hear.again.openai","Hear again (OpenAI)")]]){let f=document.createElement("button");f.type="button",f.className="bp-btn-ghost",f.textContent=u,f.setAttribute("data-testid",`ring-hear-${d}-${e.id}`),c.push(f),f.addEventListener("click",()=>{this.hearRing(e.id,d)}),p.appendChild(f)}}if(e.thread&&this.cb.onOpenThread){let h=document.createElement("button");h.type="button",h.className="bp-btn-ghost",h.textContent=m("ring.what.happened","What happened"),h.addEventListener("click",()=>{this.close(),this.cb.onOpenThread?.(e.thread)}),p.appendChild(h)}if(t.append(n,o,a),p.childElementCount>0)t.appendChild(p);return this.ringRows.set(e.id,{state:r,words:o,meta:a,hear:c}),this.fillRingNote(e),t}renderHomePage(e){let t=this.cb.onGetHome?.()??null,n=document.createElement("section");if(n.className="bp-settings-section",n.setAttribute("data-testid","settings-home"),!t){let d=document.createElement("div");d.className="bp-settings-empty",d.textContent="Single-hub mode — this hub is running locally without linked home machines.",n.appendChild(d),e.appendChild(n);return}let i=document.createElement("div");i.className="bp-settings-row";let s=document.createElement("div");s.className="bp-settings-row-info";let r=document.createElement("div");r.className="bp-settings-row-title-wrap";let o=document.createElement("span");o.className="bp-settings-row-title",o.textContent=t.name||(t.kind==="boat"?"Boat":"This machine"),r.appendChild(o);let a=document.createElement("span");a.className="bp-status-pill neutral",a.textContent=t.kind==="local"?"This machine":t.kind==="boat"?"Boat":"Linked machine",r.appendChild(a);let c=document.createElement("span"),p="Online",l="ok";if(t.moving?.state==="moving")p="Moving",l="accent";else if(t.moving?.state==="failed")p="Move failed",l="bad";else if(!t.online)p="Away",l="warn";c.className=`bp-status-pill ${l}`,c.textContent=p,r.appendChild(c);let h=document.createElement("div");if(h.className="bp-settings-row-detail",t.moving?.state==="moving")h.textContent=t.moving.step?m("home.moving.step","Moving home to {to}: {step}").replace("{to}",t.moving.to).replace("{step}",t.moving.step):m("home.moving","Moving home to {to}…").replace("{to}",t.moving.to);else if(t.moving?.state==="failed")h.textContent=t.moving.note?m("home.move.failed.note","Home move failed: {note}").replace("{note}",t.moving.note):m("home.move.failed","Home move failed");else if(!t.online)h.textContent=t.queuedCount>0?m("home.away.queued","Home ({name}) is away · {n} queued").replace("{name}",t.name||"home").replace("{n}",String(t.queuedCount)):m("home.away","Home ({name}) is away").replace("{name}",t.name||"home");else h.textContent="Your active home hub is online and serving threads and bots.";if(s.append(r,h),i.appendChild(s),t.canMoveHere&&this.cb.onMoveHomeHere){let d=document.createElement("button");d.type="button",d.className="primary",d.textContent=m("home.move.here","Make this machine the home"),d.setAttribute("data-testid","home-move-here-btn"),d.addEventListener("click",()=>{d.disabled=!0,this.cb.onMoveHomeHere?.().finally(()=>{this.refresh()})}),i.appendChild(d)}n.appendChild(i),e.appendChild(n)}}function xe(e,t,n){let i=document.createElement(e);if(t)i.className=t;if(n)i.textContent=n;return i}function _t(e,t,n=!1){let i=xe("button",n?"primary":"bp-btn-ghost",e);return i.type="button",i.addEventListener("click",t),i}function ei(e){return xe("pre","bp-context-code",e)}function mo(e){return xe("span",`bp-context-badge ${e==="Native"||e==="Enabled"?"active":e==="Untrusted"||e==="Invalid"?"warn":""}`,he(e))}function gn(e,t){let n=xe("div","bp-context-row");return n.append(xe("strong",void 0,e),mo(t)),n}class ti{fetchContext;dialog=xe("dialog","bp-context");title=xe("h2");cwd=xe("div","bp-context-path");tabs=xe("div","bp-context-tabs");body=xe("div","bp-context-body");notice=xe("p","bp-context-notice");current;thread="";requestId=0;tab=0;busy=!1;constructor(e,t){this.fetchContext=t;let n=xe("div","bp-context-head"),i=xe("div");i.append(this.title,this.cwd),this.title.id="bp-context-title",this.dialog.setAttribute("aria-labelledby",this.title.id),this.notice.setAttribute("role","status"),n.append(i,_t(m("common.refresh","Refresh"),()=>{this.load()}),_t(m("common.close","Close"),()=>this.dialog.close())),this.dialog.append(n,this.tabs,this.notice,this.body),this.dialog.addEventListener("close",()=>{this.requestId++}),e.append(this.dialog)}open(e){if(this.thread=e,this.tab=0,this.current=void 0,this.busy=!1,this.title.textContent=m("thread.context.title","Context & Prompt"),this.cwd.textContent="",!this.dialog.open)this.dialog.showModal();this.render(),this.load()}async load(e){if(this.busy)return;let t=++this.requestId;this.busy=!0,this.notice.textContent=m("thread.context.reading","Reading thread context…"),this.render();try{let n=await this.fetchContext(this.thread,e);if(t!==this.requestId)return;this.current=n,this.cwd.textContent=n.cwd,this.notice.textContent=""}catch(n){if(t===this.requestId)this.notice.textContent=String(n)}finally{if(t===this.requestId)this.busy=!1,this.render()}}render(){let e=[m("thread.context.instructions","Instructions"),m("thread.context.system","System Prompt"),m("thread.context.skills","Skills"),m("thread.context.mcp","Project MCPs")];this.tabs.replaceChildren(...e.map((n,i)=>{let s=_t(n,()=>{this.tab=i,this.render(),this.body.scrollTop=0,this.tabs.children[i].focus()});return s.setAttribute("aria-pressed",String(i===this.tab)),s})),this.body.replaceChildren();let t=this.current;if(!t)return;switch(this.tab){case 0:this.instructions(t.instructions);break;case 1:this.prompt(t);break;case 2:this.skills(t.skills);break;case 3:this.mcps(t.mcp);break}}instructions(e){if(!e.length)this.body.append(xe("p","bp-dim",m("thread.context.none.instructions","No project instructions found.")));for(let t of e){let n=xe("details","bp-context-card"),i=xe("summary");if(i.append(gn(t.path,t.status),xe("small","bp-dim",m("thread.context.size","{bytes} B · ≈{tokens} tokens",{bytes:t.bytes,tokens:t.estimated_tokens}))),n.append(i,ei(t.preview)),t.note)n.append(xe("small","bp-dim",t.note));this.body.append(n)}}prompt(e){let t=xe("div","bp-context-row"),n=_t(m("thread.context.copy","Copy prompt"),()=>{navigator.clipboard.writeText(e.prompt).then(()=>{this.notice.textContent=m("thread.context.copied","Prompt copied.")}).catch((i)=>{this.notice.textContent=String(i)})});t.append(xe("p","bp-dim",m("thread.context.native.note","Backplane’s launch prompt. Native files are loaded by the provider.")),n),this.body.append(t);for(let[i,s]of[[m("thread.context.base","Backplane"),e.sections.base],[m("thread.context.injected.label","Injected project instructions"),e.sections.instructions],[m("thread.context.index","Available skills index"),e.sections.skills]])if(s)this.body.append(xe("h3",void 0,i),ei(s))}skills(e){for(let t of["Project","User","Bundled"]){let n=e.filter((i)=>i.scope===t);if(!n.length)continue;this.body.append(xe("h3",void 0,he(t)));for(let i of n){let s=xe("article","bp-context-card");s.append(gn(i.name,i.status),xe("p",void 0,i.description),xe("small","bp-context-path",[i.source,i.provider,i.model].filter(Boolean).join(" · ")),xe("small","bp-context-path",i.path)),this.body.append(s)}}}mcps(e){if(!e.length)this.body.append(xe("p","bp-dim",m("thread.context.none.mcp","No project MCP configurations found.")));for(let t of e){let n=xe("article","bp-context-card");n.append(gn(t.path,t.state));for(let s of t.servers){let r=s.url||[s.command,...s.args].map((o)=>JSON.stringify(o)).join(" ");if(n.append(gn(s.name,s.status),ei(r)),s.cwd)n.append(xe("small","bp-context-path",s.cwd))}if(t.error)n.append(xe("p","bp-warn",t.error));let i=t.state==="Untrusted"?"trust":t.state==="Enabled"?"disable":t.state==="Disabled"?"enable":"";if(i){let s=i==="trust"?m("thread.context.trust","Trust and enable"):i==="disable"?m("thread.context.disable","Disable"):m("thread.context.enable","Enable"),r=_t(s,()=>{this.load({action:i,path:t.path,sha256:t.sha256})},i==="trust");r.disabled=this.busy;let o=xe("div","bp-context-actions");o.append(r),n.append(o)}this.body.append(n)}}}var yt="chats";function Js(e){return e.filter((t)=>t.id&&t.id!==yt&&t.id!=="scratch"&&!t.id.includes("~")).slice().sort((t,n)=>(t.title||t.id).toLowerCase().localeCompare((n.title||n.id).toLowerCase()))}function uo(e){if(!e)return null;if(e.moving?.state==="moving")return{text:e.moving.step?m("home.moving.step","Moving home to {to}: {step}").replace("{to}",e.moving.to).replace("{step}",e.moving.step):m("home.moving","Moving home to {to}…").replace("{to}",e.moving.to),isError:!1,dismissible:!1};if(e.moving?.state==="failed")return{text:e.moving.note?m("home.move.failed.note","Home move failed: {note}").replace("{note}",e.moving.note):m("home.move.failed","Home move failed"),isError:!0,dismissible:!0};if(!e.online){let t=e.name||"home",n="";if(e.awaySince&&e.awaySince>0){let s=new Date(e.awaySince);n=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`}let i="";if(n&&e.queuedCount>0)i=m("home.away.since.queued","Home ({name}) is away since {time} · {n} queued").replace("{name}",t).replace("{time}",n).replace("{n}",String(e.queuedCount));else if(n)i=m("home.away.since","Home ({name}) is away since {time}").replace("{name}",t).replace("{time}",n);else if(e.queuedCount>0)i=m("home.away.queued","Home ({name}) is away · {n} queued").replace("{name}",t).replace("{n}",String(e.queuedCount));else i=m("home.away","Home ({name}) is away").replace("{name}",t);return{text:i,isError:!1,dismissible:!1}}return null}function bo(e,t){if(e.settled)return!1;if(e.state==="done"||e.state==="stopped")return!1;if(!t)return!0;let n=e.working??0,i=Boolean(e.monitoring),s=Boolean(Kn(e.need))||e.word==="needs";return(n>0||i)&&e.state!=="paused"||s}function go(e){if(e.wake)return{icon:"◷",label:"Snoozed",tone:"dim"};let t=(e.label??"").trim(),n=(e.tone??"").trim();if(t){let s=t.toLowerCase();return{icon:s==="approve"||s==="sign in"?"!":s==="input"?"?":s==="failed"||s==="stopped"?"×":s==="working"||s==="running"?"▸":s==="waiting"?"◌":s==="done"?"✓":"•",label:t,tone:n==="bad"?s==="failed"||s==="stopped"?"bad-out":"bad":n==="run"?"run":n==="wait"?"wait":n==="ok"?"ok":"dim"}}let i=e.word||"";if(i==="needs"){if(e.want==="approval")return{icon:"!",label:"Approve",tone:"bad"};if(e.want==="sign-in")return{icon:"!",label:"Sign in",tone:"bad"};return{icon:"?",label:"Input",tone:"bad"}}if(i==="failed"||e.status==="failed"||e.state==="fail")return{icon:"×",label:"Failed",tone:"bad-out"};if(i==="cut"||i==="interrupted")return{icon:"×",label:"Stopped",tone:"bad-out"};if(i==="running"||e.status==="active"||e.status==="working"||e.state==="run")return{icon:"▸",label:"Working",tone:"run"};if(i==="monitoring"||i==="limit"||e.status==="waiting")return{icon:"◌",label:"Waiting",tone:"wait"};if(i==="done"||e.status==="finished")return{icon:"✓",label:"Done",tone:"ok"};return null}var _s="http://www.w3.org/2000/svg";function pt(e,t=14,n=""){let i=document.createElementNS(_s,"svg");if(i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(t)),i.setAttribute("height",String(t)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.75"),i.setAttribute("stroke-linecap","square"),i.setAttribute("stroke-linejoin","miter"),i.setAttribute("aria-hidden","true"),n)i.classList.add(...n.split(" "));for(let s of e){let r=document.createElementNS(_s,"path");r.setAttribute("d",s),i.appendChild(r)}return i}function zs(){return pt(["M3 6h6l2 2h10v11H3z"],14,"bp-folder-icon")}function qs(e=14,t="bp-folder-icon bp-hw-icon"){return pt(["M3 3h18v18H3z","M9 3v6h6","M9 21v-6","M15 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4z","M9 15a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"],e,t)}function fo(e=13){return pt(["M6 6h12v12H6z","M9 2v4","M15 2v4","M9 18v4","M15 18v4","M2 9h4","M2 15h4","M18 9h4","M18 15h4"],e)}function vo(e=15){return pt(["M4 10V4l4 3h8l4-3v6l-2 9H6z","M9 13h1","M14 13h1","M11 16h2"],e,"bp-cat-glyph")}function wo(e=11){return pt(["M4 12l5 5 11-11"],e)}function yo(e=13){return pt(["M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7","M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4z"],e)}function Eo(e=11){return pt(["M2 9V5a2 2 0 0 1 2-2h4l2 3h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2","M2 13h10","M9 16l3-3-3-3"],e)}function Co(){return typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||"")?"⌥⇧N":"Alt+Shift+N"}function ko(e=11){return pt(["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 6v6l4 2"],e)}function xo(e=11){return pt(["M12 17v5","M8 4h8l-1 5 3 3v2H6v-2l3-3z"],e,"bp-pin-icon")}function Ks(e){if(!e)return"";let t=e<10000000000?e*1000:e,n=Math.max(0,Math.floor((Date.now()-t)/1000));if(n<60)return"now";if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400)return`${Math.floor(n/3600)}h`;return`${Math.floor(n/86400)}d`}function Po(e){let t=e.replace(/^@/,"").trim();if(!t)return"?";let n=t.split(/[\s_-]+/).filter(Boolean);if(n.length>=2)return(n[0][0]+n[1][0]).toUpperCase();return t.slice(0,2).toUpperCase()}function ni(e){if(e==="wait"||e==="error")return"bp-mood-wait";if(e==="work"||e==="talk")return"bp-mood-work";return"bp-mood-idle"}function Qe(e){let t=e.lastIndexOf("|");return t>=0?e.slice(t+1):e}class ii{el;hostLabel;homeBanner;crewEl;filterInput;listEl;connEl;filterText="";allFilter="all";snoozeMenuRowId="";collapsedProjects=new Set;addShown=!1;sections=null;projects=[];selectedProjectId="";threads=[];bots=[];rooms=[];selectedThreadId="";cb;needErr=new Map;needBusy=new Set;constructor(e,t){this.el=e,this.cb=t;let n=document.createElement("div");n.className="bp-side-host";let i=document.createElement("div");i.className="bp-side-host-left",this.hostLabel=document.createElement("span"),this.hostLabel.textContent="This computer";let s=document.createElement("span");s.className="bp-dim",s.textContent="›",i.append(this.hostLabel,s);let r=document.createElement("button");r.type="button",r.className="icon bp-side-collapse",r.textContent="‹",r.title="Collapse sidebar",r.setAttribute("aria-label","Collapse sidebar"),r.setAttribute("data-testid","sidebar-collapse"),r.addEventListener("click",()=>this.cb.onCollapseSidebar?.()),n.append(i,r);let o=document.createElement("div");o.className="bp-side-head",this.filterInput=document.createElement("input"),this.filterInput.type="search",this.filterInput.className="bp-input bp-side-search";let a=m("sidebar.search.projects","Search projects, threads…");this.filterInput.placeholder=a,this.filterInput.setAttribute("aria-label",a),this.filterInput.setAttribute("data-testid","sidebar-filter"),this.filterInput.addEventListener("input",()=>{this.filterText=this.filterInput.value.trim().toLowerCase(),this.render()});let c=document.createElement("button");c.type="button",c.className="icon bp-side-add",c.textContent="+",c.title=m("thread.new","New thread"),c.setAttribute("aria-label",m("thread.new","New thread")),c.setAttribute("data-testid","sidebar-new-thread"),c.addEventListener("click",()=>{let d=this.firstProjectId();if(d)this.cb.onNewThread(d)});let p=document.createElement("button");p.type="button",p.className="icon bp-side-add bp-side-new-chat",p.appendChild(yo(13));let l=`${m("chats.new.noproject","New chat (no project)")} (${Co()})`;p.title=l,p.setAttribute("aria-label",m("chats.new.noproject","New chat (no project)")),p.setAttribute("data-testid","sidebar-new-chat"),p.addEventListener("click",()=>this.cb.onNewChat?.()),o.append(this.filterInput,p,c),this.homeBanner=document.createElement("div"),this.homeBanner.className="bp-side-home bp-hidden",this.homeBanner.setAttribute("data-testid","home-away-banner"),this.crewEl=document.createElement("div"),this.crewEl.className="bp-crew-band bp-hidden",this.crewEl.setAttribute("data-testid","sidebar-crew"),this.listEl=document.createElement("div"),this.listEl.className="bp-side-list",this.listEl.setAttribute("data-testid","sidebar-list");let h=document.createElement("div");h.className="bp-side-footer",this.connEl=document.createElement("span"),this.connEl.className="bp-conn-status",this.connEl.textContent="Connecting…",this.connEl.setAttribute("data-testid","conn-status"),h.appendChild(this.connEl),this.el.append(n,o,this.homeBanner,this.crewEl,this.listEl,h)}setHome(e){let t=uo(e);if(!t){this.homeBanner.className="bp-side-home bp-hidden",this.homeBanner.replaceChildren();return}this.homeBanner.className=t.isError?"bp-side-home bp-bad":"bp-side-home bp-dim";let n=document.createElement("span");if(n.className="bp-side-home-text",n.textContent=t.text,!t.dismissible){this.homeBanner.replaceChildren(n);return}let i=document.createElement("button");i.type="button",i.className="icon bp-side-home-dismiss",i.textContent="×",i.setAttribute("data-testid","home-move-dismiss");let s=m("approval.dismiss","Dismiss");i.title=s,i.setAttribute("aria-label",s),i.addEventListener("click",()=>this.cb.onDismissHomeMove?.()),this.homeBanner.replaceChildren(n,i)}setHostName(e){this.hostLabel.textContent=e||"This computer"}setConnStatus(e,t){this.connEl.textContent=e,this.connEl.className=`bp-conn-status ${t}`.trim()}setData(e,t,n,i){this.projects=e,this.threads=t,this.bots=n,this.rooms=i,this.render()}setSections(e,t,n){this.sections=e,this.bots=t,this.rooms=n,this.render()}setSelected(e){this.selectedThreadId=e,this.render()}setSelectedProject(e){if(this.selectedProjectId===e)return;this.selectedProjectId=e,this.render()}makeFoldChevron(e,t){let n=document.createElement("button");n.type="button",n.className="bp-proj-chev"+(e?" folded":""),n.textContent=e?"▸":"▾";let i=e?m("web.home.unfold","Show threads"):m("web.home.fold","Hide threads");return n.title=i,n.setAttribute("aria-label",i),n.setAttribute("aria-expanded",e?"false":"true"),n.setAttribute("data-testid",`project-fold-${t}`),n}focusFilter(){this.filterInput.focus()}firstProjectId(){if(this.sections){for(let e of this.sections)if(e.kind==="projects"&&e.rows.length>0){let t=e.rows[0];if(t.id&&!t.off)return t.id}}return this.projects[0]?.id??""}refreshLocale(){let e=m("sidebar.search.projects","Search projects, threads…");this.filterInput.placeholder=e,this.filterInput.setAttribute("aria-label",e),this.render()}renderCrewBand(e){let t=this.bots.find((c)=>c.uber),n=this.bots.filter((c)=>!c.uber&&(!e||c.name.toLowerCase().includes(e))),i=this.rooms.filter((c)=>!e||c.name.toLowerCase().includes(e)),s=Boolean(t&&(!e||t.name.toLowerCase().includes(e))),r=n.length>0||Boolean(this.cb.onNewBot)&&!e,o=i.length>0||Boolean(this.cb.onNewRoom)&&!e;if(!s&&!r&&!o){this.crewEl.classList.add("bp-hidden"),this.crewEl.replaceChildren();return}let a=document.createDocumentFragment();if(s&&t){let c=document.createElement("button");c.type="button",c.className="bp-crew-uber"+(t.thread===this.selectedThreadId?" active":""),c.setAttribute("data-testid",`crew-uber-${t.id}`);let p=document.createElement("span");if(p.className=`bp-crew-uber-avatar ${ni(t.mood)}`,t.color)p.style.color=t.color;p.appendChild(vo(14));let l=document.createElement("span");l.className="bp-crew-uber-meta";let h=document.createElement("span");if(h.className="bp-crew-uber-name",h.textContent=t.name,l.appendChild(h),t.note){let d=document.createElement("span");d.className=`bp-crew-uber-note ${ni(t.mood)}`,d.textContent=t.note,l.appendChild(d)}if(c.append(p,l),t.mood==="wait"||t.mood==="error"){let d=document.createElement("span");d.className="bp-status-pill bp-pill-bad",d.textContent="? Input",c.appendChild(d)}c.addEventListener("click",()=>this.cb.onSelectBot(t)),a.appendChild(c)}if(r){let c=document.createElement("div");c.className="bp-crew-bots",c.setAttribute("data-testid","crew-bots");let p=document.createElement("span");p.className="bp-crew-lbl",p.textContent=m("tour.title.bots","Bots").toUpperCase(),c.appendChild(p);let l=document.createElement("div");l.className="bp-crew-bot-tiles";for(let h of n){let d=document.createElement("button");if(d.type="button",d.className=`bp-crew-bot-tile ${ni(h.mood)}`+(h.thread===this.selectedThreadId?" active":""),d.title=h.note?`@${h.name} — ${h.note}`:`@${h.name}`,d.setAttribute("aria-label",`@${h.name}`),d.setAttribute("data-testid",`crew-bot-${h.id}`),h.color)d.style.setProperty("--bot-c",h.color);let u=document.createElement("span");if(u.className="bp-crew-bot-init",u.textContent=Po(h.name),d.appendChild(u),h.mood==="wait"||h.mood==="error"){let f=document.createElement("span");f.className="bp-crew-bot-wait",d.appendChild(f)}d.addEventListener("click",()=>this.cb.onSelectBot(h)),l.appendChild(d)}if(this.cb.onNewBot&&!e){let h=document.createElement("button");h.type="button",h.className="bp-crew-bot-tile bp-crew-add",h.textContent="+",h.title=m("bots.new","New bot"),h.setAttribute("aria-label",m("bots.new","New bot")),h.setAttribute("data-testid","crew-new-bot"),h.addEventListener("click",()=>this.cb.onNewBot?.()),l.appendChild(h)}c.appendChild(l),a.appendChild(c)}if(o){let c=document.createElement("div");c.className="bp-crew-rooms",c.setAttribute("data-testid","crew-rooms");for(let p of i){let l=document.createElement("button");l.type="button",l.className="bp-crew-room-chip",l.setAttribute("data-testid",`crew-room-${p.id}`);let h=document.createElement("span");h.className="bp-dim",h.textContent="#";let d=document.createElement("span");if(d.textContent=p.name,l.append(h,d),p.members!==void 0&&p.members>0){let u=document.createElement("span");u.className="bp-crew-room-cnt",u.textContent=String(p.members),l.appendChild(u)}l.title=p.members?`#${p.name} (${p.members})`:`#${p.name}`,l.addEventListener("click",()=>this.cb.onSelectRoom?.(p)),c.appendChild(l)}if(this.cb.onNewRoom&&!e){let p=document.createElement("button");p.type="button",p.className="bp-crew-room-chip bp-crew-add",p.textContent="+",p.title=m("rooms.new","New room"),p.setAttribute("aria-label",m("rooms.new","New room")),p.setAttribute("data-testid","crew-new-room"),p.addEventListener("click",()=>this.cb.onNewRoom?.()),c.appendChild(p)}a.appendChild(c)}this.crewEl.classList.remove("bp-hidden"),this.crewEl.replaceChildren(a)}projectsHead(e){let t=document.createElement("div");if(t.className="bp-side-section-head",!this.cb.onAddProject||this.addShown)return t.textContent=e,t;this.addShown=!0,t.classList.add("bp-side-section-row");let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.type="button",i.className="bp-side-sec-plus bp-side-sec-btn",i.textContent="+";let s=m("sidebar.add.project","Add project");return i.title=s,i.setAttribute("aria-label",s),i.setAttribute("data-testid","sidebar-add-project"),i.addEventListener("click",(r)=>{r.stopPropagation(),this.cb.onAddProject?.()}),t.append(n,i),t}renderStatusPill(e,t){let n=document.createElement("span");if(n.className=`bp-status-pill bp-pill-${e.tone}`,n.textContent=`${e.icon} ${e.label}`,t)n.title=t;return n}renderRowActions(e){if(e.off)return null;let t=Array.isArray(e.snooze)&&e.snooze.length>0&&Boolean(this.cb.onSnoozeRow),n=Boolean(e.wake)&&Boolean(this.cb.onSnoozeRow),i=e.kind==="swarm",s=Boolean(e.settle)&&(!i||Boolean(this.cb.onSettleSwarm)),r=Boolean(e.chat)&&Boolean(this.cb.onMoveToProject);if(!t&&!n&&!s&&!r)return null;let o=document.createElement("span");if(o.className="bp-row-acts",n&&e.wake){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-wake-btn",a.textContent=m("menu.wake","Wake"),a.title=m("menu.wake","Wake snoozed thread"),a.setAttribute("data-testid",`wake-row-${e.id}`),a.addEventListener("click",(c)=>{c.stopPropagation(),this.cb.onSnoozeRow?.(e.wake)}),o.appendChild(a)}if(t&&e.snooze){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-snooze-btn",a.title=m("menu.snooze","Snooze thread"),a.setAttribute("aria-label",m("menu.snooze","Snooze thread")),a.setAttribute("data-testid",`snooze-row-${e.id}`),a.appendChild(ko(11)),a.addEventListener("click",(c)=>{c.stopPropagation(),this.snoozeMenuRowId=this.snoozeMenuRowId===e.id?"":e.id,this.render()}),o.appendChild(a)}if(r){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-move-btn",a.title=m("chats.move","Move to project…"),a.setAttribute("aria-label",m("chats.move","Move to project…")),a.setAttribute("data-testid",`move-row-${e.id}`),a.appendChild(Eo(11)),a.addEventListener("click",(c)=>{c.stopPropagation(),this.cb.onMoveToProject?.(Qe(e.id))}),o.appendChild(a)}if(s&&e.settle){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-settle-btn",a.title=m("menu.settle","Settle"),a.setAttribute("aria-label",m("menu.settle","Settle")),a.setAttribute("data-testid",`settle-row-${e.id}`),a.appendChild(wo(11)),a.addEventListener("click",(c)=>{if(c.stopPropagation(),i)this.cb.onSettleSwarm?.(Qe(e.settle));else this.cb.onThreadAct(Qe(e.settle),"settle")}),o.appendChild(a)}return o}renderSectionThreadRow(e,t,n=!1){let i=document.createElement("div");i.className="bp-thread-row"+(n?" bp-inbox-row":"")+(!this.selectedProjectId&&(e.id===this.selectedThreadId||Qe(e.id)===this.selectedThreadId)?" active":"")+(e.off?" bp-dim":""),i.setAttribute("data-thread-id",e.id),i.setAttribute("data-testid",`thread-row-${e.id}`);let s=go(e),r=this.renderRowActions(e);if(n){let l=document.createElement("div");l.className="bp-inbox-main";let h=document.createElement("div");h.className="bp-inbox-top";let d=document.createElement("div");if(d.className="bp-thread-title",d.textContent=e.title||"Untitled thread",h.appendChild(d),r)h.appendChild(r);let u=document.createElement("div");if(u.className="bp-inbox-meta",s)u.appendChild(this.renderStatusPill(s,e.say));if(e.project&&!e.chat){let f=document.createElement("span");f.className="bp-inbox-proj",f.textContent=e.project,u.appendChild(f)}if(e.ago){let f=document.createElement("span");if(f.className="bp-thread-age",f.textContent=e.ago,e.pinned)f.title=m("tools.pinned","Pinned");u.appendChild(f)}l.append(h,u),i.appendChild(l)}else{if(t){let h=document.createElement("span");h.className="bp-tree-branch",h.setAttribute("aria-hidden","true"),i.appendChild(h)}if(s)i.appendChild(this.renderStatusPill(s,e.say));let l=document.createElement("div");if(l.className="bp-thread-title",l.textContent=e.title||"Untitled thread",i.appendChild(l),r)i.appendChild(r);if(e.ago){let h=document.createElement("span");if(h.className="bp-thread-age",h.textContent=e.ago,e.pinned)h.title=m("tools.pinned","Pinned");i.appendChild(h)}}let o=e.nav||e.id;if(!e.off&&o&&!o.startsWith("@room:"))i.addEventListener("click",()=>this.cb.onSelectThread(Qe(o)));let a=this.snoozeMenuRowId===e.id&&Array.isArray(e.snooze)&&e.snooze.length>0,c=e.kind==="swarm"?Kn(e.need):null;if(!c&&!a)return i;let p=document.createElement("div");if(p.className="bp-need-wrap",p.appendChild(i),a&&e.snooze){let l=document.createElement("div");l.className="bp-snooze-bar"+(t?" nested":""),l.setAttribute("data-testid",`snooze-bar-${e.id}`);let h=document.createElement("span");h.className="bp-dim",h.textContent="Snooze:",l.appendChild(h);for(let d of e.snooze){let u=document.createElement("button");u.type="button",u.className="bp-snooze-opt",u.textContent=d.label,u.addEventListener("click",(f)=>{f.stopPropagation(),this.snoozeMenuRowId="",this.cb.onSnoozeRow?.(d.value),this.render()}),l.appendChild(u)}p.appendChild(l)}if(c){let l=document.createElement("div");l.className="bp-need"+(t?" nested":"")+(e.off?" bp-dim":""),l.setAttribute("data-testid",`need-${e.id}`);let h=document.createElement("span");h.className="bp-need-line",h.textContent=c.line,h.title=c.line,l.appendChild(h);for(let u of c.actions){if(!un(u,Boolean(this.cb.hasRoomView)))continue;let f=document.createElement("button");f.type="button",f.className="bp-need-btn",f.textContent=u.label,f.setAttribute("data-testid",`need-${u.act}-${e.id}`),f.disabled=Boolean(e.off)||this.needBusy.has(e.id)||!this.cb.onNeedAct,f.addEventListener("click",(b)=>{b.stopPropagation();let v=this.cb.onNeedAct;if(!v)return;this.needErr.delete(e.id),this.needBusy.add(e.id),this.render(),v(u).catch((w)=>{this.needErr.set(e.id,w instanceof Error?w.message:String(w))}).finally(()=>{this.needBusy.delete(e.id),this.render()})}),l.appendChild(f)}p.appendChild(l);let d=this.needErr.get(e.id);if(d){let u=document.createElement("div");u.className="bp-need-err"+(t?" nested":""),u.textContent=d,p.appendChild(u)}}return p}renderHubSections(e,t){let n=this.sections??[],i=new Set;for(let o of n)if(o.kind==="threads")for(let a of o.rows)i.add(a.id),i.add(Qe(a.id));else if(o.kind==="projects")for(let a of o.rows)for(let c of a.threads??[])i.add(c.id),i.add(Qe(c.id));let s=this.selectedThreadId?this.threads.find((o)=>o.id===this.selectedThreadId)??null:null,r=!1;for(let o of n)if(o.kind==="projects"&&(o.rows.length>0||(o.count??0)>0))r=!0;for(let o of n){if(o.kind==="bub")continue;if(o.kind==="threads"){let a=Boolean(o.fold&&o.toggle),c=o.rows.filter((l)=>{if(!t)return!0;return`${l.title} ${l.project??""}`.toLowerCase().includes(t)});if(!a&&c.length===0)continue;if(a&&t&&c.length===0)continue;if(a&&!t&&(o.count??c.length)===0)continue;let p=document.createElement("section");if(p.className=`bp-side-section bp-side-inbox bp-sec-${o.id}`,p.setAttribute("data-section-id",o.id),a){let l=document.createElement("button");l.type="button",l.className="bp-side-section-head bp-side-section-toggle";let h=t?c.length:o.count??c.length,d=o.open||Boolean(t)?"▾":"▸";if(l.textContent=`${d} ${o.title.toUpperCase()} (${h})`,o.hint)l.title=o.hint;l.setAttribute("data-testid",`section-toggle-${o.id}`),l.addEventListener("click",()=>{if(o.toggle)this.cb.onToggleSection?.(o.toggle)}),p.appendChild(l)}else{let l=document.createElement("div");if(l.className="bp-side-section-head"+(o.id==="needs"?" bp-head-needs":o.id==="running"?" bp-head-running":""),o.id===yt&&this.cb.onNewChat){l.classList.add("bp-side-section-row");let h=document.createElement("span");h.textContent=`${m("chats.title",o.title).toUpperCase()} ${c.length}`;let d=document.createElement("button");d.type="button",d.className="bp-side-sec-plus bp-side-sec-btn",d.textContent="+",d.title=m("chats.new.noproject","New chat (no project)"),d.setAttribute("aria-label",d.title),d.setAttribute("data-testid","section-new-chat"),d.addEventListener("click",(u)=>{u.stopPropagation(),this.cb.onNewChat?.()}),l.append(h,d)}else l.textContent=`${o.title.toUpperCase()} ${c.length}`;p.appendChild(l)}if(!a||Boolean(o.open)||Boolean(t))for(let l of c)p.appendChild(this.renderSectionThreadRow(l,!1,!0));e.appendChild(p);continue}if(o.kind==="projects"){let a=o.rows,c=a.filter((d)=>{if(!t)return!0;if((d.title||d.id).toLowerCase().includes(t))return!0;if((d.threads??[]).some((u)=>u.title.toLowerCase().includes(t)))return!0;if((d.swarms??[]).some((u)=>u.title.toLowerCase().includes(t)))return!0;return!1}),p=Boolean(o.fold&&o.toggle);if(t&&c.length===0)continue;if(!p&&o.id!=="active"&&c.length===0)continue;let l=document.createElement("section");if(l.className=`bp-side-section bp-sec-${o.id}`,l.setAttribute("data-section-id",o.id),p){let d=document.createElement("button");d.type="button",d.className="bp-side-section-head bp-side-section-toggle";let u=t?c.length:o.count??c.length,f=o.open||Boolean(t)?"▾":"▸";if(d.textContent=`${f} ${o.title.toUpperCase()} (${u})`,o.hint)d.title=o.hint;d.setAttribute("data-testid",`section-toggle-${o.id}`),d.addEventListener("click",()=>{if(o.toggle)this.cb.onToggleSection?.(o.toggle)}),l.appendChild(d)}else l.appendChild(this.projectsHead(o.title.toUpperCase()));if(!p||Boolean(o.open)||Boolean(t)){if(o.id==="all"&&!t){let d=a.some((f)=>f.hasBoard||f.hasSchematic),u=a.some((f)=>!f.hasBoard&&!f.hasSchematic);if(d&&u){let f=document.createElement("div");f.className="bp-proj-filter",f.setAttribute("data-testid","all-projects-filter");let b=[{id:"all",label:"All"},{id:"hw",label:"Boards"},{id:"sw",label:"Code"}];for(let v of b){let w=document.createElement("button");w.type="button",w.className="bp-proj-filter-btn"+(this.allFilter===v.id?" active":""),w.textContent=v.label,w.addEventListener("click",()=>{this.allFilter=v.id,this.render()}),f.appendChild(w)}if(l.appendChild(f),this.allFilter==="hw")c=c.filter((v)=>v.hasBoard||v.hasSchematic);else if(this.allFilter==="sw")c=c.filter((v)=>!v.hasBoard&&!v.hasSchematic)}}if(o.id==="active"&&!r&&!t){let d=document.createElement("div");d.className="bp-side-empty",d.textContent="No projects yet.",l.appendChild(d)}for(let d of c){let u=document.createElement("div");if(u.className="bp-proj-group"+(d.off||o.id==="quiet"?" bp-dim":""),u.setAttribute("data-project-id",d.id),d.nav||d.key)u.setAttribute("data-project-key",d.nav||d.key||"");let f=document.createElement("div");f.className="bp-proj-head";let b=document.createElement("button");b.type="button",b.className="bp-proj-toggle";let w=Boolean(d.hasBoard||d.hasSchematic)?qs(14):zs();if(d.css)w.style.color=d.css;let E=document.createElement("span");E.className="bp-proj-name",E.textContent=d.title||d.id,b.append(w,E);let k=d.fold==="project-fold"&&Boolean(d.nav),L=()=>{if(k)this.cb.onToggleProjectFold?.(d.nav)};if(!d.off&&this.cb.canOpenProject?.())b.title=m("web.home.open","Open project home");if(b.setAttribute("data-testid",`project-open-${d.id}`),this.selectedProjectId&&Qe(d.id)===this.selectedProjectId)f.classList.add("active");b.addEventListener("click",()=>{if(d.off||!this.cb.onOpenProject?.(d.id))L()});let M=this.makeFoldChevron(Boolean(d.folded),d.id);if(k)M.addEventListener("click",(P)=>{P.stopPropagation(),L()});else M.disabled=!0;f.appendChild(M);let A=document.createElement("div");if(A.className="bp-proj-meta",(d.needsCount??0)>0){let P=document.createElement("span");P.className="bp-proj-badge-need",P.textContent=String(d.needsCount),P.title=`${d.needsCount} needing you`,A.appendChild(P)}if((d.running??0)>0){let P=document.createElement("span");P.className="bp-proj-badge-run",P.textContent=String(d.running),P.title=`${d.running} running`,A.appendChild(P)}if(d.pinned&&o.id!=="pinned")A.appendChild(xo(11));let B=document.createElement("div");if(B.className="bp-proj-acts",!d.off&&this.cb.onQuickOpenViewer){if(d.hasBoard){let P=document.createElement("button");P.type="button",P.className="bp-proj-quick",P.title=m("viewer.board","Open Board"),P.setAttribute("aria-label",`Open Board (${d.title})`),P.setAttribute("data-testid",`quick-board-${d.id}`),P.appendChild(qs(13,"")),P.addEventListener("click",(Y)=>{Y.stopPropagation(),this.cb.onQuickOpenViewer?.(Qe(d.id),"board")}),B.appendChild(P)}if(d.hasSchematic){let P=document.createElement("button");P.type="button",P.className="bp-proj-quick",P.title=m("viewer.schematic","Open Schematic"),P.setAttribute("aria-label",`Open Schematic (${d.title})`),P.setAttribute("data-testid",`quick-sch-${d.id}`),P.appendChild(fo(13)),P.addEventListener("click",(Y)=>{Y.stopPropagation(),this.cb.onQuickOpenViewer?.(Qe(d.id),"schematic")}),B.appendChild(P)}}let T=document.createElement("button");if(T.type="button",T.className="icon bp-proj-add",T.title=m("thread.new","New thread"),T.textContent="+",T.setAttribute("data-testid",`new-thread-${d.id}`),d.off)T.disabled=!0;T.addEventListener("click",(P)=>{P.stopPropagation(),this.cb.onNewThread(Qe(d.id))}),B.appendChild(T),f.append(b,A,B),u.appendChild(f);let H=Boolean(t)&&(d.title||d.id).toLowerCase().includes(t),O=Boolean(d.folded&&!t);for(let P of d.swarms??[]){if(!bo(P,O))continue;if(t&&!H&&!P.title.toLowerCase().includes(t))continue;u.appendChild(this.renderSectionThreadRow(P,!0))}if(!O){for(let P of d.threads??[]){if(t&&!H&&!P.title.toLowerCase().includes(t))continue;u.appendChild(this.renderSectionThreadRow(P,!0))}if(s&&s.project===Qe(d.id)&&!i.has(s.id)&&(!t||H||s.title.toLowerCase().includes(t)))u.appendChild(this.renderSectionThreadRow({id:s.id,title:s.title,status:s.status,state:s.state,ago:Ks(s.updatedAt),pinned:s.pinned,nav:s.id},!0))}l.appendChild(u)}}e.appendChild(l)}}}render(){this.addShown=!1;let e=this.filterText;this.renderCrewBand(e);let t=document.createDocumentFragment();if(this.sections!==null)this.renderHubSections(t,e);else{let n=new Map;for(let i of this.threads){if(i.archived||i.swarm)continue;if(e){if(!`${i.title} ${i.preview??""}`.toLowerCase().includes(e))continue}let s=n.get(i.project)??[];s.push(i),n.set(i.project,s)}if(t.appendChild(this.projectsHead("RECENT")),this.projects.length===0&&this.threads.length===0){let i=document.createElement("div");i.className="bp-side-empty",i.textContent="No projects yet.",t.appendChild(i)}for(let i of this.projects){let s=n.get(i.id)??[];if(e&&s.length===0&&!i.title.toLowerCase().includes(e))continue;let r=document.createElement("section");r.className="bp-proj-group",r.setAttribute("data-project-id",i.id);let o=document.createElement("div");o.className="bp-proj-head";let a=document.createElement("button");a.type="button",a.className="bp-proj-toggle";let c=this.collapsedProjects.has(i.id)&&!e,p=zs();if(i.css)p.style.color=i.css;let l=document.createElement("span");l.className="bp-proj-name",l.textContent=i.title||i.id,a.append(p,l);let h=()=>{if(this.collapsedProjects.has(i.id))this.collapsedProjects.delete(i.id);else this.collapsedProjects.add(i.id);this.render()};if(this.cb.canOpenProject?.())a.title=m("web.home.open","Open project home");if(a.setAttribute("data-testid",`project-open-${i.id}`),this.selectedProjectId&&i.id===this.selectedProjectId)o.classList.add("active");a.addEventListener("click",()=>{if(!this.cb.onOpenProject?.(i.id))h()});let d=this.makeFoldChevron(c,i.id);d.addEventListener("click",(f)=>{f.stopPropagation(),h()}),o.appendChild(d);let u=document.createElement("button");if(u.type="button",u.className="icon bp-proj-add",u.title=m("thread.new","New thread"),u.textContent="+",u.setAttribute("data-testid",`new-thread-${i.id}`),u.addEventListener("click",(f)=>{f.stopPropagation(),this.cb.onNewThread(i.id)}),o.append(a,u),r.appendChild(o),!c)for(let f of s)r.appendChild(this.renderSectionThreadRow({id:f.id,title:f.title,status:f.status,state:f.state,ago:Ks(f.updatedAt),pinned:f.pinned,nav:f.id},!0));t.appendChild(r)}}this.listEl.replaceChildren(t)}}function So(e){try{return new URL(e,window.location.origin).searchParams.get("s")||""}catch{return""}}function zt(e){if(!e)return;for(let t of e.getTracks())try{t.stop()}catch{}}function Lo(e,t){if(t===16000){let r=new Int16Array(e.length);for(let o=0;o0?c/p:0));s[r]=l<0?l*32768:l*32767}return s}class si{hub;cb;active=!1;starting=!1;sessionGen=0;activeGen=0;abortedGen=0;threadId="";sessionKey="";stream=null;audioCtx=null;processor=null;pendingPcm=[];postChain=Promise.resolve();stopDrain=Promise.resolve();mark=0;constructor(e,t){this.hub=e,this.cb=t}isRecording(){return this.active||this.starting}async toggle(){if(this.active||this.starting)await this.stop();else await this.start()}async start(){if(this.active||this.starting)return;let e=this.cb.getThreadId();if(!e)return;if(!navigator.mediaDevices?.getUserMedia){this.cb.showError("Microphone access is not available in this browser.");return}let t=++this.sessionGen;this.starting=!0,this.threadId=e,this.sessionKey="",this.pendingPcm=[],this.mark=this.cb.getCaret(),this.cb.setRecording(!0);let n;try{n=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{if(t===this.sessionGen)this.starting=!1,this.cb.setRecording(!1),this.cb.showError("Microphone permission denied.");return}if(t!==this.sessionGen||this.cb.getThreadId()!==e){zt(n);return}if(this.stream=n,await this.stopDrain,t!==this.sessionGen||this.cb.getThreadId()!==e){if(zt(n),this.stream===n)this.stream=null;return}try{let i=await this.hub.rpc("voice.start",{thread:e,draft:this.cb.getDraft(),caret:this.mark});if(t!==this.sessionGen||this.cb.getThreadId()!==e){if(zt(n),this.stream===n)this.stream=null;if(!this.active&&!this.starting)this.hub.rpc("voice.stop",{thread:e}).catch(()=>{});return}let s=i.session||(i.path?So(i.path):"");if(!s)throw Error("Hub did not return a voice session.");this.sessionKey=s,this.activeGen=t,this.starting=!1,this.active=!0,this.startCapture(n,t)}catch(i){if(t===this.sessionGen)this.cleanupAudio(),this.starting=!1,this.active=!1,this.cb.setRecording(!1),this.cb.showError(i instanceof Error?i.message:"Could not start voice dictation.");else if(zt(n),this.stream===n)this.stream=null}}async stop(){if(!this.active&&!this.starting)return;let e=this.activeGen,t=this.active,n=this.threadId,i=this.sessionKey;this.sessionGen++,this.starting=!1,this.active=!1,this.sessionKey="",this.cb.setRecording(!1),this.cb.setLevel(0),this.cleanupAudio();let r=this.stopDrain.then(async()=>{if(t&&i){let o=new Int16Array(this.pendingPcm);this.pendingPcm=[],this.enqueuePost(i,new Uint8Array(o.buffer),!0,e),await this.postChain}else this.pendingPcm=[];if(t&&n)await this.hub.rpc("voice.stop",{thread:n}).catch(()=>{})});this.stopDrain=r,await r}cancel(){if(!this.active&&!this.starting)return;let e=this.active,t=this.threadId;if(this.abortedGen=Math.max(this.abortedGen,this.sessionGen),this.sessionGen++,this.starting=!1,this.active=!1,this.sessionKey="",this.pendingPcm=[],this.cb.setRecording(!1),this.cb.setLevel(0),this.cleanupAudio(),e&&t&&this.hub.getState()==="connected")this.hub.rpc("voice.stop",{thread:t}).catch(()=>{})}handleFrame(e){let t=String(e.ev??""),n=String(e.thread??"");if(n&&this.cb.getThreadId()&&n!==this.cb.getThreadId())return;if(t==="draft"&&typeof e.text==="string")this.cb.setDraft(e.text),this.mark=e.text.length;else if(t==="edit"){let i=this.cb.getDraft(),s=Number(e.del??0),r=String(e.ins??""),o=Math.max(0,Math.min(i.length,this.mark)),a=Math.max(0,o-s),c=i.slice(0,a)+r+i.slice(o);this.mark=a+r.length,this.cb.setDraft(c)}else if(t==="level")this.cb.setLevel(Math.max(0,Math.min(100,Number(e.v??0))));else if(t==="view"){let i=e.view;if(i&&i.on===!1&&(this.active||this.starting))this.stop()}}startCapture(e,t){let i=new(window.AudioContext||window.webkitAudioContext),s=i.createMediaStreamSource(e),r=i.createScriptProcessor(4096,1,1);r.onaudioprocess=(o)=>{if(!this.active||t!==this.sessionGen||!this.sessionKey)return;let a=Lo(o.inputBuffer.getChannelData(0),i.sampleRate);for(let c=0;c=3200){let c=new Int16Array(this.pendingPcm.splice(0,3200));this.enqueuePost(this.sessionKey,new Uint8Array(c.buffer),!1,t)}},s.connect(r),r.connect(i.destination),this.audioCtx=i,this.processor=r}enqueuePost(e,t,n,i){this.postChain=this.postChain.then(async()=>{if(i<=this.abortedGen)return;try{let s={"Content-Type":"application/octet-stream","X-Voice-Session":e};if(n)s["X-Voice-End"]="1";let r=await fetch("/voice/in",{method:"POST",credentials:"same-origin",headers:s,body:t});if(!r.ok&&!n&&i===this.sessionGen&&this.active)this.failUpload(`Voice upload failed (${r.status}).`)}catch{if(!n&&i===this.sessionGen&&this.active)this.failUpload("Voice upload failed.")}})}failUpload(e){this.abortedGen=Math.max(this.abortedGen,this.sessionGen),this.sessionGen++,this.active=!1,this.starting=!1,this.sessionKey="",this.pendingPcm=[],this.cleanupAudio(),this.cb.setRecording(!1),this.cb.setLevel(0),this.cb.showError(e)}cleanupAudio(){if(this.processor)this.processor.disconnect(),this.processor.onaudioprocess=null,this.processor=null;if(this.audioCtx)this.audioCtx.close().catch(()=>{}),this.audioCtx=null;zt(this.stream),this.stream=null}}var Ys=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],Xs=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Qs=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Zs=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ao=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function qt(e,t){let n=new Int32Array(16),i=0;for(let a=0;a0){if(n[c]++,c>i)i=c}}let s=new Int32Array(16),r=0;for(let a=1;a<=15;a++)s[a]=r,r+=n[a];let o=new Int32Array(r);for(let a=0;a0)o[s[c]++]=a}return{counts:n,symbols:o,maxBits:i}}var No=(()=>{let e=new Uint8Array(288);return e.fill(8,0,144),e.fill(9,144,256),e.fill(7,256,280),e.fill(8,280,288),qt(e,288)})(),Mo=(()=>{let e=new Uint8Array(32);return e.fill(5),qt(e,32)})();class ri{win=new Uint8Array(32768);winPos=0;feed(e,t=16777216){let n=0,i=0,s=0,r=(h)=>{while(s=e.length)throw Error("truncated deflate frame");i|=e[n++]<>>=h,s-=h,d},o=(h)=>{let d=0,u=0,f=0;for(let b=1;b<=h.maxBits;b++){d|=r(1);let v=h.counts[b];if(d-v{let d=c+h;if(d>t)throw Error("inflated frame exceeds limit");if(d<=a.length)return;let u=a.length;while(u{p(1),a[c++]=h,this.win[this.winPos]=h,this.winPos=this.winPos+1&32767};while(n0){if(n>=e.length&&s<3)break;let h=r(1),d=r(2);if(d===0){if(i=0,s=0,n+4>e.length)throw Error("truncated stored block");let u=e[n]|e[n+1]<<8,f=e[n+2]|e[n+3]<<8;if(n+=4,(u^65535)!==f)throw Error("invalid stored block length");if(n+u>e.length)throw Error("truncated stored payload");p(u);for(let b=0;b=e.length)break}else if(d===1||d===2){let u=No,f=Mo;if(d===2){let b=r(5)+257,v=r(5)+1,w=r(4)+4,E=new Uint8Array(19);for(let B=0;BL)throw Error("code length overflow");for(let O=0;OL)throw Error("code length overflow");A+=T}else if(B===18){let T=r(7)+11;if(A+T>L)throw Error("code length overflow");A+=T}else throw Error("invalid code length symbol")}u=qt(M,b),f=qt(M.subarray(b),v)}while(!0){let b=o(u);if(b<256)l(b);else if(b===256)break;else{let v=b-257;if(v>=Ys.length)throw Error("invalid length symbol");let w=Ys[v]+(Xs[v]?r(Xs[v]):0),E=o(f);if(E>=Qs.length)throw Error("invalid distance symbol");let k=Qs[E]+(Zs[E]?r(Zs[E]):0);p(w);let L=this.winPos-k&32767;for(let M=0;M{this.stateListeners.delete(e)}}onFrame(e){return this.frameListeners.add(e),()=>{this.frameListeners.delete(e)}}onBinary(e){return this.binaryListeners.add(e),()=>{this.binaryListeners.delete(e)}}rpc(e,t={},n=20000){return new Promise((i,s)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){s(Error("Not connected to hub"));return}let r=this.nextId++,o=window.setTimeout(()=>{this.pending.delete(r),s(Error(`RPC timeout: ${e}`))},n);this.pending.set(r,{resolve:i,reject:s,timer:o}),this.ws.send(JSON.stringify({id:r,m:e,p:t}))})}setState(e){this.state=e;for(let t of this.stateListeners)t(e,this.hello)}rejectAllPending(e){for(let[,t]of this.pending)window.clearTimeout(t.timer),t.reject(Error(e));this.pending.clear()}openSocket(){if(this.closed)return;this.inflater=null;let t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?data=1&enc=json&z=deflate`,n=new WebSocket(t);n.binaryType="arraybuffer",this.ws=n;let i=(s)=>{let r;try{r=JSON.parse(s)}catch{return}if(r.t==="hub.restarting")this.restarting={reason:String(r.reason??""),build:String(r.build??""),text:String(r.text??""),at:Date.now()};if(r.t==="hello")this.restarting=null,this.hello=r,this.features=new Set(this.hello.features??[]),this.inflater=this.hello.z==="deflate"?new ri:null,this.reconnectDelay=500,this.setState("connected");else if(r.t==="reply"&&typeof r.id==="number"){let o=this.pending.get(r.id);if(o)if(this.pending.delete(r.id),window.clearTimeout(o.timer),r.ok)o.resolve(r.result??{});else{let a=r.error,c=typeof a==="string"?a:a&&typeof a==="object"&&("message"in a)?String(a.message):"Request failed",p=typeof r.errorCode==="string"?r.errorCode:void 0,l=typeof r.machine==="string"?r.machine:void 0,h=typeof r.thread==="string"?r.thread:void 0;o.reject(new Kt(c,{code:p,machine:l,thread:h}))}return}for(let o of this.frameListeners)o(r)};n.addEventListener("message",(s)=>{if(s.data instanceof ArrayBuffer){if(this.inflater){let r;try{r=this.inflater.feed(new Uint8Array(s.data))}catch{n.close();return}if(r.length>0&&r[0]===123)i(this.textDecoder.decode(r));else{let o=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);for(let a of this.binaryListeners)a(o)}return}for(let r of this.binaryListeners)r(s.data);return}if(typeof s.data!=="string")return;i(s.data)}),n.addEventListener("close",(s)=>{if(this.ws===n)this.ws=null;if(this.rejectAllPending("Connection closed"),this.closed)return;if(s.code===4001||s.code===4401||s.code===1008){this.handleRevoked();return}this.probeSessionOrReconnect()}),n.addEventListener("error",()=>{})}async probeSessionOrReconnect(){try{let t=await fetch("/",{method:"GET",credentials:"same-origin",cache:"no-store"});if(t.status===401||t.status===403){this.handleRevoked();return}if(t.ok){if((await t.text()).includes('id="pair-root"')){this.handleRevoked();return}}}catch{}this.setState("reconnecting");let e=this.reconnectDelay;this.reconnectDelay=Math.min(8000,Math.round(this.reconnectDelay*1.6)),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.openSocket()},e)}handleRevoked(){this.closed=!0,this.setState("revoked"),window.location.replace("/")}}var To=new TextDecoder;function er(e){return e.length>7&&e[0]>=160&&e[0]<=183&&e[1]===1&&e[2]===100&&e[3]===112&&e[4]===108&&e[5]===111&&e[6]===116}function tr(e){let t=0,n=0;function i(o){if(o<=23)return o;if(o===24){if(t>=e.length)return null;return e[t++]}if(o===25){if(t+2>e.length)return null;let a=e[t]<<8|e[t+1];return t+=2,a}if(o===26){if(t+4>e.length)return null;let a=(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0;return t+=4,a}return null}function s(o){if(n++,o>32||n>400000||t>=e.length)return null;let a=e[t++],c=a>>5,p=i(a&31);if(p===null)return null;switch(c){case 0:return p;case 1:return-1-p;case 2:{if(t+p>e.length)return null;let l=e.subarray(t,t+p);return t+=p,l}case 3:{if(t+p>e.length)return null;let l=To.decode(e.subarray(t,t+p));return t+=p,l}case 4:{if(p>e.length)return null;let l=Array(p);for(let h=0;h=this.b.length)return this.ok=!1,0;let n=this.b[this.i++],i=7*t;if(i>=28&&(n&240)!==0)return this.ok=!1,0;if(e=(e|(n&127)<>>0,n<128)return e}return this.ok=!1,0}nextI32(){let e=this.nextU32();return e>>>1^-(e&1)}}function ir(e){let t=0xcbf29ce484222325n,n=0x100000001b3n,i=0xffffffffffffffffn;for(let s=0;stypeof e[b]==="number"?e[b]:v,n=t("l",0),i=t("c",0),s=t("a",255)/255,r=t("m",1),o=t("w",0),a=o/2,c=r===0&&o!==0,p=e.d instanceof Uint8Array?e.d:new Uint8Array(0),l=new nr(p),h=[],d=[],u=0,f=0;while(l.more()){let b=l.nextU32(),v=h.length,w=1/0,E=1/0,k=-1/0,L=-1/0;if(r===2)u=u+l.nextI32()|0,f=f+l.nextI32()|0,h.push(u,f),w=k=u,E=L=f;else{let A=Math.min(l.nextU32(),1048576);for(let B=0;Bk)k=u;if(fL)L=f}}let M=(h.length-v)/2;if(M>0){let A=r===2||M===1?2:r===0?0:1,B=r===0?0:a;d.push({info:b,x0:w-B,y0:E-B,x1:k+B,y1:L+B,at:v,n:M,kind:A})}}return{layer:n,color:i,alpha:s,mode:r,r:a,own:c,pts:new Float32Array(h),pieces:d}}function sr(e,t,n){let i=(o)=>Array.isArray(o)&&o.length>=4?[Number(o[0])||0,Number(o[1])||0,Number(o[2])||0,Number(o[3])||0]:[0,0,0,0],s=Array.isArray(e.cs)?e.cs:[],r=[];for(let o=0;o=0&&a0){n.delete(a.h),n.set(a.h,c);while(n.size>1024){let p=n.keys().next().value;if(p!==void 0)n.delete(p);else break}}}}return{key:typeof e.key==="string"?e.key:"",fam:typeof e.fam==="string"?e.fam:"",base:typeof e.base==="string"?e.base:"",box:i(e.box),edge:i(e.edge),thick:typeof e.thick==="number"?e.thick:1600,note:typeof e.note==="string"?e.note:"",warn:typeof e.warn==="number"?e.warn!==0:!1,chunks:r}}function rr(e,t,n,i=!0){if(n.width<=0||n.height<=0||n.naturalWidth<=0||n.naturalHeight<=0)return null;let s=Math.min(n.width/n.naturalWidth,n.height/n.naturalHeight),r=n.naturalWidth*s,o=n.naturalHeight*s,a=n.left+(n.width-r)/2,c=i?n.top:n.top+(n.height-o)/2,p=(e-a)/r,l=(t-c)/o;if(p<0||p>1||l<0||l>1)return null;return{x:Math.max(0,Math.min(1000,Math.round(p*1000))),y:Math.max(0,Math.min(1000,Math.round(l*1000)))}}var or=[["Enter","Enter"],["Tab","Tab"],["Bksp","Backspace"],["Esc","Escape"],["↑","ArrowUp"],["↓","ArrowDown"],["←","ArrowLeft"],["→","ArrowRight"]];function ar(e){let t=e.trim();if(!t)return"";if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))return t;return`https://${t}`}class ai{tail=Promise.resolve();enqueue(e){let t=this.tail.then(e,e);return this.tail=t.catch(()=>{}),t}}function lr(e,t,n){let i=!0,s=!1,r=!1,o="",a=!1,c=!1,p=-1,l=null,h=new ai,d=document.createElement("div");d.className="bp-pane bp-browser-pane",d.setAttribute("data-testid","pane-browser");let u=document.createElement("div");u.className="bp-pane-bar bp-browser-nav";function f(ee,ge,C){let x=document.createElement("button");if(x.type="button",x.className="bp-v-btn",x.textContent=ee,x.setAttribute("data-testid",ge),C)x.title=C;return x}let b=f("←","browser-back","Back"),v=f("→","browser-forward","Forward"),w=f("↻","browser-reload","Reload"),E=document.createElement("form");E.className="bp-browser-url-form";let k=document.createElement("input");k.type="text",k.className="bp-browser-input",k.placeholder="https://…",k.autocomplete="off",k.spellcheck=!1,k.setAttribute("data-testid","browser-url");let L=f("Go","browser-go","Navigate");L.type="submit",E.append(k,L);let M=f("Take over","browser-takeover");M.classList.add("is-primary"),u.append(b,v,w,E,M);let A=document.createElement("div");A.className="bp-browser-drive-bar",A.hidden=!0;let B=document.createElement("div");B.className="bp-browser-keys-row";let T=document.createElement("input");T.type="text",T.className="bp-browser-input",T.placeholder="Type text or press Enter/Tab/Arrows…",T.autocomplete="off",T.spellcheck=!1,T.setAttribute("data-testid","browser-keys");let H=f("Send","browser-type-send");B.append(T,H);let O=document.createElement("div");O.className="bp-browser-quick-keys";for(let[ee,ge]of or){let C=f(ee,`browser-key-${ge}`);C.addEventListener("click",()=>te("press",{key:ge})),O.append(C)}A.append(B,O);let P=document.createElement("div");P.className="bp-browser-err",P.setAttribute("data-testid","browser-error"),P.hidden=!0;let Y=document.createElement("div");Y.className="bp-browser-stage",Y.setAttribute("data-testid","browser-stage");let re=document.createElement("img");re.className="bp-browser-img",re.alt="Hub browser screen",re.draggable=!1,re.hidden=!0,re.setAttribute("data-testid","browser-frame");let ie=document.createElement("div");ie.className="bp-pane-empty",ie.setAttribute("data-testid","browser-empty"),ie.textContent="Loading browser screen…",Y.append(re,ie);let me=document.createElement("div");me.className="bp-browser-hint",me.textContent="You have the page: click to tap, scroll to wheel, type in the key box. Hand it back when done.",me.hidden=!0,d.append(u,A,P,Y,me),e.replaceChildren(d);function Pe(ee){P.textContent=ee,P.hidden=!ee}function Ce(){A.hidden=!s,me.hidden=!s,M.textContent=s?"Hand back":"Take over",M.setAttribute("data-testid",s?"browser-handback":"browser-takeover"),M.classList.toggle("is-on",s),re.classList.toggle("is-driving",s)}function te(ee,ge={},C){h.enqueue(async()=>{if(!i)return;Pe("");try{if(await t.hub.rpc("browser",{thread:n,op:ee,...ge}),!i)return;C?.(),ue()}catch(x){if(!i)return;Pe(x instanceof Error?x.message:String(x))}})}function oe(ee){te("toolbar",{command:ee},()=>{s=!0,Ce()})}b.addEventListener("click",()=>oe("back")),v.addEventListener("click",()=>oe("forward")),w.addEventListener("click",()=>oe("reload")),E.addEventListener("submit",(ee)=>{ee.preventDefault();let ge=ar(k.value);if(!ge)return;if(k.value=ge,!s)te("takeover",{},()=>{s=!0,Ce()});te("navigate",{url:ge},()=>{s=!0,Ce()})}),M.addEventListener("click",()=>{if(s)te("handback",{},()=>{s=!1,Ce()});else te("takeover",{},()=>{s=!0,Ce(),T.focus()})});function R(){let ee=T.value;if(!ee)return;T.value="",te("type",{text:ee})}H.addEventListener("click",R),T.addEventListener("keydown",(ee)=>{if(!s)return;if(ee.key==="Enter"){if(ee.preventDefault(),T.value)R();te("press",{key:"Enter"});return}if(ee.key==="Tab"||ee.key==="Escape"||ee.key==="ArrowUp"||ee.key==="ArrowDown"||ee.key==="ArrowLeft"||ee.key==="ArrowRight"||ee.key==="Backspace"&&T.value==="")ee.preventDefault(),te("press",{key:ee.key})}),re.addEventListener("click",(ee)=>{if(!s||!r)return;let ge=re.getBoundingClientRect(),C=rr(ee.clientX,ee.clientY,{left:ge.left,top:ge.top,width:ge.width,height:ge.height,naturalWidth:re.naturalWidth,naturalHeight:re.naturalHeight});if(!C)return;te("click",C)}),re.addEventListener("wheel",(ee)=>{if(!s||!r)return;ee.preventDefault();let ge=Math.round(ee.deltaX),C=Math.round(ee.deltaY);if(ge===0&&C===0)return;te("scroll",{dx:ge,dy:C})},{passive:!1});async function ue(){if(!i)return;if(a){c=!0;return}a=!0;try{do{c=!1,l=new AbortController;let ee=await fetch(`/bots/${encodeURIComponent(n)}/screen.jpg`,{credentials:"same-origin",cache:"no-store",signal:l.signal});if(!i)return;if(ee.ok){let ge=await ee.blob();if(!i)return;let C=URL.createObjectURL(ge),x=o;if(o=C,re.src=C,re.hidden=!1,ie.hidden=!0,r=!0,x)URL.revokeObjectURL(x)}else if(!r)re.hidden=!0,ie.hidden=!1,ie.textContent="No browser page yet. An agent opens one when it needs the web."}while(i&&c)}catch{if(!i)return;if(!r)re.hidden=!0,ie.hidden=!1,ie.textContent="No browser page yet. An agent opens one when it needs the web."}finally{l=null,a=!1}}let de=t.hub.onFrame((ee)=>{if(!i)return;if(ee.t==="shot"&&ee.bot===n){if(typeof ee.n==="number"){if(ee.n===p)return;p=ee.n}ue()}});return ue(),{destroy(){if(i=!1,de(),l?.abort(),o)URL.revokeObjectURL(o),o=""}}}function U(e,t,n){let i=document.createElement(e);if(t)i.className=t;if(n!==void 0)i.textContent=n;return i}function fn(e){if(!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;if(e<1048576)return`${Math.round(e/1024)} KB`;return`${(e/1048576).toFixed(1)} MB`}function dr(e){let t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}function Io(e){return["png","jpg","jpeg","gif","webp","svg","bmp","ico"].includes(e)}function cr(e){return["txt","md","markdown","json","toml","yaml","yml","xml","csv","tsv","rs","ts","tsx","js","mjs","cjs","jsx","css","html","htm","sh","bash","py","c","h","cc","cpp","hpp","go","java","kt","swift","rb","lua","sql","ini","cfg","conf","env","gitignore","lock","log","gbr","gtl","gbl","gts","gbs","gto","gbo","gm1","drl","pos","net","kicad_pro","kicad_prl","kicad_dru","kicad_sym","kicad_mod","kicad_wks"].includes(e)}function Ro(e){let t=dr(e);if(t==="kicad_pcb")return"board";if(t==="kicad_sch")return"schematic";if(t==="step"||t==="stp"||t==="glb")return"mech";return null}function pr(e,t,n,i){let s=!0,r="",o="",a=U("div","bp-pane bp-files-pane");a.setAttribute("data-testid","pane-files");let c=U("div","bp-pane-bar"),p=U("div","bp-files-crumbs"),l=U("button","bp-v-btn","Refresh");l.type="button",l.addEventListener("click",()=>void v(r)),c.append(p,l);let h=U("div","bp-files-split"),d=U("div","bp-files-list");d.setAttribute("data-testid","files-list");let u=U("div","bp-files-preview");u.setAttribute("data-testid","files-preview"),u.append(U("div","bp-pane-empty","Select a file to preview")),h.append(d,u),a.append(c,h),e.replaceChildren(a);function f(){p.replaceChildren();let w=U("button","bp-crumb-btn","project");if(w.type="button",w.addEventListener("click",()=>void v("")),p.append(w),!r)return;let E=r.split("/").filter(Boolean),k="";for(let L of E){k=k?`${k}/${L}`:L;let M=k;p.append(U("span","bp-vh-sep","/"));let A=U("button","bp-crumb-btn",L);A.type="button",A.addEventListener("click",()=>void v(M)),p.append(A)}}async function b(w,E,k){o=w,u.replaceChildren();let L=U("div","bp-files-prev-head");L.append(U("span","bp-files-prev-name",w));let M=U("div","bp-files-prev-acts"),A=Ro(E);if(A){let O=U("button","bp-v-btn is-primary",`Open in ${A}`);O.type="button",O.setAttribute("data-testid","files-open-viewer"),O.addEventListener("click",()=>i(A,w)),M.append(O)}let B=`/files/get?thread=${encodeURIComponent(n)}&path=${encodeURIComponent(w)}`,T=U("a","bp-v-btn","Download");T.href=B,T.download=E,M.append(T),L.append(M),u.append(L);let H=dr(E);if(Io(H)){let O=U("div","bp-files-img-wrap"),P=document.createElement("img");P.className="bp-files-img",P.alt=E,P.src=B,O.append(P),u.append(O);return}if(k>524288&&!cr(H)){u.append(U("div","bp-pane-empty",`Binary file (${fn(k)}). Use Download to save.`));return}if(cr(H)||k<=65536){let O=U("div","bp-pane-empty","Loading…");u.append(O);try{let P=await fetch(B,{credentials:"same-origin"});if(!s||o!==w)return;if(!P.ok){O.textContent=`Could not load file (${P.status})`;return}if((P.headers.get("content-type")||"").startsWith("image/")){O.remove();let de=document.createElement("img");de.className="bp-files-img",de.alt=E,de.src=B,u.append(de);return}let re=262144,ie=[],me=0,Pe=!1;if(P.body){let de=P.body.getReader();try{while(!0){let{done:ee,value:ge}=await de.read();if(ee||!ge)break;if(me+ge.byteLength>re){let C=re-me;if(C>0)ie.push(ge.subarray(0,C)),me+=C;Pe=!0,await de.cancel();break}ie.push(ge),me+=ge.byteLength}}finally{de.releaseLock()}}if(!s||o!==w)return;let Ce=new Uint8Array(me),te=0;for(let de of ie)Ce.set(de,te),te+=de.byteLength;let oe=!1;for(let de=0;deL.dir===M.dir?L.name.localeCompare(M.name):L.dir?-1:1),d.replaceChildren(),w){let L=U("button","bp-file-row is-dir");L.type="button",L.append(U("span","bp-file-icon","↰"),U("span","bp-file-name",".."));let M=w.includes("/")?w.slice(0,w.lastIndexOf("/")):"";L.addEventListener("click",()=>void v(M)),d.append(L)}if(k.length===0){d.append(U("div","bp-pane-empty","Empty folder"));return}for(let L of k){let M=w?`${w}/${L.name}`:L.name,A=U("button","bp-file-row"+(L.dir?" is-dir":"")+(M===o?" is-sel":""));A.type="button",A.setAttribute("data-testid",`file-row-${L.name}`),A.append(U("span","bp-file-icon",L.dir?"▸":"·"),U("span","bp-file-name",L.name),U("span","bp-file-size",L.dir?"":fn(L.size))),A.addEventListener("click",()=>{if(L.dir)v(M);else d.querySelectorAll(".bp-file-row.is-sel").forEach((B)=>B.classList.remove("is-sel")),A.classList.add("is-sel"),b(M,L.name,L.size)}),d.append(A)}}catch(E){if(!s)return;d.replaceChildren(U("div","bp-pane-empty",E instanceof Error?E.message:String(E)))}}return v(""),{destroy(){s=!1}}}function hr(e,t,n){let i=!0,s=U("div","bp-pane bp-diff-pane");s.setAttribute("data-testid","pane-diff");let r=U("div","bp-pane-bar"),o=U("span","bp-diff-summary","Loading diff…"),a=U("button","bp-v-btn","Refresh");a.type="button",a.addEventListener("click",()=>void p()),r.append(o,a);let c=U("div","bp-diff-body");c.setAttribute("data-testid","diff-body"),s.append(r,c),e.replaceChildren(s);async function p(){o.textContent="Loading diff…",c.replaceChildren();try{let l=await t.hub.rpc("viewer.diff",{thread:n});if(!i)return;if(l?.nogit){o.textContent="Not a git repository",c.append(U("div","bp-pane-empty","This project is not a git repository."));return}let h=typeof l?.diff==="string"?l.diff:"";if(!h.trim()){o.textContent="Clean working tree",c.append(U("div","bp-pane-empty","No uncommitted changes."));return}let d=h.split(` -`),u=0,f=0,b=0,v=document.createDocumentFragment(),w=U("div","bp-diff-file");for(let E of d){if(E.startsWith("diff --git ")){if(w.childNodes.length>0)v.append(w);w=U("div","bp-diff-file"),u++;let k=E.match(/ b\/(.+)$/);w.append(U("div","bp-diff-file-head",k?k[1]:E));continue}if(E.startsWith("index ")||E.startsWith("--- ")||E.startsWith("+++ "))w.append(U("div","bp-diff-line is-meta",E));else if(E.startsWith("@@"))w.append(U("div","bp-diff-line is-hunk",E));else if(E.startsWith("+"))f++,w.append(U("div","bp-diff-line is-add",E));else if(E.startsWith("-"))b++,w.append(U("div","bp-diff-line is-del",E));else w.append(U("div","bp-diff-line",E))}if(w.childNodes.length>0)v.append(w);o.textContent=`${u||1} file${u===1?"":"s"} · +${f} -${b}`,c.append(v)}catch(l){if(!i)return;o.textContent="Diff unavailable",c.append(U("div","bp-pane-empty",l instanceof Error?l.message:String(l)))}}return p(),{destroy(){i=!1}}}function jo(e,t){let n=t.rel||"",i=t.manifest||{},s=(p)=>`/files/get?thread=${encodeURIComponent(e)}&path=${encodeURIComponent(`${n}/${p}`)}`,r=(p)=>typeof p==="string"&&p!==""&&!p.startsWith("/")&&!p.split(/[\\/]/).includes(".."),o=(Array.isArray(i.drawings)?i.drawings:[]).filter((p)=>r(p?.file)),a=new Set(o.map((p)=>p.file)),c=o.map((p)=>({title:p.title||p.kind||p.file,file:p.file,url:s(p.file),drawing:!0}));for(let p of Array.isArray(i.files)?i.files:[])if(r(p)&&!a.has(p))c.push({title:p,file:p,url:s(p),drawing:!1});return c}function mr(e,t,n){let i=!0,s="checks",r=U("div","bp-pane bp-review-pane");r.setAttribute("data-testid","pane-review");let o=U("div","bp-pane-bar"),a=U("div","bp-review-tabs"),c=U("button","bp-v-btn is-on","Checks"),p=U("button","bp-v-btn","BOM"),l=U("button","bp-v-btn","Comments"),h=U("button","bp-v-btn","Release");h.setAttribute("data-testid","review-tab-release"),c.type=p.type=l.type=h.type="button",a.append(c,p,l,h);let d=U("button","bp-v-btn","Refresh");d.type="button",d.addEventListener("click",()=>void w()),o.append(a,d);let u=U("div","bp-review-body");u.setAttribute("data-testid","review-body"),r.append(o,u),e.replaceChildren(r);function f(E){s=E,c.classList.toggle("is-on",s==="checks"),p.classList.toggle("is-on",s==="bom"),l.classList.toggle("is-on",s==="comments"),h.classList.toggle("is-on",s==="release"),w()}c.addEventListener("click",()=>f("checks")),p.addEventListener("click",()=>f("bom")),l.addEventListener("click",()=>f("comments")),h.addEventListener("click",()=>f("release"));function b(E){let k=U("div","bp-review-md bp-review-release");k.setAttribute("data-testid","review-release");let L=E.manifest||{};k.append(U("h2","bp-review-h",E.tag||"Release")),k.append(U("p","bp-review-p",[L.commit?`Commit ${L.commit.slice(0,12)}`:"",L.date||""].filter(Boolean).join(" · ")));let M=jo(n,E),A=(T,H)=>{if(H.length===0)return;k.append(U("h3","bp-review-h",T));let O=U("table","bp-review-table");for(let P of H){let Y=document.createElement("tr"),re=U("td",void 0,P.title);re.title=P.file;let ie=document.createElement("td"),me=U("a","bp-v-btn","Download");me.href=P.url,me.download=P.file.split("/").pop()||P.file,ie.append(me),Y.append(re,ie),O.append(Y)}k.append(O)};A("Drawings",M.filter((T)=>T.drawing));let B=Array.isArray(L.openFabNotes)?L.openFabNotes:[];if(B.length>0)k.append(U("div","bp-review-gate",`Open fabrication notes, not in the board (agree them with the fabricator): ${B.join(", ")}.`));if(A("Files",M.filter((T)=>!T.drawing)),E.rel){let T=U("a","bp-v-btn","Download all (.zip)");T.href=`/files/zip?thread=${encodeURIComponent(n)}&path=${encodeURIComponent(E.rel)}`,k.append(T)}return k}function v(E){let k=U("div","bp-review-md"),L=E.split(` -`),M=0;while(M{H.preventDefault();let O=B.value.trim();if(!O)return;T.disabled=!0,t.hub.rpc("review.comment",{thread:n,text:O}).then(()=>{B.value="",T.disabled=!1,w()},()=>{T.disabled=!1})}),u.append(A),M.length===0){u.append(U("div","bp-pane-empty","No review comments yet."));return}for(let H of M){let O=U("div","bp-review-comment"+(H.resolved?" is-resolved":"")),P=[H.by||"review",H.file,H.layer,H.item].filter(Boolean).join(" · ");O.append(U("div","bp-review-comment-meta",P),U("div","bp-review-comment-text",H.text)),u.append(O)}return}let E=await t.hub.rpc("review.page",{thread:n,page:s});if(!i)return;let k=E?.report||{};if(u.replaceChildren(),k.line||k.gate){let L=U("div","bp-review-gate",[k.gate,k.line].filter(Boolean).join(" · "));u.append(L)}if(k.err)u.append(U("div","bp-review-err",k.err));if(Array.isArray(k.tasks)&&k.tasks.length>0){let L=U("div","bp-review-tasks");k.tasks.forEach((M,A)=>{let B=U("label","bp-review-task"),T=document.createElement("input");T.type="checkbox",T.checked=!!(M.done??M.checked);let H=typeof M.index==="number"?M.index:A;T.addEventListener("change",()=>{t.hub.rpc("review.tick",{thread:n,index:H}).then(()=>void w(),()=>{})}),B.append(T,U("span",void 0,M.text||M.label||`Item ${A+1}`)),L.append(B)}),u.append(L)}if(s==="release"&&k.release&&k.release.manifest)u.append(b(k.release));else if(k.md&&k.md.trim())u.append(v(k.md));else if(!k.err&&(!k.tasks||k.tasks.length===0))u.append(U("div","bp-pane-empty",s==="release"?"No release yet. A release tags this design and makes its fabrication outputs and drawings in .backplane/releases.":`No ${s==="bom"?"BOM":"design checks"} report available.`))}catch(E){if(!i)return;u.replaceChildren(U("div","bp-pane-empty",E instanceof Error?E.message:String(E)))}}return w(),{destroy(){i=!1}}}function ur(e,t){let n=e>>>16&255,i=e>>>8&255,s=e&255;return t>=0.999?`rgb(${n},${i},${s})`:`rgba(${n},${i},${s},${t.toFixed(3)})`}class li{canvas;ctx;frame=null;masks={off:0,dim:0,lift:255};highlights=new Set;lightTheme=!1;cx=0;cy=0;scale=0.0001;fittedKey="";fitW=0;fitH=0;userMoved=!1;dirty=!1;rafId=0;pointers=new Map;dragStart=null;pinchStart=null;resizeObs;cbs;constructor(e,t={}){this.cbs=t,this.canvas=document.createElement("canvas"),this.canvas.className="bp-viewer-canvas",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.style.touchAction="none",e.appendChild(this.canvas);let n=this.canvas.getContext("2d");if(!n)throw Error("Canvas2D unavailable");this.ctx=n,this.resizeObs=new ResizeObserver(()=>this.scheduleDraw()),this.resizeObs.observe(this.canvas),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.canvas.addEventListener("pointermove",this.onPointerMove),this.canvas.addEventListener("pointerup",this.onPointerUp),this.canvas.addEventListener("pointercancel",this.onPointerUp),this.canvas.addEventListener("wheel",this.onWheel,{passive:!1}),this.canvas.addEventListener("dblclick",this.onDblClick)}setTheme(e){if(this.lightTheme!==e)this.lightTheme=e,this.scheduleDraw()}setFrame(e){if(this.frame=e,e&&e.key!==this.fittedKey)this.fittedKey=e.key,this.fit();else this.scheduleDraw()}setLayers(e){this.masks=e,this.scheduleDraw()}setHighlights(e){this.highlights.clear();for(let[t,n]of e)this.highlights.add(`${t}:${n}`);this.scheduleDraw()}presentMask(){if(!this.frame)return 0;let e=0;for(let t of this.frame.chunks)if(t.layer<32)e=(e|1<>>0;return e>>>0}presentColors(){let e=new Map;if(!this.frame)return e;for(let t of this.frame.chunks)if(!e.has(t.layer))e.set(t.layer,t.color);return e}applyFit(e,t){if(!this.frame||e<10||t<10)return;let n=this.frame.box,i=Math.max(n[2]-n[0],1000),s=Math.max(n[3]-n[1],1000);this.cx=(n[0]+n[2])*0.5,this.cy=(n[1]+n[3])*0.5,this.scale=Math.min(e/i,t/s)*0.92,this.fitW=e,this.fitH=t,this.userMoved=!1}fit(){if(!this.frame)return;this.userMoved=!1,this.fitW=0,this.fitH=0;let e=this.canvas.getBoundingClientRect();if(e.width>=10&&e.height>=10)this.applyFit(e.width,e.height);this.scheduleDraw()}zoomToBoxMm(e){let t=e[0]*1000,n=e[1]*1000,i=e[2]*1000,s=e[3]*1000,r=Math.max(i-t,1000),o=Math.max(s-n,1000),a=this.canvas.getBoundingClientRect(),c=Math.max(a.width,200),p=Math.max(a.height,200);this.cx=(t+i)*0.5,this.cy=(n+s)*0.5,this.scale=Math.min(c/r,p/o)*0.85,this.userMoved=!0,this.scheduleDraw()}scheduleDraw(){if(this.dirty)return;this.dirty=!0,this.rafId=requestAnimationFrame(()=>{this.dirty=!1,this.rafId=0,this.draw()})}draw(){let e=this.canvas.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height)),i=Math.min(window.devicePixelRatio||1,2),s=Math.round(t*i),r=Math.round(n*i);if(this.canvas.width!==s||this.canvas.height!==r)this.canvas.width=s,this.canvas.height=r;let o=this.ctx;o.setTransform(i,0,0,i,0,0),o.fillStyle=this.lightTheme?"#f5f4ef":"#08090b",o.fillRect(0,0,t,n);let a=this.frame;if(!a)return;if(!this.userMoved&&t>=10&&n>=10&&(Math.abs(this.fitW-t)>2||Math.abs(this.fitH-n)>2))this.applyFit(t,n);let c=t*0.5,p=n*0.5,l=this.scale,h=this.cx,d=this.cy,u=h-c/l,f=h+c/l,b=d-p/l,v=d+p/l,{off:w,dim:E,lift:k}=this.masks,L=[],M=[];for(let B=0;B>>T&1)===1)continue;if(T===k)M.push(B);else L.push(B)}let A=L.concat(M);o.lineCap="round",o.lineJoin="round";for(let B=0;B>>H.layer&1)===1,P=H.alpha*(O?0.25:1);if(P<=0.01)continue;this.drawChunk(o,H,P,u,b,f,v,h,d,l,c,p)}if(this.highlights.size>0){o.fillStyle=this.lightTheme?"rgba(245,244,239,0.72)":"rgba(8,9,11,0.72)",o.fillRect(0,0,t,n);let B=this.lightTheme?"rgba(27,29,33,0.77)":"rgba(217,221,228,0.77)";for(let T=0;Tr||v.y1o)continue;if(v.n<3)continue;let w=(d[v.at]-a)*p+l,E=(d[v.at+1]-c)*p+h;e.moveTo(w,E);for(let k=1;k0)e.fill()}else if(t.mode===2){let f=Math.max(0.75,t.r*p);e.fillStyle=u,e.beginPath();let b=0;for(let v=0;vr||w.y1o)continue;let E=(d[w.at]-a)*p+l,k=(d[w.at+1]-c)*p+h;e.moveTo(E+f,k),e.arc(E,k,f,0,Math.PI*2),b++}if(b>0)e.fill()}else{e.strokeStyle=u,e.lineWidth=Math.max(1,t.r*2*p),e.beginPath();let f=0;for(let b=0;br||v.y1o)continue;let w=(d[v.at]-a)*p+l,E=(d[v.at+1]-c)*p+h;if(v.n===1)e.moveTo(w,E),e.lineTo(w+0.01,E);else{e.moveTo(w,E);for(let k=1;k0)e.stroke()}}drawLitPieces(e,t,n,i,s,r,o,a,c,p,l,h,d){let u=t.pts,f=ur(t.color,t.alpha);for(let b=0;bo||v.y1a)continue;let w=(u[v.at]-c)*l+h,E=(u[v.at+1]-p)*l+d;if(v.kind===2){let k=Math.max(1.5,t.r*l);e.fillStyle=f,e.beginPath(),e.arc(w,E,k,0,Math.PI*2),e.fill(),e.strokeStyle=i,e.lineWidth=1.5,e.stroke()}else if(v.kind===0&&v.n>=3){e.fillStyle=f,e.beginPath(),e.moveTo(w,E);for(let k=1;k=0;l--){let h=n.chunks[l];if(h.layer<32&&(p>>>h.layer&1)===1)continue;for(let d=0;du.x1+o||ru.y1+o)continue;let f=(u.x1-u.x0+1)*(u.y1-u.y0+1);if(f{if(this.canvas.setPointerCapture(e.pointerId),this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===1)this.dragStart={x:e.clientX,y:e.clientY,cx:this.cx,cy:this.cy,moved:!1},this.pinchStart=null;else if(this.pointers.size===2){let[t,n]=Array.from(this.pointers.values());this.pinchStart={dist:Math.hypot(n.x-t.x,n.y-t.y)||1,midX:(t.x+n.x)*0.5,midY:(t.y+n.y)*0.5,scale:this.scale,cx:this.cx,cy:this.cy},this.dragStart=null}};onPointerMove=(e)=>{if(!this.pointers.has(e.pointerId))return;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===2&&this.pinchStart){let[t,n]=Array.from(this.pointers.values()),i=Math.hypot(n.x-t.x,n.y-t.y)||1,s=(t.x+n.x)*0.5,r=(t.y+n.y)*0.5,o=i/this.pinchStart.dist,a=Math.max(0.0000001,Math.min(2,this.pinchStart.scale*o)),c=this.canvas.getBoundingClientRect(),p=this.pinchStart.midX-c.left-c.width*0.5,l=this.pinchStart.midY-c.top-c.height*0.5,h=s-c.left-c.width*0.5,d=r-c.top-c.height*0.5;this.scale=a,this.cx=this.pinchStart.cx+p/this.pinchStart.scale-h/a,this.cy=this.pinchStart.cy+l/this.pinchStart.scale-d/a,this.userMoved=!0,this.cbs.onUserMove?.(),this.scheduleDraw();return}if(this.dragStart&&this.pointers.size===1){let t=e.clientX-this.dragStart.x,n=e.clientY-this.dragStart.y;if(Math.hypot(t,n)>3)this.dragStart.moved=!0;if(this.dragStart.moved)this.cx=this.dragStart.cx-t/this.scale,this.cy=this.dragStart.cy-n/this.scale,this.userMoved=!0,this.cbs.onUserMove?.(),this.scheduleDraw()}};onPointerUp=(e)=>{let t=this.dragStart&&!this.dragStart.moved&&this.pointers.size===1;if(this.pointers.delete(e.pointerId),this.pointers.size<2)this.pinchStart=null;if(this.pointers.size===0)this.dragStart=null;if(t&&this.cbs.onPick){let n=this.canvas.getBoundingClientRect(),i=this.hitTest(e.clientX-n.left,e.clientY-n.top);this.cbs.onPick(i)}};onWheel=(e)=>{e.preventDefault();let t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left-t.width*0.5,i=e.clientY-t.top-t.height*0.5,s=e.deltaY<0?1.16:0.8620689655172414,r=Math.max(0.0000001,Math.min(2,this.scale*s));this.cx+=n/this.scale-n/r,this.cy+=i/this.scale-i/r,this.scale=r,this.userMoved=!0,this.cbs.onUserMove?.(),this.scheduleDraw()};onDblClick=()=>{this.fit()};destroy(){if(this.rafId)cancelAnimationFrame(this.rafId);this.resizeObs.disconnect(),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.remove()}}var br=[{id:"fit",label:"Fit"},{id:"iso",label:"Iso"},{id:"top",label:"Top"},{id:"bottom",label:"Bottom"},{id:"front",label:"Front"},{id:"right",label:"Right"},{id:"back",label:"Back"},{id:"left",label:"Left"}];function gr(e){switch(e){case"top":return{yaw:0,pitch:Math.PI*0.499};case"bottom":return{yaw:0,pitch:-Math.PI*0.499};case"front":return{yaw:0,pitch:0};case"right":return{yaw:Math.PI*0.5,pitch:0};case"back":return{yaw:Math.PI,pitch:0};case"left":return{yaw:-Math.PI*0.5,pitch:0};case"iso":case"fit":default:return{yaw:0.6,pitch:0.7}}}function ci(e,t,n,i){if(!e||!t||!n||!i)return!1;if(!e.startsWith(t))return!1;let s=e.slice(t.length).split(` -`),r=(s[0]||"").split("\t");if(r[0]!=="git"||r[2]!==n)return!1;let o=s[1]||r.slice(4).join("\t");if(!o)return!1;let a=o.replace(/\\/g,"/"),c=i.replace(/\\/g,"/");if(c.startsWith("/")||/^[A-Za-z]:\//.test(c))return a===c;return a===c||a.endsWith(`/${c}`)}class di{refs=[];index=-1;lastCommit="";highlightEdits=!1;playing=!1;setRefs(e){if(this.refs=e,this.index>=e.length)this.index=-1,this.highlightEdits=!1}isLive(){return this.index<0||this.index>=this.refs.length}activeRef(){return this.isLive()?null:this.refs[this.index]}step(e){if(this.refs.length===0)return!1;let t=this.index;if(e>0)this.index=Math.min(this.refs.length-1,this.index+1);else this.index=Math.max(-1,this.index-1);if(this.index===-1)this.playing=!1,this.highlightEdits=!1;else this.lastCommit=this.refs[this.index].commit,this.highlightEdits=!0;return this.index!==t}selectCommit(e){if(!e)return this.goLive();let t=this.refs.findIndex((i)=>i.commit===e);if(t<0)return!1;let n=this.index!==t||!this.highlightEdits;return this.index=t,this.lastCommit=e,this.highlightEdits=!0,n}goLive(){let e=this.index!==-1||this.playing||this.highlightEdits;return this.index=-1,this.playing=!1,this.highlightEdits=!1,e}toggleHighlight(){if(this.highlightEdits)return this.goLive(),!1;if(this.refs.length===0)return!1;let e=this.lastCommit?this.refs.findIndex((t)=>t.commit===this.lastCommit):0;return this.index=e>=0?e:0,this.lastCommit=this.refs[this.index].commit,this.highlightEdits=!0,!0}compareRequest(){let e=this.activeRef();if(!e||!this.highlightEdits)return null;return{commit:e.commit,bits:0}}}var Ho=`#version 300 es +`),h=document.createElement("div");h.className="bp-code-block";let d=document.createElement("div");d.className="bp-code-head";let u=document.createElement("span");u.className="bp-code-lang",u.textContent=c||"code";let f=document.createElement("button");f.type="button",f.className="bp-btn-ghost bp-code-copy";let g=m("common.copy","Copy");f.textContent=g,f.addEventListener("click",()=>{navigator.clipboard?.writeText(l).then(()=>{f.textContent="✓",window.setTimeout(()=>{f.textContent=g},1200)}).catch(()=>{})}),d.append(u,f);let v=document.createElement("pre"),y=document.createElement("code");y.textContent=l,v.appendChild(y),h.append(d,v),t.appendChild(h);continue}if(!s.trim()){i++;continue}let r=/^(#{1,4})\s+(.+)$/.exec(s);if(r){let c=document.createElement(`h${Math.min(4,r[1].length+1)}`);c.className="bp-md-h",Vt(c,r[2]),t.appendChild(c),i++;continue}if(s.startsWith("> ")){let c=document.createElement("blockquote");c.className="bp-md-quote";let p=[];while(i "))p.push(n[i].slice(2)),i++;Vt(c,p.join(` +`)),t.appendChild(c);continue}if(/^\s*[-*]\s+/.test(s)){let c=document.createElement("ul");c.className="bp-md-list";while(i ")&&!/^\s*[-*]\s+/.test(n[i])&&!/^\s*\d+\.\s+/.test(n[i]))o.push(n[i]),i++;let a=document.createElement("p");a.className="bp-md-p";for(let c=0;c0)a.appendChild(document.createElement("br"));Vt(a,o[c])}t.appendChild(a)}return t}var Vr=new Set(["(","[",'"',"'","`"]);function Ur(e){return/[\p{L}\p{N}\-_\/+\[]/u.test(e)}function Wr(e){return/[\p{L}\p{N}\-_\/]/u.test(e)}function _r(e){return/[\p{L}\p{N}]/u.test(e)}function Ri(e,t){if(!e)return[];let n=(t??[]).filter((r)=>r.kind==="model"&&r.word&&r.label);if(n.length===0)return[{kind:"text",text:e}];let i=[],s=0;while(so)r=l,o=h,a=c;break}p=l+1}}if(a===null)break;if(r>s)i.push({kind:"text",text:e.slice(s,r)});i.push({kind:"model",word:a.word,label:a.label}),s=o}if(s3600000)return"";let t=Math.max(1,Math.round(e/1000));if(t<60)return`${t}s`;let n=Math.floor(t/60),i=t%60;return i>0?`${n}m ${i}s`:`${n}m`}function Kr(e,t){let n=document.createDocumentFragment(),i=Ri(e,t),s=m("native.thread.model","Model").toLowerCase();for(let r of i){if(r.kind==="text"){n.appendChild(document.createTextNode(r.text));continue}let o=document.createElement("span");o.className="bp-ref-chip bp-ref-model",o.title=r.word,o.setAttribute("data-ref-word",r.word);let a=document.createElement("span");a.className="bp-ref-sigil",a.textContent="&";let c=document.createElement("span");c.className="bp-ref-label",c.textContent=r.label;let p=document.createElement("span");p.className="bp-ref-kind",p.textContent=s,o.append(a,c,p),n.appendChild(o)}return n}function Jr(e){e.addEventListener("copy",(t)=>{let n=typeof window<"u"?window.getSelection():null;if(!n||n.rangeCount===0||n.isCollapsed)return;let i=n.getRangeAt(0);if(!e.contains(i.commonAncestorContainer))return;let s=i.commonAncestorContainer,a=(s.nodeType===Node.ELEMENT_NODE?s:s.parentElement)?.closest(".bp-ref-chip[data-ref-word]")?.getAttribute("data-ref-word"),c;if(a)c=a;else{let p=i.cloneContents(),l=p.querySelectorAll(".bp-ref-chip[data-ref-word]");if(l.length===0)return;for(let d of l){let u=d.getAttribute("data-ref-word")||d.textContent||"";d.replaceWith(document.createTextNode(u))}let h=p.querySelectorAll(".bp-entry");for(let d=1;d{if(!this.loadingOlder&&this.hasMore)this.loadingOlder=!0,this.cb.onLoadOlder()}),this.scrollEl.addEventListener("scroll",()=>{if(this.pinnedToBottom=this.isNearBottom(),this.hasMore&&!this.loadingOlder&&this.scrollEl.scrollTop<48)this.loadingOlder=!0,this.cb.onLoadOlder()}),typeof ResizeObserver<"u"){let n=0;new ResizeObserver(()=>{let s=this.scrollEl.clientHeight;if(n>0&&s!==n&&this.pinnedToBottom)this.scrollToBottom();n=s}).observe(this.scrollEl)}this.listEl=document.createElement("div"),this.listEl.className="bp-timeline-list",Jr(this.scrollEl),this.scrollEl.append(this.olderBtn,this.listEl),e.append(this.bannerEl,this.scrollEl)}setLoading(e){this.thread=e,this.entries=[],this.hasMore=!1,this.loadingOlder=!1,this.review=null,this.unanswered=null,this.btwNote=null,this.liveNodes.clear(),this.planExpanded.clear(),this.planRevisingId="",this.planReviseDrafts.clear(),this.renderBanners(),this.olderBtn.classList.add("bp-hidden");let t=document.createElement("div");t.className="bp-empty-state",t.textContent=m("web.chat.loading","Loading messages…"),this.listEl.replaceChildren(t)}setError(e,t,n){this.thread=e,this.entries=[],this.hasMore=!1,this.loadingOlder=!1,this.review=null,this.unanswered=null,this.btwNote=null,this.liveNodes.clear(),this.planExpanded.clear(),this.planRevisingId="",this.planReviseDrafts.clear(),this.renderBanners(),this.olderBtn.classList.add("bp-hidden");let i=document.createElement("div");i.className="bp-empty-state";let s=document.createElement("div");s.className="bp-bad",s.textContent=t;let r=document.createElement("button");r.type="button",r.textContent=m("tools.retry","Retry"),r.addEventListener("click",n),i.append(s,r),this.listEl.replaceChildren(i)}getEntries(){return this.entries.slice()}refreshLocale(){let e=this.scrollEl.scrollTop;if(this.olderBtn.textContent=m("android.load.earlier","Load earlier"),this.renderBanners(),this.thread&&this.entries.length>0)this.renderEntries(!1);this.scrollEl.scrollTop=e}setThread(e,t,n,i,s){if((this.thread?.id??"")!==(e?.id??""))this.planExpanded.clear(),this.planRevisingId="",this.planReviseDrafts.clear();this.thread=e,this.entries=t.filter((r)=>!An(r)),this.hasMore=n,this.loadingOlder=!1,this.review=i,this.unanswered=s,this.btwNote=null,this.renderBanners(),this.renderEntries(!0)}updateThreadMeta(e){if(!this.thread||this.thread.id!==e.id)return;this.thread=e}setReview(e){this.review=e,this.renderBanners()}setUnanswered(e){this.unanswered=e,this.renderBanners()}setNoProvider(e){this.noProvider=e,this.renderBanners()}showBtw(e,t){this.btwNote={q:e,a:t},this.renderBanners()}prependEntries(e,t){this.loadingOlder=!1;let n=this.scrollEl.scrollHeight,i=new Set(this.entries.map((r)=>r.id)),s=e.filter((r)=>!An(r)&&!i.has(r.id));this.entries=[...s,...this.entries],this.hasMore=t,this.renderEntries(!1),this.scrollEl.scrollTop+=this.scrollEl.scrollHeight-n}clearLoadingOlder(){this.loadingOlder=!1}upsertEntry(e){if(An(e))return;let t=this.isNearBottom()||e.kind==="user"&&Boolean(e.clientId),n=this.entries.findIndex((i)=>i.id===e.id);if(n<0&&e.clientId)n=this.entries.findIndex((i)=>i.clientId&&i.clientId===e.clientId);if(n>=0)this.entries[n]=e;else this.entries.push(e);this.renderEntries(t)}goTo(e){let t=this.scrollEl.querySelector(`[data-entry-id="${CSS.escape(e)}"]`);if(!t)return!1;return t.scrollIntoView({block:"center",behavior:"smooth"}),t.classList.remove("bp-entry-flash"),t.offsetWidth,t.classList.add("bp-entry-flash"),window.setTimeout(()=>t.classList.remove("bp-entry-flash"),1200),!0}removeEntry(e){let t=this.entries.filter((n)=>n.id!==e);if(t.length!==this.entries.length)this.entries=t,this.renderEntries(!1)}appendLiveText(e,t,n){let i=this.isNearBottom(),s=this.entries.find((o)=>o.id===e);if(!s){s={id:e,kind:"assistant",text:t,at:n,live:!0},this.entries.push(s),this.renderEntries(i);return}s.text+=t,s.live=!0;let r=this.liveNodes.get(e);if(r){if(r.replaceChildren(Ut(s.text)),i)this.scrollToBottom()}else this.renderEntries(i)}isNearBottom(){let e=this.scrollEl;return e.scrollHeight-e.scrollTop-e.clientHeight<80}scrollToBottom(){this.pinnedToBottom=!0,this.scrollEl.scrollTop=this.scrollEl.scrollHeight}renderBanners(){let e=document.createDocumentFragment();if(this.noProvider&&!this.thread?.id.includes("~")){let t=document.createElement("div");t.className="bp-banner bp-no-provider",t.setAttribute("data-testid","no-provider-banner");let n=document.createElement("div");n.className="bp-no-provider-body";let i=document.createElement("strong");if(i.textContent=fe(this.noProvider.head),n.appendChild(i),this.noProvider.text){let o=document.createElement("span");o.className="bp-dim",o.textContent=fe(this.noProvider.text),n.appendChild(o)}let s=document.createElement("div");s.className="bp-banner-actions";let r=document.createElement("button");r.type="button",r.className="primary",r.setAttribute("data-testid","no-provider-accounts-btn"),r.textContent=fe(this.noProvider.button),r.addEventListener("click",()=>this.cb.onOpenAccounts?.()),s.appendChild(r),t.append(n,s),e.appendChild(t)}if(this.review&&(this.review.text||this.review.button)){let t=document.createElement("div");t.className="bp-banner bp-review-bar",t.setAttribute("data-testid","review-bar");let n=document.createElement("span");if(n.textContent=this.review.text||m("web.chat.review.mode","Review mode"),t.appendChild(n),this.review.button){let i=document.createElement("button");i.type="button",i.textContent=this.review.button,i.addEventListener("click",()=>this.cb.onToggleReview(!(this.review?.on??!0))),t.appendChild(i)}e.appendChild(t)}if(this.unanswered&&(this.unanswered.head||this.unanswered.text)){let t=document.createElement("div");t.className="bp-banner bp-unanswered",t.setAttribute("data-testid","unanswered-notice");let n=document.createElement("div");if(n.className="bp-unanswered-body",this.unanswered.head){let i=document.createElement("strong");i.textContent=this.unanswered.head,n.appendChild(i)}if(this.unanswered.text){let i=document.createElement("span");i.textContent=this.unanswered.text,n.appendChild(i)}if(t.appendChild(n),this.unanswered.buttons?.length){let i=document.createElement("div");i.className="bp-banner-actions";for(let s of this.unanswered.buttons){let r=document.createElement("button");if(r.type="button",s.primary)r.className="primary";r.textContent=s.label,r.addEventListener("click",()=>this.cb.onUnansweredAction(s.action,s.value)),i.appendChild(r)}t.appendChild(i)}e.appendChild(t)}if(this.btwNote){let t=document.createElement("div");t.className="bp-banner bp-btw-banner";let n=document.createElement("div"),i=document.createElement("div");i.className="bp-dim",i.textContent=`/btw ${this.btwNote.q}`;let s=document.createElement("div");s.appendChild(Ut(this.btwNote.a)),n.append(i,s);let r=document.createElement("button");r.type="button",r.className="icon",r.textContent="×",r.addEventListener("click",()=>{this.btwNote=null,this.renderBanners()}),t.append(n,r),e.appendChild(t)}this.bannerEl.replaceChildren(e)}makeEntryActions(e,t,n){let i=document.createElement("div");i.className="bp-entry-foot"+(t?" user":"");let s=document.createElement("button");s.type="button",s.className="bp-entry-act";let r=m("common.copy","Copy"),o=document.createElement("span");o.textContent=r,s.append(Wt(["M9 9h11v11H9z","M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1"]),o),s.addEventListener("click",()=>{navigator.clipboard?.writeText(e.text||"").then(()=>{o.textContent="✓",window.setTimeout(()=>{o.textContent=r},1000)}).catch(()=>{})});let a=document.createElement("button");a.type="button",a.className="bp-entry-act";let c=document.createElement("span");c.textContent=m("reply.action","Reply"),a.append(Wt(["M9 17l-5-5 5-5","M20 18v-2a4 4 0 0 0-4-4H4"]),c),a.addEventListener("click",()=>this.cb.onReplyEntry(e));let p=!e.live&&!e.id.startsWith("local-")&&!e.id.startsWith("live:"),l=document.createElement("span");l.className="bp-entry-time";let h=zr(e.at);if(t)l.textContent=h,i.append(s,...p?[a]:[],l);else{let d=n&&e.at?qr(Ln(e.at)-Ln(n)):"",u=h?d?m("web.chat.finished.dur","Finished {time} · {dur}",{time:h,dur:d}):m("web.chat.finished","Finished {time}",{time:h}):"";l.textContent=e.live?m("web.chat.streaming","Streaming…"):u,i.append(l,s,...p?[a]:[])}return i}closePlanRevise(){let e=this.planRevisingId;if(!e)return!1;this.planRevisingId="";let t=this.scrollEl.scrollTop;return this.renderEntries(!1),this.scrollEl.scrollTop=t,this.listEl.querySelector(`[data-testid="ask-${CSS.escape(e)}"] [data-testid="plan-revise"]`)?.focus(),!0}renderEntries(e){let t=null,n=typeof document<"u"?document.activeElement:null;if(n instanceof HTMLTextAreaElement&&n.classList.contains("bp-plan-revise-input")&&this.listEl.contains(n)&&this.planRevisingId)this.planReviseDrafts.set(this.planRevisingId,n.value),t={askId:this.planRevisingId,start:n.selectionStart,end:n.selectionEnd,dir:n.selectionDirection};this.olderBtn.classList.toggle("bp-hidden",!this.hasMore),this.liveNodes.clear();let i=document.createDocumentFragment();if(!this.thread){let r=document.createElement("div");r.className="bp-empty-state",r.textContent=m("web.chat.choose","Choose a project thread on the left to begin."),i.appendChild(r),this.listEl.replaceChildren(i);return}if(this.entries.length===0){let r=document.createElement("div");r.className="bp-empty-state",r.textContent=m("web.chat.empty","No messages yet. Type below to start a turn."),i.appendChild(r),this.listEl.replaceChildren(i);return}let s=0;for(let r of this.entries){if(r.kind==="user"&&r.at)s=r.at;let o=document.createElement("article");if(o.className=`bp-entry bp-entry-${r.kind}`+(r.live?" is-live":""),o.setAttribute("data-entry-id",r.id),r.kind==="tool"&&r.tool){let l=document.createElement("div");l.className=`bp-tool-pill bp-tool-${r.tool.state||"done"}`;let h=document.createElement("span");if(h.className="bp-tool-name",h.textContent=r.tool.name,l.appendChild(h),r.tool.summary){let d=document.createElement("span");d.className="bp-tool-summary",d.textContent=r.tool.summary,l.appendChild(d)}o.appendChild(l),i.appendChild(o);continue}if(r.kind==="ask"&&r.ask){let l=r.ask;if(l.kind==="plan"){o.appendChild(this.renderPlanAsk(l)),i.appendChild(o);continue}let h=document.createElement("div");h.className="bp-ask-card",h.setAttribute("data-testid",`ask-${l.id}`);let d=document.createElement("div");if(d.className="bp-ask-q",d.textContent=l.question,h.appendChild(d),l.state==="open"){let u=document.createElement("div");if(u.className="bp-ask-opts",l.options&&l.options.length>0)for(let f of l.options){let g=document.createElement("button");g.type="button",g.textContent=f.label,g.addEventListener("click",()=>this.cb.onAnswerAsk(l.id,f.id)),u.appendChild(g)}else{let f=document.createElement("input");f.type="text",f.className="bp-input",f.placeholder=m("web.chat.answer.placeholder","Type answer…");let g=document.createElement("button");g.type="button",g.className="primary",g.textContent=m("web.chat.answer.btn","Answer"),g.addEventListener("click",()=>{if(f.value.trim())this.cb.onAnswerAsk(l.id,f.value.trim())}),u.append(f,g)}h.appendChild(u)}else{let u=document.createElement("div");u.className="bp-ask-answered",u.textContent=m("web.chat.answered","Answered: {answer}",{answer:l.answered??""}),h.appendChild(u)}o.appendChild(h),i.appendChild(o);continue}let a=Boolean(r.text&&r.text.trim().length>0),c=Boolean(r.images&&r.images.length>0),p=Boolean(r.attachments&&r.attachments.length>0);if(!a&&!c&&!p&&!r.live)continue;if(r.replyTo?.quote){let l=document.createElement("div");l.className="bp-reply-quote",l.textContent=m("gpui.b.in.reply.to","↩ In reply to: {quote}",{quote:r.replyTo.quote});let h=r.replyTo.id;l.setAttribute("role","button"),l.tabIndex=0,l.setAttribute("data-testid","entry-reply-quote");let d=()=>{if(this.cb.onGoToEntry)this.cb.onGoToEntry(h);else this.goTo(h)};l.addEventListener("click",d),l.addEventListener("keydown",(u)=>{if(u.key==="Enter"||u.key===" ")u.preventDefault(),d()}),o.appendChild(l)}if(a||r.live){let l=document.createElement("div");if(l.className="bp-entry-body",r.kind==="user")l.appendChild(Kr(r.text||"",r.refs));else l.appendChild(Ut(r.text||""));if(r.live)this.liveNodes.set(r.id,l);o.appendChild(l)}if(p&&r.attachments){let l=document.createElement("div");l.className="bp-entry-images";for(let h of r.attachments)if(h.previewUrl){let d=document.createElement("img");d.className="bp-reply-img",d.src=h.previewUrl,d.alt=h.name||"attachment",l.appendChild(d)}else if(h.path||h.name){let d=document.createElement("span");d.className="bp-tool-pill",d.textContent=h.name||h.path||"image",l.appendChild(d)}if(l.childElementCount>0)o.appendChild(l)}if(r.images&&r.images.length>0){let l=document.createElement("div");l.className="bp-entry-images";for(let h of r.images){let d=document.createElement("img");d.className="bp-reply-img",d.alt=h;let u=`${r.id}|${h}`,f=this.imageCache.get(u);if(f)d.src=f;else this.cb.onLoadImage(r.id,h).then((g)=>{if(!g)return;let v=g.url??(g.mime&&g.data?`data:${g.mime};base64,${g.data}`:"");if(!v)return;this.imageCache.set(u,v),d.src=v});l.appendChild(d)}o.appendChild(l)}o.appendChild(this.makeEntryActions(r,r.kind==="user",r.kind==="assistant"?s:void 0)),i.appendChild(o)}if(this.listEl.replaceChildren(i),t&&this.planRevisingId===t.askId){let r=this.listEl.querySelector(`[data-testid="ask-${CSS.escape(t.askId)}"] .bp-plan-revise-input`);if(r){if(r.focus({preventScroll:!0}),t.start!==null&&t.end!==null)r.setSelectionRange(t.start,t.end,t.dir??void 0)}}if(e&&!t)this.scrollToBottom()}renderPlanAsk(e){let t=this.planExpanded.has(e.id),n=e.state==="open"&&this.planRevisingId===e.id,i=document.createElement("div");i.className="bp-ask-card bp-ask-plan",i.setAttribute("data-testid",`ask-${e.id}`);let s=document.createElement("div");s.className="bp-plan-head";let r=Wt(["M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z","M14 2v6h6","M16 13H8","M16 17H8","M10 9H8"]);r.classList.add("bp-plan-head-ic");let o=document.createElement("span");if(o.className="bp-plan-title",o.textContent=!e.head||e.head==="Proposed plan"?m("ask.plan","Proposed plan"):fe(e.head),s.append(r,o),e.state==="open"){let l=document.createElement("span");l.className="bp-plan-badge",l.textContent=m("gpui.ask.plan.ready","Ready for review"),s.appendChild(l)}let a=document.createElement("span");if(a.className="bp-mgmt-flex1",s.appendChild(a),e.question){let l=document.createElement("button");l.type="button",l.className="bp-plan-head-btn";let h=m("common.copy","Copy"),d=document.createElement("span");d.textContent=h,l.append(Wt(["M9 9h11v11H9z","M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1"]),d),l.addEventListener("click",()=>{navigator.clipboard?.writeText(e.question).then(()=>{l.classList.add("copied"),d.textContent=m("web.clone.copied","Copied"),window.setTimeout(()=>{l.classList.remove("copied"),d.textContent=h},1200)}).catch(()=>{})}),s.appendChild(l)}let c=document.createElement("button");c.type="button",c.className="bp-plan-head-btn",c.setAttribute("data-testid","plan-expand"),c.textContent=t?m("gpui.c.term.collapse","Collapse"):m("gpui.c.term.expand","Expand"),c.addEventListener("click",()=>{if(this.planExpanded.has(e.id))this.planExpanded.delete(e.id);else this.planExpanded.add(e.id);let l=this.scrollEl.scrollTop;this.renderEntries(!1),this.scrollEl.scrollTop=l}),s.appendChild(c),i.appendChild(s);let p=document.createElement("div");if(p.className="bp-plan-body"+(t?" is-expanded":""),p.setAttribute("data-testid","plan-body"),p.appendChild(Ut(e.question||"")),i.appendChild(p),e.state==="open"){let l=document.createElement("div");l.className="bp-plan-actions";let h=e.options?.find((g)=>g.id==="implement"||g.id.endsWith("|implement")),d=document.createElement("button");if(d.type="button",d.className="primary",d.setAttribute("data-testid","plan-implement"),d.textContent=h?.label&&h.label!=="Implement"?fe(h.label):m("approval.implement","Implement"),d.addEventListener("click",()=>{this.planRevisingId="",this.planReviseDrafts.delete(e.id),this.cb.onAnswerAsk(e.id,h?.id??"implement")}),l.appendChild(d),e.revise!==!1){let g=document.createElement("button");g.type="button",g.className="bp-plan-revise-btn"+(n?" active":""),g.setAttribute("data-testid","plan-revise"),g.append(Wt(["M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7","M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"]),document.createTextNode(m("gpui.ask.plan.revise","Revise"))),g.addEventListener("click",()=>{let v=this.planRevisingId!==e.id;this.planRevisingId=v?e.id:"";let y=this.scrollEl.scrollTop;if(this.renderEntries(!1),this.scrollEl.scrollTop=y,v)this.listEl.querySelector(`[data-testid="ask-${CSS.escape(e.id)}"] .bp-plan-revise-input`)?.focus()}),l.appendChild(g)}let u=e.options?.find((g)=>g.id==="dismiss"||g.id.endsWith("|dismiss")),f=document.createElement("button");if(f.type="button",f.className="bp-plan-dismiss-btn",f.setAttribute("data-testid","plan-dismiss"),f.textContent=u?.label&&u.label!=="Dismiss"?fe(u.label):m("approval.dismiss","Dismiss"),f.addEventListener("click",()=>{this.planRevisingId="",this.planReviseDrafts.delete(e.id),this.cb.onAnswerAsk(e.id,u?.id??"dismiss")}),l.appendChild(f),i.appendChild(l),n){let g=document.createElement("div");g.className="bp-plan-revise",g.setAttribute("data-testid","plan-revise-drawer");let v=document.createElement("textarea");v.rows=2,v.className="bp-input bp-plan-revise-input",v.placeholder=m("gpui.ask.plan.reviseph","What should change in the plan?"),v.value=this.planReviseDrafts.get(e.id)??"";let y=document.createElement("button");y.type="button",y.className="bp-plan-revise-send",y.setAttribute("data-testid","plan-revise-send"),y.textContent=m("gpui.ask.plan.sendrev","Send revision"),y.disabled=v.value.trim().length===0;let w=()=>{let N=v.value.trim();if(!N)return;this.planRevisingId="",this.planReviseDrafts.delete(e.id),this.cb.onAnswerAsk(e.id,`revise:${N}`)},k=()=>{this.closePlanRevise()};g.addEventListener("keydown",(N)=>{if(N.key==="Escape")N.preventDefault(),N.stopPropagation(),k()}),v.addEventListener("input",()=>{this.planReviseDrafts.set(e.id,v.value),y.disabled=v.value.trim().length===0}),v.addEventListener("keydown",(N)=>{if(N.key==="Enter"&&!N.shiftKey)N.preventDefault(),w()}),y.addEventListener("click",w);let A=document.createElement("button");A.type="button",A.className="bp-btn-ghost",A.textContent=m("common.cancel","Cancel"),A.addEventListener("click",k),g.append(v,y,A),i.appendChild(g)}}else{let l=document.createElement("div");l.className="bp-ask-answered",l.textContent=m("web.chat.answered","Answered: {answer}",{answer:e.answered??""}),i.appendChild(l)}return i}}var Yr={claude:"Claude Code",codex:"Codex CLI",grok:"Grok CLI",muse:"Muse Code",antigravity:"Google Antigravity",opencode:"OpenCode",pi:"Pi",omp:"Oh My Pi"};var Hi=/[\x00-\x1f\x7f]/,Xr=/\s/;function Lt(e){return e.trim().replace(/^@+/,"").toLowerCase()}function yt(e,t){if(Hi.test(e)||Hi.test(t))return"";let n=Lt(e),i=t.trim();if(!n||!i||n.includes("/")||Xr.test(n))return"";if(n.length+1+i.length>200)return"";return`${n}/${i}`}function Di(e){let t=e.indexOf("/");if(t<=0)return null;let n=e.slice(0,t),i=e.slice(t+1);if(!yt(n,i))return null;return{provider:Lt(n),model:i.trim()}}function dt(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let i of e){if(typeof i!=="string")continue;let s=Di(i);if(!s)continue;let r=`${s.provider}/${s.model}`;if(!n.has(r)){if(n.add(r),t.push(r),t.length>=64)break}}return t}function Mn(e,t,n,i){let s=yt(t,n),r=dt(e);if(!s)return{keys:r,starred:!1};let o=r.indexOf(s),a=i!==void 0?i:o<0;if(a&&o<0){if(r.length>=64)return{keys:r,starred:!1};r.push(s)}else if(!a&&o>=0)r.splice(o,1);return{keys:r,starred:a}}function it(e){return e&&typeof e==="object"&&!Array.isArray(e)?e:null}function At(e){return Array.isArray(e)?e:[]}function Ne(e){return typeof e==="string"?e:""}function Qr(e){return Yr[e]??e}function Fi(e,t,n,i){let s=new Map;for(let o of e)s.set(o.provider,o);let r=[];for(let o of dt(t)){let a=Di(o);if(!a)continue;let c=s.get(a.provider),p=Boolean(c&&c.models.some((u)=>u.value!=="")),l=c?.models.find((u)=>u.value===a.model),h=l?l.ok&&(c?.ok??!0):c?.ok??!0,d=l?.why||c?.why||"";if(h&&p&&!l)h=!1,d="not available on this machine";r.push({key:o,provider:a.provider,model:a.model,label:l?.label||a.model,note:l?.note||"",on:a.provider===n&&a.model===i,ok:h,why:d})}return r}function $i(e,t=[]){let n=it(e),i=it(n?.picker)??n??{},s=At(i.sections).map(it).filter((P)=>Boolean(P)),r=(P)=>s.find((K)=>Ne(K.action)===P),o=r("provider"),a=r("model"),c=r("effort"),p=At(o?.choices).map(it).filter((P)=>Boolean(P)),l=At(a?.choices).map(it).filter((P)=>Boolean(P)),h=At(c?.choices).map(it).filter((P)=>Boolean(P)),d=Ne(i.chip),u=Ne(p.find((P)=>P.on===!0)?.value)||d.split("/")[0]?.trim()||"claude",f=Lt(u)||"claude",g=Ne(l.find((P)=>P.on===!0)?.value),v=Ne(h.find((P)=>P.on===!0)?.value),y=h.map((P)=>({value:Ne(P.value),label:Ne(P.label)||"auto",on:P.on===!0})),w=it(i.agents),k=[],A=new Set,N=(P)=>{let K=Lt(P);if(K&&!A.has(K))A.add(K),k.push(K)};for(let P of p)N(Ne(P.value)||Ne(P.label));if(w)for(let P of Object.keys(w))N(P);N(f);let L=k.map((P)=>{let K=p.find((ne)=>Lt(Ne(ne.value)||Ne(ne.label))===P),ae=it(w?.[P]),re=ae?ae.ok!==!1:K?K.ok!==!1:!0,ve=Ne(ae?.why)||Ne(K?.why),Ae=At(ae?.models).map(it).filter((ne)=>Boolean(ne)),ke;if(Ae.length>0)ke=Ae.map((ne)=>{let le=Ne(ne.value),R=Ne(ne.label)||(le===""?"default":le),he=Ne(ne.note);return{value:le,label:R,note:he,on:P===f&&le===g,ok:ne.ok!==!1&&re,why:Ne(ne.why)||ve}});else if(P===f&&l.length>0)ke=l.map((ne)=>{let le=Ne(ne.value),R=Ne(ne.label);return{value:le,label:le===""?"default":le,note:R&&R!==le?R:"",on:ne.on===!0,ok:ne.ok!==!1&&re,why:Ne(ne.why)||ve}});else if(re)ke=[{value:"",label:"default",note:"",on:P===f&&g==="",ok:!0,why:""}];else ke=[];if(P===f&&g&&!ke.some((ne)=>ne.value===g)){let ne=l.find((R)=>Ne(R.value)===g),le=Ne(ne?.label);ke.push({value:g,label:g,note:le&&le!==g?le:"",on:!0,ok:!0,why:""})}return{provider:P,label:Qr(P),ok:re,why:ve,models:ke}}),B=Array.isArray(i.favoriteKeys),T=At(i.favorites).map(it).filter((P)=>Boolean(P)),H=B?dt(i.favoriteKeys):T.length>0?dt(T.map((P)=>Ne(P.key)||yt(Ne(P.provider),Ne(P.model)))):dt(t),F=T.length>0?T.map((P)=>{let K=Lt(Ne(P.provider)),ae=Ne(P.model).trim(),re=yt(K,ae);if(!re)return null;return{key:re,provider:K,model:ae,label:Ne(P.label)||ae,note:Ne(P.note),on:P.on===!0||K===f&&ae===g,ok:P.ok!==!1,why:Ne(P.why)}}).filter((P)=>Boolean(P)):Fi(L,H,f,g);return{chip:d,provider:f,model:g,effort:v,efforts:y,providers:L,favoriteKeys:H,favorites:F}}function _t(e,t){let n=dt(t);return{...e,favoriteKeys:n,favorites:Fi(e.providers,n,e.provider,e.model)}}function Oi(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean),i=(a)=>{if(n.length===0)return!0;let c=a.toLowerCase();return n.every((p)=>c.includes(p))},s=new Set(e.favoriteKeys),r=e.favorites.filter((a)=>i(`${a.provider} ${a.model} ${a.label} ${a.note}`)),o=[];for(let a of e.providers){let c=a.models.filter((p)=>i(`${a.provider} ${a.label} ${p.value} ${p.label} ${p.note}`)).map((p)=>{let l=p.value?yt(a.provider,p.value):"";return{...p,provider:a.provider,starrable:p.value!=="",starred:Boolean(l&&s.has(l))}});if(c.length>0||n.length===0&&!a.ok&&a.why)o.push({provider:a.provider,label:a.label,ok:a.ok,why:a.why,models:c})}return{favorites:r,groups:o,efforts:e.efforts}}var Gi={claude:{viewBox:"0 0 24 24",d:"m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"},codex:{viewBox:"0 0 256 260",d:"M239.184 106.203a64.716 64.716 0 0 0-5.576-53.103C219.452 28.459 191 15.784 163.213 21.74A65.586 65.586 0 0 0 52.096 45.22a64.716 64.716 0 0 0-43.23 31.36c-14.31 24.602-11.061 55.634 8.033 76.74a64.665 64.665 0 0 0 5.525 53.102c14.174 24.65 42.644 37.324 70.446 31.36a64.72 64.72 0 0 0 48.754 21.744c28.481.025 53.714-18.361 62.414-45.481a64.767 64.767 0 0 0 43.229-31.36c14.137-24.558 10.875-55.423-8.083-76.483Zm-97.56 136.338a48.397 48.397 0 0 1-31.105-11.255l1.535-.87l51.67-29.825a8.595 8.595 0 0 0 4.247-7.367v-72.85l21.845 12.636c.218.111.37.32.409.563v60.367c-.056 26.818-21.783 48.545-48.601 48.601Zm-104.466-44.61a48.345 48.345 0 0 1-5.781-32.589l1.534.921l51.722 29.826a8.339 8.339 0 0 0 8.441 0l63.181-36.425v25.221a.87.87 0 0 1-.358.665l-52.335 30.184c-23.257 13.398-52.97 5.431-66.404-17.803ZM23.549 85.38a48.499 48.499 0 0 1 25.58-21.333v61.39a8.288 8.288 0 0 0 4.195 7.316l62.874 36.272l-21.845 12.636a.819.819 0 0 1-.767 0L41.353 151.53c-23.211-13.454-31.171-43.144-17.804-66.405v.256Zm179.466 41.695l-63.08-36.63L161.73 77.86a.819.819 0 0 1 .768 0l52.233 30.184a48.6 48.6 0 0 1-7.316 87.635v-61.391a8.544 8.544 0 0 0-4.4-7.213Zm21.742-32.69l-1.535-.922l-51.619-30.081a8.39 8.39 0 0 0-8.492 0L99.98 99.808V74.587a.716.716 0 0 1 .307-.665l52.233-30.133a48.652 48.652 0 0 1 72.236 50.391v.205ZM88.061 139.097l-21.845-12.585a.87.87 0 0 1-.41-.614V65.685a48.652 48.652 0 0 1 79.757-37.346l-1.535.87l-51.67 29.825a8.595 8.595 0 0 0-4.246 7.367l-.051 72.697Zm11.868-25.58L128.067 97.3l28.188 16.218v32.434l-28.086 16.218l-28.188-16.218l-.052-32.434Z"},grok:{viewBox:"0 0 24 24",d:"M9.497 15.122 L16.811 9.491 C17.169 9.215 17.682 9.323 17.852 9.751 C18.752 12.013 18.35 14.73 16.561 16.596 C14.772 18.462 12.283 18.871 10.007 17.939 L7.522 19.139 C11.087 21.68 15.416 21.052 18.121 18.229 C20.267 15.991 20.931 12.941 20.31 10.19 L20.315 10.196 C19.414 6.155 20.537 4.54 22.837 1.237 C22.891 1.159 22.946 1.08 23 1 L19.974 4.156 L19.974 4.146 L9.495 15.124 M7.987 16.49 C5.429 13.941 5.87 9.996 8.053 7.721 C9.667 6.037 12.313 5.35 14.622 6.361 L17.102 5.166 C16.655 4.829 16.082 4.467 15.425 4.213 C12.455 2.938 8.9 3.573 6.485 6.088 C4.163 8.51 3.433 12.234 4.687 15.411 C5.624 17.786 4.088 19.466 2.541 21.162 C1.993 21.763 1.443 22.364 1 23 L7.985 16.492"},muse:{viewBox:"0 0 24 24",d:"M10.73.032c-1.333 0-2.032 1.016-2.032 2.285 0 2.223 2.127 4.953 4.318 4.953 1.301 0 2-.953 2-2.254 0-2.254-2.095-4.984-4.286-4.984m8.413 2.984c-1.968 0-3.397 2.73-3.397 4.825 0 1.556.794 3.016 2.254 3.016 2 0 3.365-2.762 3.365-4.794 0-1.523-.762-3.047-2.222-3.047M4.857 4.159c-1.968 0-3.778 1.016-3.778 2.54 0 1.65 2.16 2.793 4.254 2.793 1.873 0 3.778-.92 3.778-2.508 0-1.682-2.159-2.825-4.254-2.825m-.222 6.476C2.413 10.635 0 13.175 0 15.397c0 1.301.825 2.159 2.095 2.159 2.19 0 4.603-2.508 4.603-4.794 0-1.27-.761-2.127-2.063-2.127m16.667.698c-2.223 0-5.016 1.62-5.016 3.651 0 1.238 1.047 2.19 2.698 2.19 2.159 0 5.016-1.587 5.016-3.682 0-1.302-1.08-2.159-2.698-2.159M7.619 16c-1.524 0-2.38 1.746-2.38 3.429 0 2.063 1.269 4.54 3.047 4.54 1.524 0 2.38-1.81 2.38-3.461C10.667 18.57 9.46 16 7.62 16m6.571 1.016c-1.333 0-2.476.667-2.476 2.032 0 2.095 2.667 4.063 4.92 4.063 1.366 0 2.54-.73 2.54-2.063 0-2.032-2.698-4.032-4.984-4.032"},antigravity:{viewBox:"0 0 24 24",d:"M20.197 20.618 C21.318 21.459 23 20.898 21.459 19.357 C16.834 14.873 17.815 2.541 12.07 2.541 C6.325 2.541 7.306 14.873 2.682 19.357 C1 21.038 2.822 21.459 3.943 20.618 C8.287 17.675 8.006 12.49 12.07 12.49 C16.134 12.49 15.853 17.675 20.197 20.618 Z"},opencode:{viewBox:"0 0 24 24",d:"M22 24H2V0h20zM17 4.8H7v14.4h10z"},pi:{viewBox:"0 0 24 24",d:"M0 0v24h6v-6h6v-6H6V6h6v6h6V0Zm18 12v12h6V12Z"},omp:{viewBox:"0 0 24 24",d:"M1.44 3.86 L22.56 3.86 C23 3.86 23 3.86 23 4.3 L23 6.06 C23 6.5 23 6.5 22.56 6.5 L1.44 6.5 C1 6.5 1 6.5 1 6.06 L1 4.3 C1 3.86 1 3.86 1.44 3.86 Z M4.74 6.5 L6.5 6.5 C6.94 6.5 6.94 6.5 6.94 6.94 L6.94 19.7 C6.94 20.14 6.94 20.14 6.5 20.14 L4.74 20.14 C4.3 20.14 4.3 20.14 4.3 19.7 L4.3 6.94 C4.3 6.5 4.3 6.5 4.74 6.5 Z M15.74 6.5 L17.5 6.5 C17.94 6.5 17.94 6.5 17.94 6.94 L17.94 13.32 C17.94 13.76 17.94 13.76 17.5 13.76 L15.74 13.76 C15.3 13.76 15.3 13.76 15.3 13.32 L15.3 6.94 C15.3 6.5 15.3 6.5 15.74 6.5 Z M15.08 14.64 L18.16 14.64 C18.82 14.64 18.82 14.64 18.82 15.3 L18.82 17.5 C18.82 18.16 18.82 18.16 18.16 18.16 L15.08 18.16 C14.42 18.16 14.42 18.16 14.42 17.5 L14.42 15.3 C14.42 14.64 14.42 14.64 15.08 14.64 Z"}};var Nt="http://www.w3.org/2000/svg",Vi=4,Ui=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function an(e){let t=document.createElementNS(Nt,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","15"),t.setAttribute("height","15"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("aria-hidden","true");for(let n of e){let i=document.createElementNS(Nt,"path");i.setAttribute("d",n),t.appendChild(i)}return t}function Tn(){return an(["M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z","M14 2v6h6","M16 13H8","M16 17H8","M10 9H8"])}function Wi(){return an(["M6 4l14 8-14 8z"])}function _i(e){let t=document.createElementNS(Nt,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","13"),t.setAttribute("height","13"),t.setAttribute("fill",e?"currentColor":"none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");let n=document.createElementNS(Nt,"path");return n.setAttribute("d","M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5-4.8-4.6 6.6-.9z"),t.appendChild(n),t}function zi(e){let t=(e||"").toLowerCase();if(t.includes("claude")||t.includes("anthropic"))return{mark:"claude",glyph:"A",color:"#d97757",title:"Claude"};if(t.includes("codex")||t.includes("openai"))return{mark:"codex",glyph:"O",color:"#10a37f",title:"Codex"};if(t.includes("gemini")||t.includes("antigravity")||t==="agy")return{mark:"antigravity",glyph:"G",color:"#4285f4",title:"Antigravity"};if(t.includes("grok"))return{mark:"grok",glyph:"X",color:"#6b7280",title:"Grok"};if(t.includes("muse"))return{mark:"muse",glyph:"M",color:"#8b5cf6",title:"Muse"};if(t.includes("opencode"))return{mark:"opencode",glyph:"C",color:"#2563eb",title:"OpenCode"};if(t.includes("omp")||t.includes("oh-my-pi"))return{mark:"omp",glyph:"Ω",color:"#c026d3",title:"Oh My Pi"};if(t==="pi"||t.startsWith("pi/")||t.startsWith("@pi"))return{mark:"pi",glyph:"π",color:"#db2777",title:"Pi"};return{glyph:"●",color:"var(--accent)",title:e||"Model"}}function qi(e){let t=Gi[e];if(!t||!t.d)return null;let n=document.createElementNS(Nt,"svg");n.setAttribute("viewBox",t.viewBox||"0 0 24 24"),n.setAttribute("width","14"),n.setAttribute("height","14"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");let i=document.createElementNS(Nt,"path");return i.setAttribute("d",t.d),n.appendChild(i),n}class In{popupEl;attachStripEl;planBarEl;fileInput;textarea;memoryEl;memoryFill;memoryText;modelBtn;providerMarkEl;modelTextEl;ctxEl;modelPickerEl;modelSearchInput;modelPickerBodyEl;modelPickerEffortsEl;modelPickerOpen=!1;modelPickerLoading=!1;modelPickerSnap=null;modelPickerQuery="";modelPickerFocusIdx=-1;onDocMouseDown;planChipBtn;planChipIconHost;planChipLbl;attachBtn;voiceBtn;sendBtn;stopBtn;errorEl;replyEl;cb;commands=[];popupMode="none";filteredSlash=[];mentionItems=[];popupIdx=0;enabled=!1;attachments=[];planMode=null;constructor(e,t){this.cb=t;let n=document.createElement("div");n.className="bp-composer",n.setAttribute("data-testid","composer");let i=document.createElement("div");i.className="bp-composer-inner",this.popupEl=document.createElement("div"),this.popupEl.className="bp-composer-popup bp-hidden",this.popupEl.setAttribute("data-testid","slash-menu"),this.errorEl=document.createElement("div"),this.errorEl.className="bp-composer-err bp-hidden",this.replyEl=document.createElement("div"),this.replyEl.className="bp-reply-strip bp-hidden",this.replyEl.setAttribute("data-testid","composer-reply"),this.attachStripEl=document.createElement("div"),this.attachStripEl.className="bp-attach-strip bp-hidden",this.attachStripEl.setAttribute("data-testid","composer-attachments"),this.planBarEl=document.createElement("div"),this.planBarEl.className="bp-plan-bar bp-hidden",this.planBarEl.setAttribute("data-testid","composer-plan-bar"),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="image/png,image/jpeg,image/webp,image/gif",this.fileInput.multiple=!0,this.fileInput.className="bp-hidden",this.fileInput.setAttribute("data-testid","composer-file-input"),this.fileInput.addEventListener("change",()=>{if(this.fileInput.files)this.addFiles(Array.from(this.fileInput.files));this.fileInput.value=""}),this.textarea=document.createElement("textarea"),this.textarea.className="bp-composer-input",this.textarea.rows=2,this.textarea.placeholder=m("composer.placeholder","Ask anything: @bot, >thread, %project, #room, $skill, /btw"),this.textarea.setAttribute("data-testid","composer-input");let s=document.createElement("div");s.className="bp-composer-bar";let r=document.createElement("button");r.type="button",r.className="bp-composer-model",r.setAttribute("data-testid","composer-model-chip"),r.setAttribute("aria-haspopup","dialog"),r.setAttribute("aria-expanded","false"),r.title=m("composer.model.tip","Choose the model and effort"),this.modelBtn=r,this.providerMarkEl=document.createElement("span"),this.providerMarkEl.className="bp-provider-mark",this.providerMarkEl.textContent="●",this.modelTextEl=document.createElement("span"),this.modelTextEl.className="bp-model-text",this.modelTextEl.textContent="default",this.ctxEl=document.createElement("span"),this.ctxEl.className="bp-ctx-pct bp-hidden",this.ctxEl.setAttribute("data-testid","composer-ctx");let o=document.createElement("span");o.className="bp-model-caret",o.textContent="▾",r.append(this.providerMarkEl,this.modelTextEl,this.ctxEl,o),r.addEventListener("click",()=>{this.toggleModelPicker()}),this.modelPickerEl=document.createElement("div"),this.modelPickerEl.className="bp-model-picker bp-hidden",this.modelPickerEl.setAttribute("data-testid","model-picker"),this.modelPickerEl.setAttribute("role","dialog");let a=document.createElement("div");a.className="bp-mp-search-wrap",this.modelSearchInput=document.createElement("input"),this.modelSearchInput.type="search",this.modelSearchInput.className="bp-mp-search",this.modelSearchInput.placeholder=m("gpui.search.models","Search models"),this.modelSearchInput.setAttribute("data-testid","model-picker-search"),this.modelSearchInput.addEventListener("input",()=>{this.modelPickerQuery=this.modelSearchInput.value,this.modelPickerFocusIdx=-1,this.renderModelPicker()}),this.modelSearchInput.addEventListener("keydown",(l)=>{if(l.key==="Escape"){l.preventDefault(),l.stopPropagation(),this.closeModelPicker(),this.textarea.focus();return}if(l.key==="ArrowDown"||l.key==="ArrowUp"){let h=this.modelPickerFocusableButtons();if(h.length===0)return;l.preventDefault();let d=l.key==="ArrowDown"?1:-1;this.modelPickerFocusIdx=this.modelPickerFocusIdx<0?d>0?0:h.length-1:(this.modelPickerFocusIdx+d+h.length)%h.length,this.updateModelPickerKbdFocus(h);return}if(l.key==="Enter"){let h=this.modelPickerFocusableButtons(),d=this.modelPickerFocusIdx>=0&&this.modelPickerFocusIdxthis.cb.onCyclePlanMode?.()),this.memoryEl=document.createElement("div"),this.memoryEl.className="bp-composer-memory bp-hidden",this.memoryEl.setAttribute("data-testid","composer-memory");let c=document.createElement("div");c.className="bp-memory-meter",this.memoryFill=document.createElement("div"),this.memoryFill.className="bp-memory-fill",c.appendChild(this.memoryFill),this.memoryText=document.createElement("span"),this.memoryEl.append(c,this.memoryText);let p=document.createElement("div");p.className="bp-composer-btns",this.attachBtn=document.createElement("button"),this.attachBtn.type="button",this.attachBtn.className="icon bp-composer-tool",this.attachBtn.title=m("web.composer.attach","Attach image"),this.attachBtn.setAttribute("aria-label",m("web.composer.attach","Attach image")),this.attachBtn.setAttribute("data-testid","composer-attach"),this.attachBtn.appendChild(an(["M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"])),this.attachBtn.addEventListener("click",()=>this.fileInput.click()),this.voiceBtn=document.createElement("button"),this.voiceBtn.type="button",this.voiceBtn.className="icon bp-composer-tool",this.voiceBtn.title=m("web.composer.voice","Voice dictation"),this.voiceBtn.setAttribute("aria-label",m("web.composer.voice","Voice dictation")),this.voiceBtn.setAttribute("data-testid","composer-voice"),this.voiceBtn.appendChild(an(["M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z","M19 10v2a7 7 0 0 1-14 0v-2","M12 19v4","M8 23h8"])),this.voiceBtn.addEventListener("click",()=>this.cb.onToggleVoice?.()),this.stopBtn=document.createElement("button"),this.stopBtn.type="button",this.stopBtn.className="primary stop bp-hidden",this.stopBtn.textContent=m("composer.stop","Stop"),this.stopBtn.setAttribute("data-testid","composer-stop"),this.stopBtn.addEventListener("click",()=>this.cb.onInterrupt()),this.sendBtn=document.createElement("button"),this.sendBtn.type="button",this.sendBtn.className="primary bp-send-btn",this.sendBtn.textContent=m("composer.send","Send"),this.sendBtn.setAttribute("data-testid","composer-send"),this.sendBtn.addEventListener("click",()=>this.submit()),p.append(this.attachBtn,this.voiceBtn,this.stopBtn,this.sendBtn),s.append(r,this.planChipBtn,this.memoryEl,p),i.append(this.modelPickerEl,this.popupEl,this.errorEl,this.replyEl,this.attachStripEl,this.planBarEl,this.fileInput,this.textarea,s),n.appendChild(i),e.appendChild(n),this.onDocMouseDown=(l)=>{if(!this.modelPickerEl.isConnected){document.removeEventListener("mousedown",this.onDocMouseDown);return}if(!this.modelPickerOpen)return;let h=l.target;if(h&&(this.modelPickerEl.contains(h)||this.modelBtn.contains(h)))return;this.closeModelPicker()},document.addEventListener("mousedown",this.onDocMouseDown),this.textarea.addEventListener("paste",(l)=>{let h=l.clipboardData?.items;if(!h)return;let d=[];for(let u=0;u0)l.preventDefault(),this.addFiles(d)}),this.textarea.addEventListener("input",()=>{this.autoGrow(),this.clearError(),this.updatePopups()}),this.textarea.addEventListener("keydown",(l)=>{if(this.popupMode!=="none"){let h=this.popupMode==="slash"?this.filteredSlash.length:this.mentionItems.length;if(l.key==="ArrowDown"){l.preventDefault(),this.popupIdx=(this.popupIdx+1)%Math.max(1,h),this.renderPopup();return}if(l.key==="ArrowUp"){l.preventDefault(),this.popupIdx=(this.popupIdx-1+Math.max(1,h))%Math.max(1,h),this.renderPopup();return}if(l.key==="Tab"||l.key==="Enter"&&!l.shiftKey&&this.shouldCompleteOnEnter()){l.preventDefault(),this.applyPopupChoice(this.popupIdx);return}if(l.key==="Escape"){l.preventDefault(),this.closePopup();return}}if(l.key==="Tab"&&l.shiftKey&&this.planMode!==null){l.preventDefault(),this.cb.onCyclePlanMode?.();return}if(l.key==="Enter"&&!l.shiftKey)l.preventDefault(),this.submit()})}setCommands(e){this.commands=e.map((t)=>({...t,word:t.word.replace(/^\//,"")}))}setModelChip(e,t,n){let i=zi(t),s=i.mark?qi(i.mark):null;if(s)this.providerMarkEl.replaceChildren(s);else this.providerMarkEl.textContent=i.glyph;if(this.providerMarkEl.style.color=i.color,this.providerMarkEl.title=i.title,this.modelTextEl.textContent=e||"default",typeof n==="number"&&Number.isFinite(n)&&n>=0)this.ctxEl.textContent=`ctx ${Math.round(n)}%`,this.ctxEl.classList.remove("bp-hidden");else this.ctxEl.textContent="",this.ctxEl.classList.add("bp-hidden")}setFeatures(e,t){this.attachBtn.classList.toggle("bp-hidden",!e),this.voiceBtn.classList.toggle("bp-hidden",!t)}setVoiceRecording(e){this.voiceBtn.classList.toggle("recording",e),this.voiceBtn.setAttribute("aria-pressed",e?"true":"false")}setVoiceLevel(e){this.voiceBtn.setAttribute("data-level",String(e))}getDraft(){return this.textarea.value}getCaret(){return this.textarea.selectionStart??this.textarea.value.length}setMemory(e){if(this.memoryEl.classList.toggle("bp-hidden",!e),!e)return;let t=e.total??0,n=t>0?Math.min(1,(e.done??0)/t):1;this.memoryFill.style.width=`${Math.round(n*100)}%`,this.memoryFill.dataset.state=e.state??"",this.memoryText.textContent=e.line??"",this.memoryEl.title=[e.status,e.lines,e.viewLine].filter(Boolean).join(` +`)}setPlanMode(e){if(this.planMode=e,this.textarea.classList.remove("is-plan","is-plan-exec"),this.sendBtn.classList.remove("is-plan","is-plan-exec"),this.planChipBtn.classList.remove("is-plan","is-exec"),this.planBarEl.classList.remove("is-exec"),!e){this.planChipBtn.classList.add("bp-hidden"),this.planChipBtn.setAttribute("aria-pressed","false"),this.planBarEl.classList.add("bp-hidden"),this.planBarEl.replaceChildren(),this.sendBtn.textContent=m("composer.send","Send");return}let t=e.phase,n=t!=="off",i=t==="armed"||t==="planning"||t==="pending",s=t==="executing";this.planChipBtn.classList.remove("bp-hidden"),this.planChipBtn.classList.toggle("is-plan",i),this.planChipBtn.classList.toggle("is-exec",s),this.planChipBtn.setAttribute("aria-pressed",n?"true":"false");let r=`${m("gpui.planmode.tip","Plan before acting (1 turn, always, or off)")} · Shift+Tab`;if(this.planChipBtn.title=r,this.planChipBtn.setAttribute("aria-label",r),this.planChipIconHost.replaceChildren(s?Wi():Tn()),this.planChipLbl.textContent=s?m("gpui.planmode.chip.building","Building"):t==="pending"?m("gpui.mgmt.fab.reviewbtn","Review"):i&&e.once?m("gpui.planmode.chip.once","Plan · 1t"):m("gpui.mgmt.plan.tab","Plan"),this.textarea.classList.toggle("is-plan",i),this.textarea.classList.toggle("is-plan-exec",s),this.sendBtn.classList.toggle("is-plan",i),this.sendBtn.classList.toggle("is-plan-exec",s),this.sendBtn.textContent=i?m("gpui.mgmt.plan.tab","Plan"):m("composer.send","Send"),!n){this.planBarEl.classList.add("bp-hidden"),this.planBarEl.replaceChildren();return}this.planBarEl.classList.remove("bp-hidden"),this.planBarEl.classList.toggle("is-exec",s);let o=document.createElement("span");o.className="bp-plan-bar-ic",o.appendChild(s?Wi():Tn());let a=document.createElement("span");a.className="bp-plan-bar-text",a.textContent=t==="armed"&&e.once?m("gpui.planmode.bar.once","Plan mode (1 turn) — explores and proposes a plan before editing"):t==="armed"?m("gpui.planmode.bar.always","Plan mode — explores and proposes a plan before editing"):t==="planning"?m("gpui.planmode.bar.planning","Planning — drafting a plan before edits"):t==="pending"?m("gpui.planmode.bar.pending","Proposed plan awaits review below"):m("gpui.planmode.bar.executing","Building the approved plan");let c=[o,a];if(t==="armed"||t==="planning"){let p=document.createElement("div");p.className="bp-plan-scopes";let l=(h,d,u,f)=>{let g=document.createElement("button");return g.type="button",g.className="bp-plan-scope-btn"+(d?" active":""),g.textContent=h,g.disabled=!this.enabled,g.setAttribute("data-testid",f),g.addEventListener("click",()=>this.cb.onSetPlanMode?.(u)),g};p.append(l(m("gpui.planmode.scope.once","1 turn"),e.once,"once","plan-scope-once"),l(m("gpui.planmode.scope.always","Always"),!e.once,"always","plan-scope-always"),l(m("gpui.bots.recall.off","Off"),!1,"off","plan-scope-off")),c.push(p)}this.planBarEl.replaceChildren(...c)}setState(e,t){if(this.enabled=e,this.textarea.disabled=!e,this.sendBtn.disabled=!e,this.attachBtn.disabled=!e,this.voiceBtn.disabled=!e,this.modelBtn.disabled=!e,!e)this.closeModelPicker();this.planChipBtn.disabled=!e,this.planBarEl.querySelectorAll(".bp-plan-scope-btn").forEach((n)=>{n.disabled=!e}),this.stopBtn.classList.toggle("bp-hidden",!t)}destroy(){document.removeEventListener("mousedown",this.onDocMouseDown)}isModelPickerOpen(){return this.modelPickerOpen}closeModelPicker(){if(!this.modelPickerOpen)return;this.modelPickerOpen=!1,this.modelPickerFocusIdx=-1,this.modelPickerEl.classList.add("bp-hidden"),this.modelBtn.classList.remove("is-open"),this.modelBtn.setAttribute("aria-expanded","false")}modelPickerFocusableButtons(){return Array.from(this.modelPickerBodyEl.querySelectorAll(".bp-mp-row-main:not(:disabled)"))}updateModelPickerKbdFocus(e){e.forEach((t,n)=>{let i=n===this.modelPickerFocusIdx;if(t.classList.toggle("is-kbd",i),i)t.scrollIntoView({block:"nearest"})})}updateFavoriteModels(e){if(!this.modelPickerSnap)return;if(this.modelPickerSnap=_t(this.modelPickerSnap,e),this.modelPickerOpen)this.renderModelPicker()}async toggleModelPicker(){if(!this.enabled)return;if(this.modelPickerOpen){this.closeModelPicker();return}this.closePopup(),this.modelPickerOpen=!0,this.modelPickerQuery="",this.modelPickerFocusIdx=-1,this.modelSearchInput.value="",this.modelPickerEl.classList.remove("bp-hidden"),this.modelBtn.classList.add("is-open"),this.modelBtn.setAttribute("aria-expanded","true"),this.modelPickerLoading=!0,this.renderModelPicker(),this.modelSearchInput.focus(),await this.reloadModelPicker()}async reloadModelPicker(){if(!this.cb.onLoadModelPicker){this.modelPickerLoading=!1,this.renderModelPicker();return}try{let e=await this.cb.onLoadModelPicker();if(!this.modelPickerOpen)return;this.modelPickerSnap=$i(e,this.cb.getFavoriteModels?.()??[])}catch{}finally{if(this.modelPickerLoading=!1,this.modelPickerOpen)this.renderModelPicker()}}async toggleFavoriteInPicker(e,t){if(!this.modelPickerSnap)return;let n=this.modelPickerSnap,i=yt(e,t);if(!i)return;let s=n.favoriteKeys.includes(i),r=Mn(n.favoriteKeys,e,t);if(r.keys.length===n.favoriteKeys.length&&r.starred===s)return;if(this.modelPickerSnap=_t(n,r.keys),this.renderModelPicker(),!this.cb.onToggleFavorite)return;try{let o=await this.cb.onToggleFavorite(e,t,r.starred);if(Array.isArray(o)&&this.modelPickerSnap){if(this.modelPickerSnap=_t(this.modelPickerSnap,dt(o)),this.modelPickerOpen)this.renderModelPicker()}}catch(o){if(this.modelPickerSnap){let a=this.cb.getFavoriteModels?.(),c=Array.isArray(a)?dt(a):Mn(this.modelPickerSnap.favoriteKeys,e,t,!r.starred).keys;if(this.modelPickerSnap=_t(this.modelPickerSnap,c),this.modelPickerOpen)this.renderModelPicker()}this.showError(o instanceof Error&&o.message?o.message:"Could not update favorite model")}}renderProviderGlyph(e){let t=zi(e),n=document.createElement("span");n.className="bp-mp-mark",n.style.color=t.color,n.title=t.title;let i=t.mark?qi(t.mark):null;if(i)n.appendChild(i);else n.textContent=t.glyph;return n}makeStarButton(e,t,n,i="model-star"){let s=document.createElement("button");s.type="button",s.className="bp-mp-star"+(n?" is-starred":"");let r=n?m("gpui.picker.favorite.remove","Remove from favorites"):m("gpui.picker.favorite.add","Add to favorites");return s.title=r,s.setAttribute("aria-label",r),s.setAttribute("aria-pressed",n?"true":"false"),s.setAttribute("data-testid",`${i}-${e}-${t}`),s.appendChild(_i(n)),s.addEventListener("click",(o)=>{o.preventDefault(),o.stopPropagation(),this.toggleFavoriteInPicker(e,t)}),s}renderModelPicker(){if(!this.modelPickerOpen)return;if(this.modelPickerFocusIdx=-1,!this.modelPickerSnap){let i=document.createElement("div");i.className="bp-mp-empty",i.textContent=this.modelPickerLoading?"…":m("gpui.no.models","No models"),this.modelPickerBodyEl.replaceChildren(i),this.modelPickerEffortsEl.classList.add("bp-hidden"),this.modelPickerEffortsEl.replaceChildren();return}let e=Oi(this.modelPickerSnap,this.modelPickerQuery),t=document.createDocumentFragment();if(e.favorites.length>0){let i=document.createElement("div");i.className="bp-mp-section bp-mp-favorites",i.setAttribute("data-testid","model-picker-favorites");let s=document.createElement("div");s.className="bp-mp-head";let r=document.createElement("span");r.className="bp-mp-head-star",r.appendChild(_i(!0));let o=document.createElement("span");o.textContent=m("gpui.picker.favorites","Favorites"),s.append(r,o),i.appendChild(s);for(let a of e.favorites){let c=document.createElement("div");c.className="bp-mp-row"+(a.on?" is-active":"")+(!a.ok?" is-disabled":""),c.setAttribute("data-testid",`model-fav-row-${a.provider}-${a.model}`);let p=document.createElement("button");if(p.type="button",p.className="bp-mp-row-main",p.disabled=!a.ok,!a.ok&&a.why)p.title=a.why;let l=document.createElement("span");l.className="bp-mp-check",l.textContent=a.on?"✓":"";let h=document.createElement("span");h.className="bp-mp-name",h.textContent=a.label;let d=document.createElement("span");d.className="bp-mp-note",d.textContent=!a.ok&&a.why?fe(a.why):a.note&&a.note!==a.label?fe(a.note):a.provider,p.append(l,this.renderProviderGlyph(a.provider),h,d),p.addEventListener("click",()=>{if(!a.ok)return;this.closeModelPicker(),this.textarea.focus(),this.cb.onSelectModel?.(a.provider,a.model)}),c.append(p,this.makeStarButton(a.provider,a.model,!0,"model-fav-star")),i.appendChild(c)}t.appendChild(i)}let n=document.createElement("div");if(n.className="bp-mp-groups",n.setAttribute("data-testid","model-picker-groups"),e.groups.length===0){let i=document.createElement("div");i.className="bp-mp-empty",i.textContent=this.modelPickerQuery.trim()?m("gpui.nothing.matches","Nothing matches"):m("gpui.no.models","No models"),n.appendChild(i)}else for(let i of e.groups){let s=document.createElement("div");s.className="bp-mp-group";let r=document.createElement("div");r.className="bp-mp-group-head";let o=document.createElement("span");if(o.className="bp-mp-group-title",o.textContent=i.label,r.append(this.renderProviderGlyph(i.provider),o),!i.ok&&i.why){let a=document.createElement("span");a.className="bp-mp-group-why",a.textContent=fe(i.why),r.appendChild(a)}s.appendChild(r);for(let a of i.models){let c=document.createElement("div");c.className="bp-mp-row"+(a.on?" is-active":"")+(!a.ok?" is-disabled":""),c.setAttribute("data-testid",`model-row-${i.provider}-${a.value||"default"}`);let p=document.createElement("button");if(p.type="button",p.className="bp-mp-row-main",p.disabled=!a.ok,!a.ok&&a.why)p.title=a.why;let l=document.createElement("span");l.className="bp-mp-check",l.textContent=a.on?"✓":"";let h=document.createElement("span");h.className="bp-mp-name",h.textContent=a.label;let d=document.createElement("span");if(d.className="bp-mp-note",d.textContent=a.note&&a.note!==a.label?fe(a.note):"",p.append(l,h,d),p.addEventListener("click",()=>{if(!a.ok)return;this.closeModelPicker(),this.textarea.focus(),this.cb.onSelectModel?.(i.provider,a.value)}),c.appendChild(p),a.starrable)c.appendChild(this.makeStarButton(i.provider,a.value,a.starred));s.appendChild(c)}n.appendChild(s)}if(t.appendChild(n),this.modelPickerBodyEl.replaceChildren(t),e.efforts.length>0){let i=document.createDocumentFragment(),s=document.createElement("span");s.className="bp-mp-efforts-lbl",s.textContent=m("model.col.effort","Effort"),i.appendChild(s);for(let r of e.efforts){let o=document.createElement("button");o.type="button",o.className="bp-mp-effort"+(r.on?" active":""),o.textContent=r.label,o.addEventListener("click",()=>{Promise.resolve(this.cb.onSelectEffort?.(r.value)).then(()=>{if(this.modelPickerOpen)this.reloadModelPicker()})}),i.appendChild(o)}this.modelPickerEffortsEl.replaceChildren(i),this.modelPickerEffortsEl.classList.remove("bp-hidden")}else this.modelPickerEffortsEl.classList.add("bp-hidden"),this.modelPickerEffortsEl.replaceChildren()}setDraft(e){this.textarea.value=e,this.autoGrow(),this.textarea.focus()}setReply(e,t,n){if(!e){this.replyEl.replaceChildren(),this.replyEl.classList.add("bp-hidden");return}let i=document.createElement("button");i.type="button",i.className="bp-reply-strip-body",i.setAttribute("data-testid","composer-reply-go");let s=document.createElement("span");s.className="bp-reply-strip-who",s.textContent=e.who;let r=document.createElement("span");if(r.className="bp-reply-strip-line",r.textContent=m("gpui.b.replying.to","↩ Replying to: {line}",{line:e.line}),i.append(s,r),t)i.addEventListener("click",t);let o=document.createElement("button");o.type="button",o.className="icon bp-reply-strip-drop",o.textContent="×";let a=m("reply.cancel","Cancel reply");if(o.title=a,o.setAttribute("aria-label",a),o.setAttribute("data-testid","composer-reply-drop"),n)o.addEventListener("click",n);this.replyEl.replaceChildren(i,o),this.replyEl.classList.remove("bp-hidden"),this.textarea.focus()}prependDraft(e){let t=this.textarea.value;this.textarea.value=t?`${e} +${t}`:e,this.autoGrow(),this.textarea.focus()}showError(e,t){let n=document.createElement("span");if(n.textContent=fe(e),t){let i=document.createElement("button");i.type="button",i.className="bp-composer-err-act",i.setAttribute("data-testid","composer-err-accounts"),i.textContent=t.label,i.addEventListener("click",t.onClick),this.errorEl.replaceChildren(n,i)}else this.errorEl.replaceChildren(n);this.errorEl.classList.remove("bp-hidden")}clearError(){this.errorEl.replaceChildren(),this.errorEl.classList.add("bp-hidden")}focus(){this.textarea.focus()}refreshLocale(){if(this.textarea.placeholder=m("composer.placeholder","Ask anything: @bot, >thread, %project, #room, $skill, /btw"),this.attachBtn.title=m("web.composer.attach","Attach image"),this.attachBtn.setAttribute("aria-label",m("web.composer.attach","Attach image")),this.voiceBtn.title=m("web.composer.voice","Voice dictation"),this.voiceBtn.setAttribute("aria-label",m("web.composer.voice","Voice dictation")),this.modelBtn.title=m("composer.model.tip","Choose the model and effort"),this.modelSearchInput.placeholder=m("gpui.search.models","Search models"),this.sendBtn.textContent=m("composer.send","Send"),this.stopBtn.textContent=m("composer.stop","Stop"),this.setPlanMode(this.planMode),this.modelPickerOpen)this.renderModelPicker()}autoGrow(){this.textarea.style.height="auto",this.textarea.style.height=`${Math.min(180,Math.max(54,this.textarea.scrollHeight))}px`}shouldCompleteOnEnter(){if(this.popupMode==="mention")return!0;if(this.popupMode==="slash"){let e=this.textarea.value;return e.startsWith("/")&&!e.includes(" ")}return!1}updatePopups(){let e=this.textarea.value;if(e.startsWith("/")&&!e.includes(" ")&&!e.includes(` +`)){let n=e.slice(1).toLowerCase();if(this.filteredSlash=this.commands.filter((i)=>i.word.toLowerCase().startsWith(n)),this.filteredSlash.length>0){this.popupMode="slash",this.popupIdx=Math.min(this.popupIdx,this.filteredSlash.length-1),this.renderPopup();return}}let t=/(?:^|\s)([@>%#])([a-zA-Z0-9._-]{1,32})$/.exec(e.slice(0,this.textarea.selectionStart));if(t){let n=t[1],i=t[2];this.cb.onQueryMentions(i,n).then((s)=>{if(s.length>0)this.mentionItems=s,this.popupMode="mention",this.popupIdx=0,this.renderPopup();else if(this.popupMode==="mention")this.closePopup()});return}this.closePopup()}closePopup(){this.popupMode="none",this.popupEl.classList.add("bp-hidden"),this.popupEl.replaceChildren()}renderPopup(){let e=document.createDocumentFragment();if(this.popupMode==="slash")this.filteredSlash.forEach((t,n)=>{let i=document.createElement("button");i.type="button",i.className="bp-popup-row"+(n===this.popupIdx?" active":""),i.setAttribute("data-testid",`slash-item-${t.word}`);let s=document.createElement("span");s.className="bp-popup-name",s.textContent=`/${t.word}`;let r=document.createElement("span");r.className="bp-popup-desc",r.textContent=t.desc||t.label,i.append(s,r),i.addEventListener("mousedown",(o)=>{o.preventDefault(),this.applyPopupChoice(n)}),e.appendChild(i)});else if(this.popupMode==="mention")this.mentionItems.forEach((t,n)=>{let i=document.createElement("button");i.type="button",i.className="bp-popup-row"+(n===this.popupIdx?" active":"");let s=document.createElement("span");s.className="bp-popup-name",s.textContent=t.word||`${t.sigil}${t.label}`;let r=document.createElement("span");r.className="bp-popup-desc",r.textContent=t.detail||t.label,i.append(s,r),i.addEventListener("mousedown",(o)=>{o.preventDefault(),this.applyPopupChoice(n)}),e.appendChild(i)});this.popupEl.replaceChildren(e),this.popupEl.classList.remove("bp-hidden")}applyPopupChoice(e){if(this.popupMode==="slash"){let t=this.filteredSlash[e];if(t)this.textarea.value=`/${t.word} `,this.autoGrow(),this.textarea.focus();this.closePopup()}else if(this.popupMode==="mention"){let t=this.mentionItems[e];if(t){let n=this.textarea.selectionStart,i=this.textarea.value.slice(0,n),s=this.textarea.value.slice(n),r=i.replace(/([@>%#][a-zA-Z0-9._-]{1,32})$/,`${t.word} `);this.textarea.value=r+s,this.textarea.selectionStart=this.textarea.selectionEnd=r.length,this.textarea.focus()}this.closePopup()}}async addFiles(e){this.clearError();for(let t of e){if(!Ui.has(t.type)){this.showError(m("web.composer.unsupported","Unsupported image type: {type}",{type:t.type||t.name}));continue}if(this.attachments.length>=Vi){this.showError(m("web.composer.maximages","At most {max} images per message.",{max:Vi}));break}let n=await new Promise((s,r)=>{let o=new FileReader;o.onload=()=>s(String(o.result||"")),o.onerror=()=>r(Error("read failed")),o.readAsDataURL(t)}).catch(()=>""),i=n.indexOf(",");if(i<0)continue;this.attachments.push({name:t.name||`image-${this.attachments.length+1}.png`,mime:t.type,data:n.slice(i+1),previewUrl:n})}this.renderAttachments()}renderAttachments(){if(this.attachments.length===0){this.attachStripEl.classList.add("bp-hidden"),this.attachStripEl.replaceChildren();return}let e=document.createDocumentFragment();this.attachments.forEach((t,n)=>{let i=document.createElement("div");i.className="bp-attach-chip";let s=document.createElement("img");s.src=t.previewUrl,s.alt=t.name,s.className="bp-attach-thumb";let r=document.createElement("button");r.type="button",r.className="icon bp-attach-rm",r.textContent="×",r.title=m("common.remove","Remove"),r.addEventListener("click",()=>{this.attachments.splice(n,1),this.renderAttachments()}),i.append(s,r),e.appendChild(i)}),this.attachStripEl.replaceChildren(e),this.attachStripEl.classList.remove("bp-hidden")}submit(){if(!this.enabled)return;let e=this.textarea.value.trim();if(!e&&this.attachments.length===0)return;if(this.closePopup(),this.clearError(),e.startsWith("/")&&this.attachments.length===0){let n=e.slice(1).split(/\s+/)[0]?.toLowerCase()??"";if(this.commands.some((i)=>i.word.toLowerCase()===n)){this.textarea.value="",this.autoGrow(),this.cb.onRunCommand(e);return}}let t=this.attachments.map(({name:n,mime:i,data:s})=>({name:n,mime:i,data:s}));this.attachments=[],this.renderAttachments(),this.textarea.value="",this.autoGrow(),this.cb.onSend(e,t)}}async function Ki(e,t=fetch){let n=await t("/auth/web/logout",{method:"POST",credentials:"same-origin",redirect:"error",headers:{"Content-Type":"application/json"},body:"{}"});if(n.status!==200||(await n.json()).state!=="revoked")throw Error("Logout was not confirmed");e()}var Zr=new Set(["bom","checks","life","plan","fab"]);function ln(e){if(!e||!Array.isArray(e.panels))return[];return e.panels.filter((t)=>t&&typeof t.id==="string"&&Zr.has(t.id))}function es(e){let t=e?.badge?.n??0;if(!Number.isFinite(t)||t<=0)return null;return{text:t>99?"99+":String(Math.floor(t)),tone:e?.badge?.tone==="bad"?"bad":"warn"}}function cn(e,t=22){let n=e.join(", ");if(n.length<=t)return n;let i="";for(let s=0;s0?` +${a}`.length:0)>t)return i?`${i} +${e.length-s}`:`${e[0]} +${e.length-1}`;i=o}return i}function Mt(e){if(!Number.isFinite(e)||e<0)return"?";if(e<1000)return String(Math.round(e));if(e<1e6){let n=e/1000;return n<10?`${n.toFixed(1).replace(/\.0$/,"")}k`:`${Math.round(n)}k`}let t=e/1e6;return t<10?`${t.toFixed(1).replace(/\.0$/,"")}M`:`${Math.round(t)}M`}function Tt(e){if(!Number.isFinite(e))return"";if(e>=1)return`$${e.toFixed(2)}`;let t=e.toFixed(4).replace(/0+$/,"");return(t.split(".")[1]??"").length<2?`$${e.toFixed(2)}`:`$${t}`}var eo=new Set(["0201","0402","0603","0805","1206","1210","1812","2010","2512"]),to=new Set(["QFN","DFN","SOT","SOIC","SOP","SSOP","TSSOP","MSOP","QFP","LQFP","TQFP","BGA","WLCSP","SOD","TO","SON","LGA"]);function ts(e){if(!e)return"";let t=e.indexOf(":"),i=(t>=0?e.slice(t+1):e).split("_");for(let o of i)if(eo.has(o))return o;let s=i[0]??"",r=s.replace(/[^a-zA-Z].*$/,"").toUpperCase();if(to.has(r)){let o=s.split("-");if(o.length>=2&&/^\d+$/.test(o[1]))return`${o[0]}-${o[1]}`;return o[0]}return i.slice(0,2).join("_")}function ns(e){let t=e?.status??"";if(!t)return null;let n=typeof e?.stock==="number"?e.stock:-1;if(t==="checking")return{text:"…",tone:"faint"};if(t==="unknown")return{text:"?",tone:"faint"};if(t==="out")return{text:`out ${Mt(Math.max(n,0))}`,tone:"bad"};if(t==="low")return{text:`low ${Mt(n)}`,tone:"warn"};return{text:Mt(n),tone:"ok"}}function is(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;return e.filter((i)=>{let s=[(i.refs??[]).join(" "),i.value??"",i.footprint??"",i.mpn??"",i.fab??""].join(" ").toLowerCase();return n.every((r)=>r==="dnp"&&Boolean(i.dnp)||s.includes(r))})}function ss(e,t){if(!t)return e;return e.filter((n)=>n.source===t)}function Rn(e){if(e==="active")return{label:"Active",tone:"ok"};if(e==="nrnd")return{label:"NRND",tone:"warn"};if(e==="eol")return{label:"EOL",tone:"bad"};return{label:"Unknown",tone:"faint"}}function dn(e){if(!Number.isFinite(e)||e<=0)return"";let t=new Date(e*1000),n=t.getUTCFullYear(),i=String(t.getUTCMonth()+1).padStart(2,"0"),s=String(t.getUTCDate()).padStart(2,"0");return`${n}-${i}-${s}`}function rs(e){return e.state==="routed"||e.state==="verified"}function os(e){switch(e.state){case"approved":return"✓";case"edited":return"✎";case"verified":return"✓✓";case"routed":return"100%";case"rejected":case"failed":return"✗";case"routing":return typeof e.routed==="number"&&typeof e.total==="number"&&e.total>0?`${e.routed}/${e.total}`:"…";case"blocked":return`⚠ ${Math.max(1,e.problems??1)}`;default:return""}}function as(e){switch(e.status){case"blocked":return{key:"gpui.mgmt.plan.st.blocked",label:"Blocked",tone:"bad"};case"routing":return{key:"gpui.mgmt.plan.st.routing",label:"Routing",tone:"accent"};case"awaiting":return{key:"gpui.mgmt.plan.st.awaiting",label:"Awaiting review",tone:"warn"};case"verified":return{key:"gpui.mgmt.plan.st.verified",label:"Verified",tone:"ok"};case"routed":return{key:"gpui.mgmt.plan.st.routed",label:"Routed",tone:"ok"};case"ready":return{key:"gpui.mgmt.plan.st.approved",label:"Approved",tone:"accent"};case"partial":return{key:"gpui.mgmt.plan.st.partial",label:"Partial",tone:"warn"};case"rejected":return{key:"gpui.mgmt.plan.st.rejected",label:"Rejected",tone:"bad"};default:if((e.blocked??0)>0)return{key:"gpui.mgmt.plan.st.blocked",label:"Blocked",tone:"bad"};if(e.routing)return{key:"gpui.mgmt.plan.st.routing",label:"Routing",tone:"accent"};if((e.awaiting??0)>0)return{key:"gpui.mgmt.plan.st.awaiting",label:"Awaiting review",tone:"warn"};return{key:"gpui.mgmt.plan.st.empty",label:"Empty",tone:"faint"}}}function ls(e){let t=e.done??0,n=e.approved??0,i=e.awaiting??0,s=e.blocked??0,r=0;if(typeof e.total!=="number"){for(let o of e.layers??[])for(let a of o.items??[])if(a.state==="routed"||a.state==="verified")t+=1;else if(a.state==="routing")r+=1;else if(a.state==="approved")n+=1}else if(e.routing)r=Math.max(0,e.total-(t+n+i+s));return[{count:t,tone:"ok"},{count:r,tone:"accent"},{count:n,tone:"input"},{count:i,tone:"warn"},{count:s,tone:"bad"}]}function cs(e){switch(e){case"current":return{text:"The fab's limits are in the DRC rules",button:null};case"stale":return{text:"The DRC rules have older fab limits",button:"Update"};case"none":return{text:"The fab's limits are not in the DRC rules",button:"Write"};default:return{text:"No KiCad project for DRC rules",button:null}}}function ds(e){return e==="extra"?"costs-more limits":"base-price limits"}function jn(e,t){return e.watchGen===t.watchGen&&e.editGen===t.editGen&&e.project!==""&&e.project===t.project&&e.editId!==""&&e.editId===t.editId}function ps(e){return{project:e.project,refs:e.refs.slice(),field:e.field,value:e.was}}function Hn(e,t){return e.watchGen===t.watchGen&&e.project!==""&&e.project===t.project&&e.threadId!==""&&e.threadId===t.threadId&&e.threadGen===t.threadGen}var Ji=["#f59e0b","#38bdf8","#c084fc","#2dd4bf","#ef4444","#a3e635","#f97316","#ec4899"],Yi=["#14b8a6","#f59e0b","#c084fc","#22c55e","#38bdf8","#ef4444","#e879f9","#84cc16"];function hs(e){let t=2166136261;for(let n=0;n>>0;return t}function zt(e,t=""){let n=t.trim().toLowerCase();if(n&&n!=="#5a7a9a"&&n!=="#8a8a8a")return t;let i=e.toUpperCase();if(i.includes("3V3A")||i.includes("AVDD")||i.includes("VDDA"))return"#38bdf8";if(i.includes("1V8")||i.includes("1.8V"))return"#c084fc";if(i.includes("2V5")||i.includes("2.5V"))return"#a3e635";if(i.includes("3V3")||i.includes("3.3V")||i.includes("VCC"))return"#f59e0b";if(i.includes("5V")||i.startsWith("+5"))return"#ef4444";if(i.includes("12V")||i.includes("24V"))return"#f97316";if(i.includes("VBAT")||i.includes("VIN"))return"#ec4899";if(i.includes("GND"))return"#2dd4bf";return Ji[hs(i)%Ji.length]}function It(e,t=""){let n=t.trim().toLowerCase();if(n&&n!=="#8a8a8a")return t;return Yi[hs(e)%Yi.length]}function ms(e,t,n,i=14){let s=Math.max(1,Math.abs(e[2]-e[0])),r=Math.max(1,Math.abs(e[3]-e[1])),o=Math.max(20,t-i*2),a=Math.max(20,n-i*2),c=Math.max(0.05,Math.min(200,Math.min(o/s,a/r)));return{cx:(e[0]+e[2])*0.5,cy:(e[1]+e[3])*0.5,scale:c,fitted:c,touched:!1}}function qe(e,t,n,i,s){return[i*0.5+(t-e.cx)*e.scale,s*0.5+(n-e.cy)*e.scale]}function pn(e,t,n,i,s){let r=Math.max(0.0001,e.scale);return[e.cx+(t-i*0.5)/r,e.cy+(n-s*0.5)/r]}function us(e,t,n){let i=Math.max(0.0001,e.scale);return{...e,cx:e.cx-t/i,cy:e.cy-n/i,touched:!0}}function bs(e,t,n,i,s,r){let o=Math.max(0.02,e.fitted*0.35),a=Math.max(40,e.fitted*24),c=Math.max(o,Math.min(a,e.scale*t)),[p,l]=pn(e,n,i,s,r);return{...e,cx:p-(n-s*0.5)/c,cy:l-(i-r*0.5)/c,scale:c,touched:!0}}function gs(e,t,n,i){let s=e.map((o)=>[o[0],o[1]]);if(s.length===0)return[n];let r=i&&t+1>=s.length?s.length:Math.min(t+1,s.length);return s.splice(r,0,[n[0],n[1]]),s}function Dn(e,t,n){let i=n?3:2;if(e.length<=i||t<0||t>=e.length)return null;let s=e.map((r)=>[r[0],r[1]]);return s.splice(t,1),s}function no(e,t,n,i,s,r){let o=s-n,a=r-i,c=o*o+a*a;if(c<0.000001)return(e-n)*(e-n)+(t-i)*(t-i);let p=Math.max(0,Math.min(1,((e-n)*o+(t-i)*a)/c)),l=n+p*o,h=i+p*a;return(e-l)*(e-l)+(t-h)*(t-h)}function Xi(e,t,n){if(n.length<3)return!1;let i=!1;for(let s=0,r=n.length-1;st!==p>t&&e<(c-o)*(t-a)/(p-a+0.000000000001)+o)i=!i}return i}function Fn(e,t){return Math.max(5,Math.min(32,e*t))}function hn(e,t,n,i,s,r,o,a,c){if(i){for(let d of e){if(d.layer!==n||d.id!==i||d.locked)continue;let u=d.path??[];for(let f=0;f=3)for(let f=0;f=0;d--){let u=t[d];if(u.layer!==n)continue;let f=u.outline??[];if(!Xi(l,h,f))continue;if(!(u.holes??[]).some((v)=>Xi(l,h,v)))return{kind:"region",id:u.id}}return null}function Bt(e){let t=null,n=null,i=[];for(let r of e){if(!r.layer)continue;i.push(r.layer);let o=r.items??[],a=o.filter((p)=>p.kind==="corridor").length,c=o.filter((p)=>p.kind==="plane").length;if((a>0||r.role==="signal")&&(!t||a>t.count))t={count:a,layer:r.layer};if((c>0||r.role==="power"||r.role==="plane")&&(!n||c>n.count))n={count:c,layer:r.layer}}let s=[];if(t)s.push(t.layer);if(n&&!s.includes(n.layer))s.push(n.layer);for(let r of i){if(s.length>=2)break;if(!s.includes(r))s.push(r)}return s}function Qi(e,t){if(!e||e.length===0)return null;if(e.length===1)return e[0];let n=Math.max(0,Math.min(1,t)),i=0;for(let o=1;o=s&&a>0.000000001){let c=(s-r)/a;return[e[o-1][0]+(e[o][0]-e[o-1][0])*c,e[o-1][1]+(e[o][1]-e[o-1][1])*c]}r+=a}return e[e.length-1]}function wt(e,t,n){for(let i of t??[])if(i.layer===e&&i.title)return i.title;for(let i of n??[])if(i.layer===e&&i.title)return i.title;return e}function fs(e,t,n){if(e==="split"&&n.length>0)return t.filter((i)=>n.includes(i.layer));return t}function Bn(e,t){return!(e[2]<=t[0]||e[0]>=t[2]||e[3]<=t[1]||e[1]>=t[3])}function Zi(e,t,n){if(n.length<3)return!1;let i=!1;for(let s=0,r=n.length-1;st!==p>t&&e<(c-o)*(t-a)/(p-a+0.000000000001)+o)i=!i}return i}function vs(e,t){if(e.length<3)return null;let n=1/0,i=1/0,s=-1/0,r=-1/0,o=0,a=0;for(let p of e)n=Math.min(n,p[0]),i=Math.min(i,p[1]),s=Math.max(s,p[0]),r=Math.max(r,p[1]),o+=p[0],a+=p[1];let c=[[(n+s)*0.5,(i+r)*0.5],[o/e.length,a/e.length]];for(let p of[0.5,0.25,0.75,0.125,0.875])for(let l of[0.5,0.25,0.75,0.125,0.875])c.push([n+(s-n)*l,i+(r-i)*p]);for(let p of c)if(Zi(p[0],p[1],e)&&!t.some((l)=>Zi(p[0],p[1],l)))return p;return null}function ys(e,t,n,i,s,r){let o=[];for(let l of e){let h=l.nets??0,d=l.path??[];if(h<=0||d.length<2)continue;let u=0;for(let f=1;f{let d=l.sel||l.hov?1:0,u=h.sel||h.hov?1:0;if(u!==d)return u-d;if(h.nets!==l.nets)return h.nets-l.nets;return l.b.id.localeCompare(h.b.id)});let a=[],c=[],p=(l,h,d,u,f)=>[l-d*0.5-f,h-u*0.5-f,l+d*0.5+f,h+u*0.5+f];for(let l of o){let h=l.b.name||"",d=String(l.nets),u=h?`${h} · ${l.nets}`:d,f=(l.sel||l.hov||l.pxLen>=95)&&h?[u,d]:[d],g=null,v=(w,k)=>Math.max(k*0.5+3,Math.min(Math.max(k*0.5+3,n-k*0.5-3),w)),y=(w,k)=>Math.max(k*0.5+3,Math.min(Math.max(k*0.5+3,i-k*0.5-3),w));e:for(let w of f){let k=Math.max(16,w.length*5.9+10),A=15;for(let N of[0.5,0.35,0.65,0.22,0.78]){let L=Qi(l.pts,N);if(!L)continue;let[B,T]=qe(t,L[0],L[1],n,i),H=v(B,k),F=y(T,15),P=p(H,F,k,15,2);if(!a.some((K)=>Bn(P,K))){g={id:l.b.id,text:w,cx:H,cy:F,pw:k,ph:15,col:l.col,sel:l.sel};break e}}}if(!g){let w=Qi(l.pts,0.5);if(w){let[k,A]=qe(t,w[0],w[1],n,i),N=Math.max(16,d.length*6.5+8),L=15,B=v(k,N);for(let T of[-18,18]){let H=y(A+T,15);if(!a.some((F)=>Bn(p(B,H,N,15,2),F))){g={id:l.b.id,text:d,cx:B,cy:H,pw:N,ph:15,col:l.col,sel:l.sel};break}}}}if(g)a.push(p(g.cx,g.cy,g.pw,g.ph,2)),c.push(g)}return c}function ws(e,t,n,i,s,r=[]){let o=new Set(s),a=[];for(let l of e){if(!l.r||!l.b||l.b.length!==4)continue;let[h,d]=qe(t,l.b[0],l.b[1],n,i),[u,f]=qe(t,l.b[2],l.b[3],n,i),g=Math.abs(u-h),v=Math.abs(f-d);if(g<13||v<9)continue;let y=(h+u)*0.5,w=(d+f)*0.5;if(y<8||y>n-8||w<8||w>i-8)continue;a.push({text:l.r,cx:y,cy:w,bw:l.r.length*5.8+4,bh:11,score:g*v+(o.has(l.r)?1e4:0)})}a.sort((l,h)=>h.score-l.score);let c=[...r],p=[];for(let l of a){let h=[l.cx-l.bw*0.5,l.cy-l.bh*0.5,l.cx+l.bw*0.5,l.cy+l.bh*0.5];if(!c.some((u)=>Bn(h,u)))c.push(h),p.push({text:l.text,cx:l.cx,cy:l.cy})}return p}function Es(e){if(!e||typeof e!=="object")return null;let t=e;if(t.panel&&typeof t.panel==="object")return t.panel;if(t.result&&typeof t.result==="object"){let n=t.result.panel;if(n&&typeof n==="object")return n}return null}function mn(e,t){if(!t||t.length===0)return e;let n=new Map;for(let r of e)if(r.layer)n.set(r.layer,r);let i=[],s=new Set;for(let r of t){if(!r.layer)continue;s.add(r.layer);let o=n.get(r.layer);if(o)i.push(o);else i.push({layer:r.layer,index:r.index,title:r.title||`L${r.index} · ${r.layer}`,subtitle:r.subtitle||"",role:r.role,status:"proposed",done:0,approved:0,total:0,items:[]})}for(let r of e)if(r.layer&&!s.has(r.layer))i.push(r);return i}function Cs(e,t,n,i,s,r,o,a){return e===t&&n===i&&s===r&&(a===void 0||o>=a)}var ks="#111917",io="#16201d",so="rgba(212, 224, 219, 0.92)",ro="rgba(61, 80, 73, 0.72)",oo="rgba(82, 107, 97, 0.85)";var xs="#f59e0b",ao="#eef5f2",Ps="#ef4444";function Et(e,t){let n=e.trim().replace(/^#/,"");if(n.length===6){let i=parseInt(n.slice(0,2),16),s=parseInt(n.slice(2,4),16),r=parseInt(n.slice(4,6),16);if(!Number.isNaN(i)&&!Number.isNaN(s)&&!Number.isNaN(r))return`rgba(${i}, ${s}, ${r}, ${t})`}return`rgba(20, 184, 166, ${t})`}function lo(e,t,n){let i=0.14,s=0.45,r=0.85,o=!1;switch(e){case"approved":case"routing":i=0.16,s=0.51,r=0.91;break;case"edited":i=0.2,s=0.56,r=0.95;break;case"routed":case"verified":i=0.08,s=0.26,r=0.59;break;case"rejected":case"failed":i=0.05,s=0.13,r=0.27;break;case"blocked":i=0.18,s=0.48,r=0.88,o=!0;break}if(t)i=Math.min(0.35,i+0.1),s=Math.min(0.71,s+0.12),r=1;else if(n)i=Math.min(0.28,i+0.06),s=Math.min(0.63,s+0.07);return{glow:i,body:s,core:r,bad:o}}function co(e,t,n){let i=0.27,s=0.83,r=!1;switch(e){case"approved":case"routing":i=0.36,s=0.91;break;case"edited":i=0.38,s=0.95;break;case"routed":case"verified":i=0.16,s=0.54;break;case"rejected":case"failed":i=0.08,s=0.27;break;case"blocked":i=0.31,s=0.94,r=!0;break}if(t)i=Math.min(0.53,i+0.12),s=1;else if(n)i=Math.min(0.45,i+0.06),s=Math.min(1,s+0.1);return{fill:i,edge:s,bad:r}}function po(e){let t=e.items??[];if(t.some((n)=>n.state==="blocked"||n.state==="failed"))return{key:"gpui.mgmt.plan.st.blocked",label:"Blocked",tone:"bad"};if(t.some((n)=>n.state==="routing"))return{key:"gpui.mgmt.plan.st.routing",label:"Routing",tone:"accent"};if(t.some((n)=>n.state==="proposed"||n.state==="edited"))return{key:"gpui.mgmt.plan.st.awaiting",label:"Awaiting review",tone:"warn"};if(t.length>0&&t.every((n)=>n.state==="routed"||n.state==="verified"))return{key:"gpui.mgmt.plan.st.routed",label:"Routed",tone:"ok"};if(t.length>0&&t.every((n)=>n.state==="approved"||n.state==="routed"||n.state==="verified"))return{key:"gpui.mgmt.plan.st.approved",label:"Approved",tone:"accent"};return{key:"gpui.mgmt.plan.st.empty",label:"Empty",tone:"faint"}}class $n{root;cb;state=null;cards=new Map;renderedLayerKey="";sharedCam=null;layerCams=new Map;hover=null;selectedVertex=null;drag=null;downPos=null;rafPending=0;constructor(e){this.cb=e,this.root=document.createElement("div"),this.root.className="bp-plan-canvas-grid",this.root.tabIndex=0,this.root.setAttribute("data-testid","mgmt-plan-canvas-grid"),this.root.addEventListener("keydown",(t)=>this.onKeyDown(t))}isDragging(){return this.drag!==null}fitAll(){this.sharedCam=null,this.layerCams.clear(),this.scheduleDraw()}destroy(){if(this.rafPending)cancelAnimationFrame(this.rafPending),this.rafPending=0;for(let e of this.cards.values())e.ro.disconnect();this.cards.clear(),this.root.replaceChildren()}visibleLayers(e){let t=mn(e.layers,e.copperLayers);if(t.length===0)return[];if(e.gridMode==="all")return t;if(e.gridMode==="single"){let s=e.shownLayers.find((o)=>t.some((a)=>a.layer===o))??Bt(t)[0]??t[0]?.layer,r=t.find((o)=>o.layer===s);return r?[r]:[]}let n=e.shownLayers.length>0&&e.shownLayers.every((s)=>t.some((r)=>r.layer===s))?e.shownLayers.slice(0,2):Bt(t),i=[];for(let s of n){let r=t.find((o)=>o.layer===s);if(r)i.push(r)}return i.length>0?i:t.slice(0,2)}update(e,t){this.state=e;let n=this.visibleLayers(e);this.root.classList.toggle("two-cols",t&&n.length>1);let i=n.map((s)=>s.layer).join("|");if(i!==this.renderedLayerKey){this.renderedLayerKey=i;for(let s of this.cards.values())s.ro.disconnect();this.cards.clear(),this.root.replaceChildren();for(let s of n){let r=this.buildCard(s);this.cards.set(s.layer,r),this.root.appendChild(r.el)}}else for(let s of n){let r=this.cards.get(s.layer);if(r)this.syncCardHeaderAndLegend(r,s)}this.scheduleDraw()}effectiveBbox(e){let t=e.bbox;if(!t||t.length!==4||Math.abs(t[2]-t[0])<0.5||Math.abs(t[3]-t[1])<0.5)return[0,0,100,70];return t}getCam(e,t,n){let i=this.state,s=i?.syncZoom?this.sharedCam:this.layerCams.get(e)??null;if(s&&s.touched)return s;return ms(i?this.effectiveBbox(i.board):[0,0,100,70],t,n,14)}setCam(e,t){if(this.state?.syncZoom)this.sharedCam=t;else this.layerCams.set(e,t)}buildCard(e){let t=document.createElement("section");t.className="bp-plan-card",t.setAttribute("data-testid",`mgmt-plan-card-${e.layer}`);let n=document.createElement("div");n.className="bp-plan-card-head";let i=document.createElement("div");i.className="bp-plan-card-head-top";let s=document.createElement("span"),r=e.role==="power"||(e.items?.length??0)>0&&(e.items??[]).every((w)=>w.kind==="plane");s.className="bp-plan-card-bar "+(r?"pwr":"sig");let o=document.createElement("span");o.className="bp-plan-card-title";let a=document.createElement("span");a.className="bp-plan-status-badge";let c=document.createElement("button");c.type="button",c.className="bp-mgmt-btn bp-plan-mini-btn",c.textContent="✓",c.title=m("gpui.mgmt.plan.layer","Approve layer"),c.addEventListener("click",(w)=>{w.stopPropagation(),this.cb.onApproveLayer(e.layer,!0)});let p=document.createElement("button");p.type="button",p.className="bp-mgmt-btn bp-plan-mini-btn",p.textContent="✗",p.title=m("gpui.mgmt.plan.rejectlayer","Reject layer"),p.addEventListener("click",(w)=>{w.stopPropagation(),this.cb.onApproveLayer(e.layer,!1)}),i.append(s,o,a,c,p);let l=document.createElement("div");l.className="bp-plan-card-sub",n.append(i,l);let h=document.createElement("div");h.className="bp-plan-card-canvas-wrap";let d=document.createElement("canvas");d.className="bp-plan-card-canvas",d.setAttribute("data-testid",`mgmt-plan-canvas-${e.layer}`);let u=document.createElement("div");u.className="bp-plan-hover-hud bp-hidden",h.append(d,u);let f=document.createElement("div");f.className="bp-plan-legend bp-hidden",t.append(n,h,f);let g=d.getContext("2d"),v=new ResizeObserver(()=>this.scheduleDraw());v.observe(h),this.attachPointerListeners(d,e.layer);let y={layer:e.layer,el:t,canvas:d,ctx:g,legendEl:f,okBtn:c,noBtn:p,statusEl:a,titleEl:o,subtitleEl:l,hoverHudEl:u,ro:v};return this.syncCardHeaderAndLegend(y,e),y}syncCardHeaderAndLegend(e,t){e.titleEl.textContent=wt(t.layer,this.state?.copperLayers,this.state?.layers)||t.title||t.layer;let n=t.subtitle||t.stackup||"";e.subtitleEl.textContent=n,e.subtitleEl.classList.toggle("bp-hidden",!n);let i=t.items??[],s=po(t);e.statusEl.className=`bp-plan-card-status tone-${s.tone==="warn"?"dim":s.tone}`,e.statusEl.textContent=i.length>0?m(s.key,s.label):"",e.statusEl.classList.toggle("bp-hidden",i.length===0);let r=i.some((a)=>a.state==="proposed"||a.state==="edited");if(e.okBtn)e.okBtn.classList.toggle("bp-hidden",!r);if(e.noBtn)e.noBtn.classList.toggle("bp-hidden",!r);let o=(this.state?.regions??[]).filter((a)=>a.layer===t.layer);if(o.length===0)e.legendEl.classList.add("bp-hidden"),e.legendEl.replaceChildren();else{e.legendEl.classList.remove("bp-hidden");let a=document.createDocumentFragment();for(let c of o){let p=document.createElement("button");p.type="button";let l=this.state?.selectedId===c.id;p.className="bp-plan-legend-chip"+(l?" active":"");let h=document.createElement("span");h.className="bp-plan-legend-sw",h.style.background=zt(c.net||c.id,c.color||"");let d=document.createElement("span");d.textContent=c.net||c.id,p.append(h,d),p.addEventListener("click",()=>{this.cb.onSelect(c.id),this.cb.onFocusItem(c.id)}),a.appendChild(p)}e.legendEl.replaceChildren(a)}}attachPointerListeners(e,t){e.addEventListener("contextmenu",(i)=>i.preventDefault()),e.addEventListener("dblclick",()=>this.fitAll()),e.addEventListener("pointerdown",(i)=>{let s=this.state;if(!s)return;this.root.focus({preventScroll:!0});let r=e.getBoundingClientRect(),o=i.clientX-r.left,a=i.clientY-r.top,c=Math.max(1,r.width),p=Math.max(1,r.height),l=this.getCam(t,c,p),h=hn(s.bands,s.regions,t,s.selectedId,l,c,p,o,a);if(i.button===2){if(h?.kind==="vertex"){let d=this.getItemPts(h.id,h.isPlane),u=Dn(d,h.idx,h.isPlane);if(u)this.selectedVertex=null,this.cb.onCommitFields(h.id,{[h.isPlane?"outline":"path"]:u})}return}if(i.button!==0)return;if(e.setPointerCapture(i.pointerId),this.downPos={x:i.clientX,y:i.clientY},h?.kind==="vertex"){let d=this.getItemPts(h.id,h.isPlane),u=d.map((f)=>[f[0],f[1]]);this.selectedVertex={id:h.id,idx:h.idx},this.drag={layer:t,kind:"vertex",id:h.id,isPlane:h.isPlane,idx:h.idx,pts:d.map((f)=>[f[0],f[1]]),origPts:u,moved:!1},this.scheduleDraw()}else if(h?.kind==="midpoint"){let d=this.getItemPts(h.id,h.isPlane),u=d.map((v)=>[v[0],v[1]]),f=gs(d,h.segIdx,h.pos,h.isPlane),g=h.isPlane&&h.segIdx+1>=d.length?f.length-1:Math.min(h.segIdx+1,f.length-1);this.selectedVertex={id:h.id,idx:g},this.patchLocalItem(h.id,h.isPlane,f),this.drag={layer:t,kind:"vertex",id:h.id,isPlane:h.isPlane,idx:g,pts:f,origPts:u,moved:!0},this.scheduleDraw()}else this.selectedVertex=null,this.drag={layer:t,kind:"pan",lastX:o,lastY:a}}),e.addEventListener("pointermove",(i)=>{let s=this.state;if(!s)return;let r=e.getBoundingClientRect(),o=i.clientX-r.left,a=i.clientY-r.top,c=Math.max(1,r.width),p=Math.max(1,r.height);if(this.drag&&this.drag.layer===t){if(this.drag.kind==="pan"){let A=this.getCam(t,c,p);this.setCam(t,us(A,o-this.drag.lastX,a-this.drag.lastY)),this.drag.lastX=o,this.drag.lastY=a,this.scheduleDraw();return}if(this.downPos&&Math.hypot(i.clientX-this.downPos.x,i.clientY-this.downPos.y)<1.5&&!this.drag.moved)return;let g=this.getCam(t,c,p),[v,y]=pn(g,o,a,c,p),w=[Math.round(v*1000)/1000,Math.round(y*1000)/1000];this.drag.moved=!0,this.drag.pts[this.drag.idx]=w;let k=this.drag.pts.map((A)=>[A[0],A[1]]);this.patchLocalItem(this.drag.id,this.drag.isPlane,k),this.scheduleDraw();return}let l=this.getCam(t,c,p),h=hn(s.bands,s.regions,t,s.selectedId,l,c,p,o,a),d=this.hover?.hit?"id"in this.hover.hit?this.hover.hit.id:"":"",u=this.hover?.hit.kind??"",f=h?h.id:"";if(this.hover=h?{layer:t,hit:h}:null,e.style.cursor=h?"pointer":"crosshair",d!==f||(h?.kind??"")!==u)this.syncHoverHud(t),this.scheduleDraw()}),e.addEventListener("pointerleave",()=>{if(this.hover?.layer===t)this.hover=null,this.syncHoverHud(t),this.scheduleDraw()});let n=()=>{let i=this.drag;if(!i||i.layer!==t)return;if(this.drag=null,this.downPos=null,i.kind==="vertex"&&i.moved){let s=i.origPts.map((r)=>[r[0],r[1]]);this.patchLocalItem(i.id,i.isPlane,s)}this.cb.onDragEnd?.(),this.scheduleDraw()};e.addEventListener("pointercancel",n),e.addEventListener("lostpointercapture",n),e.addEventListener("pointerup",(i)=>{let s=this.state,r=this.drag,o=this.downPos;if(this.drag=null,this.downPos=null,e.hasPointerCapture(i.pointerId))e.releasePointerCapture(i.pointerId);if(r&&r.kind==="vertex"&&r.layer===t){if(r.moved)this.cb.onCommitFields(r.id,{[r.isPlane?"outline":"path"]:r.pts});else this.cb.onDragEnd?.(),this.scheduleDraw();return}if(s&&o&&Math.hypot(i.clientX-o.x,i.clientY-o.y)<4.5){let a=e.getBoundingClientRect(),c=i.clientX-a.left,p=i.clientY-a.top,l=Math.max(1,a.width),h=Math.max(1,a.height),d=this.getCam(t,l,h),u=hn(s.bands,s.regions,t,s.selectedId,d,l,h,c,p);if(u&&(u.kind==="band"||u.kind==="region")){this.cb.onSelect(u.id),this.cb.onFocusItem(u.id);return}if(!u&&s.selectedId){this.cb.onSelect("");return}}this.cb.onDragEnd?.()}),e.addEventListener("wheel",(i)=>{i.preventDefault();let s=e.getBoundingClientRect(),r=i.clientX-s.left,o=i.clientY-s.top,a=Math.max(1,s.width),c=Math.max(1,s.height),p=this.getCam(t,a,c),l=Math.max(0.65,Math.min(1.55,1-i.deltaY*0.002));this.setCam(t,bs(p,l,r,o,a,c)),this.scheduleDraw()},{passive:!1})}patchLocalItem(e,t,n){let i=this.state;if(!i)return;if(t){let s=i.regions.find((r)=>r.id===e);if(s){if(s.outline=n,s.edited=!0,s.state==="proposed")s.state="edited"}}else{let s=i.bands.find((r)=>r.id===e);if(s){if(s.path=n,s.edited=!0,s.state==="proposed")s.state="edited"}}}getItemPts(e,t){let n=this.state;if(!n)return[];if(t)return(n.regions.find((i)=>i.id===e)?.outline??[]).map((i)=>[i[0],i[1]]);return(n.bands.find((i)=>i.id===e)?.path??[]).map((i)=>[i[0],i[1]])}syncHoverHud(e){let t=this.cards.get(e),n=this.state;if(!t||!n)return;if(!this.hover||this.hover.layer!==e){t.hoverHudEl.classList.add("bp-hidden"),t.hoverHudEl.textContent="";return}let i=this.hover.hit.id,s=n.bands.find((a)=>a.id===i),r=n.regions.find((a)=>a.id===i),o="";if(s)o=`${s.name||i} · ${s.nets??0}n · ${(s.width??1.5).toFixed(2)}mm`;else if(r)o=r.reference?`${r.net||i} · ${r.reference}`:r.net||i;if(!o)t.hoverHudEl.classList.add("bp-hidden");else t.hoverHudEl.classList.remove("bp-hidden"),t.hoverHudEl.textContent=o}onKeyDown(e){let t=this.state;if(!t)return;if(e.key==="0"||e.key==="Home"){e.preventDefault(),this.fitAll();return}if(e.key==="Escape"){this.selectedVertex=null,this.cb.onSelect("");return}if(!t.selectedId)return;let n=t.bands.find((o)=>o.id===t.selectedId),i=t.regions.find((o)=>o.id===t.selectedId),s=Boolean(n?.locked??i?.locked),r=e.key.toLowerCase();if(r==="a")e.preventDefault(),this.cb.onQuickApprove([t.selectedId],!0);else if(r==="r")e.preventDefault(),this.cb.onQuickApprove([t.selectedId],!1);else if(r==="l")e.preventDefault(),this.cb.onCommitFields(t.selectedId,{locked:!s});else if(r==="w"&&n&&!s){e.preventDefault();let o=e.shiftKey?-0.25:0.25,a=Math.round(Math.max(0.15,Math.min(25,(n.width??1.5)+o))*100)/100;this.cb.onCommitFields(t.selectedId,{width:a})}else if((e.key==="Delete"||e.key==="Backspace")&&!s&&this.selectedVertex?.id===t.selectedId){e.preventDefault();let o=Boolean(i),a=this.getItemPts(t.selectedId,o),c=Dn(a,this.selectedVertex.idx,o);if(c)this.selectedVertex=null,this.cb.onCommitFields(t.selectedId,{[o?"outline":"path"]:c})}}scheduleDraw(){if(this.rafPending)return;this.rafPending=requestAnimationFrame(()=>{this.rafPending=0,this.drawAll()})}drawAll(){let e=this.state;if(!e)return;let t=Math.max(0.45,Math.min(1.25,Math.abs(this.effectiveBbox(e.board)[3]-this.effectiveBbox(e.board)[1])/Math.max(1,Math.abs(this.effectiveBbox(e.board)[2]-this.effectiveBbox(e.board)[0]))));for(let n of this.cards.values()){let i=n.canvas.parentElement;if(!i)continue;let s=Math.max(120,Math.round(i.clientWidth)),r=Math.max(165,Math.min(250,Math.round(s*t)));n.canvas.style.height=`${r}px`;let o=Math.max(1,window.devicePixelRatio||1),a=Math.round(s*o),c=Math.round(r*o);if(n.canvas.width!==a||n.canvas.height!==c)n.canvas.width=a,n.canvas.height=c;n.ctx.setTransform(o,0,0,o,0,0),this.drawLayer(n.ctx,n.layer,s,r,e)}}drawLayer(e,t,n,i,s){let r=this.getCam(t,n,i),o=(g,v)=>qe(r,g,v,n,i);e.fillStyle=ks,e.fillRect(0,0,n,i);let a=(s.board.outline??[]).filter((g)=>g.length>=3);if(e.fillStyle=io,a.length>0){e.beginPath();for(let g of a){for(let v=0;vg.layer===t),p=this.hover?.layer===t?this.hover.hit:null;for(let g of c){let v=g.outline??[];if(v.length<3)continue;let y=s.selectedId===g.id,w=p?.id===g.id,k=co(g.state||"proposed",y,w),A=zt(g.net||g.id,g.color||"");e.beginPath();for(let L=0;LT)T=P;if(K>H)H=K}if(Math.abs(T-L)>=38&&Math.abs(H-B)>=18){let F=vs(v,g.holes??[]);if(F){let[P,K]=o(F[0],F[1]);e.fillStyle=Et(A,y?0.91:0.67),e.font="bold 10px ui-monospace, 'SFMono-Regular', Menlo, monospace",e.textAlign="center",e.textBaseline="middle",e.fillText(N,P,K)}}}}if(e.strokeStyle=so,e.lineWidth=1.25,e.lineCap="round",e.lineJoin="round",a.length>0){e.beginPath();for(let g of a){for(let v=0;vg.layer===t),d=ys(h,r,n,i,s.selectedId,p?.id??""),u=d.map((g)=>[g.cx-g.pw*0.5-1,g.cy-g.ph*0.5-1,g.cx+g.pw*0.5+1,g.cy+g.ph*0.5+1]),f=[];for(let g of h){for(let v of g.from??[])f.push(v);for(let v of g.to??[])f.push(v)}e.fillStyle="rgba(143, 163, 155, 0.72)",e.font="9.5px ui-monospace, 'SFMono-Regular', Menlo, monospace",e.textAlign="center",e.textBaseline="middle";for(let g of ws(l,r,n,i,f,u))e.fillText(g.text,g.cx,g.cy);for(let g of h){let v=g.guides??[];if(v.length===0)continue;let y=s.selectedId===g.id||p?.id===g.id,w=It(g.name||g.id,g.color||"");e.strokeStyle=Et(w,y?0.38:0.17),e.lineWidth=y?1:0.7,e.beginPath();for(let k of v){let[A,N]=o(k[0],k[1]),[L,B]=o(k[2],k[3]);e.moveTo(A,N),e.lineTo(L,B)}e.stroke()}for(let g of h){let v=g.path??[];if(v.length<2)continue;let y=s.selectedId===g.id,w=p?.id===g.id,k=lo(g.state||"proposed",y,w),A=It(g.name||g.id,g.color||""),N=Fn(g.width??1.5,r.scale),L=()=>{e.beginPath();for(let B=0;B{let w=y?v.length:Math.max(0,v.length-1);for(let k=0;kn.id===e))return;if(this.openPanel!==e)this.togglePanel(e)}getTabs(){return ln(this.getStateInfo())}isOpen(){return this.openPanel!==""}closePanel(){if(!this.openPanel)return;if(this.openPanel="",this.project)this.cb.hub.rpc("mgmt.panel",{project:this.project,open:""}).catch(()=>{});this.render()}clear(){this.watchGen++,this.bomEditGen++,this.askedProject="",this.digest="",this.project="",this.openPanel="",this.errorMsg="",this.bomEditingId="",this.bomLastUndo=null,this.bomEditStatus="",this.checksStatus="",this.planStatus="",this.planSelectedId="",this.planStackupOpen=!1,this.planShownLayers=[],this.planOptimistic.clear(),this.planOptimisticRev=void 0,this.planHydratedKey="",this.planHydrateAskedKey="",this.planHydrateGen++,this.planHydratedRev=void 0,this.planRenderDeferred=!1,this.planHydratedBoard=null,this.planHydratedDraw=null,this.planNoteOpen=!1,this.planMoveLayerOpen=!1,this.planCanvas?.destroy(),this.planCanvas=null,this.planCommitFields=null,this.fabStatus="",this.render()}async watchProject(e){if(!e||!this.cb.hub.hasFeature("mgmt")){this.clear();return}if(e===this.askedProject&&this.digest){this.render();return}let t=++this.watchGen;if(this.askedProject=e,this.project!==e)this.bomEditGen++,this.digest="",this.project="",this.openPanel="",this.errorMsg="",this.bomSelectedId="",this.bomEditingId="",this.bomEditStatus="",this.bomLastUndo=null,this.checksSelectedId="",this.checksStatus="",this.planStatus="",this.planSelectedId="",this.planStackupOpen=!1,this.planShownLayers=[],this.planOptimistic.clear(),this.planOptimisticRev=void 0,this.planHydratedKey="",this.planHydrateAskedKey="",this.planHydrateGen++,this.planHydratedRev=void 0,this.planRenderDeferred=!1,this.planHydratedBoard=null,this.planHydratedDraw=null,this.planNoteOpen=!1,this.planMoveLayerOpen=!1,this.planCanvas?.destroy(),this.planCanvas=null,this.planCommitFields=null,this.fabStatus="",this.lifeSelectedKey="",this.lifePartSamples=null,this.render();try{let n=await this.cb.hub.rpc("mgmt.watch",{project:e});if(t!==this.watchGen)return;let i=typeof n.digest==="string"?n.digest:"";if(!i){this.render();return}if(this.digest=i,this.project=typeof n.project==="string"&&n.project?n.project:e,n.state&&typeof n.state==="object")this.infos.set(`mgmt.state.${i}`,n.state);if(n.data&&typeof n.data==="object"){for(let[s,r]of Object.entries(n.data))if(r&&typeof r==="object")this.infos.set(`mgmt.${s}.${i}`,r)}this.errorMsg="",this.render()}catch{if(t===this.watchGen)this.render()}}handleInfo(e){let t=!1;for(let[n,i]of Object.entries(e)){if(!n.startsWith("mgmt.")&&!n.startsWith("kicad.checks."))continue;if(i===""||i===null||i===void 0){if(this.infos.delete(n))t=!0;continue}if(typeof i==="string")try{let s=JSON.parse(i);if(s&&typeof s==="object")this.infos.set(n,s),t=!0}catch{}else if(typeof i==="object")this.infos.set(n,i),t=!0}if(t)this.render()}getStateInfo(){if(!this.digest)return null;return this.infos.get(`mgmt.state.${this.digest}`)??null}getPanelData(e){if(!this.digest)return null;return this.infos.get(`mgmt.${e}.${this.digest}`)??null}togglePanel(e){let t=this.openPanel===e?"":e;if(this.openPanel=t,this.errorMsg="",this.render(),this.project)this.cb.hub.rpc("mgmt.panel",{project:this.project,open:t}).catch((n)=>{this.errorMsg=n instanceof Error?n.message:"Could not update panel",this.render()})}render(){if(this.openPanel==="plan"&&this.planCanvas?.isDragging()){this.planRenderDeferred=!0;return}this.planRenderDeferred=!1;let e=this.getStateInfo(),t=ln(e);if(!this.digest||t.length===0){this.planCanvas?.destroy(),this.planCanvas=null,this.panelEl.classList.remove("bp-plan-expanded"),this.stripEl.classList.add("bp-hidden"),this.panelEl.classList.add("bp-hidden"),this.panelEl.removeAttribute("data-testid"),this.panelEl.replaceChildren(),this.stripEl.replaceChildren(),this.cb.onOpenChange?.(!1);return}this.stripEl.classList.remove("bp-hidden");let n=document.createDocumentFragment(),i=document.createElement("div");i.className="bp-mgmt-tabs";for(let o of t){let a=document.createElement("button");a.type="button";let c=this.openPanel===o.id;a.className="bp-mgmt-tab"+(c?" active":""),a.setAttribute("data-testid",`mgmt-tab-${o.id}`),a.setAttribute("aria-pressed",c?"true":"false");let p=document.createElement("span");p.textContent=fe(o.label),a.appendChild(p);let l=this.getPanelData(o.id),h=es(l);if(h){let d=document.createElement("span");d.className=`bp-mgmt-badge bp-tone-${h.tone}`,d.textContent=h.text,a.appendChild(d)}a.addEventListener("click",()=>this.togglePanel(o.id)),i.appendChild(a)}if(n.appendChild(i),this.openPanel){let o=document.createElement("button");o.type="button",o.className="icon bp-mgmt-close",o.textContent="×",o.title=m("gpui.mgmt.close","Close the panel"),o.setAttribute("aria-label",m("gpui.mgmt.close","Close the panel")),o.setAttribute("data-testid","mgmt-close"),o.addEventListener("click",()=>this.closePanel()),n.appendChild(o)}if(this.stripEl.replaceChildren(n),!this.openPanel){this.planCanvas?.destroy(),this.planCanvas=null,this.panelEl.classList.remove("bp-plan-expanded"),this.panelEl.classList.add("bp-hidden"),this.panelEl.removeAttribute("data-testid"),this.panelEl.replaceChildren(),this.cb.onOpenChange?.(!1);return}if(this.openPanel!=="plan")this.planCanvas?.destroy(),this.planCanvas=null,this.panelEl.classList.remove("bp-plan-expanded");else this.panelEl.classList.toggle("bp-plan-expanded",this.planExpanded);this.panelEl.classList.remove("bp-hidden"),this.panelEl.setAttribute("data-testid",`mgmt-panel-${this.openPanel}`),this.cb.onOpenChange?.(!0);let s=this.openPanel==="plan"&&this.planCanvas!==null&&document.activeElement instanceof HTMLElement&&this.panelEl.contains(document.activeElement)&&(document.activeElement===this.planCanvas.root||this.planCanvas.root.contains(document.activeElement)),r=document.createDocumentFragment();if(this.errorMsg){let o=document.createElement("div");o.className="bp-mgmt-note bp-tone-bad",o.textContent=this.errorMsg,r.appendChild(o)}switch(this.openPanel){case"bom":r.appendChild(this.renderBom());break;case"checks":r.appendChild(this.renderChecks());break;case"life":r.appendChild(this.renderLife());break;case"plan":r.appendChild(this.renderPlan());break;case"fab":r.appendChild(this.renderFab());break}if(this.panelEl.replaceChildren(r),s)this.planCanvas?.root.focus({preventScroll:!0})}renderBom(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("bom");if(!t)return e.appendChild(this.makeEmpty("Reading the schematic…")),e;let n=Array.isArray(t.lines)?t.lines:[],i=document.createElement("div");i.className="bp-mgmt-head";let s=document.createElement("span");s.className="bp-dim",s.textContent=`${t.parts??0} parts · ${n.length} lines`;let r=document.createElement("span"),o=t.source==="kicad";if(r.className="bp-mgmt-pill"+(o?" accent":""),r.textContent=o?"live":"saved",i.append(s,r),(t.priced??0)>0&&(t.checking??0)===0&&typeof t.cost==="number"){let p=document.createElement("span");p.className="bp-dim",p.textContent=(t.priced??0)<(t.lookups??0)?`≥ ${Tt(t.cost)}/board`:`${Tt(t.cost)}/board`,i.appendChild(p)}if(t.paused){let p=document.createElement("span");p.className="bp-mgmt-faint",p.textContent="Stock check paused",i.appendChild(p)}if(e.appendChild(i),t.stock_note){let p=document.createElement("div");p.className="bp-mgmt-note bp-mgmt-faint",p.textContent=fe(t.stock_note),e.appendChild(p)}let a=this.bomEditingId?n.find((p)=>p.id===this.bomEditingId)??null:null;if(a)e.appendChild(this.renderBomEditor(a));else{let p=document.createElement("div");p.className="bp-mgmt-filter-row";let l=document.createElement("input");l.type="text",l.className="bp-mgmt-filter",l.placeholder="Filter BOM (ref, value, footprint, MPN, dnp)…",l.value=this.bomFilter,l.setAttribute("data-testid","mgmt-bom-filter"),l.addEventListener("input",()=>{this.bomFilter=l.value,this.renderBomRows(c,n)}),p.appendChild(l),e.appendChild(p)}let c=document.createElement("div");return c.className="bp-mgmt-rows",c.setAttribute("data-testid","mgmt-bom-rows"),this.renderBomRows(c,n),e.appendChild(c),e}renderBomRows(e,t){let n=is(t,this.bomFilter);if(n.length===0){e.replaceChildren(this.makeEmpty(t.length===0?"No parts found.":"No matching lines."));return}let i=t.some((r)=>Boolean(r.mpn)||Boolean(r.fab)),s=document.createDocumentFragment();for(let r of n){let o=Array.isArray(r.refs)?r.refs:[],a=document.createElement("div");a.className="bp-mgmt-row"+(this.bomSelectedId===r.id?" active":"")+(r.dnp?" faint":""),a.setAttribute("data-testid",`mgmt-bom-row-${r.id}`);let c=document.createElement("div");c.className="bp-mgmt-row-line";let p=document.createElement("span");if(p.className="bp-mgmt-strong bp-mgmt-flex1",p.textContent=cn(o,24),c.appendChild(p),r.dnp){let g=document.createElement("span");g.className="bp-mgmt-pill",g.textContent=m("gpui.mgmt.bom.dnp","DNP"),c.appendChild(g)}else{let g=ns(r.stock);if(g){let v=document.createElement("span");v.className=`bp-tone-${g.tone}`,v.textContent=g.text,c.appendChild(v)}}let l=document.createElement("button");l.type="button",l.className="bp-mgmt-btn",l.textContent="Edit",l.addEventListener("click",(g)=>{g.stopPropagation(),this.bomEditGen++,this.bomEditingId=r.id,this.bomEditDraft=r.mpn??"",this.bomEditStatus="",this.bomLastUndo=null,this.render()}),c.appendChild(l);let h=document.createElement("div");h.className="bp-mgmt-row-sub";let d=[`${r.qty??o.length}×`,r.value??"",ts(r.footprint??"")].filter(Boolean).join(" · "),u=document.createElement("span");u.className="bp-dim",u.textContent=d;let f=document.createElement("span");if(f.className="bp-mgmt-flex1",r.mpn)f.textContent=r.mpn;else if(i&&!r.dnp)f.className+=" bp-tone-warn",f.textContent=m("gpui.mgmt.bom.nompn","no MPN");if(h.append(u,f),!r.dnp&&typeof r.stock?.price==="number"){let g=document.createElement("span");g.className="bp-dim",g.textContent=Tt(r.stock.price),h.appendChild(g)}if(!r.dnp&&r.stock?.class){let g=document.createElement("span");g.className="bp-mgmt-faint",g.textContent=fe(r.stock.class),h.appendChild(g)}a.append(c,h),a.addEventListener("click",()=>{this.bomSelectedId=r.id,this.renderBomRows(e,t)}),s.appendChild(a)}e.replaceChildren(s)}renderBomEditor(e){let t=document.createElement("div");t.className="bp-mgmt-editor",t.setAttribute("data-testid","mgmt-bom-edit");let n=Array.isArray(e.refs)?e.refs:[],i=document.createElement("div");i.className="bp-mgmt-row-line";let s=document.createElement("span");s.className="bp-mgmt-strong",s.textContent=cn(n,30);let r=document.createElement("button");r.type="button",r.className="icon",r.textContent="×",r.addEventListener("click",()=>{this.bomEditGen++,this.bomEditingId="",this.bomLastUndo=null,this.bomEditStatus="",this.render()}),i.append(s,r);let o=document.createElement("input");o.type="text",o.className="bp-mgmt-filter",o.placeholder="MPN",o.value=this.bomEditDraft,o.addEventListener("input",()=>{this.bomEditDraft=o.value});let a=()=>({watchGen:this.watchGen,editGen:this.bomEditGen,project:this.project,editId:this.bomEditingId}),c=async(d,u=!1)=>{let f=a();this.bomEditStatus="Writing…",this.render();try{let g=await this.cb.hub.rpc("mgmt.bom.edit",d);if(!jn(f,a()))return;this.bomLastUndo=!u&&(g.changed??0)>0?{project:d.project,editId:f.editId,refs:d.refs.slice(),field:d.field,was:typeof g.was==="string"?g.was:d.field==="mpn"?e.mpn??"":e.dnp?"yes":"no"}:null,this.bomEditStatus=u?"Restored":(g.changed??0)===0?"No change":g.via==="kicad"?"Updated in KiCad":"Saved to schematic"}catch(g){if(!jn(f,a()))return;this.bomEditStatus=g instanceof Error?g.message:"Could not save edit"}this.render()},p=document.createElement("div");p.className="bp-mgmt-btn-row";let l=document.createElement("button");l.type="button",l.className="primary bp-mgmt-btn",l.textContent="Save MPN",l.addEventListener("click",()=>{c({project:this.project,refs:n.slice(),field:"mpn",value:this.bomEditDraft.trim()})});let h=document.createElement("button");if(h.type="button",h.className="bp-mgmt-btn",h.textContent=e.dnp?"Clear DNP":"Mark DNP",h.addEventListener("click",()=>{c({project:this.project,refs:n.slice(),field:"dnp",value:e.dnp?"no":"yes"})}),p.append(l,h),this.bomLastUndo&&this.bomLastUndo.project===this.project&&this.bomLastUndo.editId===this.bomEditingId){let d=this.bomLastUndo,u=document.createElement("button");u.type="button",u.className="bp-mgmt-btn",u.textContent="Undo",u.addEventListener("click",()=>{c(ps(d),!0)}),p.appendChild(u)}if(t.append(i,o,p),this.bomEditStatus){let d=document.createElement("div");d.className="bp-mgmt-faint",d.textContent=this.bomEditStatus,t.appendChild(d)}return t}renderChecks(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("checks");if(!t)return e.appendChild(this.makeEmpty("Reading checks…")),e;let n=Array.isArray(t.groups)?t.groups:[],i=Array.from(new Set(n.map((d)=>d.source).filter(Boolean))),s=(d)=>t.sources?.[d]?.label||d.toUpperCase(),r=(d)=>t.sources?.[d]?.judged===!0,o=document.createElement("div");o.className="bp-mgmt-head bp-mgmt-scroll-x";let a=document.createElement("button");a.type="button",a.className="bp-mgmt-btn"+(this.checksSource===""?" active":""),a.textContent=m("gpui.mgmt.checks.all","All"),a.addEventListener("click",()=>{this.checksSource="",this.render()}),o.appendChild(a);for(let d of i){let u=document.createElement("button");u.type="button",u.className="bp-mgmt-btn"+(this.checksSource===d?" active":""),u.textContent=s(d)+(r(d)?" · judged":""),u.addEventListener("click",()=>{this.checksSource=this.checksSource===d?"":d,this.render()}),o.appendChild(u)}let c=document.createElement("span");c.className="bp-mgmt-flex1";let p=document.createElement("button");if(p.type="button",p.className="bp-mgmt-btn",p.textContent=m("gpui.mgmt.checks.run","Run"),p.addEventListener("click",()=>{let d=this.watchGen,u=this.project;this.checksStatus="Running checks…",this.render(),this.cb.hub.rpc("kicad.checks.run",{project:u}).then(()=>{if(d!==this.watchGen||u!==this.project)return;this.checksStatus="",this.render()}).catch((f)=>{if(d!==this.watchGen||u!==this.project)return;this.checksStatus=f instanceof Error?f.message:"Could not run checks",this.render()})}),o.append(c,p),e.appendChild(o),this.checksStatus){let d=document.createElement("div");d.className="bp-mgmt-note bp-dim",d.textContent=this.checksStatus,e.appendChild(d)}let l=document.createElement("div");l.className="bp-mgmt-rows",l.setAttribute("data-testid","mgmt-checks-rows");let h=ss(n,this.checksSource);if(h.length===0)l.appendChild(this.makeEmpty("No check findings."));else for(let d of h){let u=d.severity==="error"?"bad":d.severity==="warning"?"warn":"faint",f=document.createElement("div");f.className="bp-mgmt-group-head";let g=document.createElement("span");g.className=`bp-mgmt-dot bp-tone-bg-${u}`;let v=document.createElement("span");v.className="bp-mgmt-flex1",v.textContent=`${s(d.source)} · ${d.rule}`;let y=document.createElement("span");y.className=`bp-tone-${u}`,y.textContent=String(d.n),f.append(g,v,y),l.appendChild(f);for(let w of d.rows??[]){let k=document.createElement("div");k.className="bp-mgmt-row"+(this.checksSelectedId===w.id?" active":"");let A=document.createElement("div");if(A.textContent=fe(w.title??""),k.appendChild(A),w.names||this.checksSelectedId===w.id){let N=document.createElement("div");N.className="bp-mgmt-row-sub";let L=document.createElement("span");if(L.className="bp-dim bp-mgmt-flex1",L.textContent=w.names??"",N.appendChild(L),this.checksSelectedId===w.id){let B=document.createElement("button");B.type="button",B.className="bp-mgmt-btn accent",B.textContent=m("gpui.mgmt.checks.fix","Fix with agent"),B.addEventListener("click",(T)=>{T.stopPropagation();let H={watchGen:this.watchGen,project:this.project,threadId:this.cb.getThreadId(),threadGen:this.cb.getThreadGen()};this.cb.hub.rpc("kicad.checks.fix",{project:H.project,id:w.id}).then((F)=>{let P={watchGen:this.watchGen,project:this.project,threadId:this.cb.getThreadId(),threadGen:this.cb.getThreadGen()};if(!Hn(H,P))return;if(F.text)this.cb.onSendText(F.text),this.checksStatus="Sent to agent",this.render()}).catch((F)=>{let P={watchGen:this.watchGen,project:this.project,threadId:this.cb.getThreadId(),threadGen:this.cb.getThreadGen()};if(!Hn(H,P))return;this.checksStatus=F instanceof Error?F.message:"Could not send finding",this.render()})}),N.appendChild(B)}k.appendChild(N)}k.addEventListener("click",()=>{this.checksSelectedId=w.id,this.cb.hub.rpc("kicad.checks.focus",{project:this.project,id:w.id}).catch(()=>{}),this.render()}),l.appendChild(k)}}return e.appendChild(l),e}renderLife(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("life");if(!t)return e.appendChild(this.makeEmpty("Reading lifecycle…")),e;let n=document.createElement("div");n.className="bp-mgmt-head";let i=t.counts??{};for(let c of["active","nrnd","eol"]){let p=i[c]??0,l=Rn(c),h=document.createElement("span");h.className=p>0?`bp-tone-${l.tone}`:"bp-mgmt-faint",h.textContent=`${l.label} ${p}`,n.appendChild(h)}if((i.unknown??0)>0){let c=document.createElement("span");c.className="bp-mgmt-faint",c.textContent=`${i.unknown} unknown`,n.appendChild(c)}if(t.since){let c=document.createElement("span");c.className="bp-mgmt-flex1";let p=document.createElement("span");p.className="bp-mgmt-faint",p.textContent=`since ${dn(t.since)} (${t.samples??0})`,n.append(c,p)}e.appendChild(n);let s=document.createElement("div");s.className="bp-mgmt-rows",s.setAttribute("data-testid","mgmt-life-rows");let r=t.bom?.cost??[],o=t.bom?.instock??[],a=t.bom?.lines??0;if(r.length===0)s.appendChild(this.makeEmpty(a===0?"No line has an MPN or fab part number to follow yet.":"No reading of the fab's stock yet: the BOM panel's lookups start it."));else{let c=r[r.length-1],p=o[o.length-1],l=document.createElement("div");l.className="bp-mgmt-note bp-dim",l.textContent=`Parts/board: ${Tt(c[1])} · ${Math.round(p?.[1]??0)}/${a} lines in stock (${dn(c[0])})`,s.appendChild(l)}for(let c of t.parts??[]){let p=this.lifeSelectedKey===c.key,l=Rn(c.lifecycle??"unknown"),h=document.createElement("div");h.className="bp-mgmt-row"+(p?" active":"");let d=document.createElement("div");d.className="bp-mgmt-row-line";let u=document.createElement("span");u.className="bp-mgmt-strong",u.textContent=cn(c.refs??[],14);let f=document.createElement("span");f.className="bp-mgmt-flex1 bp-dim",f.textContent=c.mpn||c.key;let g=document.createElement("span");if(g.className=`bp-tone-${l.tone}`,g.textContent=l.label,d.append(u,f,g),typeof c.stock==="number"){let v=document.createElement("span");v.className="bp-dim",v.textContent=Mt(c.stock),d.appendChild(v)}if(h.appendChild(d),p){let v=document.createElement("div");if(v.className="bp-mgmt-row-sub bp-mgmt-faint",this.lifePartLoading)v.textContent=m("gpui.mgmt.life.reading","Reading its history…");else if(this.lifePartSamples&&this.lifePartSamples.length>0){let y=this.lifePartSamples[this.lifePartSamples.length-1];v.textContent=`${this.lifePartSamples.length} samples · latest ${y.at?dn(y.at):""}`+(typeof y.stock==="number"?` · stock ${Mt(y.stock)}`:"")+(typeof y.price==="number"?` · ${Tt(y.price)}`:"")}else v.textContent=m("gpui.mgmt.life.nopart","No reading of this part yet.");h.appendChild(v)}h.addEventListener("click",()=>{if(this.lifeSelectedKey===c.key){this.lifeSelectedKey="",this.lifePartSamples=null,this.render();return}this.lifeSelectedKey=c.key,this.lifePartSamples=null,this.lifePartLoading=!0,this.render(),this.cb.hub.rpc("mgmt.life.part",{project:this.project,key:c.key}).then((v)=>{if(this.lifeSelectedKey!==c.key)return;this.lifePartLoading=!1,this.lifePartSamples=Array.isArray(v.samples)?v.samples:[],this.render()}).catch(()=>{if(this.lifeSelectedKey!==c.key)return;this.lifePartLoading=!1,this.lifePartSamples=[],this.render()})}),s.appendChild(h)}return e.appendChild(s),e}renderPlan(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("plan");if(!t)return e.appendChild(this.makeEmpty(m("gpui.mgmt.plan.reading","Reading the routing plan…"))),e;let n=(E,x)=>{let D=this.watchGen,I=this.project;this.planStatus="",this.cb.hub.rpc(E,{pro:I,...x}).catch((J)=>{if(D!==this.watchGen||I!==this.project)return;this.planOptimistic.clear(),this.planStatus=J instanceof Error?J.message:m("gpui.mgmt.plan.refused","KiCad refused"),this.render()})};if(t.revision!==this.planOptimisticRev)this.planOptimisticRev=t.revision,this.planOptimistic.clear();let i=`${this.project}:${t.revision??0}`;if(t.board_trimmed&&this.planHydrateAskedKey!==i&&this.project){this.planHydrateAskedKey=i;let E=this.watchGen,x=++this.planHydrateGen,D=this.project,I=t.revision??0;this.cb.hub.rpc("plan.get",{pro:D,board:!0}).then((J)=>{let oe=Es(J);if(!oe)return;let Ee=typeof oe.revision==="number"?oe.revision:I;if(!Cs(E,this.watchGen,x,this.planHydrateGen,D,this.project,Ee,this.planHydratedRev))return;this.planHydratedRev=Ee,this.planHydratedKey=`${D}:${Ee}`,this.planHydratedBoard=oe.board??null,this.planHydratedDraw=oe.draw??null,this.render()}).catch(()=>{})}let s=t.on===!0,r=document.createElement("div");r.className="bp-plan-header";let o=document.createElement("div");o.className="bp-plan-toggle";let a=document.createElement("span");a.className="bp-mgmt-strong",a.textContent=m("gpui.mgmt.plan.before","Plan before routing"),a.title=s?m("gpui.mgmt.plan.onwords","Before routing a board with 4 or more copper layers or more than 60 nets, the agent proposes corridors and plane regions here. It routes only what you approve."):m("gpui.mgmt.plan.offwords","Agents route as you ask. Turn it on to have them propose a routing plan first and route only what you approve here."),o.appendChild(a);let c=t.awaiting??0,p=t.blocked??0,l=t.done??0,h=t.total??0,d=t.revision??0,u=t.empty?[]:ls(t),f=u.reduce((E,x)=>E+x.count,0);if(!t.empty){let E=as(t),x=document.createElement("span");if(x.className=`bp-plan-status-badge tone-${E.tone}`,x.textContent=m(E.key,E.label),o.appendChild(x),d>0){let I=document.createElement("span");I.className="bp-dim",I.textContent=`v${d}`,o.appendChild(I)}let D=document.createElement("span");if(D.className="bp-plan-header-counts bp-mgmt-flex1 "+(c>0?"bp-tone-warn":p>0?"bp-tone-bad":"bp-dim"),D.textContent=h>0?`${l}/${h} ${m("gpui.mgmt.plan.done","done")}`:c>0?m("web.plan.awaiting","{n} awaiting approval",{n:c}):m("gpui.mgmt.plan.nothing","Nothing awaits your approval"),o.appendChild(D),!t.live){let I=document.createElement("span");I.className="bp-mgmt-pill",I.textContent=m("gpui.mgmt.plan.saved","saved plan"),o.appendChild(I)}}else{let E=document.createElement("span");E.className="bp-mgmt-flex1",o.appendChild(E)}let g=document.createElement("button");g.type="button",g.className="bp-mgmt-btn bp-plan-chip-btn"+(s?" active":""),g.setAttribute("data-testid","mgmt-plan-on"),g.setAttribute("aria-pressed",s?"true":"false"),g.textContent=m("gpui.bots.recall.on","On"),g.addEventListener("click",()=>n("plan.enable",{on:!0}));let v=document.createElement("button");if(v.type="button",v.className="bp-mgmt-btn bp-plan-chip-btn"+(!s?" active":""),v.setAttribute("data-testid","mgmt-plan-off"),v.setAttribute("aria-pressed",!s?"true":"false"),v.textContent=m("gpui.bots.recall.off","Off"),v.addEventListener("click",()=>n("plan.enable",{on:!1})),o.append(g,v),r.appendChild(o),f>0){let E=document.createElement("div");E.className="bp-plan-segbar";for(let x of u){if(x.count<=0)continue;let D=document.createElement("div");D.className=`bp-plan-seg bp-tone-bg-${x.tone}`,D.style.flexGrow=String(x.count),E.appendChild(D)}r.appendChild(E)}e.appendChild(r);for(let E of t.elsewhere??[]){let x=document.createElement("div");x.className="bp-plan-elsewhere";let D=document.createElement("span");D.className="bp-tone-warn bp-mgmt-flex1",D.textContent=m("gpui.mgmt.plan.elsewhere","A routing plan for {board} awaits your approval",{board:E.name||E.rel||""}),x.appendChild(D),e.appendChild(x)}if(t.empty){let E=document.createElement("div");E.className="bp-mgmt-note";let x=document.createElement("div");x.className="bp-dim",x.textContent=m("gpui.mgmt.plan.noboard","No routing plan for this board.");let D=document.createElement("div");return D.className="bp-mgmt-faint",D.textContent=m("gpui.mgmt.plan.emptysub","Layers, corridors, and planes appear here once a plan is proposed."),E.append(x,D),e.appendChild(E),e}let y=t.stackup_summary??"",w=Array.isArray(t.impedances)?t.impedances:[],k=Boolean(y)||w.length>0,A=document.createElement("div");if(A.className="bp-mgmt-head",c>0){let E=document.createElement("button");E.type="button",E.className="primary bp-mgmt-btn",E.setAttribute("data-testid","mgmt-plan-approve-all"),E.textContent=m("gpui.mgmt.plan.all","Approve all"),E.addEventListener("click",()=>n("plan.approve",{layer:"",ids:[],approve:!0})),A.appendChild(E)}if(t.routing){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn",E.setAttribute("data-testid","mgmt-plan-stop"),E.textContent=m("gpui.mgmt.plan.stop","Stop routing"),E.addEventListener("click",()=>n("plan.stop",{})),A.appendChild(E)}if(t.live&&l>0){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn",E.setAttribute("data-testid","mgmt-plan-verify"),E.textContent=m("gpui.mgmt.plan.verify","Verify"),E.addEventListener("click",()=>n("plan.verify",{})),A.appendChild(E)}let N=document.createElement("span");if(N.className="bp-mgmt-flex1",A.appendChild(N),k){let E=document.createElement("button");E.type="button",E.className="bp-mgmt-btn bp-plan-chip-btn"+(this.planStackupOpen?" active":""),E.setAttribute("data-testid","mgmt-plan-stackup-toggle"),E.setAttribute("aria-expanded",this.planStackupOpen?"true":"false"),E.textContent=`${m("gpui.mgmt.plan.stackup.short","Stackup")} ${this.planStackupOpen?"▾":"▸"}`,E.addEventListener("click",()=>{this.planStackupOpen=!this.planStackupOpen,this.render()}),A.appendChild(E)}let L=document.createElement("button");L.type="button",L.className="bp-mgmt-btn",L.setAttribute("data-testid","mgmt-plan-hide"),L.textContent=this.planHideDone?m("gpui.mgmt.plan.show","Show done"):m("gpui.mgmt.plan.hide","Hide done"),L.addEventListener("click",()=>{this.planHideDone=!this.planHideDone,this.render()}),A.appendChild(L),e.appendChild(A);let B=Array.isArray(t.asks)?t.asks:[];if(B.length>0){let E=B.map((oe)=>oe.what||"").filter(Boolean).join(", "),x=B[0]?.note||"",D=document.createElement("div");D.className="bp-plan-elsewhere";let I=document.createElement("div");I.className="bp-plan-ask-col";let J=document.createElement("div");if(J.className="bp-tone-warn",J.textContent=E?m("gpui.mgmt.plan.requested","Approval requested: {what}",{what:E}):m("gpui.mgmt.plan.reqplain","Approval requested"),I.appendChild(J),x){let oe=document.createElement("div");oe.className="bp-dim",oe.textContent=x,I.appendChild(oe)}D.appendChild(I),e.appendChild(D)}if(this.planStatus){let E=document.createElement("div");E.className="bp-mgmt-note bp-plan-err bp-tone-bad";let x=document.createElement("span");x.className="bp-mgmt-flex1",x.textContent=this.planStatus==="KiCad refused"?m("gpui.mgmt.plan.refused","KiCad refused"):fe(this.planStatus);let D=document.createElement("button");D.type="button",D.className="icon",D.textContent="×",D.title=m("common.close","Close"),D.addEventListener("click",()=>{this.planStatus="",this.render()}),E.append(x,D),e.appendChild(E)}if(t.keys_note){let E=document.createElement("div");E.className="bp-mgmt-note bp-dim";let x="On this KiCad version, approve from this panel: in plan view KiCad's A, R and W keys aren't the plan's yet (A opens Add Footprint). Update KiCad.";E.textContent=t.keys_note===x?m("gpui.mgmt.plan.keysnote",x):fe(t.keys_note),e.appendChild(E)}if(k&&this.planStackupOpen){let E=document.createElement("div");if(E.className="bp-plan-stackup-body",E.setAttribute("data-testid","mgmt-plan-stackup-body"),y){let x=document.createElement("div");x.className="bp-dim",x.textContent=y,E.appendChild(x)}for(let x of w){let D=document.createElement("div");D.className="bp-mgmt-faint",D.textContent=`· ${x}`,E.appendChild(D)}e.appendChild(E)}let T=(E,x,D,I)=>{let J=document.createElement("button");return J.type="button",J.className="bp-mgmt-btn bp-plan-chip-btn"+(x?" active":""),J.setAttribute("data-testid",D),J.setAttribute("aria-pressed",x?"true":"false"),J.textContent=E,J.addEventListener("click",I),J},H=document.createElement("div");if(H.className="bp-plan-viewbar",H.append(T(m("gpui.mgmt.plan.view.canvas","Canvas"),this.planViewMode==="canvas","mgmt-plan-view-canvas",()=>{this.planViewMode="canvas",this.render()}),T(m("gpui.mgmt.plan.view.split","Split"),this.planViewMode==="split","mgmt-plan-view-split",()=>{this.planViewMode="split",this.render()}),T(m("gpui.mgmt.plan.view.list","List"),this.planViewMode==="list","mgmt-plan-view-list",()=>{this.planViewMode="list",this.render()})),this.planViewMode!=="list"){let E=document.createElement("span");E.className="bp-plan-sep";let x=document.createElement("span");x.className="bp-plan-sep";let D=document.createElement("button");D.type="button",D.className="bp-mgmt-btn bp-plan-mini-btn",D.setAttribute("data-testid","mgmt-plan-fit"),D.textContent=m("gpui.mgmt.plan.fit","Fit"),D.addEventListener("click",()=>this.planCanvas?.fitAll()),H.append(E,T(m("gpui.mgmt.plan.grid.pair","Side by side"),this.planGridMode==="pair","mgmt-plan-grid-pair",()=>{this.planGridMode="pair",this.render()}),T(m("gpui.mgmt.plan.grid.all","All layers"),this.planGridMode==="all","mgmt-plan-grid-all",()=>{this.planGridMode="all",this.render()}),T(m("gpui.mgmt.plan.grid.single","Single"),this.planGridMode==="single","mgmt-plan-grid-single",()=>{this.planGridMode="single",this.render()}),x,T(m("gpui.mgmt.plan.sync","Link zoom"),this.planSyncZoom,"mgmt-plan-sync",()=>{this.planSyncZoom=!this.planSyncZoom,this.render()}),D)}let F=document.createElement("span");F.className="bp-mgmt-flex1";let P=document.createElement("button");P.type="button",P.className="bp-mgmt-btn bp-plan-mini-btn",P.setAttribute("data-testid","mgmt-plan-expand"),P.textContent=this.planExpanded?m("gpui.mgmt.plan.compact","Compact"):m("gpui.mgmt.plan.expand","Expand"),P.addEventListener("click",()=>{this.planExpanded=!this.planExpanded,this.render()}),H.append(F,P),e.appendChild(H);let K=Boolean(this.planHydratedBoard)&&this.planHydratedKey.startsWith(`${this.project}:`)&&(this.planHydratedKey===i||this.planHydratedRev!==void 0&&this.planHydratedRev>=(t.revision??0)),ae=K&&this.planHydratedBoard?this.planHydratedBoard:t.board??{bbox:[0,0,100,70],outline:[],parts:[]},re=K&&this.planHydratedDraw?this.planHydratedDraw:t.draw??{bands:[],regions:[]},ve=(re.bands??[]).map((E)=>{let x=this.planOptimistic.get(E.id);if(!x)return{...E};return{...E,...x,edited:!0,state:E.state==="proposed"?"edited":E.state}}),Ae=(re.regions??[]).map((E)=>{let x=this.planOptimistic.get(E.id);if(!x)return{...E};return{...E,...x,edited:!0,state:E.state==="proposed"?"edited":E.state}}),ke=[],ne=(t.layers??[]).map((E)=>{let x=[];for(let D of E.items??[]){let I=this.planOptimistic.get(D.id);if(!I){x.push(D);continue}let J={...D,width:typeof I.width==="number"?I.width:D.width,locked:typeof I.locked==="boolean"?I.locked:D.locked,edited:!0,state:D.state==="proposed"?"edited":D.state};if(typeof I.layer==="string"&&I.layer!==E.layer)ke.push({target:I.layer,item:J});else x.push(J)}return{...E,items:x}});for(let E of ke){let x=ne.find((D)=>D.layer===E.target);if(x)x.items=[...x.items??[],E.item]}let le=mn(ne,t.copper_layers),R=this.planGridMode==="all"?le.map((E)=>E.layer):this.planGridMode==="single"?[this.planShownLayers.find((E)=>le.some((x)=>x.layer===E))??Bt(le)[0]??le[0]?.layer??""].filter(Boolean):this.planShownLayers.length>0&&this.planShownLayers.every((E)=>le.some((x)=>x.layer===E))?this.planShownLayers.slice(0,2):Bt(le);if(this.planViewMode!=="list"&&this.planGridMode!=="all"&&le.length>1){let E=document.createElement("div");E.className="bp-plan-layerbar";for(let x of le){let D=R.includes(x.layer),I=(x.items??[]).length,J=wt(x.layer,t.copper_layers,le)||x.title||x.layer,oe=I>0?`${J} · ${I}`:J,Ee=T(oe,D,`mgmt-plan-layerpill-${x.layer}`,()=>{if(this.planGridMode==="single")this.planShownLayers=[x.layer];else if(this.planGridMode==="pair"){if(!R.includes(x.layer))this.planShownLayers=R.length>=2?[R[0],x.layer]:[...R,x.layer]}else this.planGridMode="single",this.planShownLayers=[x.layer];this.render()});if(I===0&&!D)Ee.classList.add("empty-layer");E.appendChild(Ee)}e.appendChild(E)}let he=(E,x)=>{let D=this.planOptimistic.get(E)??{};if(this.planOptimistic.set(E,{...D,...x}),typeof x.layer==="string"){if(this.planGridMode==="single")this.planShownLayers=[x.layer];else if(this.planGridMode==="pair"&&!R.includes(x.layer))this.planShownLayers=R.length>=2?[R[0],x.layer]:[...R,x.layer]}let I=typeof t.revision==="number"?t.revision:void 0;this.render(),n("plan.update",{ops:[{op:"set",id:E,fields:x}],...I!==void 0?{base:I}:{}})};if(this.planCommitFields=he,this.planSelectedId){let E="",x=null;for(let D of ne){let I=(D.items??[]).find((J)=>J.id===this.planSelectedId);if(I){E=D.layer,x=I;break}}if(x){let D=wt(E,t.copper_layers,le),I=document.createElement("div");I.className="bp-plan-inspector",I.setAttribute("data-testid","mgmt-plan-inspector");let J=document.createElement("div");J.className="bp-plan-ins-row";let oe=document.createElement("span");oe.className="bp-plan-ins-sw",oe.style.background=x.kind==="corridor"?It(x.name||x.id,x.color||""):zt(x.name||x.id,x.color||"");let Ee=document.createElement("span");Ee.className="bp-mgmt-strong",Ee.textContent=x.name||x.id;let Ce=document.createElement("span");if(Ce.className="bp-dim",Ce.textContent=D,J.append(oe,Ee,Ce),x.edited||x.state==="edited"){let q=document.createElement("span");q.className="bp-plan-ins-pill warn",q.textContent=m("gpui.mgmt.plan.edited","Edited"),J.appendChild(q)}if(x.locked){let q=document.createElement("span");q.className="bp-plan-ins-pill",q.textContent=m("gpui.mgmt.plan.locked","Locked"),J.appendChild(q)}let O=document.createElement("span");O.className="bp-mgmt-flex1",J.appendChild(O);let X=document.createElement("button");if(X.type="button",X.className="bp-mgmt-btn bp-plan-mini-btn",X.setAttribute("data-testid","mgmt-plan-lock"),X.textContent=x.locked?m("gpui.mgmt.plan.unlock","Unlock"):m("gpui.mgmt.plan.lock","Lock"),X.addEventListener("click",()=>he(x.id,{locked:!x.locked})),J.appendChild(X),x.state==="proposed"||x.state==="edited"){let q=document.createElement("button");q.type="button",q.className="primary bp-mgmt-btn bp-plan-mini-btn",q.textContent=m("android.hub.machines.approve","Approve"),q.addEventListener("click",()=>n("plan.approve",{layer:"",ids:[x.id],approve:!0}));let me=document.createElement("button");me.type="button",me.className="bp-mgmt-btn bp-plan-mini-btn",me.textContent=m("gpui.mgmt.plan.reject","Reject"),me.addEventListener("click",()=>n("plan.approve",{layer:"",ids:[x.id],approve:!1})),J.append(q,me)}let Me=document.createElement("button");Me.type="button",Me.className="bp-mgmt-btn bp-plan-mini-btn",Me.setAttribute("data-testid","mgmt-plan-note-toggle"),Me.textContent=m("gpui.mgmt.plan.addnote","Add note"),Me.addEventListener("click",()=>{this.planNoteOpen=!this.planNoteOpen,this.render()});let Ve=document.createElement("button");if(Ve.type="button",Ve.className="icon",Ve.textContent="×",Ve.addEventListener("click",()=>{this.planSelectedId="",this.planNoteOpen=!1,this.planMoveLayerOpen=!1,this.render()}),J.append(Me,Ve),I.appendChild(J),!x.locked){let q=document.createElement("div");if(q.className="bp-plan-ins-row",x.kind==="corridor"){let ie=typeof x.width==="number"?x.width:1.5,Oe=document.createElement("span");Oe.className="bp-dim",Oe.textContent=m("gpui.mgmt.plan.width","Width");let Ge=document.createElement("button");Ge.type="button",Ge.className="bp-mgmt-btn bp-plan-mini-btn",Ge.setAttribute("data-testid","mgmt-plan-w-down"),Ge.textContent="-",Ge.addEventListener("click",()=>{let ze=Math.round(Math.max(0.15,ie-0.25)*100)/100;he(x.id,{width:ze})});let He=document.createElement("span");He.className="bp-plan-ins-val",He.textContent=`${ie.toFixed(2)}mm`;let Je=document.createElement("button");Je.type="button",Je.className="bp-mgmt-btn bp-plan-mini-btn",Je.setAttribute("data-testid","mgmt-plan-w-up"),Je.textContent="+",Je.addEventListener("click",()=>{let ze=Math.round(Math.min(25,ie+0.25)*100)/100;he(x.id,{width:ze})});let Te=document.createElement("span");Te.className="bp-plan-sep",q.append(Oe,Ge,He,Je,Te)}let me=(t.copper_layers??[]).length>0?(t.copper_layers??[]).map((ie)=>ie.layer):ne.map((ie)=>ie.layer);if(me.length>0){let ie=document.createElement("span");ie.className="bp-dim",ie.textContent=m("gpui.mgmt.plan.layer.short","Layer"),q.appendChild(ie),q.appendChild(T(`${D} ${this.planMoveLayerOpen?"▴":"▾"}`,this.planMoveLayerOpen,"mgmt-plan-move-toggle",()=>{this.planMoveLayerOpen=!this.planMoveLayerOpen,this.render()}))}if(I.appendChild(q),this.planMoveLayerOpen&&me.length>0){let ie=document.createElement("div");ie.className="bp-plan-ins-row";for(let Oe of me){let Ge=wt(Oe,t.copper_layers,le);ie.appendChild(T(Ge,Oe===E,`mgmt-plan-move-${Oe}`,()=>{if(this.planMoveLayerOpen=!1,Oe!==E)he(x.id,{layer:Oe});else this.render()}))}I.appendChild(ie)}}if(this.planNoteOpen){let q=document.createElement("form");q.className="bp-plan-note-form";let me=document.createElement("input");me.type="text",me.className="bp-plan-note-input",me.setAttribute("data-testid","mgmt-plan-note-input"),me.placeholder=m("gpui.mgmt.plan.note.placeholder","Steering note for router…");let ie=document.createElement("button");ie.type="submit",ie.className="primary bp-mgmt-btn bp-plan-mini-btn",ie.setAttribute("data-testid","mgmt-plan-note-submit"),ie.textContent=m("gpui.mgmt.plan.addnote","Add note"),q.append(me,ie),q.addEventListener("submit",(Oe)=>{Oe.preventDefault();let Ge=me.value.trim();if(!Ge)return;me.value="",this.planNoteOpen=!1;let He=typeof t.revision==="number"?t.revision:void 0;this.render(),n("plan.update",{ops:[{op:"note",target:x.id,text:Ge}],...He!==void 0?{base:He}:{}})}),I.appendChild(q)}if(this.planViewMode!=="list"&&!x.locked){let q=document.createElement("div");q.className="bp-plan-hint",q.textContent=m("gpui.mgmt.plan.hint","Drag waypoints to steer · Click + on edge to insert · Right-click vertex to remove"),I.appendChild(q)}e.appendChild(I)}}let ce=document.createElement("div");ce.className="bp-mgmt-rows"+(this.planViewMode==="split"?" bp-plan-split-list":""),ce.setAttribute("data-testid","mgmt-plan-rows");let te=m("gpui.mgmt.plan.done","done"),we=fs(this.planViewMode,ne,R);if(this.planViewMode==="split"&&we.length===0){let E=document.createElement("div");E.className="bp-dim",E.style.padding="6px 8px",E.style.fontSize="11px",E.textContent=m("gpui.mgmt.plan.noitems","No corridors or planes on this layer"),ce.appendChild(E)}for(let E of we){let x=E.items??[],D=wt(E.layer,t.copper_layers,le)||E.layer;if(this.planViewMode==="split"){if(we.length>1){let I=document.createElement("div");I.className="bp-plan-split-divider";let J=E.role==="power"||E.role==="plane",oe=document.createElement("span");oe.className="bp-plan-card-bar "+(J?"pwr":"sig");let Ee=document.createElement("span");Ee.className="bp-mgmt-strong",Ee.textContent=D;let Ce=document.createElement("span");Ce.className="bp-dim",Ce.textContent=`${E.done??0}/${x.length} ${te}`,I.append(oe,Ee,Ce),ce.appendChild(I)}}else{let I=document.createElement("div");I.className="bp-mgmt-group-head bp-plan-layer-head";let J=document.createElement("div");J.className="bp-mgmt-row-line";let oe=document.createElement("span");oe.className="bp-mgmt-strong",oe.textContent=D;let Ee=document.createElement("span");if(Ee.className="bp-dim bp-mgmt-flex1",Ee.textContent=`${E.role?`${E.role} · `:""}${E.done??0}/${x.length} ${te}`,J.append(oe,Ee),E.status!=="approved"&&x.length>0){let Ce=document.createElement("button");Ce.type="button",Ce.className="bp-mgmt-btn",Ce.textContent=m("gpui.mgmt.plan.layer","Approve layer"),Ce.addEventListener("click",()=>n("plan.approve",{layer:E.layer,ids:[],approve:!0}));let O=document.createElement("button");O.type="button",O.className="bp-mgmt-btn",O.textContent=m("gpui.mgmt.plan.reject","Reject"),O.addEventListener("click",()=>n("plan.approve",{layer:E.layer,ids:[],approve:!1})),J.append(Ce,O)}if(I.appendChild(J),E.stackup){let Ce=document.createElement("div");Ce.className="bp-plan-layer-stackup",Ce.textContent=E.stackup,I.appendChild(Ce)}ce.appendChild(I)}for(let I of x){if(this.planHideDone&&rs(I))continue;let J=this.planSelectedId===I.id,oe=document.createElement("div");oe.className="bp-mgmt-row bp-plan-row"+(J?" active":""),oe.setAttribute("data-testid",`mgmt-plan-row-${I.id}`);let Ee=document.createElement("div");Ee.className="bp-mgmt-row-line";let Ce=document.createElement("span");Ce.className=`bp-plan-swatch bp-plan-st-${I.state||"proposed"}`,Ce.style.setProperty("--swatch-color",I.color||"#8a8a8a");let O=document.createElement("span");O.className="bp-mgmt-flex1"+(I.state==="blocked"||I.state==="failed"?" bp-tone-bad":I.state==="edited"?" bp-tone-warn":I.state==="rejected"||I.state==="routed"||I.state==="verified"?" bp-dim":""),O.textContent=`${I.name||I.id}${I.locked?" \uD83D\uDD12":""}`;let X=[];if(I.kind==="plane"){if(I.reference)X.push(m("gpui.mgmt.plan.reference","over {layer}",{layer:I.reference}))}else{let q=I.nets??0;X.push(q===1?m("web.plan.net.one","1 net"):m("web.plan.nets","{n} nets",{n:q}))}if(typeof I.width==="number"&&Number.isFinite(I.width))X.push(`${I.width.toFixed(2)}mm`);if(I.impedance)X.push(I.impedance);let Me=X.join(" · "),Ve=document.createElement("span");if(Ve.className="bp-plan-mark "+(I.state==="blocked"||I.state==="failed"?"bp-tone-bad":I.state==="verified"||I.state==="routed"?"bp-tone-ok":I.state==="approved"?"bp-tone-accent":"bp-dim"),Ve.textContent=os(I),Ee.append(Ce,O,Ve),I.state==="proposed"||I.state==="edited"){let q=document.createElement("button");q.type="button",q.className="bp-mgmt-btn",q.textContent="✓",q.title=m("gpui.mgmt.plan.layer","Approve layer"),q.addEventListener("click",(ie)=>{ie.stopPropagation(),n("plan.approve",{layer:"",ids:[I.id],approve:!0})});let me=document.createElement("button");me.type="button",me.className="bp-mgmt-btn",me.textContent="✗",me.title=m("gpui.mgmt.plan.reject","Reject"),me.addEventListener("click",(ie)=>{ie.stopPropagation(),n("plan.approve",{layer:"",ids:[I.id],approve:!1})}),Ee.append(q,me)}if(oe.appendChild(Ee),Me){let q=document.createElement("div");q.className="bp-mgmt-row-sub bp-plan-detail bp-dim",q.textContent=Me,oe.appendChild(q)}if(I.state==="routing"&&typeof I.total==="number"&&I.total>0){let q=document.createElement("div");q.className="bp-plan-microbar";let me=document.createElement("div");me.className="bp-plan-microbar-fill";let ie=Math.max(0,Math.min(100,Math.round((I.routed??0)/I.total*100)));me.style.width=`${ie}%`,q.appendChild(me),oe.appendChild(q)}if(I.problem_text){let q=document.createElement("div");q.className="bp-plan-problem",q.textContent=I.problem_text,oe.appendChild(q)}oe.addEventListener("click",()=>{this.planSelectedId=I.id,n("plan.focus",{id:I.id}),this.render()}),ce.appendChild(oe)}}if(this.planViewMode!=="list"){if(!this.planCanvas)this.planCanvas=new $n({onSelect:(I)=>{if(this.planSelectedId=I,!I)this.planNoteOpen=!1;this.render()},onFocusItem:(I)=>{n("plan.focus",{id:I})},onDragEnd:()=>{if(this.planRenderDeferred)this.planRenderDeferred=!1,this.render()},onCommitFields:(I,J)=>{(this.planCommitFields??he)(I,J)},onApproveLayer:(I,J)=>{n("plan.approve",{layer:I,ids:[],approve:J})},onQuickApprove:(I,J)=>{n("plan.approve",{layer:"",ids:I,approve:J})}});let E=this.panelEl.parentElement?.classList.contains("bp-has-viewer")===!1,x=this.planExpanded||this.panelEl.clientWidth>=540||E;this.planCanvas.update({gridMode:this.planGridMode,syncZoom:this.planSyncZoom,shownLayers:R,selectedId:this.planSelectedId,board:ae,bands:ve,regions:Ae,layers:le,copperLayers:t.copper_layers},x);let D=document.createElement("div");D.className="bp-plan-canvas-scroll",D.appendChild(this.planCanvas.root),e.appendChild(D)}if(this.planViewMode!=="canvas")e.appendChild(ce);if((t.draw?.bands?.length??0)>0||(t.draw?.regions?.length??0)>0){let E=document.createElement("div");E.className="bp-plan-footer",E.textContent=m("gpui.mgmt.plan.drawn","The plan's corridors and planes are drawn on the board while this panel is open. Close it to hide them."),e.appendChild(E)}return e}renderFab(){let e=document.createElement("div");e.className="bp-mgmt-body";let t=this.getPanelData("fab");if(!t)return e.appendChild(this.makeEmpty("Reading the fab's profile…")),e;if(t.error){let w=document.createElement("div");return w.className="bp-mgmt-note bp-tone-warn",w.textContent=t.error,e.appendChild(w),e}let n=(w,k={})=>{let A=this.watchGen,N=this.project;this.fabStatus="",this.cb.hub.rpc("fab.profile",{pro:N,action:w,...k}).catch((L)=>{if(A!==this.watchGen||N!==this.project)return;this.fabStatus=L instanceof Error?L.message:"Fab action failed",this.render()})},i=document.createElement("div");i.className="bp-mgmt-head";let s=document.createElement("span");s.className="bp-mgmt-strong",s.textContent=m("gpui.mgmt.fab.thefab","The fab");let r=document.createElement("span");r.className="bp-dim bp-mgmt-flex1",r.textContent=`rev ${t.rev??0}${t.updated?` · ${t.updated}`:""}${t.board?` · ${t.board}`:""} · ${ds(t.tier??"")}`;let o=document.createElement("button");if(o.type="button",o.className="bp-mgmt-btn",o.textContent=m("gpui.mgmt.fab.refresh","Refresh"),o.addEventListener("click",()=>n("refresh")),i.append(s,r,o),e.appendChild(i),this.fabStatus){let w=document.createElement("div");w.className="bp-mgmt-note bp-tone-bad",w.textContent=this.fabStatus,e.appendChild(w)}let a=document.createElement("div");a.className="bp-mgmt-rows",a.setAttribute("data-testid","mgmt-fab-rows");let c=t.review,p=document.createElement("div");p.className="bp-mgmt-row";let l=document.createElement("div");l.className="bp-mgmt-row-line";let h=document.createElement("span"),d=(c?.counts?.error??0)>0;if(h.className="bp-mgmt-flex1 "+(d?"bp-tone-bad":"bp-dim"),h.textContent=c?.running?"Reviewing the design…":c?.at==null?"No design review yet":`${c.counts?.error??0} must-fix · ${c.counts?.warning??0} should-fix · ${c.counts?.info??0} notes${c.scope?` (${c.scope})`:""}`,l.appendChild(h),c?.at!=null){let w=document.createElement("button");w.type="button",w.className="bp-mgmt-btn",w.textContent=m("gpui.mgmt.fab.findings","Findings"),w.addEventListener("click",()=>this.togglePanel("checks")),l.appendChild(w)}if(!c?.running){let w=document.createElement("button");w.type="button",w.className="bp-mgmt-btn",w.textContent=m("gpui.mgmt.fab.reviewbtn","Review"),w.addEventListener("click",()=>n("review")),l.appendChild(w)}if(c?.judge){let w=document.createElement("button");w.type="button",w.className="bp-mgmt-btn",w.textContent=m("gpui.mgmt.fab.judge","Datasheets"),w.addEventListener("click",()=>{if(c.judge)this.cb.onSendText(c.judge)}),l.appendChild(w)}p.appendChild(l),a.appendChild(p);let u=cs(t.drc?.state??""),f=document.createElement("div");f.className="bp-mgmt-row";let g=document.createElement("div");g.className="bp-mgmt-row-line";let v=document.createElement("span");if(v.className="bp-mgmt-flex1 "+(u.button?"bp-tone-warn":"bp-dim"),v.textContent=u.text,g.appendChild(v),u.button){let w=document.createElement("button");w.type="button",w.className="bp-mgmt-btn",w.textContent=u.button,w.addEventListener("click",()=>n("drc")),g.appendChild(w)}f.appendChild(g),a.appendChild(f);for(let w of t.conflicts??[]){let k=document.createElement("div");k.className="bp-mgmt-row bp-tone-bad",k.textContent=w,a.appendChild(k)}for(let w of t.suggestions??[]){let k=document.createElement("div");k.className="bp-mgmt-row";let A=document.createElement("div");A.className="bp-mgmt-row-line";let N=document.createElement("span");N.className="bp-mgmt-flex1 bp-tone-warn",N.textContent=`${w.label||w.key}: board ${w.project??"?"} mm, fab ${w.fab??"?"} mm`;let L=document.createElement("button");L.type="button",L.className="bp-mgmt-btn",L.textContent=m("gpui.mgmt.fab.apply","Apply"),L.addEventListener("click",()=>n("apply",{key:w.key})),A.append(N,L),k.appendChild(A),a.appendChild(k)}if(t.stackup?.chosen){let w=document.createElement("div");w.className="bp-mgmt-row";let k=document.createElement("div");k.className="bp-mgmt-row-line";let A=t.stackup.by==="proposed",N=document.createElement("span");if(N.className="bp-mgmt-flex1 "+(A?"bp-tone-warn":"bp-dim"),N.textContent=`${A?"Proposed: ":""}${t.stackup.chosen}${t.stackup.outer_50_mm?` (50Ω ${t.stackup.outer_50_mm} mm)`:""}`,k.appendChild(N),A){let L=t.stackup.chosen,B=document.createElement("button");B.type="button",B.className="bp-mgmt-btn",B.textContent=m("gpui.mgmt.fab.use","Use"),B.addEventListener("click",()=>n("stackup",{id:L})),k.appendChild(B)}w.appendChild(k),a.appendChild(w)}if(Array.isArray(t.changed)&&t.changed.length>0){let w=document.createElement("div");w.className="bp-mgmt-row";let k=document.createElement("div");k.className="bp-mgmt-row-line";let A=document.createElement("span");A.className="bp-mgmt-flex1 bp-tone-warn",A.textContent=m("gpui.mgmt.fab.changed","Changed since you last looked");let N=document.createElement("button");N.type="button",N.className="bp-mgmt-btn",N.textContent=m("gpui.mgmt.fab.seen","Seen"),N.addEventListener("click",()=>n("seen")),k.append(A,N),w.appendChild(k);for(let L of t.changed.slice(0,12)){let B=document.createElement("div");B.className="bp-mgmt-faint",B.textContent=L,w.appendChild(B)}a.appendChild(w)}let y=Array.isArray(t.limits)?t.limits:[];if(y.length>0){let w=document.createElement("div");w.className="bp-mgmt-group-head";let k=document.createElement("span");k.className="bp-mgmt-flex1",k.textContent=m("gpui.mgmt.fab.limit","Limit");let A=document.createElement("span");A.className="bp-mgmt-col",A.textContent=m("gpui.mgmt.fab.free","Base price");let N=document.createElement("span");N.className="bp-mgmt-col",N.textContent=m("gpui.mgmt.fab.extra","Costs more");let L=document.createElement("span");L.className="bp-mgmt-col bp-mgmt-col-read",L.textContent=m("gpui.mgmt.fab.readcol","Read"),w.append(k,A,N,L),a.appendChild(w);for(let T of y){let H=document.createElement("div");H.className="bp-mgmt-row";let F=document.createElement("div");F.className="bp-mgmt-row-line";let P=document.createElement("span");P.className="bp-mgmt-flex1"+(T.changed?" bp-tone-warn":T.inherited?" bp-dim":""),P.textContent=`${T.changed?"• ":""}${T.label??""}`;let K=document.createElement("span");K.className="bp-mgmt-col",K.textContent=T.free?.text||"—";let ae=document.createElement("span");ae.className="bp-mgmt-col bp-dim",ae.textContent=T.extra?.text||"—";let re=T.free&&typeof T.free==="object"?T.free:T.extra,ve=re?.fetched??"",Ae=Boolean(ve)&&re?.confidence!=="published",ke=ve?Ae?`${ve}*`:ve:"—",ne=re?.source??"",le;if(ne.startsWith("https://")&&ve){let R=document.createElement("a");R.className="bp-mgmt-col bp-mgmt-col-read bp-mgmt-read-link",R.href=ne,R.target="_blank",R.rel="noopener noreferrer",R.textContent=ke,le=R}else{let R=document.createElement("span");R.className="bp-mgmt-col bp-mgmt-col-read bp-mgmt-faint",R.textContent=ke,le=R}F.append(P,K,ae,le),H.appendChild(F),a.appendChild(H)}let B=document.createElement("div");B.className="bp-mgmt-note bp-mgmt-faint",B.textContent=m("gpui.mgmt.fab.derived","* worked out from the fab's page. Dimmed: the rigid board's value. A date opens the source page."),a.appendChild(B)}return e.appendChild(a),e}makeEmpty(e){let t=document.createElement("div");return t.className="bp-mgmt-note bp-mgmt-faint",t.textContent=e,t}}var ho={trs:(e)=>e,t:(e,t)=>t},mo=new Set(["/settle"]);function Ss(e,t){let n=t.trim().toLowerCase();if(!n)return 1;let i=e.toLowerCase();if(i.startsWith(n))return 3;if(i.split(/[^a-z0-9]+/i).some((o)=>o.startsWith(n)))return 2;let r=0;for(let o=0;o0||e.status==="waiting")return{urgency:3,want:"waiting"};if(e.status==="asking")return{urgency:2,want:"question"};if(e.status==="failed"||e.state==="failed")return{urgency:1,want:"failed"};return{urgency:0,want:""}}function Ls(e){let t=e.status||e.state;if(t==="active"||t==="working")return"bp-dot-work";if(t==="finished")return"bp-dot-done";if(t==="waiting"||t==="asking"||t==="blocked"||t==="failed"||(e.waiting??0)>0)return"bp-dot-need";return"bp-dot-idle"}function Ns(e,t){let n=t.trim().split(/\s+/)[0]?.toLowerCase()??"";if(!n)return null;let i=e.toLowerCase();if(i.length!==e.length)return null;let s=i.indexOf(n);if(s<0)return null;return[s,s+n.length]}function Ms(e,t=ho){let{t:n,trs:i}=t,s=[],r=new Map;for(let a of e.projects)r.set(a.id,a.title||a.id);let o=e.threads.find((a)=>a.id===e.selectedThreadId)??null;for(let a of e.railItems){if(a.state==="disabled"||a.id==="commands")continue;if(!o&&a.id!=="terminal")continue;s.push({label:i(a.label),place:a.id==="terminal"?"":"viewer",kind:"action",shortcut:a.key?a.key.toUpperCase():void 0,action:{type:"rail",id:a.id}})}if(o){if(s.push({label:o.pinned?n("menu.unpin","Unpin"):n("menu.pin","Pin"),place:"",kind:"action",action:{type:"thread-act",action:o.pinned?"unpin":"pin"}}),s.push({label:o.settled?n("phone.unsettle","Unsettle"):n("menu.settle","Settle"),place:"",kind:"action",action:{type:"thread-act",action:o.settled?"unsettle":"settle"}}),s.push({label:o.archived?n("palette.unarchive","Unarchive"):n("palette.archive","Archive"),place:"",kind:"action",action:{type:"thread-act",action:o.archived?"unarchive":"archive"}}),o.project==="chats")s.push({label:n("chats.move","Move to project…"),place:"",kind:"action",action:{type:"move-project"}});s.push({label:n("sheet.rename","Rename thread"),place:"",kind:"action",action:{type:"rename"}}),s.push({label:n("gpui.previous.thread","Previous thread"),place:"",kind:"action",action:{type:"prev-thread"}}),s.push({label:n("gpui.next.thread","Next thread"),place:"",kind:"action",action:{type:"next-thread"}})}if(o)for(let a of e.commands){if(!a.word)continue;let c=mo.has(a.word.toLowerCase());s.push({label:a.label?`${a.word} — ${a.label}`:a.word,place:a.desc||"command",kind:"command",action:{type:"command",word:a.word,runDirectly:c}})}s.push({label:n("gpui.improvements","Improvements"),place:"",kind:"action",action:{type:"improvements"}}),s.push({label:n("palette.settings","Settings"),place:"",kind:"action",action:{type:"settings"}}),s.push({label:n("gpui.fold.or.unfold.the.sidebar","Fold or unfold the sidebar"),place:"",kind:"action",action:{type:"sidebar"}}),s.push({label:n("chats.new.noproject","New chat (no project)"),place:"",kind:"action",action:{type:"new-chat"}});for(let a of e.projects)s.push({label:`New thread in ${a.title||a.id}`,place:"",kind:"action",action:{type:"new-thread",projectId:a.id}});for(let a of e.threads){let{urgency:c,want:p}=As(a);s.push({label:a.title||"Untitled thread",place:a.project==="chats"?n("chats.title","Chats"):a.project?r.get(a.project)??"":"",kind:"thread",urgency:c,want:p,dotClass:Ls(a),action:{type:"thread",id:a.id}})}for(let a of e.bots){if(!a.name||!a.thread)continue;s.push({label:a.name,place:"",kind:"bot",action:{type:"thread",id:a.thread}})}return s}function Ts(e,t,n,i=[],s=10,r=14){let o=t.trim(),a=o.length===0,c=e.slice();if(n?.threads&&n.threads.length>0){let d=new Map;for(let f of i)d.set(f.id,f.title||f.id);let u=new Set;for(let f of c)if(f.action.type==="thread")u.add(f.action.id);for(let f of n.threads){if(!f.id||u.has(f.id))continue;u.add(f.id);let{urgency:g,want:v}=As(f);c.push({label:f.title||"Untitled thread",place:f.project?d.get(f.project)??"":"",kind:"thread",urgency:g,want:v,dotClass:Ls(f),action:{type:"thread",id:f.id}})}}let p=[];for(let d=0;d0)p.push({score:v,index:d,item:u})}p.sort((d,u)=>{if(a){let v=(u.item.urgency??0)-(d.item.urgency??0);if(v!==0)return v}if(u.score!==d.score)return u.score-d.score;let f=d.item.kind==="thread"?0:1,g=u.item.kind==="thread"?0:1;if(f!==g)return f-g;return d.index-u.index});let l=new Set,h=[];for(let d of p){let u=`${d.item.label}\x00${d.item.place}\x00${d.item.kind}`;if(l.has(u))continue;if(l.add(u),h.push(d.item),h.length>=s)break}if(n?.messages&&n.messages.length>0&&h.length{if(o.target===t)this.close()}),s.addEventListener("input",()=>{this.query=s.value,this.activeIdx=0,this.renderList(),this.scheduleSearch()}),s.addEventListener("keydown",(o)=>{if(o.key==="Escape")o.preventDefault(),o.stopPropagation(),this.close();else if(o.key==="ArrowDown"){if(o.preventDefault(),this.listed.length>0)this.activeIdx=(this.activeIdx+1)%this.listed.length,this.renderList(!0)}else if(o.key==="ArrowUp"){if(o.preventDefault(),this.listed.length>0)this.activeIdx=(this.activeIdx-1+this.listed.length)%this.listed.length,this.renderList(!0)}else if(o.key==="Enter")o.preventDefault(),this.runAt(this.activeIdx)}),this.backdrop=t,this.inputEl=s,this.listEl=r,this.root.appendChild(t),this.renderList(),this.query.trim().length>=2)this.scheduleSearch();s.focus()}close(){if(this.searchTimer!==null)window.clearTimeout(this.searchTimer),this.searchTimer=null;if(this.searchGen++,this.backdrop)this.backdrop.remove(),this.backdrop=null,this.inputEl=null,this.listEl=null;this.prevFocus?.focus(),this.prevFocus=null}scheduleSearch(){if(this.searchTimer!==null)window.clearTimeout(this.searchTimer),this.searchTimer=null;let e=this.query.trim();if(e.length<2){this.searchHits=null,this.searchHitsQuery="";return}if(e===this.searchHitsQuery)return;let t=++this.searchGen;this.searchTimer=window.setTimeout(()=>{this.searchTimer=null,this.cb.onSearch(e).then((n)=>{if(t!==this.searchGen||!this.backdrop)return;if(this.query.trim()!==e)return;this.searchHits=n,this.searchHitsQuery=e,this.renderList()}).catch(()=>{})},180)}runAt(e){let t=this.listed[e];if(!t)return;this.close(),this.cb.onExecute(t.action)}renderList(e=!1){if(!this.listEl)return;let t=this.cb.getState(),n=Ms(t,{t:m,trs:fe}),i=this.query.trim()===this.searchHitsQuery?this.searchHits:null;if(this.listed=Ts(n,this.query,i,t.projects),this.activeIdx>=this.listed.length)this.activeIdx=Math.max(0,this.listed.length-1);if(this.listed.length===0){let o=document.createElement("div");o.className="bp-palette-empty",o.textContent=m("gpui.nothing.matches","Nothing matches"),this.listEl.replaceChildren(o);return}let s=document.createDocumentFragment(),r=null;for(let o=0;o0)p.appendChild(document.createTextNode(a.label.slice(0,d)));let f=document.createElement("strong");if(f.className="bp-palette-mark",f.textContent=a.label.slice(d,u),p.appendChild(f),u{if(this.activeIdx!==o)this.activeIdx=o,this.updateActiveClass()}),c.addEventListener("click",()=>this.runAt(o)),o===this.activeIdx)r=c;s.appendChild(c)}if(this.listEl.replaceChildren(s),e&&r)r.scrollIntoView({block:"nearest"})}updateActiveClass(){if(!this.listEl)return;let e=this.listEl.children;for(let t=0;t0?Math.floor(t.leadDays):0,i=[];for(let s of un(t.warnings)){let r=st(s).trim();if(r&&!i.includes(r))i.push(r)}return{project:st(t.project),root:st(t.root),intent:st(t.intent),parts:un(t.parts).map((s)=>Vn(s)).map((s)=>({name:st(s.name),kind:st(s.kind),path:st(s.path)})).filter((s)=>s.name||s.path),boards:un(t.boards).map(st).filter(Boolean),mech:un(t.mech).map((s)=>Vn(s)).map((s)=>({path:st(s.path),name:st(s.name),size:typeof s.size==="number"&&s.size>0?s.size:0})).filter((s)=>s.name||s.path),leadDays:n,warnings:i}}function Un(e){let t=[];for(let n of e.split(` +`)){let i=n.trimEnd();if(!i.trim())continue;if(t.length>=60)break;let s=i.trimStart();if(s.startsWith("#"))t.push({kind:"h",text:s.replace(/^#+/,"").trim()});else if(s.startsWith("- ")||s.startsWith("* "))t.push({kind:"li",text:s.slice(2).trim()});else t.push({kind:"p",text:s})}return t}function Bs(e){return!Un(e).some((t)=>t.kind!=="h"&&t.text.length>0)}function Rs(e){if(!Number.isFinite(e)||e<=0)return"";if(e<1024)return`${Math.floor(e)} B`;if(e<1048576)return`${(e/1024).toFixed(e<10240?1:0)} KB`;return`${(e/1048576).toFixed(1)} MB`}function Wn(e){let t=e.lastIndexOf("|");return t>=0?e.slice(t+1):e}function ye(e,t,n){let i=document.createElement(e);if(t)i.className=t;if(n!==void 0)i.textContent=n;return i}class _n{root;titleEl;rootEl;newBtn;newLbl;threadsEl;bodyEl;cb;projectId="";data=null;threads=null;error="";constructor(e,t){this.cb=t,this.root=ye("section","bp-project-home bp-hidden"),this.root.setAttribute("data-testid","project-home");let n=ye("div","bp-home-inner"),i=ye("header","bp-home-head");this.titleEl=ye("h1","bp-home-title"),this.titleEl.setAttribute("data-testid","project-home-title"),this.rootEl=ye("div","bp-home-root"),i.append(this.titleEl,this.rootEl);let s=ye("div","bp-home-bar");this.newBtn=ye("button","primary bp-home-new"),this.newBtn.type="button",this.newBtn.setAttribute("data-testid","project-home-new-thread");let r=ye("span","bp-home-new-plus","+");r.setAttribute("aria-hidden","true"),this.newLbl=ye("span","",m("thread.new","New thread")),this.newBtn.append(r,this.newLbl),this.newBtn.addEventListener("click",()=>{if(this.projectId)this.cb.onNewThread(this.projectId)}),s.appendChild(this.newBtn),this.threadsEl=ye("div","bp-home-threads"),this.bodyEl=ye("div","bp-home-body"),n.append(i,s,this.threadsEl,this.bodyEl),this.root.appendChild(n),e.appendChild(this.root)}isOpen(){return this.projectId!==""}show(e){if(this.projectId!==e.id)this.data=null,this.threads=null,this.root.scrollTop=0;this.error="",this.projectId=e.id,this.titleEl.textContent=e.title||e.id,this.root.classList.remove("bp-hidden"),this.render()}hide(){this.projectId="",this.root.classList.add("bp-hidden")}setTitle(e){if(e)this.titleEl.textContent=e}setData(e){this.data=e,this.error="",this.render()}setThreads(e){this.threads=e,this.render()}setError(e){this.error=e,this.render()}refreshLocale(){if(this.newLbl.textContent=m("thread.new","New thread"),this.isOpen())this.render()}section(e){return ye("h2","bp-home-section",e)}render(){this.rootEl.textContent=this.data?.root??"",this.rootEl.classList.toggle("bp-hidden",!this.data?.root),this.renderThreads(),this.renderBody()}renderThreads(){let e=document.createDocumentFragment(),t=this.threads;if(t){if(e.appendChild(this.section(m("gpui.projects.threads","THREADS ({n})",{n:t.length}))),t.length===0)e.appendChild(ye("div","bp-home-empty",m("gpui.no.threads.yet","No threads yet.")));for(let n of t){let i=ye("button","bp-home-row bp-home-thread"+(n.settled?" bp-dim":""));i.type="button",i.setAttribute("data-testid",`project-home-thread-${n.id}`);let s=ye("span",`bp-dot ${n.dot}`);if(n.status)s.title=n.status;let r=ye("span","bp-home-row-main",n.title||"Untitled thread"),o=ye("span","bp-home-row-faint",n.age);i.append(s,r,o),i.addEventListener("click",()=>this.cb.onOpenThread(n.id)),e.appendChild(i)}}this.threadsEl.replaceChildren(e)}renderBody(){let e=document.createDocumentFragment(),t=this.data;if(this.error){let s=ye("div","bp-home-error");s.setAttribute("data-testid","project-home-error"),s.appendChild(ye("span","",this.error));let r=ye("button","bp-btn-ghost",m("tools.retry","Retry"));r.type="button";let o=this.projectId;r.addEventListener("click",()=>this.cb.onRetry(o)),s.appendChild(r),e.appendChild(s)}if(!t){if(!this.error)e.appendChild(ye("div","bp-home-empty",m("web.home.loading","Loading project…")));this.bodyEl.replaceChildren(e);return}e.appendChild(this.section(m("gpui.goal.notes","GOAL & NOTES")));let n=ye("div","bp-home-intent");if(n.setAttribute("data-testid","project-home-intent"),Bs(t.intent))e.appendChild(ye("div","bp-home-empty",m("gpui.no.goal.yet.ask.an","No goal yet. Ask an agent to write what this project is for, or edit .backplane/intent.md.")));else{for(let s of Un(t.intent))if(s.kind==="h")n.appendChild(ye("div","bp-home-intent-h",s.text));else if(s.kind==="li"){let r=ye("div","bp-home-intent-li"),o=ye("span","bp-home-bullet","•");o.setAttribute("aria-hidden","true"),r.append(o,ye("span","",s.text)),n.appendChild(r)}else n.appendChild(ye("div","",s.text));e.appendChild(n)}let i=this.threads?.[0]?.id??"";if(t.mech.length>0)e.appendChild(this.section(m("gpui.projects.mech","MECHANICAL ({n})",{n:t.mech.length}))),t.mech.forEach((s,r)=>{let o=r===0&&t.mech.length>1,a=this.fileRow(i,"mech",`project-home-mech-${r}`);if(a.title=s.path,a.appendChild(ye("span","bp-home-row-main",s.name||s.path)),o)a.appendChild(ye("span","bp-home-row-accent",m("gpui.assembly","Assembly")));a.appendChild(ye("span","bp-home-row-faint",Rs(s.size))),e.appendChild(a)});if(t.parts.length>0){e.appendChild(this.section(m("gpui.projects.to.order","TO ORDER ({n})",{n:t.parts.length})));let s=ye("div","bp-home-order");if(s.setAttribute("data-testid","project-home-order"),t.parts.forEach((r,o)=>{let a=ye("div","bp-home-row");a.setAttribute("data-testid",`project-home-part-${o}`),a.append(ye("span","bp-home-row-main",r.name||r.path),ye("span","bp-home-row-dim",r.kind),ye("span","bp-home-row-faint",r.path)),s.appendChild(a)}),t.leadDays>0){let r=ye("div","bp-home-order-note",t.leadDays===1?m("web.home.lead.one","Lead time: 1 day"):m("web.home.lead","Lead time: {n} days",{n:t.leadDays}));r.setAttribute("data-testid","project-home-lead"),s.appendChild(r)}for(let r of t.warnings){let o=ye("div","bp-home-order-note warn",r);o.setAttribute("data-testid","project-home-warning"),s.appendChild(o)}e.appendChild(s)}if(t.boards.length>0)e.appendChild(this.section(m("gpui.projects.boards","BOARDS ({n})",{n:t.boards.length}))),t.boards.forEach((s,r)=>{let o=this.fileRow(i,"board",`project-home-board-${r}`);o.appendChild(ye("span","bp-home-row-main",s)),e.appendChild(o)});this.bodyEl.replaceChildren(e)}fileRow(e,t,n){if(!e){let s=ye("div","bp-home-row");return s.setAttribute("data-testid",n),s}let i=ye("button","bp-home-row bp-home-open");return i.type="button",i.setAttribute("data-testid",n),i.addEventListener("click",()=>this.cb.onOpenViewer(e,t)),i}}function zn(e){let t=null;if(typeof e==="string"){let i=e.trim();if(!i)return null;try{let s=JSON.parse(i);if(s&&typeof s==="object"&&!Array.isArray(s))t=s}catch{return null}}else if(e&&typeof e==="object"&&!Array.isArray(e))t=e;if(!t)return null;let n=typeof t.head==="string"?t.head.trim():"";if(!n)return null;return{reason:typeof t.reason==="string"?t.reason:"",head:n,text:typeof t.text==="string"?t.text:"",button:typeof t.button==="string"&&t.button.trim()?t.button:"Open Settings → Accounts",url:typeof t.url==="string"&&t.url.trim()?t.url:"backplane://settings/accounts"}}function uo(e){return e.startsWith("No AI provider connected yet.")}function js(e,t){if(t==="no_provider")return!0;if(t)return!1;return uo(e)}function rt(e){return typeof e==="string"?e:""}function qn(e){return typeof e==="number"&&Number.isFinite(e)?e:0}function Hs(e){let t=e&&typeof e==="object"?e:{},n=[];for(let i of Array.isArray(t.notes)?t.notes:[]){if(!i||typeof i!=="object")continue;let s=i,r=rt(s.id);if(!r)continue;n.push({id:r,said:qn(s.said),gesture:rt(s.gesture),words:rt(s.words),model:rt(s.model),conf:typeof s.conf==="number"&&Number.isFinite(s.conf)?s.conf:null,unsure:rt(s.unsure),state:rt(s.state),error:rt(s.error),thread:rt(s.thread),play:rt(s.play),heard:qn(s.heard)})}return{total:Math.max(qn(t.total),n.length),notes:n,busy:rt(t.busy)}}function Ds(e){let t=/\/ring\/audio\/(n[0-9a-f]{16})(?:\.m4a)?\?k=([0-9a-fA-F]+)$/.exec(e);return t?`/ring/audio/${t[1]}?k=${t[2]}`:""}function Fs(e){if(!e.model)return{key:"web.ring.not.heard",fallback:"Not heard"};if(e.model==="ring")return{key:"web.ring.app.words",fallback:"The Pebble app's words"};if(e.conf!==null)return{key:"web.ring.heard.by.sure",fallback:"Heard by {model}, {conf}% sure",vars:{model:e.model,conf:Math.round(e.conf)}};return{key:"web.ring.heard.by",fallback:"Heard by {model}",vars:{model:e.model}}}function $s(e,t){if(t)return{key:"web.ring.state.busy",fallback:"being heard now"};switch(e){case"sent":return{key:"web.ring.state.sent",fallback:"given to Pebble"};case"new":return{key:"web.ring.state.new",fallback:"waiting to be heard"};case"heard":return{key:"web.ring.state.heard",fallback:"waiting to go to Pebble"};case"failed":return{key:"web.ring.state.failed",fallback:"not given to Pebble"};default:return{key:"",fallback:e}}}function Os(e,t,n){if(e<=0)return{key:"ring.no.recordings.yet",fallback:"No recordings yet."};if(n.trim())return{key:"web.ring.found",fallback:"{found} of {total} have “{q}”.",vars:{found:t,total:e,q:n.trim()}};return e===1?{key:"web.ring.count.one",fallback:"1 recording"}:{key:"web.ring.count",fallback:"{n} recordings",vars:{n:e}}}var Gs="http://www.w3.org/2000/svg",Vs={terminal:["M4 17l6-6-6-6","M12 19h8"],search:["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z","M21 21l-4.3-4.3"],"circuit-board":["M3 3h18v18H3z","M9 3v6h6","M9 21v-6","M15 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4z","M9 15a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"],cpu:["M6 6h12v12H6z","M9 2v4","M15 2v4","M9 18v4","M15 18v4","M2 9h4","M2 15h4","M18 9h4","M18 15h4"],box:["M21 16V8l-9-5-9 5v8l9 5 9-5z","M3.3 7L12 12l8.7-5","M12 22V12"],gauge:["M12 14l4-4","M3.3 19a10 10 0 1 1 17.4 0"],"file-stack":["M16 2H6v12h10V2z","M20 6v12H10","M4 18h10v4H4z"],"layout-panel-left":["M3 3h18v18H3z","M10 3v18"],layers:["M12 2L2 7l10 5 10-5-10-5z","M2 12l10 5 10-5","M2 17l10 5 10-5"],wrench:["M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"],folder:["M3 6h6l2 2h10v11H3z"],diff:["M12 5v10","M7 10h10","M7 19h10"],"circle-check":["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M9 12l2 2 4-4"],globe:["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M2 12h20","M12 2a15 15 0 0 1 0 20 15 15 0 0 1 0-20z"]};function bo(e){let t=document.createElementNS(Gs,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","18"),t.setAttribute("height","18"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.75"),t.setAttribute("stroke-linecap","square"),t.setAttribute("stroke-linejoin","miter"),t.setAttribute("aria-hidden","true");let n=Vs[e]??Vs.folder;for(let i of n){let s=document.createElementNS(Gs,"path");s.setAttribute("d",i),t.appendChild(s)}return t}class Kn{el;items=[];activeId="";onPress;pagesRo=null;constructor(e,t){this.el=e,this.onPress=t,this.render()}setItems(e){this.items=e.slice(),this.render()}setActive(e){this.activeId=e,this.render()}renderButton(e){let t=e.state==="disabled",n=!t&&(e.state==="on"||this.activeId!==""&&e.id===this.activeId),i=fe(e.label),s=e.why?fe(e.why):"",r=document.createElement("button");if(r.type="button",r.className="bp-rail-btn"+(n?" active":"")+(t?" disabled":""),r.disabled=t,r.setAttribute("aria-pressed",n?"true":"false"),t){if(r.title=s||i,s)r.setAttribute("data-why",s)}else r.title=e.key?`${i} (${e.key.toUpperCase()})`:i;r.setAttribute("data-rail-id",e.id),r.setAttribute("data-testid",`rail-${e.id}`),r.appendChild(bo(e.icon));let o=document.createElement("span");if(o.className="bp-rail-lbl",o.textContent=i,r.appendChild(o),!t)r.addEventListener("click",()=>this.onPress(e.id));return r}render(){let e=this.items.filter((o)=>o.group!=="tools"),t=this.items.filter((o)=>o.group==="tools"),n=document.createElement("div");n.className="bp-rail-pages";let i;for(let o of e){if(i!==void 0&&o.group!==i){let a=document.createElement("div");a.className="bp-rail-rule",n.appendChild(a)}i=o.group,n.appendChild(this.renderButton(o))}let s=()=>{let o=n.scrollLeft>2,a=n.scrollLeft+n.clientWidth0){let o=document.createElement("div");o.className="bp-rail-tools";for(let a of t)o.appendChild(this.renderButton(a));r.appendChild(o)}this.el.replaceChildren(r)}}var go=new Set(["resume","raise","retry","move","signin"]);function Jn(e){if(!e||typeof e!=="object")return null;let t=e,n=(r)=>typeof r==="string"?r:"",i=(Array.isArray(t.actions)?t.actions:[]).filter((r)=>Boolean(r)&&typeof r==="object").map((r)=>({label:n(r.label),act:n(r.act),room:n(r.room),thread:n(r.thread)})),s={line:n(t.line),why:n(t.why),actions:i};return s.line||i.length?s:null}function bn(e,t){if(e.act==="board")return t&&e.room?{kind:"board",room:e.room}:null;if(e.act==="open")return e.thread?{kind:"thread",id:e.thread}:null;if(go.has(e.act)){let n={room:e.room,action:e.act};if(e.thread)n.thread=e.thread;return{kind:"call",method:"swarm.act",params:n}}return null}function Us(e){let t=e&&typeof e==="object"?e.open:void 0;if(typeof t!=="string")return null;let n=t.indexOf(":"),i=n<0?"":t.slice(n+1);if(!i)return null;if(t.startsWith("account:"))return{kind:"account",id:i};if(t.startsWith("thread:"))return{kind:"thread",id:i};return null}var Xn=[{id:"general",label:"General"},{id:"ai",label:"Agents and tools"},{id:"connect",label:"Connect"}],Rt=[{id:"appearance",group:"general",title:"Appearance",subtitle:"Kept in this browser only. Never sent to the hub.",icon:"sun",keywords:["theme","dark","light","auto","color","language","locale","english","espanol","japanese"]},{id:"providers",group:"ai",title:"AI providers",subtitle:"Account sign-ins live in the desktop or mobile app.",icon:"cpu",keywords:["accounts","claude","codex","antigravity","grok","openai","anthropic","signin","login","model"]},{id:"ring",group:"ai",title:"Ring",subtitle:"Voice notes from your Pebble ring. Its webhook is set up in the desktop or mobile app.",icon:"mic",keywords:["pebble","index","voice","note","notes","recording","recordings","play","hear","transcribe","search"]},{id:"devices",group:"connect",title:"Devices & browser",subtitle:"This browser session and paired devices on this hub.",icon:"link",keywords:["sign out","logout","session","cookie","revoke","paired","phone","browser","pair"]},{id:"home",group:"connect",title:"Home machine",subtitle:"Which machine hosts your always-on hub and bots.",icon:"globe",keywords:["host","boat","move","online","away","queued","linked"]}];function Ws(e){if(e==="dark"||e==="light"||e==="auto")return e;return"auto"}function _s(e){if(e==="en"||e==="es"||e==="ja"||e==="auto")return e;return"auto"}function qt(e,t){if(e==="dark"||e==="light")return e;return t==="light"?"light":"dark"}function zs(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean)}function Yn(e,t){if(t.length===0)return!0;let n=e.toLowerCase();return t.every((i)=>n.includes(i))}function qs(e,t){let n=zs(t);if(n.length===0)return[];return e.filter((i)=>{let s=[i.groupLabel,i.pageTitle,i.rowTitle,i.rowDetail,...i.keywords??[]].join(" ");return Yn(s,n)})}function Qn(e,t,n){let i=zs(n);if(i.length===0)return e.map((o)=>({page:o,hits:[]}));let s=new Map(Xn.map((o)=>[o.id,o.label])),r=[];for(let o of e){let c=t.filter((l)=>l.pageId===o.id).filter((l)=>Yn([l.rowTitle,l.rowDetail,l.pageTitle,l.groupLabel,...l.keywords??[]].join(" "),i));if(Yn([s.get(o.group)??"",o.title,o.subtitle,...o.keywords].join(" "),i)||c.length>0){let l=[];for(let h of c){if(!l.includes(h.rowTitle))l.push(h.rowTitle);if(l.length>=2)break}r.push({page:o,hits:l})}}return r}function Zn(e){return e.key?m(e.key,e.fallback,e.vars):e.fallback}function fo(e){let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("width","15"),n.setAttribute("height","15"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.75"),n.setAttribute("stroke-linecap","square"),n.setAttribute("stroke-linejoin","miter"),n.setAttribute("aria-hidden","true");let i=(s,r)=>{let o=document.createElementNS("http://www.w3.org/2000/svg",s);for(let[a,c]of Object.entries(r))o.setAttribute(a,c);n.appendChild(o)};switch(e){case"sun":i("circle",{cx:"12",cy:"12",r:"4"}),i("path",{d:"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32 1.41 1.41M2 12h2m16 0h2M4.93 19.07l1.41-1.41m11.32-11.32 1.41-1.41"});break;case"cpu":i("rect",{x:"5",y:"5",width:"14",height:"14"}),i("rect",{x:"9",y:"9",width:"6",height:"6"}),i("path",{d:"M9 2v3m6-3v3M9 19v3m6-3v3M2 9h3m-3 6h3M19 9h3m-3 6h3"});break;case"link":i("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),i("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"});break;case"mic":i("rect",{x:"9",y:"2",width:"6",height:"12"}),i("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8"});break;case"globe":i("circle",{cx:"12",cy:"12",r:"10"}),i("path",{d:"M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"});break}return n}function vo(){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","13"),t.setAttribute("height","13"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.75"),t.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("cx","11"),n.setAttribute("cy","11"),n.setAttribute("r","7");let i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d","m20 20-3.5-3.5"),t.append(n,i),t}function gn(e,t){switch(e){case"general":return m("gpui.settings.group.general",t);case"ai":return m("gpui.settings.group.agents",t);case"connect":return m("native.pair.connect",t)}}function gt(e,t){switch(e){case"appearance":return m("settings.appearance",t);case"providers":return m("web.settings.providers",t);case"ring":return m("ring.ring",t);case"devices":return t;case"home":return m("home.machine",t)}}class ei{backdrop;titleEl;badgeEl;closeBtn;navListEl;searchInput;searchClearBtn;paneEl;cb;openState=!1;activePage="appearance";forceProviders=!1;query="";searchBrowseAll=!1;devicesLoaded=!1;devicesLoading=!1;devicesRows=[];devicesError="";loadGen=0;ringLoaded=!1;ringLoading=!1;ringList={total:0,notes:[],busy:""};ringCountEl=null;ringErrorEl=null;ringRows=new Map;ringShownQuery="";ringError="";ringQuery="";ringDraft="";ringGen=0;ringBusy=new Set;ringPolls=0;ringTimers=[];constructor(e,t){this.cb=t,this.backdrop=document.createElement("div"),this.backdrop.className="bp-modal-backdrop bp-hidden",this.backdrop.setAttribute("data-testid","settings-modal");let n=document.createElement("div");n.className="bp-modal bp-settings-modal",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-labelledby","bp-settings-title");let i=document.createElement("div");i.className="bp-modal-head";let s=document.createElement("div");s.className="bp-settings-head-title",this.titleEl=document.createElement("h2"),this.titleEl.id="bp-settings-title",this.titleEl.textContent=m("palette.settings","Settings"),this.badgeEl=document.createElement("span"),this.badgeEl.className="bp-settings-badge",this.badgeEl.textContent="Browser",s.append(this.titleEl,this.badgeEl),this.closeBtn=document.createElement("button"),this.closeBtn.type="button",this.closeBtn.className="icon",this.closeBtn.textContent="×",this.closeBtn.setAttribute("aria-label",m("common.close","Close")),this.closeBtn.addEventListener("click",()=>this.close()),i.append(s,this.closeBtn);let r=document.createElement("div");r.className="bp-settings-body";let o=document.createElement("aside");o.className="bp-settings-nav";let a=document.createElement("div");a.className="bp-settings-search";let c=document.createElement("span");c.className="bp-settings-search-icon",c.appendChild(vo()),this.searchInput=document.createElement("input"),this.searchInput.type="text",this.searchInput.className="bp-settings-search-input",this.searchInput.placeholder="Search settings…",this.searchInput.setAttribute("aria-label","Search settings"),this.searchInput.setAttribute("data-testid","settings-search"),this.searchClearBtn=document.createElement("button"),this.searchClearBtn.type="button",this.searchClearBtn.className="bp-settings-search-clear bp-hidden",this.searchClearBtn.textContent="×",this.searchClearBtn.title="Clear search",this.searchClearBtn.setAttribute("aria-label","Clear search"),a.append(c,this.searchInput,this.searchClearBtn),this.navListEl=document.createElement("nav"),this.navListEl.className="bp-settings-nav-list",this.navListEl.setAttribute("aria-label","Settings sections"),o.append(a,this.navListEl),this.paneEl=document.createElement("div"),this.paneEl.className="bp-settings-pane",r.append(o,this.paneEl),n.append(i,r),this.backdrop.appendChild(n),this.backdrop.addEventListener("click",(p)=>{if(p.target===this.backdrop)this.close()}),this.searchInput.addEventListener("input",()=>{this.query=this.searchInput.value,this.searchBrowseAll=this.query.trim().length>0,this.syncSearchClear(),this.render()}),this.searchInput.addEventListener("keydown",(p)=>{if(p.key==="Enter"){let l=Qn(Rt,this.buildSearchItems(),this.query);if(l.length>0)p.preventDefault(),this.activePage=l[0].page.id,this.searchBrowseAll=!1,this.render()}else if(p.key==="Escape"&&this.query.trim().length>0)p.preventDefault(),p.stopPropagation(),this.clearSearch()}),this.searchClearBtn.addEventListener("click",()=>{this.clearSearch(),this.searchInput.focus()}),e.appendChild(this.backdrop)}isOpen(){return this.openState}handleEscape(){if(!this.openState)return;if(this.query.trim().length>0)this.clearSearch(),this.searchInput.focus();else this.close()}async open(e){if(this.openState=!0,e)this.activePage=e;if(this.backdrop.classList.remove("bp-hidden"),this.render(),this.loadDevices(),this.activePage==="ring")this.loadRing();window.setTimeout(()=>{if(this.openState)this.searchInput.focus()},0)}async openToAccounts(){this.forceProviders=!0,this.query="",this.searchInput.value="",this.searchBrowseAll=!1,this.syncSearchClear(),await this.open("providers")}close(){this.openState=!1,this.forceProviders=!1,this.query="",this.searchInput.value="",this.searchBrowseAll=!1,this.syncSearchClear(),this.backdrop.classList.add("bp-hidden");for(let e of this.ringTimers)window.clearTimeout(e);if(this.ringTimers=[],this.ringBusy.clear(),this.ringPolls=0,this.activePage==="ring")this.paneEl.replaceChildren()}refreshLocale(){if(this.titleEl.textContent=m("palette.settings","Settings"),this.closeBtn.setAttribute("aria-label",m("common.close","Close")),this.openState)this.render()}async refresh(){if(!this.openState)return;this.render(),await this.loadDevices()}clearSearch(){this.query="",this.searchInput.value="",this.searchBrowseAll=!1,this.syncSearchClear(),this.render()}syncSearchClear(){this.searchClearBtn.classList.toggle("bp-hidden",this.query.length===0)}async loadDevices(){let e=++this.loadGen;if(this.devicesLoading=!this.devicesLoaded,this.devicesLoading&&this.openState)this.renderPane();try{let t=await this.cb.onLoadDevices();if(e!==this.loadGen)return;this.devicesRows=t,this.devicesError="",this.devicesLoaded=!0}catch(t){if(e!==this.loadGen)return;let n=t instanceof Error&&t.message?t.message:"Not available from a browser";this.devicesError=`${n} — manage paired devices in Backplane › Settings › Devices on desktop or a paired phone.`,this.devicesRows=[],this.devicesLoaded=!0}finally{if(e===this.loadGen){if(this.devicesLoading=!1,this.openState)this.render()}}}async loadRing(){if(!this.cb.onRingList||!(this.cb.hasRing?.()??!1))return;let e=++this.ringGen;if(this.ringLoading=!this.ringLoaded,this.ringLoading)this.showRing();try{let t=await this.cb.onRingList(this.ringQuery);if(e!==this.ringGen)return;if(this.ringList=t,this.ringError="",!t.busy)this.ringBusy.clear();if(t.busy&&this.openState&&this.ringPolls<40)this.ringPolls++,this.ringLater(3000);else if(!t.busy)this.ringPolls=0}catch(t){if(e!==this.ringGen)return;this.ringError=t instanceof Error&&t.message?t.message:m("web.ring.error","Could not load recordings.")}finally{if(e===this.ringGen)this.ringLoaded=!0,this.ringLoading=!1,this.showRing()}}ringLater(e){let t=window.setTimeout(()=>{if(this.ringTimers=this.ringTimers.filter((n)=>n!==t),this.openState)this.loadRing()},e);this.ringTimers.push(t)}ringIsBusy(e){return this.ringBusy.has(e)||this.ringList.busy===e}showRing(){if(!this.openState||this.activePage!=="ring"||this.query.trim()&&this.searchBrowseAll)return;let e=this.ringList.notes.map((i)=>i.id),t=Array.from(this.ringRows.keys());if(!(this.ringCountEl?.isConnected===!0&&this.ringShownQuery===this.ringQuery&&e.length===t.length&&e.every((i,s)=>i===t[s]))){this.renderPane();return}if(this.ringCountEl)this.ringCountEl.textContent=this.ringCountLine();if(this.ringErrorEl)this.ringErrorEl.textContent=this.ringError,this.ringErrorEl.classList.toggle("bp-hidden",!this.ringError);for(let i of this.ringList.notes)this.fillRingNote(i)}ringCountLine(){return this.ringLoading?m("web.ring.loading","Loading recordings…"):Zn(Os(this.ringList.total,this.ringList.notes.length,this.ringQuery))}fillRingNote(e){let t=this.ringRows.get(e.id);if(!t)return;let n=this.ringIsBusy(e.id);t.state.className="bp-status-pill "+(n?"accent":e.state==="sent"?"ok":e.state==="failed"?"bad":"warn"),t.state.textContent=Zn($s(e.state,n)),t.words.className="bp-ring-words"+(e.words?"":" bp-dim"),t.words.textContent=e.words||m("web.ring.no.words","(no words)"),t.meta.textContent=[Zn(Fs(e)),e.unsure,e.error].filter(Boolean).join(" · ");for(let i of t.hear)i.disabled=n}async hearRing(e,t){if(!this.cb.onRingHear||this.ringIsBusy(e))return;this.ringBusy.add(e),this.ringError="",this.showRing();try{await this.cb.onRingHear(e,t),this.ringPolls=0,this.ringLater(1500)}catch(n){this.ringBusy.delete(e),this.ringError=n instanceof Error&&n.message?n.message:m("web.ring.error","Could not load recordings."),this.showRing()}}buildSearchItems(){let e=this.cb.onGetHome?.()??null,t=this.cb.onGetNoProvider?.()??null,n=gn("general","General"),i=gn("ai","Agents and tools"),s=gn("connect","Connect"),r=gt("appearance","Appearance"),o=gt("providers","AI providers"),a=gt("devices","Devices & browser"),c=gt("home","Home machine"),p=[{pageId:"appearance",pageTitle:r,groupLabel:n,rowTitle:m("settings.theme","Theme"),rowDetail:"Auto (follow hub), Dark, or Light in this browser.",keywords:["theme","dark","light","auto","appearance","colors"]},{pageId:"appearance",pageTitle:r,groupLabel:n,rowTitle:m("settings.lang","Language"),rowDetail:"Interface language for this browser.",keywords:["locale","english","espanol","japanese","language"]},{pageId:"providers",pageTitle:o,groupLabel:i,rowTitle:t?fe(t.head):"Provider connections",rowDetail:"Connect Claude, Codex, Antigravity, or other AI providers in Settings → Accounts.",keywords:["accounts","claude","codex","antigravity","grok","openai","signin"]},{pageId:"ring",pageTitle:gt("ring","Ring"),groupLabel:i,rowTitle:m("ring.recordings","Recordings"),rowDetail:"Read, search, play and hear again the voice notes from your Pebble ring.",keywords:["pebble","voice","note","recording","play","hear","transcribe"]},{pageId:"devices",pageTitle:a,groupLabel:s,rowTitle:"This browser",rowDetail:"Sign out and revoke this browser's session cookie.",keywords:["logout","sign out","session","cookie"]},{pageId:"devices",pageTitle:a,groupLabel:s,rowTitle:"Paired devices",rowDetail:this.devicesRows.map((l)=>`${l.title||l.head||""} ${l.detail||l.text||""}`).join(" ")||"Paired phones and browsers on this hub.",keywords:["phone","pair","revoke","browser"]},{pageId:"home",pageTitle:c,groupLabel:s,rowTitle:e?.name?`${e.name}`:c,rowDetail:"Which machine hosts your always-on hub and bots.",keywords:["boat","move","online","away","queued","machine"]}];for(let l of this.devicesRows){let h=l.title||l.head||"";if(h)p.push({pageId:"devices",pageTitle:a,groupLabel:s,rowTitle:h,rowDetail:l.detail||l.text||"",keywords:["paired","device"]})}return p}render(){this.renderNav(),this.renderPane()}renderNav(){let e=document.createDocumentFragment(),t=Qn(Rt,this.buildSearchItems(),this.query),n=this.cb.onGetNoProvider?.()??null,i=this.cb.onGetHome?.()??null;if(t.length===0){let r=document.createElement("div");r.className="bp-settings-nav-empty",r.setAttribute("data-testid","settings-nav-empty"),r.textContent="No matching settings",e.appendChild(r),this.navListEl.replaceChildren(e);return}let s="";for(let r of t){let o=r.page;if(o.group!==s){s=o.group;let d=Xn.find((u)=>u.id===o.group);if(d){let u=document.createElement("div");u.className="bp-settings-group",u.textContent=gn(d.id,d.label),e.appendChild(u)}}let a=document.createElement("button");a.type="button";let c=!this.searchBrowseAll&&o.id===this.activePage;a.className="bp-settings-nav-item"+(c?" active":""),a.setAttribute("data-testid",`settings-nav-${o.id}`);let p=document.createElement("div");p.className="bp-settings-nav-row";let l=document.createElement("span");l.className="bp-settings-nav-icon",l.appendChild(fo(o.icon));let h=document.createElement("span");if(h.className="bp-settings-nav-label",h.textContent=gt(o.id,o.title),p.append(l,h),o.id==="providers"&&(n||this.forceProviders)){let d=document.createElement("span");d.className="bp-settings-nav-dot warn",d.title="Action needed",p.appendChild(d)}else if(o.id==="home"&&i){let d=document.createElement("span");d.className="bp-settings-nav-dot "+(i.moving?.state==="failed"?"bad":i.online?"ok":"warn"),p.appendChild(d)}if(a.appendChild(p),r.hits.length>0)for(let d of r.hits){let u=document.createElement("div");u.className="bp-settings-hit",u.textContent=d,a.appendChild(u)}a.addEventListener("click",()=>{if(this.activePage=o.id,this.searchBrowseAll=!1,this.render(),o.id==="ring")this.loadRing()}),e.appendChild(a)}this.navListEl.replaceChildren(e)}renderPane(){let e=document.createDocumentFragment(),t=this.query.trim();if(t&&this.searchBrowseAll){this.renderSearchResults(e,t),this.paneEl.replaceChildren(e);return}let n=Rt.find((o)=>o.id===this.activePage)??Rt[0],i=document.createElement("div");i.className="bp-settings-pane-head";let s=document.createElement("h3");s.textContent=gt(n.id,n.title);let r=document.createElement("div");switch(r.className="bp-settings-pane-sub",r.textContent=n.subtitle,i.append(s,r),e.appendChild(i),n.id){case"appearance":this.renderAppearancePage(e);break;case"providers":this.renderProvidersPage(e);break;case"ring":this.renderRingPage(e);break;case"devices":this.renderDevicesPage(e);break;case"home":this.renderHomePage(e);break}this.paneEl.replaceChildren(e)}renderSearchResults(e,t){let n=qs(this.buildSearchItems(),t),i=document.createElement("div");i.className="bp-settings-pane-head";let s=document.createElement("h3");s.textContent="Search results";let r=document.createElement("div");if(r.className="bp-settings-pane-sub",r.textContent=n.length===0?`No settings match "${t}".`:`${n.length} matching ${n.length===1?"setting":"settings"} for "${t}"`,i.append(s,r),e.appendChild(i),n.length===0){let a=document.createElement("div");a.className="bp-settings-empty",a.textContent="Try searching for theme, language, providers, sign out, devices, or home.",e.appendChild(a);return}let o=Array.from(new Set(n.map((a)=>a.pageId)));for(let a of o){let c=Rt.find((u)=>u.id===a);if(!c)continue;let p=document.createElement("div");p.className="bp-settings-search-sec";let l=document.createElement("div");l.className="bp-settings-subhead",l.textContent=gt(c.id,c.title);let h=document.createElement("button");h.type="button",h.className="bp-settings-search-open",h.textContent="Open page ›",h.addEventListener("click",()=>{if(this.activePage=a,this.searchBrowseAll=!1,this.render(),a==="ring")this.loadRing()}),p.append(l,h),e.appendChild(p);let d=new Set(n.filter((u)=>u.pageId===a).map((u)=>u.rowTitle));if(a==="appearance")this.renderAppearancePage(e,d);else if(a==="providers")this.renderProvidersPage(e);else if(a==="ring"){let u=document.createElement("div");u.className="bp-settings-empty",u.textContent="Read, search, play and hear again the voice notes from your Pebble ring.",e.appendChild(u)}else if(a==="devices")this.renderDevicesPage(e,d);else if(a==="home")this.renderHomePage(e)}}renderAppearancePage(e,t){let n=this.cb.onGetThemePref?.()??"auto",i=this.cb.onGetHubTheme?.()??"dark",s=qt(n,i),r=this.cb.onGetLocalePref?.()??"auto",o=m("settings.theme","Theme"),a=m("settings.lang","Language");if(!t||t.has(o)){let c=m("settings.theme.dark","Dark"),p=m("settings.theme.light","Light"),l=n==="auto"?`Following hub theme (${i==="light"?p:c}). Stored in this browser only.`:`Using ${s==="light"?p:c} in this browser. Select Auto to follow the hub.`;e.appendChild(this.makeSegmentedRow(o,l,[{value:"auto",label:"Auto"},{value:"dark",label:c},{value:"light",label:p}],n,"settings-theme",(h)=>{this.cb.onSetThemePref?.(h),this.render()}))}if(!t||t.has(a))e.appendChild(this.makeSegmentedRow(a,"Interface language for this browser. Automatic follows the hub or browser language.",[{value:"auto",label:m("settings.lang.auto","Automatic")},{value:"en",label:m("settings.lang.en","English")},{value:"es",label:m("settings.lang.es","Español")},{value:"ja",label:m("settings.lang.ja","日本語")}],r,"settings-locale",(c)=>{this.cb.onSetLocalePref?.(c),this.render()}))}makeSegmentedRow(e,t,n,i,s,r){let o=document.createElement("div");o.className="bp-settings-row";let a=document.createElement("div");a.className="bp-settings-row-info";let c=document.createElement("div");c.className="bp-settings-row-title",c.textContent=e;let p=document.createElement("div");p.className="bp-settings-row-detail",p.textContent=t,a.append(c,p);let l=document.createElement("div");l.className="bp-chip-group",l.setAttribute("role","group"),l.setAttribute("aria-label",e);for(let h of n){let d=document.createElement("button");d.type="button";let u=h.value===i;d.className="bp-chip"+(u?" active":""),d.textContent=h.label,d.setAttribute("aria-pressed",u?"true":"false"),d.setAttribute("data-testid",`${s}-${h.value}`),d.addEventListener("click",()=>r(h.value)),l.appendChild(d)}return o.append(a,l),o}renderProvidersPage(e){let t=this.cb.onGetNoProvider?.()??null,n=document.createElement("section");if(n.className="bp-settings-section",n.setAttribute("data-testid","settings-providers"),t||this.forceProviders){let i=document.createElement("div");i.className="bp-settings-notice warn";let s=document.createElement("div");s.className="bp-settings-row-info";let r=document.createElement("div");r.className="bp-settings-row-title",r.textContent=t?fe(t.head):m("provider.notice.head","No AI provider connected");let o=document.createElement("div");o.className="bp-settings-row-detail",o.textContent=m("web.settings.providers.browser","Connect a provider in the Backplane desktop or mobile app under Settings → Accounts."),s.append(r,o);let a=document.createElement("div");a.className="bp-set-btns";let c=document.createElement("a");c.className="bp-link-btn primary",c.href=t?.url||"backplane://settings/accounts",c.setAttribute("data-testid","settings-open-accounts"),c.textContent=t?fe(t.button):m("provider.notice.button","Open Settings → Accounts"),a.appendChild(c),i.append(s,a),n.appendChild(i)}else{let i=document.createElement("div");i.className="bp-settings-row";let s=document.createElement("div");s.className="bp-settings-row-info";let r=document.createElement("div");r.className="bp-settings-row-title-wrap";let o=document.createElement("span");o.className="bp-settings-row-title",o.textContent="Provider connections";let a=document.createElement("span");a.className="bp-status-pill ok",a.textContent=m("gpui.acct.connected","Connected"),r.append(o,a);let c=document.createElement("div");c.className="bp-settings-row-detail",c.textContent="Provider sign-ins, fallback order, API keys, and usage limits are managed in the Backplane desktop or mobile app.",s.append(r,c);let p=document.createElement("div");p.className="bp-set-btns";let l=document.createElement("a");l.className="bp-link-btn",l.href="backplane://settings/accounts",l.setAttribute("data-testid","settings-open-accounts"),l.textContent=m("provider.notice.button","Open Settings → Accounts"),p.appendChild(l),i.append(s,p),n.appendChild(i)}e.appendChild(n)}renderDevicesPage(e,t){let n=!t||t.has("This browser"),i=!t||t.has("Paired devices")||this.devicesRows.some((o)=>t.has(o.title||o.head||""));if(n){let o=document.createElement("div");o.className="bp-settings-subhead",o.textContent="This browser",e.appendChild(o);let a=document.createElement("div");a.className="bp-settings-row";let c=document.createElement("div");c.className="bp-settings-row-info";let p=document.createElement("div");p.className="bp-settings-row-title",p.textContent="Browser session";let l=document.createElement("div");l.className="bp-settings-row-detail",l.textContent="Sign out and revoke this browser's session cookie.",c.append(p,l);let h=document.createElement("button");h.type="button",h.className="primary stop",h.textContent=m("agy.signout","Sign out"),h.setAttribute("data-testid","logout-btn"),h.addEventListener("click",()=>{h.disabled=!0,this.cb.onLogout().catch(()=>{l.setAttribute("role","alert"),l.className="bp-settings-row-detail bp-bad",l.textContent=m("web.logout.failed","Could not confirm sign-out. Try again."),h.disabled=!1})}),a.append(c,h),e.appendChild(a)}if(!i)return;let s=document.createElement("div");if(s.className="bp-settings-subhead",s.textContent="Paired devices",e.appendChild(s),this.devicesLoading){let o=document.createElement("div");o.className="bp-settings-empty",o.textContent="Loading paired devices…",e.appendChild(o);return}if(this.devicesError){let o=document.createElement("div");o.className="bp-settings-notice bad";let a=document.createElement("div");a.className="bp-settings-row-detail",a.textContent=this.devicesError,o.appendChild(a),e.appendChild(o);return}let r=!t||t.has("Paired devices")?this.devicesRows:this.devicesRows.filter((o)=>t.has(o.title||o.head||""));if(r.length===0){let o=document.createElement("div");o.className="bp-settings-empty",o.textContent="No paired devices listed.",e.appendChild(o)}else for(let o of r){let a=document.createElement("div");a.className="bp-settings-row";let c=document.createElement("div");c.className="bp-settings-row-info";let p=document.createElement("div");p.className="bp-settings-row-title-wrap";let l=document.createElement("span");l.className="bp-settings-row-title",l.textContent=o.title||o.head||"",p.appendChild(l);let h=o.detail||o.text||"";if(h){let d=document.createElement("span"),u=h.toLowerCase();d.className="bp-status-pill "+(u.includes("this browser")?"accent":"neutral"),d.textContent=h,p.appendChild(d)}if(c.appendChild(p),a.appendChild(c),o.buttons?.length){let d=document.createElement("div");d.className="bp-set-btns";for(let u of o.buttons){let f=document.createElement("button");if(f.type="button",u.primary)f.className="primary";if(u.danger)f.className="primary stop";f.textContent=u.label||m("common.remove","Remove"),f.addEventListener("click",()=>{f.disabled=!0,this.cb.onDevicesAct(u.action,u.value).finally(()=>{this.refresh()})}),d.appendChild(f)}a.appendChild(d)}e.appendChild(a)}if(!t){let o=document.createElement("div");o.className="bp-settings-footnote",o.textContent="Pair new browsers or phones, configure Tailscale HTTPS forwarding, or revoke access in desktop or mobile Settings → Devices.",e.appendChild(o)}}renderRingPage(e){let t=document.createElement("section");if(t.className="bp-settings-section",t.setAttribute("data-testid","settings-ring"),!this.cb.onRingList||!(this.cb.hasRing?.()??!1)){let a=document.createElement("div");a.className="bp-settings-empty",a.textContent=m("web.ring.unavailable","This hub does not show ring notes to a browser yet. Update it, or open Settings › Ring in the desktop app."),t.appendChild(a),e.appendChild(t);return}let n=document.createElement("form");n.className="bp-ring-search";let i=document.createElement("input");i.type="search",i.className="bp-ring-search-input",i.placeholder=m("ring.search.what.you.said","Search what you said"),i.setAttribute("aria-label",m("ring.search.what.you.said","Search what you said")),i.setAttribute("data-testid","ring-search"),i.value=this.ringDraft,i.addEventListener("input",()=>{this.ringDraft=i.value});let s=document.createElement("button");if(s.type="submit",s.className="primary",s.textContent=m("common.search","Search"),n.append(i,s),this.ringQuery){let a=document.createElement("button");a.type="button",a.className="bp-btn-ghost",a.textContent=m("ring.show.all","Show all"),a.addEventListener("click",()=>{this.ringDraft="",this.ringQuery="",this.loadRing()}),n.appendChild(a)}n.addEventListener("submit",(a)=>{a.preventDefault(),this.ringQuery=this.ringDraft.trim(),this.loadRing()}),t.appendChild(n);let r=document.createElement("div");r.className="bp-settings-notice bad"+(this.ringError?"":" bp-hidden"),r.setAttribute("data-testid","ring-error"),r.textContent=this.ringError,t.appendChild(r),this.ringErrorEl=r;let o=document.createElement("div");o.className="bp-ring-count",o.setAttribute("data-testid","ring-count"),o.textContent=this.ringCountLine(),t.appendChild(o),this.ringCountEl=o,this.ringRows.clear(),this.ringShownQuery=this.ringQuery;for(let a of this.ringList.notes)t.appendChild(this.renderRingNote(a));e.appendChild(t)}renderRingNote(e){let t=document.createElement("div");t.className="bp-ring-note"+(e.state==="failed"?" bad":""),t.setAttribute("data-testid",`ring-note-${e.id}`);let n=document.createElement("div");n.className="bp-ring-note-head";let i=document.createElement("span");i.className="bp-settings-row-title";let s=e.said>0?new Date(e.said*1000).toLocaleString(Bi(),{dateStyle:"medium",timeStyle:"short"}):"";i.textContent=[s,e.gesture].filter(Boolean).join(" · ");let r=document.createElement("span");n.append(i,r);let o=document.createElement("div"),a=document.createElement("div");a.className="bp-settings-row-detail";let c=[],p=document.createElement("div");p.className="bp-ring-acts";let l=Ds(e.play);if(l){let h=document.createElement("audio");h.className="bp-ring-audio",h.controls=!0,h.preload="none",h.src=l,h.setAttribute("data-testid",`ring-audio-${e.id}`),p.appendChild(h);for(let[d,u]of[["local",m("ring.hear.again.local","Hear again (local)")],["openai",m("ring.hear.again.openai","Hear again (OpenAI)")]]){let f=document.createElement("button");f.type="button",f.className="bp-btn-ghost",f.textContent=u,f.setAttribute("data-testid",`ring-hear-${d}-${e.id}`),c.push(f),f.addEventListener("click",()=>{this.hearRing(e.id,d)}),p.appendChild(f)}}if(e.thread&&this.cb.onOpenThread){let h=document.createElement("button");h.type="button",h.className="bp-btn-ghost",h.textContent=m("ring.what.happened","What happened"),h.addEventListener("click",()=>{this.close(),this.cb.onOpenThread?.(e.thread)}),p.appendChild(h)}if(t.append(n,o,a),p.childElementCount>0)t.appendChild(p);return this.ringRows.set(e.id,{state:r,words:o,meta:a,hear:c}),this.fillRingNote(e),t}renderHomePage(e){let t=this.cb.onGetHome?.()??null,n=document.createElement("section");if(n.className="bp-settings-section",n.setAttribute("data-testid","settings-home"),!t){let d=document.createElement("div");d.className="bp-settings-empty",d.textContent="Single-hub mode — this hub is running locally without linked home machines.",n.appendChild(d),e.appendChild(n);return}let i=document.createElement("div");i.className="bp-settings-row";let s=document.createElement("div");s.className="bp-settings-row-info";let r=document.createElement("div");r.className="bp-settings-row-title-wrap";let o=document.createElement("span");o.className="bp-settings-row-title",o.textContent=t.name||(t.kind==="boat"?"Boat":"This machine"),r.appendChild(o);let a=document.createElement("span");a.className="bp-status-pill neutral",a.textContent=t.kind==="local"?"This machine":t.kind==="boat"?"Boat":"Linked machine",r.appendChild(a);let c=document.createElement("span"),p="Online",l="ok";if(t.moving?.state==="moving")p="Moving",l="accent";else if(t.moving?.state==="failed")p="Move failed",l="bad";else if(!t.online)p="Away",l="warn";c.className=`bp-status-pill ${l}`,c.textContent=p,r.appendChild(c);let h=document.createElement("div");if(h.className="bp-settings-row-detail",t.moving?.state==="moving")h.textContent=t.moving.step?m("home.moving.step","Moving home to {to}: {step}").replace("{to}",t.moving.to).replace("{step}",t.moving.step):m("home.moving","Moving home to {to}…").replace("{to}",t.moving.to);else if(t.moving?.state==="failed")h.textContent=t.moving.note?m("home.move.failed.note","Home move failed: {note}").replace("{note}",t.moving.note):m("home.move.failed","Home move failed");else if(!t.online)h.textContent=t.queuedCount>0?m("home.away.queued","Home ({name}) is away · {n} queued").replace("{name}",t.name||"home").replace("{n}",String(t.queuedCount)):m("home.away","Home ({name}) is away").replace("{name}",t.name||"home");else h.textContent="Your active home hub is online and serving threads and bots.";if(s.append(r,h),i.appendChild(s),t.canMoveHere&&this.cb.onMoveHomeHere){let d=document.createElement("button");d.type="button",d.className="primary",d.textContent=m("home.move.here","Make this machine the home"),d.setAttribute("data-testid","home-move-here-btn"),d.addEventListener("click",()=>{d.disabled=!0,this.cb.onMoveHomeHere?.().finally(()=>{this.refresh()})}),i.appendChild(d)}n.appendChild(i),e.appendChild(n)}}function Se(e,t,n){let i=document.createElement(e);if(t)i.className=t;if(n)i.textContent=n;return i}function Kt(e,t,n=!1){let i=Se("button",n?"primary":"bp-btn-ghost",e);return i.type="button",i.addEventListener("click",t),i}function ti(e){return Se("pre","bp-context-code",e)}function yo(e){return Se("span",`bp-context-badge ${e==="Native"||e==="Enabled"?"active":e==="Untrusted"||e==="Invalid"?"warn":""}`,fe(e))}function fn(e,t){let n=Se("div","bp-context-row");return n.append(Se("strong",void 0,e),yo(t)),n}class ni{fetchContext;dialog=Se("dialog","bp-context");title=Se("h2");cwd=Se("div","bp-context-path");tabs=Se("div","bp-context-tabs");body=Se("div","bp-context-body");notice=Se("p","bp-context-notice");current;thread="";requestId=0;tab=0;busy=!1;constructor(e,t){this.fetchContext=t;let n=Se("div","bp-context-head"),i=Se("div");i.append(this.title,this.cwd),this.title.id="bp-context-title",this.dialog.setAttribute("aria-labelledby",this.title.id),this.notice.setAttribute("role","status"),n.append(i,Kt(m("common.refresh","Refresh"),()=>{this.load()}),Kt(m("common.close","Close"),()=>this.dialog.close())),this.dialog.append(n,this.tabs,this.notice,this.body),this.dialog.addEventListener("close",()=>{this.requestId++}),e.append(this.dialog)}open(e){if(this.thread=e,this.tab=0,this.current=void 0,this.busy=!1,this.title.textContent=m("thread.context.title","Context & Prompt"),this.cwd.textContent="",!this.dialog.open)this.dialog.showModal();this.render(),this.load()}async load(e){if(this.busy)return;let t=++this.requestId;this.busy=!0,this.notice.textContent=m("thread.context.reading","Reading thread context…"),this.render();try{let n=await this.fetchContext(this.thread,e);if(t!==this.requestId)return;this.current=n,this.cwd.textContent=n.cwd,this.notice.textContent=""}catch(n){if(t===this.requestId)this.notice.textContent=String(n)}finally{if(t===this.requestId)this.busy=!1,this.render()}}render(){let e=[m("thread.context.instructions","Instructions"),m("thread.context.system","System Prompt"),m("thread.context.skills","Skills"),m("thread.context.mcp","Project MCPs")];this.tabs.replaceChildren(...e.map((n,i)=>{let s=Kt(n,()=>{this.tab=i,this.render(),this.body.scrollTop=0,this.tabs.children[i].focus()});return s.setAttribute("aria-pressed",String(i===this.tab)),s})),this.body.replaceChildren();let t=this.current;if(!t)return;switch(this.tab){case 0:this.instructions(t.instructions);break;case 1:this.prompt(t);break;case 2:this.skills(t.skills);break;case 3:this.mcps(t.mcp);break}}instructions(e){if(!e.length)this.body.append(Se("p","bp-dim",m("thread.context.none.instructions","No project instructions found.")));for(let t of e){let n=Se("details","bp-context-card"),i=Se("summary");if(i.append(fn(t.path,t.status),Se("small","bp-dim",m("thread.context.size","{bytes} B · ≈{tokens} tokens",{bytes:t.bytes,tokens:t.estimated_tokens}))),n.append(i,ti(t.preview)),t.note)n.append(Se("small","bp-dim",t.note));this.body.append(n)}}prompt(e){let t=Se("div","bp-context-row"),n=Kt(m("thread.context.copy","Copy prompt"),()=>{navigator.clipboard.writeText(e.prompt).then(()=>{this.notice.textContent=m("thread.context.copied","Prompt copied.")}).catch((i)=>{this.notice.textContent=String(i)})});t.append(Se("p","bp-dim",m("thread.context.native.note","Backplane’s launch prompt. Native files are loaded by the provider.")),n),this.body.append(t);for(let[i,s]of[[m("thread.context.base","Backplane"),e.sections.base],[m("thread.context.injected.label","Injected project instructions"),e.sections.instructions],[m("thread.context.index","Available skills index"),e.sections.skills]])if(s)this.body.append(Se("h3",void 0,i),ti(s))}skills(e){for(let t of["Project","User","Bundled"]){let n=e.filter((i)=>i.scope===t);if(!n.length)continue;this.body.append(Se("h3",void 0,fe(t)));for(let i of n){let s=Se("article","bp-context-card");s.append(fn(i.name,i.status),Se("p",void 0,i.description),Se("small","bp-context-path",[i.source,i.provider,i.model].filter(Boolean).join(" · ")),Se("small","bp-context-path",i.path)),this.body.append(s)}}}mcps(e){if(!e.length)this.body.append(Se("p","bp-dim",m("thread.context.none.mcp","No project MCP configurations found.")));for(let t of e){let n=Se("article","bp-context-card");n.append(fn(t.path,t.state));for(let s of t.servers){let r=s.url||[s.command,...s.args].map((o)=>JSON.stringify(o)).join(" ");if(n.append(fn(s.name,s.status),ti(r)),s.cwd)n.append(Se("small","bp-context-path",s.cwd))}if(t.error)n.append(Se("p","bp-warn",t.error));let i=t.state==="Untrusted"?"trust":t.state==="Enabled"?"disable":t.state==="Disabled"?"enable":"";if(i){let s=i==="trust"?m("thread.context.trust","Trust and enable"):i==="disable"?m("thread.context.disable","Disable"):m("thread.context.enable","Enable"),r=Kt(s,()=>{this.load({action:i,path:t.path,sha256:t.sha256})},i==="trust");r.disabled=this.busy;let o=Se("div","bp-context-actions");o.append(r),n.append(o)}this.body.append(n)}}}var Ct="chats",si="bp.sidebar.cache.v1";function Qs(e){try{let t=e?.getItem(si);if(!t)return null;let n=JSON.parse(t);if(!n||n.v!==1)return null;let i=Array.isArray(n.projects)?n.projects:[],s=Array.isArray(n.threads)?n.threads:[],r=n.sections===null?null:Array.isArray(n.sections)?n.sections:null,o=Array.isArray(n.bots)?n.bots:[],a=Array.isArray(n.rooms)?n.rooms:[],c=n.shellHashes&&typeof n.shellHashes==="object"&&!Array.isArray(n.shellHashes)?n.shellHashes:{},p=Array.isArray(n.openSectionFolds)?n.openSectionFolds.filter((l)=>typeof l==="string"):[];if(i.length===0&&s.length===0&&(!r||r.length===0))return null;return{v:1,hostName:typeof n.hostName==="string"?n.hostName:void 0,sections:r,projects:i,threads:s,bots:o,rooms:a,shellHashes:c,openSectionFolds:p}}catch{return null}}function Zs(e,t){try{e?.setItem(si,JSON.stringify({v:1,...t}))}catch{}}function ri(e){try{e?.removeItem(si)}catch{}}function er(e){return e.filter((t)=>t.id&&t.id!==Ct&&t.id!=="scratch"&&!t.id.includes("~")).slice().sort((t,n)=>(t.title||t.id).toLowerCase().localeCompare((n.title||n.id).toLowerCase()))}function wo(e){if(!e)return null;if(e.moving?.state==="moving")return{text:e.moving.step?m("home.moving.step","Moving home to {to}: {step}").replace("{to}",e.moving.to).replace("{step}",e.moving.step):m("home.moving","Moving home to {to}…").replace("{to}",e.moving.to),isError:!1,dismissible:!1};if(e.moving?.state==="failed")return{text:e.moving.note?m("home.move.failed.note","Home move failed: {note}").replace("{note}",e.moving.note):m("home.move.failed","Home move failed"),isError:!0,dismissible:!0};if(!e.online){let t=e.name||"home",n="";if(e.awaySince&&e.awaySince>0){let s=new Date(e.awaySince);n=`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`}let i="";if(n&&e.queuedCount>0)i=m("home.away.since.queued","Home ({name}) is away since {time} · {n} queued").replace("{name}",t).replace("{time}",n).replace("{n}",String(e.queuedCount));else if(n)i=m("home.away.since","Home ({name}) is away since {time}").replace("{name}",t).replace("{time}",n);else if(e.queuedCount>0)i=m("home.away.queued","Home ({name}) is away · {n} queued").replace("{name}",t).replace("{n}",String(e.queuedCount));else i=m("home.away","Home ({name}) is away").replace("{name}",t);return{text:i,isError:!1,dismissible:!1}}return null}function Eo(e,t){if(e.settled)return!1;if(e.state==="done"||e.state==="stopped")return!1;if(!t)return!0;let n=e.working??0,i=Boolean(e.monitoring),s=Boolean(Jn(e.need))||e.word==="needs";return(n>0||i)&&e.state!=="paused"||s}function Co(e){if(e.wake)return{icon:"◷",label:"Snoozed",tone:"dim"};let t=(e.label??"").trim(),n=(e.tone??"").trim();if(t){let s=t.toLowerCase();return{icon:s==="approve"||s==="sign in"?"!":s==="input"?"?":s==="failed"||s==="stopped"?"×":s==="working"||s==="running"?"▸":s==="waiting"?"◌":s==="done"?"✓":"•",label:t,tone:n==="bad"?s==="failed"||s==="stopped"?"bad-out":"bad":n==="run"?"run":n==="wait"?"wait":n==="ok"?"ok":"dim"}}let i=e.word||"";if(i==="needs"){if(e.want==="approval")return{icon:"!",label:"Approve",tone:"bad"};if(e.want==="sign-in")return{icon:"!",label:"Sign in",tone:"bad"};return{icon:"?",label:"Input",tone:"bad"}}if(i==="failed"||e.status==="failed"||e.state==="fail")return{icon:"×",label:"Failed",tone:"bad-out"};if(i==="cut"||i==="interrupted")return{icon:"×",label:"Stopped",tone:"bad-out"};if(i==="running"||e.status==="active"||e.status==="working"||e.state==="run")return{icon:"▸",label:"Working",tone:"run"};if(i==="monitoring"||i==="limit"||e.status==="waiting")return{icon:"◌",label:"Waiting",tone:"wait"};if(i==="done"||e.status==="finished")return{icon:"✓",label:"Done",tone:"ok"};return null}var Ks="http://www.w3.org/2000/svg";function pt(e,t=14,n=""){let i=document.createElementNS(Ks,"svg");if(i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(t)),i.setAttribute("height",String(t)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","1.75"),i.setAttribute("stroke-linecap","square"),i.setAttribute("stroke-linejoin","miter"),i.setAttribute("aria-hidden","true"),n)i.classList.add(...n.split(" "));for(let s of e){let r=document.createElementNS(Ks,"path");r.setAttribute("d",s),i.appendChild(r)}return i}function Js(){return pt(["M3 6h6l2 2h10v11H3z"],14,"bp-folder-icon")}function Ys(e=14,t="bp-folder-icon bp-hw-icon"){return pt(["M3 3h18v18H3z","M9 3v6h6","M9 21v-6","M15 9a2 2 0 1 0 0-4 2 2 0 0 0 0 4z","M9 15a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"],e,t)}function ko(e=13){return pt(["M6 6h12v12H6z","M9 2v4","M15 2v4","M9 18v4","M15 18v4","M2 9h4","M2 15h4","M18 9h4","M18 15h4"],e)}function xo(e=15){return pt(["M4 10V4l4 3h8l4-3v6l-2 9H6z","M9 13h1","M14 13h1","M11 16h2"],e,"bp-cat-glyph")}function Po(e=11){return pt(["M4 12l5 5 11-11"],e)}function So(e=13){return pt(["M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7","M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4z"],e)}function Ao(e=11){return pt(["M2 9V5a2 2 0 0 1 2-2h4l2 3h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2","M2 13h10","M9 16l3-3-3-3"],e)}function Lo(){return typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform||"")?"⌥⇧N":"Alt+Shift+N"}function No(e=11){return pt(["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M12 6v6l4 2"],e)}function Mo(e=11){return pt(["M12 17v5","M8 4h8l-1 5 3 3v2H6v-2l3-3z"],e,"bp-pin-icon")}function Xs(e){if(!e)return"";let t=e<10000000000?e*1000:e,n=Math.max(0,Math.floor((Date.now()-t)/1000));if(n<60)return"now";if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400)return`${Math.floor(n/3600)}h`;return`${Math.floor(n/86400)}d`}function To(e){let t=e.replace(/^@/,"").trim();if(!t)return"?";let n=t.split(/[\s_-]+/).filter(Boolean);if(n.length>=2)return(n[0][0]+n[1][0]).toUpperCase();return t.slice(0,2).toUpperCase()}function ii(e){if(e==="wait"||e==="error")return"bp-mood-wait";if(e==="work"||e==="talk")return"bp-mood-work";return"bp-mood-idle"}function Qe(e){let t=e.lastIndexOf("|");return t>=0?e.slice(t+1):e}class oi{el;hostLabel;homeBanner;crewEl;filterInput;listEl;connEl;filterText="";allFilter="all";snoozeMenuRowId="";collapsedProjects=new Set;addShown=!1;sections=null;projects=[];selectedProjectId="";threads=[];bots=[];rooms=[];selectedThreadId="";cb;needErr=new Map;needBusy=new Set;constructor(e,t){this.el=e,this.cb=t;let n=document.createElement("div");n.className="bp-side-host";let i=document.createElement("div");i.className="bp-side-host-left",this.hostLabel=document.createElement("span"),this.hostLabel.textContent="This computer";let s=document.createElement("span");s.className="bp-dim",s.textContent="›",i.append(this.hostLabel,s);let r=document.createElement("button");r.type="button",r.className="icon bp-side-collapse",r.textContent="‹",r.title="Collapse sidebar",r.setAttribute("aria-label","Collapse sidebar"),r.setAttribute("data-testid","sidebar-collapse"),r.addEventListener("click",()=>this.cb.onCollapseSidebar?.()),n.append(i,r);let o=document.createElement("div");o.className="bp-side-head",this.filterInput=document.createElement("input"),this.filterInput.type="search",this.filterInput.className="bp-input bp-side-search";let a=m("sidebar.search.projects","Search projects, threads…");this.filterInput.placeholder=a,this.filterInput.setAttribute("aria-label",a),this.filterInput.setAttribute("data-testid","sidebar-filter"),this.filterInput.addEventListener("input",()=>{this.filterText=this.filterInput.value.trim().toLowerCase(),this.render()});let c=document.createElement("button");c.type="button",c.className="icon bp-side-add",c.textContent="+",c.title=m("thread.new","New thread"),c.setAttribute("aria-label",m("thread.new","New thread")),c.setAttribute("data-testid","sidebar-new-thread"),c.addEventListener("click",()=>{let d=this.firstProjectId();if(d)this.cb.onNewThread(d)});let p=document.createElement("button");p.type="button",p.className="icon bp-side-add bp-side-new-chat",p.appendChild(So(13));let l=`${m("chats.new.noproject","New chat (no project)")} (${Lo()})`;p.title=l,p.setAttribute("aria-label",m("chats.new.noproject","New chat (no project)")),p.setAttribute("data-testid","sidebar-new-chat"),p.addEventListener("click",()=>this.cb.onNewChat?.()),o.append(this.filterInput,p,c),this.homeBanner=document.createElement("div"),this.homeBanner.className="bp-side-home bp-hidden",this.homeBanner.setAttribute("data-testid","home-away-banner"),this.crewEl=document.createElement("div"),this.crewEl.className="bp-crew-band bp-hidden",this.crewEl.setAttribute("data-testid","sidebar-crew"),this.listEl=document.createElement("div"),this.listEl.className="bp-side-list",this.listEl.setAttribute("data-testid","sidebar-list");let h=document.createElement("div");h.className="bp-side-footer",this.connEl=document.createElement("span"),this.connEl.className="bp-conn-status",this.connEl.textContent="Connecting…",this.connEl.setAttribute("data-testid","conn-status"),h.appendChild(this.connEl),this.el.append(n,o,this.homeBanner,this.crewEl,this.listEl,h)}setHome(e){let t=wo(e);if(!t){this.homeBanner.className="bp-side-home bp-hidden",this.homeBanner.replaceChildren();return}this.homeBanner.className=t.isError?"bp-side-home bp-bad":"bp-side-home bp-dim";let n=document.createElement("span");if(n.className="bp-side-home-text",n.textContent=t.text,!t.dismissible){this.homeBanner.replaceChildren(n);return}let i=document.createElement("button");i.type="button",i.className="icon bp-side-home-dismiss",i.textContent="×",i.setAttribute("data-testid","home-move-dismiss");let s=m("approval.dismiss","Dismiss");i.title=s,i.setAttribute("aria-label",s),i.addEventListener("click",()=>this.cb.onDismissHomeMove?.()),this.homeBanner.replaceChildren(n,i)}setHostName(e){this.hostLabel.textContent=e||"This computer"}setConnStatus(e,t){this.connEl.textContent=e,this.connEl.className=`bp-conn-status ${t}`.trim()}setData(e,t,n,i){this.projects=e,this.threads=t,this.bots=n,this.rooms=i,this.render()}setSections(e,t,n){this.sections=e,this.bots=t,this.rooms=n,this.render()}setSelected(e){this.selectedThreadId=e,this.render()}setSelectedProject(e){if(this.selectedProjectId===e)return;this.selectedProjectId=e,this.render()}makeFoldChevron(e,t){let n=document.createElement("button");n.type="button",n.className="bp-proj-chev"+(e?" folded":""),n.textContent=e?"▸":"▾";let i=e?m("web.home.unfold","Show threads"):m("web.home.fold","Hide threads");return n.title=i,n.setAttribute("aria-label",i),n.setAttribute("aria-expanded",e?"false":"true"),n.setAttribute("data-testid",`project-fold-${t}`),n}focusFilter(){this.filterInput.focus()}firstProjectId(){if(this.sections){for(let e of this.sections)if(e.kind==="projects"&&e.rows.length>0){let t=e.rows[0];if(t.id&&!t.off)return t.id}}return this.projects[0]?.id??""}refreshLocale(){let e=m("sidebar.search.projects","Search projects, threads…");this.filterInput.placeholder=e,this.filterInput.setAttribute("aria-label",e),this.render()}renderCrewBand(e){let t=this.bots.find((c)=>c.uber),n=this.bots.filter((c)=>!c.uber&&(!e||c.name.toLowerCase().includes(e))),i=this.rooms.filter((c)=>!e||c.name.toLowerCase().includes(e)),s=Boolean(t&&(!e||t.name.toLowerCase().includes(e))),r=n.length>0||Boolean(this.cb.onNewBot)&&!e,o=i.length>0||Boolean(this.cb.onNewRoom)&&!e;if(!s&&!r&&!o){this.crewEl.classList.add("bp-hidden"),this.crewEl.replaceChildren();return}let a=document.createDocumentFragment();if(s&&t){let c=document.createElement("button");c.type="button",c.className="bp-crew-uber"+(t.thread===this.selectedThreadId?" active":""),c.setAttribute("data-testid",`crew-uber-${t.id}`);let p=document.createElement("span");if(p.className=`bp-crew-uber-avatar ${ii(t.mood)}`,t.color)p.style.color=t.color;p.appendChild(xo(14));let l=document.createElement("span");l.className="bp-crew-uber-meta";let h=document.createElement("span");if(h.className="bp-crew-uber-name",h.textContent=t.name,l.appendChild(h),t.note){let d=document.createElement("span");d.className=`bp-crew-uber-note ${ii(t.mood)}`,d.textContent=t.note,l.appendChild(d)}if(c.append(p,l),t.mood==="wait"||t.mood==="error"){let d=document.createElement("span");d.className="bp-status-pill bp-pill-bad",d.textContent="? Input",c.appendChild(d)}c.addEventListener("click",()=>this.cb.onSelectBot(t)),a.appendChild(c)}if(r){let c=document.createElement("div");c.className="bp-crew-bots",c.setAttribute("data-testid","crew-bots");let p=document.createElement("span");p.className="bp-crew-lbl",p.textContent=m("tour.title.bots","Bots").toUpperCase(),c.appendChild(p);let l=document.createElement("div");l.className="bp-crew-bot-tiles";for(let h of n){let d=document.createElement("button");if(d.type="button",d.className=`bp-crew-bot-tile ${ii(h.mood)}`+(h.thread===this.selectedThreadId?" active":""),d.title=h.note?`@${h.name} — ${h.note}`:`@${h.name}`,d.setAttribute("aria-label",`@${h.name}`),d.setAttribute("data-testid",`crew-bot-${h.id}`),h.color)d.style.setProperty("--bot-c",h.color);let u=document.createElement("span");if(u.className="bp-crew-bot-init",u.textContent=To(h.name),d.appendChild(u),h.mood==="wait"||h.mood==="error"){let f=document.createElement("span");f.className="bp-crew-bot-wait",d.appendChild(f)}d.addEventListener("click",()=>this.cb.onSelectBot(h)),l.appendChild(d)}if(this.cb.onNewBot&&!e){let h=document.createElement("button");h.type="button",h.className="bp-crew-bot-tile bp-crew-add",h.textContent="+",h.title=m("bots.new","New bot"),h.setAttribute("aria-label",m("bots.new","New bot")),h.setAttribute("data-testid","crew-new-bot"),h.addEventListener("click",()=>this.cb.onNewBot?.()),l.appendChild(h)}c.appendChild(l),a.appendChild(c)}if(o){let c=document.createElement("div");c.className="bp-crew-rooms",c.setAttribute("data-testid","crew-rooms");for(let p of i){let l=document.createElement("button");l.type="button",l.className="bp-crew-room-chip",l.setAttribute("data-testid",`crew-room-${p.id}`);let h=document.createElement("span");h.className="bp-dim",h.textContent="#";let d=document.createElement("span");if(d.textContent=p.name,l.append(h,d),p.members!==void 0&&p.members>0){let u=document.createElement("span");u.className="bp-crew-room-cnt",u.textContent=String(p.members),l.appendChild(u)}l.title=p.members?`#${p.name} (${p.members})`:`#${p.name}`,l.addEventListener("click",()=>this.cb.onSelectRoom?.(p)),c.appendChild(l)}if(this.cb.onNewRoom&&!e){let p=document.createElement("button");p.type="button",p.className="bp-crew-room-chip bp-crew-add",p.textContent="+",p.title=m("rooms.new","New room"),p.setAttribute("aria-label",m("rooms.new","New room")),p.setAttribute("data-testid","crew-new-room"),p.addEventListener("click",()=>this.cb.onNewRoom?.()),c.appendChild(p)}a.appendChild(c)}this.crewEl.classList.remove("bp-hidden"),this.crewEl.replaceChildren(a)}projectsHead(e){let t=document.createElement("div");if(t.className="bp-side-section-head",!this.cb.onAddProject||this.addShown)return t.textContent=e,t;this.addShown=!0,t.classList.add("bp-side-section-row");let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.type="button",i.className="bp-side-sec-plus bp-side-sec-btn",i.textContent="+";let s=m("sidebar.add.project","Add project");return i.title=s,i.setAttribute("aria-label",s),i.setAttribute("data-testid","sidebar-add-project"),i.addEventListener("click",(r)=>{r.stopPropagation(),this.cb.onAddProject?.()}),t.append(n,i),t}renderStatusPill(e,t){let n=document.createElement("span");if(n.className=`bp-status-pill bp-pill-${e.tone}`,n.textContent=`${e.icon} ${e.label}`,t)n.title=t;return n}renderRowActions(e){if(e.off)return null;let t=Array.isArray(e.snooze)&&e.snooze.length>0&&Boolean(this.cb.onSnoozeRow),n=Boolean(e.wake)&&Boolean(this.cb.onSnoozeRow),i=e.kind==="swarm",s=Boolean(e.settle)&&(!i||Boolean(this.cb.onSettleSwarm)),r=Boolean(e.chat)&&Boolean(this.cb.onMoveToProject);if(!t&&!n&&!s&&!r)return null;let o=document.createElement("span");if(o.className="bp-row-acts",n&&e.wake){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-wake-btn",a.textContent=m("menu.wake","Wake"),a.title=m("menu.wake","Wake snoozed thread"),a.setAttribute("data-testid",`wake-row-${e.id}`),a.addEventListener("click",(c)=>{c.stopPropagation(),this.cb.onSnoozeRow?.(e.wake)}),o.appendChild(a)}if(t&&e.snooze){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-snooze-btn",a.title=m("menu.snooze","Snooze thread"),a.setAttribute("aria-label",m("menu.snooze","Snooze thread")),a.setAttribute("data-testid",`snooze-row-${e.id}`),a.appendChild(No(11)),a.addEventListener("click",(c)=>{c.stopPropagation(),this.snoozeMenuRowId=this.snoozeMenuRowId===e.id?"":e.id,this.render()}),o.appendChild(a)}if(r){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-move-btn",a.title=m("chats.move","Move to project…"),a.setAttribute("aria-label",m("chats.move","Move to project…")),a.setAttribute("data-testid",`move-row-${e.id}`),a.appendChild(Ao(11)),a.addEventListener("click",(c)=>{c.stopPropagation(),this.cb.onMoveToProject?.(Qe(e.id))}),o.appendChild(a)}if(s&&e.settle){let a=document.createElement("button");a.type="button",a.className="bp-row-act-btn bp-settle-btn",a.title=m("menu.settle","Settle"),a.setAttribute("aria-label",m("menu.settle","Settle")),a.setAttribute("data-testid",`settle-row-${e.id}`),a.appendChild(Po(11)),a.addEventListener("click",(c)=>{if(c.stopPropagation(),i)this.cb.onSettleSwarm?.(Qe(e.settle));else this.cb.onThreadAct(Qe(e.settle),"settle")}),o.appendChild(a)}return o}renderSectionThreadRow(e,t,n=!1){let i=document.createElement("div");i.className="bp-thread-row"+(n?" bp-inbox-row":"")+(!this.selectedProjectId&&(e.id===this.selectedThreadId||Qe(e.id)===this.selectedThreadId)?" active":"")+(e.off?" bp-dim":""),i.setAttribute("data-thread-id",e.id),i.setAttribute("data-testid",`thread-row-${e.id}`);let s=Co(e),r=this.renderRowActions(e);if(n){let l=document.createElement("div");l.className="bp-inbox-main";let h=document.createElement("div");h.className="bp-inbox-top";let d=document.createElement("div");if(d.className="bp-thread-title",d.textContent=e.title||"Untitled thread",h.appendChild(d),r)h.appendChild(r);let u=document.createElement("div");if(u.className="bp-inbox-meta",s)u.appendChild(this.renderStatusPill(s,e.say));if(e.project&&!e.chat){let f=document.createElement("span");f.className="bp-inbox-proj",f.textContent=e.project,u.appendChild(f)}if(e.ago){let f=document.createElement("span");if(f.className="bp-thread-age",f.textContent=e.ago,e.pinned)f.title=m("tools.pinned","Pinned");u.appendChild(f)}l.append(h,u),i.appendChild(l)}else{if(t){let h=document.createElement("span");h.className="bp-tree-branch",h.setAttribute("aria-hidden","true"),i.appendChild(h)}if(s)i.appendChild(this.renderStatusPill(s,e.say));let l=document.createElement("div");if(l.className="bp-thread-title",l.textContent=e.title||"Untitled thread",i.appendChild(l),r)i.appendChild(r);if(e.ago){let h=document.createElement("span");if(h.className="bp-thread-age",h.textContent=e.ago,e.pinned)h.title=m("tools.pinned","Pinned");i.appendChild(h)}}let o=e.nav||e.id;if(!e.off&&o&&!o.startsWith("@room:"))i.addEventListener("click",()=>this.cb.onSelectThread(Qe(o)));let a=this.snoozeMenuRowId===e.id&&Array.isArray(e.snooze)&&e.snooze.length>0,c=e.kind==="swarm"?Jn(e.need):null;if(!c&&!a)return i;let p=document.createElement("div");if(p.className="bp-need-wrap",p.appendChild(i),a&&e.snooze){let l=document.createElement("div");l.className="bp-snooze-bar"+(t?" nested":""),l.setAttribute("data-testid",`snooze-bar-${e.id}`);let h=document.createElement("span");h.className="bp-dim",h.textContent="Snooze:",l.appendChild(h);for(let d of e.snooze){let u=document.createElement("button");u.type="button",u.className="bp-snooze-opt",u.textContent=d.label,u.addEventListener("click",(f)=>{f.stopPropagation(),this.snoozeMenuRowId="",this.cb.onSnoozeRow?.(d.value),this.render()}),l.appendChild(u)}p.appendChild(l)}if(c){let l=document.createElement("div");l.className="bp-need"+(t?" nested":"")+(e.off?" bp-dim":""),l.setAttribute("data-testid",`need-${e.id}`);let h=document.createElement("span");h.className="bp-need-line",h.textContent=c.line,h.title=c.line,l.appendChild(h);for(let u of c.actions){if(!bn(u,Boolean(this.cb.hasRoomView)))continue;let f=document.createElement("button");f.type="button",f.className="bp-need-btn",f.textContent=u.label,f.setAttribute("data-testid",`need-${u.act}-${e.id}`),f.disabled=Boolean(e.off)||this.needBusy.has(e.id)||!this.cb.onNeedAct,f.addEventListener("click",(g)=>{g.stopPropagation();let v=this.cb.onNeedAct;if(!v)return;this.needErr.delete(e.id),this.needBusy.add(e.id),this.render(),v(u).catch((y)=>{this.needErr.set(e.id,y instanceof Error?y.message:String(y))}).finally(()=>{this.needBusy.delete(e.id),this.render()})}),l.appendChild(f)}p.appendChild(l);let d=this.needErr.get(e.id);if(d){let u=document.createElement("div");u.className="bp-need-err"+(t?" nested":""),u.textContent=d,p.appendChild(u)}}return p}renderHubSections(e,t){let n=this.sections??[],i=new Set;for(let o of n)if(o.kind==="threads")for(let a of o.rows)i.add(a.id),i.add(Qe(a.id));else if(o.kind==="projects")for(let a of o.rows)for(let c of a.threads??[])i.add(c.id),i.add(Qe(c.id));let s=this.selectedThreadId?this.threads.find((o)=>o.id===this.selectedThreadId)??null:null,r=!1;for(let o of n)if(o.kind==="projects"&&(o.rows.length>0||(o.count??0)>0))r=!0;for(let o of n){if(o.kind==="bub")continue;if(o.kind==="threads"){let a=Boolean(o.fold&&o.toggle),c=o.rows.filter((l)=>{if(!t)return!0;return`${l.title} ${l.project??""}`.toLowerCase().includes(t)});if(!a&&c.length===0)continue;if(a&&t&&c.length===0)continue;if(a&&!t&&(o.count??c.length)===0)continue;let p=document.createElement("section");if(p.className=`bp-side-section bp-side-inbox bp-sec-${o.id}`,p.setAttribute("data-section-id",o.id),a){let l=document.createElement("button");l.type="button",l.className="bp-side-section-head bp-side-section-toggle";let h=t?c.length:o.count??c.length,d=o.open||Boolean(t)?"▾":"▸";if(l.textContent=`${d} ${o.title.toUpperCase()} (${h})`,o.hint)l.title=o.hint;l.setAttribute("data-testid",`section-toggle-${o.id}`),l.addEventListener("click",()=>{if(o.toggle)this.cb.onToggleSection?.(o.toggle)}),p.appendChild(l)}else{let l=document.createElement("div");if(l.className="bp-side-section-head"+(o.id==="needs"?" bp-head-needs":o.id==="running"?" bp-head-running":""),o.id===Ct&&this.cb.onNewChat){l.classList.add("bp-side-section-row");let h=document.createElement("span");h.textContent=`${m("chats.title",o.title).toUpperCase()} ${c.length}`;let d=document.createElement("button");d.type="button",d.className="bp-side-sec-plus bp-side-sec-btn",d.textContent="+",d.title=m("chats.new.noproject","New chat (no project)"),d.setAttribute("aria-label",d.title),d.setAttribute("data-testid","section-new-chat"),d.addEventListener("click",(u)=>{u.stopPropagation(),this.cb.onNewChat?.()}),l.append(h,d)}else l.textContent=`${o.title.toUpperCase()} ${c.length}`;p.appendChild(l)}if(!a||Boolean(o.open)||Boolean(t))for(let l of c)p.appendChild(this.renderSectionThreadRow(l,!1,!0));e.appendChild(p);continue}if(o.kind==="projects"){let a=o.rows,c=a.filter((d)=>{if(!t)return!0;if((d.title||d.id).toLowerCase().includes(t))return!0;if((d.threads??[]).some((u)=>u.title.toLowerCase().includes(t)))return!0;if((d.swarms??[]).some((u)=>u.title.toLowerCase().includes(t)))return!0;return!1}),p=Boolean(o.fold&&o.toggle);if(t&&c.length===0)continue;if(!p&&o.id!=="active"&&c.length===0)continue;let l=document.createElement("section");if(l.className=`bp-side-section bp-sec-${o.id}`,l.setAttribute("data-section-id",o.id),p){let d=document.createElement("button");d.type="button",d.className="bp-side-section-head bp-side-section-toggle";let u=t?c.length:o.count??c.length,f=o.open||Boolean(t)?"▾":"▸";if(d.textContent=`${f} ${o.title.toUpperCase()} (${u})`,o.hint)d.title=o.hint;d.setAttribute("data-testid",`section-toggle-${o.id}`),d.addEventListener("click",()=>{if(o.toggle)this.cb.onToggleSection?.(o.toggle)}),l.appendChild(d)}else l.appendChild(this.projectsHead(o.title.toUpperCase()));if(!p||Boolean(o.open)||Boolean(t)){if(o.id==="all"&&!t){let d=a.some((f)=>f.hasBoard||f.hasSchematic),u=a.some((f)=>!f.hasBoard&&!f.hasSchematic);if(d&&u){let f=document.createElement("div");f.className="bp-proj-filter",f.setAttribute("data-testid","all-projects-filter");let g=[{id:"all",label:"All"},{id:"hw",label:"Boards"},{id:"sw",label:"Code"}];for(let v of g){let y=document.createElement("button");y.type="button",y.className="bp-proj-filter-btn"+(this.allFilter===v.id?" active":""),y.textContent=v.label,y.addEventListener("click",()=>{this.allFilter=v.id,this.render()}),f.appendChild(y)}if(l.appendChild(f),this.allFilter==="hw")c=c.filter((v)=>v.hasBoard||v.hasSchematic);else if(this.allFilter==="sw")c=c.filter((v)=>!v.hasBoard&&!v.hasSchematic)}}if(o.id==="active"&&!r&&!t){let d=document.createElement("div");d.className="bp-side-empty",d.textContent="No projects yet.",l.appendChild(d)}for(let d of c){let u=document.createElement("div");if(u.className="bp-proj-group"+(d.off||o.id==="quiet"?" bp-dim":""),u.setAttribute("data-project-id",d.id),d.nav||d.key)u.setAttribute("data-project-key",d.nav||d.key||"");let f=document.createElement("div");f.className="bp-proj-head";let g=document.createElement("button");g.type="button",g.className="bp-proj-toggle";let y=Boolean(d.hasBoard||d.hasSchematic)?Ys(14):Js();if(d.css)y.style.color=d.css;let w=document.createElement("span");w.className="bp-proj-name",w.textContent=d.title||d.id,g.append(y,w);let k=d.fold==="project-fold"&&Boolean(d.nav),A=()=>{if(k)this.cb.onToggleProjectFold?.(d.nav)};if(!d.off&&this.cb.canOpenProject?.())g.title=m("web.home.open","Open project home");if(g.setAttribute("data-testid",`project-open-${d.id}`),this.selectedProjectId&&Qe(d.id)===this.selectedProjectId)f.classList.add("active");g.addEventListener("click",()=>{if(d.off||!this.cb.onOpenProject?.(d.id))A()});let N=this.makeFoldChevron(Boolean(d.folded),d.id);if(k)N.addEventListener("click",(P)=>{P.stopPropagation(),A()});else N.disabled=!0;f.appendChild(N);let L=document.createElement("div");if(L.className="bp-proj-meta",(d.needsCount??0)>0){let P=document.createElement("span");P.className="bp-proj-badge-need",P.textContent=String(d.needsCount),P.title=`${d.needsCount} needing you`,L.appendChild(P)}if((d.running??0)>0){let P=document.createElement("span");P.className="bp-proj-badge-run",P.textContent=String(d.running),P.title=`${d.running} running`,L.appendChild(P)}if(d.pinned&&o.id!=="pinned")L.appendChild(Mo(11));let B=document.createElement("div");if(B.className="bp-proj-acts",!d.off&&this.cb.onQuickOpenViewer){if(d.hasBoard){let P=document.createElement("button");P.type="button",P.className="bp-proj-quick",P.title=m("viewer.board","Open Board"),P.setAttribute("aria-label",`Open Board (${d.title})`),P.setAttribute("data-testid",`quick-board-${d.id}`),P.appendChild(Ys(13,"")),P.addEventListener("click",(K)=>{K.stopPropagation(),this.cb.onQuickOpenViewer?.(Qe(d.id),"board")}),B.appendChild(P)}if(d.hasSchematic){let P=document.createElement("button");P.type="button",P.className="bp-proj-quick",P.title=m("viewer.schematic","Open Schematic"),P.setAttribute("aria-label",`Open Schematic (${d.title})`),P.setAttribute("data-testid",`quick-sch-${d.id}`),P.appendChild(ko(13)),P.addEventListener("click",(K)=>{K.stopPropagation(),this.cb.onQuickOpenViewer?.(Qe(d.id),"schematic")}),B.appendChild(P)}}let T=document.createElement("button");if(T.type="button",T.className="icon bp-proj-add",T.title=m("thread.new","New thread"),T.textContent="+",T.setAttribute("data-testid",`new-thread-${d.id}`),d.off)T.disabled=!0;T.addEventListener("click",(P)=>{P.stopPropagation(),this.cb.onNewThread(Qe(d.id))}),B.appendChild(T),f.append(g,L,B),u.appendChild(f);let H=Boolean(t)&&(d.title||d.id).toLowerCase().includes(t),F=Boolean(d.folded&&!t);for(let P of d.swarms??[]){if(!Eo(P,F))continue;if(t&&!H&&!P.title.toLowerCase().includes(t))continue;u.appendChild(this.renderSectionThreadRow(P,!0))}if(!F){for(let P of d.threads??[]){if(t&&!H&&!P.title.toLowerCase().includes(t))continue;u.appendChild(this.renderSectionThreadRow(P,!0))}if(s&&s.project===Qe(d.id)&&!i.has(s.id)&&(!t||H||s.title.toLowerCase().includes(t)))u.appendChild(this.renderSectionThreadRow({id:s.id,title:s.title,status:s.status,state:s.state,ago:Xs(s.updatedAt),pinned:s.pinned,nav:s.id},!0))}l.appendChild(u)}}e.appendChild(l)}}}render(){this.addShown=!1;let e=this.filterText;this.renderCrewBand(e);let t=document.createDocumentFragment();if(this.sections!==null)this.renderHubSections(t,e);else{let n=new Map;for(let i of this.threads){if(i.archived||i.swarm)continue;if(e){if(!`${i.title} ${i.preview??""}`.toLowerCase().includes(e))continue}let s=n.get(i.project)??[];s.push(i),n.set(i.project,s)}if(t.appendChild(this.projectsHead("RECENT")),this.projects.length===0&&this.threads.length===0){let i=document.createElement("div");i.className="bp-side-empty",i.textContent="No projects yet.",t.appendChild(i)}for(let i of this.projects){let s=n.get(i.id)??[];if(e&&s.length===0&&!i.title.toLowerCase().includes(e))continue;let r=document.createElement("section");r.className="bp-proj-group",r.setAttribute("data-project-id",i.id);let o=document.createElement("div");o.className="bp-proj-head";let a=document.createElement("button");a.type="button",a.className="bp-proj-toggle";let c=this.collapsedProjects.has(i.id)&&!e,p=Js();if(i.css)p.style.color=i.css;let l=document.createElement("span");l.className="bp-proj-name",l.textContent=i.title||i.id,a.append(p,l);let h=()=>{if(this.collapsedProjects.has(i.id))this.collapsedProjects.delete(i.id);else this.collapsedProjects.add(i.id);this.render()};if(this.cb.canOpenProject?.())a.title=m("web.home.open","Open project home");if(a.setAttribute("data-testid",`project-open-${i.id}`),this.selectedProjectId&&i.id===this.selectedProjectId)o.classList.add("active");a.addEventListener("click",()=>{if(!this.cb.onOpenProject?.(i.id))h()});let d=this.makeFoldChevron(c,i.id);d.addEventListener("click",(f)=>{f.stopPropagation(),h()}),o.appendChild(d);let u=document.createElement("button");if(u.type="button",u.className="icon bp-proj-add",u.title=m("thread.new","New thread"),u.textContent="+",u.setAttribute("data-testid",`new-thread-${i.id}`),u.addEventListener("click",(f)=>{f.stopPropagation(),this.cb.onNewThread(i.id)}),o.append(a,u),r.appendChild(o),!c)for(let f of s)r.appendChild(this.renderSectionThreadRow({id:f.id,title:f.title,status:f.status,state:f.state,ago:Xs(f.updatedAt),pinned:f.pinned,nav:f.id},!0));t.appendChild(r)}}this.listEl.replaceChildren(t)}}function Io(e){try{return new URL(e,window.location.origin).searchParams.get("s")||""}catch{return""}}function Jt(e){if(!e)return;for(let t of e.getTracks())try{t.stop()}catch{}}function Bo(e,t){if(t===16000){let r=new Int16Array(e.length);for(let o=0;o0?c/p:0));s[r]=l<0?l*32768:l*32767}return s}class ai{hub;cb;active=!1;starting=!1;sessionGen=0;activeGen=0;abortedGen=0;threadId="";sessionKey="";stream=null;audioCtx=null;processor=null;pendingPcm=[];postChain=Promise.resolve();stopDrain=Promise.resolve();mark=0;constructor(e,t){this.hub=e,this.cb=t}isRecording(){return this.active||this.starting}async toggle(){if(this.active||this.starting)await this.stop();else await this.start()}async start(){if(this.active||this.starting)return;let e=this.cb.getThreadId();if(!e)return;if(!navigator.mediaDevices?.getUserMedia){this.cb.showError("Microphone access is not available in this browser.");return}let t=++this.sessionGen;this.starting=!0,this.threadId=e,this.sessionKey="",this.pendingPcm=[],this.mark=this.cb.getCaret(),this.cb.setRecording(!0);let n;try{n=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{if(t===this.sessionGen)this.starting=!1,this.cb.setRecording(!1),this.cb.showError("Microphone permission denied.");return}if(t!==this.sessionGen||this.cb.getThreadId()!==e){Jt(n);return}if(this.stream=n,await this.stopDrain,t!==this.sessionGen||this.cb.getThreadId()!==e){if(Jt(n),this.stream===n)this.stream=null;return}try{let i=await this.hub.rpc("voice.start",{thread:e,draft:this.cb.getDraft(),caret:this.mark});if(t!==this.sessionGen||this.cb.getThreadId()!==e){if(Jt(n),this.stream===n)this.stream=null;if(!this.active&&!this.starting)this.hub.rpc("voice.stop",{thread:e}).catch(()=>{});return}let s=i.session||(i.path?Io(i.path):"");if(!s)throw Error("Hub did not return a voice session.");this.sessionKey=s,this.activeGen=t,this.starting=!1,this.active=!0,this.startCapture(n,t)}catch(i){if(t===this.sessionGen)this.cleanupAudio(),this.starting=!1,this.active=!1,this.cb.setRecording(!1),this.cb.showError(i instanceof Error?i.message:"Could not start voice dictation.");else if(Jt(n),this.stream===n)this.stream=null}}async stop(){if(!this.active&&!this.starting)return;let e=this.activeGen,t=this.active,n=this.threadId,i=this.sessionKey;this.sessionGen++,this.starting=!1,this.active=!1,this.sessionKey="",this.cb.setRecording(!1),this.cb.setLevel(0),this.cleanupAudio();let r=this.stopDrain.then(async()=>{if(t&&i){let o=new Int16Array(this.pendingPcm);this.pendingPcm=[],this.enqueuePost(i,new Uint8Array(o.buffer),!0,e),await this.postChain}else this.pendingPcm=[];if(t&&n)await this.hub.rpc("voice.stop",{thread:n}).catch(()=>{})});this.stopDrain=r,await r}cancel(){if(!this.active&&!this.starting)return;let e=this.active,t=this.threadId;if(this.abortedGen=Math.max(this.abortedGen,this.sessionGen),this.sessionGen++,this.starting=!1,this.active=!1,this.sessionKey="",this.pendingPcm=[],this.cb.setRecording(!1),this.cb.setLevel(0),this.cleanupAudio(),e&&t&&this.hub.getState()==="connected")this.hub.rpc("voice.stop",{thread:t}).catch(()=>{})}handleFrame(e){let t=String(e.ev??""),n=String(e.thread??"");if(n&&this.cb.getThreadId()&&n!==this.cb.getThreadId())return;if(t==="draft"&&typeof e.text==="string")this.cb.setDraft(e.text),this.mark=e.text.length;else if(t==="edit"){let i=this.cb.getDraft(),s=Number(e.del??0),r=String(e.ins??""),o=Math.max(0,Math.min(i.length,this.mark)),a=Math.max(0,o-s),c=i.slice(0,a)+r+i.slice(o);this.mark=a+r.length,this.cb.setDraft(c)}else if(t==="level")this.cb.setLevel(Math.max(0,Math.min(100,Number(e.v??0))));else if(t==="view"){let i=e.view;if(i&&i.on===!1&&(this.active||this.starting))this.stop()}}startCapture(e,t){let i=new(window.AudioContext||window.webkitAudioContext),s=i.createMediaStreamSource(e),r=i.createScriptProcessor(4096,1,1);r.onaudioprocess=(o)=>{if(!this.active||t!==this.sessionGen||!this.sessionKey)return;let a=Bo(o.inputBuffer.getChannelData(0),i.sampleRate);for(let c=0;c=3200){let c=new Int16Array(this.pendingPcm.splice(0,3200));this.enqueuePost(this.sessionKey,new Uint8Array(c.buffer),!1,t)}},s.connect(r),r.connect(i.destination),this.audioCtx=i,this.processor=r}enqueuePost(e,t,n,i){this.postChain=this.postChain.then(async()=>{if(i<=this.abortedGen)return;try{let s={"Content-Type":"application/octet-stream","X-Voice-Session":e};if(n)s["X-Voice-End"]="1";let r=await fetch("/voice/in",{method:"POST",credentials:"same-origin",headers:s,body:t});if(!r.ok&&!n&&i===this.sessionGen&&this.active)this.failUpload(`Voice upload failed (${r.status}).`)}catch{if(!n&&i===this.sessionGen&&this.active)this.failUpload("Voice upload failed.")}})}failUpload(e){this.abortedGen=Math.max(this.abortedGen,this.sessionGen),this.sessionGen++,this.active=!1,this.starting=!1,this.sessionKey="",this.pendingPcm=[],this.cleanupAudio(),this.cb.setRecording(!1),this.cb.setLevel(0),this.cb.showError(e)}cleanupAudio(){if(this.processor)this.processor.disconnect(),this.processor.onaudioprocess=null,this.processor=null;if(this.audioCtx)this.audioCtx.close().catch(()=>{}),this.audioCtx=null;Jt(this.stream),this.stream=null}}var tr=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],nr=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ir=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],sr=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Ro=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Yt(e,t){let n=new Int32Array(16),i=0;for(let a=0;a0){if(n[c]++,c>i)i=c}}let s=new Int32Array(16),r=0;for(let a=1;a<=15;a++)s[a]=r,r+=n[a];let o=new Int32Array(r);for(let a=0;a0)o[s[c]++]=a}return{counts:n,symbols:o,maxBits:i}}var jo=(()=>{let e=new Uint8Array(288);return e.fill(8,0,144),e.fill(9,144,256),e.fill(7,256,280),e.fill(8,280,288),Yt(e,288)})(),Ho=(()=>{let e=new Uint8Array(32);return e.fill(5),Yt(e,32)})();class li{win=new Uint8Array(32768);winPos=0;feed(e,t=16777216){let n=0,i=0,s=0,r=(h)=>{while(s=e.length)throw Error("truncated deflate frame");i|=e[n++]<>>=h,s-=h,d},o=(h)=>{let d=0,u=0,f=0;for(let g=1;g<=h.maxBits;g++){d|=r(1);let v=h.counts[g];if(d-v{let d=c+h;if(d>t)throw Error("inflated frame exceeds limit");if(d<=a.length)return;let u=a.length;while(u{p(1),a[c++]=h,this.win[this.winPos]=h,this.winPos=this.winPos+1&32767};while(n0){if(n>=e.length&&s<3)break;let h=r(1),d=r(2);if(d===0){if(i=0,s=0,n+4>e.length)throw Error("truncated stored block");let u=e[n]|e[n+1]<<8,f=e[n+2]|e[n+3]<<8;if(n+=4,(u^65535)!==f)throw Error("invalid stored block length");if(n+u>e.length)throw Error("truncated stored payload");p(u);for(let g=0;g=e.length)break}else if(d===1||d===2){let u=jo,f=Ho;if(d===2){let g=r(5)+257,v=r(5)+1,y=r(4)+4,w=new Uint8Array(19);for(let B=0;BA)throw Error("code length overflow");for(let F=0;FA)throw Error("code length overflow");L+=T}else if(B===18){let T=r(7)+11;if(L+T>A)throw Error("code length overflow");L+=T}else throw Error("invalid code length symbol")}u=Yt(N,g),f=Yt(N.subarray(g),v)}while(!0){let g=o(u);if(g<256)l(g);else if(g===256)break;else{let v=g-257;if(v>=tr.length)throw Error("invalid length symbol");let y=tr[v]+(nr[v]?r(nr[v]):0),w=o(f);if(w>=ir.length)throw Error("invalid distance symbol");let k=ir[w]+(sr[w]?r(sr[w]):0);p(y);let A=this.winPos-k&32767;for(let N=0;N{this.stateListeners.delete(e)}}onFrame(e){return this.frameListeners.add(e),()=>{this.frameListeners.delete(e)}}onBinary(e){return this.binaryListeners.add(e),()=>{this.binaryListeners.delete(e)}}rpc(e,t={},n=20000){return new Promise((i,s)=>{if(!this.ws||this.ws.readyState!==WebSocket.OPEN){s(Error("Not connected to hub"));return}let r=this.nextId++,o=window.setTimeout(()=>{this.pending.delete(r),s(Error(`RPC timeout: ${e}`))},n);this.pending.set(r,{resolve:i,reject:s,timer:o}),this.ws.send(JSON.stringify({id:r,m:e,p:t}))})}setState(e){this.state=e;for(let t of this.stateListeners)t(e,this.hello)}rejectAllPending(e){for(let[,t]of this.pending)window.clearTimeout(t.timer),t.reject(Error(e));this.pending.clear()}openSocket(){if(this.closed)return;this.inflater=null;let t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?data=1&enc=json&z=deflate`,n=new WebSocket(t);n.binaryType="arraybuffer",this.ws=n;let i=(s)=>{let r;try{r=JSON.parse(s)}catch{return}if(r.t==="hub.restarting")this.restarting={reason:String(r.reason??""),build:String(r.build??""),text:String(r.text??""),at:Date.now()};if(r.t==="hello")this.restarting=null,this.hello=r,this.features=new Set(this.hello.features??[]),this.inflater=this.hello.z==="deflate"?new li:null,this.reconnectDelay=500,this.setState("connected");else if(r.t==="reply"&&typeof r.id==="number"){let o=this.pending.get(r.id);if(o)if(this.pending.delete(r.id),window.clearTimeout(o.timer),r.ok)o.resolve(r.result??{});else{let a=r.error,c=typeof a==="string"?a:a&&typeof a==="object"&&("message"in a)?String(a.message):"Request failed",p=typeof r.errorCode==="string"?r.errorCode:void 0,l=typeof r.machine==="string"?r.machine:void 0,h=typeof r.thread==="string"?r.thread:void 0;o.reject(new Xt(c,{code:p,machine:l,thread:h}))}return}for(let o of this.frameListeners)o(r)};n.addEventListener("message",(s)=>{if(s.data instanceof ArrayBuffer){if(this.inflater){let r;try{r=this.inflater.feed(new Uint8Array(s.data))}catch{n.close();return}if(r.length>0&&r[0]===123)i(this.textDecoder.decode(r));else{let o=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);for(let a of this.binaryListeners)a(o)}return}for(let r of this.binaryListeners)r(s.data);return}if(typeof s.data!=="string")return;i(s.data)}),n.addEventListener("close",(s)=>{if(this.ws===n)this.ws=null;if(this.rejectAllPending("Connection closed"),this.closed)return;if(s.code===4001||s.code===4401||s.code===1008){this.handleRevoked();return}this.probeSessionOrReconnect()}),n.addEventListener("error",()=>{})}async probeSessionOrReconnect(){try{let t=await fetch("/",{method:"GET",credentials:"same-origin",cache:"no-store"});if(t.status===401||t.status===403){this.handleRevoked();return}if(t.ok){if((await t.text()).includes('id="pair-root"')){this.handleRevoked();return}}}catch{}this.setState("reconnecting");let e=this.reconnectDelay;this.reconnectDelay=Math.min(8000,Math.round(this.reconnectDelay*1.6)),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.openSocket()},e)}handleRevoked(){this.closed=!0,this.setState("revoked"),window.location.replace("/")}}var Do=new TextDecoder;function rr(e){return e.length>7&&e[0]>=160&&e[0]<=183&&e[1]===1&&e[2]===100&&e[3]===112&&e[4]===108&&e[5]===111&&e[6]===116}function or(e){let t=0,n=0;function i(o){if(o<=23)return o;if(o===24){if(t>=e.length)return null;return e[t++]}if(o===25){if(t+2>e.length)return null;let a=e[t]<<8|e[t+1];return t+=2,a}if(o===26){if(t+4>e.length)return null;let a=(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0;return t+=4,a}return null}function s(o){if(n++,o>32||n>400000||t>=e.length)return null;let a=e[t++],c=a>>5,p=i(a&31);if(p===null)return null;switch(c){case 0:return p;case 1:return-1-p;case 2:{if(t+p>e.length)return null;let l=e.subarray(t,t+p);return t+=p,l}case 3:{if(t+p>e.length)return null;let l=Do.decode(e.subarray(t,t+p));return t+=p,l}case 4:{if(p>e.length)return null;let l=Array(p);for(let h=0;h=this.b.length)return this.ok=!1,0;let n=this.b[this.i++],i=7*t;if(i>=28&&(n&240)!==0)return this.ok=!1,0;if(e=(e|(n&127)<>>0,n<128)return e}return this.ok=!1,0}nextI32(){let e=this.nextU32();return e>>>1^-(e&1)}}function lr(e){let t=0xcbf29ce484222325n,n=0x100000001b3n,i=0xffffffffffffffffn;for(let s=0;stypeof e[g]==="number"?e[g]:v,n=t("l",0),i=t("c",0),s=t("a",255)/255,r=t("m",1),o=t("w",0),a=o/2,c=r===0&&o!==0,p=e.d instanceof Uint8Array?e.d:new Uint8Array(0),l=new ar(p),h=[],d=[],u=0,f=0;while(l.more()){let g=l.nextU32(),v=h.length,y=1/0,w=1/0,k=-1/0,A=-1/0;if(r===2)u=u+l.nextI32()|0,f=f+l.nextI32()|0,h.push(u,f),y=k=u,w=A=f;else{let L=Math.min(l.nextU32(),1048576);for(let B=0;Bk)k=u;if(fA)A=f}}let N=(h.length-v)/2;if(N>0){let L=r===2||N===1?2:r===0?0:1,B=r===0?0:a;d.push({info:g,x0:y-B,y0:w-B,x1:k+B,y1:A+B,at:v,n:N,kind:L})}}return{layer:n,color:i,alpha:s,mode:r,r:a,own:c,pts:new Float32Array(h),pieces:d}}function cr(e,t,n){let i=(o)=>Array.isArray(o)&&o.length>=4?[Number(o[0])||0,Number(o[1])||0,Number(o[2])||0,Number(o[3])||0]:[0,0,0,0],s=Array.isArray(e.cs)?e.cs:[],r=[];for(let o=0;o=0&&a0){n.delete(a.h),n.set(a.h,c);while(n.size>1024){let p=n.keys().next().value;if(p!==void 0)n.delete(p);else break}}}}return{key:typeof e.key==="string"?e.key:"",fam:typeof e.fam==="string"?e.fam:"",base:typeof e.base==="string"?e.base:"",box:i(e.box),edge:i(e.edge),thick:typeof e.thick==="number"?e.thick:1600,note:typeof e.note==="string"?e.note:"",warn:typeof e.warn==="number"?e.warn!==0:!1,chunks:r}}function dr(e,t,n,i=!0){if(n.width<=0||n.height<=0||n.naturalWidth<=0||n.naturalHeight<=0)return null;let s=Math.min(n.width/n.naturalWidth,n.height/n.naturalHeight),r=n.naturalWidth*s,o=n.naturalHeight*s,a=n.left+(n.width-r)/2,c=i?n.top:n.top+(n.height-o)/2,p=(e-a)/r,l=(t-c)/o;if(p<0||p>1||l<0||l>1)return null;return{x:Math.max(0,Math.min(1000,Math.round(p*1000))),y:Math.max(0,Math.min(1000,Math.round(l*1000)))}}var pr=[["Enter","Enter"],["Tab","Tab"],["Bksp","Backspace"],["Esc","Escape"],["↑","ArrowUp"],["↓","ArrowDown"],["←","ArrowLeft"],["→","ArrowRight"]];function hr(e){let t=e.trim();if(!t)return"";if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))return t;return`https://${t}`}class di{tail=Promise.resolve();enqueue(e){let t=this.tail.then(e,e);return this.tail=t.catch(()=>{}),t}}function mr(e,t,n){let i=!0,s=!1,r=!1,o="",a=!1,c=!1,p=-1,l=null,h=new di,d=document.createElement("div");d.className="bp-pane bp-browser-pane",d.setAttribute("data-testid","pane-browser");let u=document.createElement("div");u.className="bp-pane-bar bp-browser-nav";function f(te,we,E){let x=document.createElement("button");if(x.type="button",x.className="bp-v-btn",x.textContent=te,x.setAttribute("data-testid",we),E)x.title=E;return x}let g=f("←","browser-back","Back"),v=f("→","browser-forward","Forward"),y=f("↻","browser-reload","Reload"),w=document.createElement("form");w.className="bp-browser-url-form";let k=document.createElement("input");k.type="text",k.className="bp-browser-input",k.placeholder="https://…",k.autocomplete="off",k.spellcheck=!1,k.setAttribute("data-testid","browser-url");let A=f("Go","browser-go","Navigate");A.type="submit",w.append(k,A);let N=f("Take over","browser-takeover");N.classList.add("is-primary"),u.append(g,v,y,w,N);let L=document.createElement("div");L.className="bp-browser-drive-bar",L.hidden=!0;let B=document.createElement("div");B.className="bp-browser-keys-row";let T=document.createElement("input");T.type="text",T.className="bp-browser-input",T.placeholder="Type text or press Enter/Tab/Arrows…",T.autocomplete="off",T.spellcheck=!1,T.setAttribute("data-testid","browser-keys");let H=f("Send","browser-type-send");B.append(T,H);let F=document.createElement("div");F.className="bp-browser-quick-keys";for(let[te,we]of pr){let E=f(te,`browser-key-${we}`);E.addEventListener("click",()=>ne("press",{key:we})),F.append(E)}L.append(B,F);let P=document.createElement("div");P.className="bp-browser-err",P.setAttribute("data-testid","browser-error"),P.hidden=!0;let K=document.createElement("div");K.className="bp-browser-stage",K.setAttribute("data-testid","browser-stage");let ae=document.createElement("img");ae.className="bp-browser-img",ae.alt="Hub browser screen",ae.draggable=!1,ae.hidden=!0,ae.setAttribute("data-testid","browser-frame");let re=document.createElement("div");re.className="bp-pane-empty",re.setAttribute("data-testid","browser-empty"),re.textContent="Loading browser screen…",K.append(ae,re);let ve=document.createElement("div");ve.className="bp-browser-hint",ve.textContent="You have the page: click to tap, scroll to wheel, type in the key box. Hand it back when done.",ve.hidden=!0,d.append(u,L,P,K,ve),e.replaceChildren(d);function Ae(te){P.textContent=te,P.hidden=!te}function ke(){L.hidden=!s,ve.hidden=!s,N.textContent=s?"Hand back":"Take over",N.setAttribute("data-testid",s?"browser-handback":"browser-takeover"),N.classList.toggle("is-on",s),ae.classList.toggle("is-driving",s)}function ne(te,we={},E){h.enqueue(async()=>{if(!i)return;Ae("");try{if(await t.hub.rpc("browser",{thread:n,op:te,...we}),!i)return;E?.(),he()}catch(x){if(!i)return;Ae(x instanceof Error?x.message:String(x))}})}function le(te){ne("toolbar",{command:te},()=>{s=!0,ke()})}g.addEventListener("click",()=>le("back")),v.addEventListener("click",()=>le("forward")),y.addEventListener("click",()=>le("reload")),w.addEventListener("submit",(te)=>{te.preventDefault();let we=hr(k.value);if(!we)return;if(k.value=we,!s)ne("takeover",{},()=>{s=!0,ke()});ne("navigate",{url:we},()=>{s=!0,ke()})}),N.addEventListener("click",()=>{if(s)ne("handback",{},()=>{s=!1,ke()});else ne("takeover",{},()=>{s=!0,ke(),T.focus()})});function R(){let te=T.value;if(!te)return;T.value="",ne("type",{text:te})}H.addEventListener("click",R),T.addEventListener("keydown",(te)=>{if(!s)return;if(te.key==="Enter"){if(te.preventDefault(),T.value)R();ne("press",{key:"Enter"});return}if(te.key==="Tab"||te.key==="Escape"||te.key==="ArrowUp"||te.key==="ArrowDown"||te.key==="ArrowLeft"||te.key==="ArrowRight"||te.key==="Backspace"&&T.value==="")te.preventDefault(),ne("press",{key:te.key})}),ae.addEventListener("click",(te)=>{if(!s||!r)return;let we=ae.getBoundingClientRect(),E=dr(te.clientX,te.clientY,{left:we.left,top:we.top,width:we.width,height:we.height,naturalWidth:ae.naturalWidth,naturalHeight:ae.naturalHeight});if(!E)return;ne("click",E)}),ae.addEventListener("wheel",(te)=>{if(!s||!r)return;te.preventDefault();let we=Math.round(te.deltaX),E=Math.round(te.deltaY);if(we===0&&E===0)return;ne("scroll",{dx:we,dy:E})},{passive:!1});async function he(){if(!i)return;if(a){c=!0;return}a=!0;try{do{c=!1,l=new AbortController;let te=await fetch(`/bots/${encodeURIComponent(n)}/screen.jpg`,{credentials:"same-origin",cache:"no-store",signal:l.signal});if(!i)return;if(te.ok){let we=await te.blob();if(!i)return;let E=URL.createObjectURL(we),x=o;if(o=E,ae.src=E,ae.hidden=!1,re.hidden=!0,r=!0,x)URL.revokeObjectURL(x)}else if(!r)ae.hidden=!0,re.hidden=!1,re.textContent="No browser page yet. An agent opens one when it needs the web."}while(i&&c)}catch{if(!i)return;if(!r)ae.hidden=!0,re.hidden=!1,re.textContent="No browser page yet. An agent opens one when it needs the web."}finally{l=null,a=!1}}let ce=t.hub.onFrame((te)=>{if(!i)return;if(te.t==="shot"&&te.bot===n){if(typeof te.n==="number"){if(te.n===p)return;p=te.n}he()}});return he(),{destroy(){if(i=!1,ce(),l?.abort(),o)URL.revokeObjectURL(o),o=""}}}function U(e,t,n){let i=document.createElement(e);if(t)i.className=t;if(n!==void 0)i.textContent=n;return i}function vn(e){if(!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;if(e<1048576)return`${Math.round(e/1024)} KB`;return`${(e/1048576).toFixed(1)} MB`}function br(e){let t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}function $o(e){return["png","jpg","jpeg","gif","webp","svg","bmp","ico"].includes(e)}function ur(e){return["txt","md","markdown","json","toml","yaml","yml","xml","csv","tsv","rs","ts","tsx","js","mjs","cjs","jsx","css","html","htm","sh","bash","py","c","h","cc","cpp","hpp","go","java","kt","swift","rb","lua","sql","ini","cfg","conf","env","gitignore","lock","log","gbr","gtl","gbl","gts","gbs","gto","gbo","gm1","drl","pos","net","kicad_pro","kicad_prl","kicad_dru","kicad_sym","kicad_mod","kicad_wks"].includes(e)}function Oo(e){let t=br(e);if(t==="kicad_pcb")return"board";if(t==="kicad_sch")return"schematic";if(t==="step"||t==="stp"||t==="glb")return"mech";return null}function gr(e,t,n,i){let s=!0,r="",o="",a=U("div","bp-pane bp-files-pane");a.setAttribute("data-testid","pane-files");let c=U("div","bp-pane-bar"),p=U("div","bp-files-crumbs"),l=U("button","bp-v-btn","Refresh");l.type="button",l.addEventListener("click",()=>void v(r)),c.append(p,l);let h=U("div","bp-files-split"),d=U("div","bp-files-list");d.setAttribute("data-testid","files-list");let u=U("div","bp-files-preview");u.setAttribute("data-testid","files-preview"),u.append(U("div","bp-pane-empty","Select a file to preview")),h.append(d,u),a.append(c,h),e.replaceChildren(a);function f(){p.replaceChildren();let y=U("button","bp-crumb-btn","project");if(y.type="button",y.addEventListener("click",()=>void v("")),p.append(y),!r)return;let w=r.split("/").filter(Boolean),k="";for(let A of w){k=k?`${k}/${A}`:A;let N=k;p.append(U("span","bp-vh-sep","/"));let L=U("button","bp-crumb-btn",A);L.type="button",L.addEventListener("click",()=>void v(N)),p.append(L)}}async function g(y,w,k){o=y,u.replaceChildren();let A=U("div","bp-files-prev-head");A.append(U("span","bp-files-prev-name",y));let N=U("div","bp-files-prev-acts"),L=Oo(w);if(L){let F=U("button","bp-v-btn is-primary",`Open in ${L}`);F.type="button",F.setAttribute("data-testid","files-open-viewer"),F.addEventListener("click",()=>i(L,y)),N.append(F)}let B=`/files/get?thread=${encodeURIComponent(n)}&path=${encodeURIComponent(y)}`,T=U("a","bp-v-btn","Download");T.href=B,T.download=w,N.append(T),A.append(N),u.append(A);let H=br(w);if($o(H)){let F=U("div","bp-files-img-wrap"),P=document.createElement("img");P.className="bp-files-img",P.alt=w,P.src=B,F.append(P),u.append(F);return}if(k>524288&&!ur(H)){u.append(U("div","bp-pane-empty",`Binary file (${vn(k)}). Use Download to save.`));return}if(ur(H)||k<=65536){let F=U("div","bp-pane-empty","Loading…");u.append(F);try{let P=await fetch(B,{credentials:"same-origin"});if(!s||o!==y)return;if(!P.ok){F.textContent=`Could not load file (${P.status})`;return}if((P.headers.get("content-type")||"").startsWith("image/")){F.remove();let ce=document.createElement("img");ce.className="bp-files-img",ce.alt=w,ce.src=B,u.append(ce);return}let ae=262144,re=[],ve=0,Ae=!1;if(P.body){let ce=P.body.getReader();try{while(!0){let{done:te,value:we}=await ce.read();if(te||!we)break;if(ve+we.byteLength>ae){let E=ae-ve;if(E>0)re.push(we.subarray(0,E)),ve+=E;Ae=!0,await ce.cancel();break}re.push(we),ve+=we.byteLength}}finally{ce.releaseLock()}}if(!s||o!==y)return;let ke=new Uint8Array(ve),ne=0;for(let ce of re)ke.set(ce,ne),ne+=ce.byteLength;let le=!1;for(let ce=0;ceA.dir===N.dir?A.name.localeCompare(N.name):A.dir?-1:1),d.replaceChildren(),y){let A=U("button","bp-file-row is-dir");A.type="button",A.append(U("span","bp-file-icon","↰"),U("span","bp-file-name",".."));let N=y.includes("/")?y.slice(0,y.lastIndexOf("/")):"";A.addEventListener("click",()=>void v(N)),d.append(A)}if(k.length===0){d.append(U("div","bp-pane-empty","Empty folder"));return}for(let A of k){let N=y?`${y}/${A.name}`:A.name,L=U("button","bp-file-row"+(A.dir?" is-dir":"")+(N===o?" is-sel":""));L.type="button",L.setAttribute("data-testid",`file-row-${A.name}`),L.append(U("span","bp-file-icon",A.dir?"▸":"·"),U("span","bp-file-name",A.name),U("span","bp-file-size",A.dir?"":vn(A.size))),L.addEventListener("click",()=>{if(A.dir)v(N);else d.querySelectorAll(".bp-file-row.is-sel").forEach((B)=>B.classList.remove("is-sel")),L.classList.add("is-sel"),g(N,A.name,A.size)}),d.append(L)}}catch(w){if(!s)return;d.replaceChildren(U("div","bp-pane-empty",w instanceof Error?w.message:String(w)))}}return v(""),{destroy(){s=!1}}}function fr(e,t,n){let i=!0,s=U("div","bp-pane bp-diff-pane");s.setAttribute("data-testid","pane-diff");let r=U("div","bp-pane-bar"),o=U("span","bp-diff-summary","Loading diff…"),a=U("button","bp-v-btn","Refresh");a.type="button",a.addEventListener("click",()=>void p()),r.append(o,a);let c=U("div","bp-diff-body");c.setAttribute("data-testid","diff-body"),s.append(r,c),e.replaceChildren(s);async function p(){o.textContent="Loading diff…",c.replaceChildren();try{let l=await t.hub.rpc("viewer.diff",{thread:n});if(!i)return;if(l?.nogit){o.textContent="Not a git repository",c.append(U("div","bp-pane-empty","This project is not a git repository."));return}let h=typeof l?.diff==="string"?l.diff:"";if(!h.trim()){o.textContent="Clean working tree",c.append(U("div","bp-pane-empty","No uncommitted changes."));return}let d=h.split(` +`),u=0,f=0,g=0,v=document.createDocumentFragment(),y=U("div","bp-diff-file");for(let w of d){if(w.startsWith("diff --git ")){if(y.childNodes.length>0)v.append(y);y=U("div","bp-diff-file"),u++;let k=w.match(/ b\/(.+)$/);y.append(U("div","bp-diff-file-head",k?k[1]:w));continue}if(w.startsWith("index ")||w.startsWith("--- ")||w.startsWith("+++ "))y.append(U("div","bp-diff-line is-meta",w));else if(w.startsWith("@@"))y.append(U("div","bp-diff-line is-hunk",w));else if(w.startsWith("+"))f++,y.append(U("div","bp-diff-line is-add",w));else if(w.startsWith("-"))g++,y.append(U("div","bp-diff-line is-del",w));else y.append(U("div","bp-diff-line",w))}if(y.childNodes.length>0)v.append(y);o.textContent=`${u||1} file${u===1?"":"s"} · +${f} -${g}`,c.append(v)}catch(l){if(!i)return;o.textContent="Diff unavailable",c.append(U("div","bp-pane-empty",l instanceof Error?l.message:String(l)))}}return p(),{destroy(){i=!1}}}function Go(e,t){let n=t.rel||"",i=t.manifest||{},s=(p)=>`/files/get?thread=${encodeURIComponent(e)}&path=${encodeURIComponent(`${n}/${p}`)}`,r=(p)=>typeof p==="string"&&p!==""&&!p.startsWith("/")&&!p.split(/[\\/]/).includes(".."),o=(Array.isArray(i.drawings)?i.drawings:[]).filter((p)=>r(p?.file)),a=new Set(o.map((p)=>p.file)),c=o.map((p)=>({title:p.title||p.kind||p.file,file:p.file,url:s(p.file),drawing:!0}));for(let p of Array.isArray(i.files)?i.files:[])if(r(p)&&!a.has(p))c.push({title:p,file:p,url:s(p),drawing:!1});return c}function vr(e,t,n){let i=!0,s="checks",r=U("div","bp-pane bp-review-pane");r.setAttribute("data-testid","pane-review");let o=U("div","bp-pane-bar"),a=U("div","bp-review-tabs"),c=U("button","bp-v-btn is-on","Checks"),p=U("button","bp-v-btn","BOM"),l=U("button","bp-v-btn","Comments"),h=U("button","bp-v-btn","Release");h.setAttribute("data-testid","review-tab-release"),c.type=p.type=l.type=h.type="button",a.append(c,p,l,h);let d=U("button","bp-v-btn","Refresh");d.type="button",d.addEventListener("click",()=>void y()),o.append(a,d);let u=U("div","bp-review-body");u.setAttribute("data-testid","review-body"),r.append(o,u),e.replaceChildren(r);function f(w){s=w,c.classList.toggle("is-on",s==="checks"),p.classList.toggle("is-on",s==="bom"),l.classList.toggle("is-on",s==="comments"),h.classList.toggle("is-on",s==="release"),y()}c.addEventListener("click",()=>f("checks")),p.addEventListener("click",()=>f("bom")),l.addEventListener("click",()=>f("comments")),h.addEventListener("click",()=>f("release"));function g(w){let k=U("div","bp-review-md bp-review-release");k.setAttribute("data-testid","review-release");let A=w.manifest||{};k.append(U("h2","bp-review-h",w.tag||"Release")),k.append(U("p","bp-review-p",[A.commit?`Commit ${A.commit.slice(0,12)}`:"",A.date||""].filter(Boolean).join(" · ")));let N=Go(n,w),L=(T,H)=>{if(H.length===0)return;k.append(U("h3","bp-review-h",T));let F=U("table","bp-review-table");for(let P of H){let K=document.createElement("tr"),ae=U("td",void 0,P.title);ae.title=P.file;let re=document.createElement("td"),ve=U("a","bp-v-btn","Download");ve.href=P.url,ve.download=P.file.split("/").pop()||P.file,re.append(ve),K.append(ae,re),F.append(K)}k.append(F)};L("Drawings",N.filter((T)=>T.drawing));let B=Array.isArray(A.openFabNotes)?A.openFabNotes:[];if(B.length>0)k.append(U("div","bp-review-gate",`Open fabrication notes, not in the board (agree them with the fabricator): ${B.join(", ")}.`));if(L("Files",N.filter((T)=>!T.drawing)),w.rel){let T=U("a","bp-v-btn","Download all (.zip)");T.href=`/files/zip?thread=${encodeURIComponent(n)}&path=${encodeURIComponent(w.rel)}`,k.append(T)}return k}function v(w){let k=U("div","bp-review-md"),A=w.split(` +`),N=0;while(N{H.preventDefault();let F=B.value.trim();if(!F)return;T.disabled=!0,t.hub.rpc("review.comment",{thread:n,text:F}).then(()=>{B.value="",T.disabled=!1,y()},()=>{T.disabled=!1})}),u.append(L),N.length===0){u.append(U("div","bp-pane-empty","No review comments yet."));return}for(let H of N){let F=U("div","bp-review-comment"+(H.resolved?" is-resolved":"")),P=[H.by||"review",H.file,H.layer,H.item].filter(Boolean).join(" · ");F.append(U("div","bp-review-comment-meta",P),U("div","bp-review-comment-text",H.text)),u.append(F)}return}let w=await t.hub.rpc("review.page",{thread:n,page:s});if(!i)return;let k=w?.report||{};if(u.replaceChildren(),k.line||k.gate){let A=U("div","bp-review-gate",[k.gate,k.line].filter(Boolean).join(" · "));u.append(A)}if(k.err)u.append(U("div","bp-review-err",k.err));if(Array.isArray(k.tasks)&&k.tasks.length>0){let A=U("div","bp-review-tasks");k.tasks.forEach((N,L)=>{let B=U("label","bp-review-task"),T=document.createElement("input");T.type="checkbox",T.checked=!!(N.done??N.checked);let H=typeof N.index==="number"?N.index:L;T.addEventListener("change",()=>{t.hub.rpc("review.tick",{thread:n,index:H}).then(()=>void y(),()=>{})}),B.append(T,U("span",void 0,N.text||N.label||`Item ${L+1}`)),A.append(B)}),u.append(A)}if(s==="release"&&k.release&&k.release.manifest)u.append(g(k.release));else if(k.md&&k.md.trim())u.append(v(k.md));else if(!k.err&&(!k.tasks||k.tasks.length===0))u.append(U("div","bp-pane-empty",s==="release"?"No release yet. A release tags this design and makes its fabrication outputs and drawings in .backplane/releases.":`No ${s==="bom"?"BOM":"design checks"} report available.`))}catch(w){if(!i)return;u.replaceChildren(U("div","bp-pane-empty",w instanceof Error?w.message:String(w)))}}return y(),{destroy(){i=!1}}}function yr(e,t){let n=e>>>16&255,i=e>>>8&255,s=e&255;return t>=0.999?`rgb(${n},${i},${s})`:`rgba(${n},${i},${s},${t.toFixed(3)})`}class pi{canvas;ctx;frame=null;masks={off:0,dim:0,lift:255};highlights=new Set;lightTheme=!1;cx=0;cy=0;scale=0.0001;fittedKey="";fitW=0;fitH=0;userMoved=!1;dirty=!1;rafId=0;pointers=new Map;dragStart=null;pinchStart=null;resizeObs;cbs;constructor(e,t={}){this.cbs=t,this.canvas=document.createElement("canvas"),this.canvas.className="bp-viewer-canvas",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.style.touchAction="none",e.appendChild(this.canvas);let n=this.canvas.getContext("2d");if(!n)throw Error("Canvas2D unavailable");this.ctx=n,this.resizeObs=new ResizeObserver(()=>this.scheduleDraw()),this.resizeObs.observe(this.canvas),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.canvas.addEventListener("pointermove",this.onPointerMove),this.canvas.addEventListener("pointerup",this.onPointerUp),this.canvas.addEventListener("pointercancel",this.onPointerUp),this.canvas.addEventListener("wheel",this.onWheel,{passive:!1}),this.canvas.addEventListener("dblclick",this.onDblClick)}setTheme(e){if(this.lightTheme!==e)this.lightTheme=e,this.scheduleDraw()}setFrame(e){if(this.frame=e,e&&e.key!==this.fittedKey)this.fittedKey=e.key,this.fit();else this.scheduleDraw()}setLayers(e){this.masks=e,this.scheduleDraw()}setHighlights(e){this.highlights.clear();for(let[t,n]of e)this.highlights.add(`${t}:${n}`);this.scheduleDraw()}presentMask(){if(!this.frame)return 0;let e=0;for(let t of this.frame.chunks)if(t.layer<32)e=(e|1<>>0;return e>>>0}presentColors(){let e=new Map;if(!this.frame)return e;for(let t of this.frame.chunks)if(!e.has(t.layer))e.set(t.layer,t.color);return e}applyFit(e,t){if(!this.frame||e<10||t<10)return;let n=this.frame.box,i=Math.max(n[2]-n[0],1000),s=Math.max(n[3]-n[1],1000);this.cx=(n[0]+n[2])*0.5,this.cy=(n[1]+n[3])*0.5,this.scale=Math.min(e/i,t/s)*0.92,this.fitW=e,this.fitH=t,this.userMoved=!1}fit(){if(!this.frame)return;this.userMoved=!1,this.fitW=0,this.fitH=0;let e=this.canvas.getBoundingClientRect();if(e.width>=10&&e.height>=10)this.applyFit(e.width,e.height);this.scheduleDraw()}zoomToBoxMm(e){let t=e[0]*1000,n=e[1]*1000,i=e[2]*1000,s=e[3]*1000,r=Math.max(i-t,1000),o=Math.max(s-n,1000),a=this.canvas.getBoundingClientRect(),c=Math.max(a.width,200),p=Math.max(a.height,200);this.cx=(t+i)*0.5,this.cy=(n+s)*0.5,this.scale=Math.min(c/r,p/o)*0.85,this.userMoved=!0,this.scheduleDraw()}scheduleDraw(){if(this.dirty)return;this.dirty=!0,this.rafId=requestAnimationFrame(()=>{this.dirty=!1,this.rafId=0,this.draw()})}draw(){let e=this.canvas.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height)),i=Math.min(window.devicePixelRatio||1,2),s=Math.round(t*i),r=Math.round(n*i);if(this.canvas.width!==s||this.canvas.height!==r)this.canvas.width=s,this.canvas.height=r;let o=this.ctx;o.setTransform(i,0,0,i,0,0),o.fillStyle=this.lightTheme?"#f5f4ef":"#08090b",o.fillRect(0,0,t,n);let a=this.frame;if(!a)return;if(!this.userMoved&&t>=10&&n>=10&&(Math.abs(this.fitW-t)>2||Math.abs(this.fitH-n)>2))this.applyFit(t,n);let c=t*0.5,p=n*0.5,l=this.scale,h=this.cx,d=this.cy,u=h-c/l,f=h+c/l,g=d-p/l,v=d+p/l,{off:y,dim:w,lift:k}=this.masks,A=[],N=[];for(let B=0;B>>T&1)===1)continue;if(T===k)N.push(B);else A.push(B)}let L=A.concat(N);o.lineCap="round",o.lineJoin="round";for(let B=0;B>>H.layer&1)===1,P=H.alpha*(F?0.25:1);if(P<=0.01)continue;this.drawChunk(o,H,P,u,g,f,v,h,d,l,c,p)}if(this.highlights.size>0){o.fillStyle=this.lightTheme?"rgba(245,244,239,0.72)":"rgba(8,9,11,0.72)",o.fillRect(0,0,t,n);let B=this.lightTheme?"rgba(27,29,33,0.77)":"rgba(217,221,228,0.77)";for(let T=0;Tr||v.y1o)continue;if(v.n<3)continue;let y=(d[v.at]-a)*p+l,w=(d[v.at+1]-c)*p+h;e.moveTo(y,w);for(let k=1;k0)e.fill()}else if(t.mode===2){let f=Math.max(0.75,t.r*p);e.fillStyle=u,e.beginPath();let g=0;for(let v=0;vr||y.y1o)continue;let w=(d[y.at]-a)*p+l,k=(d[y.at+1]-c)*p+h;e.moveTo(w+f,k),e.arc(w,k,f,0,Math.PI*2),g++}if(g>0)e.fill()}else{e.strokeStyle=u,e.lineWidth=Math.max(1,t.r*2*p),e.beginPath();let f=0;for(let g=0;gr||v.y1o)continue;let y=(d[v.at]-a)*p+l,w=(d[v.at+1]-c)*p+h;if(v.n===1)e.moveTo(y,w),e.lineTo(y+0.01,w);else{e.moveTo(y,w);for(let k=1;k0)e.stroke()}}drawLitPieces(e,t,n,i,s,r,o,a,c,p,l,h,d){let u=t.pts,f=yr(t.color,t.alpha);for(let g=0;go||v.y1a)continue;let y=(u[v.at]-c)*l+h,w=(u[v.at+1]-p)*l+d;if(v.kind===2){let k=Math.max(1.5,t.r*l);e.fillStyle=f,e.beginPath(),e.arc(y,w,k,0,Math.PI*2),e.fill(),e.strokeStyle=i,e.lineWidth=1.5,e.stroke()}else if(v.kind===0&&v.n>=3){e.fillStyle=f,e.beginPath(),e.moveTo(y,w);for(let k=1;k=0;l--){let h=n.chunks[l];if(h.layer<32&&(p>>>h.layer&1)===1)continue;for(let d=0;du.x1+o||ru.y1+o)continue;let f=(u.x1-u.x0+1)*(u.y1-u.y0+1);if(f{if(this.canvas.setPointerCapture(e.pointerId),this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===1)this.dragStart={x:e.clientX,y:e.clientY,cx:this.cx,cy:this.cy,moved:!1},this.pinchStart=null;else if(this.pointers.size===2){let[t,n]=Array.from(this.pointers.values());this.pinchStart={dist:Math.hypot(n.x-t.x,n.y-t.y)||1,midX:(t.x+n.x)*0.5,midY:(t.y+n.y)*0.5,scale:this.scale,cx:this.cx,cy:this.cy},this.dragStart=null}};onPointerMove=(e)=>{if(!this.pointers.has(e.pointerId))return;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===2&&this.pinchStart){let[t,n]=Array.from(this.pointers.values()),i=Math.hypot(n.x-t.x,n.y-t.y)||1,s=(t.x+n.x)*0.5,r=(t.y+n.y)*0.5,o=i/this.pinchStart.dist,a=Math.max(0.0000001,Math.min(2,this.pinchStart.scale*o)),c=this.canvas.getBoundingClientRect(),p=this.pinchStart.midX-c.left-c.width*0.5,l=this.pinchStart.midY-c.top-c.height*0.5,h=s-c.left-c.width*0.5,d=r-c.top-c.height*0.5;this.scale=a,this.cx=this.pinchStart.cx+p/this.pinchStart.scale-h/a,this.cy=this.pinchStart.cy+l/this.pinchStart.scale-d/a,this.userMoved=!0,this.cbs.onUserMove?.(),this.scheduleDraw();return}if(this.dragStart&&this.pointers.size===1){let t=e.clientX-this.dragStart.x,n=e.clientY-this.dragStart.y;if(Math.hypot(t,n)>3)this.dragStart.moved=!0;if(this.dragStart.moved)this.cx=this.dragStart.cx-t/this.scale,this.cy=this.dragStart.cy-n/this.scale,this.userMoved=!0,this.cbs.onUserMove?.(),this.scheduleDraw()}};onPointerUp=(e)=>{let t=this.dragStart&&!this.dragStart.moved&&this.pointers.size===1;if(this.pointers.delete(e.pointerId),this.pointers.size<2)this.pinchStart=null;if(this.pointers.size===0)this.dragStart=null;if(t&&this.cbs.onPick){let n=this.canvas.getBoundingClientRect(),i=this.hitTest(e.clientX-n.left,e.clientY-n.top);this.cbs.onPick(i)}};onWheel=(e)=>{e.preventDefault();let t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left-t.width*0.5,i=e.clientY-t.top-t.height*0.5,s=e.deltaY<0?1.16:0.8620689655172414,r=Math.max(0.0000001,Math.min(2,this.scale*s));this.cx+=n/this.scale-n/r,this.cy+=i/this.scale-i/r,this.scale=r,this.userMoved=!0,this.cbs.onUserMove?.(),this.scheduleDraw()};onDblClick=()=>{this.fit()};destroy(){if(this.rafId)cancelAnimationFrame(this.rafId);this.resizeObs.disconnect(),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.remove()}}var wr=[{id:"fit",label:"Fit"},{id:"iso",label:"Iso"},{id:"top",label:"Top"},{id:"bottom",label:"Bottom"},{id:"front",label:"Front"},{id:"right",label:"Right"},{id:"back",label:"Back"},{id:"left",label:"Left"}];function Er(e){switch(e){case"top":return{yaw:0,pitch:Math.PI*0.499};case"bottom":return{yaw:0,pitch:-Math.PI*0.499};case"front":return{yaw:0,pitch:0};case"right":return{yaw:Math.PI*0.5,pitch:0};case"back":return{yaw:Math.PI,pitch:0};case"left":return{yaw:-Math.PI*0.5,pitch:0};case"iso":case"fit":default:return{yaw:0.6,pitch:0.7}}}function hi(e,t,n,i){if(!e||!t||!n||!i)return!1;if(!e.startsWith(t))return!1;let s=e.slice(t.length).split(` +`),r=(s[0]||"").split("\t");if(r[0]!=="git"||r[2]!==n)return!1;let o=s[1]||r.slice(4).join("\t");if(!o)return!1;let a=o.replace(/\\/g,"/"),c=i.replace(/\\/g,"/");if(c.startsWith("/")||/^[A-Za-z]:\//.test(c))return a===c;return a===c||a.endsWith(`/${c}`)}class mi{refs=[];index=-1;lastCommit="";highlightEdits=!1;playing=!1;setRefs(e){if(this.refs=e,this.index>=e.length)this.index=-1,this.highlightEdits=!1}isLive(){return this.index<0||this.index>=this.refs.length}activeRef(){return this.isLive()?null:this.refs[this.index]}step(e){if(this.refs.length===0)return!1;let t=this.index;if(e>0)this.index=Math.min(this.refs.length-1,this.index+1);else this.index=Math.max(-1,this.index-1);if(this.index===-1)this.playing=!1,this.highlightEdits=!1;else this.lastCommit=this.refs[this.index].commit,this.highlightEdits=!0;return this.index!==t}selectCommit(e){if(!e)return this.goLive();let t=this.refs.findIndex((i)=>i.commit===e);if(t<0)return!1;let n=this.index!==t||!this.highlightEdits;return this.index=t,this.lastCommit=e,this.highlightEdits=!0,n}goLive(){let e=this.index!==-1||this.playing||this.highlightEdits;return this.index=-1,this.playing=!1,this.highlightEdits=!1,e}toggleHighlight(){if(this.highlightEdits)return this.goLive(),!1;if(this.refs.length===0)return!1;let e=this.lastCommit?this.refs.findIndex((t)=>t.commit===this.lastCommit):0;return this.index=e>=0?e:0,this.lastCommit=this.refs[this.index].commit,this.highlightEdits=!0,!0}compareRequest(){let e=this.activeRef();if(!e||!this.highlightEdits)return null;return{commit:e.commit,bits:0}}}var Vo=`#version 300 es precision highp float; out vec2 vUv; void main() { @@ -20,7 +20,7 @@ void main() { vUv = vec2(x * 0.5 + 0.5, 1.0 - (y * 0.5 + 0.5)); gl_Position = vec4(x, y, 0.0, 1.0); } -`,Do=`#version 300 es +`,Uo=`#version 300 es precision highp float; in vec2 vUv; uniform vec3 uBgTop; @@ -37,7 +37,7 @@ void main() { vec3 lin = mix(uBgTop, uBgBot, clamp(vUv.y, 0.0, 1.0)); outColor = vec4(linearToSrgb(clamp(lin, 0.0, 1.0)), 1.0); } -`,Fo=`#version 300 es +`,Wo=`#version 300 es precision highp float; layout(location = 0) in vec3 aPos; layout(location = 1) in vec3 aNrm; @@ -55,7 +55,7 @@ void main() { vCol = aCol; gl_Position = uMvp * vec4(aPos, 1.0); } -`,$o=`#version 300 es +`,_o=`#version 300 es precision highp float; in vec3 vPos; in vec3 vNrm; @@ -151,8 +151,8 @@ void main() { rgb = rgb / (vec3(1.0) + max(rgb - vec3(0.8), vec3(0.0)) * 0.28); outColor = vec4(linearToSrgb(clamp(rgb, 0.0, 1.0)), alpha * uFade); } -`;function Ze(e){let t=e/255;return t<=0.04045?t/12.92:Math.pow((t+0.055)/1.055,2.4)}var Oo=[Ze(77),Ze(83),Ze(94)],Go=[Ze(53),Ze(58),Ze(67)],Vo=[Ze(245),Ze(246),Ze(248)],Uo=[Ze(225),Ze(228),Ze(233)];function fr(e,t,n){let i=e.createShader(t);if(!i)throw Error("createShader failed");if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){let s=e.getShaderInfoLog(i)||"shader compile error";throw e.deleteShader(i),Error(s)}return i}function vr(e,t,n){let i=fr(e,e.VERTEX_SHADER,t),s=fr(e,e.FRAGMENT_SHADER,n),r=e.createProgram();if(!r)throw Error("createProgram failed");if(e.attachShader(r,i),e.attachShader(r,s),e.linkProgram(r),e.deleteShader(i),e.deleteShader(s),!e.getProgramParameter(r,e.LINK_STATUS)){let o=e.getProgramInfoLog(r)||"program link error";throw e.deleteProgram(r),Error(o)}return r}function Wo(e,t){let n=new Float32Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++)n[i*4+s]=e[0+s]*t[i*4+0]+e[4+s]*t[i*4+1]+e[8+s]*t[i*4+2]+e[12+s]*t[i*4+3];return n}function _o(e,t,n,i){let s=1/Math.tan(e*0.5),r=1/(n-i),o=new Float32Array(16);return o[0]=s/t,o[5]=s,o[10]=(i+n)*r,o[11]=-1,o[14]=2*i*n*r,o}function wr(e){let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]}function yr(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function pi(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}class hi{canvas;gl=null;bgProg=null;bgVao=null;uBgTop=null;uBgBot=null;prog=null;uMvp=null;uEye=null;uRight=null;uUp=null;uFwd=null;uFade=null;worker=null;boardBatch=null;partBatches=[];activeKey="";lastMeshId="";nextJobId=1;partsTotal=0;partsDone=0;center=[0,0,0];target=[0,0,0];radius=50;dist=120;yaw=0.6;pitch=0.7;lightTheme=!1;dirty=!1;rafId=0;pointers=new Map;pinchDist=0;resizeObs;cbs;constructor(e,t={}){this.cbs=t,this.canvas=document.createElement("canvas"),this.canvas.className="bp-viewer-canvas",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.style.touchAction="none",e.appendChild(this.canvas);let n=this.canvas.getContext("webgl2",{antialias:!0,alpha:!1,preserveDrawingBuffer:!0});if(n)this.gl=n,this.bgProg=vr(n,Ho,Do),this.bgVao=n.createVertexArray(),this.uBgTop=n.getUniformLocation(this.bgProg,"uBgTop"),this.uBgBot=n.getUniformLocation(this.bgProg,"uBgBot"),this.prog=vr(n,Fo,$o),this.uMvp=n.getUniformLocation(this.prog,"uMvp"),this.uEye=n.getUniformLocation(this.prog,"uEye"),this.uRight=n.getUniformLocation(this.prog,"uRight"),this.uUp=n.getUniformLocation(this.prog,"uUp"),this.uFwd=n.getUniformLocation(this.prog,"uFwd"),this.uFade=n.getUniformLocation(this.prog,"uFade"),n.enable(n.DEPTH_TEST),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);else this.cbs.onStatus?.("WebGL2 is unavailable in this browser");try{this.worker=new Worker("/assets/mesh-worker.js",{type:"module"}),this.worker.onmessage=(i)=>this.onWorkerMessage(i.data)}catch{this.cbs.onStatus?.("3D worker unavailable")}this.resizeObs=new ResizeObserver(()=>this.scheduleDraw()),this.resizeObs.observe(this.canvas),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.canvas.addEventListener("pointermove",this.onPointerMove),this.canvas.addEventListener("pointerup",this.onPointerUp),this.canvas.addEventListener("pointercancel",this.onPointerUp),this.canvas.addEventListener("wheel",this.onWheel,{passive:!1}),this.canvas.addEventListener("dblclick",this.onDblClick),this.canvas.addEventListener("contextmenu",this.onContextMenu)}keptToken(){return this.activeKey&&this.lastMeshId?`${this.activeKey} ${this.lastMeshId}`:""}setTheme(e){if(this.lightTheme!==e)this.lightTheme=e,this.scheduleDraw()}handleFrame(e){let t=typeof e.key==="string"?e.key:"";if(!t)return;if(e.mesh instanceof Uint8Array&&typeof e.n==="number"&&!e.part){this.activeKey=t,this.lastMeshId=ir(e.mesh),this.clearParts(),this.cbs.onStatus?.("Building 3D model…");let n=new Uint8Array(e.mesh),i=e.faces instanceof Uint8Array?new Uint8Array(e.faces):void 0,s=[n.buffer];if(i)s.push(i.buffer);this.worker?.postMessage({id:this.nextJobId++,kind:"solid",key:t,n:e.n,mesh:n,faces:i},s);return}if(e.parts&&typeof e.parts==="object"&&!Array.isArray(e.parts)&&!(e.parts instanceof Uint8Array)){if(this.activeKey&&t!==this.activeKey)return;if(this.activeKey=t,this.clearParts(),this.partsTotal=typeof e.parts.of==="number"?e.parts.of:0,this.partsDone=0,this.partsTotal>0)this.cbs.onStatus?.(`Loading parts 0/${this.partsTotal}…`);this.scheduleDraw();return}if(typeof e.part==="string"&&e.mesh instanceof Uint8Array&&e.at instanceof Uint8Array&&typeof e.n==="number"){if(this.activeKey&&t!==this.activeKey)return;let n=new Uint8Array(e.mesh),i=new Uint8Array(e.at),s=e.faces instanceof Uint8Array?new Uint8Array(e.faces):void 0,r=[n.buffer,i.buffer];if(s)r.push(s.buffer);this.worker?.postMessage({id:this.nextJobId++,kind:"part",key:t,partId:e.part,n:e.n,mesh:n,at:i,faces:s,refs:Array.isArray(e.refs)?e.refs:[],done:typeof e.done==="number"?e.done:0},r)}}onWorkerMessage(e){if(e.error){this.cbs.onStatus?.(e.error);return}if(e.key!==this.activeKey||!this.gl)return;if(e.kind==="solid")this.deleteBatch(this.boardBatch),this.boardBatch=this.uploadBatch(e.positions,e.normals,e.colors,0),this.center=[e.center[0],e.center[1],e.center[2]],this.target=[e.center[0],e.center[1],e.center[2]],this.radius=e.radius,this.fit(),this.cbs.onStatus?.(""),this.scheduleDraw();else if(e.kind==="part"){let t=this.uploadBatch(e.positions,e.normals,e.colors,performance.now());if(t)this.partBatches.push(t);if(this.partsDone=e.done||this.partsDone+1,this.partsTotal>0&&this.partsDone>>24===0)r++;else o++;let a=r>0?new Float32Array(r*9):null,c=r>0?new Float32Array(r*9):null,p=r>0?new Float32Array(r*12):null,l=o>0?new Float32Array(o*9):null,h=o>0?new Float32Array(o*9):null,d=o>0?new Float32Array(o*12):null,u=0,f=0;for(let w=0;w>>24&255,L=1-k/255,M=(E>>>16&255)/255,A=(E>>>8&255)/255,B=(E&255)/255,T=w*9;if(k===0&&a&&c&&p){let H=u*9;for(let P=0;P<9;P++)a[H+P]=e[T+P],c[H+P]=t[T+P];let O=u*12;for(let P=0;P<3;P++)p[O+P*4]=M,p[O+P*4+1]=A,p[O+P*4+2]=B,p[O+P*4+3]=1;u++}else if(l&&h&&d){let H=f*9;for(let P=0;P<9;P++)l[H+P]=e[T+P],h[H+P]=t[T+P];let O=f*12;for(let P=0;P<3;P++)d[O+P*4]=M,d[O+P*4+1]=A,d[O+P*4+2]=B,d[O+P*4+3]=L;f++}}let b=a&&c&&p?this.createSubBatch(a,c,p,r*3):null,v=l&&h&&d?this.createSubBatch(l,h,d,o*3):null;if(!b&&!v)return null;return{opaque:b,translucent:v,fadeStartMs:i}}deleteSubBatch(e){let t=this.gl;if(!t||!e)return;t.deleteVertexArray(e.vao),t.deleteBuffer(e.posBuf),t.deleteBuffer(e.nrmBuf),t.deleteBuffer(e.colBuf)}deleteBatch(e){if(!e)return;this.deleteSubBatch(e.opaque),this.deleteSubBatch(e.translucent)}clearParts(){for(let e of this.partBatches)this.deleteBatch(e);this.partBatches=[]}fit(){this.setView("fit")}setView(e){let t=35*Math.PI/180;this.dist=this.radius/Math.sin(t*0.5)*1.15,this.target=[this.center[0],this.center[1],this.center[2]];let{yaw:n,pitch:i}=gr(e);this.yaw=n,this.pitch=i,this.scheduleDraw()}snapPng(){return this.draw(performance.now()),new Promise((e)=>{this.canvas.toBlob((t)=>e(t),"image/png")})}scheduleDraw(){if(this.dirty)return;this.dirty=!0,this.rafId=requestAnimationFrame((e)=>{if(this.dirty=!1,this.rafId=0,this.draw(e))this.scheduleDraw()})}drawSubBatch(e){if(!e||!this.gl)return;this.gl.bindVertexArray(e.vao),this.gl.drawArrays(this.gl.TRIANGLES,0,e.vertCount)}draw(e){let t=this.gl;if(!t||!this.prog)return!1;let n=this.canvas.getBoundingClientRect(),i=Math.max(1,Math.round(n.width)),s=Math.max(1,Math.round(n.height)),r=Math.min(window.devicePixelRatio||1,2),o=Math.round(i*r),a=Math.round(s*r);if(this.canvas.width!==o||this.canvas.height!==a)this.canvas.width=o,this.canvas.height=a;if(t.viewport(0,0,o,a),!this.boardBatch&&this.partBatches.length===0)return!1;if(t.depthMask(!0),t.clear(t.DEPTH_BUFFER_BIT),this.bgProg&&this.bgVao){t.disable(t.DEPTH_TEST),t.disable(t.BLEND),t.depthMask(!1),t.useProgram(this.bgProg);let H=this.lightTheme?Vo:Oo,O=this.lightTheme?Uo:Go;t.uniform3f(this.uBgTop,H[0],H[1],H[2]),t.uniform3f(this.uBgBot,O[0],O[1],O[2]),t.bindVertexArray(this.bgVao),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.bindVertexArray(null)}let c=Math.cos(this.pitch),p=Math.sin(this.pitch),l=Math.cos(this.yaw),h=Math.sin(this.yaw),d=[this.target[0]+this.dist*c*h,this.target[1]-this.dist*c*l,this.target[2]+this.dist*p],u=wr([this.target[0]-d[0],this.target[1]-d[1],this.target[2]-d[2]]),f=Math.abs(u[2])>0.99?[0,1,0]:[0,0,1],b=wr(yr(u,f)),v=yr(b,u),w=new Float32Array([b[0],v[0],-u[0],0,b[1],v[1],-u[1],0,b[2],v[2],-u[2],0,-pi(b,d),-pi(v,d),pi(u,d),1]),E=Math.max(0.05,this.dist*0.01),k=Math.max(this.dist*10,this.radius*20),L=_o(35*Math.PI/180,o/a,E,k),M=Wo(L,w);t.useProgram(this.prog),t.uniformMatrix4fv(this.uMvp,!1,M),t.uniform3f(this.uEye,d[0],d[1],d[2]),t.uniform3f(this.uRight,b[0],b[1],b[2]),t.uniform3f(this.uUp,v[0],v[1],v[2]),t.uniform3f(this.uFwd,u[0],u[1],u[2]);let A=!1,B=[],T=[];for(let H of this.partBatches){let O=e-H.fadeStartMs,P=H.fadeStartMs===0?1:Math.min(1,Math.max(0,O/300));if(P<1){if(A=!0,P>0)T.push({batch:H,fade:P})}else B.push(H)}if(t.enable(t.DEPTH_TEST),t.depthMask(!0),t.disable(t.BLEND),t.uniform1f(this.uFade,1),this.boardBatch)this.drawSubBatch(this.boardBatch.opaque);for(let H of B)this.drawSubBatch(H.opaque);if(t.depthMask(!1),t.enable(t.BLEND),t.uniform1f(this.uFade,1),this.boardBatch)this.drawSubBatch(this.boardBatch.translucent);for(let H of B)this.drawSubBatch(H.translucent);for(let{batch:H,fade:O}of T)t.uniform1f(this.uFade,O),this.drawSubBatch(H.opaque),this.drawSubBatch(H.translucent);return t.depthMask(!0),t.bindVertexArray(null),A}onPointerDown=(e)=>{if(this.canvas.setPointerCapture(e.pointerId),this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY,button:e.button,shift:e.shiftKey}),this.pointers.size===2){let[t,n]=Array.from(this.pointers.values());this.pinchDist=Math.hypot(n.x-t.x,n.y-t.y)||1}};onPointerMove=(e)=>{let t=this.pointers.get(e.pointerId);if(!t)return;let n=e.clientX-t.x,i=e.clientY-t.y;if(t.x=e.clientX,t.y=e.clientY,this.pointers.size===2){let[s,r]=Array.from(this.pointers.values()),o=Math.hypot(r.x-s.x,r.y-s.y)||1;if(this.pinchDist>0)this.dist=Math.max(this.radius*0.05,Math.min(this.radius*20,this.dist*(this.pinchDist/o)));this.pinchDist=o,this.cbs.onUserMove?.(),this.scheduleDraw();return}if(t.button===2||t.button===1||t.shift){let s=this.dist*0.0014,r=Math.cos(this.yaw),o=Math.sin(this.yaw);this.target[0]-=n*r*s,this.target[1]-=n*o*s,this.target[2]+=i*s}else this.yaw+=n*0.008,this.pitch=Math.max(-Math.PI*0.49,Math.min(Math.PI*0.49,this.pitch+i*0.008));this.cbs.onUserMove?.(),this.scheduleDraw()};onPointerUp=(e)=>{if(this.pointers.delete(e.pointerId),this.pointers.size<2)this.pinchDist=0};onWheel=(e)=>{e.preventDefault();let t=e.deltaY<0?0.8620689655172414:1.16;this.dist=Math.max(this.radius*0.05,Math.min(this.radius*20,this.dist*t)),this.cbs.onUserMove?.(),this.scheduleDraw()};onDblClick=()=>{this.fit()};onContextMenu=(e)=>{e.preventDefault()};destroy(){if(this.rafId)cancelAnimationFrame(this.rafId);if(this.resizeObs.disconnect(),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.deleteBatch(this.boardBatch),this.clearParts(),this.gl){if(this.bgVao)this.gl.deleteVertexArray(this.bgVao);if(this.bgProg)this.gl.deleteProgram(this.bgProg);if(this.prog)this.gl.deleteProgram(this.prog)}this.worker?.terminate(),this.canvas.remove()}}var Er=64,zo=16777216;function qo(e,t){switch(e){case"board":case"3d":return t.board!==!1;case"schematic":return t.schematic!==!1;case"mech":return t.mech!==!1;case"gerbers":return t.gerbers!==!1;default:return!0}}function Jt(e){if(!e)return"";let t=e.replace(/\\/g,"/").replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Cr(e){switch(e){case"board":return m("viewer.board","Board");case"schematic":return m("viewer.schematic","Schematic");case"3d":return m("viewer.solid","3D");case"gerbers":return m("gpui.gerbers","Gerbers");case"mech":return m("viewer.mech","Mech");case"files":return m("viewer.files","Files");case"diff":return m("viewer.diff","Diff");case"review":return m("viewer.review","Review");case"browser":return m("bots.tab.browser","Browser");case"terminal":return m("viewer.terminal","Terminal");default:return e?e.charAt(0).toUpperCase()+e.slice(1):""}}function mi(e){return e==="board"||e==="schematic"||e==="gerbers"}function Ko(e){return e==="files"||e==="diff"||e==="review"||e==="browser"||e==="terminal"}function ui(e,t){let n=document.createElement("div");n.className="bp-vh";let i=document.createElement("div");i.className="bp-vh-title";let s=document.createElement("span");s.className="bp-vh-page";let r=document.createElement("span");r.className="bp-vh-sep",r.textContent="·",r.hidden=!0;let o=document.createElement("span");o.className="bp-vh-file",o.hidden=!0,i.append(s,r,o);let a=document.createElement("div");a.className="bp-vh-actions",n.append(i,a);let c=document.createElement("div");c.className="bp-solid-bar",c.setAttribute("data-testid","solid-presets-bar"),c.hidden=!0;let p=document.createElement("div");p.className="bp-v-banner",p.hidden=!0;let l=document.createElement("div");l.className="bp-v-stage-wrap";let h=document.createElement("div");h.className="bp-v-stage";let d=document.createElement("div");d.className="bp-v-overlay",d.hidden=!0;let u=document.createElement("div");u.className="bp-v-layers",u.hidden=!0;let f=document.createElement("div");f.className="bp-v-info",f.hidden=!0,l.append(h,d,u,f);let b=document.createElement("div");b.className="bp-history-bar",b.setAttribute("data-testid","viewer-history-bar"),b.hidden=!0,e.replaceChildren(n,c,p,l,b);let v="",w="",E=0,k=!1,L=new Set,M=[],A=0,B=new Map,T=new Map,H={},O=[],P="",Y="",re=!1,ie=!1,me=0,Pe=!1,Ce=0,te="",oe=0,R=null,ue=null,de=null,ee=null,ge=null,C=new di,x=0,F=!1,I="",J="",se="",Ee="";document.addEventListener("click",(V)=>{if(!F)return;if(V.target instanceof Node&&b.contains(V.target))return;F=!1,Le()}),document.addEventListener("keydown",(V)=>{if(F&&V.key==="Escape")F=!1,Le()});function D(){if(x)window.clearInterval(x),x=0;C.playing=!1}function ne(){let V=w==="3d"||w==="mech";if(c.hidden=!V,!V)return;if(c.childElementCount>0)return;for(let _ of br){let G=document.createElement("button");G.type="button",G.className="bp-v-btn",G.textContent=_.label,G.setAttribute("data-testid",`solid-view-${_.id}`),G.addEventListener("click",()=>{de?.setView(_.id)}),c.append(G)}let W=document.createElement("button");W.type="button",W.className="bp-v-btn",W.textContent="Snap view",W.setAttribute("data-testid","solid-snap"),W.addEventListener("click",()=>{if(!de)return;de.snapPng().then((_)=>{if(!_)return;let G=URL.createObjectURL(_),z=document.createElement("a");z.href=G;let ae=($e()||w||"view").replace(/[^a-zA-Z0-9._-]/g,"_");z.download=`${ae}-snap.png`,z.click(),setTimeout(()=>URL.revokeObjectURL(G),1000)})}),c.append(W)}async function Te(){if(!v||w!=="board"&&w!=="schematic")return;Le();let V=C.compareRequest();if(!V){I="",J="",se="",Ee="",await ht(!1);return}let W=`${w}|${V.commit}|${V.bits}|${Y}`;if(W===Ee&&L.size>0){He(C.highlightEdits?`Comparing against ${C.activeRef()?.label||V.commit.slice(0,7)} (edits highlighted)`:`Comparing against ${C.activeRef()?.label||V.commit.slice(0,7)}`,!1);return}let _=++E;L.clear(),B.clear(),we(),k=!0,I="",J=V.commit,se="",Ee=W;try{let G=Y||(w==="schematic"?H.sch:H.pcb)||"";if(!G){let ke=await t.hub.rpc("viewer.files",{thread:v});if(_!==E)return;H=ke||{},Oe(),G=(w==="schematic"?H.sch:H.pcb)||""}if(!G)throw Error(`Unable to resolve ${w} file path for compare`);let z=await t.hub.rpc("viewer.compare",{thread:v,kind:w,commit:V.commit,bits:V.bits,...Y?{path:Y}:{}});if(_!==E)return;let ae=typeof z?.root==="string"?z.root:"",q=w==="schematic"?"1":"0";I=ae?`${q}|${ae}|diff -`:`${q}|`,J=V.commit,se=G.startsWith("/")||/^[A-Za-z]:[\\/]/.test(G)||!ae?G:`${ae.replace(/\/+$/,"")}/${G.replace(/^\/+/,"")}`,k=!1;let ye=M;we();for(let ke of ye)if(ke.kind==="bin")tt(ke.buf);else et(ke.key,ke.none,ke.retryable,ke.big);He(C.highlightEdits?`Comparing against ${C.activeRef()?.label||V.commit.slice(0,7)} (edits highlighted)`:`Viewing snapshot: ${C.activeRef()?.label||V.commit.slice(0,7)}`,!1)}catch(G){if(_!==E)return;k=!1,I="",J="",se="",Ee="",we(),He(G instanceof Error?G.message:String(G),!0)}}function Le(){let V=w==="board"||w==="schematic";if(b.hidden=!V,!V)return;let W=document.createElement("div");W.className="bp-history-group";let _=document.createElement("button");_.type="button",_.className="bp-v-btn",_.textContent="<",_.title="Older snapshot",_.disabled=C.refs.length===0||C.index>=C.refs.length-1,_.setAttribute("data-testid","history-prev"),_.addEventListener("click",()=>{if(D(),C.step(1))Te()});let G=document.createElement("button");G.type="button",G.className="bp-v-btn"+(C.playing?" is-on":""),G.textContent=C.playing?"⏸":"▶",G.title=C.playing?"Pause history":"Play history",G.disabled=C.refs.length===0,G.setAttribute("data-testid","history-play"),G.addEventListener("click",()=>{if(C.playing){D(),Le();return}if(C.refs.length===0)return;if(C.playing=!0,C.isLive())C.index=C.refs.length-1,Te();else Le();x=window.setInterval(()=>{if(!C.playing||w!=="board"&&w!=="schematic"){D(),Le();return}if(C.step(-1))Te();else D(),Le()},1400)});let z=document.createElement("button");z.type="button",z.className="bp-v-btn",z.textContent=">",z.title="Newer snapshot",z.disabled=C.isLive(),z.setAttribute("data-testid","history-next"),z.addEventListener("click",()=>{if(D(),C.step(-1))Te()});let ae=document.createElement("button");ae.type="button",ae.className="bp-v-btn"+(C.isLive()?" is-on":""),ae.textContent="Live",ae.setAttribute("data-testid","history-live"),ae.addEventListener("click",()=>{if(D(),C.goLive())He("",!1),Te()});let q=document.createElement("span");q.className="bp-history-label",q.setAttribute("data-testid","history-label");let ye=C.activeRef();q.textContent=ye?ye.label||ye.commit.slice(0,7):C.refs.length>0?`Live (${C.refs.length} saved)`:"Live",W.append(_,G,z,ae,q);let ke=document.createElement("div");ke.className="bp-history-group";let Ae=document.createElement("button");Ae.type="button",Ae.className="bp-v-btn"+(C.highlightEdits?" is-on":""),Ae.textContent="Highlight edits",Ae.disabled=C.refs.length===0,Ae.setAttribute("data-testid","history-highlight"),Ae.addEventListener("click",()=>{D(),C.toggleHighlight(),Te()});let Ge=document.createElement("div");Ge.className="bp-history-menu-wrap";let je=document.createElement("button");if(je.type="button",je.className="bp-v-btn"+(F||!C.isLive()?" is-on":""),je.disabled=C.refs.length===0,je.setAttribute("data-testid","history-compare"),je.setAttribute("aria-haspopup","menu"),je.setAttribute("aria-expanded",String(F)),je.textContent=ye?`Compare: ${ye.label||ye.commit.slice(0,7)} ▾`:"Compare ▾",je.addEventListener("click",(De)=>{De.stopPropagation(),F=!F,Le()}),Ge.append(je),F&&C.refs.length>0){let De=document.createElement("div");De.className="bp-history-menu",De.setAttribute("role","menu"),De.setAttribute("data-testid","history-compare-menu");let Ie=(Ve,mt,tn)=>{let at=document.createElement("button");at.type="button",at.className="bp-history-menu-item"+(tn?" is-active":""),at.setAttribute("role","menuitem"),at.setAttribute("data-commit",mt),at.textContent=Ve,at.addEventListener("click",()=>{if(F=!1,D(),C.selectCommit(mt)){if(C.isLive())He("",!1);Te()}else Le()}),De.append(at)};Ie("Live (working tree)","",C.isLive());for(let Ve of C.refs)Ie(Ve.label||Ve.commit.slice(0,7),Ve.commit,ye?.commit===Ve.commit);Ge.append(De)}ke.append(Ae,Ge),b.replaceChildren(W,ke)}async function Be(V){if(!V)return;try{let W=await t.hub.rpc("viewer.refs",{thread:V});if(V!==v)return;C.setRefs(Array.isArray(W?.refs)?W.refs:[]),Le()}catch{if(V!==v)return;C.setRefs([]),Le()}}function K(){return document.documentElement.classList.contains("light")}let fe=new MutationObserver(()=>{let V=K();ue?.setTheme(V),de?.setTheme(V),ge?.setTheme(V)});fe.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});function le(V,W="",_=!1,G=""){if(V==="none"){d.hidden=!0,d.replaceChildren();return}d.hidden=!1,d.className=`bp-v-overlay is-${V}`;let z=document.createElement("div");z.className="bp-v-state-card";let ae=document.createElement("div");if(ae.className="bp-v-state-msg",ae.textContent=W,z.append(ae),_){let q=document.createElement("button");q.type="button",q.className="bp-v-btn is-primary",q.textContent=m("tools.retry","Retry"),q.addEventListener("click",()=>void ht(!0)),z.append(q)}if(G){let q=document.createElement("div");q.className="bp-v-state-msg",q.textContent=m("gpui.c.solid.big.next","Loading it may take a while and a lot of memory.");let ye=document.createElement("button");ye.type="button",ye.className="bp-v-btn is-primary",ye.textContent=m("gpui.c.solid.load.big","Load it anyway"),ye.addEventListener("click",()=>{le("loading",m("gpui.c.solid.loading.big","Loading it anyway…")),t.hub.rpc("kicad.big",{key:G}).catch(()=>le("error",W,!1,G))}),z.append(q,ye)}d.replaceChildren(z)}function He(V,W){p.textContent=V,p.hidden=!V,p.classList.toggle("is-warn",W)}function $e(){if(Y)return Jt(Y);if(w==="board"||w==="3d")return Jt(H.pcb);if(w==="schematic")return Jt(H.sch);if(w==="mech")return Jt(P);return""}function Oe(){s.textContent=Cr(w);let V=$e();if(r.hidden=!V,o.hidden=!V,o.textContent=V,a.replaceChildren(),w==="mech"&&O.length>1){let _=document.createElement("select");_.className="bp-v-select",_.setAttribute("aria-label",m("viewer.mech","Mech"));for(let G of O){let z=document.createElement("option");z.value=G,z.textContent=Jt(G),z.selected=G===P,_.append(z)}_.addEventListener("change",()=>{P=_.value,Oe(),ht(!1)}),a.append(_)}if(mi(w)){let _=document.createElement("button");_.type="button",_.className="bp-v-btn"+(Pe?" is-on":""),_.textContent=R?.layerHead||"Layers",_.setAttribute("data-testid","viewer-layers-btn"),_.addEventListener("click",()=>{if(Pe=!Pe,u.hidden=!Pe,_.classList.toggle("is-on",Pe),Pe)We("","")}),a.append(_)}if(w==="board"||w==="schematic"||w==="3d"||w==="mech"||w==="gerbers"){let _=document.createElement("button");_.type="button",_.className="bp-v-btn",_.textContent="Fit",_.setAttribute("data-testid","viewer-fit-btn"),_.addEventListener("click",()=>{ue?.fit(),de?.fit()}),a.append(_)}if((w==="board"||w==="schematic")&&t.hub.hasFeature("follow")){let _=document.createElement("button");_.type="button",_.className="bp-v-btn"+(re&&!ie?" is-on":""),_.textContent=re?ie?m("gpui.follow.paused","Follow (paused)"):"Follow agent":"Follow agent",_.setAttribute("data-testid","viewer-follow-btn"),_.addEventListener("click",()=>void Qt()),a.append(_)}let W=document.createElement("button");W.type="button",W.className="bp-v-btn bp-v-close",W.textContent="✕",W.title=m("common.close","Close"),W.setAttribute("aria-label",m("common.close","Close")),W.setAttribute("data-testid","viewer-close-btn"),W.addEventListener("click",()=>t.closeViewer()),a.append(W)}function Ne(){if(!R){u.replaceChildren();return}let V=document.createDocumentFragment(),W=document.createElement("div");W.className="bp-v-layers-head";let _=document.createElement("span");if(_.textContent=R.layerHead||"Layers",W.append(_),R.layerReset){let q=document.createElement("button");q.type="button",q.className="bp-v-btn",q.textContent="Reset",q.addEventListener("click",()=>void We("reset","")),W.append(q)}if(V.append(W),R.layerModes){let q=document.createElement("div");q.className="bp-v-layers-modes",["All","Dim","Only"].forEach((ye,ke)=>{let Ae=document.createElement("button");Ae.type="button",Ae.className="bp-v-btn"+(R?.layerMode===ke?" is-on":""),Ae.textContent=ye,Ae.addEventListener("click",()=>void We("mode",String(ke))),q.append(Ae)}),V.append(q)}let G=ue?.presentColors()??new Map,z=(R.layerList||[]).concat(R.layerMarks||[]),ae=document.createElement("div");ae.className="bp-v-layers-list";for(let q of z){let ye=G.get(q.layer);if(ye===void 0)continue;let ke=document.createElement("div");ke.className="bp-v-layer-row"+(q.active?" is-focus":"");let Ae=document.createElement("input");Ae.type="checkbox",Ae.checked=q.on!==!1,Ae.addEventListener("change",()=>void We("toggle",String(q.layer)));let Ge=document.createElement("span");Ge.className="bp-v-layer-swatch";let je=ye>>>16&255,De=ye>>>8&255,Ie=ye&255;Ge.style.background=q.on!==!1?`rgb(${je},${De},${Ie})`:`rgba(${je},${De},${Ie},0.2)`;let Ve=document.createElement("button");Ve.type="button",Ve.className="bp-v-layer-name",Ve.textContent=q.name,Ve.addEventListener("click",()=>void We("pick",String(q.layer))),ke.append(Ae,Ge,Ve),ae.append(ke)}V.append(ae),u.replaceChildren(V)}async function We(V,W){if(!mi(w))return;let _=E;try{let G=await t.hub.rpc("viewer.layers",{kind:w,present:oe,off:Ce,focus:te,...V?{action:V,value:W}:{}});if(_!==E||!G)return;Ce=Number(G.own)||0,te=typeof G.focus==="string"?G.focus:"",R=G;let z={off:Number(G.off)||0,dim:Number(G.dim)||0,lift:typeof G.lift==="number"?G.lift:255};if(ue?.setLayers(z),Oe(),Pe)Ne()}catch{}}async function ze(){if(!re||ie||!v||!t.hub.hasFeature("follow"))return;ie=!0,Oe();try{await t.hub.rpc("viewer.follow",{thread:v,action:"pause"})}catch{}}async function Qt(){if(!v||!t.hub.hasFeature("follow"))return;let V=!re?"on":ie?"resume":"off";try{let W=await t.hub.rpc("viewer.follow",{thread:v,action:V});if(re=!!W.on,ie=!!W.paused,Oe(),W.on&&!W.paused&&W.focus&&Array.isArray(W.focus.box)&&W.focus.box.length===4&&(W.seq||0)>me)me=W.seq||me,ue?.zoomToBoxMm([W.focus.box[0],W.focus.box[1],W.focus.box[2],W.focus.box[3]])}catch{}}function rt(){f.hidden=!0,f.replaceChildren(),ue?.setHighlights([])}function Zt(V){let W=V.split(";").filter(Boolean),_=W.shift()||V,G=[],z="",ae="";for(let Ge of W){if(Ge.startsWith("g="))continue;let je=Ge.indexOf("=");if(je>0){let De=Ge.slice(0,je),Ie=Ge.slice(je+1);if((De==="ref"||De==="symbol")&&!z)z=Ie;if(De==="net"&&!ae)ae=Ie;G.push([De,Ie])}else G.push([Ge,""])}let q=document.createElement("div");q.className="bp-v-info-head";let ye=document.createElement("span");ye.className="bp-v-info-title",ye.textContent=_;let ke=document.createElement("button");ke.type="button",ke.className="bp-v-info-x",ke.textContent="×",ke.setAttribute("aria-label","Clear selection"),ke.addEventListener("click",rt),q.append(ye,ke);let Ae=document.createElement("div");Ae.className="bp-v-info-rows";for(let[Ge,je]of G){let De=document.createElement("span");De.className="bp-v-info-chip",De.textContent=je?`${Ge}: ${je}`:Ge,Ae.append(De)}return f.replaceChildren(q,...G.length>0?[Ae]:[]),f.hidden=!1,{ref:z||void 0,net:ae||void 0}}async function It(V){if(!V){rt();return}let W=Array.from(L)[0]||"";if(!W)return;let _=E;try{let G=await t.hub.rpc("viewer.info",{key:W,at:V.at,idx:V.idx});if(_!==E)return;let z=typeof G.info==="string"?G.info:"";if(!z){rt();return}let{ref:ae,net:q}=Zt(z),ye=[];if(ae)ye.push(["ref",ae]);if(q)ye.push(["net",q]);let ke=[[V.at,V.idx]];for(let[Ae,Ge]of ye){let je=await t.hub.rpc("viewer.probe",{key:W,name:Ae,value:Ge});if(_!==E)return;if(Array.isArray(je.matches))for(let De of je.matches)ke.push(De)}ue?.setHighlights(ke)}catch{rt()}}function ve(){ee?.destroy(),ee=null,ge?.destroy(),ge=null,ue?.destroy(),ue=null,de?.destroy(),de=null,h.replaceChildren(),Pe=!1,u.hidden=!0,f.hidden=!0,f.replaceChildren(),He("",!1),le("none")}function we(){M=[],A=0}async function ht(V){if(!v||!w)return;let W=++E;if(L.clear(),k=!1,we(),ve(),Oe(),ne(),Le(),(w==="board"||w==="schematic")&&v)Be(v);if(Ko(w)){if(t.hub.rpc("viewer.watch",{thread:v,kind:""}).catch(()=>{}),w==="files")ee=pr(h,t,v,(z,ae)=>{if(w=z,Y=ae,z==="mech")P=ae;ht(!1)});else if(w==="diff")ee=hr(h,t,v);else if(w==="review")ee=mr(h,t,v);else if(w==="browser")ee=lr(h,t,v);else if(w==="terminal")le("loading","Loading terminal…"),import("/assets/terminal.js").then((ae)=>{if(W!==E)return;if(le("none"),ae?.mountTerminalPane)ge=ae.mountTerminalPane(h,t,v,K());else le("error","Terminal chunk missing",!0)},(ae)=>{if(W!==E)return;le("error",ae instanceof Error?ae.message:String(ae),!0)});return}if(le("loading","Loading…"),!H.root)try{let z=await t.hub.rpc("viewer.files",{thread:v});if(W!==E)return;H=z||{},Oe()}catch{}if(w==="gerbers"&&H.hasGerbers===!1){le("empty","No Gerbers in this project",!1);return}let _=K();if(w==="3d"||w==="mech")de=new hi(h,{onStatus:(z,ae)=>{if(ae)le("none"),He(z,!1);else if(z)le("loading",z);else le("none"),He("",!1)},onUserMove:()=>void ze()}),de.setTheme(_);else if(w==="board"||w==="schematic"||w==="gerbers")ue=new li(h,{onPick:(z)=>void It(z),onUserMove:()=>void ze()}),ue.setTheme(_);else{le("empty",`${Cr(w)} is not available in this viewer`,!1);return}let G={thread:v};if(V)G.force=!0;if(w==="mech"){if(O.length===0)try{let z=await t.hub.rpc("mech.list",{thread:v});if(W!==E)return;if(O=Array.isArray(z.parts)?z.parts:[],!P)P=z.primary||O[0]||"";Oe()}catch(z){if(W!==E)return;le("error",z instanceof Error?z.message:String(z),!0);return}if(!P){le("empty",m("gpui.rail.no.mech","No mechanical parts in this project"),!1);return}G.kind="3d",G.path=P}else{if(G.kind=w,Y&&(w==="board"||w==="schematic"))G.path=Y;if(w==="3d"&&!V&&de){let z=de.keptToken();if(z)G.kept=z}if((w==="board"||w==="schematic"||w==="gerbers")&&!V&&t.hub.hasFeature("keptChunks"))G.keptChunks=Array.from(T.keys())}k=!0,I="",J="",se="",Ee="";try{let z=await t.hub.rpc("viewer.watch",G);if(W!==E)return;L=new Set(Array.isArray(z.keys)?z.keys:[]),k=!1;let ae=M;we();for(let q of ae)if(q.kind==="bin")tt(q.buf);else et(q.key,q.none,q.retryable,q.big)}catch(z){if(W!==E)return;k=!1,L.clear(),we();let ae=z instanceof Error?z.message:String(z),q=/no gerbers|not in this project|another machine/i.test(ae);le(q?"empty":"error",ae,!q)}}function et(V,W,_,G=!1){if(k){if(M.length{if(V.t==="plot"&&typeof V.none==="string"&&typeof V.key==="string")et(V.key,V.none,V.retryable===!0)}),ot=rn(()=>{if(w)Oe()}),en=(V)=>{if(V.key==="Escape"&&w&&!f.hidden)rt()};return window.addEventListener("keydown",en),{open(V,W){if(W!==v){if(v=W,H={},O=[],P="",B.clear(),re=!1,ie=!1,me=0,Ce=0,te="",oe=0,R=null,t.hub.hasFeature("follow"))t.hub.rpc("viewer.follow",{thread:W}).then((_)=>{if(W!==v)return;if(re=!!_.on,ie=!!_.paused,me=Number(_.seq)||0,w)Oe()}).catch(()=>{})}if(V!==w)D(),C.goLive(),Ce=0,te="",oe=0,R=null;w=V,Y="",ht(!1)},reconcileHas(V){if(w&&!qo(w,V))t.closeViewer()},close(){if(E++,k=!1,D(),F=!1,I="",J="",se="",Ee="",C.goLive(),c.hidden=!0,b.hidden=!0,we(),v)t.hub.rpc("viewer.watch",{thread:v,kind:""}).catch(()=>{});w="",L.clear(),ve()}}}var kr="http://www.w3.org/2000/svg";function Yt(e){let t=document.createElementNS(kr,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","13"),t.setAttribute("height","13"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("aria-hidden","true");for(let n of e){let i=document.createElementNS(kr,"path");i.setAttribute("d",n),t.appendChild(i)}return t}function xr(e){if(!e)return"bp-dot-idle";let t=e.status||e.state;if(t==="active"||t==="working")return"bp-dot-work";if(t==="finished")return"bp-dot-done";if(t==="waiting"||t==="asking"||t==="blocked"||t==="failed"||(e.waiting??0)>0)return"bp-dot-need";return"bp-dot-idle"}function Jo(e){if(!e)return"";let t=e<10000000000?e*1000:e,n=Math.max(0,Math.floor((Date.now()-t)/1000));if(n<60)return"now";if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400)return`${Math.floor(n/3600)}h`;return`${Math.floor(n/86400)}d`}function Pr(e,t){if(!e)return!0;if(t==="board"||t==="3d")return e.board!==!1;if(t==="schematic")return e.schematic!==!1;if(t==="mech")return e.mech!==!1;if(t==="gerbers")return e.gerbers!==!1;return!0}var Xt="dark",vn=(()=>{try{return Gs(localStorage.getItem("bp.theme.pref"))}catch{return"auto"}})(),bi=null,Bt=(()=>{try{return Vs(localStorage.getItem("bp.locale"))}catch{return"auto"}})();function Nr(){let e=Wt(vn,Xt);document.documentElement.classList.toggle("light",e==="light");try{localStorage.setItem("bp.theme",e)}catch{}}function Sr(e){if(!e)return;Xt=e==="light"?"light":"dark",Nr()}function Lr(){if(Bt!=="auto")kt(Bt);else if(bi)kt(bi);else if(typeof navigator<"u"&&navigator.language){if(!kt(navigator.language))kt("en")}}function Yo(){return`web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ar(){let e=document.getElementById("root");if(!e)return;try{if(localStorage.getItem("bp.theme")==="light")Xt="light";if(Wt(vn,Xt)==="light")document.documentElement.classList.add("light");if(Bt!=="auto")kt(Bt)}catch{}let t=document.createElement("header");t.className="bp-topbar",t.setAttribute("data-testid","topbar");let n=document.createElement("button");n.type="button",n.className="icon bp-side-toggle",n.textContent="☰",n.title="Toggle sidebar",n.setAttribute("aria-label","Toggle sidebar");let i=document.createElement("div");i.className="bp-brand";let s=document.createElement("img");s.src="/assets/favicon.svg",s.alt="Backplane",s.className="bp-logo";let r=document.createElement("span");r.className="bp-brand-name bp-hide-phone",r.textContent="Backplane";let o=document.createElement("span");o.className="bp-crumb-sep bp-hide-phone",o.textContent="/";let a=document.createElement("span");a.className="bp-crumb-proj bp-hide-phone";let c=document.createElement("span");c.className="bp-crumb-sep bp-hide-phone",c.textContent="/";let p=document.createElement("span");p.className="bp-crumb-thread",p.setAttribute("data-testid","thread-title");let l=document.createElement("span");l.className="bp-plan-top-badge bp-hidden",l.setAttribute("data-testid","plan-top-badge"),i.append(s,r,o,a,c,p,l);let h=document.createElement("div");h.className="bp-top-state bp-hide-phone bp-hidden";let d=document.createElement("span");d.className="bp-top-state-lbl",d.textContent="STATE";let u=document.createElement("span");u.className="bp-dot bp-dot-idle";let f=document.createElement("span");f.className="bp-top-state-word",h.append(d,u,f);let b=document.createElement("div");b.className="bp-top-acts bp-hide-phone bp-hidden";let v=document.createElement("button");v.type="button",v.className="bp-btn-ghost bp-top-act";let w=document.createElement("span");w.textContent=m("menu.pin","Pin"),v.append(Yt(["M12 17v5","M9 3h6l1 7 3 3H5l3-3 1-7z"]),w);let E=document.createElement("button");E.type="button",E.className="bp-btn-ghost bp-top-act";let k=document.createElement("span");k.textContent=m("menu.settle","Settle"),E.append(Yt(["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M9 12l2 2 4-4"]),k);let L=document.createElement("div");L.className="bp-menu-wrap";let M=document.createElement("button");M.type="button",M.className="bp-btn-ghost bp-top-act",M.textContent="▾",M.title="Thread menu",M.setAttribute("aria-label","Thread menu"),M.setAttribute("data-testid","thread-menu-btn");let A=document.createElement("div");A.className="bp-popover bp-hidden",A.setAttribute("data-testid","thread-menu"),L.append(M,A),b.append(v,E,L);let B=document.createElement("div");B.className="bp-top-right";let T=document.createElement("button");T.type="button",T.className="bp-btn-ghost bp-top-act bp-hide-tablet",T.setAttribute("data-testid","improvements-btn");let H=document.createElement("span");H.textContent=m("gpui.improvements","Improvements"),T.append(Yt(["M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 16.8l-6.2 4.5 2.4-7.4L2 9.4h7.6z"]),H);let O=document.createElement("button");O.type="button",O.className="bp-cmd-box bp-hide-tablet",O.textContent="> Jump or run a command";let P=document.createElement("button");P.type="button",P.className="icon bp-top-icon",P.title="Search",P.setAttribute("aria-label","Search"),P.appendChild(Yt(["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z","M21 21l-4.3-4.3"]));let Y=document.createElement("button");Y.type="button",Y.className="icon bp-top-icon",Y.title=m("palette.settings","Settings"),Y.setAttribute("aria-label",m("palette.settings","Settings")),Y.setAttribute("data-testid","settings-btn"),Y.appendChild(Yt(["M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9c.26.6.85 1 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"])),B.append(T,O,P,Y),t.append(n,i,h,b,B);let re=document.createElement("div");re.className="bp-body";let ie=document.createElement("aside");ie.className="bp-sidebar",ie.setAttribute("data-testid","sidebar");let me=document.createElement("main");me.className="bp-center";let Pe=document.createElement("div");Pe.className="bp-right-area bp-hidden",Pe.setAttribute("data-testid","right-area");let Ce=document.createElement("div");Ce.className="bp-right-top";let te=document.createElement("section");te.className="bp-viewer-pane bp-hidden",te.setAttribute("data-testid","viewer-pane"),Ce.appendChild(te),Pe.appendChild(Ce);let oe=document.createElement("nav");oe.className="bp-rail",oe.setAttribute("aria-label","Viewer rail"),oe.setAttribute("data-testid","viewer-rail"),re.append(ie,me,Pe,oe),e.append(t,re);let R=new oi,ue=null,de=new Set,ee=0,ge=null,C=[],x=[],F=[],I=[],J=[],se=[],Ee=[],D="",ne=0,Te=0,Le=null,Be=null,K="",fe=null,le=20,He={},$e=new Map;function Oe(g,y){$e.delete(g),$e.set(g,y);while($e.size>le){let S=$e.keys().next().value;if(S!==void 0)$e.delete(S);else break}}let Ne="",We=0,ze=new Wn(me,{onNewThread:(g)=>{ut(g)},onOpenThread:(g)=>{qe(g)},onOpenViewer:(g,y)=>{qe(g).then(()=>{if(D===g)mt(y)})},onRetry:(g)=>{It(g)}});function Qt(){if(!Ne)return;Ne="",We++,me.classList.remove("bp-home-open"),ze.hide(),ve.setSelectedProject(""),Ie()}function rt(g){return C.find((y)=>y.id===g)??C.find((y)=>Un(y.id)===g)}async function Zt(g,y){try{let S=await R.rpc("threads.list",{project:g,limit:50,archived:!1});if(y!==We||Ne!==g)return;let N=(S.threads??[]).filter((j)=>!j.swarm).map((j)=>({id:j.id,title:j.title,dot:xr(j),status:j.status||j.state||"",age:Jo(j.updatedAt),settled:j.settled}));ze.setThreads(N)}catch{if(y===We&&Ne===g)ze.setThreads([])}}function It(g){if(!g||!R.hasFeature("projecthome"))return!1;tt.cancel(),pe.closeModelPicker(),Ne=g;let y=++We,S=rt(g);return me.classList.add("bp-home-open"),ie.classList.remove("bp-sidebar-open"),ze.show({id:g,title:S?.title??g}),ve.setSelectedProject(g),Ie(),Zt(g,y),R.rpc("project.home",{project:g}).then((N)=>{if(y===We&&Ne===g)ze.setData(Ns(N))}).catch((N)=>{if(y!==We||Ne!==g)return;ze.setError(N instanceof Error&&N.message?N.message:m("web.home.error","Could not load this project."))}),!0}let ve=new ii(ie,{onSelectThread:(g)=>{if(g===D&&Le!==null){Qt(),ie.classList.remove("bp-sidebar-open");return}qe(g)},onNewThread:(g)=>{ut(g)},onOpenProject:(g)=>It(Un(g)),canOpenProject:()=>R.hasFeature("projecthome"),onSelectBot:(g)=>{qe(g.thread)},onQuickOpenViewer:(g,y)=>{let S=x.find((j)=>j.project===g&&!j.archived&&!j.swarm);(async()=>{if(S)await qe(S.id);else await ut(g);if(D)K=y,G.setActive(y),fe?.open(y,D)})()},onThreadAct:(g,y)=>{bt(g,y)},onSnoozeRow:(g)=>{R.rpc("sidebar.act",{action:"row-snooze",value:g}).then(()=>Xe()).catch(()=>{})},onToggleSection:(g)=>{if(de.has(g))de.delete(g);else de.add(g);Xe()},onToggleProjectFold:(g)=>{R.rpc("sidebar.act",{action:"project-fold",value:g}).then(()=>Xe()).catch(()=>{})},onCollapseSidebar:()=>{ie.classList.remove("bp-sidebar-open"),ie.classList.add("bp-sidebar-collapsed")},onNeedAct:async(g)=>{let y=un(g,!1);if(!y)return;if(y.kind==="thread"){qe(y.id);return}if(y.kind!=="call")return;let S=Os(await R.rpc(y.method,y.params));if(S?.kind==="thread")qe(S.id);Xe()},hasRoomView:!1,onAddProject:()=>_.open({mode:"folder"}),onSettleSwarm:(g)=>{R.rpc("sidebar.act",{action:"swarm-settle",value:g}).then(()=>Xe()).catch(()=>{})},onNewChat:()=>{ut(yt)},onMoveToProject:(g)=>De(g),onDismissHomeMove:()=>{R.rpc("home.move.dismiss",{}).then((g)=>{if(g?.home!==void 0){if(z=g.home??null,ve.setHome(z),q.isOpen())q.refresh()}}).catch(()=>{})}}),we=new An(me,{onLoadOlder:()=>{wi()},onGoToEntry:(g)=>{vi(g)},onOpenAccounts:()=>{ke()},onAnswerAsk:(g,y)=>{R.rpc("ask.answer",{ask:g,answer:y}).catch((S)=>{pe.showError(S instanceof Error?S.message:"Could not send answer")})},onToggleReview:(g)=>{if(!D)return;let y=ne;R.rpc("thread.review",{thread:D,on:g}).then((S)=>{if(y===ne)we.setReview(S.review??null)}).catch(()=>{})},onUnansweredAction:(g,y)=>{if(!D)return;if(g==="again"||g==="thread-again")R.rpc("thread.again",{thread:D,value:y}).catch(()=>{});else R.rpc("thread.act",{thread:D,action:g,value:y}).catch(()=>{})},onReplyEntry:(g)=>{if(!R.hasFeature("reply")){let y=(g.text||"").split(` -`)[0]?.slice(0,100)??"";if(y)pe.prependDraft(`> ${y} -`);return}if(!g.text||!g.text.trim()||g.live||g.id.startsWith("local-"))return;jt({id:g.id,text:g.text,role:g.kind==="user"?"user":"assistant"})},onLoadImage:async(g,y)=>{try{let S={entry:g,path:y};if(R.hasFeature("blobs"))S.metaOnly=!0;let N=await R.rpc("message.image",S);if(N.blob&&N.blob.startsWith("/blob/"))return{url:N.blob};if(N.mime&&N.data)return{mime:N.mime,data:N.data}}catch{}return null}});function ht(g){if(!g)return null;if(g.planMode)return g.planMode;if(g.provider==="claude")return{phase:"off",interaction:"default",once:!1};return null}function et(g,y){if(!D)return;let S=ne,N=D;R.rpc(g,y).then((j)=>{if(S!==ne||D!==N)return;if(j.thread){let Q=x.findIndex((ce)=>ce.id===j.thread.id);if(Q>=0)x[Q]=j.thread;else x.unshift(j.thread);ve.setData(C,x,F,I),we.updateThreadMeta(j.thread),Ie(),pe.setState(!0,j.thread.state==="working")}}).catch((j)=>{if(S===ne&&D===N)pe.showError(j instanceof Error?j.message:"Could not change Plan mode")})}let tt,pe=new Tn(me,{onSend:(g,y)=>{Ei(g,y)},onRunCommand:(g)=>{Ci(g)},onInterrupt:()=>{if(D)R.rpc("turn.interrupt",{thread:D}).catch(()=>{})},onQueryMentions:async(g,y)=>{try{return(await R.rpc("mentions.list",{q:g,kind:y,limit:10})).items??[]}catch{return[]}},onToggleVoice:()=>{tt.toggle()},onCyclePlanMode:()=>{let g=x.find((S)=>S.id===D)??null,y=ht(g);if(!y||!D)return;if(y.interaction!=="plan")et("thread.planonce",{thread:D,on:!0});else if(y.once)et("thread.pick",{thread:D,action:"interaction",value:"plan"});else et("thread.pick",{thread:D,action:"interaction",value:"default"})},onSetPlanMode:(g)=>{if(!D)return;if(g==="once")et("thread.planonce",{thread:D,on:!0});else if(g==="always")et("thread.pick",{thread:D,action:"interaction",value:"plan"});else et("thread.pick",{thread:D,action:"interaction",value:"default"})},getFavoriteModels:()=>J,onLoadModelPicker:async()=>{if(!D)return null;return R.rpc("thread.picker",{thread:D})},onSelectModel:async(g,y)=>{if(!D)return;let S=ne,N=D;try{let j=await R.rpc("thread.model",{thread:N,provider:g,model:y});if(S!==ne||D!==N)return;if(j.thread){let Q=x.findIndex((ce)=>ce.id===j.thread.id);if(Q>=0)x[Q]=j.thread;else x.unshift(j.thread);ve.setData(C,x,F,I),we.updateThreadMeta(j.thread),Ie(),pe.setState(!0,j.thread.state==="working")}}catch(j){if(S===ne&&D===N)pe.showError(j instanceof Error?j.message:"Could not switch model")}},onSelectEffort:async(g)=>{if(!D)return;let y=ne,S=D;try{let N=await R.rpc("thread.pick",{thread:S,action:"effort",value:g});if(y!==ne||D!==S)return;if(N.thread){let j=x.findIndex((Q)=>Q.id===N.thread.id);if(j>=0)x[j]=N.thread;else x.unshift(N.thread);ve.setData(C,x,F,I),we.updateThreadMeta(N.thread),Ie()}}catch(N){if(y===ne&&D===S)pe.showError(N instanceof Error?N.message:"Could not set effort")}},onToggleFavorite:async(g,y,S)=>{let N=await R.rpc("models.favorite",{provider:g,model:y,on:S});if(Array.isArray(N.favorites))return J=N.favorites,J;return null}});tt=new si(R,{getThreadId:()=>D,getDraft:()=>pe.getDraft(),getCaret:()=>pe.getCaret(),setDraft:(g)=>pe.setDraft(g),setRecording:(g)=>pe.setVoiceRecording(g),setLevel:(g)=>pe.setVoiceLevel(g),showError:(g)=>pe.showError(g)});function Rt(){let g=K!=="",y=ot.isOpen();Pe.classList.toggle("bp-hidden",!g&&!y),Pe.classList.toggle("bp-has-viewer",g),Pe.classList.toggle("bp-has-mgmt",y)}let ot=new $n(Ce,Pe,{hub:R,getThreadId:()=>D,getThreadGen:()=>ne,onSendText:(g)=>{Ei(g)},onOpenChange:()=>Rt()});function en(g){let y=window.prompt("Rename thread",g.title||"");if(!y||!y.trim())return;R.rpc("thread.act",{thread:g.id,action:"rename",title:y.trim()}).then((S)=>{if(S.thread)x=x.map((N)=>N.id===S.thread.id?S.thread:N),Ie(),Xe()}).catch((S)=>{pe.showError(S instanceof Error?S.message:"Could not rename thread")})}function V(g){switch(g.type){case"thread":qe(g.id);break;case"rail":if(!D&&g.id!=="terminal")break;if(K===g.id)Ve();else mt(g.id);break;case"thread-act":if(D)bt(D,g.action);break;case"new-thread":ut(g.projectId);break;case"new-chat":ut(yt);break;case"move-project":if(D)De(D);break;case"rename":{let y=x.find((S)=>S.id===D);if(y)en(y);break}case"prev-thread":case"next-thread":{let y=x.filter((Q)=>!Q.archived&&!Q.swarm);if(y.length<2)break;let S=y.findIndex((Q)=>Q.id===D),N=g.type==="next-thread"?1:-1,j=y[(S<0?0:S+N+y.length)%y.length];if(j)qe(j.id);break}case"command":if(g.runDirectly)Ci(g.word);else pe.setDraft(`${g.word} `),pe.focus();break;case"improvements":je();break;case"settings":q.open();break;case"sidebar":ie.classList.toggle("bp-sidebar-open"),ie.classList.toggle("bp-sidebar-collapsed");break}}let W=new On(e,{getState:()=>({selectedThreadId:D,threads:x,projects:C,bots:F,railItems:se,commands:Ee}),onSearch:async(g)=>{if(!R.hasFeature("search"))return{threads:[],projects:[],messages:[]};return R.rpc("search",{q:g,limit:20})},onExecute:V}),_=new Pn(e,{hub:R,onProjectAdded:(g)=>{if(Xe(),g.id)ut(g.id)},onCloneDone:(g)=>{if(Xe(),g.thread)qe(g.thread)}}),G=new qn(oe,(g)=>{if(g==="commands"){W.open();return}if(!D)return;if(K===g)Ve();else mt(g)}),z=null,ae=null,q=new Zn(e,{onLoadDevices:async()=>(await R.rpc("devices.page",{})).rows??[],onDevicesAct:async(g,y)=>{await R.rpc("devices.page.act",{action:g,value:y})},onGetHome:()=>z,onMoveHomeHere:async()=>{await R.rpc("home.move",{to:"back"})},onGetNoProvider:()=>ae,onGetThemePref:()=>vn,onSetThemePref:(g)=>{vn=g;try{if(g==="auto")localStorage.removeItem("bp.theme.pref");else localStorage.setItem("bp.theme.pref",g)}catch{}Nr()},onGetHubTheme:()=>Xt,onGetLocalePref:()=>Bt,onSetLocalePref:(g)=>{Bt=g;try{if(g==="auto")localStorage.removeItem("bp.locale");else localStorage.setItem("bp.locale",g)}catch{}Lr()},hasRing:()=>R.hasFeature("ringnotes"),onRingList:async(g)=>Is(await R.rpc("ring.list",{q:g})),onRingHear:async(g,y)=>{await R.rpc("ring.hear",{note:g,engine:y})},onOpenThread:(g)=>{qe(g)},onLogout:()=>_i(()=>{R.disconnect(),window.location.replace("/")})});function ye(g){if(ae=g,we.setNoProvider(g),q.isOpen())q.refresh()}function ke(){q.openToAccounts()}function Ae(g,y){let S=g instanceof Error?g.message:y,N=g instanceof Kt?g:null,j=N?.code,Q=N?.machine,ce=j==="no_provider_remote"&&Q?m("provider.notice.senderr.remote","No AI provider connected on {machine}. Open Settings → Accounts on {machine} to connect Claude, Codex, Antigravity, or another provider.").replaceAll("{machine}",Q):S;pe.showError(ce,Bs(S,j)?{label:m("provider.notice.button","Open Settings → Accounts"),onClick:ke}:void 0)}v.addEventListener("click",()=>{let g=x.find((y)=>y.id===D);if(g)bt(g.id,g.pinned?"unpin":"pin")}),E.addEventListener("click",()=>{let g=x.find((y)=>y.id===D);if(g)bt(g.id,g.settled?"unsettle":"settle")});let Ge=new ti(e,(g,y)=>y?R.rpc("thread.context.mcp",{thread:g,...y}):R.rpc("thread.context",{thread:g}));M.addEventListener("click",(g)=>{g.stopPropagation();let y=x.find((j)=>j.id===D);if(!y)return;if(!A.classList.contains("bp-hidden")){A.classList.add("bp-hidden");return}let S=[{label:"Rename…",run:()=>en(y)},{label:y.pinned?m("menu.unpin","Unpin"):m("menu.pin","Pin"),run:()=>{bt(y.id,y.pinned?"unpin":"pin")}},{label:y.settled?m("phone.unsettle","Unsettle"):m("menu.settle","Settle"),run:()=>{bt(y.id,y.settled?"unsettle":"settle")}},{label:y.archived?"Unarchive":"Archive",run:()=>{bt(y.id,y.archived?"unarchive":"archive")}},{label:"Delete",danger:!0,run:()=>{if(window.confirm("Delete this thread?"))bt(y.id,"delete")}}];if(R.hasFeature("threadContext"))S.unshift({label:m("thread.context.title","Context & Prompt"),run:()=>Ge.open(y.id)});let N=document.createDocumentFragment();for(let j of S){let Q=document.createElement("button");Q.type="button",Q.className="bp-popover-item"+(j.danger?" danger":""),Q.textContent=j.label,Q.addEventListener("click",()=>{A.classList.add("bp-hidden"),j.run()}),N.appendChild(Q)}A.replaceChildren(N),A.classList.remove("bp-hidden")}),document.addEventListener("click",()=>A.classList.add("bp-hidden"));async function je(){let g=document.createElement("div");g.className="bp-modal-backdrop",g.setAttribute("data-testid","improvements-modal");let y=document.createElement("div");y.className="bp-modal";let S=document.createElement("div");S.className="bp-modal-head";let N=document.createElement("h2");N.textContent=m("gpui.improvements","Improvements");let j=document.createElement("button");j.type="button",j.className="icon",j.textContent="×",j.addEventListener("click",()=>g.remove()),S.append(N,j);let Q=document.createElement("div");Q.className="bp-modal-body",Q.textContent="Loading…",y.append(S,Q),g.appendChild(y),g.addEventListener("click",(ce)=>{if(ce.target===g)g.remove()}),e.appendChild(g);try{let ce=await R.rpc("improvements.projects",{}),Fe=ce.projects??[];if(Fe.length===0){Q.textContent="No projects available for Improvements.";return}let Je=document.createDocumentFragment();for(let Ye of Fe){let Me=document.createElement("div");Me.className="bp-set-row";let Z=document.createElement("div");Z.className="bp-set-info",Z.textContent=Ye.title||Ye.name||Ye.id;let Ue=document.createElement("button");Ue.type="button",Ue.className=Ye.id===ce.project?"primary":"",Ue.textContent=Ye.id===ce.project?"Active":"Select",Ue.addEventListener("click",()=>{R.rpc("improvements.project",{project:Ye.id}).then(()=>g.remove()).catch(()=>{})}),Me.append(Z,Ue),Je.appendChild(Me)}Q.replaceChildren(Je)}catch(ce){Q.textContent=ce instanceof Error?ce.message:"Could not load Improvements."}}function De(g){let y=x.find((Z)=>Z.id===g),S=document.createElement("div");S.className="bp-modal-backdrop",S.setAttribute("data-testid","move-project-modal");let N=document.createElement("div");N.className="bp-modal";let j=document.createElement("div");j.className="bp-modal-head";let Q=document.createElement("h2");Q.textContent=m("chats.move","Move to project…");let ce=document.createElement("button");ce.type="button",ce.className="icon",ce.textContent="×",ce.addEventListener("click",()=>S.remove()),j.append(Q,ce);let Fe=document.createElement("div");Fe.className="bp-modal-body";let Je=document.createElement("div");Je.className="bp-move-note",Je.textContent=y?.title||"";let Ye=document.createElement("div");Ye.className="bp-move-err",Fe.append(Je);let Me=Js(C);if(Me.length===0){let Z=document.createElement("div");Z.textContent=m("chats.move.none","No project to move it to. Add a project first."),Fe.appendChild(Z)}for(let Z of Me){let Ue=document.createElement("button");Ue.type="button",Ue.className="bp-move-row",Ue.textContent=Z.title||Z.id,Ue.setAttribute("data-testid",`move-project-${Z.id}`),Ue.addEventListener("click",()=>{R.rpc("thread.move_project",{thread:g,project:Z.id}).then((lt)=>{if(lt.thread)x=x.map((ct)=>ct.id===lt.thread.id?lt.thread:ct);else x=x.map((ct)=>ct.id===g?{...ct,project:Z.id}:ct);ve.setData(C,x,F,I),Ie(),Xe(),S.remove()}).catch((lt)=>{Ye.textContent=lt instanceof Error?lt.message:"Could not move the chat"})}),Fe.appendChild(Ue)}Fe.appendChild(Ye),N.append(j,Fe),S.appendChild(N),S.addEventListener("click",(Z)=>{if(Z.target===S)S.remove()}),e.appendChild(S)}T.addEventListener("click",()=>{je()}),O.addEventListener("click",()=>W.open()),P.addEventListener("click",()=>W.open()),Y.addEventListener("click",()=>{q.open()}),n.addEventListener("click",()=>{ie.classList.toggle("bp-sidebar-open"),ie.classList.toggle("bp-sidebar-collapsed")});function Ie(){let g=Ne?null:x.find((j)=>j.id===D)??null,y=Ne?rt(Ne)??{id:Ne,title:Ne}:g?rt(g.project):void 0;if(Ne&&y)ze.setTitle(y.title);let S=!Ne&&g?.project===yt;a.textContent=S?m("chats.title","Chats"):y?.title??"",o.classList.toggle("bp-hidden",!y&&!S),c.classList.toggle("bp-hidden",!g),p.textContent=g?g.title||"Untitled thread":"";let N=ht(g);if(pe.setPlanMode(N),!N||N.phase==="off")l.classList.add("bp-hidden"),l.classList.remove("is-exec"),l.textContent="";else l.classList.remove("bp-hidden"),l.classList.toggle("is-exec",N.phase==="executing"),l.title=m("gpui.planmode.tip","Plan before acting (1 turn, always, or off)"),l.textContent=N.phase==="armed"&&N.once?m("gpui.planmode.top.once","Plan (1 turn)"):N.phase==="armed"?m("gpui.mgmt.plan.tab","Plan"):N.phase==="planning"?m("gpui.planmode.top.planning","Planning"):N.phase==="pending"?m("gpui.planmode.top.pending","Review plan"):m("gpui.planmode.top.executing","Building plan");if(h.classList.toggle("bp-hidden",!g),b.classList.toggle("bp-hidden",!g),g){u.className=`bp-dot ${xr(g)}`,f.textContent=g.status||g.state||"idle",w.textContent=g.pinned?m("menu.unpin","Unpin"):m("menu.pin","Pin"),k.textContent=g.settled?m("phone.unsettle","Unsettle"):m("menu.settle","Settle");let j=g;pe.setModelChip(g.chip||g.model||"default",g.provider,j.ctxPct??j.contextPct),pe.setMemory(g.memory)}else pe.setModelChip("default"),pe.setMemory(null)}function Ve(g=!0){if(Te++,K="",G.setActive(""),te.classList.add("bp-hidden"),fe?.close(),Rt(),g&&D&&R.getState()==="connected")R.rpc("viewer.watch",{thread:D,kind:""}).catch(()=>{})}function mt(g){if(Te++,K=g,G.setActive(g),te.classList.remove("bp-hidden"),Rt(),!fe&&typeof ui==="function")fe=ui(te,{hub:R,getThreadId:()=>D,closeViewer:()=>Ve(!0)});if(fe)fe.open(g,D);else{let y=document.createElement("div");y.className="bp-viewer-placeholder";let S=document.createElement("div");S.className="bp-viewer-bar";let N=document.createElement("span");N.textContent=g.toUpperCase();let j=document.createElement("button");j.type="button",j.className="icon",j.textContent="×",j.addEventListener("click",()=>Ve(!0)),S.append(N,j);let Q=document.createElement("div");Q.className="bp-dim bp-viewer-msg",Q.textContent=`Viewer pane (${g}).`,y.append(S,Q),te.replaceChildren(y)}}async function tn(g,y){if(!g||!R.hasFeature("rail")){if(y===ne)se=[],G.setItems([]);return}let S=++Te;try{let N=await R.rpc("viewer.rail",{thread:g,page:K});if(y!==ne||S!==Te)return;let j=Array.isArray(N.rail)?N.rail:Array.isArray(N.items)?N.items:[];if(se=j,G.setItems(j),N.has){if(fe?.reconcileHas?.(N.has),K&&!Pr(N.has,K))Ve(!0)}}catch{if(y===ne&&S===Te)se=[],G.setItems([])}}function at(g){for(let y of g)if(y.kind==="threads"){for(let S of y.rows)if(!S.off&&(S.nav||S.id)&&!(S.nav||"").startsWith("@room:"))return S.nav||S.id}else if(y.kind==="projects"){for(let S of y.rows)for(let N of S.threads??[])if(!N.off&&(N.nav||N.id)&&!(N.nav||"").startsWith("@room:"))return N.nav||N.id}return""}function gi(g,y){for(let S of g)if(S.kind==="threads"){if(S.rows.some((N)=>(N.nav||N.id)===y))return!0}else if(S.kind==="projects"){for(let N of S.rows)if((N.threads??[]).some((j)=>(j.nav||j.id)===y))return!0}return!1}function wn(g){let y=[];for(let S of g){if(S.kind!=="projects")continue;for(let N of S.rows)y.push({id:N.id,title:N.title,css:N.css,color:N.color})}if(y.length>0)C=y}async function Xe(){if(!R.hasFeature("sections"))return!1;let g=++ee;try{let y=await R.rpc("sidebar.sections",{open:Array.from(de)});if(g!==ee)return!0;let S=Array.isArray(y.sections)?y.sections:[];if(ue=S,wn(S),ve.setData(C,x,F,I),ve.setSections(S,F,I),Ie(),Ne)Zt(Ne,We);return!0}catch{return!1}}function nn(){if(!R.hasFeature("sections"))return;if(ge!==null)window.clearTimeout(ge);ge=window.setTimeout(()=>{ge=null,Xe()},150)}async function Mr(){if(Le=null,R.hasFeature("bots"))try{let y=await R.rpc("bots.list",{});F=y.bots??[],I=y.rooms??[]}catch{}if(R.hasFeature("shell")){let y=await R.rpc("shell.sync",{have:He,settled:25}),S=new Set(y.removed??[]),N=new Set((y.projects??[]).map((j)=>j.id));if(S.size>0||N.size>0)C=[...C.filter((j)=>!S.has(j.id)&&!N.has(j.id)),...y.projects??[]],x=[...x.filter((j)=>!S.has(j.project)&&!N.has(j.project)),...y.threads??[]];else if(Array.isArray(y.threads)&&y.threads.length>0){let j=new Map(x.map((Q)=>[Q.id,Q]));for(let Q of y.threads)j.set(Q.id,Q);x=Array.from(j.values())}if(y.sections!==void 0){let j=Array.isArray(y.sections)?y.sections:Array.isArray(y.sections?.sections)?y.sections.sections:null;if(j)ue=j,wn(j)}if(y.h)He=y.h;ve.setData(C,x,F,I),ve.setSections(ue,F,I)}else if(R.hasFeature("sections")){let[y,S]=await Promise.all([R.rpc("sidebar.sections",{open:Array.from(de)}).catch(()=>null),R.rpc("threads.list",{limit:200,archived:!1}).catch(()=>({threads:[]}))]);if(x=S.threads??[],y&&Array.isArray(y.sections)){let N=y.sections;if(!N.some((Q)=>Q.kind==="projects"&&Q.rows.length>0)){let Q=N.find((ce)=>ce.kind==="projects"&&ce.fold&&ce.toggle&&(ce.count??0)>0);if(Q?.toggle&&!de.has(Q.toggle)){de.add(Q.toggle);let ce=await R.rpc("sidebar.sections",{open:Array.from(de)}).catch(()=>null);if(ce&&Array.isArray(ce.sections))N=ce.sections}}ue=N,wn(N),ve.setData(C,x,F,I),ve.setSections(N,F,I)}else ue=null,C=(await R.rpc("projects.list",{limit:100})).projects??[],ve.setSections(null,F,I),ve.setData(C,x,F,I);await R.rpc("subscribe",{topic:"lists"}).catch(()=>{})}else{ue=null;let[y,S]=await Promise.all([R.rpc("projects.list",{limit:100}),R.rpc("threads.list",{limit:200,archived:!1})]);C=y.projects??[],x=S.threads??[],ve.setSections(null,F,I),ve.setData(C,x,F,I),await R.rpc("subscribe",{topic:"lists"}).catch(()=>{})}let g=D;if(!g){let y="";try{y=localStorage.getItem("bp.lastThread")||""}catch{}if(y&&(ue&&gi(ue,y)||x.some((S)=>S.id===y)))g=y;else if(ue)g=at(ue);if(!g)g=(x.find((N)=>!N.archived&&!N.swarm&&!N.settled)??x.find((N)=>!N.archived&&!N.swarm))?.id??""}if(g&&(ue&&gi(ue,g)||x.some((y)=>y.id===g)))await qe(g,Ne!=="");else D="",se=[],G.setItems([]),pe.setState(!1,!1),Ie();if(Ne)It(Ne)}async function qe(g,y=!1){if(!y)Qt();if(D&&D!==g){tt.cancel();let Me=we.getEntries();if(Me.length>0){let Z=$e.get(D);Oe(D,{entries:Me,ids:Z?.ids??Me.map((Ue)=>Ue.id),olderCursor:Be,review:Z?.review??null,unanswered:Z?.unanswered??null,rail:Z?.rail??se,hashes:Z?.hashes??{}})}}let S=++ne;Te++,jt(null);let N=Le;if(Le=null,N!==null)R.rpc("unsubscribe",{sub:N}).catch(()=>{});D=g,pe.closeModelPicker();let j=$e.get(g);Be=j?.olderCursor??null;try{localStorage.setItem("bp.lastThread",g)}catch{}ve.setSelected(g),ie.classList.remove("bp-sidebar-open"),Ie();let Q=x.find((Me)=>Me.id===g)??null;if(j)we.setThread(Q,j.entries,Boolean(j.olderCursor),j.review,j.unanswered),se=j.rail,G.setItems(j.rail);else we.setLoading(Q),se=[],G.setItems([]);if(pe.setState(!0,Q?.state==="working"),R.hasFeature("open")){let Me={};if(j){for(let[Re,Dt]of Object.entries(j.hashes))Me[Re]=Dt;for(let Re of j.entries)if(Re.h)Me[Re.id]=Re.h}let Z;try{Z=await R.rpc("thread.open",{thread:g,limit:40,have:Me})}catch(Re){if(S===ne){let Dt=Re instanceof Error&&Re.message?Re.message:"Could not load messages.";we.setError(Q,Dt,()=>{qe(g)})}return}if(S!==ne){if(Z.sub!==void 0&&Z.sub!==null)R.rpc("unsubscribe",{sub:Z.sub}).catch(()=>{});return}if(Le=Z.sub??null,Z.thread){Q=Z.thread;let Re=x.findIndex((Dt)=>Dt.id===Z.thread.id);if(Re>=0)x[Re]=Z.thread;else x.unshift(Z.thread);Ie(),pe.setState(!0,Q.state==="working")}if("next"in Z)Be=Z.next??null;let Ue=new Map;if(j)for(let Re of j.entries)Ue.set(Re.id,Re);for(let Re of Z.entries??[])Ue.set(Re.id,Re);let lt=Z.ids??j?.ids??(Z.entries??[]).map((Re)=>Re.id),ct=lt.map((Re)=>Ue.get(Re)).filter((Re)=>Boolean(Re)),Ht=j?.rail??[];if(Z.rail!==void 0){if(Array.isArray(Z.rail))Ht=Z.rail;else if(Ht=Array.isArray(Z.rail?.rail)?Z.rail.rail:Array.isArray(Z.rail?.items)?Z.rail.items:[],Z.rail?.has){if(fe?.reconcileHas?.(Z.rail.has),K&&!Pr(Z.rail.has,K))Ve(!0)}}se=Ht,G.setItems(Ht);let yn=j?.review??null;if(R.hasFeature("reviewmode"))try{let Re=await R.rpc("thread.review",{thread:g});if(S!==ne)return;yn=Re.review??null}catch{}if(S!==ne)return;let xi="unanswered"in Z?Z.unanswered??null:j?.unanswered??null,Tr=Z.h??j?.hashes??{};if(Oe(g,{entries:ct,ids:lt,olderCursor:Be,review:yn,unanswered:xi,rail:Ht,hashes:Tr}),we.setThread(Q,ct,Boolean(Be),yn,xi),fi(g,S),K)mt(K);return}let ce;try{ce=await R.rpc("thread.entries",{thread:g,limit:40})}catch(Me){if(S===ne){let Z=Me instanceof Error&&Me.message?Me.message:"Could not load messages.";we.setError(Q,Z,()=>{qe(g)})}return}if(S!==ne)return;if(ce.thread){let Me=x.findIndex((Z)=>Z.id===ce.thread.id);if(Me>=0)x[Me]=ce.thread;else x.unshift(ce.thread);Ie()}Be=ce.next??null;let Fe=null;if(R.hasFeature("reviewmode"))try{let Me=await R.rpc("thread.review",{thread:g});if(S!==ne)return;Fe=Me.review??null}catch{}if(S!==ne)return;let Je=ce.entries??[],Ye=ce.unanswered??null;Oe(g,{entries:Je,ids:Je.map((Me)=>Me.id),olderCursor:Be,review:Fe,unanswered:Ye,rail:j?.rail??[],hashes:j?.hashes??{}}),we.setThread(Q,Je,Boolean(Be),Fe,Ye);try{let Z=(await R.rpc("subscribe",{topic:"thread",thread:g})).sub??null;if(Z!==null){if(S!==ne){R.rpc("unsubscribe",{sub:Z}).catch(()=>{});return}Le=Z}}catch{}if(S!==ne)return;if(tn(g,S),fi(g,S),K)mt(K)}async function fi(g,y){if(!g||!R.hasFeature("mgmt")){if(y===ne)ot.clear();return}let S=x.find((j)=>j.id===g),N=S?.project?C.find((j)=>j.id===S.project)?.root??"":"";if(!N&&R.hasFeature("viewers"))try{let j=await R.rpc("viewer.files",{thread:g});if(y!==ne)return;N=j.pcb||j.sch||j.root||""}catch{}if(y!==ne)return;if(N)await ot.watchProject(N);else ot.clear()}async function vi(g){let y=ne;for(let S=0;S<25&&y===ne;S++){if(we.goTo(g))return;if(!Be)return;let N=Be;if(await wi(),Be===N)return}}async function wi(){if(!D||!Be){we.clearLoadingOlder();return}let g=ne,y=D,S=Be;try{let N=await R.rpc("thread.entries",{thread:y,limit:40,before:S});if(g!==ne||D!==y)return;Be=N.next??null,we.prependEntries(N.entries??[],Boolean(Be))}catch{if(g===ne)we.clearLoadingOlder()}}async function ut(g){try{let y=await R.rpc("thread.create",{project:g});if(y.thread)x=[y.thread,...x.filter((S)=>S.id!==y.thread.id)],ve.setData(C,x,F,I),Xe(),await qe(y.thread.id),pe.focus()}catch(y){Ae(y,"Could not create thread")}}let Et=null;function yi(g){return(g.split(` -`).map((y)=>y.trim()).find((y)=>y.length>0)??"").slice(0,200)}function jt(g){Et=g,pe.setReply(g?{who:g.role==="user"?m("secret.you","You"):m("model.col.agent","Agent"),line:yi(g.text)}:null,()=>{if(Et)vi(Et.id)},()=>jt(null))}async function Ei(g,y=[]){if(!D)return;let S=ne,N=D,j=Yo(),Q=`local-${j}`,ce=Et&&g.trim()&&R.hasFeature("reply")?Et:null;if(ce)jt(null);we.upsertEntry({id:Q,kind:"user",text:g,at:Date.now(),clientId:j,...ce?{replyTo:{id:ce.id,quote:yi(ce.text)}}:{},attachments:y.map((Fe)=>({name:Fe.name,mime:Fe.mime,previewUrl:`data:${Fe.mime};base64,${Fe.data}`}))});try{let Fe={thread:N,text:g,clientId:j};if(y.length>0)Fe.attachments=y;if(ce)Fe.replyTo={id:ce.id,text:ce.text};let Je=await R.rpc("message.send",Fe);if(S!==ne||D!==N)return;if(Je.entry)we.upsertEntry(Je.entry)}catch(Fe){if(S===ne&&D===N){if(we.removeEntry(Q),pe.setDraft(g),ce&&!Et)jt(ce);Ae(Fe,"Failed to send message")}}}async function Ci(g){if(!D)return;let y=ne,S=D;try{let N=await R.rpc("composer.run",{thread:S,text:g});if(y!==ne||D!==S)return;if(N.error)pe.setDraft(g),Ae(new Kt(N.error,{code:N.errorCode,machine:N.machine}),N.error);else if(N.kind==="btw"&&typeof N.a==="string")we.showBtw(N.q??"",N.a);else if(N.kind==="edit"&&typeof N.text==="string")pe.setDraft(N.text);else if(N.kind==="project")_.open({mode:"folder"});else if(N.kind==="clone")_.open({mode:"clone",repo:N.repo??"",text:N.text??""})}catch(N){if(y===ne&&D===S)pe.setDraft(g),Ae(N,"Command refused")}}async function bt(g,y){try{let S=await R.rpc("thread.act",{thread:g,action:y});if(S.thread){if(x=x.map((N)=>N.id===S.thread.id?S.thread:N),ve.setData(C,x,F,I),S.thread.id===D)we.updateThreadMeta(S.thread),Ie()}Xe()}catch(S){pe.showError(S instanceof Error?S.message:`Action "${y}" not allowed`)}}function ki(g,y){if(!g||!g.text||y-g.at>=300000)return"";let S=g.build.split("-").pop()??"";if(g.reason==="build"&&S)return m("hub.restarting.build",g.text,{build:S});if(g.reason==="stop")return m("hub.stopped",g.text);return m("hub.restarting",g.text)}function sn(g){if(g==="connected")ve.setConnStatus(m("gpui.acct.connected","Connected"),"bp-ok");else if(g==="reconnecting"&&ki(R.restarting,Date.now()))ve.setConnStatus(ki(R.restarting,Date.now()),"");else if(g==="reconnecting")ve.setConnStatus("Reconnecting…","bp-warn");else if(g==="revoked")ve.setConnStatus(m("gpui.acct.sign.in.expired","Sign-in expired"),"bp-bad");else ve.setConnStatus("Connecting…","")}rn(()=>{sn(R.getState()),H.textContent=m("gpui.improvements","Improvements"),Y.title=m("palette.settings","Settings"),Y.setAttribute("aria-label",m("palette.settings","Settings")),Ie(),ve.refreshLocale(),we.refreshLocale(),pe.refreshLocale(),G.render(),q.refreshLocale(),ze.refreshLocale(),_.refreshLocale()}),R.onState((g,y)=>{if(g==="connected"&&y){if(y.locale)bi=y.locale,Lr();if(y.theme)Sr(y.theme);if(y.name)ve.setHostName(y.name);if(Array.isArray(y.favoriteModels))J=y.favoriteModels,pe.updateFavoriteModels(J);if(z=y.home??null,ve.setHome(z),ye(_n(y.noProvider)),q.isOpen())q.refresh();sn(g);let S=typeof y.hubBack==="string"?String(y.hubBack):"";if(S)try{let N=JSON.parse(S);if(N.reason==="crash")ve.setConnStatus(m("hub.back.crash",N.text??""),"bp-warn"),window.setTimeout(()=>sn(R.getState()),6000)}catch{}if(pe.setFeatures(R.hasFeature("images"),R.hasFeature("voice")),Array.isArray(y.commands))Ee=y.commands,pe.setCommands(Ee);else Ee=[];Mr(),_.reconcile()}else tt.cancel(),sn(g)}),R.onFrame((g)=>{if(g.t==="voice"){tt.handleFrame(g);return}if(g.t==="info"&&g.info&&typeof g.info==="object"){let S=g.info;if(Object.prototype.hasOwnProperty.call(S,"provider.notice"))ye(_n(S["provider.notice"]));ot.handleInfo(S);return}if(g.t!=="d")return;let y=g;if(y.k==="clone"||y.k==="clone.repos"||y.k==="clone.signin"){_.handleFrame(y);return}switch(y.k){case"project":{let S=y.project;if(!S)break;let N=C.findIndex((j)=>j.id===S.id);if(N>=0)C[N]=S;else C.unshift(S);ve.setData(C,x,F,I),Ie(),nn();break}case"thread":{let S=y.thread;if(!S)break;let N=x.findIndex((j)=>j.id===S.id);if(N>=0)x[N]=S;else x.unshift(S);if(ve.setData(C,x,F,I),S.id===D)we.updateThreadMeta(S),Ie(),pe.setState(!0,S.state==="working");nn();break}case"thread.removed":{let S=String(y.id??"");x=x.filter((N)=>N.id!==S),ve.setData(C,x,F,I),nn();break}case"entry":{if(y.thread===D&&y.entry)we.upsertEntry(y.entry);break}case"text":{if(y.thread===D)we.appendLiveText(String(y.entry??""),String(y.append??""),Number(y.at??Date.now()));break}case"turn":{if(y.thread===D){let S=String(y.state??"idle");pe.setState(!0,S==="working"),tn(D,ne)}nn();break}case"btw":{if(y.thread===D)we.showBtw(String(y.q??""),String(y.a??""));break}case"unanswered":{if(y.thread===D)we.setUnanswered(y.unanswered??null);break}case"theme":{if(typeof y.theme==="string")Sr(y.theme);break}case"home":{if(z=y.home??null,ve.setHome(z),q.isOpen())q.refresh();break}case"favorites":{if(Array.isArray(y.favorites))J=y.favorites.filter((S)=>typeof S==="string"),pe.updateFavoriteModels(J);break}default:break}}),window.addEventListener("keydown",(g)=>{let y=g.key.toLowerCase();if((g.ctrlKey||g.metaKey)&&(y==="k"||g.shiftKey&&y==="p"))if(g.preventDefault(),W.isOpen())W.close();else W.open();else if(g.shiftKey&&g.code==="KeyN"&&(g.altKey||g.ctrlKey||g.metaKey))g.preventDefault(),ut(yt);else if(g.key==="Escape"){let S=document.querySelector('[data-testid="move-project-modal"]');if(S){S.remove();return}if(W.isOpen())W.close();else if(pe.isModelPickerOpen())pe.closeModelPicker();else if(_.isOpen())_.escape();else if(q.isOpen())q.handleEscape();else if(we.closePlanRevise());else if(ot.isOpen())ot.closePanel()}}),R.connect()}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",Ar);else Ar(); +`;function Ze(e){let t=e/255;return t<=0.04045?t/12.92:Math.pow((t+0.055)/1.055,2.4)}var zo=[Ze(77),Ze(83),Ze(94)],qo=[Ze(53),Ze(58),Ze(67)],Ko=[Ze(245),Ze(246),Ze(248)],Jo=[Ze(225),Ze(228),Ze(233)];function Cr(e,t,n){let i=e.createShader(t);if(!i)throw Error("createShader failed");if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){let s=e.getShaderInfoLog(i)||"shader compile error";throw e.deleteShader(i),Error(s)}return i}function kr(e,t,n){let i=Cr(e,e.VERTEX_SHADER,t),s=Cr(e,e.FRAGMENT_SHADER,n),r=e.createProgram();if(!r)throw Error("createProgram failed");if(e.attachShader(r,i),e.attachShader(r,s),e.linkProgram(r),e.deleteShader(i),e.deleteShader(s),!e.getProgramParameter(r,e.LINK_STATUS)){let o=e.getProgramInfoLog(r)||"program link error";throw e.deleteProgram(r),Error(o)}return r}function Yo(e,t){let n=new Float32Array(16);for(let i=0;i<4;i++)for(let s=0;s<4;s++)n[i*4+s]=e[0+s]*t[i*4+0]+e[4+s]*t[i*4+1]+e[8+s]*t[i*4+2]+e[12+s]*t[i*4+3];return n}function Xo(e,t,n,i){let s=1/Math.tan(e*0.5),r=1/(n-i),o=new Float32Array(16);return o[0]=s/t,o[5]=s,o[10]=(i+n)*r,o[11]=-1,o[14]=2*i*n*r,o}function xr(e){let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]}function Pr(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function ui(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}class bi{canvas;gl=null;bgProg=null;bgVao=null;uBgTop=null;uBgBot=null;prog=null;uMvp=null;uEye=null;uRight=null;uUp=null;uFwd=null;uFade=null;worker=null;boardBatch=null;partBatches=[];activeKey="";lastMeshId="";nextJobId=1;partsTotal=0;partsDone=0;center=[0,0,0];target=[0,0,0];radius=50;dist=120;yaw=0.6;pitch=0.7;lightTheme=!1;dirty=!1;rafId=0;pointers=new Map;pinchDist=0;resizeObs;cbs;constructor(e,t={}){this.cbs=t,this.canvas=document.createElement("canvas"),this.canvas.className="bp-viewer-canvas",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.style.touchAction="none",e.appendChild(this.canvas);let n=this.canvas.getContext("webgl2",{antialias:!0,alpha:!1,preserveDrawingBuffer:!0});if(n)this.gl=n,this.bgProg=kr(n,Vo,Uo),this.bgVao=n.createVertexArray(),this.uBgTop=n.getUniformLocation(this.bgProg,"uBgTop"),this.uBgBot=n.getUniformLocation(this.bgProg,"uBgBot"),this.prog=kr(n,Wo,_o),this.uMvp=n.getUniformLocation(this.prog,"uMvp"),this.uEye=n.getUniformLocation(this.prog,"uEye"),this.uRight=n.getUniformLocation(this.prog,"uRight"),this.uUp=n.getUniformLocation(this.prog,"uUp"),this.uFwd=n.getUniformLocation(this.prog,"uFwd"),this.uFade=n.getUniformLocation(this.prog,"uFade"),n.enable(n.DEPTH_TEST),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);else this.cbs.onStatus?.("WebGL2 is unavailable in this browser");try{this.worker=new Worker("/assets/mesh-worker.js",{type:"module"}),this.worker.onmessage=(i)=>this.onWorkerMessage(i.data)}catch{this.cbs.onStatus?.("3D worker unavailable")}this.resizeObs=new ResizeObserver(()=>this.scheduleDraw()),this.resizeObs.observe(this.canvas),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.canvas.addEventListener("pointermove",this.onPointerMove),this.canvas.addEventListener("pointerup",this.onPointerUp),this.canvas.addEventListener("pointercancel",this.onPointerUp),this.canvas.addEventListener("wheel",this.onWheel,{passive:!1}),this.canvas.addEventListener("dblclick",this.onDblClick),this.canvas.addEventListener("contextmenu",this.onContextMenu)}keptToken(){return this.activeKey&&this.lastMeshId?`${this.activeKey} ${this.lastMeshId}`:""}setTheme(e){if(this.lightTheme!==e)this.lightTheme=e,this.scheduleDraw()}handleFrame(e){let t=typeof e.key==="string"?e.key:"";if(!t)return;if(e.mesh instanceof Uint8Array&&typeof e.n==="number"&&!e.part){this.activeKey=t,this.lastMeshId=lr(e.mesh),this.clearParts(),this.cbs.onStatus?.("Building 3D model…");let n=new Uint8Array(e.mesh),i=e.faces instanceof Uint8Array?new Uint8Array(e.faces):void 0,s=[n.buffer];if(i)s.push(i.buffer);this.worker?.postMessage({id:this.nextJobId++,kind:"solid",key:t,n:e.n,mesh:n,faces:i},s);return}if(e.parts&&typeof e.parts==="object"&&!Array.isArray(e.parts)&&!(e.parts instanceof Uint8Array)){if(this.activeKey&&t!==this.activeKey)return;if(this.activeKey=t,this.clearParts(),this.partsTotal=typeof e.parts.of==="number"?e.parts.of:0,this.partsDone=0,this.partsTotal>0)this.cbs.onStatus?.(`Loading parts 0/${this.partsTotal}…`);this.scheduleDraw();return}if(typeof e.part==="string"&&e.mesh instanceof Uint8Array&&e.at instanceof Uint8Array&&typeof e.n==="number"){if(this.activeKey&&t!==this.activeKey)return;let n=new Uint8Array(e.mesh),i=new Uint8Array(e.at),s=e.faces instanceof Uint8Array?new Uint8Array(e.faces):void 0,r=[n.buffer,i.buffer];if(s)r.push(s.buffer);this.worker?.postMessage({id:this.nextJobId++,kind:"part",key:t,partId:e.part,n:e.n,mesh:n,at:i,faces:s,refs:Array.isArray(e.refs)?e.refs:[],done:typeof e.done==="number"?e.done:0},r)}}onWorkerMessage(e){if(e.error){this.cbs.onStatus?.(e.error);return}if(e.key!==this.activeKey||!this.gl)return;if(e.kind==="solid")this.deleteBatch(this.boardBatch),this.boardBatch=this.uploadBatch(e.positions,e.normals,e.colors,0),this.center=[e.center[0],e.center[1],e.center[2]],this.target=[e.center[0],e.center[1],e.center[2]],this.radius=e.radius,this.fit(),this.cbs.onStatus?.(""),this.scheduleDraw();else if(e.kind==="part"){let t=this.uploadBatch(e.positions,e.normals,e.colors,performance.now());if(t)this.partBatches.push(t);if(this.partsDone=e.done||this.partsDone+1,this.partsTotal>0&&this.partsDone>>24===0)r++;else o++;let a=r>0?new Float32Array(r*9):null,c=r>0?new Float32Array(r*9):null,p=r>0?new Float32Array(r*12):null,l=o>0?new Float32Array(o*9):null,h=o>0?new Float32Array(o*9):null,d=o>0?new Float32Array(o*12):null,u=0,f=0;for(let y=0;y>>24&255,A=1-k/255,N=(w>>>16&255)/255,L=(w>>>8&255)/255,B=(w&255)/255,T=y*9;if(k===0&&a&&c&&p){let H=u*9;for(let P=0;P<9;P++)a[H+P]=e[T+P],c[H+P]=t[T+P];let F=u*12;for(let P=0;P<3;P++)p[F+P*4]=N,p[F+P*4+1]=L,p[F+P*4+2]=B,p[F+P*4+3]=1;u++}else if(l&&h&&d){let H=f*9;for(let P=0;P<9;P++)l[H+P]=e[T+P],h[H+P]=t[T+P];let F=f*12;for(let P=0;P<3;P++)d[F+P*4]=N,d[F+P*4+1]=L,d[F+P*4+2]=B,d[F+P*4+3]=A;f++}}let g=a&&c&&p?this.createSubBatch(a,c,p,r*3):null,v=l&&h&&d?this.createSubBatch(l,h,d,o*3):null;if(!g&&!v)return null;return{opaque:g,translucent:v,fadeStartMs:i}}deleteSubBatch(e){let t=this.gl;if(!t||!e)return;t.deleteVertexArray(e.vao),t.deleteBuffer(e.posBuf),t.deleteBuffer(e.nrmBuf),t.deleteBuffer(e.colBuf)}deleteBatch(e){if(!e)return;this.deleteSubBatch(e.opaque),this.deleteSubBatch(e.translucent)}clearParts(){for(let e of this.partBatches)this.deleteBatch(e);this.partBatches=[]}fit(){this.setView("fit")}setView(e){let t=35*Math.PI/180;this.dist=this.radius/Math.sin(t*0.5)*1.15,this.target=[this.center[0],this.center[1],this.center[2]];let{yaw:n,pitch:i}=Er(e);this.yaw=n,this.pitch=i,this.scheduleDraw()}snapPng(){return this.draw(performance.now()),new Promise((e)=>{this.canvas.toBlob((t)=>e(t),"image/png")})}scheduleDraw(){if(this.dirty)return;this.dirty=!0,this.rafId=requestAnimationFrame((e)=>{if(this.dirty=!1,this.rafId=0,this.draw(e))this.scheduleDraw()})}drawSubBatch(e){if(!e||!this.gl)return;this.gl.bindVertexArray(e.vao),this.gl.drawArrays(this.gl.TRIANGLES,0,e.vertCount)}draw(e){let t=this.gl;if(!t||!this.prog)return!1;let n=this.canvas.getBoundingClientRect(),i=Math.max(1,Math.round(n.width)),s=Math.max(1,Math.round(n.height)),r=Math.min(window.devicePixelRatio||1,2),o=Math.round(i*r),a=Math.round(s*r);if(this.canvas.width!==o||this.canvas.height!==a)this.canvas.width=o,this.canvas.height=a;if(t.viewport(0,0,o,a),!this.boardBatch&&this.partBatches.length===0)return!1;if(t.depthMask(!0),t.clear(t.DEPTH_BUFFER_BIT),this.bgProg&&this.bgVao){t.disable(t.DEPTH_TEST),t.disable(t.BLEND),t.depthMask(!1),t.useProgram(this.bgProg);let H=this.lightTheme?Ko:zo,F=this.lightTheme?Jo:qo;t.uniform3f(this.uBgTop,H[0],H[1],H[2]),t.uniform3f(this.uBgBot,F[0],F[1],F[2]),t.bindVertexArray(this.bgVao),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.bindVertexArray(null)}let c=Math.cos(this.pitch),p=Math.sin(this.pitch),l=Math.cos(this.yaw),h=Math.sin(this.yaw),d=[this.target[0]+this.dist*c*h,this.target[1]-this.dist*c*l,this.target[2]+this.dist*p],u=xr([this.target[0]-d[0],this.target[1]-d[1],this.target[2]-d[2]]),f=Math.abs(u[2])>0.99?[0,1,0]:[0,0,1],g=xr(Pr(u,f)),v=Pr(g,u),y=new Float32Array([g[0],v[0],-u[0],0,g[1],v[1],-u[1],0,g[2],v[2],-u[2],0,-ui(g,d),-ui(v,d),ui(u,d),1]),w=Math.max(0.05,this.dist*0.01),k=Math.max(this.dist*10,this.radius*20),A=Xo(35*Math.PI/180,o/a,w,k),N=Yo(A,y);t.useProgram(this.prog),t.uniformMatrix4fv(this.uMvp,!1,N),t.uniform3f(this.uEye,d[0],d[1],d[2]),t.uniform3f(this.uRight,g[0],g[1],g[2]),t.uniform3f(this.uUp,v[0],v[1],v[2]),t.uniform3f(this.uFwd,u[0],u[1],u[2]);let L=!1,B=[],T=[];for(let H of this.partBatches){let F=e-H.fadeStartMs,P=H.fadeStartMs===0?1:Math.min(1,Math.max(0,F/300));if(P<1){if(L=!0,P>0)T.push({batch:H,fade:P})}else B.push(H)}if(t.enable(t.DEPTH_TEST),t.depthMask(!0),t.disable(t.BLEND),t.uniform1f(this.uFade,1),this.boardBatch)this.drawSubBatch(this.boardBatch.opaque);for(let H of B)this.drawSubBatch(H.opaque);if(t.depthMask(!1),t.enable(t.BLEND),t.uniform1f(this.uFade,1),this.boardBatch)this.drawSubBatch(this.boardBatch.translucent);for(let H of B)this.drawSubBatch(H.translucent);for(let{batch:H,fade:F}of T)t.uniform1f(this.uFade,F),this.drawSubBatch(H.opaque),this.drawSubBatch(H.translucent);return t.depthMask(!0),t.bindVertexArray(null),L}onPointerDown=(e)=>{if(this.canvas.setPointerCapture(e.pointerId),this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY,button:e.button,shift:e.shiftKey}),this.pointers.size===2){let[t,n]=Array.from(this.pointers.values());this.pinchDist=Math.hypot(n.x-t.x,n.y-t.y)||1}};onPointerMove=(e)=>{let t=this.pointers.get(e.pointerId);if(!t)return;let n=e.clientX-t.x,i=e.clientY-t.y;if(t.x=e.clientX,t.y=e.clientY,this.pointers.size===2){let[s,r]=Array.from(this.pointers.values()),o=Math.hypot(r.x-s.x,r.y-s.y)||1;if(this.pinchDist>0)this.dist=Math.max(this.radius*0.05,Math.min(this.radius*20,this.dist*(this.pinchDist/o)));this.pinchDist=o,this.cbs.onUserMove?.(),this.scheduleDraw();return}if(t.button===2||t.button===1||t.shift){let s=this.dist*0.0014,r=Math.cos(this.yaw),o=Math.sin(this.yaw);this.target[0]-=n*r*s,this.target[1]-=n*o*s,this.target[2]+=i*s}else this.yaw+=n*0.008,this.pitch=Math.max(-Math.PI*0.49,Math.min(Math.PI*0.49,this.pitch+i*0.008));this.cbs.onUserMove?.(),this.scheduleDraw()};onPointerUp=(e)=>{if(this.pointers.delete(e.pointerId),this.pointers.size<2)this.pinchDist=0};onWheel=(e)=>{e.preventDefault();let t=e.deltaY<0?0.8620689655172414:1.16;this.dist=Math.max(this.radius*0.05,Math.min(this.radius*20,this.dist*t)),this.cbs.onUserMove?.(),this.scheduleDraw()};onDblClick=()=>{this.fit()};onContextMenu=(e)=>{e.preventDefault()};destroy(){if(this.rafId)cancelAnimationFrame(this.rafId);if(this.resizeObs.disconnect(),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("dblclick",this.onDblClick),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.deleteBatch(this.boardBatch),this.clearParts(),this.gl){if(this.bgVao)this.gl.deleteVertexArray(this.bgVao);if(this.bgProg)this.gl.deleteProgram(this.bgProg);if(this.prog)this.gl.deleteProgram(this.prog)}this.worker?.terminate(),this.canvas.remove()}}var Sr=64,Qo=16777216;function Zo(e,t){switch(e){case"board":case"3d":return t.board!==!1;case"schematic":return t.schematic!==!1;case"mech":return t.mech!==!1;case"gerbers":return t.gerbers!==!1;default:return!0}}function Qt(e){if(!e)return"";let t=e.replace(/\\/g,"/").replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Ar(e){switch(e){case"board":return m("viewer.board","Board");case"schematic":return m("viewer.schematic","Schematic");case"3d":return m("viewer.solid","3D");case"gerbers":return m("gpui.gerbers","Gerbers");case"mech":return m("viewer.mech","Mech");case"files":return m("viewer.files","Files");case"diff":return m("viewer.diff","Diff");case"review":return m("viewer.review","Review");case"browser":return m("bots.tab.browser","Browser");case"terminal":return m("viewer.terminal","Terminal");default:return e?e.charAt(0).toUpperCase()+e.slice(1):""}}function gi(e){return e==="board"||e==="schematic"||e==="gerbers"}function ea(e){return e==="files"||e==="diff"||e==="review"||e==="browser"||e==="terminal"}function fi(e,t){let n=document.createElement("div");n.className="bp-vh";let i=document.createElement("div");i.className="bp-vh-title";let s=document.createElement("span");s.className="bp-vh-page";let r=document.createElement("span");r.className="bp-vh-sep",r.textContent="·",r.hidden=!0;let o=document.createElement("span");o.className="bp-vh-file",o.hidden=!0,i.append(s,r,o);let a=document.createElement("div");a.className="bp-vh-actions",n.append(i,a);let c=document.createElement("div");c.className="bp-solid-bar",c.setAttribute("data-testid","solid-presets-bar"),c.hidden=!0;let p=document.createElement("div");p.className="bp-v-banner",p.hidden=!0;let l=document.createElement("div");l.className="bp-v-stage-wrap";let h=document.createElement("div");h.className="bp-v-stage";let d=document.createElement("div");d.className="bp-v-overlay",d.hidden=!0;let u=document.createElement("div");u.className="bp-v-layers",u.hidden=!0;let f=document.createElement("div");f.className="bp-v-info",f.hidden=!0,l.append(h,d,u,f);let g=document.createElement("div");g.className="bp-history-bar",g.setAttribute("data-testid","viewer-history-bar"),g.hidden=!0,e.replaceChildren(n,c,p,l,g);let v="",y="",w=0,k=!1,A=new Set,N=[],L=0,B=new Map,T=new Map,H={},F=[],P="",K="",ae=!1,re=!1,ve=0,Ae=!1,ke=0,ne="",le=0,R=null,he=null,ce=null,te=null,we=null,E=new mi,x=0,D=!1,I="",J="",oe="",Ee="";document.addEventListener("click",(G)=>{if(!D)return;if(G.target instanceof Node&&g.contains(G.target))return;D=!1,Me()}),document.addEventListener("keydown",(G)=>{if(D&&G.key==="Escape")D=!1,Me()});function Ce(){if(x)window.clearInterval(x),x=0;E.playing=!1}function O(){let G=y==="3d"||y==="mech";if(c.hidden=!G,!G)return;if(c.childElementCount>0)return;for(let _ of wr){let V=document.createElement("button");V.type="button",V.className="bp-v-btn",V.textContent=_.label,V.setAttribute("data-testid",`solid-view-${_.id}`),V.addEventListener("click",()=>{ce?.setView(_.id)}),c.append(V)}let z=document.createElement("button");z.type="button",z.className="bp-v-btn",z.textContent="Snap view",z.setAttribute("data-testid","solid-snap"),z.addEventListener("click",()=>{if(!ce)return;ce.snapPng().then((_)=>{if(!_)return;let V=URL.createObjectURL(_),W=document.createElement("a");W.href=V;let se=(Ge()||y||"view").replace(/[^a-zA-Z0-9._-]/g,"_");W.download=`${se}-snap.png`,W.click(),setTimeout(()=>URL.revokeObjectURL(V),1000)})}),c.append(z)}async function X(){if(!v||y!=="board"&&y!=="schematic")return;Me();let G=E.compareRequest();if(!G){I="",J="",oe="",Ee="",await xe(!1);return}let z=`${y}|${G.commit}|${G.bits}|${K}`;if(z===Ee&&A.size>0){Oe(E.highlightEdits?`Comparing against ${E.activeRef()?.label||G.commit.slice(0,7)} (edits highlighted)`:`Comparing against ${E.activeRef()?.label||G.commit.slice(0,7)}`,!1);return}let _=++w;A.clear(),B.clear(),be(),k=!0,I="",J=G.commit,oe="",Ee=z;try{let V=K||(y==="schematic"?H.sch:H.pcb)||"";if(!V){let Pe=await t.hub.rpc("viewer.files",{thread:v});if(_!==w)return;H=Pe||{},He(),V=(y==="schematic"?H.sch:H.pcb)||""}if(!V)throw Error(`Unable to resolve ${y} file path for compare`);let W=await t.hub.rpc("viewer.compare",{thread:v,kind:y,commit:G.commit,bits:G.bits,...K?{path:K}:{}});if(_!==w)return;let se=typeof W?.root==="string"?W.root:"",Q=y==="schematic"?"1":"0";I=se?`${Q}|${se}|diff +`:`${Q}|`,J=G.commit,oe=V.startsWith("/")||/^[A-Za-z]:[\\/]/.test(V)||!se?V:`${se.replace(/\/+$/,"")}/${V.replace(/^\/+/,"")}`,k=!1;let pe=N;be();for(let Pe of pe)if(Pe.kind==="bin")tt(Pe.buf);else ft(Pe.key,Pe.none,Pe.retryable,Pe.big);Oe(E.highlightEdits?`Comparing against ${E.activeRef()?.label||G.commit.slice(0,7)} (edits highlighted)`:`Viewing snapshot: ${E.activeRef()?.label||G.commit.slice(0,7)}`,!1)}catch(V){if(_!==w)return;k=!1,I="",J="",oe="",Ee="",be(),Oe(V instanceof Error?V.message:String(V),!0)}}function Me(){let G=y==="board"||y==="schematic";if(g.hidden=!G,!G)return;let z=document.createElement("div");z.className="bp-history-group";let _=document.createElement("button");_.type="button",_.className="bp-v-btn",_.textContent="<",_.title="Older snapshot",_.disabled=E.refs.length===0||E.index>=E.refs.length-1,_.setAttribute("data-testid","history-prev"),_.addEventListener("click",()=>{if(Ce(),E.step(1))X()});let V=document.createElement("button");V.type="button",V.className="bp-v-btn"+(E.playing?" is-on":""),V.textContent=E.playing?"⏸":"▶",V.title=E.playing?"Pause history":"Play history",V.disabled=E.refs.length===0,V.setAttribute("data-testid","history-play"),V.addEventListener("click",()=>{if(E.playing){Ce(),Me();return}if(E.refs.length===0)return;if(E.playing=!0,E.isLive())E.index=E.refs.length-1,X();else Me();x=window.setInterval(()=>{if(!E.playing||y!=="board"&&y!=="schematic"){Ce(),Me();return}if(E.step(-1))X();else Ce(),Me()},1400)});let W=document.createElement("button");W.type="button",W.className="bp-v-btn",W.textContent=">",W.title="Newer snapshot",W.disabled=E.isLive(),W.setAttribute("data-testid","history-next"),W.addEventListener("click",()=>{if(Ce(),E.step(-1))X()});let se=document.createElement("button");se.type="button",se.className="bp-v-btn"+(E.isLive()?" is-on":""),se.textContent="Live",se.setAttribute("data-testid","history-live"),se.addEventListener("click",()=>{if(Ce(),E.goLive())Oe("",!1),X()});let Q=document.createElement("span");Q.className="bp-history-label",Q.setAttribute("data-testid","history-label");let pe=E.activeRef();Q.textContent=pe?pe.label||pe.commit.slice(0,7):E.refs.length>0?`Live (${E.refs.length} saved)`:"Live",z.append(_,V,W,se,Q);let Pe=document.createElement("div");Pe.className="bp-history-group";let Re=document.createElement("button");Re.type="button",Re.className="bp-v-btn"+(E.highlightEdits?" is-on":""),Re.textContent="Highlight edits",Re.disabled=E.refs.length===0,Re.setAttribute("data-testid","history-highlight"),Re.addEventListener("click",()=>{Ce(),E.toggleHighlight(),X()});let De=document.createElement("div");De.className="bp-history-menu-wrap";let Fe=document.createElement("button");if(Fe.type="button",Fe.className="bp-v-btn"+(D||!E.isLive()?" is-on":""),Fe.disabled=E.refs.length===0,Fe.setAttribute("data-testid","history-compare"),Fe.setAttribute("aria-haspopup","menu"),Fe.setAttribute("aria-expanded",String(D)),Fe.textContent=pe?`Compare: ${pe.label||pe.commit.slice(0,7)} ▾`:"Compare ▾",Fe.addEventListener("click",($e)=>{$e.stopPropagation(),D=!D,Me()}),De.append(Fe),D&&E.refs.length>0){let $e=document.createElement("div");$e.className="bp-history-menu",$e.setAttribute("role","menu"),$e.setAttribute("data-testid","history-compare-menu");let Ye=(Ie,at,vt)=>{let nt=document.createElement("button");nt.type="button",nt.className="bp-history-menu-item"+(vt?" is-active":""),nt.setAttribute("role","menuitem"),nt.setAttribute("data-commit",at),nt.textContent=Ie,nt.addEventListener("click",()=>{if(D=!1,Ce(),E.selectCommit(at)){if(E.isLive())Oe("",!1);X()}else Me()}),$e.append(nt)};Ye("Live (working tree)","",E.isLive());for(let Ie of E.refs)Ye(Ie.label||Ie.commit.slice(0,7),Ie.commit,pe?.commit===Ie.commit);De.append($e)}Pe.append(Re,De),g.replaceChildren(z,Pe)}async function Ve(G){if(!G)return;try{let z=await t.hub.rpc("viewer.refs",{thread:G});if(G!==v)return;E.setRefs(Array.isArray(z?.refs)?z.refs:[]),Me()}catch{if(G!==v)return;E.setRefs([]),Me()}}function q(){return document.documentElement.classList.contains("light")}let me=new MutationObserver(()=>{let G=q();he?.setTheme(G),ce?.setTheme(G),we?.setTheme(G)});me.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]});function ie(G,z="",_=!1,V=""){if(G==="none"){d.hidden=!0,d.replaceChildren();return}d.hidden=!1,d.className=`bp-v-overlay is-${G}`;let W=document.createElement("div");W.className="bp-v-state-card";let se=document.createElement("div");if(se.className="bp-v-state-msg",se.textContent=z,W.append(se),_){let Q=document.createElement("button");Q.type="button",Q.className="bp-v-btn is-primary",Q.textContent=m("tools.retry","Retry"),Q.addEventListener("click",()=>void xe(!0)),W.append(Q)}if(V){let Q=document.createElement("div");Q.className="bp-v-state-msg",Q.textContent=m("gpui.c.solid.big.next","Loading it may take a while and a lot of memory.");let pe=document.createElement("button");pe.type="button",pe.className="bp-v-btn is-primary",pe.textContent=m("gpui.c.solid.load.big","Load it anyway"),pe.addEventListener("click",()=>{ie("loading",m("gpui.c.solid.loading.big","Loading it anyway…")),t.hub.rpc("kicad.big",{key:V}).catch(()=>ie("error",z,!1,V))}),W.append(Q,pe)}d.replaceChildren(W)}function Oe(G,z){p.textContent=G,p.hidden=!G,p.classList.toggle("is-warn",z)}function Ge(){if(K)return Qt(K);if(y==="board"||y==="3d")return Qt(H.pcb);if(y==="schematic")return Qt(H.sch);if(y==="mech")return Qt(P);return""}function He(){s.textContent=Ar(y);let G=Ge();if(r.hidden=!G,o.hidden=!G,o.textContent=G,a.replaceChildren(),y==="mech"&&F.length>1){let _=document.createElement("select");_.className="bp-v-select",_.setAttribute("aria-label",m("viewer.mech","Mech"));for(let V of F){let W=document.createElement("option");W.value=V,W.textContent=Qt(V),W.selected=V===P,_.append(W)}_.addEventListener("change",()=>{P=_.value,He(),xe(!1)}),a.append(_)}if(gi(y)){let _=document.createElement("button");_.type="button",_.className="bp-v-btn"+(Ae?" is-on":""),_.textContent=R?.layerHead||"Layers",_.setAttribute("data-testid","viewer-layers-btn"),_.addEventListener("click",()=>{if(Ae=!Ae,u.hidden=!Ae,_.classList.toggle("is-on",Ae),Ae)Te("","")}),a.append(_)}if(y==="board"||y==="schematic"||y==="3d"||y==="mech"||y==="gerbers"){let _=document.createElement("button");_.type="button",_.className="bp-v-btn",_.textContent="Fit",_.setAttribute("data-testid","viewer-fit-btn"),_.addEventListener("click",()=>{he?.fit(),ce?.fit()}),a.append(_)}if((y==="board"||y==="schematic")&&t.hub.hasFeature("follow")){let _=document.createElement("button");_.type="button",_.className="bp-v-btn"+(ae&&!re?" is-on":""),_.textContent=ae?re?m("gpui.follow.paused","Follow (paused)"):"Follow agent":"Follow agent",_.setAttribute("data-testid","viewer-follow-btn"),_.addEventListener("click",()=>void et()),a.append(_)}let z=document.createElement("button");z.type="button",z.className="bp-v-btn bp-v-close",z.textContent="✕",z.title=m("common.close","Close"),z.setAttribute("aria-label",m("common.close","Close")),z.setAttribute("data-testid","viewer-close-btn"),z.addEventListener("click",()=>t.closeViewer()),a.append(z)}function Je(){if(!R){u.replaceChildren();return}let G=document.createDocumentFragment(),z=document.createElement("div");z.className="bp-v-layers-head";let _=document.createElement("span");if(_.textContent=R.layerHead||"Layers",z.append(_),R.layerReset){let Q=document.createElement("button");Q.type="button",Q.className="bp-v-btn",Q.textContent="Reset",Q.addEventListener("click",()=>void Te("reset","")),z.append(Q)}if(G.append(z),R.layerModes){let Q=document.createElement("div");Q.className="bp-v-layers-modes",["All","Dim","Only"].forEach((pe,Pe)=>{let Re=document.createElement("button");Re.type="button",Re.className="bp-v-btn"+(R?.layerMode===Pe?" is-on":""),Re.textContent=pe,Re.addEventListener("click",()=>void Te("mode",String(Pe))),Q.append(Re)}),G.append(Q)}let V=he?.presentColors()??new Map,W=(R.layerList||[]).concat(R.layerMarks||[]),se=document.createElement("div");se.className="bp-v-layers-list";for(let Q of W){let pe=V.get(Q.layer);if(pe===void 0)continue;let Pe=document.createElement("div");Pe.className="bp-v-layer-row"+(Q.active?" is-focus":"");let Re=document.createElement("input");Re.type="checkbox",Re.checked=Q.on!==!1,Re.addEventListener("change",()=>void Te("toggle",String(Q.layer)));let De=document.createElement("span");De.className="bp-v-layer-swatch";let Fe=pe>>>16&255,$e=pe>>>8&255,Ye=pe&255;De.style.background=Q.on!==!1?`rgb(${Fe},${$e},${Ye})`:`rgba(${Fe},${$e},${Ye},0.2)`;let Ie=document.createElement("button");Ie.type="button",Ie.className="bp-v-layer-name",Ie.textContent=Q.name,Ie.addEventListener("click",()=>void Te("pick",String(Q.layer))),Pe.append(Re,De,Ie),se.append(Pe)}G.append(se),u.replaceChildren(G)}async function Te(G,z){if(!gi(y))return;let _=w;try{let V=await t.hub.rpc("viewer.layers",{kind:y,present:le,off:ke,focus:ne,...G?{action:G,value:z}:{}});if(_!==w||!V)return;ke=Number(V.own)||0,ne=typeof V.focus==="string"?V.focus:"",R=V;let W={off:Number(V.off)||0,dim:Number(V.dim)||0,lift:typeof V.lift==="number"?V.lift:255};if(he?.setLayers(W),He(),Ae)Je()}catch{}}async function ze(){if(!ae||re||!v||!t.hub.hasFeature("follow"))return;re=!0,He();try{await t.hub.rpc("viewer.follow",{thread:v,action:"pause"})}catch{}}async function et(){if(!v||!t.hub.hasFeature("follow"))return;let G=!ae?"on":re?"resume":"off";try{let z=await t.hub.rpc("viewer.follow",{thread:v,action:G});if(ae=!!z.on,re=!!z.paused,He(),z.on&&!z.paused&&z.focus&&Array.isArray(z.focus.box)&&z.focus.box.length===4&&(z.seq||0)>ve)ve=z.seq||ve,he?.zoomToBoxMm([z.focus.box[0],z.focus.box[1],z.focus.box[2],z.focus.box[3]])}catch{}}function ht(){f.hidden=!0,f.replaceChildren(),he?.setHighlights([])}function Ht(G){let z=G.split(";").filter(Boolean),_=z.shift()||G,V=[],W="",se="";for(let De of z){if(De.startsWith("g="))continue;let Fe=De.indexOf("=");if(Fe>0){let $e=De.slice(0,Fe),Ye=De.slice(Fe+1);if(($e==="ref"||$e==="symbol")&&!W)W=Ye;if($e==="net"&&!se)se=Ye;V.push([$e,Ye])}else V.push([De,""])}let Q=document.createElement("div");Q.className="bp-v-info-head";let pe=document.createElement("span");pe.className="bp-v-info-title",pe.textContent=_;let Pe=document.createElement("button");Pe.type="button",Pe.className="bp-v-info-x",Pe.textContent="×",Pe.setAttribute("aria-label","Clear selection"),Pe.addEventListener("click",ht),Q.append(pe,Pe);let Re=document.createElement("div");Re.className="bp-v-info-rows";for(let[De,Fe]of V){let $e=document.createElement("span");$e.className="bp-v-info-chip",$e.textContent=Fe?`${De}: ${Fe}`:De,Re.append($e)}return f.replaceChildren(Q,...V.length>0?[Re]:[]),f.hidden=!1,{ref:W||void 0,net:se||void 0}}async function tn(G){if(!G){ht();return}let z=Array.from(A)[0]||"";if(!z)return;let _=w;try{let V=await t.hub.rpc("viewer.info",{key:z,at:G.at,idx:G.idx});if(_!==w)return;let W=typeof V.info==="string"?V.info:"";if(!W){ht();return}let{ref:se,net:Q}=Ht(W),pe=[];if(se)pe.push(["ref",se]);if(Q)pe.push(["net",Q]);let Pe=[[G.at,G.idx]];for(let[Re,De]of pe){let Fe=await t.hub.rpc("viewer.probe",{key:z,name:Re,value:De});if(_!==w)return;if(Array.isArray(Fe.matches))for(let $e of Fe.matches)Pe.push($e)}he?.setHighlights(Pe)}catch{ht()}}function kt(){te?.destroy(),te=null,we?.destroy(),we=null,he?.destroy(),he=null,ce?.destroy(),ce=null,h.replaceChildren(),Ae=!1,u.hidden=!0,f.hidden=!0,f.replaceChildren(),Oe("",!1),ie("none")}function be(){N=[],L=0}async function xe(G){if(!v||!y)return;let z=++w;if(A.clear(),k=!1,be(),kt(),He(),O(),Me(),(y==="board"||y==="schematic")&&v)Ve(v);if(ea(y)){if(t.hub.rpc("viewer.watch",{thread:v,kind:""}).catch(()=>{}),y==="files")te=gr(h,t,v,(W,se)=>{if(y=W,K=se,W==="mech")P=se;xe(!1)});else if(y==="diff")te=fr(h,t,v);else if(y==="review")te=vr(h,t,v);else if(y==="browser")te=mr(h,t,v);else if(y==="terminal")ie("loading","Loading terminal…"),import("/assets/terminal.js").then((se)=>{if(z!==w)return;if(ie("none"),se?.mountTerminalPane)we=se.mountTerminalPane(h,t,v,q());else ie("error","Terminal chunk missing",!0)},(se)=>{if(z!==w)return;ie("error",se instanceof Error?se.message:String(se),!0)});return}if(ie("loading","Loading…"),!H.root)try{let W=await t.hub.rpc("viewer.files",{thread:v});if(z!==w)return;H=W||{},He()}catch{}if(y==="gerbers"&&H.hasGerbers===!1){ie("empty","No Gerbers in this project",!1);return}let _=q();if(y==="3d"||y==="mech")ce=new bi(h,{onStatus:(W,se)=>{if(se)ie("none"),Oe(W,!1);else if(W)ie("loading",W);else ie("none"),Oe("",!1)},onUserMove:()=>void ze()}),ce.setTheme(_);else if(y==="board"||y==="schematic"||y==="gerbers")he=new pi(h,{onPick:(W)=>void tn(W),onUserMove:()=>void ze()}),he.setTheme(_);else{ie("empty",`${Ar(y)} is not available in this viewer`,!1);return}let V={thread:v};if(G)V.force=!0;if(y==="mech"){if(F.length===0)try{let W=await t.hub.rpc("mech.list",{thread:v});if(z!==w)return;if(F=Array.isArray(W.parts)?W.parts:[],!P)P=W.primary||F[0]||"";He()}catch(W){if(z!==w)return;ie("error",W instanceof Error?W.message:String(W),!0);return}if(!P){ie("empty",m("gpui.rail.no.mech","No mechanical parts in this project"),!1);return}V.kind="3d",V.path=P}else{if(V.kind=y,K&&(y==="board"||y==="schematic"))V.path=K;if(y==="3d"&&!G&&ce){let W=ce.keptToken();if(W)V.kept=W}if((y==="board"||y==="schematic"||y==="gerbers")&&!G&&t.hub.hasFeature("keptChunks"))V.keptChunks=Array.from(T.keys())}k=!0,I="",J="",oe="",Ee="";try{let W=await t.hub.rpc("viewer.watch",V);if(z!==w)return;A=new Set(Array.isArray(W.keys)?W.keys:[]),k=!1;let se=N;be();for(let Q of se)if(Q.kind==="bin")tt(Q.buf);else ft(Q.key,Q.none,Q.retryable,Q.big)}catch(W){if(z!==w)return;k=!1,A.clear(),be();let se=W instanceof Error?W.message:String(W),Q=/no gerbers|not in this project|another machine/i.test(se);ie(Q?"empty":"error",se,!Q)}}function ft(G,z,_,V=!1){if(k){if(N.length{if(G.t==="plot"&&typeof G.none==="string"&&typeof G.key==="string")ft(G.key,G.none,G.retryable===!0)}),Dt=on(()=>{if(y)He()}),ot=(G)=>{if(G.key==="Escape"&&y&&!f.hidden)ht()};return window.addEventListener("keydown",ot),{open(G,z){if(z!==v){if(v=z,H={},F=[],P="",B.clear(),ae=!1,re=!1,ve=0,ke=0,ne="",le=0,R=null,t.hub.hasFeature("follow"))t.hub.rpc("viewer.follow",{thread:z}).then((_)=>{if(z!==v)return;if(ae=!!_.on,re=!!_.paused,ve=Number(_.seq)||0,y)He()}).catch(()=>{})}if(G!==y)Ce(),E.goLive(),ke=0,ne="",le=0,R=null;y=G,K="",xe(!1)},reconcileHas(G){if(y&&!Zo(y,G))t.closeViewer()},close(){if(w++,k=!1,Ce(),D=!1,I="",J="",oe="",Ee="",E.goLive(),c.hidden=!0,g.hidden=!0,be(),v)t.hub.rpc("viewer.watch",{thread:v,kind:""}).catch(()=>{});y="",A.clear(),kt()}}}var Lr="http://www.w3.org/2000/svg";function Zt(e){let t=document.createElementNS(Lr,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","13"),t.setAttribute("height","13"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.8"),t.setAttribute("aria-hidden","true");for(let n of e){let i=document.createElementNS(Lr,"path");i.setAttribute("d",n),t.appendChild(i)}return t}function Nr(e){if(!e)return"bp-dot-idle";let t=e.status||e.state;if(t==="active"||t==="working")return"bp-dot-work";if(t==="finished")return"bp-dot-done";if(t==="waiting"||t==="asking"||t==="blocked"||t==="failed"||(e.waiting??0)>0)return"bp-dot-need";return"bp-dot-idle"}function ta(e){if(!e)return"";let t=e<10000000000?e*1000:e,n=Math.max(0,Math.floor((Date.now()-t)/1000));if(n<60)return"now";if(n<3600)return`${Math.floor(n/60)}m`;if(n<86400)return`${Math.floor(n/3600)}h`;return`${Math.floor(n/86400)}d`}function Mr(e,t){if(!e)return!0;if(t==="board"||t==="3d")return e.board!==!1;if(t==="schematic")return e.schematic!==!1;if(t==="mech")return e.mech!==!1;if(t==="gerbers")return e.gerbers!==!1;return!0}var en="dark",yn=(()=>{try{return Ws(localStorage.getItem("bp.theme.pref"))}catch{return"auto"}})(),vi=null,jt=(()=>{try{return _s(localStorage.getItem("bp.locale"))}catch{return"auto"}})();function Rr(){let e=qt(yn,en);document.documentElement.classList.toggle("light",e==="light");try{localStorage.setItem("bp.theme",e)}catch{}}function Tr(e){if(!e)return;en=e==="light"?"light":"dark",Rr()}function Ir(){if(jt!=="auto")St(jt);else if(vi)St(vi);else if(typeof navigator<"u"&&navigator.language){if(!St(navigator.language))St("en")}}function na(){return`web-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Br(){let e=document.getElementById("root");if(!e)return;try{if(localStorage.getItem("bp.theme")==="light")en="light";if(qt(yn,en)==="light")document.documentElement.classList.add("light");if(jt!=="auto")St(jt)}catch{}let t=document.createElement("header");t.className="bp-topbar",t.setAttribute("data-testid","topbar");let n=document.createElement("button");n.type="button",n.className="icon bp-side-toggle",n.textContent="☰",n.title="Toggle sidebar",n.setAttribute("aria-label","Toggle sidebar");let i=document.createElement("div");i.className="bp-brand";let s=document.createElement("img");s.src="/assets/favicon.svg",s.alt="Backplane",s.className="bp-logo";let r=document.createElement("span");r.className="bp-brand-name bp-hide-phone",r.textContent="Backplane";let o=document.createElement("span");o.className="bp-crumb-sep bp-hide-phone",o.textContent="/";let a=document.createElement("span");a.className="bp-crumb-proj bp-hide-phone";let c=document.createElement("span");c.className="bp-crumb-sep bp-hide-phone",c.textContent="/";let p=document.createElement("span");p.className="bp-crumb-thread",p.setAttribute("data-testid","thread-title");let l=document.createElement("span");l.className="bp-plan-top-badge bp-hidden",l.setAttribute("data-testid","plan-top-badge"),i.append(s,r,o,a,c,p,l);let h=document.createElement("div");h.className="bp-top-state bp-hide-phone bp-hidden";let d=document.createElement("span");d.className="bp-top-state-lbl",d.textContent="STATE";let u=document.createElement("span");u.className="bp-dot bp-dot-idle";let f=document.createElement("span");f.className="bp-top-state-word",h.append(d,u,f);let g=document.createElement("div");g.className="bp-top-acts bp-hide-phone bp-hidden";let v=document.createElement("button");v.type="button",v.className="bp-btn-ghost bp-top-act";let y=document.createElement("span");y.textContent=m("menu.pin","Pin"),v.append(Zt(["M12 17v5","M9 3h6l1 7 3 3H5l3-3 1-7z"]),y);let w=document.createElement("button");w.type="button",w.className="bp-btn-ghost bp-top-act";let k=document.createElement("span");k.textContent=m("menu.settle","Settle"),w.append(Zt(["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z","M9 12l2 2 4-4"]),k);let A=document.createElement("div");A.className="bp-menu-wrap";let N=document.createElement("button");N.type="button",N.className="bp-btn-ghost bp-top-act",N.textContent="▾",N.title="Thread menu",N.setAttribute("aria-label","Thread menu"),N.setAttribute("data-testid","thread-menu-btn");let L=document.createElement("div");L.className="bp-popover bp-hidden",L.setAttribute("data-testid","thread-menu"),A.append(N,L),g.append(v,w,A);let B=document.createElement("div");B.className="bp-top-right";let T=document.createElement("button");T.type="button",T.className="bp-btn-ghost bp-top-act bp-hide-tablet",T.setAttribute("data-testid","improvements-btn");let H=document.createElement("span");H.textContent=m("gpui.improvements","Improvements"),T.append(Zt(["M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 16.8l-6.2 4.5 2.4-7.4L2 9.4h7.6z"]),H);let F=document.createElement("button");F.type="button",F.className="bp-cmd-box bp-hide-tablet",F.textContent="> Jump or run a command";let P=document.createElement("button");P.type="button",P.className="icon bp-top-icon",P.title="Search",P.setAttribute("aria-label","Search"),P.appendChild(Zt(["M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16z","M21 21l-4.3-4.3"]));let K=document.createElement("button");K.type="button",K.className="icon bp-top-icon",K.title=m("palette.settings","Settings"),K.setAttribute("aria-label",m("palette.settings","Settings")),K.setAttribute("data-testid","settings-btn"),K.appendChild(Zt(["M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z","M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9c.26.6.85 1 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"])),B.append(T,F,P,K),t.append(n,i,h,g,B);let ae=document.createElement("div");ae.className="bp-body";let re=document.createElement("aside");re.className="bp-sidebar",re.setAttribute("data-testid","sidebar");let ve=document.createElement("main");ve.className="bp-center";let Ae=document.createElement("div");Ae.className="bp-right-area bp-hidden",Ae.setAttribute("data-testid","right-area");let ke=document.createElement("div");ke.className="bp-right-top";let ne=document.createElement("section");ne.className="bp-viewer-pane bp-hidden",ne.setAttribute("data-testid","viewer-pane"),ke.appendChild(ne),Ae.appendChild(ke);let le=document.createElement("nav");le.className="bp-rail",le.setAttribute("aria-label","Viewer rail"),le.setAttribute("data-testid","viewer-rail"),ae.append(re,ve,Ae,le),e.append(t,ae);let R=new ci,he=null,ce=new Set,te=0,we=null,E=[],x=[],D=[],I=[],J="",oe=[],Ee=[],Ce=[],O="",X=0,Me=0,Ve=null,q=null,me="",ie=null,Oe=20,Ge={},He=new Map;function Je(b,C){He.delete(b),He.set(b,C);while(He.size>Oe){let S=He.keys().next().value;if(S!==void 0)He.delete(S);else break}}let Te="",ze=0,et=new _n(ve,{onNewThread:(b)=>{ut(b)},onOpenThread:(b)=>{_e(b)},onOpenViewer:(b,C)=>{_e(b).then(()=>{if(O===b)vt(C)})},onRetry:(b)=>{kt(b)}});function ht(){if(!Te)return;Te="",ze++,ve.classList.remove("bp-home-open"),et.hide(),be.setSelectedProject(""),Ie()}function Ht(b){return E.find((C)=>C.id===b)??E.find((C)=>Wn(C.id)===b)}async function tn(b,C){try{let S=await R.rpc("threads.list",{project:b,limit:50,archived:!1});if(C!==ze||Te!==b)return;let M=(S.threads??[]).filter((j)=>!j.swarm).map((j)=>({id:j.id,title:j.title,dot:Nr(j),status:j.status||j.state||"",age:ta(j.updatedAt),settled:j.settled}));et.setThreads(M)}catch{if(C===ze&&Te===b)et.setThreads([])}}function kt(b){if(!b||!R.hasFeature("projecthome"))return!1;mt.cancel(),ue.closeModelPicker(),Te=b;let C=++ze,S=Ht(b);return ve.classList.add("bp-home-open"),re.classList.remove("bp-sidebar-open"),et.show({id:b,title:S?.title??b}),be.setSelectedProject(b),Ie(),tn(b,C),R.rpc("project.home",{project:b}).then((M)=>{if(C===ze&&Te===b)et.setData(Is(M))}).catch((M)=>{if(C!==ze||Te!==b)return;et.setError(M instanceof Error&&M.message?M.message:m("web.home.error","Could not load this project."))}),!0}let be=new oi(re,{onSelectThread:(b)=>{if(b===O&&Ve!==null){ht(),re.classList.remove("bp-sidebar-open");return}_e(b)},onNewThread:(b)=>{ut(b)},onOpenProject:(b)=>kt(Wn(b)),canOpenProject:()=>R.hasFeature("projecthome"),onSelectBot:(b)=>{_e(b.thread)},onQuickOpenViewer:(b,C)=>{let S=x.find((j)=>j.project===b&&!j.archived&&!j.swarm);(async()=>{if(S)await _e(S.id);else await ut(b);if(O)me=C,W.setActive(C),ie?.open(C,O)})()},onThreadAct:(b,C)=>{bt(b,C)},onSnoozeRow:(b)=>{R.rpc("sidebar.act",{action:"row-snooze",value:b}).then(()=>Xe()).catch(()=>{})},onToggleSection:(b)=>{if(ce.has(b))ce.delete(b);else ce.add(b);Xe()},onToggleProjectFold:(b)=>{R.rpc("sidebar.act",{action:"project-fold",value:b}).then(()=>Xe()).catch(()=>{})},onCollapseSidebar:()=>{re.classList.remove("bp-sidebar-open"),re.classList.add("bp-sidebar-collapsed")},onNeedAct:async(b)=>{let C=bn(b,!1);if(!C)return;if(C.kind==="thread"){_e(C.id);return}if(C.kind!=="call")return;let S=Us(await R.rpc(C.method,C.params));if(S?.kind==="thread")_e(S.id);Xe()},hasRoomView:!1,onAddProject:()=>V.open({mode:"folder"}),onSettleSwarm:(b)=>{R.rpc("sidebar.act",{action:"swarm-settle",value:b}).then(()=>Xe()).catch(()=>{})},onNewChat:()=>{ut(Ct)},onMoveToProject:(b)=>Ye(b),onDismissHomeMove:()=>{R.rpc("home.move.dismiss",{}).then((b)=>{if(b?.home!==void 0){if(se=b.home??null,be.setHome(se),pe.isOpen())pe.refresh()}}).catch(()=>{})}}),xe=new Nn(ve,{onLoadOlder:()=>{Ci()},onGoToEntry:(b)=>{Ei(b)},onOpenAccounts:()=>{Re()},onAnswerAsk:(b,C)=>{R.rpc("ask.answer",{ask:b,answer:C}).catch((S)=>{ue.showError(S instanceof Error?S.message:"Could not send answer")})},onToggleReview:(b)=>{if(!O)return;let C=X;R.rpc("thread.review",{thread:O,on:b}).then((S)=>{if(C===X)xe.setReview(S.review??null)}).catch(()=>{})},onUnansweredAction:(b,C)=>{if(!O)return;if(b==="again"||b==="thread-again")R.rpc("thread.again",{thread:O,value:C}).catch(()=>{});else R.rpc("thread.act",{thread:O,action:b,value:C}).catch(()=>{})},onReplyEntry:(b)=>{if(!R.hasFeature("reply")){let C=(b.text||"").split(` +`)[0]?.slice(0,100)??"";if(C)ue.prependDraft(`> ${C} +`);return}if(!b.text||!b.text.trim()||b.live||b.id.startsWith("local-"))return;Ft({id:b.id,text:b.text,role:b.kind==="user"?"user":"assistant"})},onLoadImage:async(b,C)=>{try{let S={entry:b,path:C};if(R.hasFeature("blobs"))S.metaOnly=!0;let M=await R.rpc("message.image",S);if(M.blob&&M.blob.startsWith("/blob/"))return{url:M.blob};if(M.mime&&M.data)return{mime:M.mime,data:M.data}}catch{}return null}});function ft(b){if(!b)return null;if(b.planMode)return b.planMode;if(b.provider==="claude")return{phase:"off",interaction:"default",once:!1};return null}function tt(b,C){if(!O)return;let S=X,M=O;R.rpc(b,C).then((j)=>{if(S!==X||O!==M)return;if(j.thread){let Z=x.findIndex((ge)=>ge.id===j.thread.id);if(Z>=0)x[Z]=j.thread;else x.unshift(j.thread);be.setData(E,x,D,I),xe.updateThreadMeta(j.thread),Ie(),ue.setState(!0,j.thread.state==="working")}}).catch((j)=>{if(S===X&&O===M)ue.showError(j instanceof Error?j.message:"Could not change Plan mode")})}let mt,ue=new In(ve,{onSend:(b,C)=>{xi(b,C)},onRunCommand:(b)=>{Pi(b)},onInterrupt:()=>{if(O)R.rpc("turn.interrupt",{thread:O}).catch(()=>{})},onQueryMentions:async(b,C)=>{try{return(await R.rpc("mentions.list",{q:b,kind:C,limit:10})).items??[]}catch{return[]}},onToggleVoice:()=>{mt.toggle()},onCyclePlanMode:()=>{let b=x.find((S)=>S.id===O)??null,C=ft(b);if(!C||!O)return;if(C.interaction!=="plan")tt("thread.planonce",{thread:O,on:!0});else if(C.once)tt("thread.pick",{thread:O,action:"interaction",value:"plan"});else tt("thread.pick",{thread:O,action:"interaction",value:"default"})},onSetPlanMode:(b)=>{if(!O)return;if(b==="once")tt("thread.planonce",{thread:O,on:!0});else if(b==="always")tt("thread.pick",{thread:O,action:"interaction",value:"plan"});else tt("thread.pick",{thread:O,action:"interaction",value:"default"})},getFavoriteModels:()=>oe,onLoadModelPicker:async()=>{if(!O)return null;return R.rpc("thread.picker",{thread:O})},onSelectModel:async(b,C)=>{if(!O)return;let S=X,M=O;try{let j=await R.rpc("thread.model",{thread:M,provider:b,model:C});if(S!==X||O!==M)return;if(j.thread){let Z=x.findIndex((ge)=>ge.id===j.thread.id);if(Z>=0)x[Z]=j.thread;else x.unshift(j.thread);be.setData(E,x,D,I),xe.updateThreadMeta(j.thread),Ie(),ue.setState(!0,j.thread.state==="working")}}catch(j){if(S===X&&O===M)ue.showError(j instanceof Error?j.message:"Could not switch model")}},onSelectEffort:async(b)=>{if(!O)return;let C=X,S=O;try{let M=await R.rpc("thread.pick",{thread:S,action:"effort",value:b});if(C!==X||O!==S)return;if(M.thread){let j=x.findIndex((Z)=>Z.id===M.thread.id);if(j>=0)x[j]=M.thread;else x.unshift(M.thread);be.setData(E,x,D,I),xe.updateThreadMeta(M.thread),Ie()}}catch(M){if(C===X&&O===S)ue.showError(M instanceof Error?M.message:"Could not set effort")}},onToggleFavorite:async(b,C,S)=>{let M=await R.rpc("models.favorite",{provider:b,model:C,on:S});if(Array.isArray(M.favorites))return oe=M.favorites,oe;return null}});mt=new ai(R,{getThreadId:()=>O,getDraft:()=>ue.getDraft(),getCaret:()=>ue.getCaret(),setDraft:(b)=>ue.setDraft(b),setRecording:(b)=>ue.setVoiceRecording(b),setLevel:(b)=>ue.setVoiceLevel(b),showError:(b)=>ue.showError(b)});function Dt(){let b=me!=="",C=ot.isOpen();Ae.classList.toggle("bp-hidden",!b&&!C),Ae.classList.toggle("bp-has-viewer",b),Ae.classList.toggle("bp-has-mgmt",C)}let ot=new On(ke,Ae,{hub:R,getThreadId:()=>O,getThreadGen:()=>X,onSendText:(b)=>{xi(b)},onOpenChange:()=>Dt()});function G(b){let C=window.prompt("Rename thread",b.title||"");if(!C||!C.trim())return;R.rpc("thread.act",{thread:b.id,action:"rename",title:C.trim()}).then((S)=>{if(S.thread)x=x.map((M)=>M.id===S.thread.id?S.thread:M),Ie(),Xe()}).catch((S)=>{ue.showError(S instanceof Error?S.message:"Could not rename thread")})}function z(b){switch(b.type){case"thread":_e(b.id);break;case"rail":if(!O&&b.id!=="terminal")break;if(me===b.id)at();else vt(b.id);break;case"thread-act":if(O)bt(O,b.action);break;case"new-thread":ut(b.projectId);break;case"new-chat":ut(Ct);break;case"move-project":if(O)Ye(O);break;case"rename":{let C=x.find((S)=>S.id===O);if(C)G(C);break}case"prev-thread":case"next-thread":{let C=x.filter((Z)=>!Z.archived&&!Z.swarm);if(C.length<2)break;let S=C.findIndex((Z)=>Z.id===O),M=b.type==="next-thread"?1:-1,j=C[(S<0?0:S+M+C.length)%C.length];if(j)_e(j.id);break}case"command":if(b.runDirectly)Pi(b.word);else ue.setDraft(`${b.word} `),ue.focus();break;case"improvements":$e();break;case"settings":pe.open();break;case"sidebar":re.classList.toggle("bp-sidebar-open"),re.classList.toggle("bp-sidebar-collapsed");break}}let _=new Gn(e,{getState:()=>({selectedThreadId:O,threads:x,projects:E,bots:D,railItems:Ee,commands:Ce}),onSearch:async(b)=>{if(!R.hasFeature("search"))return{threads:[],projects:[],messages:[]};return R.rpc("search",{q:b,limit:20})},onExecute:z}),V=new Sn(e,{hub:R,onProjectAdded:(b)=>{if(Xe(),b.id)ut(b.id)},onCloneDone:(b)=>{if(Xe(),b.thread)_e(b.thread)}}),W=new Kn(le,(b)=>{if(b==="commands"){_.open();return}if(!O)return;if(me===b)at();else vt(b)}),se=null,Q=null,pe=new ei(e,{onLoadDevices:async()=>(await R.rpc("devices.page",{})).rows??[],onDevicesAct:async(b,C)=>{await R.rpc("devices.page.act",{action:b,value:C})},onGetHome:()=>se,onMoveHomeHere:async()=>{await R.rpc("home.move",{to:"back"})},onGetNoProvider:()=>Q,onGetThemePref:()=>yn,onSetThemePref:(b)=>{yn=b;try{if(b==="auto")localStorage.removeItem("bp.theme.pref");else localStorage.setItem("bp.theme.pref",b)}catch{}Rr()},onGetHubTheme:()=>en,onGetLocalePref:()=>jt,onSetLocalePref:(b)=>{jt=b;try{if(b==="auto")localStorage.removeItem("bp.locale");else localStorage.setItem("bp.locale",b)}catch{}Ir()},hasRing:()=>R.hasFeature("ringnotes"),onRingList:async(b)=>Hs(await R.rpc("ring.list",{q:b})),onRingHear:async(b,C)=>{await R.rpc("ring.hear",{note:b,engine:C})},onOpenThread:(b)=>{_e(b)},onLogout:()=>Ki(()=>{try{ri(window.localStorage)}catch{}R.disconnect(),window.location.replace("/")})});function Pe(b){if(Q=b,xe.setNoProvider(b),pe.isOpen())pe.refresh()}function Re(){pe.openToAccounts()}function De(b,C){let S=b instanceof Error?b.message:C,M=b instanceof Xt?b:null,j=M?.code,Z=M?.machine,ge=j==="no_provider_remote"&&Z?m("provider.notice.senderr.remote","No AI provider connected on {machine}. Open Settings → Accounts on {machine} to connect Claude, Codex, Antigravity, or another provider.").replaceAll("{machine}",Z):S;ue.showError(ge,js(S,j)?{label:m("provider.notice.button","Open Settings → Accounts"),onClick:Re}:void 0)}v.addEventListener("click",()=>{let b=x.find((C)=>C.id===O);if(b)bt(b.id,b.pinned?"unpin":"pin")}),w.addEventListener("click",()=>{let b=x.find((C)=>C.id===O);if(b)bt(b.id,b.settled?"unsettle":"settle")});let Fe=new ni(e,(b,C)=>C?R.rpc("thread.context.mcp",{thread:b,...C}):R.rpc("thread.context",{thread:b}));N.addEventListener("click",(b)=>{b.stopPropagation();let C=x.find((j)=>j.id===O);if(!C)return;if(!L.classList.contains("bp-hidden")){L.classList.add("bp-hidden");return}let S=[{label:"Rename…",run:()=>G(C)},{label:C.pinned?m("menu.unpin","Unpin"):m("menu.pin","Pin"),run:()=>{bt(C.id,C.pinned?"unpin":"pin")}},{label:C.settled?m("phone.unsettle","Unsettle"):m("menu.settle","Settle"),run:()=>{bt(C.id,C.settled?"unsettle":"settle")}},{label:C.archived?"Unarchive":"Archive",run:()=>{bt(C.id,C.archived?"unarchive":"archive")}},{label:"Delete",danger:!0,run:()=>{if(window.confirm("Delete this thread?"))bt(C.id,"delete")}}];if(R.hasFeature("threadContext"))S.unshift({label:m("thread.context.title","Context & Prompt"),run:()=>Fe.open(C.id)});let M=document.createDocumentFragment();for(let j of S){let Z=document.createElement("button");Z.type="button",Z.className="bp-popover-item"+(j.danger?" danger":""),Z.textContent=j.label,Z.addEventListener("click",()=>{L.classList.add("bp-hidden"),j.run()}),M.appendChild(Z)}L.replaceChildren(M),L.classList.remove("bp-hidden")}),document.addEventListener("click",()=>L.classList.add("bp-hidden"));async function $e(){let b=document.createElement("div");b.className="bp-modal-backdrop",b.setAttribute("data-testid","improvements-modal");let C=document.createElement("div");C.className="bp-modal";let S=document.createElement("div");S.className="bp-modal-head";let M=document.createElement("h2");M.textContent=m("gpui.improvements","Improvements");let j=document.createElement("button");j.type="button",j.className="icon",j.textContent="×",j.addEventListener("click",()=>b.remove()),S.append(M,j);let Z=document.createElement("div");Z.className="bp-modal-body",Z.textContent="Loading…",C.append(S,Z),b.appendChild(C),b.addEventListener("click",(ge)=>{if(ge.target===b)b.remove()}),e.appendChild(b);try{let ge=await R.rpc("improvements.projects",{}),de=ge.projects??[];if(de.length===0){Z.textContent="No projects available for Improvements.";return}let Le=document.createDocumentFragment();for(let Ke of de){let Be=document.createElement("div");Be.className="bp-set-row";let ee=document.createElement("div");ee.className="bp-set-info",ee.textContent=Ke.title||Ke.name||Ke.id;let Ue=document.createElement("button");Ue.type="button",Ue.className=Ke.id===ge.project?"primary":"",Ue.textContent=Ke.id===ge.project?"Active":"Select",Ue.addEventListener("click",()=>{R.rpc("improvements.project",{project:Ke.id}).then(()=>b.remove()).catch(()=>{})}),Be.append(ee,Ue),Le.appendChild(Be)}Z.replaceChildren(Le)}catch(ge){Z.textContent=ge instanceof Error?ge.message:"Could not load Improvements."}}function Ye(b){let C=x.find((ee)=>ee.id===b),S=document.createElement("div");S.className="bp-modal-backdrop",S.setAttribute("data-testid","move-project-modal");let M=document.createElement("div");M.className="bp-modal";let j=document.createElement("div");j.className="bp-modal-head";let Z=document.createElement("h2");Z.textContent=m("chats.move","Move to project…");let ge=document.createElement("button");ge.type="button",ge.className="icon",ge.textContent="×",ge.addEventListener("click",()=>S.remove()),j.append(Z,ge);let de=document.createElement("div");de.className="bp-modal-body";let Le=document.createElement("div");Le.className="bp-move-note",Le.textContent=C?.title||"";let Ke=document.createElement("div");Ke.className="bp-move-err",de.append(Le);let Be=er(E);if(Be.length===0){let ee=document.createElement("div");ee.textContent=m("chats.move.none","No project to move it to. Add a project first."),de.appendChild(ee)}for(let ee of Be){let Ue=document.createElement("button");Ue.type="button",Ue.className="bp-move-row",Ue.textContent=ee.title||ee.id,Ue.setAttribute("data-testid",`move-project-${ee.id}`),Ue.addEventListener("click",()=>{R.rpc("thread.move_project",{thread:b,project:ee.id}).then((lt)=>{if(lt.thread)x=x.map((ct)=>ct.id===lt.thread.id?lt.thread:ct);else x=x.map((ct)=>ct.id===b?{...ct,project:ee.id}:ct);be.setData(E,x,D,I),Ie(),Xe(),S.remove()}).catch((lt)=>{Ke.textContent=lt instanceof Error?lt.message:"Could not move the chat"})}),de.appendChild(Ue)}de.appendChild(Ke),M.append(j,de),S.appendChild(M),S.addEventListener("click",(ee)=>{if(ee.target===S)S.remove()}),e.appendChild(S)}T.addEventListener("click",()=>{$e()}),F.addEventListener("click",()=>_.open()),P.addEventListener("click",()=>_.open()),K.addEventListener("click",()=>{pe.open()}),n.addEventListener("click",()=>{re.classList.toggle("bp-sidebar-open"),re.classList.toggle("bp-sidebar-collapsed")});function Ie(){let b=Te?null:x.find((j)=>j.id===O)??null,C=Te?Ht(Te)??{id:Te,title:Te}:b?Ht(b.project):void 0;if(Te&&C)et.setTitle(C.title);let S=!Te&&b?.project===Ct;a.textContent=S?m("chats.title","Chats"):C?.title??"",o.classList.toggle("bp-hidden",!C&&!S),c.classList.toggle("bp-hidden",!b),p.textContent=b?b.title||"Untitled thread":"";let M=ft(b);if(ue.setPlanMode(M),!M||M.phase==="off")l.classList.add("bp-hidden"),l.classList.remove("is-exec"),l.textContent="";else l.classList.remove("bp-hidden"),l.classList.toggle("is-exec",M.phase==="executing"),l.title=m("gpui.planmode.tip","Plan before acting (1 turn, always, or off)"),l.textContent=M.phase==="armed"&&M.once?m("gpui.planmode.top.once","Plan (1 turn)"):M.phase==="armed"?m("gpui.mgmt.plan.tab","Plan"):M.phase==="planning"?m("gpui.planmode.top.planning","Planning"):M.phase==="pending"?m("gpui.planmode.top.pending","Review plan"):m("gpui.planmode.top.executing","Building plan");if(h.classList.toggle("bp-hidden",!b),g.classList.toggle("bp-hidden",!b),b){u.className=`bp-dot ${Nr(b)}`,f.textContent=b.status||b.state||"idle",y.textContent=b.pinned?m("menu.unpin","Unpin"):m("menu.pin","Pin"),k.textContent=b.settled?m("phone.unsettle","Unsettle"):m("menu.settle","Settle");let j=b;ue.setModelChip(b.chip||b.model||"default",b.provider,j.ctxPct??j.contextPct),ue.setMemory(b.memory)}else ue.setModelChip("default"),ue.setMemory(null)}function at(b=!0){if(Me++,me="",W.setActive(""),ne.classList.add("bp-hidden"),ie?.close(),Dt(),b&&O&&R.getState()==="connected")R.rpc("viewer.watch",{thread:O,kind:""}).catch(()=>{})}function vt(b){if(Me++,me=b,W.setActive(b),ne.classList.remove("bp-hidden"),Dt(),!ie&&typeof fi==="function")ie=fi(ne,{hub:R,getThreadId:()=>O,closeViewer:()=>at(!0)});if(ie)ie.open(b,O);else{let C=document.createElement("div");C.className="bp-viewer-placeholder";let S=document.createElement("div");S.className="bp-viewer-bar";let M=document.createElement("span");M.textContent=b.toUpperCase();let j=document.createElement("button");j.type="button",j.className="icon",j.textContent="×",j.addEventListener("click",()=>at(!0)),S.append(M,j);let Z=document.createElement("div");Z.className="bp-dim bp-viewer-msg",Z.textContent=`Viewer pane (${b}).`,C.append(S,Z),ne.replaceChildren(C)}}async function nt(b,C){if(!b||!R.hasFeature("rail")){if(C===X)Ee=[],W.setItems([]);return}let S=++Me;try{let M=await R.rpc("viewer.rail",{thread:b,page:me});if(C!==X||S!==Me)return;let j=Array.isArray(M.rail)?M.rail:Array.isArray(M.items)?M.items:[];if(Ee=j,W.setItems(j),M.has){if(ie?.reconcileHas?.(M.has),me&&!Mr(M.has,me))at(!0)}}catch{if(C===X&&S===Me)Ee=[],W.setItems([])}}function jr(b){for(let C of b)if(C.kind==="threads"){for(let S of C.rows)if(!S.off&&(S.nav||S.id)&&!(S.nav||"").startsWith("@room:"))return S.nav||S.id}else if(C.kind==="projects"){for(let S of C.rows)for(let M of S.threads??[])if(!M.off&&(M.nav||M.id)&&!(M.nav||"").startsWith("@room:"))return M.nav||M.id}return""}function yi(b,C){for(let S of b)if(S.kind==="threads"){if(S.rows.some((M)=>(M.nav||M.id)===C))return!0}else if(S.kind==="projects"){for(let M of S.rows)if((M.threads??[]).some((j)=>(j.nav||j.id)===C))return!0}return!1}function nn(){try{Zs(window.localStorage,{hostName:J||void 0,sections:he,projects:E,threads:x,bots:D,rooms:I,shellHashes:Ge,openSectionFolds:Array.from(ce)})}catch{}}function wn(b){let C=[];for(let S of b){if(S.kind!=="projects")continue;for(let M of S.rows)C.push({id:M.id,title:M.title,css:M.css,color:M.color})}if(C.length>0)E=C}async function Xe(){if(!R.hasFeature("sections"))return!1;let b=++te;try{let C=await R.rpc("sidebar.sections",{open:Array.from(ce)});if(b!==te)return!0;let S=Array.isArray(C.sections)?C.sections:[];if(he=S,wn(S),be.setData(E,x,D,I),be.setSections(S,D,I),nn(),Ie(),Te)tn(Te,ze);return!0}catch{return!1}}function sn(){if(!R.hasFeature("sections"))return;if(we!==null)window.clearTimeout(we);we=window.setTimeout(()=>{we=null,Xe()},150)}async function Hr(){Ve=null;let b=R.hasFeature("bots")?R.rpc("bots.list",{}).catch(()=>null):Promise.resolve(null);if(R.hasFeature("shell")){let S={};for(let[de,Le]of Object.entries(Ge)){if(de==="@sections"&&(!he||he.length===0)||de.startsWith("p:")&&E.length===0)continue;S[de]=Le}let[M,j]=await Promise.all([b,R.rpc("shell.sync",{have:S,settled:25,open:Array.from(ce)})]);if(M)D=M.bots??[],I=M.rooms??[];let Z=new Set(j.removed??[]),ge=new Set((j.projects??[]).map((de)=>de.id));if(Z.size>0||ge.size>0)E=[...E.filter((de)=>!Z.has(de.id)&&!ge.has(de.id)),...j.projects??[]],x=[...x.filter((de)=>!Z.has(de.project)&&!ge.has(de.project)),...j.threads??[]];else if(Array.isArray(j.threads)&&j.threads.length>0){let de=new Map(x.map((Le)=>[Le.id,Le]));for(let Le of j.threads)de.set(Le.id,Le);x=Array.from(de.values())}if(j.sections!==void 0){let de=Array.isArray(j.sections)?j.sections:Array.isArray(j.sections?.sections)?j.sections.sections:null;if(de)he=de,wn(de)}if(j.h)Ge=j.h;be.setData(E,x,D,I),be.setSections(he,D,I),nn()}else if(R.hasFeature("sections")){let[S,M,j]=await Promise.all([b,R.rpc("sidebar.sections",{open:Array.from(ce)}).catch(()=>null),R.rpc("threads.list",{limit:200,archived:!1}).catch(()=>({threads:[]}))]);if(S)D=S.bots??[],I=S.rooms??[];if(x=j.threads??[],M&&Array.isArray(M.sections)){let Z=M.sections;if(!Z.some((de)=>de.kind==="projects"&&de.rows.length>0)){let de=Z.find((Le)=>Le.kind==="projects"&&Le.fold&&Le.toggle&&(Le.count??0)>0);if(de?.toggle&&!ce.has(de.toggle)){ce.add(de.toggle);let Le=await R.rpc("sidebar.sections",{open:Array.from(ce)}).catch(()=>null);if(Le&&Array.isArray(Le.sections))Z=Le.sections}}he=Z,wn(Z),be.setData(E,x,D,I),be.setSections(Z,D,I)}else he=null,E=(await R.rpc("projects.list",{limit:100})).projects??[],be.setSections(null,D,I),be.setData(E,x,D,I);nn(),await R.rpc("subscribe",{topic:"lists"}).catch(()=>{})}else{he=null;let[S,M,j]=await Promise.all([b,R.rpc("projects.list",{limit:100}),R.rpc("threads.list",{limit:200,archived:!1})]);if(S)D=S.bots??[],I=S.rooms??[];E=M.projects??[],x=j.threads??[],be.setSections(null,D,I),be.setData(E,x,D,I),nn(),await R.rpc("subscribe",{topic:"lists"}).catch(()=>{})}let C=O;if(!C){let S="";try{S=localStorage.getItem("bp.lastThread")||""}catch{}if(S&&(he&&yi(he,S)||x.some((M)=>M.id===S)))C=S;else if(he)C=jr(he);if(!C)C=(x.find((j)=>!j.archived&&!j.swarm&&!j.settled)??x.find((j)=>!j.archived&&!j.swarm))?.id??""}if(C&&(he&&yi(he,C)||x.some((S)=>S.id===C)))await _e(C,Te!=="");else O="",Ee=[],W.setItems([]),ue.setState(!1,!1),Ie();if(Te)kt(Te)}async function _e(b,C=!1){if(!C)ht();if(O&&O!==b){mt.cancel();let Be=xe.getEntries();if(Be.length>0){let ee=He.get(O);Je(O,{entries:Be,ids:ee?.ids??Be.map((Ue)=>Ue.id),olderCursor:q,review:ee?.review??null,unanswered:ee?.unanswered??null,rail:ee?.rail??Ee,hashes:ee?.hashes??{}})}}let S=++X;Me++,Ft(null);let M=Ve;if(Ve=null,M!==null)R.rpc("unsubscribe",{sub:M}).catch(()=>{});O=b,ue.closeModelPicker();let j=He.get(b);q=j?.olderCursor??null;try{localStorage.setItem("bp.lastThread",b)}catch{}be.setSelected(b),re.classList.remove("bp-sidebar-open"),Ie();let Z=x.find((Be)=>Be.id===b)??null;if(j)xe.setThread(Z,j.entries,Boolean(j.olderCursor),j.review,j.unanswered),Ee=j.rail,W.setItems(j.rail);else xe.setLoading(Z),Ee=[],W.setItems([]);if(ue.setState(!0,Z?.state==="working"),R.hasFeature("open")){let Be={};if(j){for(let[je,Ot]of Object.entries(j.hashes))Be[je]=Ot;for(let je of j.entries)if(je.h)Be[je.id]=je.h}let ee;try{ee=await R.rpc("thread.open",{thread:b,limit:40,have:Be})}catch(je){if(S===X){let Ot=je instanceof Error&&je.message?je.message:"Could not load messages.";xe.setError(Z,Ot,()=>{_e(b)})}return}if(S!==X){if(ee.sub!==void 0&&ee.sub!==null)R.rpc("unsubscribe",{sub:ee.sub}).catch(()=>{});return}if(Ve=ee.sub??null,ee.thread){Z=ee.thread;let je=x.findIndex((Ot)=>Ot.id===ee.thread.id);if(je>=0)x[je]=ee.thread;else x.unshift(ee.thread);Ie(),ue.setState(!0,Z.state==="working")}if("next"in ee)q=ee.next??null;let Ue=new Map;if(j)for(let je of j.entries)Ue.set(je.id,je);for(let je of ee.entries??[])Ue.set(je.id,je);let lt=ee.ids??j?.ids??(ee.entries??[]).map((je)=>je.id),ct=lt.map((je)=>Ue.get(je)).filter((je)=>Boolean(je)),$t=j?.rail??[];if(ee.rail!==void 0){if(Array.isArray(ee.rail))$t=ee.rail;else if($t=Array.isArray(ee.rail?.rail)?ee.rail.rail:Array.isArray(ee.rail?.items)?ee.rail.items:[],ee.rail?.has){if(ie?.reconcileHas?.(ee.rail.has),me&&!Mr(ee.rail.has,me))at(!0)}}Ee=$t,W.setItems($t);let En=j?.review??null;if(R.hasFeature("reviewmode"))try{let je=await R.rpc("thread.review",{thread:b});if(S!==X)return;En=je.review??null}catch{}if(S!==X)return;let Ai="unanswered"in ee?ee.unanswered??null:j?.unanswered??null,Dr=ee.h??j?.hashes??{};if(Je(b,{entries:ct,ids:lt,olderCursor:q,review:En,unanswered:Ai,rail:$t,hashes:Dr}),xe.setThread(Z,ct,Boolean(q),En,Ai),wi(b,S),me)vt(me);return}let ge;try{ge=await R.rpc("thread.entries",{thread:b,limit:40})}catch(Be){if(S===X){let ee=Be instanceof Error&&Be.message?Be.message:"Could not load messages.";xe.setError(Z,ee,()=>{_e(b)})}return}if(S!==X)return;if(ge.thread){let Be=x.findIndex((ee)=>ee.id===ge.thread.id);if(Be>=0)x[Be]=ge.thread;else x.unshift(ge.thread);Ie()}q=ge.next??null;let de=null;if(R.hasFeature("reviewmode"))try{let Be=await R.rpc("thread.review",{thread:b});if(S!==X)return;de=Be.review??null}catch{}if(S!==X)return;let Le=ge.entries??[],Ke=ge.unanswered??null;Je(b,{entries:Le,ids:Le.map((Be)=>Be.id),olderCursor:q,review:de,unanswered:Ke,rail:j?.rail??[],hashes:j?.hashes??{}}),xe.setThread(Z,Le,Boolean(q),de,Ke);try{let ee=(await R.rpc("subscribe",{topic:"thread",thread:b})).sub??null;if(ee!==null){if(S!==X){R.rpc("unsubscribe",{sub:ee}).catch(()=>{});return}Ve=ee}}catch{}if(S!==X)return;if(nt(b,S),wi(b,S),me)vt(me)}async function wi(b,C){if(!b||!R.hasFeature("mgmt")){if(C===X)ot.clear();return}let S=x.find((j)=>j.id===b),M=S?.project?E.find((j)=>j.id===S.project)?.root??"":"";if(!M&&R.hasFeature("viewers"))try{let j=await R.rpc("viewer.files",{thread:b});if(C!==X)return;M=j.pcb||j.sch||j.root||""}catch{}if(C!==X)return;if(M)await ot.watchProject(M);else ot.clear()}async function Ei(b){let C=X;for(let S=0;S<25&&C===X;S++){if(xe.goTo(b))return;if(!q)return;let M=q;if(await Ci(),q===M)return}}async function Ci(){if(!O||!q){xe.clearLoadingOlder();return}let b=X,C=O,S=q;try{let M=await R.rpc("thread.entries",{thread:C,limit:40,before:S});if(b!==X||O!==C)return;q=M.next??null,xe.prependEntries(M.entries??[],Boolean(q))}catch{if(b===X)xe.clearLoadingOlder()}}async function ut(b){try{let C=await R.rpc("thread.create",{project:b});if(C.thread)x=[C.thread,...x.filter((S)=>S.id!==C.thread.id)],be.setData(E,x,D,I),Xe(),await _e(C.thread.id),ue.focus()}catch(C){De(C,"Could not create thread")}}let xt=null;function ki(b){return(b.split(` +`).map((C)=>C.trim()).find((C)=>C.length>0)??"").slice(0,200)}function Ft(b){xt=b,ue.setReply(b?{who:b.role==="user"?m("secret.you","You"):m("model.col.agent","Agent"),line:ki(b.text)}:null,()=>{if(xt)Ei(xt.id)},()=>Ft(null))}async function xi(b,C=[]){if(!O)return;let S=X,M=O,j=na(),Z=`local-${j}`,ge=xt&&b.trim()&&R.hasFeature("reply")?xt:null;if(ge)Ft(null);xe.upsertEntry({id:Z,kind:"user",text:b,at:Date.now(),clientId:j,...ge?{replyTo:{id:ge.id,quote:ki(ge.text)}}:{},attachments:C.map((de)=>({name:de.name,mime:de.mime,previewUrl:`data:${de.mime};base64,${de.data}`}))});try{let de={thread:M,text:b,clientId:j};if(C.length>0)de.attachments=C;if(ge)de.replyTo={id:ge.id,text:ge.text};let Le=await R.rpc("message.send",de);if(S!==X||O!==M)return;if(Le.entry)xe.upsertEntry(Le.entry)}catch(de){if(S===X&&O===M){if(xe.removeEntry(Z),ue.setDraft(b),ge&&!xt)Ft(ge);De(de,"Failed to send message")}}}async function Pi(b){if(!O)return;let C=X,S=O;try{let M=await R.rpc("composer.run",{thread:S,text:b});if(C!==X||O!==S)return;if(M.error)ue.setDraft(b),De(new Xt(M.error,{code:M.errorCode,machine:M.machine}),M.error);else if(M.kind==="btw"&&typeof M.a==="string")xe.showBtw(M.q??"",M.a);else if(M.kind==="edit"&&typeof M.text==="string")ue.setDraft(M.text);else if(M.kind==="project")V.open({mode:"folder"});else if(M.kind==="clone")V.open({mode:"clone",repo:M.repo??"",text:M.text??""})}catch(M){if(C===X&&O===S)ue.setDraft(b),De(M,"Command refused")}}async function bt(b,C){try{let S=await R.rpc("thread.act",{thread:b,action:C});if(S.thread){if(x=x.map((M)=>M.id===S.thread.id?S.thread:M),be.setData(E,x,D,I),S.thread.id===O)xe.updateThreadMeta(S.thread),Ie()}Xe()}catch(S){ue.showError(S instanceof Error?S.message:`Action "${C}" not allowed`)}}function Si(b,C){if(!b||!b.text||C-b.at>=300000)return"";let S=b.build.split("-").pop()??"";if(b.reason==="build"&&S)return m("hub.restarting.build",b.text,{build:S});if(b.reason==="stop")return m("hub.stopped",b.text);return m("hub.restarting",b.text)}function rn(b){if(b==="connected")be.setConnStatus(m("gpui.acct.connected","Connected"),"bp-ok");else if(b==="reconnecting"&&Si(R.restarting,Date.now()))be.setConnStatus(Si(R.restarting,Date.now()),"");else if(b==="reconnecting")be.setConnStatus("Reconnecting…","bp-warn");else if(b==="revoked")be.setConnStatus(m("gpui.acct.sign.in.expired","Sign-in expired"),"bp-bad");else be.setConnStatus("Connecting…","")}on(()=>{rn(R.getState()),H.textContent=m("gpui.improvements","Improvements"),K.title=m("palette.settings","Settings"),K.setAttribute("aria-label",m("palette.settings","Settings")),Ie(),be.refreshLocale(),xe.refreshLocale(),ue.refreshLocale(),W.render(),pe.refreshLocale(),et.refreshLocale(),V.refreshLocale()}),R.onState((b,C)=>{if(b==="connected"&&C){if(C.locale)vi=C.locale,Ir();if(C.theme)Tr(C.theme);if(C.name)J=C.name,be.setHostName(C.name);if(Array.isArray(C.favoriteModels))oe=C.favoriteModels,ue.updateFavoriteModels(oe);if(se=C.home??null,be.setHome(se),Pe(zn(C.noProvider)),pe.isOpen())pe.refresh();rn(b);let S=typeof C.hubBack==="string"?String(C.hubBack):"";if(S)try{let M=JSON.parse(S);if(M.reason==="crash")be.setConnStatus(m("hub.back.crash",M.text??""),"bp-warn"),window.setTimeout(()=>rn(R.getState()),6000)}catch{}if(ue.setFeatures(R.hasFeature("images"),R.hasFeature("voice")),Array.isArray(C.commands))Ce=C.commands,ue.setCommands(Ce);else Ce=[];Hr(),V.reconcile()}else{if(b==="revoked")try{ri(window.localStorage)}catch{}mt.cancel(),rn(b)}}),R.onFrame((b)=>{if(b.t==="voice"){mt.handleFrame(b);return}if(b.t==="info"&&b.info&&typeof b.info==="object"){let S=b.info;if(Object.prototype.hasOwnProperty.call(S,"provider.notice"))Pe(zn(S["provider.notice"]));ot.handleInfo(S);return}if(b.t!=="d")return;let C=b;if(C.k==="clone"||C.k==="clone.repos"||C.k==="clone.signin"){V.handleFrame(C);return}switch(C.k){case"project":{let S=C.project;if(!S)break;let M=E.findIndex((j)=>j.id===S.id);if(M>=0)E[M]=S;else E.unshift(S);be.setData(E,x,D,I),Ie(),sn();break}case"thread":{let S=C.thread;if(!S)break;let M=x.findIndex((j)=>j.id===S.id);if(M>=0)x[M]=S;else x.unshift(S);if(be.setData(E,x,D,I),S.id===O)xe.updateThreadMeta(S),Ie(),ue.setState(!0,S.state==="working");sn();break}case"thread.removed":{let S=String(C.id??"");x=x.filter((M)=>M.id!==S),be.setData(E,x,D,I),sn();break}case"entry":{if(C.thread===O&&C.entry)xe.upsertEntry(C.entry);break}case"text":{if(C.thread===O)xe.appendLiveText(String(C.entry??""),String(C.append??""),Number(C.at??Date.now()));break}case"turn":{if(C.thread===O){let S=String(C.state??"idle");ue.setState(!0,S==="working"),nt(O,X)}sn();break}case"btw":{if(C.thread===O)xe.showBtw(String(C.q??""),String(C.a??""));break}case"unanswered":{if(C.thread===O)xe.setUnanswered(C.unanswered??null);break}case"theme":{if(typeof C.theme==="string")Tr(C.theme);break}case"home":{if(se=C.home??null,be.setHome(se),pe.isOpen())pe.refresh();break}case"favorites":{if(Array.isArray(C.favorites))oe=C.favorites.filter((S)=>typeof S==="string"),ue.updateFavoriteModels(oe);break}default:break}}),window.addEventListener("keydown",(b)=>{let C=b.key.toLowerCase();if((b.ctrlKey||b.metaKey)&&(C==="k"||b.shiftKey&&C==="p"))if(b.preventDefault(),_.isOpen())_.close();else _.open();else if(b.shiftKey&&b.code==="KeyN"&&(b.altKey||b.ctrlKey||b.metaKey))b.preventDefault(),ut(Ct);else if(b.key==="Escape"){let S=document.querySelector('[data-testid="move-project-modal"]');if(S){S.remove();return}if(_.isOpen())_.close();else if(ue.isModelPickerOpen())ue.closeModelPicker();else if(V.isOpen())V.escape();else if(pe.isOpen())pe.handleEscape();else if(xe.closePlanRevise());else if(ot.isOpen())ot.closePanel()}});try{let b=Qs(window.localStorage);if(b){if(b.hostName)J=b.hostName,be.setHostName(b.hostName);E=b.projects,x=b.threads,D=b.bots,I=b.rooms,he=b.sections,Ge=b.shellHashes;for(let C of b.openSectionFolds)ce.add(C);be.setData(E,x,D,I),be.setSections(he,D,I)}}catch{}R.connect()}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",Br);else Br(); diff --git a/web/dist/manifest.json b/web/dist/manifest.json index 20a620ccbe..b5fd75b77d 100644 --- a/web/dist/manifest.json +++ b/web/dist/manifest.json @@ -1,6 +1,6 @@ { "version": 1, - "totalAssetGzipBytes": 237496, + "totalAssetGzipBytes": 238104, "styleTokensSha256": "a4fed1b1c7bc676acc328907343eb5dcf87e426383d05617c632e48c0c3f2b80", "i18nKeys": [ "agy.signout", @@ -347,7 +347,7 @@ "i18nSubsetSha256": "ad3083cc73511c7876092934bbfa1a26823b509f16985a9cf924cf2136eff864", "inputs": { "web/src/addproject.ts": "06a7ff3e13cd78d993ebca7f638d5d623da06c0099186ad534bae8f184dbe44f", - "web/src/app.ts": "bdcd9cb1bc3517282752c8b6757802e5c1a43077e675a32cff83b2d6c777a38d", + "web/src/app.ts": "49513e5b9724a687e09e6a63da28789882cd7c6a729f7b0f3069b7f12c7e1b6c", "web/src/chat.ts": "639e3af0791aedcde788c1a76aee6ea07cf96f5749d6a3564898c2beb8bd7337", "web/src/clone-model.ts": "d265df49436e14f415bbeb2a271ffa3552f9163be62bdc0158cecc10c3cdae45", "web/src/composer.ts": "63a5e9d7acfd321007c0a18880ee0ba055506335fcf4808154febc2b380f91a8", @@ -374,7 +374,7 @@ "web/src/settings-model.ts": "2f8f64cc93ee54c1bf45d918d8568eec2457970db7b3c43e926b2b4c45dcd5f6", "web/src/settings.ts": "8d4c24f554ba9c7ba4c4a96098fe25eea68b91f41489aee4d2b01b616f41f507", "web/src/shell.css": "15c189efe5a2ed0b2e85bee37b3439ec9f2a60f462fbc5e8665721580ccd1e60", - "web/src/sidebar.ts": "857243b9136fcae26a7d30e2e7d406eb3fc25c2c081238ad5175636f72c5412d", + "web/src/sidebar.ts": "11a7f47186af373ed289bb46939308f5ef7ee041806016f1b30082ed0a6fa6b1", "web/src/swarm-need.ts": "503bbf5ffe0389f068847571c792321b0ad5c8d26a18c73b8e41c0a8989e227f", "web/src/thread-context.ts": "b9fbd5b3ef0b1357b5a4444a1e9a0ac0606afe1c8a5377c4777752e918af0ac2", "web/src/user-refs.ts": "56bcf0dc116d5f14260606f07cf9af9becbbd7cbb102dc9e0687a4ea5f894011", @@ -411,9 +411,9 @@ }, "outputs": { "assets/app.js": { - "bytes": 440245, - "gzipBytes": 123764, - "sha256": "f82de1e9fd0ebc95f4cc4fef3c97b3f476b4e451d2bd235167042d52a30c0590" + "bytes": 442032, + "gzipBytes": 124372, + "sha256": "7ace8de321ab67d4beb7b5416db401f553313ac0d16aabca497f92c79f837557" }, "assets/favicon-light.svg": { "bytes": 1207, diff --git a/web/src/app.ts b/web/src/app.ts index dc0d5e8dbc..202bf20b3d 100644 --- a/web/src/app.ts +++ b/web/src/app.ts @@ -28,7 +28,10 @@ import { ThreadContextDialog } from "./thread-context"; import { CHATS, SidebarView, + clearSidebarCache, + loadSidebarCache, moveTargets, + saveSidebarCache, type BotItem, type PlanModeInfo, type ProjectItem, @@ -320,6 +323,7 @@ function mountApp(): void { let threads: ThreadItem[] = []; let bots: BotItem[] = []; let rooms: RoomItem[] = []; + let hostDisplayName = ""; let favoriteModels: string[] = []; let railItems: RailEntry[] = []; let helloCommands: SlashCommand[] = []; @@ -864,6 +868,7 @@ function mountApp(): void { onRingHear: async (note, engine) => { await hub.rpc("ring.hear", { note, engine }); }, onOpenThread: (id) => { void openThread(id); }, onLogout: () => signOut(() => { + try { clearSidebarCache(window.localStorage); } catch { /* ignore */ } hub.disconnect(); window.location.replace("/"); }), @@ -1236,6 +1241,21 @@ function mountApp(): void { return false; } + function persistSidebarCache(): void { + try { + saveSidebarCache(window.localStorage, { + hostName: hostDisplayName || undefined, + sections, + projects, + threads, + bots, + rooms, + shellHashes, + openSectionFolds: Array.from(openSectionFolds), + }); + } catch { /* ignore */ } + } + function syncProjectsFromSections(list: SidebarSection[]): void { const out: ProjectItem[] = []; for (const sec of list) { @@ -1260,6 +1280,7 @@ function mountApp(): void { syncProjectsFromSections(list); sidebar.setData(projects, threads, bots, rooms); sidebar.setSections(list, bots, rooms); + persistSidebarCache(); updateHeader(); if (homeProjectId) void loadHomeThreads(homeProjectId, homeGen); return true; @@ -1280,23 +1301,31 @@ function mountApp(): void { async function loadLists(): Promise { threadSubId = null; - if (hub.hasFeature("bots")) { - try { - const bRes = await hub.rpc<{ bots?: BotItem[]; rooms?: RoomItem[] }>("bots.list", {}); - bots = bRes.bots ?? []; - rooms = bRes.rooms ?? []; - } catch { /* ignore */ } - } + const botsPromise = hub.hasFeature("bots") + ? hub.rpc<{ bots?: BotItem[]; rooms?: RoomItem[] }>("bots.list", {}).catch(() => null) + : Promise.resolve(null); if (hub.hasFeature("shell")) { - const sRes = await hub.rpc<{ - projects?: ProjectItem[]; - threads?: ThreadItem[]; - sections?: SidebarSection[] | { sections?: SidebarSection[] }; - removed?: string[]; - h?: Record; - sub?: SubId; - }>("shell.sync", { have: shellHashes, settled: 25 }); + const have: Record = {}; + for (const [k, v] of Object.entries(shellHashes)) { + if ((k === "@sections" && (!sections || sections.length === 0)) || (k.startsWith("p:") && projects.length === 0)) continue; + have[k] = v; + } + const [bRes, sRes] = await Promise.all([ + botsPromise, + hub.rpc<{ + projects?: ProjectItem[]; + threads?: ThreadItem[]; + sections?: SidebarSection[] | { sections?: SidebarSection[] }; + removed?: string[]; + h?: Record; + sub?: SubId; + }>("shell.sync", { have, settled: 25, open: Array.from(openSectionFolds) }), + ]); + if (bRes) { + bots = bRes.bots ?? []; + rooms = bRes.rooms ?? []; + } const removed = new Set(sRes.removed ?? []); const updatedPids = new Set((sRes.projects ?? []).map((p) => p.id)); if (removed.size > 0 || updatedPids.size > 0) { @@ -1327,13 +1356,19 @@ function mountApp(): void { if (sRes.h) shellHashes = sRes.h; sidebar.setData(projects, threads, bots, rooms); sidebar.setSections(sections, bots, rooms); + persistSidebarCache(); } else if (hub.hasFeature("sections")) { - const [secRes, tRes] = await Promise.all([ + const [bRes, secRes, tRes] = await Promise.all([ + botsPromise, hub.rpc<{ sections?: SidebarSection[] }>("sidebar.sections", { open: Array.from(openSectionFolds), }).catch(() => null), hub.rpc<{ threads?: ThreadItem[] }>("threads.list", { limit: 200, archived: false }).catch(() => ({ threads: [] })), ]); + if (bRes) { + bots = bRes.bots ?? []; + rooms = bRes.rooms ?? []; + } threads = tRes.threads ?? []; if (secRes && Array.isArray(secRes.sections)) { let list = secRes.sections; @@ -1361,17 +1396,24 @@ function mountApp(): void { sidebar.setSections(null, bots, rooms); sidebar.setData(projects, threads, bots, rooms); } + persistSidebarCache(); await hub.rpc("subscribe", { topic: "lists" }).catch(() => {}); } else { sections = null; - const [pRes, tRes] = await Promise.all([ + const [bRes, pRes, tRes] = await Promise.all([ + botsPromise, hub.rpc<{ projects?: ProjectItem[] }>("projects.list", { limit: 100 }), hub.rpc<{ threads?: ThreadItem[] }>("threads.list", { limit: 200, archived: false }), ]); + if (bRes) { + bots = bRes.bots ?? []; + rooms = bRes.rooms ?? []; + } projects = pRes.projects ?? []; threads = tRes.threads ?? []; sidebar.setSections(null, bots, rooms); sidebar.setData(projects, threads, bots, rooms); + persistSidebarCache(); await hub.rpc("subscribe", { topic: "lists" }).catch(() => {}); } @@ -1831,7 +1873,10 @@ function mountApp(): void { applyEffectiveLocale(); } if (hello.theme) applyHubTheme(hello.theme); - if (hello.name) sidebar.setHostName(hello.name); + if (hello.name) { + hostDisplayName = hello.name; + sidebar.setHostName(hello.name); + } if (Array.isArray(hello.favoriteModels)) { favoriteModels = hello.favoriteModels; composer.updateFavoriteModels(favoriteModels); @@ -1855,6 +1900,9 @@ function mountApp(): void { // a clone's pushes may have been missed while the socket was down addProject.reconcile(); } else { + if (state === "revoked") { + try { clearSidebarCache(window.localStorage); } catch { /* ignore */ } + } voice.cancel(); renderConnStatus(state); } @@ -1990,6 +2038,25 @@ function mountApp(): void { } }); + try { + const cached = loadSidebarCache(window.localStorage); + if (cached) { + if (cached.hostName) { + hostDisplayName = cached.hostName; + sidebar.setHostName(cached.hostName); + } + projects = cached.projects; + threads = cached.threads; + bots = cached.bots; + rooms = cached.rooms; + sections = cached.sections; + shellHashes = cached.shellHashes; + for (const f of cached.openSectionFolds) openSectionFolds.add(f); + sidebar.setData(projects, threads, bots, rooms); + sidebar.setSections(sections, bots, rooms); + } + } catch { /* ignore */ } + hub.connect(); } diff --git a/web/src/sidebar.ts b/web/src/sidebar.ts index 2e966ff4ab..d48dd8599d 100644 --- a/web/src/sidebar.ts +++ b/web/src/sidebar.ts @@ -13,6 +13,69 @@ import type { HomeInfo } from "./ws"; /** The place of the chats that belong to no project (the hub's `sidebar::CHATS`): `thread.create {project: CHATS}` starts one. */ export const CHATS = "chats"; +export const SIDEBAR_CACHE_KEY = "bp.sidebar.cache.v1"; + +export interface SidebarCache { + v: 1; + hostName?: string; + sections: SidebarSection[] | null; + projects: ProjectItem[]; + threads: ThreadItem[]; + bots: BotItem[]; + rooms: RoomItem[]; + shellHashes: Record; + openSectionFolds: string[]; +} + +export function loadSidebarCache(storage: Pick | null | undefined): SidebarCache | null { + try { + const raw = storage?.getItem(SIDEBAR_CACHE_KEY); + if (!raw) return null; + const parsed = JSON.parse(raw) as Partial | null; + if (!parsed || parsed.v !== 1) return null; + const projects = Array.isArray(parsed.projects) ? parsed.projects : []; + const threads = Array.isArray(parsed.threads) ? parsed.threads : []; + const sections = parsed.sections === null ? null : Array.isArray(parsed.sections) ? parsed.sections : null; + const bots = Array.isArray(parsed.bots) ? parsed.bots : []; + const rooms = Array.isArray(parsed.rooms) ? parsed.rooms : []; + const shellHashes = parsed.shellHashes && typeof parsed.shellHashes === "object" && !Array.isArray(parsed.shellHashes) + ? parsed.shellHashes + : {}; + const openSectionFolds = Array.isArray(parsed.openSectionFolds) + ? parsed.openSectionFolds.filter((x): x is string => typeof x === "string") + : []; + if (projects.length === 0 && threads.length === 0 && (!sections || sections.length === 0)) return null; + return { + v: 1, + hostName: typeof parsed.hostName === "string" ? parsed.hostName : undefined, + sections, + projects, + threads, + bots, + rooms, + shellHashes, + openSectionFolds, + }; + } catch { + return null; + } +} + +export function saveSidebarCache( + storage: Pick | null | undefined, + cache: Omit, +): void { + try { + storage?.setItem(SIDEBAR_CACHE_KEY, JSON.stringify({ v: 1, ...cache })); + } catch { /* ignore quota / private mode */ } +} + +export function clearSidebarCache(storage: Pick | null | undefined): void { + try { + storage?.removeItem(SIDEBAR_CACHE_KEY); + } catch { /* ignore */ } +} + /** The projects a chat may move to: this hub's own, by name (a linked machine's copy, `~`, is not offered). */ export function moveTargets(projects: ProjectItem[]): ProjectItem[] { return projects diff --git a/web/test/sidebar.test.ts b/web/test/sidebar.test.ts index 5611f4ccf4..5427083388 100644 --- a/web/test/sidebar.test.ts +++ b/web/test/sidebar.test.ts @@ -3,7 +3,7 @@ import { readFileSync } from "node:fs"; import { join } from "node:path"; mock.module("virtual:i18n", () => ({ CATALOGS: {} })); -const { statusPillOf, isSwarmVisibleUnderProject, moveTargets, homeBannerState, CHATS } = await import("../src/sidebar"); +const { statusPillOf, isSwarmVisibleUnderProject, moveTargets, homeBannerState, CHATS, SIDEBAR_CACHE_KEY, loadSidebarCache, saveSidebarCache, clearSidebarCache } = await import("../src/sidebar"); const root = join(import.meta.dir, ".."); const sidebarSrc = readFileSync(join(root, "src/sidebar.ts"), "utf8"); @@ -95,4 +95,38 @@ describe("SidebarView Crew / Inbox / Bench + Status Pills + Snooze", () => { expect(sidebarSrc).toContain("this.cb.onDismissHomeMove?.()"); expect(appSrc).toContain('"home.move.dismiss"'); }); + + test("Sidebar cache round-trips, rejects empty/invalid entries, and clears on logout", () => { + const store = new Map(); + const storage = { + getItem: (k: string) => store.get(k) ?? null, + setItem: (k: string, v: string) => { store.set(k, v); }, + removeItem: (k: string) => { store.delete(k); }, + }; + expect(loadSidebarCache(storage)).toBeNull(); + store.set(SIDEBAR_CACHE_KEY, "{bad json"); + expect(loadSidebarCache(storage)).toBeNull(); + store.set(SIDEBAR_CACHE_KEY, JSON.stringify({ v: 1, projects: [], threads: [], sections: [] })); + expect(loadSidebarCache(storage)).toBeNull(); + + saveSidebarCache(storage, { + hostName: "desk", + sections: [{ id: "pinned", kind: "projects", title: "Pinned", rows: [] }], + projects: [{ id: "p1", title: "Amp" }], + threads: [{ id: "t1", project: "p1", title: "Bringup", state: "idle", updatedAt: 100 }], + bots: [{ id: "b1", name: "Bub", thread: "tb1", uber: true }], + rooms: [{ id: "r1", name: "lab" }], + shellHashes: { "p:p1": "abc", "@sections": "def" }, + openSectionFolds: ["sec:quiet"], + }); + const loaded = loadSidebarCache(storage); + expect(loaded).not.toBeNull(); + expect(loaded?.hostName).toBe("desk"); + expect(loaded?.shellHashes).toEqual({ "p:p1": "abc", "@sections": "def" }); + expect(loaded?.openSectionFolds).toEqual(["sec:quiet"]); + clearSidebarCache(storage); + expect(loadSidebarCache(storage)).toBeNull(); + expect(appSrc).toContain("loadSidebarCache("); + expect(appSrc).toContain("clearSidebarCache("); + }); });