pi-straw-boss 0.49.0 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-TW.md +1 -1
- package/dist/gui/assets/{ask-BbPMnLTh.js → ask-Dclbf0Cy.js} +1 -1
- package/dist/gui/assets/{chat-Czv0jPAD.js → chat-B0m1yWBk.js} +1 -1
- package/dist/gui/assets/{drawer-aV6sM3Cp.js → drawer-kYN0P7C-.js} +1 -1
- package/dist/gui/assets/{index-BwRZ1vKG.js → index-CxTaPRCa.js} +1 -1
- package/dist/gui/assets/{layer-fdSmeR4i.js → layer-BmJR_8JP.js} +1 -1
- package/dist/gui/assets/{lightbox-DeyJW1Ta.js → lightbox-2K2fMlal.js} +1 -1
- package/dist/gui/assets/{link-DEyMVgpE.js → link-ByO-DEpC.js} +1 -1
- package/dist/gui/assets/pair-BJfr5h5E.js +1 -0
- package/dist/gui/assets/{picker-CezqOEMn.js → picker-CCeY0TM7.js} +1 -1
- package/dist/gui/assets/{server-894bzpGw.js → server-D-wiAwuR.js} +1 -1
- package/dist/gui/assets/{spawn-4YbdgJBa.js → spawn-Ca0rhrKR.js} +1 -1
- package/dist/gui/assets/{trust-Vf8ZY7v-.js → trust-S5_5phfE.js} +1 -1
- package/dist/gui/assets/{unit_count-DFKHs2Sk.js → unit_count-CWBSU9VR.js} +1 -1
- package/dist/gui/assets/{views-BmcT2brW.js → views-C9jvGick.js} +2 -2
- package/dist/gui/index.html +1 -1
- package/dist/server/{chunk-F4ZOTRQT.mjs → chunk-PW2KM4BC.mjs} +7 -5
- package/dist/server/cli.mjs +1 -1
- package/dist/server/main.mjs +60 -10
- package/package.json +1 -1
- package/src/appentry.ts +6 -11
- package/src/entryform.ts +68 -0
- package/src/paircode.ts +9 -4
- package/src/remote.ts +3 -3
- package/dist/gui/assets/pair-ChR0ekqj.js +0 -1
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ The tower only routes and coordinates, so it can run a lighter model: set `tower
|
|
|
105
105
|
| Stash, Stashed, Pop on the page | A base's Stash puts it away under its label; the HUD's Stashed list opens each one again with Pop. A base's Quit is checked first, as `/boss close all` is. |
|
|
106
106
|
| `/boss stash [name]`, `/boss pop [name]` | Put this whole base away (its tower, mains, members, and idle shells) and close it; open it again later, every pi resumed from its own session file in its old role. A stash refuses, naming why, while anything a resume would lose is there: a running turn, a queued message, an open dialog, a running monitor, a subagent, or a busy shell. |
|
|
107
107
|
| `/boss gui`, `/boss gui stop`, `/boss gui rotate` | Open the net in the browser (any session, joins nothing); stop its GUI, from any session. The GUI is served by the sb server, one per machine, so it does not depend on which pi session runs: `/boss gui` starts the server when none runs and prints the URL, and a server that went down comes back when any pi session starts or looks (or from `cli.mjs up`). The URL carries a random token that is kept across a restart, an upgrade, a crash, a reboot, and a `/boss gui stop` followed by `/boss gui` (on the same port, in `gui-secrets.json`), so a page left open reconnects by itself and a phone stays paired. A new token comes only from `/boss gui rotate` (after a confirm; it unpairs every phone and opens the new address), a missing or corrupt `gui-secrets.json`, or a port that was taken at the next start: the old address then answers 403 and a phone scans the QR code again. Keeping the token has a cost you chose: another account on this machine that binds the port during a crash or restart gap sees what an open page sends; rotate after a gap you do not trust. With `STRAW_BOSS_DESK=1` (a desk shell shows the page itself) it opens no browser and the page leaves out Phone and Stash. Only `/boss gui stop` keeps the GUI stopped, until the next `/boss gui` or `cli.mjs up`; `/boss stash` and `/boss close all` do not start a stopped GUI. The header's Server button (this computer's page only) shows the server's state, restarts it, and shows its log. Type into a session from its comms view, or work its terminal with the key pad under the terminal tile, or on a desktop by clicking into it and typing; answer a waiting `robot_hand` selector, `ask_user_question` questionnaire, or pi-code hook confirmation there or in its alert (so can any extension's `select` and `confirm`, also from a paired device; other dialogs show read-only, to answer in the terminal; `secret_drop` always takes its secret in the terminal, never on a page, local or over the tailnet, because pi-intercom identities are self-reported). Documents a session shows with [pi-herdr-doc-review](https://www.npmjs.com/package/pi-herdr-doc-review) 0.4.0 or newer open beside its comms: HTML in a sandboxed frame whose form answers the agent, text read-only. |
|
|
108
|
-
| `/boss gui remote`, `/boss gui remote off` | Reach the GUI from your phone over your tailnet (`tailscale serve`, never Funnel): pair by QR code (or, in an installed app, by the short code shown beside it), and a phone stays paired (90 days from its last use, `remote off` included) until you unpair it in the Phone tile or the GUI gets a new token (a pairing belongs to the token, which a restart keeps; `/boss gui rotate`, a lost `gui-secrets.json`, or a taken port makes a new one and the old pairings are cleared); remote access stays on across a restart or a new server until `remote off`, and a paired phone keeps working after a restart; after a new token a phone pairs again: in the browser by scanning the QR code, in an installed app by typing the pairing code (see below); off removes only its own serve entry. The serve entry points at a second loopback listener of the sb server's GUI, so a request is remote because of the listener it arrived on, whatever headers it carries. The page installs as an app (Add to Home Screen, or Chrome's Install) with a fixed entry, `https://<this machine>.<tailnet>.ts.net:8443/sb-app/`, as its start URL (a token-free address on the tailnet listener only): open with a pairing, it leads to the current page; open without one (after a new token, or on iOS, where the app keeps cookies of its own and scanning the QR in Safari never reaches it), it shows
|
|
108
|
+
| `/boss gui remote`, `/boss gui remote off` | Reach the GUI from your phone over your tailnet (`tailscale serve`, never Funnel): pair by QR code (or, in an installed app, by the short code shown beside it), and a phone stays paired (90 days from its last use, `remote off` included) until you unpair it in the Phone tile or the GUI gets a new token (a pairing belongs to the token, which a restart keeps; `/boss gui rotate`, a lost `gui-secrets.json`, or a taken port makes a new one and the old pairings are cleared); remote access stays on across a restart or a new server until `remote off`, and a paired phone keeps working after a restart; after a new token a phone pairs again: in the browser by scanning the QR code, in an installed app by typing the pairing code (see below); off removes only its own serve entry. The serve entry points at a second loopback listener of the sb server's GUI, so a request is remote because of the listener it arrived on, whatever headers it carries. The page installs as an app (Add to Home Screen, or Chrome's Install) with a fixed entry, `https://<this machine>.<tailnet>.ts.net:8443/sb-app/`, as its start URL (a token-free address on the tailnet listener only): open with a pairing, it leads to the current page; open without one (after a new token, or on iOS, where the app keeps cookies of its own and scanning the QR in Safari never reaches it), it shows eight boxes for the **pairing code** that `/boss gui remote` prints under the QR (and the Phone tile shows beside it), one character per box (a paste fills them all). The code is 8 characters, shown as two groups of four (`ABCD EFGH`; no hyphen to type), works once within ten minutes, and is void after five wrong tries until you ask this computer for a new one. An app installed before this entry existed opens its old address, which now leads to the entry as well. |
|
|
109
109
|
| `node dist/server/cli.mjs up --dir <folder> --label <name>` (a shell, not a pi command) | The desk steps of `up`, for a shell that shows the page itself (straw-boss-desk): with `STRAW_BOSS_DESK=1` set in the environment of `herdr server` and of this command, it installs Herdr's pi integration when it is not current, makes the shell's home base (a workspace in the folder, recorded in `desk.json` and found again by its workspace id), has the sb server stand in for its tower, waits for the GUI, and prints one JSON line with `url`, `workspace`, `pane`, `tower`, `created`, and `integration`. Idempotent: a second run opens nothing. Without the switch it exits 2. See [Desk mode](docs/how-it-works.md#desk-mode-up---dir). |
|
|
110
110
|
|
|
111
111
|
Subagents and sessions in Herdr worktree workspaces never join: the session that launched them speaks for them. Outside Herdr the extension does nothing.
|
package/README.zh-TW.md
CHANGED
|
@@ -102,7 +102,7 @@ pi install npm:pi-straw-boss
|
|
|
102
102
|
| 網頁上的「收起」「已收起」「接回」 | 基地的「收起」以基地名稱收起它;上方的「已收起」列出收起的基地,按「接回」打開。基地的「關掉」會先檢查,和 `/boss close all` 一樣。 |
|
|
103
103
|
| `/boss stash [名稱]`、`/boss pop [名稱]` | 把整個基地(塔台、主智慧體、成員和閒置的 shell)收起來並關掉;之後再打開,每個 pi 都從自己的 session 檔接回原本的角色。只要有接回後會遺失的東西就拒絕並說明原因:正在跑的回合、排隊中的訊息、開著的對話框、執行中的 Monitor、子智慧體,或前景有程式在跑的 shell。 |
|
|
104
104
|
| `/boss gui`、`/boss gui stop`、`/boss gui rotate` | 在瀏覽器開啟網(任何 session 都能開,不會加入任何東西);停止它的伺服器,在哪個 session 都可以。整台機器只跑一個伺服器,網址會保留(見下):開它的 session `/reload` 之後會重開(網址不變);跑它的 session 結束時(關掉 pane、離開 pi、當機),另一個還開著的 session 會在幾秒內重開它(網址不變)(塔台優先;pi-straw-boss 版本比伺服器舊的 session 要等約六秒才接手,直到下一個較新的 session 再接回去);之後才啟動的 session 也會把停著的伺服器重開,即使所有 session 都離開過或機器重開機;版本較新的 session 會接手,但開著的頁面不會自動換成新版:它會顯示「這個網址已失效」,要用 `/boss gui` 重開。網址裡的 token 會跨過重啟保留:伺服器重啟、升級、當機、重開機,或 `/boss gui stop` 之後再 `/boss gui`,都沿用同一個 token(存在 `gui-secrets.json`,連同埠號),開著的分頁會自行重新連線,手機仍維持配對。只有 `/boss gui rotate`(會先確認;換新 token 與 CSRF 密鑰、解除所有手機的配對並開啟新網址)、`gui-secrets.json` 遺失或損毀,或下次啟動時埠號被占用,才會換新 token:舊網址回 403,手機要重新掃 QR code。保留 token 的代價是你選擇接受的:當機或重啟的空檔裡,這台機器上其他帳號若搶先佔用該埠,會看到開著的頁面送出的內容;對空檔不放心時請 rotate。設了 `STRAW_BOSS_DESK=1`(桌面殼自己顯示頁面)時,它不會開瀏覽器,頁面也不顯示 Phone 與 Stash。只有 `/boss gui stop` 會讓它維持停止,直到下一次 `/boss gui`;`/boss stash` 和 `/boss close all` 不會把停著的伺服器重開。可以在通訊畫面直接打字給某個 session,或用終端機畫面下方的按鍵面板操作它的終端機,在桌面上也可以點進終端機直接打字;在等回覆的 `robot_hand` 選單、`ask_user_question` 問卷或 pi-code 的 hook 確認,可以在那裡或它的警示裡作答(任何 extension 的 `select` 和 `confirm` 也可以,`confirm` 也可以從配對的裝置作答;其他對話框只能看,要回到終端機回答;`secret_drop` 的機密一律在終端機輸入,任何頁面(本機或 tailnet)都不接受,因為 pi-intercom 的身分是自己申報的,無法驗證)。session 用 [pi-herdr-doc-review](https://www.npmjs.com/package/pi-herdr-doc-review) 0.4.0 以上顯示的文件,會開在它的通訊畫面旁邊:HTML 放在沙箱框架裡,表單送出的答案會傳給智慧體;純文字只能讀。 |
|
|
105
|
-
| `/boss gui remote`、`/boss gui remote off` | 透過你的 tailnet 用手機連 GUI(`tailscale serve`,絕不用 Funnel):掃 QR code 配對(已安裝的 app 則輸入 QR 旁邊顯示的短配對碼),手機配對後的紀錄會保留(從最後一次使用起算 90 天,重啟與 `remote off` 都不影響),直到你在「手機」視窗解除配對;遠端存取在 stop、`/reload`、換新伺服器之後仍會保持開啟,直到 `remote off`;伺服器重啟後 token 不變,已配對的手機照常使用;GUI 換新 token(`/boss gui rotate`、`gui-secrets.json` 遺失,或埠號被占用)時,舊的配對全部清除(cookie 綁在舊 token 的路徑上),手機要重新配對:瀏覽器掃 QR code,已安裝的 app 輸入配對碼(見下);關閉時只移除它自己的 serve 設定。serve 指向 GUI 伺服器的第二個 loopback 監聽埠,請求算不算遠端取決於它進來的監聽埠,不看它帶什麼標頭。頁面可以安裝成 app(加入主畫面,或 Chrome 的「安裝」):app 的起始網址是固定入口 `https://<這台機器>.<tailnet>.ts.net:8443/sb-app/`(沒有 token,只在 tailnet 監聽埠上):已配對時它會帶你到目前的頁面;沒有配對時(換新 token 後,或 iOS 上 app 有自己的 cookie、在 Safari 掃 QR code 永遠到不了 app
|
|
105
|
+
| `/boss gui remote`、`/boss gui remote off` | 透過你的 tailnet 用手機連 GUI(`tailscale serve`,絕不用 Funnel):掃 QR code 配對(已安裝的 app 則輸入 QR 旁邊顯示的短配對碼),手機配對後的紀錄會保留(從最後一次使用起算 90 天,重啟與 `remote off` 都不影響),直到你在「手機」視窗解除配對;遠端存取在 stop、`/reload`、換新伺服器之後仍會保持開啟,直到 `remote off`;伺服器重啟後 token 不變,已配對的手機照常使用;GUI 換新 token(`/boss gui rotate`、`gui-secrets.json` 遺失,或埠號被占用)時,舊的配對全部清除(cookie 綁在舊 token 的路徑上),手機要重新配對:瀏覽器掃 QR code,已安裝的 app 輸入配對碼(見下);關閉時只移除它自己的 serve 設定。serve 指向 GUI 伺服器的第二個 loopback 監聽埠,請求算不算遠端取決於它進來的監聽埠,不看它帶什麼標頭。頁面可以安裝成 app(加入主畫面,或 Chrome 的「安裝」):app 的起始網址是固定入口 `https://<這台機器>.<tailnet>.ts.net:8443/sb-app/`(沒有 token,只在 tailnet 監聽埠上):已配對時它會帶你到目前的頁面;沒有配對時(換新 token 後,或 iOS 上 app 有自己的 cookie、在 Safari 掃 QR code 永遠到不了 app),它會顯示 8 個輸入格,輸入 `/boss gui remote` 在 QR code 下方印出的**配對碼**(「手機」視窗也顯示在 QR code 旁),每格一個字元(貼上整組會自動填滿)。配對碼 8 個字元,顯示成兩組各四個(`ABCD EFGH`,不需要輸入連字號),十分鐘內只能用一次,輸錯五次後作廢,要在這台電腦上重新取得新的才能再試。在這個入口出現之前安裝的 app,舊網址現在也會導向入口。 |
|
|
106
106
|
| `node dist/server/cli.mjs up --dir <資料夾> --label <名稱>`(給外殼程式用,不是 pi 指令) | `up` 的桌面步驟,給自己顯示頁面的外殼程式(straw-boss-desk)使用:在啟動 `herdr server` 與執行這個指令的環境都設了 `STRAW_BOSS_DESK=1` 時,它會在 Herdr 的 pi 整合不是最新時安裝,建立外殼的家基地(在該資料夾開一個工作區,記在 `desk.json`,之後以工作區 id 找回),讓 sb server 代替這個工作區的塔台,等 GUI 起來,最後印出一行 JSON,內有 `url`、`workspace`、`pane`、`tower`、`created`、`integration`。重複執行不會多開東西;沒設這個開關時以代碼 2 結束。詳見[桌面模式](docs/how-it-works.md#desk-mode-up---dir)。 |
|
|
107
107
|
|
|
108
108
|
子智慧體,以及在 Herdr worktree 工作區裡的 session,都不會加入網,由開出它們的 session 代表它們。不在 Herdr 裡時,這個擴充套件什麼都不做。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{a as t,i as n,n as r,r as i,t as a}from"./sending-aEpvzoz2.js";import{X as o,dt as s}from"./index-BwRZ1vKG.js";var c=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer it in the terminal.`),l=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer them in the terminal.`),u=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),y=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,b=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,x=((t,n={})=>(n.locale??e())===`zh-TW`?b(t):y(t)),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`安全考量,遠端不支援輸入機密。請到執行 GUI 的那台電腦的終端機中回答。`:`For security, entering a secret is not supported remotely. Answer it in the terminal on the computer the GUI runs on.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`機密內容只能在終端機輸入,這裡不接受。請到執行 GUI 的那台電腦的終端機中回答。`:`A secret is entered in the terminal only, not here. Answer it in the terminal on the computer the GUI runs on.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),R={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function z(e,t,n,r,i){let{q:a}=n,o=r[a],s=R[e]??0,c=e===`ArrowUp`,l=c||e===`ArrowDown`,u=()=>({to:r.map((e,t)=>({q:(a+1+t)%r.length,part:`opt`})).find(e=>e.q!==a&&!i[e.q])??`send`});if(e===`Tab`)return t?n.part===`opt`&&a>0?{to:{q:a-1,part:`opt`}}:void 0:a<r.length-1?{to:{q:a+1,part:`opt`}}:void 0;if(!t){if(n.part===`opt`){let t=n.o+s;if(s)return t>=0&&t<o.options?{to:{q:a,part:`opt`,o:t},...o.multiple?{}:{pick:t}}:{to:s>0&&o.own?{q:a,part:`own`}:n};if(e===`Enter`||e===` `&&!o.multiple)return{...u(),...o.multiple?{}:{pick:n.o}}}else if(n.part===`own`){if(e===`Enter`)return u();if(l)return{to:c?{q:a,part:`opt`,o:o.options-1}:{q:a,part:`note`}}}else if(c)return{to:{q:a,part:`own`}}}}function B(e,t,n){let r=e=>Math.max(0,e.opts.findIndex(e=>e.getAttribute(`aria-checked`)===`true`)),i=(e,t)=>e.opts.forEach((e,n)=>e.setAttribute(`tabindex`,n===t?`0`:`-1`)),a=e=>{for(let[n,r]of t.entries()){let t=r.opts.indexOf(e);if(t>=0)return{q:n,part:`opt`,o:t};if(e===r.own||e===r.note)return{q:n,part:e===r.own?`own`:`note`}}};t.forEach(e=>i(e,r(e)));let o=e=>{let n=a(e.target);n?.part===`opt`&&i(t[n.q],n.o)};e.addEventListener(`focusin`,o),e.addEventListener(`click`,o);let s=!1;return e.addEventListener(`keydown`,e=>{let i=a(e.target);if(!i||e.ctrlKey||e.altKey||e.metaKey||e.isComposing)return;let o=e.target;if(i.part!==`opt`&&(e.key===`ArrowUp`?o.selectionStart!==0:e.key===`ArrowDown`&&o.selectionEnd!==o.value.length))return;let c=z(e.key,e.shiftKey,i,t.map(e=>({options:e.opts.length,multiple:e.multiple,own:!!e.own})),t.map(e=>e.answered()));if(!c||(e.preventDefault(),e.repeat&&[`Enter`,` `].includes(e.key)))return;if(s=e.key===` `,c.pick!==void 0){let e=t[i.q].opts[c.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let l=c.to===`send`?void 0:t[c.to.q],u=c.to===`send`?n():c.to.part===`opt`?l.opts[c.to.o??r(l)]:c.to.part===`own`?l.own:l.note;u&&!u.disabled&&u.focus()}),e.addEventListener(`keyup`,e=>s&&e.key===` `&&(s=!1,e.preventDefault())),()=>t[0]?.opts[r(t[0])]}var V=e=>e.multiple?d():e.freeform&&e.options.length?u():``,H=(e,t)=>o(`div`,{class:`ask-one`},e.header&&o(`b`,{class:`ask-head`},e.header),o(`p`,{class:`ask-q`},e.question),e.context&&o(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&o(`ol`,{class:`ask-opts`,"aria-label":S()},...e.options.map(e=>o(`li`,{class:`ask-opt`},o(`b`,null,e.title),e.description&&o(`small`,null,e.description)))),t&&V(e)&&o(`small`,{class:`ask-how`},V(e))),U=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),W=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),G=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),K=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),q={digest:E,"not-allowed":O,malformed:D};function J(e){let{outcome:i,reason:a,by:o}=e.body;return i===`accepted`?[`ok`,n()]:i===`stale`?[`error`,o===`local`?I():o===`cancel`?P():F()]:i===`rejected`?[`error`,(Object.hasOwn(q,String(a))?q[String(a)]:k)()]:i===`busy`?[`error`,t()]:i===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,a??s({status:e.status})]}var Y=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,X=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function Z(e,t,n=location.hostname!==`127.0.0.1`,s,u){let d,y,b,E=!1,D=!1,O;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>y&&!y.el.contains(e.target)&&(y.lost=void 0));let k=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),P=()=>{if(!y)return;let e=document.activeElement;e&&e!==document.body&&e!==y.lost&&(y.lost=void 0),y.controls.forEach(e=>e.disabled=!E||D||y.done),y.send&&(y.send.disabled=!E||D||y.done||!y.pick()),e&&y.el.contains(e)&&e.disabled&&(y.lost=e);let t=y.lost;t&&!t.disabled&&y.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),y.lost=void 0)};async function F(e,n){[e.sending,D,e.spell]=[!0,!0,!1],P(),k(e.note,``,a());let s=await t(`answer`,n).catch(()=>void 0),c=o(`button`,{type:`button`,class:`cmp-link`},i());c.onclick=()=>void F(e,n);let[l,d,f]=s?J(s):[`error`,r(),!0];[e.done,e.sending,D,e.busy]=[!s||Y(s),!1,!1,s?.body.outcome===`busy`],k(e.note,l,d,...f?[c]:[]),P(),e.note.scrollIntoView?.({block:`nearest`}),u&&s?.body.outcome===`accepted`&&setTimeout(u,1200)}let I=(e,t,n,r,i)=>{let a=o(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},o(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>o(`small`,null,e)));return a.onclick=r,a};function R(e,t){let r,i=W(t).map(e=>I(`radio`,U(e.label),[e.note&&U(e.note)],()=>(r=e.i,i.forEach((n,r)=>n.setAttribute(`aria-checked`,String(W(t)[r].i===e.i))),P()),e.i+1)),a=t.select?.copy!==void 0&&o(`button`,{type:`button`,class:`cmp-link`},h());a&&(a.disabled=!navigator.clipboard,a.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>k(e.note,`ok`,m()),()=>k(e.note,`error`,p())));let s=i.filter((e,r)=>!(n&&W(t)[r].hereOnly));return i.forEach(e=>!s.includes(e)&&(e.disabled=!0)),e.pick=()=>r===void 0?void 0:{choice:r},e.first=B(e.el,[{opts:i,multiple:!1,answered:()=>r!==void 0}],()=>e.send),e.controls=s,[o(`pre`,{class:`ask-title`},U(t.select.title)),o(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":f()},...i),o(`div`,{class:`ask-acts`},e.send,a)]}function z(e,t){let n=t.questions.map(()=>({picks:new Set,text:o(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:T(),"aria-label":w()}),note:o(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:v(),"aria-label":_()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],s=t.multiple?`checkbox`:`radio`,c=t.options.map((e,n)=>I(s,e.title,[e.description,e.preview&&g()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),c.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),P()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),c.forEach(e=>e.setAttribute(`aria-checked`,`false`))),P()),e.controls.push(...c,a.text,a.note),r.push({opts:c,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),o(`div`,{class:`ask-one`},t.header&&o(`b`,{class:`ask-head`},t.header),o(`p`,{class:`ask-q`},t.question),o(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":S()},...c),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>G(e.picks,e.text.value,e.note.value))}:void 0,e.first=B(e.el,r,()=>e.send),[...i,o(`div`,{class:`ask-acts`},e.send)]}function q(e){let t=e.asks??(e.ask?[e.ask]:[]),r=t.length>1,i=e.answer,a={key:X(e),el:o(`section`,{class:`ask`}),note:o(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};i&&((a.send=o(`button`,{type:`button`,class:`ask-send`},M())).onclick=()=>void(a.pick()&&F(a,K(i,a.pick(),crypto.randomUUID()))));let u=e.tool===`secret_drop`,d=o(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${r?l():c()} ${r||!t[0]?``:V(t[0])}`.trim()),f=s&&e.tool!==`secret_drop`&&o(`button`,{type:`button`,class:`cmp-link`},N());f&&(f.onclick=s);let p=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[o(`p`,{class:`ask-why`},x({tool:e.tool}))]:[];return a.el.append(...p,...i&&!u?i.select?R(a,i):z(a,i):[...t.length?t.map(e=>H(e,r)):[o(`p`,{class:`ask-why`},u?n?A():j():e.why??L())],o(`div`,{class:`ask-acts`},u?o(`p`,{class:`ask-term`},c()):d,f)],a.note),a}let Z=(t,n)=>{let r=document.activeElement;y&&y!==n&&(y.focus=y.el.contains(r)?r:void 0),[d,y,b]=[t,n,n?.send?n:b],e.replaceChildren(...n?[n.el]:[]),P(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=y&&!y.done?y.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},update(e,t){E=t,e&&(O=void clearTimeout(O)),!e&&(y?.done||y?.sending)?O??=setTimeout(()=>(O=void 0,Z()),6e3):e?y&&(X(e)===y.key||!e.answer&&(y.done||y.sending)&&e.callId===d?.callId)?((y.busy||y.sending)&&!e.answer?y.spell=!0:y.busy&&y.spell&&e.answer&&([y.done,y.busy]=[!1,!1],k(y.note,``,C())),d=e):Z(e,b?.key===X(e)&&!b.done?b:q(e)):Z(),P()}}}export{Z as t};
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{a as t,i as n,n as r,r as i,t as a}from"./sending-aEpvzoz2.js";import{X as o,dt as s}from"./index-CxTaPRCa.js";var c=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer it in the terminal.`),l=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer them in the terminal.`),u=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),y=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,b=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,x=((t,n={})=>(n.locale??e())===`zh-TW`?b(t):y(t)),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`安全考量,遠端不支援輸入機密。請到執行 GUI 的那台電腦的終端機中回答。`:`For security, entering a secret is not supported remotely. Answer it in the terminal on the computer the GUI runs on.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`機密內容只能在終端機輸入,這裡不接受。請到執行 GUI 的那台電腦的終端機中回答。`:`A secret is entered in the terminal only, not here. Answer it in the terminal on the computer the GUI runs on.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),R={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function z(e,t,n,r,i){let{q:a}=n,o=r[a],s=R[e]??0,c=e===`ArrowUp`,l=c||e===`ArrowDown`,u=()=>({to:r.map((e,t)=>({q:(a+1+t)%r.length,part:`opt`})).find(e=>e.q!==a&&!i[e.q])??`send`});if(e===`Tab`)return t?n.part===`opt`&&a>0?{to:{q:a-1,part:`opt`}}:void 0:a<r.length-1?{to:{q:a+1,part:`opt`}}:void 0;if(!t){if(n.part===`opt`){let t=n.o+s;if(s)return t>=0&&t<o.options?{to:{q:a,part:`opt`,o:t},...o.multiple?{}:{pick:t}}:{to:s>0&&o.own?{q:a,part:`own`}:n};if(e===`Enter`||e===` `&&!o.multiple)return{...u(),...o.multiple?{}:{pick:n.o}}}else if(n.part===`own`){if(e===`Enter`)return u();if(l)return{to:c?{q:a,part:`opt`,o:o.options-1}:{q:a,part:`note`}}}else if(c)return{to:{q:a,part:`own`}}}}function B(e,t,n){let r=e=>Math.max(0,e.opts.findIndex(e=>e.getAttribute(`aria-checked`)===`true`)),i=(e,t)=>e.opts.forEach((e,n)=>e.setAttribute(`tabindex`,n===t?`0`:`-1`)),a=e=>{for(let[n,r]of t.entries()){let t=r.opts.indexOf(e);if(t>=0)return{q:n,part:`opt`,o:t};if(e===r.own||e===r.note)return{q:n,part:e===r.own?`own`:`note`}}};t.forEach(e=>i(e,r(e)));let o=e=>{let n=a(e.target);n?.part===`opt`&&i(t[n.q],n.o)};e.addEventListener(`focusin`,o),e.addEventListener(`click`,o);let s=!1;return e.addEventListener(`keydown`,e=>{let i=a(e.target);if(!i||e.ctrlKey||e.altKey||e.metaKey||e.isComposing)return;let o=e.target;if(i.part!==`opt`&&(e.key===`ArrowUp`?o.selectionStart!==0:e.key===`ArrowDown`&&o.selectionEnd!==o.value.length))return;let c=z(e.key,e.shiftKey,i,t.map(e=>({options:e.opts.length,multiple:e.multiple,own:!!e.own})),t.map(e=>e.answered()));if(!c||(e.preventDefault(),e.repeat&&[`Enter`,` `].includes(e.key)))return;if(s=e.key===` `,c.pick!==void 0){let e=t[i.q].opts[c.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let l=c.to===`send`?void 0:t[c.to.q],u=c.to===`send`?n():c.to.part===`opt`?l.opts[c.to.o??r(l)]:c.to.part===`own`?l.own:l.note;u&&!u.disabled&&u.focus()}),e.addEventListener(`keyup`,e=>s&&e.key===` `&&(s=!1,e.preventDefault())),()=>t[0]?.opts[r(t[0])]}var V=e=>e.multiple?d():e.freeform&&e.options.length?u():``,H=(e,t)=>o(`div`,{class:`ask-one`},e.header&&o(`b`,{class:`ask-head`},e.header),o(`p`,{class:`ask-q`},e.question),e.context&&o(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&o(`ol`,{class:`ask-opts`,"aria-label":S()},...e.options.map(e=>o(`li`,{class:`ask-opt`},o(`b`,null,e.title),e.description&&o(`small`,null,e.description)))),t&&V(e)&&o(`small`,{class:`ask-how`},V(e))),U=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),W=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),G=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),K=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),q={digest:E,"not-allowed":O,malformed:D};function J(e){let{outcome:i,reason:a,by:o}=e.body;return i===`accepted`?[`ok`,n()]:i===`stale`?[`error`,o===`local`?I():o===`cancel`?P():F()]:i===`rejected`?[`error`,(Object.hasOwn(q,String(a))?q[String(a)]:k)()]:i===`busy`?[`error`,t()]:i===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,a??s({status:e.status})]}var Y=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,X=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function Z(e,t,n=location.hostname!==`127.0.0.1`,s,u){let d,y,b,E=!1,D=!1,O;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>y&&!y.el.contains(e.target)&&(y.lost=void 0));let k=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),P=()=>{if(!y)return;let e=document.activeElement;e&&e!==document.body&&e!==y.lost&&(y.lost=void 0),y.controls.forEach(e=>e.disabled=!E||D||y.done),y.send&&(y.send.disabled=!E||D||y.done||!y.pick()),e&&y.el.contains(e)&&e.disabled&&(y.lost=e);let t=y.lost;t&&!t.disabled&&y.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),y.lost=void 0)};async function F(e,n){[e.sending,D,e.spell]=[!0,!0,!1],P(),k(e.note,``,a());let s=await t(`answer`,n).catch(()=>void 0),c=o(`button`,{type:`button`,class:`cmp-link`},i());c.onclick=()=>void F(e,n);let[l,d,f]=s?J(s):[`error`,r(),!0];[e.done,e.sending,D,e.busy]=[!s||Y(s),!1,!1,s?.body.outcome===`busy`],k(e.note,l,d,...f?[c]:[]),P(),e.note.scrollIntoView?.({block:`nearest`}),u&&s?.body.outcome===`accepted`&&setTimeout(u,1200)}let I=(e,t,n,r,i)=>{let a=o(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},o(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>o(`small`,null,e)));return a.onclick=r,a};function R(e,t){let r,i=W(t).map(e=>I(`radio`,U(e.label),[e.note&&U(e.note)],()=>(r=e.i,i.forEach((n,r)=>n.setAttribute(`aria-checked`,String(W(t)[r].i===e.i))),P()),e.i+1)),a=t.select?.copy!==void 0&&o(`button`,{type:`button`,class:`cmp-link`},h());a&&(a.disabled=!navigator.clipboard,a.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>k(e.note,`ok`,m()),()=>k(e.note,`error`,p())));let s=i.filter((e,r)=>!(n&&W(t)[r].hereOnly));return i.forEach(e=>!s.includes(e)&&(e.disabled=!0)),e.pick=()=>r===void 0?void 0:{choice:r},e.first=B(e.el,[{opts:i,multiple:!1,answered:()=>r!==void 0}],()=>e.send),e.controls=s,[o(`pre`,{class:`ask-title`},U(t.select.title)),o(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":f()},...i),o(`div`,{class:`ask-acts`},e.send,a)]}function z(e,t){let n=t.questions.map(()=>({picks:new Set,text:o(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:T(),"aria-label":w()}),note:o(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:v(),"aria-label":_()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],s=t.multiple?`checkbox`:`radio`,c=t.options.map((e,n)=>I(s,e.title,[e.description,e.preview&&g()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),c.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),P()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),c.forEach(e=>e.setAttribute(`aria-checked`,`false`))),P()),e.controls.push(...c,a.text,a.note),r.push({opts:c,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),o(`div`,{class:`ask-one`},t.header&&o(`b`,{class:`ask-head`},t.header),o(`p`,{class:`ask-q`},t.question),o(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":S()},...c),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>G(e.picks,e.text.value,e.note.value))}:void 0,e.first=B(e.el,r,()=>e.send),[...i,o(`div`,{class:`ask-acts`},e.send)]}function q(e){let t=e.asks??(e.ask?[e.ask]:[]),r=t.length>1,i=e.answer,a={key:X(e),el:o(`section`,{class:`ask`}),note:o(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};i&&((a.send=o(`button`,{type:`button`,class:`ask-send`},M())).onclick=()=>void(a.pick()&&F(a,K(i,a.pick(),crypto.randomUUID()))));let u=e.tool===`secret_drop`,d=o(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${r?l():c()} ${r||!t[0]?``:V(t[0])}`.trim()),f=s&&e.tool!==`secret_drop`&&o(`button`,{type:`button`,class:`cmp-link`},N());f&&(f.onclick=s);let p=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[o(`p`,{class:`ask-why`},x({tool:e.tool}))]:[];return a.el.append(...p,...i&&!u?i.select?R(a,i):z(a,i):[...t.length?t.map(e=>H(e,r)):[o(`p`,{class:`ask-why`},u?n?A():j():e.why??L())],o(`div`,{class:`ask-acts`},u?o(`p`,{class:`ask-term`},c()):d,f)],a.note),a}let Z=(t,n)=>{let r=document.activeElement;y&&y!==n&&(y.focus=y.el.contains(r)?r:void 0),[d,y,b]=[t,n,n?.send?n:b],e.replaceChildren(...n?[n.el]:[]),P(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=y&&!y.done?y.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},update(e,t){E=t,e&&(O=void clearTimeout(O)),!e&&(y?.done||y?.sending)?O??=setTimeout(()=>(O=void 0,Z()),6e3):e?y&&(X(e)===y.key||!e.answer&&(y.done||y.sending)&&e.callId===d?.callId)?((y.busy||y.sending)&&!e.answer?y.spell=!0:y.busy&&y.spell&&e.answer&&([y.done,y.busy]=[!1,!1],k(y.note,``,C())),d=e):Z(e,b?.key===X(e)&&!b.done?b:q(e)):Z(),P()}}}export{Z as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-D3RS3c_W.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{O as t,Q as n,X as r,d as i,h as a,n as o,w as s}from"./index-BwRZ1vKG.js";import{a as c,i as l,n as u,o as d,r as ee,t as te}from"./views-BmcT2brW.js";var ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`分支摘要`:`branch summary`),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`通訊紀錄`:`Comms log`),f=e=>`context compacted · ${e?.tokens} tokens summarized`,p=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,ae=((t,n={})=>(n.locale??e())===`zh-TW`?p(t):f(t)),oe=((t={},n={})=>(n.locale??e())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),m=e=>`exit ${e?.code}`,h=e=>`結束碼 ${e?.code}`,se=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),g=e=>`Image ${e?.n}`,_=e=>`圖片 ${e?.n}`,ce=((t,n={})=>(n.locale??e())===`zh-TW`?_(t):g(t)),le=((t={},n={})=>(n.locale??e())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),v=e=>`${e?.count} image(s)`,y=e=>`${e?.count} 張圖片`,ue=((t,n={})=>(n.locale??e())===`zh-TW`?y(t):v(t)),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`收到`:`incoming`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`跳到最新`:`jump to latest`),x=e=>`${e?.count} new`,S=e=>`${e?.count} 則新訊息`,C=((t,n={})=>(n.locale??e())===`zh-TW`?S(t):x(t)),fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),pe=((t={},n={})=>(n.locale??e())===`zh-TW`?`通知`:`notice`),me=((t={},n={})=>(n.locale??e())===`zh-TW`?`細節`:`details`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`表單回覆`:`form answers`),he=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息,來自`:`message from`),T=e=>`answer from ${e?.from}`,E=e=>`${e?.from} 的回答`,ge=((t,n={})=>(n.locale??e())===`zh-TW`?E(t):T(t)),D=e=>`request from ${e?.from}`,O=e=>`${e?.from} 的請求`,_e=((t,n={})=>(n.locale??e())===`zh-TW`?O(t):D(t)),k=e=>`message from ${e?.from}`,A=e=>`${e?.from} 的訊息`,ve=((t,n={})=>(n.locale??e())===`zh-TW`?A(t):k(t)),j=e=>`reply to your ask from ${e?.from}`,M=e=>`${e?.from} 回覆了你的詢問`,ye=((t,n={})=>(n.locale??e())===`zh-TW`?M(t):j(t)),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`記憶`:`memory`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`監看`:`monitor`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`本機`:`this computer`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友`:`teammate`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`提問,來自`:`question from`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`回報,來自`:`report from`),Se=((t={},n={})=>(n.locale??e())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`狀態:`:`status of`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),Ce=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台事件`:`tower event`),we=((t={},n={})=>(n.locale??e())===`zh-TW`?`在旁開啟`:`open beside`),B=e=>`Open image ${e?.n}`,V=e=>`打開圖片 ${e?.n}`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?V(t):B(t)),H=e=>`show all (${e?.size})`,U=e=>`顯示全部(${e?.size})`,Ee=((t,n={})=>(n.locale??e())===`zh-TW`?U(t):H(t)),De=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示全部參數`:`show all arguments`),W=e=>`◇ thought · ${e?.count} chars`,Oe=e=>`◇ 思考 · ${e?.count} 字元`,ke=((t,n={})=>(n.locale??e())===`zh-TW`?Oe(t):W(t)),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`這座塔台正在待命。有訊息進來時,sb server 會喚醒它跑一個 run;你在這裡送出的第一則訊息就會啟動它。`:`This tower stands by. The sb server wakes it for a run when a message arrives; your first message here starts that run.`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法取得`:`unavailable`),Ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`你`:`you`);function Pe(){let e=!0,t=0;return{get pinned(){return e},scrolled(n){e=n,n&&(t=0)},hold:()=>void(e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?C({count:t}):b()}}async function Fe(e,t,n,r){let i=()=>e.items.some(e=>e.id===n);for(;!i()&&e.before;)r(e.prepend(await t.older(e.before)));return i()?!0:(r(e.reset(await t.latest())),!1)}function Ie(e=600){let t=[],n,r=!1,i=new Set,a=new Map,o=new Map,s=e=>e.forEach(e=>(i.delete(e.id),e.tools?.forEach(e=>(o.delete(e.id),a.delete(e.id)))));function c(e,t){let n=[];for(let r of e)i.has(r.id)||(i.add(r.id),r.kind===`result`&&r.callId?(a.set(r.callId,r),o.has(r.callId)&&t.add(o.get(r.callId))):(r.tools?.forEach(e=>o.set(e.id,r.id)),n.push(r)));return n}let l=e=>({rebuild:!1,added:[],touched:[],dropped:[],front:!1,...e});return{get items(){return t},get before(){return n},get detached(){return r},result:e=>a.get(e),reset(e){return[t,n,r]=[[],e.before,!1],i.clear(),a.clear(),o.clear(),t=c(e.items,new Set),l({rebuild:!0,added:t})},append(i){if(r)return l({});let a=new Set,o=c(i,a);t.push(...o);let u=t.length>e?t.splice(0,t.length-e):[];return s(u),u.length&&(n=t[0].id),l({added:o,touched:[...a],dropped:u.map(e=>e.id)})},prepend(i){let a=new Set,o=c(i.items,a);t.unshift(...o),n=i.before;let u=t.length>e?t.splice(e):[];return s(u),u.length&&(r=!0),l({added:o,touched:[...a],dropped:u.map(e=>e.id),front:!0})}}}var Le=e=>a(e.role),Re=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,ze=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,Be={intercom_message:he,subagent_result:I,subagent_ping:F,subagent_status:L,"pi-loop-monitor":P,"memory-context":N,"doc-review":w,"straw-tower":z,"straw-link":R},G=e=>{let t=i(`<span class="ava"><svg><use/></svg></span>`);return t.querySelector(`use`).setAttribute(`href`,`#i-${o[e]??e}`),t};function Ve(e){let t=[],n=0;for(let i of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,i.index),r(`a`,{href:i[0],rel:`noopener noreferrer`,target:`_blank`},i[0])),n=i.index+i[0].length;return[...t,e.slice(n)]}function K(e,i,{who:a,link:o,docFor:f}){let p=Ie(),m=new Map,h=new Set,g=()=>h.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>f?.(e))):e.shown&&h.delete(e)),_=r(`div`,{class:`chat-list`}),v=r(`div`,{class:`chat-top`}),y=r(`div`,{class:`chat-live`}),b=r(`div`,{class:`chat-end`}),x=r(`button`,{class:`chat-pill`,type:`button`,hidden:``}),S=r(`p`,{class:`chat-empty`},fe()),C=r(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ie()},v,_,y,b);e.replaceChildren(C,x);let w=Pe(),T=!1,E=!1,D,O,k=0,A=!1,j,M=()=>A||j!==void 0,N=()=>(clearTimeout(j),j=setTimeout(()=>(j=void 0,w.pinned&&!p.detached&&F()),250)),P=(e=w.button(p.detached))=>(x.hidden=!e,x.textContent=e??``),F=()=>(w.jump(),O=void 0,C.scrollTop=C.scrollHeight,P());async function I(e){T=!0;let t=await Fe(p,i,e,e=>(q(e),X(e))).finally(()=>T=!1),r=m.get(e);if(D===e){if(!t||!r)return F();w.hold(),O=r,r.scrollIntoView({block:`center`}),n(r,`lit`),clearTimeout(k),k=window.setTimeout(()=>(O=void 0,r.classList.remove(`lit`)),2e3),P()}}let L=()=>D?void I(D):F(),R=(e,t,n,r)=>{e.disabled=!0,i.entry(n).then(n=>{let i=n&&r(n);if(i===void 0)return void(e.textContent=Me());t.textContent=i,e.remove()},()=>e.textContent=Me())};function z(e,t=0){if(!t||!i.pic)return null;let n=Array.from({length:t},(t,n)=>i.pic(e,n));return r(`div`,{class:`pics`},...n.map((e,t)=>{let i=r(`img`,{src:e,alt:ce({n:t+1}),loading:`lazy`,decoding:`async`}),a=r(`button`,{type:`button`,class:`pic`,"aria-label":Te({n:t+1})},i);return i.addEventListener(`error`,()=>a.replaceWith(r(`em`,{class:`pic-gone`},le()))),a.addEventListener(`click`,()=>void s(async()=>{let{lightbox:e}=await import(`./lightbox-DeyJW1Ta.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),a}))}function B(e,t){let n=p.result(e.id),i=r(`pre`,{class:`out`},n?.text??``),a=r(`pre`,{class:`args`},e.args??``),o=e.cut?r(`button`,{class:`more`,type:`button`},De()):null;o?.addEventListener(`click`,()=>R(o,a,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${oe()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let s=n?.more?r(`button`,{class:`more`,type:`button`},Ee({size:ze(n.bytes??0)})):null;s?.addEventListener(`click`,()=>R(s,i,n.id,e=>e.text));let c=e.name===`show_doc`&&f?r(`button`,{class:`more open`,type:`button`,hidden:``},we()):null;c?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>f?.(e)?.()))),c&&h.add({paths:e.summary.split(`, `),button:c}),c&&queueMicrotask(g);let l=r(`details`,{class:`act`},r(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},r(`b`,{class:`badge`}),r(`code`,null,e.name),r(`span`,{class:`sum`},e.summary),c),a,o,n&&r(`div`,{class:`result`},n.images?r(`em`,null,ue({count:n.images})):null,i,s)),u=n&&z(n.id,n.images);return u?[l,u]:[l]}let V=e=>r(`time`,null,Re(e.at)),H=(e,t,n,i)=>r(`article`,{class:`tx you`},r(`header`,null,V(e),r(`b`,null,Ne()),G(`user`)),r(`div`,{class:`bubble`,title:i},n?r(`small`,{class:`boss-flag`},ne()):null,...Ve(t),z(e.id,e.images))),U=(e,t,n,i={})=>r(`article`,{class:`tx sys`},r(`details`,{class:`notice`},r(`summary`,null,G(`comms`),r(`em`,null,de()),...t,V(e)),i.crashed?r(`small`,{class:`boss-flag`},ne()):null,r(`pre`,null,n),i.raw?r(`details`,{class:`notice-raw`},r(`summary`,null,me()),r(`pre`,{class:`raw`},i.raw)):null)),W=e=>{let t=l(e);return[he(),` `,t.name&&o(t.name)||t.name,t.id?` (${t.id})`:``,` · `,be()]},Oe=e=>e.kind===`link`?[{ask:_e,reply:ye,answer:ge,message:ve}[e.what]({from:e.from}),` · `,xe()]:e.kind===`intercom`?W(e.from):[e.kind===`server`?Se():Ce()];function K(e){switch(e.kind){case`user`:{let t=a().service?ee(e.text):void 0;if(t)return U(e,t.kind===`intercom`?W(t.from):[t.kind===`server`?Se():Ce()],e.text??``);let n=a().service?te(e.text):void 0;return H(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let t=a(),n=r(`pre`,{class:`thought-text`}),i=e.thought?r(`button`,{class:`thought`,type:`button`},e.thought<0?Ae():ke({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&i?.addEventListener(`click`,()=>R(i,n,e.id,e=>e.thoughtText)),r(`article`,{class:`tx in`},G(t.role),r(`div`,{class:`tx-body`},r(`header`,null,r(`b`,null,Le(t)),e.model?r(`span`,null,e.model):null,V(e),e.stop?r(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),i,n,e.text?r(`div`,{class:`md`},c(d(e.text))):null,e.error?r(`p`,{class:`fault`},e.error):null,...(e.tools??[]).flatMap(t=>B(t,e.id))))}case`bash`:return r(`article`,{class:`tx sys`},r(`details`,{class:`act`},r(`summary`,{"data-mark":e.exit?`error`:`done`},r(`b`,{class:`badge`}),r(`code`,null,`shell`),r(`span`,{class:`sum`},`! ${e.command}`),e.exit?r(`span`,{class:`stop`,"data-mark":`error`},se({code:e.exit})):null),e.text?r(`pre`,{class:`out`},e.text):null));case`notice`:{let t=u(e);return t?.kind===`boss`&&a().service?H(e,t.body,t.crashed,e.text??``):t&&t.kind!==`boss`?U(e,Oe(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):U(e,[Be[e.type??``]?.()??e.type??pe(),` `,e.from&&o(e.from)||(e.from??``)],e.text??``)}case`divider`:return r(`article`,{class:`tx rule`},r(`details`,null,r(`summary`,null,e.type===`compaction`?ae({tokens:(e.tokens??0).toLocaleString()}):re()),r(`pre`,null,e.text??``)));default:return r(`article`,{class:`tx note`},e.text??``,` `,V(e))}}function q(e){e.rebuild&&(m.clear(),_.replaceChildren());for(let t of e.dropped)m.get(t)?.remove(),m.delete(t);let t=e.added.map(e=>(m.set(e.id,K(e)),m.get(e.id)));e.front?_.prepend(...t):_.append(...t),E&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),S.remove();let n=a().service;S.textContent=n?.state===`standing`&&!n.run?je():fe(),p.items.length||_.append(S),v.hidden=!p.before,He()}let J=[],Y=new Map;function He(){let e=new Set;for(let n of J){let i=Date.parse(n.startedAt),a=p.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=i);if(a===0&&p.before)continue;let o=a<0?``:p.items[a].id,s=JSON.stringify([o,t(n)]),c=Y.get(n.id);if(e.add(n.id),c&&c.sig===s&&c.el.isConnected)continue;c?.el.remove();let l=t(n),u=r(`article`,{class:`tx rule conv-rule`},r(`div`,null,r(`b`,null,l.title),l.ended?r(`small`,null,l.ended):null));Y.set(n.id,{el:u,sig:s});let d=o?m.get(o):void 0;d?d.before(u):_.append(u)}for(let[t,n]of Y)e.has(t)||(n.el.remove(),Y.delete(t))}let X=e=>e.touched.forEach(e=>{let t=m.get(e),n=p.items.find(t=>t.id===e);if(t&&n){let r=K(n);t.classList.contains(`fresh`)&&Date.now()-Number(t.dataset.born??0)<400&&r.classList.add(`fresh`),t.replaceWith(r),m.set(e,r)}}),Ue=async()=>{if(!T&&p.before&&E){T=!0;try{let e=C.scrollHeight,t=p.prepend(await i.older(p.before));q(t),X(t),C.scrollTop+=C.scrollHeight-e}finally{T=!1}p.before&&C.clientHeight&&v.getBoundingClientRect().bottom>=C.getBoundingClientRect().top&&Ue()}};x.addEventListener(`click`,()=>{D=void 0,p.detached?i.latest().then(e=>(q(p.reset(e)),F())):F()});let Z=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void Ue(),{root:C}),new IntersectionObserver(e=>C.clientHeight&&(w.scrolled(e.at(-1).isIntersecting),P()),{root:C,rootMargin:`0px 0px 67px`})],Q,We=()=>(Q??(Z[0].observe(v),Z[1].observe(b)),clearTimeout(Q),Q=setTimeout(()=>(Q=void 0,Z.forEach(e=>e.disconnect())),600));C.addEventListener(`scroll`,()=>(We(),!A&&j!==void 0&&N()),{passive:!0}),C.addEventListener(`touchstart`,()=>(A=!0,clearTimeout(j),j=void 0),{passive:!0});for(let e of[`touchend`,`touchcancel`])C.addEventListener(e,()=>(A=!1,N()),{passive:!0});for(let e of[`wheel`,`touchstart`,`pointerdown`,`keydown`])C.addEventListener(e,()=>O=D=void 0,{passive:!0});let $=new ResizeObserver(()=>M()?void 0:w.pinned&&!p.detached?C.scrollTop=C.scrollHeight:O?.scrollIntoView({block:`center`}));return $.observe(_),$.observe(C),{log:C,docs:g,runs(e){JSON.stringify(e)!==JSON.stringify(J)&&(J=e,He())},apply(e){if(e.reset)q(p.reset({items:e.items??[],before:e.before})),E=!0,L();else if(e.items?.length){let t=p.append(e.items);q(t),X(t),w.arrived(t.added.length)&&!p.detached&&!M()?F():P()}},reveal(e){D=e,E&&L()},setLive(e,t){y.dataset.mark=t,y.lastChild?.textContent!==e&&y.replaceChildren(...e?[r(`b`,{class:`badge`}),r(`span`,null,e)]:[])}}}export{K as mountChat,ce as t};
|
|
2
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{O as t,Q as n,X as r,d as i,h as a,n as o,w as s}from"./index-CxTaPRCa.js";import{a as c,i as l,n as u,o as d,r as ee,t as te}from"./views-C9jvGick.js";var ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`分支摘要`:`branch summary`),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`通訊紀錄`:`Comms log`),f=e=>`context compacted · ${e?.tokens} tokens summarized`,p=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,ae=((t,n={})=>(n.locale??e())===`zh-TW`?p(t):f(t)),oe=((t={},n={})=>(n.locale??e())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),m=e=>`exit ${e?.code}`,h=e=>`結束碼 ${e?.code}`,se=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),g=e=>`Image ${e?.n}`,_=e=>`圖片 ${e?.n}`,ce=((t,n={})=>(n.locale??e())===`zh-TW`?_(t):g(t)),le=((t={},n={})=>(n.locale??e())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),v=e=>`${e?.count} image(s)`,y=e=>`${e?.count} 張圖片`,ue=((t,n={})=>(n.locale??e())===`zh-TW`?y(t):v(t)),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`收到`:`incoming`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`跳到最新`:`jump to latest`),x=e=>`${e?.count} new`,S=e=>`${e?.count} 則新訊息`,C=((t,n={})=>(n.locale??e())===`zh-TW`?S(t):x(t)),fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),pe=((t={},n={})=>(n.locale??e())===`zh-TW`?`通知`:`notice`),me=((t={},n={})=>(n.locale??e())===`zh-TW`?`細節`:`details`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`表單回覆`:`form answers`),he=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息,來自`:`message from`),T=e=>`answer from ${e?.from}`,E=e=>`${e?.from} 的回答`,ge=((t,n={})=>(n.locale??e())===`zh-TW`?E(t):T(t)),D=e=>`request from ${e?.from}`,O=e=>`${e?.from} 的請求`,_e=((t,n={})=>(n.locale??e())===`zh-TW`?O(t):D(t)),k=e=>`message from ${e?.from}`,A=e=>`${e?.from} 的訊息`,ve=((t,n={})=>(n.locale??e())===`zh-TW`?A(t):k(t)),j=e=>`reply to your ask from ${e?.from}`,M=e=>`${e?.from} 回覆了你的詢問`,ye=((t,n={})=>(n.locale??e())===`zh-TW`?M(t):j(t)),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`記憶`:`memory`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`監看`:`monitor`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`本機`:`this computer`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友`:`teammate`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`提問,來自`:`question from`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`回報,來自`:`report from`),Se=((t={},n={})=>(n.locale??e())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`狀態:`:`status of`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),Ce=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台事件`:`tower event`),we=((t={},n={})=>(n.locale??e())===`zh-TW`?`在旁開啟`:`open beside`),B=e=>`Open image ${e?.n}`,V=e=>`打開圖片 ${e?.n}`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?V(t):B(t)),H=e=>`show all (${e?.size})`,U=e=>`顯示全部(${e?.size})`,Ee=((t,n={})=>(n.locale??e())===`zh-TW`?U(t):H(t)),De=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示全部參數`:`show all arguments`),W=e=>`◇ thought · ${e?.count} chars`,Oe=e=>`◇ 思考 · ${e?.count} 字元`,ke=((t,n={})=>(n.locale??e())===`zh-TW`?Oe(t):W(t)),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`這座塔台正在待命。有訊息進來時,sb server 會喚醒它跑一個 run;你在這裡送出的第一則訊息就會啟動它。`:`This tower stands by. The sb server wakes it for a run when a message arrives; your first message here starts that run.`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法取得`:`unavailable`),Ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`你`:`you`);function Pe(){let e=!0,t=0;return{get pinned(){return e},scrolled(n){e=n,n&&(t=0)},hold:()=>void(e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?C({count:t}):b()}}async function Fe(e,t,n,r){let i=()=>e.items.some(e=>e.id===n);for(;!i()&&e.before;)r(e.prepend(await t.older(e.before)));return i()?!0:(r(e.reset(await t.latest())),!1)}function Ie(e=600){let t=[],n,r=!1,i=new Set,a=new Map,o=new Map,s=e=>e.forEach(e=>(i.delete(e.id),e.tools?.forEach(e=>(o.delete(e.id),a.delete(e.id)))));function c(e,t){let n=[];for(let r of e)i.has(r.id)||(i.add(r.id),r.kind===`result`&&r.callId?(a.set(r.callId,r),o.has(r.callId)&&t.add(o.get(r.callId))):(r.tools?.forEach(e=>o.set(e.id,r.id)),n.push(r)));return n}let l=e=>({rebuild:!1,added:[],touched:[],dropped:[],front:!1,...e});return{get items(){return t},get before(){return n},get detached(){return r},result:e=>a.get(e),reset(e){return[t,n,r]=[[],e.before,!1],i.clear(),a.clear(),o.clear(),t=c(e.items,new Set),l({rebuild:!0,added:t})},append(i){if(r)return l({});let a=new Set,o=c(i,a);t.push(...o);let u=t.length>e?t.splice(0,t.length-e):[];return s(u),u.length&&(n=t[0].id),l({added:o,touched:[...a],dropped:u.map(e=>e.id)})},prepend(i){let a=new Set,o=c(i.items,a);t.unshift(...o),n=i.before;let u=t.length>e?t.splice(e):[];return s(u),u.length&&(r=!0),l({added:o,touched:[...a],dropped:u.map(e=>e.id),front:!0})}}}var Le=e=>a(e.role),Re=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,ze=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,Be={intercom_message:he,subagent_result:I,subagent_ping:F,subagent_status:L,"pi-loop-monitor":P,"memory-context":N,"doc-review":w,"straw-tower":z,"straw-link":R},G=e=>{let t=i(`<span class="ava"><svg><use/></svg></span>`);return t.querySelector(`use`).setAttribute(`href`,`#i-${o[e]??e}`),t};function Ve(e){let t=[],n=0;for(let i of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,i.index),r(`a`,{href:i[0],rel:`noopener noreferrer`,target:`_blank`},i[0])),n=i.index+i[0].length;return[...t,e.slice(n)]}function K(e,i,{who:a,link:o,docFor:f}){let p=Ie(),m=new Map,h=new Set,g=()=>h.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>f?.(e))):e.shown&&h.delete(e)),_=r(`div`,{class:`chat-list`}),v=r(`div`,{class:`chat-top`}),y=r(`div`,{class:`chat-live`}),b=r(`div`,{class:`chat-end`}),x=r(`button`,{class:`chat-pill`,type:`button`,hidden:``}),S=r(`p`,{class:`chat-empty`},fe()),C=r(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ie()},v,_,y,b);e.replaceChildren(C,x);let w=Pe(),T=!1,E=!1,D,O,k=0,A=!1,j,M=()=>A||j!==void 0,N=()=>(clearTimeout(j),j=setTimeout(()=>(j=void 0,w.pinned&&!p.detached&&F()),250)),P=(e=w.button(p.detached))=>(x.hidden=!e,x.textContent=e??``),F=()=>(w.jump(),O=void 0,C.scrollTop=C.scrollHeight,P());async function I(e){T=!0;let t=await Fe(p,i,e,e=>(q(e),X(e))).finally(()=>T=!1),r=m.get(e);if(D===e){if(!t||!r)return F();w.hold(),O=r,r.scrollIntoView({block:`center`}),n(r,`lit`),clearTimeout(k),k=window.setTimeout(()=>(O=void 0,r.classList.remove(`lit`)),2e3),P()}}let L=()=>D?void I(D):F(),R=(e,t,n,r)=>{e.disabled=!0,i.entry(n).then(n=>{let i=n&&r(n);if(i===void 0)return void(e.textContent=Me());t.textContent=i,e.remove()},()=>e.textContent=Me())};function z(e,t=0){if(!t||!i.pic)return null;let n=Array.from({length:t},(t,n)=>i.pic(e,n));return r(`div`,{class:`pics`},...n.map((e,t)=>{let i=r(`img`,{src:e,alt:ce({n:t+1}),loading:`lazy`,decoding:`async`}),a=r(`button`,{type:`button`,class:`pic`,"aria-label":Te({n:t+1})},i);return i.addEventListener(`error`,()=>a.replaceWith(r(`em`,{class:`pic-gone`},le()))),a.addEventListener(`click`,()=>void s(async()=>{let{lightbox:e}=await import(`./lightbox-2K2fMlal.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),a}))}function B(e,t){let n=p.result(e.id),i=r(`pre`,{class:`out`},n?.text??``),a=r(`pre`,{class:`args`},e.args??``),o=e.cut?r(`button`,{class:`more`,type:`button`},De()):null;o?.addEventListener(`click`,()=>R(o,a,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${oe()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let s=n?.more?r(`button`,{class:`more`,type:`button`},Ee({size:ze(n.bytes??0)})):null;s?.addEventListener(`click`,()=>R(s,i,n.id,e=>e.text));let c=e.name===`show_doc`&&f?r(`button`,{class:`more open`,type:`button`,hidden:``},we()):null;c?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>f?.(e)?.()))),c&&h.add({paths:e.summary.split(`, `),button:c}),c&&queueMicrotask(g);let l=r(`details`,{class:`act`},r(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},r(`b`,{class:`badge`}),r(`code`,null,e.name),r(`span`,{class:`sum`},e.summary),c),a,o,n&&r(`div`,{class:`result`},n.images?r(`em`,null,ue({count:n.images})):null,i,s)),u=n&&z(n.id,n.images);return u?[l,u]:[l]}let V=e=>r(`time`,null,Re(e.at)),H=(e,t,n,i)=>r(`article`,{class:`tx you`},r(`header`,null,V(e),r(`b`,null,Ne()),G(`user`)),r(`div`,{class:`bubble`,title:i},n?r(`small`,{class:`boss-flag`},ne()):null,...Ve(t),z(e.id,e.images))),U=(e,t,n,i={})=>r(`article`,{class:`tx sys`},r(`details`,{class:`notice`},r(`summary`,null,G(`comms`),r(`em`,null,de()),...t,V(e)),i.crashed?r(`small`,{class:`boss-flag`},ne()):null,r(`pre`,null,n),i.raw?r(`details`,{class:`notice-raw`},r(`summary`,null,me()),r(`pre`,{class:`raw`},i.raw)):null)),W=e=>{let t=l(e);return[he(),` `,t.name&&o(t.name)||t.name,t.id?` (${t.id})`:``,` · `,be()]},Oe=e=>e.kind===`link`?[{ask:_e,reply:ye,answer:ge,message:ve}[e.what]({from:e.from}),` · `,xe()]:e.kind===`intercom`?W(e.from):[e.kind===`server`?Se():Ce()];function K(e){switch(e.kind){case`user`:{let t=a().service?ee(e.text):void 0;if(t)return U(e,t.kind===`intercom`?W(t.from):[t.kind===`server`?Se():Ce()],e.text??``);let n=a().service?te(e.text):void 0;return H(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let t=a(),n=r(`pre`,{class:`thought-text`}),i=e.thought?r(`button`,{class:`thought`,type:`button`},e.thought<0?Ae():ke({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&i?.addEventListener(`click`,()=>R(i,n,e.id,e=>e.thoughtText)),r(`article`,{class:`tx in`},G(t.role),r(`div`,{class:`tx-body`},r(`header`,null,r(`b`,null,Le(t)),e.model?r(`span`,null,e.model):null,V(e),e.stop?r(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),i,n,e.text?r(`div`,{class:`md`},c(d(e.text))):null,e.error?r(`p`,{class:`fault`},e.error):null,...(e.tools??[]).flatMap(t=>B(t,e.id))))}case`bash`:return r(`article`,{class:`tx sys`},r(`details`,{class:`act`},r(`summary`,{"data-mark":e.exit?`error`:`done`},r(`b`,{class:`badge`}),r(`code`,null,`shell`),r(`span`,{class:`sum`},`! ${e.command}`),e.exit?r(`span`,{class:`stop`,"data-mark":`error`},se({code:e.exit})):null),e.text?r(`pre`,{class:`out`},e.text):null));case`notice`:{let t=u(e);return t?.kind===`boss`&&a().service?H(e,t.body,t.crashed,e.text??``):t&&t.kind!==`boss`?U(e,Oe(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):U(e,[Be[e.type??``]?.()??e.type??pe(),` `,e.from&&o(e.from)||(e.from??``)],e.text??``)}case`divider`:return r(`article`,{class:`tx rule`},r(`details`,null,r(`summary`,null,e.type===`compaction`?ae({tokens:(e.tokens??0).toLocaleString()}):re()),r(`pre`,null,e.text??``)));default:return r(`article`,{class:`tx note`},e.text??``,` `,V(e))}}function q(e){e.rebuild&&(m.clear(),_.replaceChildren());for(let t of e.dropped)m.get(t)?.remove(),m.delete(t);let t=e.added.map(e=>(m.set(e.id,K(e)),m.get(e.id)));e.front?_.prepend(...t):_.append(...t),E&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),S.remove();let n=a().service;S.textContent=n?.state===`standing`&&!n.run?je():fe(),p.items.length||_.append(S),v.hidden=!p.before,He()}let J=[],Y=new Map;function He(){let e=new Set;for(let n of J){let i=Date.parse(n.startedAt),a=p.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=i);if(a===0&&p.before)continue;let o=a<0?``:p.items[a].id,s=JSON.stringify([o,t(n)]),c=Y.get(n.id);if(e.add(n.id),c&&c.sig===s&&c.el.isConnected)continue;c?.el.remove();let l=t(n),u=r(`article`,{class:`tx rule conv-rule`},r(`div`,null,r(`b`,null,l.title),l.ended?r(`small`,null,l.ended):null));Y.set(n.id,{el:u,sig:s});let d=o?m.get(o):void 0;d?d.before(u):_.append(u)}for(let[t,n]of Y)e.has(t)||(n.el.remove(),Y.delete(t))}let X=e=>e.touched.forEach(e=>{let t=m.get(e),n=p.items.find(t=>t.id===e);if(t&&n){let r=K(n);t.classList.contains(`fresh`)&&Date.now()-Number(t.dataset.born??0)<400&&r.classList.add(`fresh`),t.replaceWith(r),m.set(e,r)}}),Ue=async()=>{if(!T&&p.before&&E){T=!0;try{let e=C.scrollHeight,t=p.prepend(await i.older(p.before));q(t),X(t),C.scrollTop+=C.scrollHeight-e}finally{T=!1}p.before&&C.clientHeight&&v.getBoundingClientRect().bottom>=C.getBoundingClientRect().top&&Ue()}};x.addEventListener(`click`,()=>{D=void 0,p.detached?i.latest().then(e=>(q(p.reset(e)),F())):F()});let Z=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void Ue(),{root:C}),new IntersectionObserver(e=>C.clientHeight&&(w.scrolled(e.at(-1).isIntersecting),P()),{root:C,rootMargin:`0px 0px 67px`})],Q,We=()=>(Q??(Z[0].observe(v),Z[1].observe(b)),clearTimeout(Q),Q=setTimeout(()=>(Q=void 0,Z.forEach(e=>e.disconnect())),600));C.addEventListener(`scroll`,()=>(We(),!A&&j!==void 0&&N()),{passive:!0}),C.addEventListener(`touchstart`,()=>(A=!0,clearTimeout(j),j=void 0),{passive:!0});for(let e of[`touchend`,`touchcancel`])C.addEventListener(e,()=>(A=!1,N()),{passive:!0});for(let e of[`wheel`,`touchstart`,`pointerdown`,`keydown`])C.addEventListener(e,()=>O=D=void 0,{passive:!0});let $=new ResizeObserver(()=>M()?void 0:w.pinned&&!p.detached?C.scrollTop=C.scrollHeight:O?.scrollIntoView({block:`center`}));return $.observe(_),$.observe(C),{log:C,docs:g,runs(e){JSON.stringify(e)!==JSON.stringify(J)&&(J=e,He())},apply(e){if(e.reset)q(p.reset({items:e.items??[],before:e.before})),E=!0,L();else if(e.items?.length){let t=p.append(e.items);q(t),X(t),w.arrived(t.added.length)&&!p.detached&&!M()?F():P()}},reveal(e){D=e,E&&L()},setLive(e,t){y.dataset.mark=t,y.lastChild?.textContent!==e&&y.replaceChildren(...e?[r(`b`,{class:`badge`}),r(`span`,null,e)]:[])}}}export{K as mountChat,ce as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-Ccbha5pD.js";import{n,t as r}from"./unit_count-
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-Ccbha5pD.js";import{n,t as r}from"./unit_count-CWBSU9VR.js";import{C as i,S as a,X as o,_ as s,a as c,d as l,g as u,h as d,i as f,it as p,l as m,m as h,o as g,v as _,x as v}from"./index-CxTaPRCa.js";var y=((t={},n={})=>(n.locale??e())===`zh-TW`?`關閉清單`:`Close the list`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`切換到其他單位`:`Switch to a unit`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`回到主地圖`:`Back to the map`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`所有單位`:`All units`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`指揮中`:`commanding`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`已結束`:`ended`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`錯誤`:`error`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`閒置`:`idle`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`無狀態`:`unknown`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`等待`:`waiting`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`工作中`:`working`),A=.4;function j(e,t,n){let[r,i]=[Math.abs(e),Math.abs(t)];return Math.max(r,i)<10?`wait`:r>=1.7*i&&(n?e<0:e>0)?`drag`:`pass`}var M=(e,t,n)=>Math.abs(n)>=.45?n>0:e>=t*A,N=(e,t)=>t||e.some(e=>e.editable||e.sink||e.scrollsX||[`input`,`textarea`,`select`].includes(e.tag));function P(e){let t=e,n=getComputedStyle(e).overflowX;return{tag:e.tagName.toLowerCase(),editable:t.isContentEditable,sink:e.matches(`.composer, .term-sink`),scrollsX:(n===`auto`||n===`scroll`)&&e.scrollWidth>e.clientWidth+1}}var F=e=>{let t=[];for(let n=e;n;n=n.parentElement)t.push(P(n));return t},I={working:k,waiting:O,idle:E,done:w,error:T,unknown:D,commanding:C},L=(e,t,n)=>(t?w:I[e])({},n&&{locale:n}),R=(e,t)=>t.flatMap(t=>[t,...t.subs.map(e=>({...e,sub:!0}))].map(t=>({id:t.key,key:t.key,ws:e,name:t.name,role:t.role,mark:t.mark,note:t.note,ended:!!t.ended,sub:`sub`in t,control:!!t.control})));function z(e){return e.bases.flatMap(e=>{let t=[{id:`tower`,rows:e.tower?R(e.id,[{...e.tower,role:`tower`}]):[]},...e.tabs.map(t=>({id:t.id,label:p({label:t.label}),rows:R(e.id,t.units)})),{id:`outside`,label:n(),rows:R(e.id,e.outside)}].filter(e=>e.rows.length);return t.length?[{id:e.id,label:e.label,mark:e.mark,groups:t}]:[]})}var B=e=>e.role===`main`&&e.mark===`idle`,V=e=>e.reduce((e,t)=>(t.sub?e.at(-1)?.subs.push(t):e.push({...t,subs:[]}),e),[]),H=()=>l(`<div class="unit"><div class="card"><a class="hit"></a>${f}<div class="meta"><span class="name"></span><span class="line"><em class="role"></em><b class="dstate"></b><span class="note"></span></span></div><button type="button" class="quit-btn" data-close="unit" hidden></button></div><div class="subs"></div></div>`),U=()=>l(`<div class="unit tower-row"><div class="trow"><a class="tower-go">${f}</a><button type="button" class="pair-btn tower-add"></button></div><div class="subs"></div></div>`),W=()=>l(`<section class="dbase"><h3><a></a><small></small></h3><div class="dgroups"></div></section>`),G=()=>l(`<div class="dgroup"><h4></h4><div class="drows"></div></div>`),K=()=>matchMedia(`(max-width: 640px)`).matches;function q(){let e=o(`div`,{class:`drawer-body`}),n=o(`button`,{type:`button`,class:`x`,"aria-label":y()},`×`),l=o(`a`,{class:`drawer-map`},x()),f=o(`button`,{type:`button`,class:`pair-btn`,"data-close":`dismiss-all`,hidden:``}),p=o(`div`,{class:`drawer-sweep`,hidden:``},f);c(l,{view:`map`});let C=o(`aside`,{class:`drawer`,"aria-label":b()},o(`header`,null,o(`b`,null,S()),n),e,o(`footer`,{class:`drawer-foot`},p,l)),w=o(`div`,{class:`drawer-veil`});document.body.append(w,C);let T,E,D=!1,O=0,k=0,A,P=()=>{i(f,T??{bases:[]}),p.hidden=f.hidden;let n=(e,t)=>{c(e.querySelector(`.hit`),{view:`session`,ws:t.ws,key:t.key}),e.querySelector(`.hit`).setAttribute(`aria-label`,`${t.name}: ${L(t.mark,t.ended)}`),e.classList.toggle(`current`,t.key===E),e.toggleAttribute(`data-dismiss`,t.role===`subagent`&&t.ended),e.dataset.key=t.key,h(e,t.mark),m(e.querySelector(`.plate`),t.role,t.mark),_(e,`.name`,t.name),_(e,`.role`,d(t.role)),_(e,`.dstate`,L(t.mark,t.ended)),u(e,`.note`,t.note,t.mark,t.note?void 0:``);let r=e.querySelector(`:scope > .card > .quit-btn`);B(t)?v(r,t):r.hidden=!0,s(e.querySelector(`.subs`),t.subs??[],H,n)},a=(e,r)=>{let i=e.querySelector(`.tower-go`),a=e.querySelector(`.tower-add`),o=T?.bases.find(e=>e.id===r.ws);c(i,{view:`session`,ws:r.ws,key:r.key}),i.setAttribute(`aria-label`,`${r.name}: ${L(r.mark,r.ended)}`),e.classList.toggle(`current`,r.key===E),e.dataset.key=r.key,h(e,r.mark),m(i.querySelector(`.plate`),`tower`,r.mark),a.hidden=!o,o&&(g(a,o),a.textContent=`+`,a.setAttribute(`aria-label`,t({base:o.label}))),s(e.querySelector(`.subs`),r.subs,H,n)};s(e,z(T??{bases:[]}),W,(e,t)=>{h(e,t.mark),_(e,`h3 a`,t.label),c(e.querySelector(`h3 a`),{view:`workspace`,ws:t.id}),_(e,`small`,r({count:t.groups.reduce((e,t)=>e+t.rows.length,0)})),s(e.querySelector(`.dgroups`),t.groups,G,(e,t)=>{_(e,`h4`,t.label??``),e.querySelector(`h4`).toggleAttribute(`hidden`,!t.label),t.id===`tower`?s(e.querySelector(`.drows`),V(t.rows),U,a):s(e.querySelector(`.drows`),V(t.rows),H,n)})})},I=e=>{O=Math.max(0,Math.min(k,e)),C.style.setProperty(`--dx`,`${O}px`),w.style.opacity=String(k?O/k:0),w.style.pointerEvents=O>0?`auto`:`none`},R=e=>{D=e,C.classList.toggle(`on`,e),C.inert=!e,document.documentElement.classList.remove(`drawer-drag`),I(e?k:0)},q=()=>{k=C.offsetWidth,P(),C.classList.add(`on`),document.documentElement.classList.add(`drawer-drag`)};C.inert=!0,document.addEventListener(`touchstart`,e=>{let t=e.target,n=C.contains(t)||t===w;if(A=void 0,!K()||e.touches.length!==1||document.querySelector(`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`)||(D?!n:N(F(t),!!getSelection()?.toString())))return;let r=e.touches[0],i=D?t.closest(`.unit[data-dismiss] > .card`)??void 0:void 0;A={x0:r.clientX,y0:r.clientY,mode:`wait`,was:D,base:O,last:r.clientX,at:performance.now(),v:0,card:i}},{passive:!0}),document.addEventListener(`touchmove`,e=>{if(!A||A.mode===`pass`)return;let t=e.touches[0],n=t.clientX-A.x0,r=t.clientY-A.y0;if(A.mode===`wait`){let e=j(n,r,A.was);if(e===`wait`)return;if(e===`pass`&&A.card&&j(n,r,!1)===`drag`)A.mode=`card`,A.card.classList.add(`swiping`);else if(e===`pass`)return void(A.mode=`pass`);else A.mode=`drag`,q()}e.preventDefault();let i=performance.now();if(A.v=(t.clientX-A.last)/Math.max(1,i-A.at),[A.last,A.at]=[t.clientX,i],A.mode!==`card`)return I(A.base+n);let a=Math.max(0,n);A.card.style.setProperty(`--sx`,`${a}px`),A.card.style.setProperty(`--so`,String(1-a/A.card.offsetWidth))},{passive:!1});let J=(e,t)=>{e.classList.remove(`swiping`),e.style.removeProperty(`--sx`),e.style.removeProperty(`--so`),t&&(e.classList.add(`gone`),a({key:e.parentElement.dataset.key}).then(t=>t||e.classList.remove(`gone`)))},Y=e=>{let t=A;A=void 0,t?.mode===`drag`&&R(M(O,k,t.v)),t?.mode===`card`&&J(t.card,e.type===`touchend`&&M(Math.max(0,t.last-t.x0),t.card.offsetWidth,t.v))};return document.addEventListener(`touchend`,Y),document.addEventListener(`touchcancel`,Y),w.addEventListener(`click`,()=>R(!1)),C.addEventListener(`click`,e=>e.target.closest(`a[data-route], button[data-open], .x`)&&R(!1)),document.addEventListener(`keydown`,e=>D&&e.key===`Escape`&&(e.preventDefault(),R(!1)),!0),document.addEventListener(`sb-drawer`,()=>(D||q(),R(!D))),{net(e){T=e,D&&P()},route(e){E=e.view===`session`?e.key:void 0,l.toggleAttribute(`aria-current`,e.view===`map`),D&&P()}}}export{q as mountDrawer};
|