From c7ef17fb0f77a2d5dbf8e5c800ace6bdf0451c33 Mon Sep 17 00:00:00 2001 From: whackur Date: Sat, 7 Nov 2026 13:13:38 +0900 Subject: [PATCH 1/2] feat(web): add Shift+Left terminal key --- docs/keybindings.md | 2 +- docs/web-viewer.md | 2 +- ...minal-BuLVJ0Wx.js => Terminal-N9POd-x9.js} | 2 +- .../{index-C0YZmztO.js => index-VyUeVokt.js} | 4 +-- viewer-ui/dist/index.html | 2 +- .../components/terminal/TermKeyBar.test.tsx | 33 +++++++++++++++++++ viewer-ui/src/lib/terminal/termKeys.test.ts | 10 ++++++ viewer-ui/src/lib/terminal/termKeys.ts | 3 ++ 8 files changed, 52 insertions(+), 6 deletions(-) rename viewer-ui/dist/assets/{Terminal-BuLVJ0Wx.js => Terminal-N9POd-x9.js} (96%) rename viewer-ui/dist/assets/{index-C0YZmztO.js => index-VyUeVokt.js} (99%) create mode 100644 viewer-ui/src/components/terminal/TermKeyBar.test.tsx diff --git a/docs/keybindings.md b/docs/keybindings.md index 8f842b06..8c43c02f 100644 --- a/docs/keybindings.md +++ b/docs/keybindings.md @@ -48,7 +48,7 @@ From `md` width up, a hint line under the footer mirrors the TUI's hint bar. Idl The leader followed by `t`, `w`, `s`, `z`, `r`, `c`, `l`, `b`, `o`, `x`, `p`, or `u` does what the matching bullet under [Leader commands](#leader-commands) describes, using the same controls the buttons use. In the browser, `r` is the sizing recovery command and `z` remains an alias. The focus keys `1`, `2`, and `3`–`9`, `0` address the list, the content pane, and terminal panes 1–8 with the same numbering. `Ctrl+Shift+Left` and `Ctrl+Shift+Right` switch projects exactly as they do in the TUI. -`Shift+Left` and `Shift+Right` walk the same ring — the list, the content pane, then each terminal pane — among whatever is on screen: a maximized terminal offers its panes alone, a maximized upper region the list and the content pane, and a narrow screen only the view its bottom navigation chose, which is what the TUI's fullscreen rules amount to. Stepping onto a pane while another is zoomed moves the zoom to it, as the TUI's fullscreen cycle does. A control inside a region — the sidebar's filter, a pane's toolbar — counts as that region; a keyboard nowhere on the ring (in the header or the footer, say) enters it at the near end. The chord is the page's wherever it is not typing, so it never reaches a pane as `ESC[1;2D`; in a text field it stays the browser's word selection. +`Shift+Left` and `Shift+Right` walk the same ring — the list, the content pane, then each terminal pane — among whatever is on screen: a maximized terminal offers its panes alone, a maximized upper region the list and the content pane, and a narrow screen only the view its bottom navigation chose, which is what the TUI's fullscreen rules amount to. Stepping onto a pane while another is zoomed moves the zoom to it, as the TUI's fullscreen cycle does. A control inside a region — the sidebar's filter, a pane's toolbar — counts as that region; a keyboard nowhere on the ring (in the header or the footer, say) enters it at the near end. The physical chord is the page's wherever it is not typing, so it never reaches a pane as `ESC[1;2D`; in a text field it stays the browser's word selection. To send `Shift+Left` to the active terminal instead, for example to answer a Codex question prompt, use the key bar's `⇧←` button. `Shift+PageUp` and `Shift+PageDown` scroll the focused pane a page, as in the TUI — xterm.js binds them itself. diff --git a/docs/web-viewer.md b/docs/web-viewer.md index 8da1dff1..b64969d5 100644 --- a/docs/web-viewer.md +++ b/docs/web-viewer.md @@ -22,7 +22,7 @@ From `md` width up, the project tabs run across the header or down the page's le The terminal toolbar can add a pane, show panes as a grid or tabs (from `md` width up; below it the panel is always tabbed and the control is hidden, since a split grid would give each pane fewer columns than a command line needs), maximize the terminal panel, claim sizing for this screen, show or hide the on-screen key bar, and open a message form for the active pane. The key-bar toggle remains in the terminal toolbar. A project has up to 8 panes. Pane order and zoom are shared while the session runs; they are not restored after the session ends. A PTY has one size, so the client whose most recent key/paste/click/touch/wheel interaction claimed sizing determines the grid rendered by every client. A new connection, browser resize, focus change, or reconnect leaves the current owner in place; the terminal toolbar's sizing button remains available for manual recovery. -On phones and other narrow layouts, the bottom navigation switches among `Repo`, `Content`, and `Terminal`. Swiping the row of terminal tabs scrolls it and tapping a tab switches to it; to reorder by touch, rest a finger on a tab until it dims, then drag (a mouse still drags at once). Scrolling a list, the content pane or a terminal back to its top does not trigger the browser's pull-to-refresh; pulling down on the header or another fixed bar still refreshes. Touch-dragging a terminal scrolls it; the key bar supplies Escape, Tab, arrows, and control keys when a soft keyboard cannot. A soft keyboard opening does not resize the panes: the PTY keeps its grid and the pane shows the part of it around the cursor — the bottom of a full screen, the top of a terminal just opened — so a full-screen program is not made to repaint from the top every time the keyboard comes and goes. Layout changes made while the keyboard is up are applied once it closes. Its `Ctrl` button is a latch for the next typed character. The keyboard-bar preference is stored in the browser, so it can be changed from the terminal toolbar. The shortcut leader key is stored in the browser too, and can be rebound or switched off from the shortcut sheet. +On phones and other narrow layouts, the bottom navigation switches among `Repo`, `Content`, and `Terminal`. Swiping the row of terminal tabs scrolls it and tapping a tab switches to it; to reorder by touch, rest a finger on a tab until it dims, then drag (a mouse still drags at once). Scrolling a list, the content pane or a terminal back to its top does not trigger the browser's pull-to-refresh; pulling down on the header or another fixed bar still refreshes. Touch-dragging a terminal scrolls it; the key bar supplies Escape, Tab, Shift+Tab, arrows, Shift+Left (`⇧←`), and control keys when a soft keyboard cannot. A soft keyboard opening does not resize the panes: the PTY keeps its grid and the pane shows the part of it around the cursor — the bottom of a full screen, the top of a terminal just opened — so a full-screen program is not made to repaint from the top every time the keyboard comes and goes. Layout changes made while the keyboard is up are applied once it closes. Its `Ctrl` button is a latch for the next typed character. The keyboard-bar preference is stored in the browser, so it can be changed from the terminal toolbar. The shortcut leader key is stored in the browser too, and can be rebound or switched off from the shortcut sheet. The message form (the pencil in the terminal toolbar, or the leader followed by `m`) exists because xterm's hidden input field drops and repeats characters from an IME on iPadOS, which makes Korean typed straight into a pane unreliable; an ordinary text field composes it correctly. Send writes the message into the active pane and presses Return, so it runs at once; Cmd/Ctrl+Return does the same from the keyboard, and Return alone adds a line. When the program has turned on bracketed paste, a multi-line message goes in as one paste rather than one command per line. Clear empties the field. A draft is kept per pane for the life of the page, so closing the form does not lose it. The TUI has no such form: it reads keys from the host terminal, whose IME already composes. diff --git a/viewer-ui/dist/assets/Terminal-BuLVJ0Wx.js b/viewer-ui/dist/assets/Terminal-N9POd-x9.js similarity index 96% rename from viewer-ui/dist/assets/Terminal-BuLVJ0Wx.js rename to viewer-ui/dist/assets/Terminal-N9POd-x9.js index 607d01b0..345e4e29 100644 --- a/viewer-ui/dist/assets/Terminal-BuLVJ0Wx.js +++ b/viewer-ui/dist/assets/Terminal-N9POd-x9.js @@ -1,4 +1,4 @@ -import{t as e}from"./jsx-runtime-EIAPxkjE.js";import{t}from"./react-BPk_wmJm.js";import{$ as n,A as r,B as i,C as a,E as o,F as s,H as c,I as l,K as u,M as d,N as f,P as p,R as m,S as h,T as g,U as _,X as v,_ as y,_t as b,a as x,c as ee,ct as te,d as S,f as C,ft as w,gt as T,h as ne,ht as E,j as re,l as ie,m as ae,n as D,o as O,p as k,pt as oe,r as se,s as ce,st as le,t as ue,u as de,w as fe,x as pe,y as me}from"./lastPane-Kg5ZBFNS.js";import{t as he}from"./api-BwgkHPos.js";var A=t();function ge(e,t){for(;t;)[e,t]=[t,e%t];return e}function _e(e,t){switch(e){case 1:return[1];case 2:return t?[2]:[1,1];case 3:return[2,1];case 4:return[2,2];case 5:return[3,2];case 6:return[3,3];case 7:return[4,3];default:return[4,4]}}function ve(e,t){let n=_e(e,t),r=n.reduce((e,t)=>e*t/ge(e,t),1),i=[];return n.forEach((e,t)=>{let n=r/e;for(let r=0;r1,h=()=>{c.current!==null&&clearTimeout(c.current),c.current=null},g=()=>{h(),l.current=!1,i.current=null,a.current=null,o.current=null,s.current=!1,d(null),p(null)};return{draggingPane:u,dragOverPane:f,reorderable:m,endPaneDrag:g,onPaneDragStart:(e,t,r)=>{if(e.target.closest(`button`))return;let o=r?.holdToDrag===!0&&e.pointerType===`touch`;if(o||n(t),e.button!==0||!m&&!o)return;if(i.current=t,a.current={x:e.clientX,y:e.clientY},s.current=!1,!o){e.currentTarget.setPointerCapture(e.pointerId);return}if(l.current=!0,!m)return;let u=e.currentTarget,f=e.pointerId;h(),c.current=setTimeout(()=>{c.current=null,l.current=!1,s.current=!0,d(t);try{u.setPointerCapture(f)}catch{g()}},350)},onPaneDragMove:e=>{let t=i.current,n=a.current;if(t===null||n===null)return;if(!s.current){if(!(Math.hypot(e.clientX-n.x,e.clientY-n.y)>=4))return;if(l.current){g();return}}s.current=!0,d(t);let r=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-pane-id]`),c=r?Number(r.getAttribute(`data-pane-id`)):null,u=c!==null&&c!==t?c:null;o.current=u,p(u)},onPaneDragEnd:()=>{let t=i.current,a=o.current;t!==null&&l.current&&n(t),t!==null&&s.current&&a!==null&&r(ee(e,t,a)),g()}}}function be(e){return typeof e==`number`&&Number.isSafeInteger(e)}function xe(e){return be(e)&&e>=0}function Se(e){return typeof e==`string`&&/^[0-9]+$/.test(e)}function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r;switch(n.type){case`created`:r=xe(n.pane)&&xe(n.rows)&&xe(n.cols)&&(n.client===void 0||xe(n.client))&&(n.title===void 0||typeof n.title==`string`);break;case`exited`:r=xe(n.pane);break;case`resized`:r=xe(n.pane)&&xe(n.rows)&&xe(n.cols);break;case`hello`:r=xe(n.client)&&xe(n.panes);break;case`replay_complete`:r=!0;break;case`size_owner`:r=typeof n.owned==`boolean`&&(n.generation===void 0||Se(n.generation));break;case`error`:r=typeof n.message==`string`;break;case`reordered`:r=Array.isArray(n.order)&&n.order.every(xe);break;case`zoomed`:r=n.pane===null||xe(n.pane);break;case`pending`:r=xe(n.count);break;case`attention`:r=xe(n.pane)&&(n.message===void 0||typeof n.message==`string`);break;case`recovery`:r=xe(n.pane)&&typeof n.state==`string`&&(n.detail===void 0||typeof n.detail==`string`)&&(n.deadline_epoch===void 0||be(n.deadline_epoch))&&xe(n.attempt);break;default:return null}return r?n:null}function we(e,t){return!e||e.readyState!==WebSocket.OPEN?!1:(e.send(JSON.stringify(t)),!0)}function Te(e){return e.byteLength<4?null:{pane:new DataView(e).getUint32(0,!0),data:new Uint8Array(e,4)}}function Ee(e){let[t,n]=(0,A.useState)({});return{recovery:t,setRecovery:n,cancelRecovery:(0,A.useCallback)(t=>{we(e.current,{type:`cancel_recovery`,pane:t})},[e])}}var De=240,Oe=`cubic-bezier(0.2, 0, 0, 1)`;function ke(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ae(e){return e instanceof HTMLElement&&typeof e.animate==`function`&&!ke()}function je(e,t){if(!Ae(e)){t();return}let n=!1,r=()=>{n||(n=!0,t())},i=e.animate([{opacity:1,transform:`translateY(0)`},{opacity:0,transform:`translateY(12px)`}],{duration:200,easing:Oe,fill:`forwards`});i.onfinish=r,i.oncancel=r}function Me(e){Ae(e)&&e.animate([{opacity:0},{opacity:1}],{duration:De,easing:Oe})}var Ne={esc:`\x1B`,tab:` `,"shift-tab":`\x1B[Z`,"ctrl-b":``,"ctrl-c":``,"ctrl-d":``,"ctrl-z":``,"ctrl-l":`\f`,"ctrl-r":``,up:`\x1B[A`,down:`\x1B[B`,right:`\x1B[C`,left:`\x1B[D`},Pe={up:`\x1BOA`,down:`\x1BOB`,right:`\x1BOC`,left:`\x1BOD`};function Fe(e,t=!1){if(t){let t=Pe[e];if(t)return t}return Ne[e]}function Ie(e){if(e.length!==1)return null;if(e===` `)return`\0`;if(e===`?`)return``;let t=e.charCodeAt(0);return t>=97&&t<=122&&(t-=32),t<64||t>95?null:String.fromCharCode(t&31)}function Le(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:Ie(t)??t,armed:!1}:{data:t,armed:!1}}function Re(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:[...t].length===1?`\x1b${t}`:t,armed:!1}:{data:t,armed:!1}}function ze(e){return e===`shown`||e===`hidden`?e:null}function Be(e,t){return e||t<768}var Ve=[{kind:`key`,key:`esc`,label:`Esc`,aria:`Escape`},{kind:`key`,key:`tab`,label:`Tab`,aria:`Tab`},{kind:`key`,key:`shift-tab`,label:`⇧Tab`,aria:`Shift Tab`},{kind:`latch`,latch:`alt`,label:`Alt`,aria:`Alt for the next key`},{kind:`latch`,latch:`ctrl`,label:`Ctrl`,aria:`Control for the next key`},{kind:`key`,key:`ctrl-b`,label:`^B`,aria:`Control B`},{kind:`key`,key:`ctrl-c`,label:`^C`,aria:`Control C`},{kind:`key`,key:`ctrl-d`,label:`^D`,aria:`Control D`},{kind:`key`,key:`ctrl-z`,label:`^Z`,aria:`Control Z`},{kind:`key`,key:`ctrl-l`,label:`^L`,aria:`Control L`},{kind:`key`,key:`ctrl-r`,label:`^R`,aria:`Control R`},{kind:`key`,key:`left`,label:`←`,aria:`Left arrow`},{kind:`key`,key:`down`,label:`↓`,aria:`Down arrow`},{kind:`key`,key:`up`,label:`↑`,aria:`Up arrow`},{kind:`key`,key:`right`,label:`→`,aria:`Right arrow`}];function He(e,t){return e!==null&&t.includes(e)?e:null}function Ue(e,t){return e!==null&&He(e,t)===null}function We(e,t){return e===t?null:t}function Ge({socketRef:e,viewsRef:t,zoomed:n,zoomAskedRef:r,active:i,onForceFit:a}){let o=t=>we(e.current,t),s=()=>o({type:`create`,rows:24,cols:80}),c=e=>{let t=We(r.current===void 0?n:r.current,e);o({type:`zoom`,pane:t})&&(r.current=t)},l=()=>o({type:`claim_size`});return{create:s,toggleZoom:c,claimSize:()=>{l()&&a()},requestSize:l,closePane:e=>je(document.querySelector(`[data-pane-cell][data-pane-id="${e}"]`),()=>o({type:`close`,pane:e})),reorder:e=>o({type:`reorder`,order:e}),sendKey:e=>{if(i===null)return;let n=t.current.get(i)?.term.modes.applicationCursorKeysMode??!1;o({type:`input`,pane:i,data:Fe(e,n)})}}}function Ke(e){return e===`live`}function qe(e,t,n,r,i){let a=r!==void 0&&r!==t.current;n&&(!e.current||a)&&i(),e.current=n,t.current=r??null}function Je(e,t){let[n,r]=(0,A.useState)(0);return y(()=>{Ke(e)&&we(t.current,{type:`claim_size`})},e===`live`),{refitEpoch:n,forceFit:(0,A.useCallback)(()=>r(e=>e+1),[])}}function Ye(){let[e,t]=(0,A.useState)(null),[n,r]=(0,A.useState)(`connecting`),[i,a]=(0,A.useState)(0),[o,s]=(0,A.useState)([]),[c,l]=(0,A.useState)(null),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)({}),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(!0);return{pending:e,setPending:t,link:n,setLink:r,replayLeft:i,setReplayLeft:a,panes:o,setPanes:s,active:c,setActive:l,zoomed:u,setZoomed:d,titles:f,setTitles:p,closing:m,setClosing:h,ownsSize:g,setOwnsSize:_}}function Xe(e){let t=e.indexOf(`;`);if(t===-1)return{kind:`ignore`};let n=e.slice(0,t),r=e.slice(t+1);if(!$e(n)||r===`?`||r===``)return{kind:`ignore`};let i=et(r);return i===null?{kind:`ignore`}:{kind:`write`,text:i}}var Ze=`cpqs01234567`,Qe=`cs`;function $e(e){if(e===``)return!0;let t=[...e];return t.every(e=>Ze.includes(e))?t.some(e=>Qe.includes(e)):!1}function et(e){try{let t=atob(e),n=Uint8Array.from(t,e=>e.charCodeAt(0));return new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{return null}}var tt=1048576,nt=262144,rt=class{term;highWater;lowWater;items=[];outstanding=0;pumping=!1;barrierInFlight=null;constructor(e,t=tt,n=nt){this.term=e,this.highWater=t,this.lowWater=n}write(e){this.items.push({kind:`bytes`,data:e}),this.pump()}barrier(e){this.items.push({kind:`barrier`,run:e,cancelled:!1}),this.pump()}clear(){for(let e of this.items)e.kind===`barrier`&&(e.cancelled=!0);this.items=[],this.barrierInFlight&&(this.barrierInFlight.cancelled=!0)}pump(){if(!this.pumping){this.pumping=!0;try{for(;this.items.length>0;){if(this.barrierInFlight)return;let e=this.items[0];if(e.kind===`barrier`){this.items.shift();let t={cancelled:e.cancelled};if(this.barrierInFlight=t,this.term.write(``,()=>{this.barrierInFlight=null,t.cancelled||e.run(),this.pump()}),this.barrierInFlight===t)return;continue}if(this.outstanding>=this.highWater)return;this.items.shift();let t=e.data.byteLength;this.outstanding+=t,this.term.write(e.data,()=>{this.outstanding-=t,this.outstanding<=this.lowWater&&this.pump()})}}finally{this.pumping=!1}}}},it=new WeakMap;function at(e){let t=it.get(e);return t||(t=new rt(e),it.set(e,t)),t}function ot(e,t){at(e).write(t)}function st(e,t){at(e).barrier(t)}function ct(e){it.get(e)?.clear()}function lt(e,t,n){st(e,()=>{t.release(),n()})}function ut(e){let t=e[0];return Array.isArray(t)?t[0]:t}function dt(e,t,n){let r=t,i=()=>r;return e.parser.registerCsiHandler({final:`n`},i),e.parser.registerCsiHandler({prefix:`?`,final:`n`},i),e.parser.registerCsiHandler({final:`c`},i),e.parser.registerCsiHandler({prefix:`>`,final:`c`},i),e.parser.registerCsiHandler({prefix:`=`,final:`c`},i),e.parser.registerCsiHandler({intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({final:`t`},e=>r&&[14,16,18].includes(ut(e)??-1)),e.parser.registerDcsHandler({intermediates:`$`,final:`q`},i),e.parser.registerDcsHandler({prefix:`?`,intermediates:`$`,final:`q`},i),e.parser.registerOscHandler(52,e=>(r||n(e),!0)),{begin(){r=!0},release(){r=!1}}}function ft(){return{active:!1,panes:new Map,order:[],zoomed:!1}}function pt(){return{containerRef:(0,A.useRef)(null),socketRef:(0,A.useRef)(null),viewsRef:(0,A.useRef)(new Map),bodyRefs:(0,A.useRef)(new Map),ptySizesRef:(0,A.useRef)(new Map),askedSizesRef:(0,A.useRef)(new Map),desiredSizesRef:(0,A.useRef)(new Map),ownsSizeRef:(0,A.useRef)(!0),sizeOwnerGenerationRef:(0,A.useRef)(null),pendingRef:(0,A.useRef)(new Map),replayRef:(0,A.useRef)(ft()),zoomAskedRef:(0,A.useRef)(void 0),slotRefs:(0,A.useRef)(new Map)}}function mt({socketRef:e,panes:t,active:r,zoom:i,link:a,commands:o,focusPane:s,cancelRecovery:c,openCompose:l}){let u=pe(),d=(0,A.useRef)({commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e});d.current={commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e};let f=(0,A.useMemo)(()=>{let e={"terminal.newPane":()=>d.current.commands.create(),paneCursor:()=>({index:r===null?-1:t.indexOf(r),count:t.length})};t.length>0&&(e.focusPaneAt=e=>{let n=t[e];n!==void 0&&(i!==null&&n!==i?d.current.commands.toggleZoom(n):d.current.focusPane(n))});for(let r of v){let i=n(r.id);if(i===null)continue;let a=O(t,i);a!==null&&(e[r.id]=()=>d.current.focusPane(a))}return r===null||(e[`terminal.closePane`]=()=>d.current.commands.closePane(r),e[`terminal.claimSizing`]=()=>d.current.commands.claimSize(),e[`terminal.cancelRecovery`]=()=>d.current.cancelRecovery(r),e[`terminal.composeMessage`]=()=>d.current.openCompose(),e[`terminal.swapPanePrompt`]=ht,e.swapPanes=e=>{let n=O(t,e);n!==null&&d.current.commands.reorder(ie(t,r,n))},e.zoomActivePane=()=>d.current.commands.toggleZoom(r),e.sendInput=e=>void we(d.current.socketRef.current,{type:`input`,pane:r,data:e})),e},[t,r,i]);me(f);let p=u?.disarm;(0,A.useEffect)(()=>{a!==`live`&&p?.()},[a,p])}function ht(){}function gt({termHeight:e,bodyHeight:t,rows:n,cursorRow:r,atLive:i}){let a=e-t;if(a<=0||n<=0||!i)return 0;let o=e/n,s=(Math.min(Math.max(r,0),n-1)+1)*o,c=Math.min(Math.max(s-t,0),a);return Math.round(a-c)}function _t({panes:e,viewsRef:t,bodyRefs:n,keyboardOpen:r,size:i,zoomed:a,mode:o}){(0,A.useEffect)(()=>{let r=[];for(let i of e){let e=t.current.get(i),a=n.current.get(i),o=e?.term.element;if(!e||!a||!o)continue;let{term:s}=e,c=()=>{let e=s.buffer.active,t=gt({termHeight:o.offsetHeight,bodyHeight:a.clientHeight,rows:s.rows,cursorRow:e.cursorY,atLive:e.viewportY===e.baseY}),n=t>0?`-${t}px`:``;o.style.marginBottom!==n&&(o.style.marginBottom=n)};c();let l=s.onRender(c),u=s.onScroll(c),d=new ResizeObserver(c);d.observe(a),r.push(()=>{l.dispose(),u.dispose(),d.disconnect()})}return()=>{for(let e of r)e()}},[e,t,n,r,i,a,o])}function vt({repo:e,panes:t,replayLeft:n,active:r,setActive:i,zoomed:s,zoom:c,viewsRef:l,panelRef:u,size:d,mode:f}){(0,A.useEffect)(()=>{if(Ue(s,t))return;let a=g(r,t,n,D(e));a!==null&&(i(a),se(e,a))},[r,t,n,e,s,i]),(0,A.useEffect)(()=>{c!==null&&c!==r&&(i(c),se(e,c))},[c,r,e,i]);let p=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=r===null?void 0:l.current.get(r),t=e?.term.element,n=o(r,!!t&&t.clientHeight>0,p.current);if(!n.focus||!e){p.current=n.held;return}let i=a(document.activeElement,u.current);fe(i)&&(e.term.focus(),p.current=n.held)},[r,t,d,f,c,l,u])}var yt=60;function bt({panes:e,size:t,zoomed:n,mode:r,screenScale:i,socketRef:a,viewsRef:o,bodyRefs:s,ptySizesRef:c,desiredSizesRef:l,askedSizesRef:u,ownsSize:d,layoutPending:f,keyboardOpen:p,refitEpoch:m}){let h=(0,A.useRef)(null),g=(0,A.useRef)(m),_=(0,A.useCallback)(()=>{for(let[e,t]of o.current){let n=s.current.get(e);if(!n||n.clientHeight===0||n.clientWidth===0)continue;let r=l.current.get(e)??{rows:t.term.rows,cols:t.term.cols},i=u.current.get(e);i&&i.rows===r.rows&&i.cols===r.cols||we(a.current,{type:`resize`,pane:e,rows:r.rows,cols:r.cols})&&u.current.set(e,r)}},[a,o,s,u,l]);(0,A.useEffect)(()=>{if(!p){g.current!==m&&(u.current.clear(),g.current=m);for(let[e,t]of o.current){let n=s.current.get(e);if(n&&n.clientHeight!==0&&n.clientWidth!==0){if(!d||f){let n=c.current.get(e);n?(t.term.resize(n.cols,n.rows),l.current.set(e,n)):t.term.resize(t.term.cols,t.term.rows)}else t.term.resize(t.term.cols,t.term.rows),t.fit.fit(),l.current.set(e,{rows:t.term.rows,cols:t.term.cols})}}if(d&&!f)return h.current&&clearTimeout(h.current),h.current=setTimeout(_,yt),()=>{h.current&&clearTimeout(h.current)}}},[e,n,r,i,m,t,_,o,s,c,l,u,d,f,p])}var xt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,Ct=(e,t)=>{for(var n in t)xt(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,r)=>{for(var i=r>1?void 0:r?St(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&xt(t,n,i),i},M=(e,t)=>(n,r)=>t(n,r,e),wt=`Terminal input`,Tt={get:()=>wt,set:e=>wt=e},Et=`Too much output to announce, navigate to rows manually to read`,Dt={get:()=>Et,set:e=>Et=e};function Ot(e){return e.replace(/\r?\n/g,`\r`)}function kt(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function At(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function jt(e,t,n,r){e.stopPropagation(),e.clipboardData&&Mt(e.clipboardData.getData(`text/plain`),t,n,r)}function Mt(e,t,n,r){e=Ot(e),e=kt(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Nt(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function Pt(e,t,n,r,i){Nt(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ft(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function It(e,t=0,n=e.length){let r=``;for(let i=t;i65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Lt=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},Rt=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},zt=``,Bt=` `,Vt=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ht}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ht=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ut=class e extends Vt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ht,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ft(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Wt=`di$target`,Gt=`di$dependencies`,Kt=new Map;function qt(e){return e[Gt]||[]}function Jt(e){if(Kt.has(e))return Kt.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Yt(t,e,r)};return t._id=e,Kt.set(e,t),t}function Yt(e,t,n){t[Wt]===t?t[Gt].push({id:e,index:n}):(t[Gt]=[{id:e,index:n}],t[Wt]=t)}var Xt=Jt(`BufferService`),Zt=Jt(`CoreMouseService`),Qt=Jt(`CoreService`),$t=Jt(`CharsetService`),en=Jt(`InstantiationService`),tn=Jt(`LogService`),nn=Jt(`OptionsService`),rn=Jt(`OscLinkService`),an=Jt(`UnicodeService`),on=Jt(`DecorationService`),sn=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Ut,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):cn(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};sn=j([M(0,Xt),M(1,nn),M(2,rn)],sn);function cn(e,t){if(confirm(`Do you want to navigate to ${t}? +import{t as e}from"./jsx-runtime-EIAPxkjE.js";import{t}from"./react-BPk_wmJm.js";import{$ as n,A as r,B as i,C as a,E as o,F as s,H as c,I as l,K as u,M as d,N as f,P as p,R as m,S as h,T as g,U as _,X as v,_ as y,_t as b,a as x,c as ee,ct as te,d as S,f as C,ft as w,gt as T,h as ne,ht as E,j as re,l as ie,m as ae,n as D,o as O,p as k,pt as oe,r as se,s as ce,st as le,t as ue,u as de,w as fe,x as pe,y as me}from"./lastPane-Kg5ZBFNS.js";import{t as he}from"./api-BwgkHPos.js";var A=t();function ge(e,t){for(;t;)[e,t]=[t,e%t];return e}function _e(e,t){switch(e){case 1:return[1];case 2:return t?[2]:[1,1];case 3:return[2,1];case 4:return[2,2];case 5:return[3,2];case 6:return[3,3];case 7:return[4,3];default:return[4,4]}}function ve(e,t){let n=_e(e,t),r=n.reduce((e,t)=>e*t/ge(e,t),1),i=[];return n.forEach((e,t)=>{let n=r/e;for(let r=0;r1,h=()=>{c.current!==null&&clearTimeout(c.current),c.current=null},g=()=>{h(),l.current=!1,i.current=null,a.current=null,o.current=null,s.current=!1,d(null),p(null)};return{draggingPane:u,dragOverPane:f,reorderable:m,endPaneDrag:g,onPaneDragStart:(e,t,r)=>{if(e.target.closest(`button`))return;let o=r?.holdToDrag===!0&&e.pointerType===`touch`;if(o||n(t),e.button!==0||!m&&!o)return;if(i.current=t,a.current={x:e.clientX,y:e.clientY},s.current=!1,!o){e.currentTarget.setPointerCapture(e.pointerId);return}if(l.current=!0,!m)return;let u=e.currentTarget,f=e.pointerId;h(),c.current=setTimeout(()=>{c.current=null,l.current=!1,s.current=!0,d(t);try{u.setPointerCapture(f)}catch{g()}},350)},onPaneDragMove:e=>{let t=i.current,n=a.current;if(t===null||n===null)return;if(!s.current){if(!(Math.hypot(e.clientX-n.x,e.clientY-n.y)>=4))return;if(l.current){g();return}}s.current=!0,d(t);let r=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-pane-id]`),c=r?Number(r.getAttribute(`data-pane-id`)):null,u=c!==null&&c!==t?c:null;o.current=u,p(u)},onPaneDragEnd:()=>{let t=i.current,a=o.current;t!==null&&l.current&&n(t),t!==null&&s.current&&a!==null&&r(ee(e,t,a)),g()}}}function be(e){return typeof e==`number`&&Number.isSafeInteger(e)}function xe(e){return be(e)&&e>=0}function Se(e){return typeof e==`string`&&/^[0-9]+$/.test(e)}function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r;switch(n.type){case`created`:r=xe(n.pane)&&xe(n.rows)&&xe(n.cols)&&(n.client===void 0||xe(n.client))&&(n.title===void 0||typeof n.title==`string`);break;case`exited`:r=xe(n.pane);break;case`resized`:r=xe(n.pane)&&xe(n.rows)&&xe(n.cols);break;case`hello`:r=xe(n.client)&&xe(n.panes);break;case`replay_complete`:r=!0;break;case`size_owner`:r=typeof n.owned==`boolean`&&(n.generation===void 0||Se(n.generation));break;case`error`:r=typeof n.message==`string`;break;case`reordered`:r=Array.isArray(n.order)&&n.order.every(xe);break;case`zoomed`:r=n.pane===null||xe(n.pane);break;case`pending`:r=xe(n.count);break;case`attention`:r=xe(n.pane)&&(n.message===void 0||typeof n.message==`string`);break;case`recovery`:r=xe(n.pane)&&typeof n.state==`string`&&(n.detail===void 0||typeof n.detail==`string`)&&(n.deadline_epoch===void 0||be(n.deadline_epoch))&&xe(n.attempt);break;default:return null}return r?n:null}function we(e,t){return!e||e.readyState!==WebSocket.OPEN?!1:(e.send(JSON.stringify(t)),!0)}function Te(e){return e.byteLength<4?null:{pane:new DataView(e).getUint32(0,!0),data:new Uint8Array(e,4)}}function Ee(e){let[t,n]=(0,A.useState)({});return{recovery:t,setRecovery:n,cancelRecovery:(0,A.useCallback)(t=>{we(e.current,{type:`cancel_recovery`,pane:t})},[e])}}var De=240,Oe=`cubic-bezier(0.2, 0, 0, 1)`;function ke(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ae(e){return e instanceof HTMLElement&&typeof e.animate==`function`&&!ke()}function je(e,t){if(!Ae(e)){t();return}let n=!1,r=()=>{n||(n=!0,t())},i=e.animate([{opacity:1,transform:`translateY(0)`},{opacity:0,transform:`translateY(12px)`}],{duration:200,easing:Oe,fill:`forwards`});i.onfinish=r,i.oncancel=r}function Me(e){Ae(e)&&e.animate([{opacity:0},{opacity:1}],{duration:De,easing:Oe})}var Ne={esc:`\x1B`,tab:` `,"shift-tab":`\x1B[Z`,"shift-left":`\x1B[1;2D`,"ctrl-b":``,"ctrl-c":``,"ctrl-d":``,"ctrl-z":``,"ctrl-l":`\f`,"ctrl-r":``,up:`\x1B[A`,down:`\x1B[B`,right:`\x1B[C`,left:`\x1B[D`},Pe={up:`\x1BOA`,down:`\x1BOB`,right:`\x1BOC`,left:`\x1BOD`};function Fe(e,t=!1){if(t){let t=Pe[e];if(t)return t}return Ne[e]}function Ie(e){if(e.length!==1)return null;if(e===` `)return`\0`;if(e===`?`)return``;let t=e.charCodeAt(0);return t>=97&&t<=122&&(t-=32),t<64||t>95?null:String.fromCharCode(t&31)}function Le(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:Ie(t)??t,armed:!1}:{data:t,armed:!1}}function Re(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:[...t].length===1?`\x1b${t}`:t,armed:!1}:{data:t,armed:!1}}function ze(e){return e===`shown`||e===`hidden`?e:null}function Be(e,t){return e||t<768}var Ve=[{kind:`key`,key:`esc`,label:`Esc`,aria:`Escape`},{kind:`key`,key:`tab`,label:`Tab`,aria:`Tab`},{kind:`key`,key:`shift-tab`,label:`⇧Tab`,aria:`Shift Tab`},{kind:`latch`,latch:`alt`,label:`Alt`,aria:`Alt for the next key`},{kind:`latch`,latch:`ctrl`,label:`Ctrl`,aria:`Control for the next key`},{kind:`key`,key:`ctrl-b`,label:`^B`,aria:`Control B`},{kind:`key`,key:`ctrl-c`,label:`^C`,aria:`Control C`},{kind:`key`,key:`ctrl-d`,label:`^D`,aria:`Control D`},{kind:`key`,key:`ctrl-z`,label:`^Z`,aria:`Control Z`},{kind:`key`,key:`ctrl-l`,label:`^L`,aria:`Control L`},{kind:`key`,key:`ctrl-r`,label:`^R`,aria:`Control R`},{kind:`key`,key:`shift-left`,label:`⇧←`,aria:`Shift Left arrow`},{kind:`key`,key:`left`,label:`←`,aria:`Left arrow`},{kind:`key`,key:`down`,label:`↓`,aria:`Down arrow`},{kind:`key`,key:`up`,label:`↑`,aria:`Up arrow`},{kind:`key`,key:`right`,label:`→`,aria:`Right arrow`}];function He(e,t){return e!==null&&t.includes(e)?e:null}function Ue(e,t){return e!==null&&He(e,t)===null}function We(e,t){return e===t?null:t}function Ge({socketRef:e,viewsRef:t,zoomed:n,zoomAskedRef:r,active:i,onForceFit:a}){let o=t=>we(e.current,t),s=()=>o({type:`create`,rows:24,cols:80}),c=e=>{let t=We(r.current===void 0?n:r.current,e);o({type:`zoom`,pane:t})&&(r.current=t)},l=()=>o({type:`claim_size`});return{create:s,toggleZoom:c,claimSize:()=>{l()&&a()},requestSize:l,closePane:e=>je(document.querySelector(`[data-pane-cell][data-pane-id="${e}"]`),()=>o({type:`close`,pane:e})),reorder:e=>o({type:`reorder`,order:e}),sendKey:e=>{if(i===null)return;let n=t.current.get(i)?.term.modes.applicationCursorKeysMode??!1;o({type:`input`,pane:i,data:Fe(e,n)})}}}function Ke(e){return e===`live`}function qe(e,t,n,r,i){let a=r!==void 0&&r!==t.current;n&&(!e.current||a)&&i(),e.current=n,t.current=r??null}function Je(e,t){let[n,r]=(0,A.useState)(0);return y(()=>{Ke(e)&&we(t.current,{type:`claim_size`})},e===`live`),{refitEpoch:n,forceFit:(0,A.useCallback)(()=>r(e=>e+1),[])}}function Ye(){let[e,t]=(0,A.useState)(null),[n,r]=(0,A.useState)(`connecting`),[i,a]=(0,A.useState)(0),[o,s]=(0,A.useState)([]),[c,l]=(0,A.useState)(null),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)({}),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(!0);return{pending:e,setPending:t,link:n,setLink:r,replayLeft:i,setReplayLeft:a,panes:o,setPanes:s,active:c,setActive:l,zoomed:u,setZoomed:d,titles:f,setTitles:p,closing:m,setClosing:h,ownsSize:g,setOwnsSize:_}}function Xe(e){let t=e.indexOf(`;`);if(t===-1)return{kind:`ignore`};let n=e.slice(0,t),r=e.slice(t+1);if(!$e(n)||r===`?`||r===``)return{kind:`ignore`};let i=et(r);return i===null?{kind:`ignore`}:{kind:`write`,text:i}}var Ze=`cpqs01234567`,Qe=`cs`;function $e(e){if(e===``)return!0;let t=[...e];return t.every(e=>Ze.includes(e))?t.some(e=>Qe.includes(e)):!1}function et(e){try{let t=atob(e),n=Uint8Array.from(t,e=>e.charCodeAt(0));return new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{return null}}var tt=1048576,nt=262144,rt=class{term;highWater;lowWater;items=[];outstanding=0;pumping=!1;barrierInFlight=null;constructor(e,t=tt,n=nt){this.term=e,this.highWater=t,this.lowWater=n}write(e){this.items.push({kind:`bytes`,data:e}),this.pump()}barrier(e){this.items.push({kind:`barrier`,run:e,cancelled:!1}),this.pump()}clear(){for(let e of this.items)e.kind===`barrier`&&(e.cancelled=!0);this.items=[],this.barrierInFlight&&(this.barrierInFlight.cancelled=!0)}pump(){if(!this.pumping){this.pumping=!0;try{for(;this.items.length>0;){if(this.barrierInFlight)return;let e=this.items[0];if(e.kind===`barrier`){this.items.shift();let t={cancelled:e.cancelled};if(this.barrierInFlight=t,this.term.write(``,()=>{this.barrierInFlight=null,t.cancelled||e.run(),this.pump()}),this.barrierInFlight===t)return;continue}if(this.outstanding>=this.highWater)return;this.items.shift();let t=e.data.byteLength;this.outstanding+=t,this.term.write(e.data,()=>{this.outstanding-=t,this.outstanding<=this.lowWater&&this.pump()})}}finally{this.pumping=!1}}}},it=new WeakMap;function at(e){let t=it.get(e);return t||(t=new rt(e),it.set(e,t)),t}function ot(e,t){at(e).write(t)}function st(e,t){at(e).barrier(t)}function ct(e){it.get(e)?.clear()}function lt(e,t,n){st(e,()=>{t.release(),n()})}function ut(e){let t=e[0];return Array.isArray(t)?t[0]:t}function dt(e,t,n){let r=t,i=()=>r;return e.parser.registerCsiHandler({final:`n`},i),e.parser.registerCsiHandler({prefix:`?`,final:`n`},i),e.parser.registerCsiHandler({final:`c`},i),e.parser.registerCsiHandler({prefix:`>`,final:`c`},i),e.parser.registerCsiHandler({prefix:`=`,final:`c`},i),e.parser.registerCsiHandler({intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({final:`t`},e=>r&&[14,16,18].includes(ut(e)??-1)),e.parser.registerDcsHandler({intermediates:`$`,final:`q`},i),e.parser.registerDcsHandler({prefix:`?`,intermediates:`$`,final:`q`},i),e.parser.registerOscHandler(52,e=>(r||n(e),!0)),{begin(){r=!0},release(){r=!1}}}function ft(){return{active:!1,panes:new Map,order:[],zoomed:!1}}function pt(){return{containerRef:(0,A.useRef)(null),socketRef:(0,A.useRef)(null),viewsRef:(0,A.useRef)(new Map),bodyRefs:(0,A.useRef)(new Map),ptySizesRef:(0,A.useRef)(new Map),askedSizesRef:(0,A.useRef)(new Map),desiredSizesRef:(0,A.useRef)(new Map),ownsSizeRef:(0,A.useRef)(!0),sizeOwnerGenerationRef:(0,A.useRef)(null),pendingRef:(0,A.useRef)(new Map),replayRef:(0,A.useRef)(ft()),zoomAskedRef:(0,A.useRef)(void 0),slotRefs:(0,A.useRef)(new Map)}}function mt({socketRef:e,panes:t,active:r,zoom:i,link:a,commands:o,focusPane:s,cancelRecovery:c,openCompose:l}){let u=pe(),d=(0,A.useRef)({commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e});d.current={commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e};let f=(0,A.useMemo)(()=>{let e={"terminal.newPane":()=>d.current.commands.create(),paneCursor:()=>({index:r===null?-1:t.indexOf(r),count:t.length})};t.length>0&&(e.focusPaneAt=e=>{let n=t[e];n!==void 0&&(i!==null&&n!==i?d.current.commands.toggleZoom(n):d.current.focusPane(n))});for(let r of v){let i=n(r.id);if(i===null)continue;let a=O(t,i);a!==null&&(e[r.id]=()=>d.current.focusPane(a))}return r===null||(e[`terminal.closePane`]=()=>d.current.commands.closePane(r),e[`terminal.claimSizing`]=()=>d.current.commands.claimSize(),e[`terminal.cancelRecovery`]=()=>d.current.cancelRecovery(r),e[`terminal.composeMessage`]=()=>d.current.openCompose(),e[`terminal.swapPanePrompt`]=ht,e.swapPanes=e=>{let n=O(t,e);n!==null&&d.current.commands.reorder(ie(t,r,n))},e.zoomActivePane=()=>d.current.commands.toggleZoom(r),e.sendInput=e=>void we(d.current.socketRef.current,{type:`input`,pane:r,data:e})),e},[t,r,i]);me(f);let p=u?.disarm;(0,A.useEffect)(()=>{a!==`live`&&p?.()},[a,p])}function ht(){}function gt({termHeight:e,bodyHeight:t,rows:n,cursorRow:r,atLive:i}){let a=e-t;if(a<=0||n<=0||!i)return 0;let o=e/n,s=(Math.min(Math.max(r,0),n-1)+1)*o,c=Math.min(Math.max(s-t,0),a);return Math.round(a-c)}function _t({panes:e,viewsRef:t,bodyRefs:n,keyboardOpen:r,size:i,zoomed:a,mode:o}){(0,A.useEffect)(()=>{let r=[];for(let i of e){let e=t.current.get(i),a=n.current.get(i),o=e?.term.element;if(!e||!a||!o)continue;let{term:s}=e,c=()=>{let e=s.buffer.active,t=gt({termHeight:o.offsetHeight,bodyHeight:a.clientHeight,rows:s.rows,cursorRow:e.cursorY,atLive:e.viewportY===e.baseY}),n=t>0?`-${t}px`:``;o.style.marginBottom!==n&&(o.style.marginBottom=n)};c();let l=s.onRender(c),u=s.onScroll(c),d=new ResizeObserver(c);d.observe(a),r.push(()=>{l.dispose(),u.dispose(),d.disconnect()})}return()=>{for(let e of r)e()}},[e,t,n,r,i,a,o])}function vt({repo:e,panes:t,replayLeft:n,active:r,setActive:i,zoomed:s,zoom:c,viewsRef:l,panelRef:u,size:d,mode:f}){(0,A.useEffect)(()=>{if(Ue(s,t))return;let a=g(r,t,n,D(e));a!==null&&(i(a),se(e,a))},[r,t,n,e,s,i]),(0,A.useEffect)(()=>{c!==null&&c!==r&&(i(c),se(e,c))},[c,r,e,i]);let p=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=r===null?void 0:l.current.get(r),t=e?.term.element,n=o(r,!!t&&t.clientHeight>0,p.current);if(!n.focus||!e){p.current=n.held;return}let i=a(document.activeElement,u.current);fe(i)&&(e.term.focus(),p.current=n.held)},[r,t,d,f,c,l,u])}var yt=60;function bt({panes:e,size:t,zoomed:n,mode:r,screenScale:i,socketRef:a,viewsRef:o,bodyRefs:s,ptySizesRef:c,desiredSizesRef:l,askedSizesRef:u,ownsSize:d,layoutPending:f,keyboardOpen:p,refitEpoch:m}){let h=(0,A.useRef)(null),g=(0,A.useRef)(m),_=(0,A.useCallback)(()=>{for(let[e,t]of o.current){let n=s.current.get(e);if(!n||n.clientHeight===0||n.clientWidth===0)continue;let r=l.current.get(e)??{rows:t.term.rows,cols:t.term.cols},i=u.current.get(e);i&&i.rows===r.rows&&i.cols===r.cols||we(a.current,{type:`resize`,pane:e,rows:r.rows,cols:r.cols})&&u.current.set(e,r)}},[a,o,s,u,l]);(0,A.useEffect)(()=>{if(!p){g.current!==m&&(u.current.clear(),g.current=m);for(let[e,t]of o.current){let n=s.current.get(e);if(n&&n.clientHeight!==0&&n.clientWidth!==0){if(!d||f){let n=c.current.get(e);n?(t.term.resize(n.cols,n.rows),l.current.set(e,n)):t.term.resize(t.term.cols,t.term.rows)}else t.term.resize(t.term.cols,t.term.rows),t.fit.fit(),l.current.set(e,{rows:t.term.rows,cols:t.term.cols})}}if(d&&!f)return h.current&&clearTimeout(h.current),h.current=setTimeout(_,yt),()=>{h.current&&clearTimeout(h.current)}}},[e,n,r,i,m,t,_,o,s,c,l,u,d,f,p])}var xt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,Ct=(e,t)=>{for(var n in t)xt(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,r)=>{for(var i=r>1?void 0:r?St(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&xt(t,n,i),i},M=(e,t)=>(n,r)=>t(n,r,e),wt=`Terminal input`,Tt={get:()=>wt,set:e=>wt=e},Et=`Too much output to announce, navigate to rows manually to read`,Dt={get:()=>Et,set:e=>Et=e};function Ot(e){return e.replace(/\r?\n/g,`\r`)}function kt(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function At(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function jt(e,t,n,r){e.stopPropagation(),e.clipboardData&&Mt(e.clipboardData.getData(`text/plain`),t,n,r)}function Mt(e,t,n,r){e=Ot(e),e=kt(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Nt(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function Pt(e,t,n,r,i){Nt(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ft(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function It(e,t=0,n=e.length){let r=``;for(let i=t;i65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Lt=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},Rt=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},zt=``,Bt=` `,Vt=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ht}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ht=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ut=class e extends Vt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ht,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ft(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Wt=`di$target`,Gt=`di$dependencies`,Kt=new Map;function qt(e){return e[Gt]||[]}function Jt(e){if(Kt.has(e))return Kt.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Yt(t,e,r)};return t._id=e,Kt.set(e,t),t}function Yt(e,t,n){t[Wt]===t?t[Gt].push({id:e,index:n}):(t[Gt]=[{id:e,index:n}],t[Wt]=t)}var Xt=Jt(`BufferService`),Zt=Jt(`CoreMouseService`),Qt=Jt(`CoreService`),$t=Jt(`CharsetService`),en=Jt(`InstantiationService`),tn=Jt(`LogService`),nn=Jt(`OptionsService`),rn=Jt(`OscLinkService`),an=Jt(`UnicodeService`),on=Jt(`DecorationService`),sn=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Ut,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):cn(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};sn=j([M(0,Xt),M(1,nn),M(2,rn)],sn);function cn(e,t){if(confirm(`Do you want to navigate to ${t}? WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ln=Jt(`CharSizeService`),un=Jt(`CoreBrowserService`),dn=Jt(`MouseService`),fn=Jt(`RenderService`),pn=Jt(`SelectionService`),mn=Jt(`CharacterJoinerService`),hn=Jt(`ThemeService`),gn=Jt(`LinkProviderService`),_n=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Cn.isErrorNoTelemetry(e)?new Cn(e.message+` diff --git a/viewer-ui/dist/assets/index-C0YZmztO.js b/viewer-ui/dist/assets/index-VyUeVokt.js similarity index 99% rename from viewer-ui/dist/assets/index-C0YZmztO.js rename to viewer-ui/dist/assets/index-VyUeVokt.js index 0d2c3043..89180398 100644 --- a/viewer-ui/dist/assets/index-C0YZmztO.js +++ b/viewer-ui/dist/assets/index-VyUeVokt.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Markdown-DEJAds14.js","./jsx-runtime-EIAPxkjE.js","./react-BPk_wmJm.js","./Markdown-C8LL_u4z.css","./Html-DGFy4jGa.js","./HtmlEditor-DzgQSTDx.js","./BusyLabel-BNTNuT1X.js","./api-BwgkHPos.js","./Terminal-BuLVJ0Wx.js","./lastPane-Kg5ZBFNS.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Markdown-DEJAds14.js","./jsx-runtime-EIAPxkjE.js","./react-BPk_wmJm.js","./Markdown-C8LL_u4z.css","./Html-DGFy4jGa.js","./HtmlEditor-DzgQSTDx.js","./BusyLabel-BNTNuT1X.js","./api-BwgkHPos.js","./Terminal-N9POd-x9.js","./lastPane-Kg5ZBFNS.js"])))=>i.map(i=>d[i]); import{n as e,t}from"./jsx-runtime-EIAPxkjE.js";import{t as n}from"./react-BPk_wmJm.js";import{$ as r,A as i,C as a,D as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,Q as _,R as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_t as T,at as E,b as ee,c as te,ct as ne,dt as re,et as ie,ft as ae,g as oe,gt as se,ht as D,i as ce,it as le,j as ue,k as de,lt as fe,mt as pe,nt as me,ot as he,pt as ge,q as _e,r as ve,rt as ye,s as be,st as xe,tt as O,ut as k,v as Se,w as Ce,x as we,y as Te,z as Ee}from"./lastPane-Kg5ZBFNS.js";import{t as A}from"./BusyLabel-BNTNuT1X.js";import{a as De,i as Oe,n as ke,o as Ae,r as je,s as Me,t as j}from"./api-BwgkHPos.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ne=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(ee)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=ee,te=function(){re.postMessage(null)}}else te=function(){_(ee,0)};function ie(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Pe=e(((e,t)=>{t.exports=Ne()})),Fe=e((e=>{var t=Pe(),r=n(),i=T();function a(e){var t=`https://react.dev/errors/`+e;if(1we||(e.current=Ce[we],Ce[we]=null,we--)}function A(e,t){we++,Ce[we]=e.current,e.current=t}var De=Te(null),Oe=Te(null),ke=Te(null),Ae=Te(null);function je(e,t){switch(A(ke,t),A(Oe,e),A(De,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Ee(De),A(De,e)}function Me(){Ee(De),Ee(Oe),Ee(ke)}function j(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,A(Ae,e)),t=De.current;var n=dp(t,e.type);t!==n&&(A(Oe,e),A(De,n))}function Ne(e){Oe.current===e&&(Ee(De),Ee(Oe)),Ae.current===e&&(Ee(Ae),sh._currentValue=Se)}var Fe,Ie;function M(e){if(Fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Fe=t&&t[1]||``,Ie=-1)`:-1>>=0,e===0?32:31-(it(e)/at|0)|0}var st=256,ct=262144,lt=4194304;function ut(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function dt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ut(n))):i=ut(o):i=ut(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ut(n))):i=ut(o)):i=ut(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ft(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function pt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function _t(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function vt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=gr),yr=` `,br=!1;function xr(e,t){switch(e){case`keyup`:return mr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Sr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Cr=!1;function wr(e,t){switch(e){case`compositionend`:return Sr(t);case`keypress`:return t.which===32?(br=!0,yr):null;case`textInput`:return e=t.data,e===yr&&br?null:e;default:return null}}function Tr(e,t){if(Cr)return e===`compositionend`||!hr&&xr(e,t)?(e=Rn(),Ln=In=Fn=null,Cr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Jr(n)}}function Xr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=qr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=qr(e.document)}return t}function Qr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var $r=Mn&&`documentMode`in document&&11>=document.documentMode,ei=null,ti=null,ni=null,ri=!1;function ii(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ri||ei==null||ei!==qr(r)||(r=ei,`selectionStart`in r&&Qr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ni&&Kr(ni,r)||(ni=r,r=Jf(ti,`onSelect`),0>=o,i-=o,ea=1<<32-rt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),L&&na(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),L&&na(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return L&&na(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),L&&na(i,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===re&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case te:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===re){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),fo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===de&&io(l)===r.type){n(e,r.sibling),c=i(r,o.props),fo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===re?(c=Vi(o.props.children,e.mode,c,o.key),fo(c,o),c.return=e,e=c):(c=Bi(o.type,o.key,o.props,null,e.mode,c),fo(c,o),c.return=e,e=c)}return s(e);case ne:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Wi(o,e.mode,c),c.return=e,e=c}return s(e);case de:return o=io(o),_(e,r,o,c)}if(xe(o))return h(e,r,o,c);if(ve(o)){if(l=ve(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,uo(o),c);if(o.$$typeof===se)return _(e,r,ka(e,o),c);po(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=Hi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{lo=0;var i=_(e,t,n,r);return co=null,i}catch(t){if(t===Qa||t===eo)throw t;var a=Ii(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ho=mo(!0),go=mo(!1),_o=!1;function vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function xo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ni(e),Mi(e,null,n),t}return ki(e,r,t,n),Ni(e)}function So(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bt(e,n)}}function Co(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var wo=!1;function To(){if(wo){var e=Ua;if(e!==null)throw e}}function Eo(e,t,n,r){wo=!1;var i=e.updateQueue;_o=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===Ha&&(wo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=E({},d,f);break a;case 2:_o=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function Do(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function Oo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=O.T,s={};s.types=o===null?null:o.types,O.T=s,pc(e,!1,t,n);try{var c=i(),l=O.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?fc(e,t,Ka(c,r),jd(e)):fc(e,t,r,jd(e))}catch(n){fc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{k.p=a,o!==null&&s.types!==null&&(o.types=s.types),O.T=o}}function nc(){}function rc(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=ic(e).queue;tc(e,i,t,Se,n===null?nc:function(){return ac(e),n(r)})}function ic(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Se,baseState:Se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:Se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ac(e){var t=ic(e);t.next===null&&(t=e.alternate.memoizedState),fc(e,t.next.queue,{},jd())}function oc(){return Oa(sh)}function sc(){return ls().memoizedState}function cc(){return ls().memoizedState}function lc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=bo(n);var r=xo(t,e,n);r!==null&&(Pd(r,t,n),So(r,t,n)),t={cache:Fa()},e.payload=t;return}t=t.return}}function uc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mc(e)?hc(t,n):(n=Ai(e,t,n,r),n!==null&&(Pd(n,e,r),gc(n,t,r)))}function dc(e,t,n){fc(e,t,n,jd())}function fc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mc(e))hc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Gr(s,o))return ki(e,t,i,0),G===null&&Oi(),!1}catch{}if(n=Ai(e,t,i,r),n!==null)return Pd(n,e,r),gc(n,t,r),!0}return!1}function pc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},mc(e)){if(t)throw Error(a(479))}else t=Ai(e,n,r,2),t!==null&&Pd(t,e,2)}function mc(e){var t=e.alternate;return e===R||t!==null&&t===R}function hc(e,t){Jo=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function gc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bt(e,n)}}var _c={readContext:Oa,use:fs,useCallback:B,useContext:B,useEffect:B,useImperativeHandle:B,useLayoutEffect:B,useInsertionEffect:B,useMemo:B,useReducer:B,useRef:B,useState:B,useDebugValue:B,useDeferredValue:B,useTransition:B,useSyncExternalStore:B,useId:B,useHostTransitionStatus:B,useFormState:B,useActionState:B,useOptimistic:B,useMemoCache:B,useCacheRefresh:B,useEffectEvent:B},vc={readContext:Oa,use:fs,useCallback:function(e,t){return cs().memoizedState=[e,t===void 0?null:t],e},useContext:Oa,useEffect:Hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Bs(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bs(4194308,4,e,t)},useInsertionEffect:function(e,t){Bs(4,2,e,t)},useMemo:function(e,t){var n=cs();t=t===void 0?null:t;var r=e();if(Yo){nt(!0);try{e()}finally{nt(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=cs();if(n!==void 0){var i=n(t);if(Yo){nt(!0);try{n(t)}finally{nt(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=uc.bind(null,R,e),[r.memoizedState,e]},useRef:function(e){var t=cs();return e={current:e},t.memoizedState=e},useState:function(e){e=ws(e);var t=e.queue,n=dc.bind(null,R,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Xs,useDeferredValue:function(e,t){return $s(cs(),e,t)},useTransition:function(){var e=ws(!1);return e=tc.bind(null,R,e.queue,!0,!1),cs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=R,i=cs();if(L){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),G===null)throw Error(a(349));q&127||ys(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Hs(xs.bind(null,r,o,e),[e]),r.flags|=2048,Rs(9,{destroy:void 0},bs.bind(null,r,o,n,t),null),n},useId:function(){var e=cs(),t=G.identifierPrefix;if(L){var n=ta,r=ea;n=(r&~(1<<32-rt(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Xo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[Dt]=t,o[Ot]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return V(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=ke.current,ma(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=sa,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[Dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||da(t,!0)}else e=lp(e).createTextNode(r),e[Dt]=t,t.stateNode=e}return V(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ma(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[Dt]=t}else ha(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),e=!1}else n=ga(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Bo(t),t):(Bo(t),null);if(t.flags&128)throw Error(a(558))}return V(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ma(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[Dt]=t}else ha(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),i=!1}else i=ga(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Bo(t),t):(Bo(t),null)}return Bo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),V(t),null);case 4:return Me(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,V(t),null;case 10:return Sa(t.type),V(t),null;case 19:if(Uo(t),r=t.memoizedState,r===null)return V(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)bl(r,!1);else{if(Y!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,bl(r,!1),e=o.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)zi(n,e),n=n.sibling;return Ho(t,Vo.current&1|2),L&&na(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ge()>_d&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Wo(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!L)return V(t),null}else 2*Ge()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ge(),e.sibling=null,o=Vo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||L?Ho(t,o):(n=o,A(Po,t),A(Vo,n),Fo===null&&(Fo=t)),L&&na(t,r.treeForkCount),e}return V(t),null;case 22:case 23:return Bo(t),No(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Ee(Ja),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Sa(Pa),V(t),null;case 25:return null;case 30:return t.flags|=33554432,V(t),null}throw Error(a(156,t.tag))}function Sl(e,t){switch(aa(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Sa(Pa),Me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ne(t),null;case 31:if(t.memoizedState!==null){if(Bo(t),t.alternate===null)throw Error(a(340));ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Bo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Uo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Me(),null;case 10:return Sa(t.type),null;case 22:case 23:return Bo(t),No(),e!==null&&Ee(Ja),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Sa(Pa),null;case 25:return null;default:return null}}function Cl(e,t){switch(aa(t),t.tag){case 3:Sa(Pa),Me();break;case 26:case 27:case 5:Ne(t);break;case 4:Me();break;case 31:t.memoizedState!==null&&Bo(t);break;case 13:Bo(t);break;case 19:Uo(t);break;case 10:Sa(t.type);break;case 22:case 23:Bo(t),No(),e!==null&&Ee(Ja);break;case 24:Sa(Pa)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Oo(t,n)}catch(t){Z(e,e.return,t)}}}function Dl(e,t,n){n.props=Tc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=xi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);p(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[Dt]=e,Vt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Yr(s,h),v=Yr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,O.T=null,n=wd,wd=null;var o=bd,s=Sd;if(X=0,xd=bd=null,Sd=0,W&6)throw Error(a(331));var c=W;if(W|=4,Zu(o.current),Uu(o,o.current,s,n),W=c,Df(0,!1),tt&&typeof tt.onPostCommitFiberRoot==`function`)try{tt.onPostCommitFiberRoot(et,o)}catch{}return!0}finally{k.p=i,O.T=r,uf(e,t)}}function pf(e,t,n){t=Ki(n,t),t=jc(e.stateNode,t,2),e=xo(e,t,2),e!==null&&(_t(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=Ki(n,e),n=Mc(2),r=xo(t,n,2),r!==null&&(Nc(n,r,t,e),_t(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new td;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ad=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,G===e&&(q&n)===n&&(Y===4||Y===3&&(q&62914560)===q&&300>Ge()-hd?W&2?ld|=n:Vd(e,0):ld|=n,dd===q&&(dd=0)),Ef(e)}function gf(e,t){t===0&&(t=ht()),e=ji(e,t),e!==null&&(_t(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Ve(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-rt(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=q,a=dt(r,r===G?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ft(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=Ge(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}X!==0&&X!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=cn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Vt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+cn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+cn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+cn(n.imageSizes)+`"]`)):i+=`[href="`+cn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=E({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Ft]=!0,o.onload=o.onerror=function(){Ht(o)}),Vt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+cn(r)+`"][href="`+cn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=E({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Vt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Bt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=E({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Vt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Bt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=E({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Vt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Bt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=E({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Vt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=ke.current)?bm(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Bt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Bt(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(i,e,o,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Bt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Pm(e){return`href="`+cn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return E({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Ft]){r.loading=1;return}}else t=e.createElement(`link`),t[Ft]=!0,t.onload=t.onerror=Ht.bind(null,t),np(t,`link`,n),Vt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+cn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+cn(n.href)+`"]`);if(r)return t.instance=r,Vt(r),r;var i=E({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Vt(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var o=e.querySelector(Fm(i));if(o)return t.state.loading|=4,t.instance=o,Vt(o),o;r=Im(n),(i=vm.get(i))&&Hm(r,i),o=(e.ownerDocument||e).createElement(`link`),Vt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(i=e.querySelector(zm(o)))?(t.instance=i,Vt(i),i):(r=n,(i=vm.get(o))&&(r=E({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Vt(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Vt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Vt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Fe()}))(),M=n(),N=t();function Le({onClose:e,onOpened:t,canClone:n,cloning:r,onClone:i}){let[a,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(null),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(``),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(``),[y,b]=(0,M.useState)(0);(0,M.useEffect)(()=>{let e=!1;return j.browse(a??void 0).then(t=>{e||(c(t),u(null))}).catch(t=>{e||u(t instanceof Error?t.message:`could not browse`)}),()=>{e=!0}},[a,y]);let x=e=>o(`${s.path.replace(/\/$/,``)}/${e}`),S=async()=>{if(s){f(!0);try{t(await j.open(s.path))}catch(e){D.error(e instanceof Error?e.message:`could not open`),f(!1)}}},C=async()=>{if(!s)return;let e=p.trim();if(e){g(!0);try{await j.mkdir(s.path,e),m(``),b(e=>e+1)}catch(e){D.error(e instanceof Error?e.message:`could not create folder`)}finally{g(!1)}}};return(0,N.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 md:pt-[8vh]`,onClick:e,children:(0,N.jsxs)(`div`,{className:`nc-rise-in flex max-h-[min(80vh,calc(var(--nc-visual-viewport-height,100vh)-8vh-1rem))] w-[34rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`font-medium text-ink-50`,children:`Open a project`}),(0,N.jsx)(`button`,{onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,N.jsx)(ae,{})})]}),(0,N.jsx)(`div`,{className:`shrink-0 truncate border-b border-ink-700 px-3 py-1.5 text-ink-400`,children:s?.path??`…`}),(0,N.jsxs)(`ul`,{className:`h-72 min-h-0 overflow-y-auto`,children:[s?.parent&&(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{onClick:()=>o(s.parent),className:`w-full px-3 py-1 text-left text-ink-400 hover:bg-ink-850`,children:`../`})}),s?.entries.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{onClick:()=>x(e.name),className:`flex w-full items-center gap-2 px-3 py-1 text-left hover:bg-ink-850`,children:[(0,N.jsxs)(`span`,{className:`truncate text-accent`,children:[e.name,`/`]}),e.is_repo&&(0,N.jsx)(`span`,{className:`rounded-sm bg-ink-700 px-1 text-2xs text-ink-200`,children:`git`})]})},e.name)),s&&s.entries.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-1 text-ink-400`,children:`No sub-folders.`})]}),l&&(0,N.jsx)(`p`,{className:`shrink-0 px-3 py-1 text-removed`,children:l}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C()},placeholder:`New folder name`,"aria-label":`new folder name`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,N.jsx)(`button`,{onClick:C,disabled:!s||!p.trim()||h,"aria-busy":h,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,N.jsx)(A,{busy:h,children:`Create`})})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s&&i(s.path,_)},disabled:!n,placeholder:n?`Clone a git URL here`:`git is not installed on the server`,"aria-label":`git URL to clone`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none disabled:opacity-50`}),(0,N.jsx)(`button`,{onClick:()=>s&&i(s.path,_),disabled:!n||!s||!_.trim()||r,"aria-busy":r,title:n?void 0:`the server has no git on its PATH`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,N.jsx)(A,{busy:r,children:`Clone`})})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-ink-400`,children:s?s.path:``}),(0,N.jsx)(`button`,{onClick:S,disabled:!s||d,"aria-busy":d,className:`ml-auto shrink-0 rounded-sm bg-ink-50 px-3 py-1 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,N.jsx)(A,{busy:d,children:`Open`})})]})]})})}var Re=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='12%2057%201150%201150'%20role='img'%20aria-label='Black%20crow'%3e%3ctitle%3eBlack%20crow%3c/title%3e%3cdesc%3eMonochrome%20black%20crow%20silhouette%20on%20a%20transparent%20background,%20framed%20so%20the%20bird%20sits%20centred%20for%20use%20as%20an%20inline%20mark%20on%20a%20square%20tile.%3c/desc%3e%3cg%20fill-rule='evenodd'%20clip-rule='evenodd'%3e%3cpath%20fill='%23000000'%20d='M%20882%20147%20L%20859%20136%20L%20844%20131%20L%20831%20129%20L%20830%20128%20L%20815%20127%20L%20814%20126%20L%20796%20126%20L%20795%20127%20L%20786%20127%20L%20785%20128%20L%20775%20129%20L%20752%20136%20L%20732%20146%20L%20713%20160%20L%20701%20172%20L%20684%20172%20L%20683%20173%20L%20673%20173%20L%20672%20174%20L%20650%20176%20L%20649%20177%20L%20627%20181%20L%20602%20190%20L%20589%20197%20L%20579%20204%20L%20562%20221%20L%20562%20223%20L%20565%20223%20L%20578%20228%20L%20581%20228%20L%20612%20238%20L%20672%20252%20L%20684%20258%20L%20698%20271%20L%20702%20278%20L%20705%20288%20L%20705%20294%20L%20703%20301%20L%20699%20308%20L%20688%20318%20L%20630%20347%20L%20593%20372%20L%20561%20399%20L%20544%20416%20L%20522%20441%20L%20492%20481%20L%20461%20531%20L%20438%20576%20L%20431%20594%20L%20425%20602%20L%20405%20635%20L%20387%20668%20L%20385%20676%20L%20390%20679%20L%20368%20705%20L%20330%20755%20L%20306%20790%20L%20296%20808%20L%20289%20818%20L%20280%20838%20L%20280%20843%20L%20283%20845%20L%20292%20843%20L%20297%20840%20L%20299%20840%20L%20321%20828%20L%20322%20830%20L%20311%20844%20L%20288%20878%20L%20287%20881%20L%20259%20924%20L%20235%20965%20L%20205%201023%20L%20205%201025%20L%20197%201042%20L%20191%201061%20L%20191%201071%20L%20192%201072%20L%20198%201071%20L%20220%201056%20L%20242%201038%20L%20300%20986%20L%20302%20987%20L%20265%201040%20L%20264%201043%20L%20246%201070%20L%20235%201090%20L%20227%201112%20L%20227%201123%20L%20229%201128%20L%20234%201133%20L%20239%201135%20L%20255%201135%20L%20274%201129%20L%20279%201134%20L%20286%201137%20L%20290%201137%20L%20291%201138%20L%20310%201138%20L%20311%201137%20L%20317%201137%20L%20318%201136%20L%20326%201135%20L%20344%201129%20L%20369%201116%20L%20395%201097%20L%20420%201073%20L%20445%201042%20L%20457%201024%20L%20461%201016%20L%20464%201013%20L%20468%201011%20L%20489%20994%20L%20595%20901%20L%20601%20906%20L%20606%20913%20L%20614%20921%20L%20637%20949%20L%20639%20953%20L%20639%20956%20L%20636%20960%20L%20634%20961%20L%20619%20962%20L%20613%20965%20L%20605%20974%20L%20602%20982%20L%20602%20994%20L%20605%201001%20L%20608%201004%20L%20609%201004%20L%20609%20999%20L%20612%20992%20L%20616%20988%20L%20620%20986%20L%20627%20986%20L%20635%20983%20L%20645%20983%20L%20646%20982%20L%20655%20982%20L%20668%20986%20L%20676%20990%20L%20682%20996%20L%20685%201003%20L%20688%201006%20L%20696%201009%20L%20697%201012%20L%20697%201024%20L%20693%201033%20L%20693%201035%20L%20695%201035%20L%20700%201032%20L%20707%201025%20L%20710%201020%20L%20713%201010%20L%20713%201003%20L%20711%20998%20L%20711%20994%20L%20712%20993%20L%20719%201003%20L%20723%201005%20L%20727%201005%20L%20730%201011%20L%20730%201022%20L%20727%201031%20L%20728%201033%20L%20740%201021%20L%20743%201014%20L%20744%201003%20L%20747%20999%20L%20749%20992%20L%20748%20977%20L%20744%20968%20L%20740%20963%20L%20741%20962%20L%20755%20961%20L%20768%20964%20L%20777%20969%20L%20783%20975%20L%20786%20981%20L%20789%20984%20L%20795%20987%20L%20799%20987%20L%20801%20991%20L%20801%20997%20L%20802%20998%20L%20799%201013%20L%20802%201012%20L%20808%201007%20L%20813%201000%20L%20816%20991%20L%20816%20981%20L%20814%20976%20L%20814%20968%20L%20815%20967%20L%20819%20970%20L%20823%20970%20L%20826%20973%20L%20829%20980%20L%20830%20993%20L%20834%20990%20L%20838%20979%20L%20838%20968%20L%20832%20951%20L%20822%20940%20L%20815%20936%20L%20803%20933%20L%20776%20935%20L%20763%20931%20L%20753%20922%20L%20731%20898%20L%20703%20865%20L%20703%20863%20L%20710%20853%20L%20711%20855%20L%20707%20862%20L%20709%20862%20L%20718%20857%20L%20754%20832%20L%20793%20799%20L%20818%20774%20L%20849%20737%20L%20850%20741%20L%20845%20755%20L%20847%20755%20L%20861%20743%20L%20881%20721%20L%20906%20686%20L%20918%20665%20L%20933%20635%20L%20951%20590%20L%20971%20525%20L%20971%20521%20L%20974%20512%20L%20974%20508%20L%20978%20493%20L%20979%20482%20L%20980%20481%20L%20981%20466%20L%20982%20465%20L%20983%20441%20L%20982%20440%20L%20982%20428%20L%20981%20427%20L%20980%20414%20L%20978%20409%20L%20976%20397%20L%20970%20381%20L%20971%20379%20L%20974%20383%20L%20976%20381%20L%20977%20334%20L%20976%20333%20L%20976%20322%20L%20975%20321%20L%20974%20307%20L%20973%20306%20L%20973%20301%20L%20972%20300%20L%20969%20280%20L%20958%20243%20L%20949%20224%20L%20949%20222%20L%20939%20204%20L%20922%20181%20L%20903%20162%20Z%20M%20625%20888%20L%20656%20874%20L%20658%20874%20L%20665%20870%20L%20725%20930%20L%20728%20934%20L%20728%20940%20L%20723%20943%20L%20714%20944%20L%20707%20950%20L%20683%20951%20L%20673%20947%20L%20659%20932%20Z%20M%20787%20182%20L%20792%20182%20L%20796%20187%20L%20795%20192%20L%20791%20195%20L%20788%20195%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20895%20156%20L%20863%20138%20L%20838%20130%20L%20819%20127%20L%20789%20127%20L%20777%20129%20L%20753%20136%20L%20736%20144%20L%20717%20157%20L%20702%20172%20L%20652%20176%20L%20628%20181%20L%20607%20188%20L%20585%20200%20L%20562%20222%20L%20613%20238%20L%20670%20251%20L%20683%20257%20L%20697%20269%20L%20705%20286%20L%20705%20296%20L%20703%20302%20L%20698%20310%20L%20687%20319%20L%20631%20347%20L%20591%20374%20L%20568%20393%20L%20538%20423%20L%20520%20444%20L%20481%20498%20L%20457%20539%20L%20437%20579%20L%20432%20593%20L%20413%20622%20L%20386%20671%20L%20386%20677%20L%20390%20677%20L%20391%20679%20L%20374%20698%20L%20334%20750%20L%20307%20789%20L%20290%20817%20L%20280%20839%20L%20281%20844%20L%20291%20843%20L%20323%20826%20L%20325%20827%20L%20289%20877%20L%20237%20962%20L%20209%201015%20L%20198%201040%20L%20191%201063%20L%20191%201070%20L%20194%201072%20L%20213%201061%20L%20259%201023%20L%20302%20984%20L%20303%20985%20L%20262%201045%20L%20245%201072%20L%20233%201095%20L%20227%201114%20L%20228%201126%20L%20233%201132%20L%20242%201135%20L%20252%201135%20L%20274%201128%20L%20278%201133%20L%20288%201137%20L%20313%201137%20L%20343%201129%20L%20373%201113%20L%20398%201094%20L%20424%201068%20L%20441%201047%20L%20465%201012%20L%20520%20967%20L%20595%20900%20L%20611%20917%20L%20639%20952%20L%20639%20957%20L%20637%20960%20L%20632%20962%20L%20618%20963%20L%20611%20967%20L%20606%20973%20L%20602%20983%20L%20602%20992%20L%20608%201004%20L%20611%20993%20L%20619%20986%20L%20626%20986%20L%20643%20982%20L%20656%20982%20L%20675%20989%20L%20683%20997%20L%20688%201006%20L%20696%201009%20L%20697%201025%20L%20693%201034%20L%20694%201035%20L%20701%201031%20L%20710%201019%20L%20712%201013%20L%20712%20993%20L%20720%201003%20L%20727%201005%20L%20730%201009%20L%20730%201025%20L%20727%201032%20L%20732%201030%20L%20739%201022%20L%20743%201013%20L%20743%201004%20L%20749%20991%20L%20748%20978%20L%20740%20964%20L%20743%20961%20L%20757%20961%20L%20769%20964%20L%20781%20972%20L%20791%20985%20L%20798%20986%20L%20802%20994%20L%20802%201003%20L%20799%201013%20L%20810%201004%20L%20815%20994%20L%20816%20983%20L%20814%20977%20L%20814%20965%20L%20818%20969%20L%20825%20971%20L%20830%20983%20L%20830%20993%20L%20833%20991%20L%20837%20982%20L%20838%20969%20L%20834%20956%20L%20825%20943%20L%20820%20939%20L%20807%20934%20L%20774%20935%20L%20762%20931%20L%20736%20904%20L%20702%20864%20L%20715%20845%20L%20716%20847%20L%20707%20862%20L%20719%20856%20L%20744%20839%20L%20786%20805%20L%20824%20767%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20853%20750%20L%20883%20718%20L%20906%20685%20L%20927%20647%20L%20951%20589%20L%20968%20535%20L%20976%20502%20L%20982%20461%20L%20981%20422%20L%20976%20398%20L%20968%20378%20L%20969%20376%20L%20975%20383%20L%20977%20341%20L%20970%20286%20L%20958%20244%20L%20945%20215%20L%20925%20185%20L%20906%20165%20Z%20M%20625%20888%20L%20665%20870%20L%20728%20933%20L%20729%20940%20L%20726%20943%20L%20715%20944%20L%20708%20950%20L%20692%20952%20L%20678%20950%20L%20672%20947%20L%20662%20936%20Z%20M%20785%20183%20L%20792%20182%20L%20796%20186%20L%20796%20191%20L%20791%20195%20L%20785%20194%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20896%20157%20L%20869%20141%20L%20837%20130%20L%20817%20127%20L%20792%20127%20L%20778%20129%20L%20751%20137%20L%20733%20146%20L%20715%20159%20L%20702%20172%20L%20653%20176%20L%20610%20187%20L%20581%20203%20L%20562%20222%20L%20625%20241%20L%20671%20251%20L%20683%20257%20L%20698%20270%20L%20705%20285%20L%20704%20300%20L%20699%20309%20L%20689%20318%20L%20628%20349%20L%20581%20382%20L%20540%20421%20L%20517%20448%20L%20478%20503%20L%20456%20541%20L%20439%20575%20L%20432%20593%20L%20412%20624%20L%20388%20667%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20363%20712%20L%20332%20753%20L%20289%20819%20L%20281%20836%20L%20281%20844%20L%20293%20842%20L%20323%20826%20L%20325%20827%20L%20284%20885%20L%20236%20964%20L%20205%201024%20L%20197%201043%20L%20191%201064%20L%20191%201070%20L%20197%201071%20L%20210%201063%20L%20253%201028%20L%20303%20983%20L%20304%20984%20L%20259%201050%20L%20235%201091%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20238%201134%20L%20249%201135%20L%20261%201133%20L%20274%201128%20L%20278%201133%20L%20289%201137%20L%20312%201137%20L%20342%201129%20L%20368%201116%20L%20399%201093%20L%20423%201069%20L%20443%201044%20L%20463%201013%20L%20493%20990%20L%20595%20900%20L%20612%20918%20L%20639%20952%20L%20639%20957%20L%20636%20961%20L%20616%20964%20L%20606%20973%20L%20602%20984%20L%20602%20991%20L%20608%201004%20L%20611%20993%20L%20621%20985%20L%20625%20986%20L%20639%20982%20L%20657%20982%20L%20677%20990%20L%20685%201002%20L%20690%201007%20L%20697%201010%20L%20698%201021%20L%20693%201034%20L%20694%201035%20L%20705%201027%20L%20710%201018%20L%20712%201011%20L%20712%201001%20L%20710%20994%20L%20712%20993%20L%20720%201003%20L%20729%201006%20L%20731%201020%20L%20728%201032%20L%20738%201023%20L%20743%201012%20L%20743%201003%20L%20748%20994%20L%20747%20976%20L%20740%20964%20L%20743%20961%20L%20759%20961%20L%20767%20963%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201004%20L%20799%201012%20L%20803%201011%20L%20810%201004%20L%20815%20994%20L%20814%20965%20L%20818%20969%20L%20823%20969%20L%20830%20982%20L%20830%20992%20L%20832%20992%20L%20837%20982%20L%20837%20965%20L%20831%20950%20L%20821%20940%20L%20806%20934%20L%20772%20935%20L%20762%20931%20L%20733%20901%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20707%20862%20L%20738%20843%20L%20780%20810%20L%20822%20769%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20855%20748%20L%20882%20719%20L%20904%20688%20L%20930%20640%20L%20950%20591%20L%20967%20538%20L%20978%20490%20L%20982%20459%20L%20982%20434%20L%20976%20399%20L%20967%20376%20L%20969%20375%20L%20975%20383%20L%20976%20329%20L%20971%20293%20L%20960%20250%20L%20942%20210%20L%20923%20183%20Z%20M%20625%20888%20L%20665%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20708%20950%20L%20695%20952%20L%20677%20950%20L%20666%20941%20Z%20M%20786%20182%20L%20790%20181%20L%20794%20183%20L%20797%20188%20L%20792%20195%20L%20787%20195%20L%20782%20190%20L%20782%20187%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20873%20143%20L%20841%20131%20L%20816%20127%20L%20794%20127%20L%20779%20129%20L%20754%20136%20L%20735%20145%20L%20715%20159%20L%20702%20172%20L%20648%20177%20L%20629%20181%20L%20608%20188%20L%20584%20201%20L%20562%20222%20L%20614%20238%20L%20671%20251%20L%20685%20258%20L%20698%20270%20L%20704%20281%20L%20706%20292%20L%20703%20303%20L%20699%20309%20L%20686%20320%20L%20628%20349%20L%20590%20375%20L%20565%20396%20L%20543%20418%20L%20518%20447%20L%20490%20485%20L%20460%20534%20L%20441%20571%20L%20431%20595%20L%20405%20636%20L%20386%20672%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20371%20702%20L%20335%20749%20L%20291%20816%20L%20280%20840%20L%20282%20844%20L%20298%20840%20L%20324%20825%20L%20326%20826%20L%20294%20870%20L%20235%20966%20L%20206%201022%20L%20198%201041%20L%20191%201065%20L%20191%201070%20L%20196%201071%20L%20214%201060%20L%20254%201027%20L%20303%20983%20L%20304%20984%20L%20256%201055%20L%20232%201098%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20239%201134%20L%20248%201135%20L%20264%201132%20L%20274%201128%20L%20280%201134%20L%20289%201137%20L%20311%201137%20L%20339%201130%20L%20371%201114%20L%20401%201091%20L%20422%201070%20L%20440%201048%20L%20463%201013%20L%20487%20995%20L%20595%20900%20L%20613%20919%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20605%20975%20L%20602%20991%20L%20604%20998%20L%20608%201003%20L%20611%20993%20L%20620%20985%20L%20624%20986%20L%20632%20983%20L%20647%20981%20L%20658%20982%20L%20677%20990%20L%20689%201006%20L%20697%201009%20L%20698%201021%20L%20694%201035%20L%20703%201029%20L%20710%201018%20L%20712%201010%20L%20712%201002%20L%20710%20997%20L%20711%20992%20L%20720%201003%20L%20728%201005%20L%20730%201008%20L%20731%201021%20L%20728%201032%20L%20738%201023%20L%20742%201014%20L%20743%201003%20L%20748%20994%20L%20748%20980%20L%20742%20966%20L%20739%20963%20L%20741%20961%20L%20753%20960%20L%20770%20964%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20804%201010%20L%20809%201005%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20823%20969%20L%20826%20972%20L%20830%20982%20L%20831%20992%20L%20834%20989%20L%20838%20975%20L%20837%20966%20L%20831%20950%20L%20821%20940%20L%20804%20934%20L%20779%20936%20L%20763%20932%20L%20731%20899%20L%20702%20865%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20708%20862%20L%20749%20835%20L%20781%20809%20L%20820%20771%20L%20851%20733%20L%20852%20736%20L%20846%20755%20L%20857%20746%20L%20881%20720%20L%20907%20683%20L%20928%20644%20L%20945%20604%20L%20967%20537%20L%20978%20489%20L%20982%20455%20L%20982%20437%20L%20979%20413%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20332%20L%20972%20299%20L%20962%20257%20L%20954%20235%20L%20943%20212%20L%20923%20183%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20706%20951%20L%20684%20952%20L%20677%20950%20L%20665%20940%20Z%20M%20701%20220%20L%20710%20219%20L%20717%20221%20L%20704%20223%20L%20704%20221%20Z%20M%20666%20217%20L%20679%20216%20L%20689%20218%20L%20685%20220%20L%20675%20220%20Z%20M%20658%20210%20L%20661%20208%20L%20686%20205%20L%20706%20206%20L%20725%20209%20L%20733%20217%20L%20741%20220%20L%20738%20221%20L%20696%20214%20L%20661%20212%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20188%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20864%20139%20L%20836%20130%20L%20813%20127%20L%20796%20127%20L%20774%20130%20L%20749%20138%20L%20735%20145%20L%20720%20155%20L%20702%20172%20L%20687%20173%20L%20700%20174%20L%20694%20181%20L%20674%20184%20L%20670%20180%20L%20665%20183%20L%20657%20184%20L%20639%20196%20L%20641%20198%20L%20647%20198%20L%20648%20194%20L%20654%20193%20L%20686%20204%20L%20724%20208%20L%20740%20213%20L%20751%20222%20L%20750%20223%20L%20693%20214%20L%20671%20212%20L%20639%20212%20L%20636%20211%20L%20634%20207%20L%20629%20207%20L%20626%20210%20L%20617%20210%20L%20614%20208%20L%20604%20207%20L%20594%20213%20L%20582%20216%20L%20580%20214%20L%20581%20210%20L%20576%20208%20L%20586%20200%20L%20565%20218%20L%20563%20222%20L%20618%20239%20L%20671%20251%20L%20682%20256%20L%20689%20261%20L%20702%20276%20L%20706%20288%20L%20704%20301%20L%20700%20308%20L%20683%20322%20L%20630%20348%20L%20585%20379%20L%20563%20398%20L%20523%20441%20L%20497%20475%20L%20459%20536%20L%20443%20567%20L%20431%20595%20L%20411%20626%20L%20387%20670%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20368%20706%20L%20333%20752%20L%20290%20818%20L%20281%20837%20L%20282%20844%20L%20300%20839%20L%20324%20825%20L%20326%20826%20L%20285%20884%20L%20242%20954%20L%20207%201020%20L%20192%201060%20L%20192%201071%20L%20196%201071%20L%20211%201062%20L%20240%201039%20L%20303%20983%20L%20305%20984%20L%20277%201023%20L%20242%201078%20L%20228%201110%20L%20227%201119%20L%20231%201130%20L%20239%201134%20L%20255%201134%20L%20274%201128%20L%20280%201134%20L%20285%201136%20L%20310%201137%20L%20339%201130%20L%20374%201112%20L%20394%201097%20L%20421%201071%20L%20445%201041%20L%20463%201013%20L%20488%20994%20L%20595%20900%20L%20614%20920%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20607%20972%20L%20603%20980%20L%20602%20989%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20620%20985%20L%20623%20986%20L%20631%20983%20L%20647%20981%20L%20665%20984%20L%20676%20989%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201023%20L%20694%201035%20L%20699%201032%20L%20709%201020%20L%20712%201010%20L%20710%20997%20L%20711%20992%20L%20719%201002%20L%20725%201005%20L%20727%201004%20L%20730%201008%20L%20731%201022%20L%20728%201032%20L%20739%201021%20L%20743%201010%20L%20743%201003%20L%20748%20993%20L%20748%20981%20L%20746%20974%20L%20739%20963%20L%20741%20961%20L%20755%20960%20L%20770%20964%20L%20779%20970%20L%20789%20983%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20808%201006%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20825%20970%20L%20829%20978%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20832%20952%20L%20822%20941%20L%20813%20936%20L%20803%20934%20L%20776%20936%20L%20763%20932%20L%20723%20890%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20708%20862%20L%20742%20840%20L%20782%20808%20L%20818%20773%20L%20851%20733%20L%20852%20736%20L%20846%20754%20L%20850%20752%20L%20881%20720%20L%20905%20686%20L%20932%20635%20L%20950%20590%20L%20969%20529%20L%20977%20494%20L%20982%20454%20L%20980%20419%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20334%20L%20969%20284%20L%20959%20248%20L%20941%20209%20L%20921%20181%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20941%20L%20724%20944%20L%20716%20944%20L%20707%20951%20L%20683%20952%20L%20673%20948%20L%20659%20933%20Z%20M%20563%20618%20L%20569%20614%20L%20579%20621%20L%20576%20626%20L%20572%20627%20L%20568%20623%20L%20565%20623%20Z%20M%20575%20603%20L%20578%20603%20L%20588%20613%20L%20588%20619%20L%20585%20621%20L%20582%20620%20L%20575%20613%20L%20576%20612%20L%20573%20605%20Z%20M%20748%20398%20L%20752%20412%20L%20752%20432%20L%20748%20444%20L%20732%20470%20L%20716%20484%20L%20698%20493%20L%20685%20494%20L%20682%20491%20L%20707%20445%20L%20685%20473%20L%20667%20492%20L%20647%20508%20L%20632%20517%20L%20619%20519%20L%20615%20517%20L%20615%20513%20L%20643%20470%20L%20603%20514%20L%20589%20526%20L%20569%20538%20L%20558%20540%20L%20554%20539%20L%20552%20535%20L%20577%20498%20L%20549%20528%20L%20526%20546%20L%20508%20554%20L%20498%20555%20L%20495%20552%20L%20501%20541%20L%20482%20555%20L%20471%20558%20L%20464%20558%20L%20461%20560%20L%20460%20559%20L%20461%20555%20L%20469%20547%20L%20473%20537%20L%20491%20512%20L%20511%20497%20L%20582%20434%20L%20617%20408%20L%20632%20399%20L%20659%20386%20L%20677%20380%20L%20695%20377%20L%20712%20377%20L%20725%20380%20L%20739%20388%20Z%20M%20625%20216%20L%20683%20216%20L%20737%20222%20L%20742%20224%20L%20733%20226%20L%20721%20225%20L%20713%20230%20L%20711%20228%20L%20706%20228%20L%20694%20237%20L%20690%20233%20L%20690%20225%20L%20679%20228%20L%20674%20232%20L%20668%20232%20L%20659%20229%20L%20649%20222%20L%20632%20219%20L%20632%20217%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20795%20193%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20607%20972%20L%20603%20981%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20616%20987%20L%20620%20985%20L%20627%20985%20L%20635%20982%20L%20655%20981%20L%20676%20989%20L%20683%20996%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201024%20L%20694%201034%20L%20699%201032%20L%20706%201025%20L%20712%201010%20L%20710%20994%20L%20709%20997%20L%20706%20994%20L%20700%20994%20L%20694%20997%20L%20672%20976%20L%20658%20974%20L%20647%20967%20L%20642%20974%20L%20638%20974%20L%20636%20972%20L%20636%20961%20L%20629%20963%20L%20631%20972%20L%20625%20977%20L%20620%20977%20L%20613%20967%20L%20614%20966%20Z%20M%20686%20966%20L%20704%20980%20L%20719%201002%20L%20727%201004%20L%20730%201007%20L%20731%201023%20L%20728%201032%20L%20731%201030%20L%20741%201017%20L%20743%201003%20L%20748%20992%20L%20748%20981%20L%20742%20967%20L%20740%20965%20L%20742%20968%20L%20735%20972%20L%20726%20965%20L%20705%20960%20L%20724%20968%20L%20740%20983%20L%20742%20987%20L%20740%20991%20L%20732%20991%20L%20728%20996%20L%20726%20996%20L%20721%20992%20L%20713%20979%20Z%20M%20784%20943%20L%20784%20946%20L%20798%20950%20L%20819%20969%20L%20825%20970%20L%20830%20981%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20829%20948%20L%20825%20944%20L%20830%20950%20L%20821%20957%20L%20813%20951%20L%20794%20942%20Z%20M%20659%20933%20L%20662%20937%20L%20658%20942%20L%20658%20945%20L%20663%20947%20L%20666%20945%20L%20667%20946%20L%20668%20944%20L%20670%20946%20Z%20M%20643%20913%20L%20647%20918%20L%20644%20921%20L%20642%20928%20L%20629%20938%20L%20627%20936%20L%20636%20947%20L%20634%20945%20L%20641%20933%20L%20651%20923%20L%20657%20930%20Z%20M%20936%20310%20L%20934%20309%20L%20945%20338%20L%20949%20368%20L%20949%20381%20L%20947%20383%20L%20935%20367%20L%20914%20348%20L%20929%20377%20L%20934%20397%20L%20936%20414%20L%20935%20440%20L%20933%20442%20L%20930%20440%20L%20924%20419%20L%20912%20395%20L%20909%20393%20L%20910%20410%20L%20907%20433%20L%20899%20458%20L%20895%20462%20L%20893%20460%20L%20892%20445%20L%20888%20427%20L%20873%20390%20L%20873%20416%20L%20871%20430%20L%20866%20448%20L%20862%20454%20L%20859%20452%20L%20853%20433%20L%20842%20410%20L%20823%20382%20L%20807%20365%20L%20805%20366%20L%20811%20394%20L%20812%20416%20L%20810%20425%20L%20806%20428%20L%20801%20423%20L%20790%20403%20L%20772%20383%20L%20759%20372%20L%20733%20357%20L%20724%20355%20L%20705%20346%20L%20693%20344%20L%20669%20344%20L%20646%20349%20L%20636%20353%20L%20662%20349%20L%20677%20349%20L%20699%20353%20L%20708%20356%20L%20725%20366%20L%20736%20376%20L%20745%20389%20L%20753%20415%20L%20752%20442%20L%20743%20476%20L%20723%20520%20L%20693%20569%20L%20646%20631%20L%20605%20676%20L%20568%20709%20L%20565%20710%20L%20562%20706%20L%20562%20692%20L%20567%20665%20L%20578%20636%20L%20602%20619%20L%20622%20602%20L%20645%20578%20L%20670%20546%20L%20630%20588%20L%20603%20610%20L%20574%20628%20L%20560%20633%20L%20556%20633%20L%20555%20631%20L%20563%20617%20L%20596%20572%20L%20647%20509%20L%20636%20515%20L%20562%20609%20L%20541%20630%20L%20520%20645%20L%20502%20653%20L%20490%20653%20L%20536%20590%20L%20513%20617%20L%20478%20651%20L%20454%20665%20L%20440%20669%20L%20436%20667%20L%20488%20596%20L%20459%20630%20L%20436%20653%20L%20411%20671%20L%20392%20678%20L%20372%20701%20L%20319%20772%20L%20289%20820%20L%20281%20838%20L%20282%20844%20L%20295%20841%20L%20324%20825%20L%20326%20826%20L%20289%20878%20L%20242%20954%20L%20209%201016%20L%20193%201056%20L%20191%201069%20L%20192%201071%20L%20196%201071%20L%20219%201056%20L%20303%20983%20L%20305%20984%20L%20255%201057%20L%20234%201094%20L%20228%201111%20L%20228%201124%20L%20234%201132%20L%20240%201134%20L%20254%201134%20L%20275%201128%20L%20279%201133%20L%20291%201137%20L%20316%201136%20L%20344%201128%20L%20364%201118%20L%20389%201101%20L%20403%201089%20L%20427%201064%20L%20447%201038%20L%20463%201013%20L%20489%20993%20L%20594%20901%20L%20595%20899%20L%20593%20894%20L%20588%20891%20L%20567%20868%20L%20569%20865%20L%20576%20867%20L%20586%20873%20L%20589%20867%20L%20607%20867%20L%20619%20880%20L%20622%20887%20L%20626%20891%20L%20624%20889%20L%20626%20886%20L%20666%20870%20L%20705%20909%20L%20710%20905%20L%20713%20905%20L%20716%20908%20L%20716%20911%20L%20712%20916%20L%20728%20932%20L%20730%20939%20L%20727%20943%20L%20717%20944%20L%20710%20949%20L%20712%20948%20L%20725%20951%20L%20739%20963%20L%20740%20961%20L%20756%20960%20L%20774%20966%20L%20784%20975%20L%20789%20983%20L%20800%20987%20L%20802%20991%20L%20802%201005%20L%20799%201012%20L%20806%201008%20L%20811%201002%20L%20815%20993%20L%20813%20968%20L%20812%20973%20L%20807%20971%20L%20796%20976%20L%20791%20973%20L%20788%20967%20L%20779%20958%20L%20767%20952%20L%20762%20941%20L%20756%20940%20L%20751%20932%20L%20749%20931%20L%20743%20936%20L%20738%20936%20L%20736%20933%20L%20741%20925%20L%20739%20915%20L%20742%20912%20L%20745%20914%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20709%20861%20L%20746%20837%20L%20783%20807%20L%20826%20764%20L%20851%20732%20L%20853%20734%20L%20846%20754%20L%20851%20751%20L%20874%20728%20L%20890%20708%20L%20908%20681%20L%20938%20621%20L%20960%20560%20L%20971%20521%20L%20979%20481%20L%20982%20444%20L%20977%20405%20L%20970%20382%20L%20966%20375%20L%20968%20374%20L%20974%20381%20L%20975%20368%20L%20974%20372%20L%20968%20364%20L%20966%20354%20L%20957%20337%20Z%20M%20247%201077%20L%20251%201085%20L%20246%201088%20L%20245%201091%20L%20240%201092%20L%20239%201085%20L%20241%201081%20Z%20M%20370%20935%20L%20371%20937%20L%20326%20997%20L%20301%201034%20L%20289%201044%20L%20286%201042%20L%20283%201045%20L%20277%201045%20L%20273%201043%20L%20264%201052%20L%20261%201049%20L%20270%201037%20L%20271%201038%20L%20281%201027%20L%20293%201010%20L%20326%20971%20Z%20M%20726%20921%20L%20728%20921%20L%20731%20926%20L%20729%20933%20L%20722%20926%20Z%20M%20729%20897%20L%20734%20902%20L%20732%20906%20L%20726%20902%20L%20726%20899%20Z%20M%20715%20882%20L%20720%20886%20L%20718%20890%20L%20711%20887%20Z%20M%20605%20762%20L%20608%20761%20L%20607%20760%20L%20609%20757%20L%20610%20759%20L%20617%20761%20L%20620%20764%20L%20611%20770%20L%20607%20770%20L%20606%20765%20L%20608%20765%20Z%20M%20611%20754%20L%20617%20750%20L%20620%20751%20L%20621%20749%20L%20625%20749%20L%20628%20752%20L%20628%20756%20L%20623%20761%20Z%20M%20549%20710%20L%20551%20713%20L%20551%20722%20L%20506%20774%20L%20403%20878%20L%20309%20963%20L%20307%20961%20L%20313%20953%20L%20322%20945%20L%20340%20922%20L%20375%20885%20Z%20M%20695%20704%20L%20696%20708%20L%20698%20709%20L%20695%20710%20L%20695%20713%20L%20692%20715%20L%20688%20710%20Z%20M%20704%20694%20L%20706%20695%20L%20706%20698%20L%20710%20698%20L%20713%20703%20L%20708%20708%20L%20707%20714%20L%20705%20716%20L%20701%20716%20L%20697%20708%20L%20699%20706%20L%20697%20705%20L%20701%20701%20L%20704%20705%20L%20706%20704%20L%20706%20700%20L%20702%20697%20Z%20M%20552%20678%20L%20554%20681%20L%20552%20701%20L%20465%20787%20L%20361%20883%20L%20316%20927%20L%20253%20993%20L%20211%201042%20L%20211%201036%20L%20222%201011%20L%20261%20942%20L%20292%20898%20L%20338%20843%20L%20374%20807%20L%20387%20807%20L%20403%20801%20L%20419%20792%20L%20456%20766%20L%20500%20728%20Z%20M%20704%20654%20L%20706%20658%20L%20711%20658%20L%20714%20661%20L%20715%20673%20L%20713%20676%20L%20705%20676%20L%20702%20674%20L%20704%20677%20L%20704%20681%20L%20702%20682%20L%20704%20685%20L%20700%20686%20L%20694%20678%20L%20691%20678%20L%20688%20674%20L%20692%20670%20L%20692%20664%20L%20694%20661%20Z%20M%20565%20642%20L%20558%20663%20L%20545%20677%20L%20494%20726%20L%20443%20767%20L%20401%20792%20L%20392%20795%20L%20387%20794%20L%20405%20766%20L%20455%20707%20L%20388%20767%20L%20355%20794%20L%20304%20827%20L%20299%20826%20L%20302%20817%20L%20316%20795%20L%20360%20739%20L%20398%20700%20L%20425%20677%20L%20428%20679%20L%20443%20679%20L%20461%20673%20L%20476%20664%20L%20493%20666%20L%20517%20657%20L%20542%20641%20L%20546%20643%20Z%20M%20563%20221%20L%20572%20225%20L%20571%20223%20L%20574%20220%20L%20585%20217%20L%20596%20218%20L%20607%20215%20L%20653%20214%20L%20706%20218%20L%20749%20224%20L%20749%20226%20L%20735%20233%20L%20732%20238%20L%20732%20249%20L%20693%20242%20L%20620%20239%20L%20672%20251%20L%20688%20260%20L%20701%20274%20L%20706%20287%20L%20704%20301%20L%20707%20297%20L%20711%20300%20L%20713%20309%20L%20720%20324%20L%20723%20327%20L%20724%20308%20L%20726%20304%20L%20735%20318%20L%20757%20341%20L%20753%20319%20L%20754%20313%20L%20760%20317%20L%20786%20345%20L%20784%20324%20L%20775%20300%20L%20779%20300%20L%20800%20317%20L%20800%20312%20L%20787%20283%20L%20772%20264%20L%20778%20263%20L%20800%20271%20L%20803%20270%20L%20770%20236%20L%20772%20234%20L%20797%20234%20L%20807%20230%20L%20801%20230%20L%20800%20228%20L%20811%20218%20L%20818%20203%20L%20818%20193%20L%20812%20179%20L%20798%20168%20L%20784%20166%20L%20760%20173%20L%20747%20173%20L%20712%20163%20L%20718%20157%20L%20703%20171%20L%20711%20173%20L%20720%20178%20L%20723%20182%20L%20720%20186%20L%20695%20190%20L%20680%20190%20L%20670%20193%20L%20656%20193%20L%20687%20204%20L%20729%20209%20L%20742%20214%20L%20753%20223%20L%20752%20224%20L%20729%20219%20L%20669%20212%20L%20610%20213%20L%20576%20218%20L%20565%20221%20L%20565%20219%20Z%20M%20771%20189%20L%20772%20201%20L%20775%20207%20L%20780%20212%20L%20787%20215%20L%20796%20216%20L%20796%20218%20L%20784%20219%20L%20776%20215%20L%20771%20210%20L%20768%20204%20L%20768%20194%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20796%20192%20L%20790%20196%20L%20786%20195%20L%20782%20191%20L%20782%20186%20Z'/%3e%3c/g%3e%3c/svg%3e`;function ze({className:e}){return(0,N.jsx)(`span`,{className:`block overflow-hidden rounded-[20.7%] bg-accent ${e??``}`,children:(0,N.jsx)(`img`,{src:Re,alt:``,"aria-hidden":`true`,className:`h-full w-full`})})}function Be(){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ze,{className:`h-[22px] w-[22px] shrink-0`}),(0,N.jsx)(`span`,{className:`hidden text-[16px] font-medium tracking-[0.04em] text-ink-50 md:inline`,children:`nightcrow`})]})}function Ve({open:e}){return(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-3.5 w-3.5 shrink-0 transition-transform ${e?`rotate-90`:``}`,children:(0,N.jsx)(`path`,{d:`m9 18 6-6-6-6`})})}function He({className:e=`h-4 w-4`}){return(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,N.jsx)(`path`,{d:`M3 6h.01`}),(0,N.jsx)(`path`,{d:`M3 12h.01`}),(0,N.jsx)(`path`,{d:`M3 18h.01`}),(0,N.jsx)(`path`,{d:`M8 6h13`}),(0,N.jsx)(`path`,{d:`M8 12h13`}),(0,N.jsx)(`path`,{d:`M8 18h13`})]})}function Ue({className:e=`h-4 w-4`}){return(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,N.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`}),(0,N.jsx)(`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`}),(0,N.jsx)(`path`,{d:`M10 9H8`}),(0,N.jsx)(`path`,{d:`M16 13H8`}),(0,N.jsx)(`path`,{d:`M16 17H8`})]})}function We({className:e=`h-4 w-4`}){return(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,N.jsx)(`path`,{d:`m4 17 6-6-6-6`}),(0,N.jsx)(`path`,{d:`M12 19h8`})]})}function Ge({repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i,className:a=``}){let[o,s]=(0,M.useState)(!1),c=f(),l=(0,M.useRef)(null),u=e.find(e=>e.id===t);return(0,M.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(s(!1),l.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]),(0,N.jsxs)(`div`,{className:`relative min-w-0 flex-1 ${a}`,children:[(0,N.jsxs)(`button`,{ref:l,onClick:()=>s(e=>!e),"aria-haspopup":`menu`,"aria-expanded":o,title:u?.display_path??`Select a project`,className:`flex min-w-0 max-w-full items-center gap-1 rounded-sm bg-ink-700 py-0.5 pl-2 pr-1 text-ink-50`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:u?.name??`No project`}),(0,N.jsx)(Ve,{open:o})]}),o&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>s(!1)}),(0,N.jsxs)(`div`,{role:`menu`,className:`nc-pop-in origin-top-left absolute left-0 z-50 mt-1 max-h-[70vh] w-56 max-w-[80vw] overflow-y-auto rounded-md border border-ink-700 bg-ink-900 py-1 shadow-lg`,children:[e.length===0&&(0,N.jsx)(`p`,{className:`px-3 py-1.5 text-ink-400`,children:`No projects open.`}),e.map(e=>(0,N.jsxs)(`div`,{className:`flex items-center ${e.id===t?`bg-ink-700 text-ink-50`:`text-ink-200`}`,children:[(0,N.jsx)(`button`,{role:`menuitem`,onClick:()=>{n(e.id),s(!1)},title:e.display_path,className:`min-w-0 flex-1 truncate py-1.5 pl-3 pr-1 text-left hover:text-accent`,children:e.name}),(0,N.jsx)(`button`,{onClick:()=>r(e.id),"aria-label":`close ${e.name}`,...e.id===t?c(`project.close`,`Close project`):{title:`Close project`},className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,N.jsx)(ae,{className:`h-3.5 w-3.5`})})]},e.id)),(0,N.jsx)(`div`,{className:`my-1 border-t border-ink-800`}),(0,N.jsxs)(`button`,{role:`menuitem`,onClick:()=>{i(),s(!1)},...c(`project.openDialog`,`Open a project`),className:`flex w-full items-center gap-1 px-3 py-1.5 text-left text-ink-400 hover:text-ink-200`,children:[(0,N.jsx)(ne,{className:`h-3.5 w-3.5`}),`open`]})]})]})]})}function Ke({side:e,repos:t,repo:n,onSelectRepo:r,onCloseRepo:i,onOpenPicker:a,draggingRepo:o,dragOverRepo:s,onRepoDragStart:u,onRepoDragMove:p,onRepoDragEnd:m}){let h=f(),g=c(),_=t.length>1?[`project.previous`,`project.next`]:[],v=e=>e!==null,b=_.map(e=>_e(e,g)).filter(v),x=_.map(e=>d(e,g)).filter(v),S=e===`left`;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`nav`,{"aria-keyshortcuts":b.length>0?b.join(` `):void 0,title:x.length>0?`Previous or next project (${x.join(`, `)})`:void 0,className:S?`hidden min-h-0 flex-1 flex-col overflow-y-auto md:flex`:`hidden items-stretch self-stretch overflow-x-auto pl-1 md:flex`,children:t.map(e=>(0,N.jsxs)(`div`,{"data-repo-id":e.id,onPointerDown:t=>u(t,e.id),onPointerMove:p,onPointerUp:m,onPointerCancel:m,onLostPointerCapture:m,"data-active":e.id===n,className:`nc-title-target flex items-center whitespace-nowrap ${S?`min-w-0 border-b border-ink-700`:`border-r border-ink-700`} ${t.length>1?`touch-none`:``} ${o===e.id?`opacity-60`:``} ${s===e.id?`bg-ink-800 ring-1 ring-inset ring-accent`:``} ${e.id===n?S?`bg-ink-900 text-ink-50 shadow-[inset_1px_0_0_0_var(--color-accent)]`:`bg-ink-950 text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:bg-ink-850 hover:text-ink-200`}`,title:e.display_path,children:[(0,N.jsx)(`button`,{onClick:()=>{r(e.id)},"aria-label":e.name,className:`self-stretch pl-3 pr-1 text-left ${S?`min-w-0 flex-1 py-2`:``}`,children:(0,N.jsx)(l,{title:e.name,className:S?``:y})}),(0,N.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e.id)},"data-tab-close":!0,...e.id===n?h(`project.close`,`Close project`):{title:`Close project`},"aria-label":`close ${e.name}`,className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,N.jsx)(ae,{})})]},e.id))}),(0,N.jsxs)(`button`,{onClick:a,...h(`project.openDialog`,`Open a project`),className:`hidden shrink-0 items-center gap-1 rounded-sm px-2 py-0.5 text-ink-400 hover:text-accent md:inline-flex ${S?`mx-1 my-2 justify-center`:``}`,children:[(0,N.jsx)(ne,{className:`h-3.5 w-3.5`}),`open`]})]})}var qe={key:()=>je(`/api/push/key`).then(e=>e.public_key),subscribe:e=>Oe(`/api/push/subscribe`,e),unsubscribe:e=>Oe(`/api/push/unsubscribe`,{endpoint:e}),status:e=>Oe(`/api/push/status`,{endpoint:e}).then(e=>e.subscribed),test:e=>Oe(`/api/push/test`,{endpoint:e})};function Je(){let e=navigator;return{secure:window.isSecureContext,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0,hasPushManager:`PushManager`in window,permission:()=>typeof Notification>`u`?void 0:Notification.permission,requestPermission:()=>Notification.requestPermission(),isIos:/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&navigator.maxTouchPoints>1,standalone:e.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`).matches===!0}}function Ye(e){return e.secure?e.isIos&&!e.standalone?`needs-install`:!e.serviceWorker||!e.hasPushManager||e.permission()===void 0?`unsupported`:e.permission()===`denied`?`denied`:null:`insecure`}function Xe(e){e.secure&&e.serviceWorker&&e.serviceWorker.register(`./sw.js`).catch(()=>{})}async function Ze(e){return(await e.serviceWorker.ready).pushManager.getSubscription()}async function Qe(e){let t=Ye(e);if(t)return t;let n=await Ze(e);return n?await qe.status(n.endpoint)?`on`:(await n.unsubscribe().catch(()=>!1),`off`):`off`}async function $e(e){let t=Ye(e);if(t)return t;let n=await e.requestPermission();if(n===`denied`)return`denied`;if(n!==`granted`)return`off`;let r;try{r=await qe.key()}catch{return`unavailable`}let i=await e.serviceWorker.ready;await(await i.pushManager.getSubscription())?.unsubscribe();let a=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:nt(r)});return await qe.subscribe(a.toJSON()),`on`}async function et(e){let t=await Ze(e);return t&&(await qe.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>!1)),Ye(e)??`off`}async function tt(e){let t=await Ze(e);if(!t)throw Error(`notifications are off in this browser`);await qe.test(t.endpoint)}function nt(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e{let e=!1;return Qe(a).then(t=>!e&&n(t)).catch(()=>!e&&n(`off`)),()=>{e=!0}},[a]);let o=(0,M.useCallback)(async(e,t)=>{i(!0);try{let t=await e();return t&&n(t),!0}catch(e){return D.error(e instanceof Error?`${t}: ${e.message}`:t),!1}finally{i(!1)}},[]);return{state:t,busy:r,enable:()=>o(()=>$e(a),`could not turn notifications on`),disable:()=>o(()=>et(a),`could not turn notifications off`),test:async()=>{await o(()=>tt(a),`could not send a test`)&&D.info(`Test notification sent`)}}}var it={unsupported:`This browser does not support notifications.`,insecure:`Notifications need HTTPS or localhost. See the notifications guide for tailscale serve.`,"needs-install":`On iPhone and iPad, add nightcrow to the Home Screen and open it from there first.`,denied:`Notifications are blocked for this site. Allow them in the browser's site settings.`,unavailable:`The server could not load its notification key. Check the daemon log.`},at=`rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`;function ot(){let{state:e,busy:t,enable:n,disable:r,test:i}=rt(),a=e?it[e]:void 0;return(0,N.jsxs)(`section`,{"aria-labelledby":`nc-notifications-title`,className:`border-t border-ink-800 px-3 py-2`,children:[(0,N.jsx)(`h3`,{id:`nc-notifications-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Notifications`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`When a terminal asks for you`}),(e===`off`||e===`on`)&&(0,N.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e===`on`,"aria-busy":t,disabled:t,onClick:e===`on`?r:n,className:at,children:e===`on`?`On`:`Off`}),e===null&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:`…`})]}),a&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-ink-400`,children:a}),e===`on`&&(0,N.jsx)(`button`,{type:`button`,disabled:t,onClick:i,className:`mt-1 ${at}`,children:`Send a test notification`})]})}var st=`nc-settings-title`,ct=`nc-settings-dialog`,lt=`nc-screen-scale`;function ut({accent:e,next:t,cycle:n,onReloadConfig:r,reloading:i,onShowShortcuts:a}){let[c,l]=(0,M.useState)(!1),u=(0,M.useRef)(null),d=(0,M.useRef)(null),{scale:p,setScale:m}=ue(),h=f();(0,M.useLayoutEffect)(()=>{if(!c)return;let e=d.current;if(!e)return;e.querySelector(`[data-initial-focus]`)?.focus();let t=()=>[...e.querySelectorAll(`a[href], button:not(:disabled), select:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])`)],n=n=>{if(n.key===`Escape`){n.preventDefault(),l(!1),u.current?.focus();return}if(n.key!==`Tab`)return;let r=t(),i=r[0],a=r.at(-1);!i||!a?(n.preventDefault(),e.focus()):n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus())},r=t=>{let n=t.target;n instanceof Node&&!e.contains(n)&&!u.current?.contains(n)&&l(!1)};return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}},[c]);let g=()=>{l(!1),u.current?.focus(),a()};return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{ref:u,type:`button`,onClick:()=>l(e=>!e),"aria-label":`Settings`,"aria-haspopup":`dialog`,"aria-expanded":c,"aria-controls":ct,title:`Settings`,className:`ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,N.jsx)(re,{})}),c&&(0,N.jsxs)(`div`,{ref:d,id:ct,role:`dialog`,"aria-labelledby":st,tabIndex:-1,className:`nc-pop-in origin-top-right fixed right-2 top-[calc(var(--nc-header-h)+8px)] z-50 flex max-h-[calc(100vh-3.75rem)] w-72 max-w-[calc(100vw-1rem)] flex-col overflow-y-auto rounded-md border border-ink-700 bg-ink-900 shadow-xl focus:outline-none`,style:{maxHeight:`calc(100dvh - 3.75rem)`},children:[(0,N.jsx)(`div`,{className:`border-b border-ink-700 px-3 py-2`,children:(0,N.jsx)(`h2`,{id:st,className:`font-medium text-ink-50`,children:`Settings`})}),(0,N.jsxs)(`section`,{"aria-labelledby":`nc-appearance-title`,className:`px-3 py-2`,children:[(0,N.jsx)(`h3`,{id:`nc-appearance-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Appearance`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`Accent colour`}),(0,N.jsxs)(`button`,{type:`button`,"data-initial-focus":!0,onClick:n,...h(`session.cycleAccent`,`Accent: ${e.name} (click for ${t.name})`),"aria-label":`accent colour: ${e.name}, click for ${t.name}`,className:`flex items-center gap-1.5 rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 rounded-full bg-accent ring-1 ring-ink-600`}),e.name]})]}),(0,N.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,N.jsx)(`label`,{htmlFor:lt,className:`min-w-0 flex-1 text-ink-200`,children:`Screen scale`}),(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(`select`,{id:lt,"aria-label":`Screen scale`,value:p,onChange:e=>m(Number(e.currentTarget.value)),className:`appearance-none rounded-sm border border-ink-700 bg-ink-850 py-1 pl-2 pr-7 text-ink-50 focus:border-accent focus:outline-none`,children:o.map(e=>(0,N.jsxs)(`option`,{value:e,children:[e,`%`]},e))}),(0,N.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-2 flex items-center text-ink-400`,children:(0,N.jsx)(Ve,{open:!0})})]})]})]}),(0,N.jsx)(ot,{}),(0,N.jsxs)(`div`,{className:`border-t border-ink-800 px-3 py-2`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,"aria-busy":i,...h(`session.reloadConfig`,`Reload config.toml on the server (does not reload this page)`),"aria-label":`reload the server config`,className:`flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`,children:[(0,N.jsx)(fe,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),`Reload config.toml`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:g,...h(`help.shortcuts`,`Keyboard shortcuts`),"aria-label":`keyboard shortcuts`,className:`mt-1 flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700`,children:[(0,N.jsx)(s,{className:`h-3.5 w-3.5`}),`Keyboard shortcuts`]})]})]})]})}function dt(e){return e===`top`||e===`left`?e:null}function ft(e){return e===`top`?`left`:`top`}function pt({repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,cloning:a,accent:o,next:s,cycle:c,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p,onReloadConfig:m,reloading:h,onShowShortcuts:g,tabStrip:_}){return(0,N.jsxs)(`header`,{className:`flex h-(--nc-header-h) items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,N.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,N.jsx)(Be,{})}),(0,N.jsx)(Ge,{className:`md:hidden`,repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i}),_.side===`top`&&(0,N.jsx)(Ke,{side:`top`,repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p}),a&&(0,N.jsxs)(`span`,{role:`status`,title:`A clone is running on the server`,className:`flex shrink-0 items-center gap-1.5 px-2 py-0.5 text-ink-400`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-accent`}),`Cloning…`]}),(0,N.jsx)(ut,{accent:o,next:s,cycle:c,onReloadConfig:m,reloading:h,onShowShortcuts:g}),(0,N.jsx)(`button`,{onClick:_.toggle,title:`Project tabs ${_.side===`top`?`across the top`:`down the left`} (click to move them ${ft(_.side)})`,"aria-label":`project tabs: ${_.side}, click for ${ft(_.side)}`,"aria-pressed":_.side===`left`,className:`ml-1 hidden h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent md:flex`,children:(0,N.jsx)(Ee,{side:_.side})}),(0,N.jsx)(`a`,{href:`/logout`,title:`Sign out`,"aria-label":`sign out`,className:`ml-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,N.jsx)(he,{})})]})}var mt=[`w-3/5`,`w-2/5`,`w-4/5`,`w-1/2`,`w-3/4`,`w-1/3`,`w-2/3`];function ht({className:e=``}){return(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`nc-skeleton block h-2.5 rounded-xs ${e}`})}function gt({rows:e=6,as:t=`div`,className:n=``}){let r=t;return(0,N.jsx)(N.Fragment,{children:Array.from({length:e},(e,t)=>(0,N.jsxs)(r,{"aria-hidden":`true`,className:`flex items-center gap-2 px-3 py-1.5 ${n}`,children:[(0,N.jsx)(ht,{className:`w-3 shrink-0`}),(0,N.jsx)(ht,{className:mt[t%mt.length]})]},t))})}function _t(){return(0,N.jsxs)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`flex h-full flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex h-(--nc-header-h) shrink-0 items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,N.jsx)(ht,{className:`h-[22px] w-[22px] shrink-0 rounded-sm`}),(0,N.jsx)(ht,{className:`hidden w-24 md:block`}),(0,N.jsx)(ht,{className:`w-28 md:hidden`}),(0,N.jsx)(ht,{className:`ml-auto h-4 w-4 shrink-0`}),(0,N.jsx)(ht,{className:`ml-1 h-4 w-4 shrink-0`})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 grid-rows-[minmax(0,1fr)] md:grid-cols-[18rem_minmax(0,1fr)] md:grid-rows-[minmax(0,3fr)_minmax(0,2fr)]`,children:[(0,N.jsx)(`div`,{className:`overflow-hidden border-chrome-line py-2 md:border-r`,children:(0,N.jsx)(gt,{rows:10})}),(0,N.jsx)(`div`,{className:`hidden overflow-hidden py-2 md:block`,children:(0,N.jsx)(gt,{rows:14})}),(0,N.jsxs)(`div`,{className:`hidden overflow-hidden border-t border-chrome-line md:col-span-2 md:block`,children:[(0,N.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b border-chrome-line px-3`,children:[(0,N.jsx)(ht,{className:`w-30`}),(0,N.jsx)(ht,{className:`w-30`})]}),(0,N.jsx)(`div`,{className:`py-2`,children:(0,N.jsx)(gt,{rows:5})})]})]}),(0,N.jsx)(`div`,{className:`flex shrink-0 border-t border-chrome-line bg-ink-900 md:hidden`,children:[0,1,2].map(e=>(0,N.jsxs)(`div`,{className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-1 py-1`,children:[(0,N.jsx)(ht,{className:`h-5 w-5`}),(0,N.jsx)(ht,{className:`h-2 w-10`})]},e))})]})}function vt({onSuccess:e}){let[t,n]=(0,M.useState)(``),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(!1);return(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,N.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),o(!0),i(null);try{await j.login(t),e()}catch(e){i(e instanceof Error?e.message:`login failed`)}finally{o(!1)}},className:`w-[17rem] max-w-[86vw]`,children:[(0,N.jsx)(ze,{className:`mx-auto mb-3 block h-10 w-10`}),(0,N.jsx)(`h1`,{className:`text-center text-lg font-medium tracking-wide text-ink-50`,children:`nightcrow`}),(0,N.jsx)(`p`,{className:`mt-1 mb-5 text-center text-caption text-ink-400 uppercase`,children:`web viewer`}),r&&(0,N.jsx)(`p`,{className:`mb-2.5 text-center text-removed`,children:r}),(0,N.jsx)(`input`,{type:`password`,autoFocus:!0,value:t,onChange:e=>n(e.target.value),placeholder:`password`,className:`mb-2 w-full rounded-sm border border-ink-700 bg-ink-900 px-2.5 py-1.5 outline-none placeholder:text-ink-400 focus:border-accent focus:ring-[3px] focus:ring-accent/15`}),(0,N.jsx)(`button`,{"aria-busy":a,type:`submit`,disabled:a,className:`w-full rounded-sm bg-ink-50 py-1.5 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,N.jsx)(A,{busy:a,children:`Sign in`})})]})})}var yt=`nightcrow.sidebarWidth`,bt=.5;function xt(e){return Math.min(Math.max(Math.round(e),280),720)}function St(e){let t=720;try{t=Math.min(t,Math.round(window.innerWidth*bt))}catch{}return Math.min(Math.max(Math.round(e),280),Math.max(t,280))}function Ct(){let e=Number(m(yt));return Number.isFinite(e)&&e>0?xt(e):460}function wt(e){h(yt,String(e))}function Tt(){let[e,t]=(0,M.useState)(Ct),n=(0,M.useCallback)(e=>{let n=St(e);t(n),wt(n)},[]);return{width:e,resize:n,commit:n,reset:(0,M.useCallback)(()=>{let e=xt(460);t(e),wt(e)},[])}}var Et=`[data-terminal-panel]`,Dt=`dialog[open], [role="dialog"], [aria-modal="true"]`,Ot=`input, textarea, select, [contenteditable], [role="textbox"], [role="searchbox"], [role="combobox"]`,kt=`data-focus-region`;function At(e){return{"data-focus-region":e,tabIndex:-1}}function jt(e){if(!(e instanceof Element)||e.closest(`[data-terminal-panel]`))return null;let t=e.closest(Ot)??e;return{tagName:t.tagName,isContentEditable:Ft(t),role:t.getAttribute(`role`),type:It(t),inDialog:e.closest(Dt)!==null}}function Mt(e=document){return Nt(e)===`terminal`}function Nt(e=document){let t=e.activeElement;if(!t)return null;if(t.closest(`[data-terminal-panel]`))return`terminal`;let n=t.closest(`[${kt}]`)?.getAttribute(kt);return n===`list`||n===`content`?n:null}function Pt(e,t=document){let n=t.querySelector(`[${kt}="${e}"]`);if(!n)return!1;let r=a(t.activeElement,t.querySelector(Et));return Ce(r)?(n.focus(),!0):!1}function Ft(e){let t=e.getAttribute(`contenteditable`);return t===null?e.isContentEditable===!0:t!==`false`}function It(e){return e.tagName===`INPUT`?e.type?.toLowerCase()??null:null}var Lt=600;function Rt(e){let[t,n]=(0,M.useState)({scrollTop:0,height:Lt}),r=(0,M.useCallback)(()=>{let t=e.current;if(!t)return;let r={scrollTop:t.scrollTop,height:t.clientHeight||Lt};n(e=>e.scrollTop===r.scrollTop&&e.height===r.height?e:r)},[e]);return(0,M.useLayoutEffect)(()=>{r();let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e,r]),{viewport:t,refresh:r}}function zt(){let e=new Map;return{start(t){let n=(e.get(t)??0)+1;return e.set(t,n),n},isCurrent(t,n){return e.get(t)===n}}}var Bt={children:{},expanded:new Set};function Vt(e,t,n){return{...e,children:{...e.children,[t]:n}}}function Ht(e,t){let n=new Set(e);return n.delete(t)||n.add(t),n}function Ut(e,t){return{...e,expanded:Ht(e.expanded,t)}}function Wt(e,t){let n=new Set(e.expanded);return t.forEach(e=>n.add(e)),{...e,expanded:n}}function Gt(e){let t=[],n=``;for(let r of e.split(`/`))n=n?`${n}/${r}`:r,t.push(n);return t}var Kt=180,qt={items:[],truncated:!1};function Jt({repo:e,authed:t,tab:n,filter:r,filterOpen:i,handle:a}){let[o,s]=(0,M.useState)(Bt),[c,l]=(0,M.useState)(qt),[u,d]=(0,M.useState)(!1),[f]=(0,M.useState)(zt);(0,M.useEffect)(()=>{if(!e||!t||n!==`tree`||!i||!r){l(qt),d(!1);return}d(!0);let o=!0,s=setTimeout(()=>{j.treeSearch(e,r).then(e=>{o&&l({items:e.matches,truncated:e.truncated})}).catch(e=>{o&&a(e)}).finally(()=>{o&&d(!1)})},Kt);return()=>{o=!1,clearTimeout(s)}},[e,t,n,r,i,a]);let p=(0,M.useCallback)((t,n)=>{if(!e)return;let r=f.start(t);j.tree(e,t).then(e=>{f.isCurrent(t,r)&&s(n=>Vt(n,t,e.entries))}).catch(e=>{if(!f.isCurrent(t,r)||n?.restoring)return Me(e)?a(e):void 0;a(e)})},[e,a,f]);(0,M.useEffect)(()=>{e&&t&&n===`tree`&&p(``)},[e,t,n,p]);let m=(0,M.useCallback)(e=>{let t=!o.expanded.has(e);s(t=>Ut(t,e)),t&&!(e in o.children)&&p(e)},[o,p]),h=(0,M.useCallback)(e=>{s(t=>({...t,expanded:new Set(e)})),e.forEach(e=>{e in o.children||p(e,{restoring:!0})})},[o,p]),g=(0,M.useCallback)(e=>{let t=Gt(e);s(e=>Wt(e,t)),t.forEach(e=>{e in o.children||p(e)})},[o,p]);return{treeChildren:o.children,treeExpanded:o.expanded,treeMatches:c.items,treeTruncated:c.truncated,treeSearchLoading:u,loadTreeChildren:p,toggleTreeDir:m,revealTreeDir:g,seedTreeExpanded:h}}function Yt(e,t){let n=[],r=(i,a)=>{for(let o of e[i]??[]){let e=i?`${i}/${o.name}`:o.name;n.push({path:e,name:o.name,is_dir:o.is_dir,depth:a}),o.is_dir&&t.has(e)&&r(e,a+1)}};return r(``,0),n}var Xt=[`status`,`log`,`tree`],P={status:`Show the working-tree status`,log:`Show the commit log`,tree:`Show the file tree`};function Zt(e){return e===`log`?`view.toggleLog`:e===`tree`?`view.toggleTree`:null}function Qt({tab:e,onChoose:t,filterOpen:n,onToggleFilter:r}){let i=f();return(0,N.jsxs)(`div`,{className:`flex shrink-0 items-stretch border-b border-chrome-line px-2`,children:[Xt.map(n=>{let r=Zt(n);return(0,N.jsx)(`button`,{onClick:()=>t(n),"aria-current":n===e?`page`:void 0,...r&&n!==e?i(r,P[n]):{title:P[n]},className:`px-2 py-1.5 ${n===e?`text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:text-ink-200`}`,children:n},n)}),(0,N.jsx)(`button`,{onClick:r,"aria-pressed":n,title:n?`Hide the filter`:`Filter the list`,"aria-label":n?`Hide the filter`:`Filter the list`,className:`my-1 ml-auto flex shrink-0 items-center rounded-sm px-1.5 hover:text-accent ${n?`text-ink-50`:`text-ink-400`}`,children:(0,N.jsx)(k,{})})]})}function $t({path:e,from:t,className:n}){return(0,N.jsx)(`span`,{className:`whitespace-nowrap ${n??``}`,title:t?`${t} → ${e}`:e,children:t?`${t} → ${e}`:e})}var en=1e3;function tn(e,t){return e===void 0||e<=0?0:e-t}function nn(e,t,n){let r=tn(t,n);return e===null||Math.abs(r-e)>=1e3?r:e}function rn(e,t,n){if(e===void 0)return`cool`;let r=Math.max(0,t-e);return r>=n?`cool`:r<5e3?`fresh`:`warm`}function an(e,t,n){return e.some(e=>rn(e,t,n)!==`cool`)}var on={fresh:`text-accent font-bold`,warm:`text-accent`,cool:``};function sn(e,t,n){let[r,i]=(0,M.useState)(()=>Date.now()+n);return(0,M.useEffect)(()=>{if(t<=0||!e)return;let r=e.map(e=>e.mtime),a=Date.now()+n;if(i(a),!an(r,a,t))return;let o=setInterval(()=>{let e=Date.now()+n;i(e),an(r,e,t)||clearInterval(o)},en);return()=>clearInterval(o)},[e,t,n]),r}function cn(e){return e.startsWith(`not a git repository`)?`Not a git repository. Run git init here to track changes.`:`Status unavailable: ${e}`}function ln(e){let t=Math.max(0,Math.floor(Date.now()/1e3-e));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<2592e3?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/2592e3)}mo`:`${Math.floor(t/31536e3)}y`}function un(e){return e===`+`?`bg-added/10`:e===`-`?`bg-removed/10`:``}function dn(e){return e===`?`?`text-ink-400`:e===`D`?`text-removed`:e===`A`?`text-added`:`text-accent`}function fn(e,t,n,r=20,i=12){let a=Math.max(1,Math.ceil(n/r)),o=Math.min(Math.floor(Math.max(0,t)/r),Math.max(0,e-a)),s=o+a,c=Math.max(0,Math.min(e,o-i)),l=Math.max(c,Math.min(e,s+i));return{start:c,end:l,before:c*r,after:(e-l)*r}}function pn(e){return Math.max(0,e-1)*20}function mn({status:e,files:t,hotWindowMs:n,clockSkewMs:r,viewport:i,openDiff:a}){let o=sn(t,n,r);if(e===null)return(0,N.jsx)(gt,{as:`li`,rows:8});if(e.unavailable!==void 0)return(0,N.jsx)(`li`,{className:`nc-fade-in px-3 py-1 text-ink-400`,children:cn(e.unavailable)});let s=t.length>200?fn(t.length,i.scrollTop,i.height):null,c=s?.start??0,l=s?t.slice(s.start,s.end):t;return(0,N.jsxs)(N.Fragment,{children:[s&&(0,N.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":t.length,style:{height:s.before}}),l.map((e,t)=>{let r=c+t;return(0,N.jsx)(`li`,{"data-virtual-row":s?r:void 0,children:(0,N.jsxs)(`button`,{onClick:()=>a(e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,N.jsxs)(`span`,{className:`shrink-0`,children:[(0,N.jsx)(`span`,{className:dn(e.index),children:e.index===` `?` `:e.index}),(0,N.jsx)(`span`,{className:dn(e.worktree),children:e.worktree===` `?` `:e.worktree})]}),(0,N.jsx)($t,{path:e.path,from:e.old_path,className:on[rn(e.mtime,o,n)]})]})},e.path)}),s&&(0,N.jsx)(`li`,{"aria-hidden":`true`,style:{height:s.after}}),e.truncated&&(0,N.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,e.files.length,` changed files.`]})]})}var hn={merge:`MERGING`,rebase:`REBASING`,"cherry-pick":`CHERRY-PICKING`,revert:`REVERTING`,bisect:`BISECTING`,am:`APPLYING`};function gn(e){let t=e?.operation,n=t?t.step!==void 0&&t.total!==void 0?`${hn[t.kind]} ${t.step}/${t.total}`:hn[t.kind]:null,r=e?.conflicts??0,i=r===0?null:r===1?`1 conflict`:`${r} conflicts`;return n&&i?`${n} · ${i}`:n??i}function _n(e){return e.kind===`head`&&e.name!==`HEAD`?`HEAD → ${e.name}`:e.name}function vn(e){switch(e){case`head`:return`border-accent text-accent font-medium`;case`local`:return`border-added/60 text-added`;case`tag`:return`border-ink-600 text-ink-200`;case`remote`:return`border-ink-700 text-ink-400`}}function yn({visibleCommits:e,decorations:t,commits:n,commitDrillDown:r,visibleCommitFiles:i,logDone:a,logStalled:o,logPagingPaused:s,viewport:c,setLogStalled:l,logSentinelRef:u,openCommitFiles:d,openCommit:f,openCommitFileDiff:p,setCommitDrillDown:m,setPaneEmpty:h,bumpPaneRequest:g}){let _=!r&&e.length>200?fn(e.length,c.scrollTop,c.height):null,v=_?e.slice(_.start,_.end):e,y=_?.start??0,b=r&&i.length>200?fn(i.length,c.scrollTop,c.height):null,x=b?i.slice(b.start,b.end):i,S=b?.start??0;return(0,N.jsxs)(N.Fragment,{children:[!r&&_&&(0,N.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":e.length,style:{height:_.before}}),!r&&v.map((e,n)=>{let r=y+n,i=t.divergenceOf(e.oid);return(0,N.jsx)(`li`,{"data-virtual-row":_?r:void 0,children:(0,N.jsxs)(`button`,{onClick:()=>void d(e),title:`${e.author} · ${e.summary}`,className:`flex w-max min-w-full items-baseline gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,N.jsx)(`span`,{className:`w-2 shrink-0 ${i===`behind`?`text-accent`:`text-added`}`,title:i===`ahead`?`Not on the upstream yet`:i===`behind`?`On the upstream, not here yet`:void 0,children:i===`ahead`?`↑`:i===`behind`?`↓`:``}),(0,N.jsx)(`span`,{className:`shrink-0 text-accent`,children:e.short_id}),(0,N.jsx)(`span`,{className:`w-10 shrink-0 text-right text-ink-400`,children:ln(e.time)}),(0,N.jsx)(`span`,{className:`max-w-[6rem] shrink-0 truncate text-ink-400`,children:e.author}),t.refsOf(e.oid)?.map(e=>(0,N.jsx)(`span`,{className:`shrink-0 self-center rounded-sm border px-1 text-2xs ${vn(e.kind)}`,children:_n(e)},`${e.kind}:${e.name}`)),(0,N.jsx)(`span`,{className:`whitespace-nowrap ${e.merge?`text-ink-400`:``}`,children:e.summary})]})},e.oid)}),!r&&_&&(0,N.jsx)(`li`,{"aria-hidden":`true`,style:{height:_.after}}),!r&&t.truncated&&(0,N.jsx)(`li`,{className:`px-3 py-1 text-2xs text-ink-400`,children:`Too many refs to mark them all — some branch, tag or upstream marks are not shown.`}),!r&&!a&&!o&&!s&&(0,N.jsxs)(`li`,{ref:u,className:`flex flex-col gap-2 px-3 py-1.5`,"aria-hidden":`true`,children:[(0,N.jsx)(ht,{className:`w-3/5`}),(0,N.jsx)(ht,{className:`w-2/5`}),(0,N.jsx)(ht,{className:`w-1/2`})]}),!r&&!a&&!o&&s&&(0,N.jsxs)(`li`,{className:`px-3 py-1 text-ink-400`,children:[`filtering `,n.length,` loaded commits — clear the filter to load more`]}),!r&&o&&(0,N.jsx)(`li`,{className:`px-3 py-1`,children:(0,N.jsx)(`button`,{onClick:()=>l(!1),className:`text-ink-400 hover:text-accent`,children:`could not load more — retry`})}),r&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`li`,{className:`sticky top-0 z-10 flex w-max min-w-full items-center gap-1 bg-ink-900 px-2 py-1 text-ink-400`,children:[(0,N.jsx)(`button`,{onClick:()=>{g(),m(null),h()},className:`rounded-sm px-1 hover:text-accent`,title:`Back to commit log`,children:`< log`}),(0,N.jsx)(`span`,{className:`text-ink-600`,children:`·`}),(0,N.jsx)(`span`,{className:`shrink-0 text-accent`,children:r.commit.short_id}),(0,N.jsx)(`button`,{onClick:()=>f(r.commit.oid),className:`rounded-sm px-1 hover:text-accent`,title:`Show the complete commit diff`,children:`all changes`})]}),b&&(0,N.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":i.length,style:{height:b.before}}),x.map((e,t)=>{let n=S+t;return(0,N.jsx)(`li`,{"data-virtual-row":b?n:void 0,children:(0,N.jsxs)(`button`,{onClick:()=>p(r.commit.oid,e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,N.jsx)(`span`,{className:dn(e.index),children:e.index}),(0,N.jsx)($t,{path:e.path,from:e.old_path})]})},e.path)}),b&&(0,N.jsx)(`li`,{"aria-hidden":`true`,style:{height:b.after}}),r.files.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No changed files.`}),r.files.length>0&&i.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No matching files.`}),r.truncated&&(0,N.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,r.files.length,` files.`]})]})]})}function bn({treeSearching:e,treeMatches:t,treeTruncated:n,treeSearchLoading:r,treeRows:i,treeExpanded:a,openFile:o,revealTreeDir:s,toggleTreeDir:c}){return e?(0,N.jsxs)(N.Fragment,{children:[t.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{onClick:()=>{e.is_dir?s(e.path):o(e.path)},title:e.path,className:`w-max min-w-full whitespace-nowrap px-3 py-0.5 text-left hover:bg-ink-850`,children:e.is_dir?(0,N.jsxs)(`span`,{className:`text-accent`,children:[e.path,`/`]}):e.path})},e.path)),t.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:r?`searching…`:`no matches`}),n&&(0,N.jsxs)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:[`showing the first `,t.length,` matches`]})]}):(0,N.jsx)(N.Fragment,{children:i.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{onClick:()=>e.is_dir?c(e.path):o(e.path),title:e.path,style:{paddingLeft:`${e.depth*.75+.5}rem`},className:`flex w-max min-w-full items-center gap-1 py-0.5 pr-3 text-left hover:bg-ink-850`,children:[e.is_dir?(0,N.jsx)(Ve,{open:a.has(e.path)}):(0,N.jsx)(`span`,{className:`h-3.5 w-3.5 shrink-0`}),(0,N.jsx)(`span`,{className:`whitespace-nowrap ${e.is_dir?`text-accent`:``}`,children:e.is_dir?`${e.name}/`:e.name})]})},e.path))})}function xn(e){let{tab:t,chooseTab:n,filter:r,setFilter:i,filterOpen:a,setFilterOpen:o,status:s,files:c,hotWindowMs:l,clockSkewMs:u,openDiff:d,openFile:f,openCommit:p,openCommitFileDiff:m,openCommitFiles:h,repo:g,authed:_,handle:v,sidebarRef:y,draggingSidebar:b,onSidebarDragStart:x,onSidebarDragMove:S,onSidebarDragEnd:C,onSidebarDragCancel:w,filesMax:T,bumpPaneRequest:E,commits:ee,logDone:te,logStalled:ne,setLogStalled:re,commitDrillDown:ie,setCommitDrillDown:ae,logSentinelRef:oe,visibleCommits:se,decorations:D,logPagingPaused:ce,visibleCommitFiles:le,mobileView:ue,restoreTree:de,restoreKnown:fe,onTreeExpanded:pe,clearPane:me,touched:he}=e,ge=Jt({repo:g,authed:_,tab:t,filter:r,filterOpen:a,handle:v}),_e=(0,M.useRef)(null),{viewport:ve,refresh:ye}=Rt(_e),be=t===`tree`&&a&&r!==``,xe=Yt(ge.treeChildren,ge.treeExpanded),{seedTreeExpanded:O}=ge,k=(0,M.useRef)(!1);(0,M.useEffect)(()=>{k.current||fe&&!he&&t===`tree`&&(k.current=!0,de.length!==0&&O(de))},[t,fe,he,de,O]);let Se=e=>{pe([...Ht(ge.treeExpanded,e)]),ge.toggleTreeDir(e)},Ce=e=>{let t=new Set(ge.treeExpanded);Gt(e).forEach(e=>t.add(e)),pe([...t]),ge.revealTreeDir(e)},we=()=>{a&&i(``),o(e=>!e)};return(0,N.jsxs)(`section`,{ref:y,...At(`list`),className:`nc-fade-in relative min-h-0 flex-col overflow-hidden ${ue===`files`?`flex`:`hidden md:flex`} ${T?`md:flex`:`border-chrome-line md:border-r`}`,children:[!T&&(0,N.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the file sidebar (double-click to reset)`,title:`Drag to resize · double-click to reset`,onPointerDown:x,onPointerMove:S,onPointerUp:C,onPointerCancel:w,onLostPointerCapture:C,className:`absolute -right-px top-0 z-20 hidden h-full w-1.5 cursor-col-resize touch-none md:block ${b?`bg-accent`:`hover:bg-accent`}`}),(0,N.jsx)(Qt,{tab:t,onChoose:n,filterOpen:a,onToggleFilter:we}),a&&(0,N.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`filter…`,autoFocus:!0,className:`mx-2 mb-1 shrink-0 rounded-sm bg-ink-850 px-2 py-1 outline-none placeholder:text-ink-400 focus:ring-1 focus:ring-accent`}),(0,N.jsxs)(`ul`,{ref:_e,onScroll:ye,className:`nc-content min-h-0 flex-1 overflow-auto`,children:[t===`status`&&(0,N.jsx)(mn,{status:s,files:c,hotWindowMs:l,clockSkewMs:u,viewport:ve,openDiff:d}),t===`log`&&(0,N.jsx)(yn,{visibleCommits:se,decorations:D,commits:ee,commitDrillDown:ie,visibleCommitFiles:le,logDone:te,logStalled:ne,logPagingPaused:ce,viewport:ve,setLogStalled:re,logSentinelRef:oe,openCommitFiles:h,openCommit:p,openCommitFileDiff:m,setCommitDrillDown:ae,setPaneEmpty:me,bumpPaneRequest:E}),t===`tree`&&(0,N.jsx)(bn,{treeSearching:be,treeMatches:ge.treeMatches,treeTruncated:ge.treeTruncated,treeSearchLoading:ge.treeSearchLoading,treeRows:xe,treeExpanded:ge.treeExpanded,openFile:f,revealTreeDir:Ce,toggleTreeDir:Se})]})]})}function Sn(e){let t=[],n=[],r=[],i=()=>{let e=Math.max(n.length,r.length);for(let i=0;i{t(e=>e===`split`?`unified`:`split`)},[])}}var wn=[`.md`,`.markdown`],Tn=[`.html`,`.htm`];function En(e){let t=e.toLowerCase();return wn.some(e=>t.endsWith(e))}function Dn(e){let t=e.toLowerCase();return Tn.some(e=>t.endsWith(e))}function On(e){return En(e)||Dn(e)}function kn(e){return e.map(e=>e.map(e=>e.t).join(``)).join(` -`)}function An(e,t=0){if(new Set(e.hunks.map(t=>t.file_path??e.path)).size>1)return null;for(let n of e.hunks.slice(Math.max(0,t)))for(let e of n.lines)if(e.new_lineno!==void 0)return e.new_lineno;return null}function jn(e){return Math.max(0,e-1-2)}function Mn(e,t){return t<=0?null:Math.min(e,t)}function Nn(e,t){let n=0;return e.forEach((e,r)=>{e<=t&&(n=r)}),n}function Pn(e){return e.kind===`empty`||!e.source?null:{want:e.kind===`diff`?`file`:`diff`,source:e.source}}function Fn(e){return e.index!==`D`&&e.worktree!==`D`}function In(e){return e.hunks.some(e=>e.lines.some(e=>e.old_lineno!==void 0||e.new_lineno!==void 0))}function Ln(e){return e.kind===`workdir`?`workdir:${e.path}`:`commit:${e.oid}:${e.path}`}function Rn({pane:e,previewRendered:t,setPreviewRendered:n,filesMax:r,setMaximized:i,onShowOtherFace:a,canEdit:o,editing:s,onToggleEdit:c}){let l=Cn(),d=f();return(0,N.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[Pn(e)&&(0,N.jsx)(`button`,{onClick:a,"aria-pressed":e.kind===`file`,title:e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,"aria-label":e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${e.kind===`file`?`text-accent`:``}`,children:(0,N.jsx)(b,{})}),e.kind===`diff`&&(0,N.jsx)(`button`,{onClick:l.toggle,"aria-pressed":l.layout===`split`,title:l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,"aria-label":l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${l.layout===`split`?`text-accent`:``}`,children:(0,N.jsx)(v,{})}),o&&(0,N.jsx)(`button`,{onClick:c,"aria-pressed":s,title:s?`Stop editing`:`Edit this page's text`,"aria-label":s?`Stop editing`:`Edit this page's text`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${s?`text-accent`:``}`,children:(0,N.jsx)(xe,{})}),e.kind===`file`&&On(e.value.path)&&!s&&(0,N.jsx)(`button`,{onClick:()=>n(e=>!e),"aria-pressed":t,title:t?`Show raw source`:`Show the rendered page`,"aria-label":t?`Show raw source`:`Show the rendered page`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${t?`text-accent`:``}`,children:(0,N.jsx)(p,{})}),(0,N.jsx)(`button`,{onClick:()=>i(r?`none`:`files`),"aria-pressed":r,...d(`view.toggleMaximize`,r?`Restore the layout`:`Maximize the file pane`),"aria-label":r?`Restore the layout`:`Maximize the file pane`,className:`hidden shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent md:flex`,children:(0,N.jsx)(u,{maximized:r})})]})}var zn=3;function Bn(e){let t=e<1?1:String(Math.floor(e)).length;return Math.max(t,zn)}function Vn(e){let t=0;for(let n of e)for(let e of n.lines)t=Math.max(t,e.old_lineno??0,e.new_lineno??0);return Bn(t)}function F({nos:e,digits:t,tint:n=``,stickyClass:r=`sticky left-0`}){return(0,N.jsx)(`span`,{className:`${r} shrink-0 select-none bg-ink-950`,children:(0,N.jsx)(`span`,{className:`flex gap-[1ch] px-[1ch] text-ink-400 ${n}`,children:e.map((e,n)=>(0,N.jsx)(`span`,{className:`text-right`,style:{width:`${t}ch`},children:e??``},n))})})}function Hn(){let e=`(min-width: 768px)`,[t,n]=(0,M.useState)(()=>window.matchMedia(e).matches);return(0,M.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function Un(e,t,n){return e.hunks.flatMap((e,r)=>{let i={kind:`header`,hunk:r,text:`${e.file_path?`${e.file_path} `:``}${e.header}`};if(!t)return[i,...e.lines.map(e=>({kind:`unified`,hunk:r,line:e}))];let a=Sn(e.lines);return n?[i,...a.map(({left:e,right:t})=>({kind:`pair`,hunk:r,left:e,right:t}))]:[i,...a.map(({left:e})=>({kind:`side`,hunk:r,line:e,side:`old`,border:!1})),...a.map(({right:e},t)=>({kind:`side`,hunk:r,line:e,side:`new`,border:t===0}))]})}function Wn({line:e}){return(0,N.jsxs)(`span`,{className:`whitespace-pre pr-3`,children:[(0,N.jsx)(`span`,{className:`select-none text-ink-400`,children:e.kind}),e.spans.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Gn({line:e,side:t,digits:n,stickyClass:r}){let i=e?un(e.kind):`bg-ink-900/40`;return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 ${i}`,children:[(0,N.jsx)(F,{nos:[e?t===`old`?e.old_lineno:e.new_lineno:void 0],digits:n,tint:i,stickyClass:r}),e?(0,N.jsx)(Wn,{line:e}):(0,N.jsx)(`span`,{className:`pr-3`,children:` `})]})}function Kn({diff:e,split:t,viewport:n}){let r=Hn(),i=(0,M.useMemo)(()=>Un(e,t,r),[e,t,r]),a=Vn(e.hunks),o=fn(i.length,n.scrollTop,n.height);return(0,N.jsxs)(`div`,{className:`min-w-full py-1`,"data-virtual-count":i.length,children:[(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.before}}),i.slice(o.start,o.end).map((e,t)=>{let n=o.start+t,r={"data-hunk":e.hunk,"data-virtual-row":n};if(e.kind===`header`)return(0,N.jsx)(`div`,{...r,className:`h-5 bg-ink-850 px-3 text-ink-400`,children:e.text},n);if(e.kind===`unified`){let t=un(e.line.kind);return(0,N.jsxs)(`div`,{...r,className:`flex h-5 w-max min-w-full ${t}`,children:[(0,N.jsx)(F,{nos:[e.line.old_lineno,e.line.new_lineno],digits:a,tint:t}),(0,N.jsx)(Wn,{line:e.line})]},n)}return e.kind===`pair`?(0,N.jsxs)(`div`,{...r,className:`flex h-5 min-w-full`,children:[(0,N.jsx)(Gn,{line:e.left,side:`old`,digits:a}),(0,N.jsx)(`div`,{className:`flex min-w-0 flex-1 border-l border-ink-800`,children:(0,N.jsx)(Gn,{line:e.right,side:`new`,digits:a,stickyClass:`sticky left-1/2`})})]},n):(0,N.jsx)(`div`,{...r,className:`flex h-5 min-w-full ${e.border?`border-t border-ink-800`:``}`,children:(0,N.jsx)(Gn,{line:e.line,side:e.side,digits:a})},n)}),(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.after}})]})}function qn({line:e}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-ink-400 select-none`,children:e.kind}),e.spans.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Jn({line:e,digits:t,side:n}){if(e===null)return(0,N.jsxs)(`div`,{className:`flex bg-ink-900/40`,children:[(0,N.jsx)(F,{nos:[void 0],digits:t,tint:`bg-ink-900/40`}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:` `})]});let r=un(e.kind);return(0,N.jsxs)(`div`,{className:`flex ${r}`,children:[(0,N.jsx)(F,{nos:[n===`old`?e.old_lineno:e.new_lineno],digits:t,tint:r}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,N.jsx)(qn,{line:e})})]})}function Yn({cells:e,digits:t,side:n,border:r}){return(0,N.jsx)(`div`,{className:`min-w-0 flex-none overflow-x-auto md:flex-1 md:basis-1/2 ${r?`border-t border-ink-800 md:border-t-0 md:border-l`:``}`,children:(0,N.jsx)(`div`,{className:`w-max min-w-full`,children:e.map((e,r)=>(0,N.jsx)(Jn,{line:e,digits:t,side:n},r))})})}function Xn({lines:e,digits:t}){let n=Sn(e);return(0,N.jsxs)(`div`,{className:`flex flex-col md:flex-row`,children:[(0,N.jsx)(Yn,{cells:n.map(e=>e.left),digits:t,side:`old`,border:!1}),(0,N.jsx)(Yn,{cells:n.map(e=>e.right),digits:t,side:`new`,border:!0})]})}function Zn({diff:e,split:t,viewport:n={scrollTop:0,height:600}}){if(e.hunks.reduce((e,t)=>e+t.lines.length,0)>200)return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Kn,{diff:e,split:t,viewport:n}),e.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]});let r=Vn(e.hunks);return(0,N.jsxs)(`div`,{className:`p-1`,children:[e.hunks.length===0&&(0,N.jsx)(`p`,{className:`p-3 text-ink-400`,children:`No changes.`}),e.hunks.map((e,n)=>{let i=(0,N.jsxs)(`div`,{className:`bg-ink-850 px-3 py-0.5 text-ink-400`,children:[e.file_path?`${e.file_path} `:``,e.header]});return(0,N.jsx)(`div`,{"data-hunk":n,className:`mb-2`,children:t?(0,N.jsxs)(N.Fragment,{children:[i,(0,N.jsx)(Xn,{lines:e.lines,digits:r})]}):(0,N.jsxs)(`div`,{className:`w-max min-w-full`,children:[i,e.lines.map((e,t)=>{let n=un(e.kind);return(0,N.jsxs)(`div`,{className:`flex ${n}`,children:[(0,N.jsx)(F,{nos:[e.old_lineno,e.new_lineno],digits:r,tint:n}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,N.jsx)(qn,{line:e})})]},t)})]})},n)}),e.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]})}var Qn=[`failed to fetch dynamically imported module`,`error loading dynamically imported module`,`importing a module script failed`,`unable to preload css`];function $n(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return Qn.some(e=>n.includes(e))}var er=class extends M.Component{state={error:null,failed:!1};static getDerivedStateFromError(e){return{error:e,failed:!0}}componentDidCatch(e,t){console.error(`nightcrow: a subtree failed to render`,e,t)}render(){return this.state.failed?(0,N.jsx)(tr,{chunk:$n(this.state.error),region:this.props.region,className:this.props.className}):this.props.children}};function tr({chunk:e,region:t,className:n}){return(0,N.jsxs)(`div`,{role:`alert`,className:`h-full min-h-0 flex-col items-start gap-3 p-4 text-ink-400 ${n??`flex`}`,children:[e?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`text-accent`,children:`Part of the app could not be loaded.`}),(0,N.jsx)(`p`,{children:`Most likely the server was updated while this tab was open, and reloading picks up the current version. If the reload fails too, the server is not reachable from here. Either way nothing on the server is affected — the session, its repositories, and its terminals are untouched.`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`text-removed`,children:t?`The ${t} could not be rendered.`:`Something went wrong.`}),(0,N.jsx)(`p`,{children:`The details are in the browser console.`})]}),(0,N.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:border-accent hover:text-accent`,children:`Reload`})]})}function nr({lines:e}){let t=Bn(e.length);return(0,N.jsx)(`pre`,{className:`w-max min-w-full py-2 text-ink-200`,children:e.map((e,n)=>(0,N.jsxs)(`div`,{"data-line":n+1,className:`flex`,children:[(0,N.jsx)(F,{nos:[n+1],digits:t}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},n))})}function rr({lines:e,viewport:t}){let n=Bn(e.length),r=fn(e.length,t.scrollTop,t.height);return(0,N.jsxs)(`pre`,{className:`w-max min-w-full`,"data-virtual-count":e.length,children:[(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.before}}),e.slice(r.start,r.end).map((e,t)=>{let i=r.start+t;return(0,N.jsxs)(`div`,{"data-line":i+1,"data-virtual-row":i,className:`flex h-5 text-ink-200`,children:[(0,N.jsx)(F,{nos:[i+1],digits:n}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},i)}),(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.after}})]})}var ir=`modulepreload`,ar=function(e,t){return new URL(e,t).href},or={},sr=function(e){return e.pathname.endsWith(`.css`)},cr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},lr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ar(t,n);let r=s(t),i=sr(r);return cr(or,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ir,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function ur(e,t){return`${e??``}\u0000${Ln(t)}`}var dr=(0,M.lazy)(()=>lr(()=>import(`./Markdown-DEJAds14.js`).then(e=>({default:e.MarkdownView})),__vite__mapDeps([0,1,2,3]),import.meta.url)),fr=(0,M.lazy)(()=>lr(()=>import(`./Html-DGFy4jGa.js`).then(e=>({default:e.HtmlView})),__vite__mapDeps([4,1]),import.meta.url)),pr=(0,M.lazy)(()=>lr(()=>import(`./HtmlEditor-DzgQSTDx.js`).then(e=>({default:e.HtmlEditor})),__vite__mapDeps([5,1,2,6,7]),import.meta.url));function mr({repo:e,pane:t,loading:n=!1,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,showOtherFace:s,status:c,className:l=``}){let u=Cn(),[d,f]=(0,M.useState)(!1),p=t.kind===`file`?t.value.path:null,m=t.kind===`file`&&t.source?.kind===`commit`,h=e!==null&&p!==null&&!m&&Dn(p),g=(0,M.useRef)(null),{viewport:_,refresh:v}=Rt(g),y=t.kind===`file`?t.anchor:void 0,b=(0,M.useRef)(null),x=()=>{let n=g.current;if(!n)return 0;let r=n.getBoundingClientRect().top,i=Array.from(n.querySelectorAll(`[data-hunk]`),e=>({offset:e.getBoundingClientRect().top-r+n.scrollTop,hunk:Number(e.dataset.hunk??0)}));return t.kind===`diff`&&t.source&&(b.current={key:ur(e,t.source),top:n.scrollTop,left:n.scrollLeft}),i[Nn(i.map(e=>e.offset),n.scrollTop)]?.hunk??0};return(0,M.useEffect)(()=>{let n=g.current;if(!n)return;if(t.kind===`diff`&&t.source){let r=b.current;r&&r.key===ur(e,t.source)&&(n.scrollTop=r.top,n.scrollLeft=r.left,b.current=null,v());return}if(y===void 0||t.kind!==`file`)return;let r=Mn(y,t.value.lines.length);if(r===null)return;if(t.value.lines.length>200){n.scrollTop=pn(r),v();return}let i=n.querySelector(`[data-line="${r}"]`);i&&(n.scrollTop+=i.getBoundingClientRect().top-n.getBoundingClientRect().top,v())},[t,y,e,v]),(0,M.useEffect)(()=>{f(!1)},[e,p,m]),(0,N.jsxs)(`section`,{...At(`content`),className:`min-h-0 min-w-0 flex-col ${l}`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-850 px-3 py-0.5 text-ink-400`,children:[t.kind===`file`&&(0,N.jsx)($t,{path:t.value.path,className:`min-w-0 truncate`}),(0,N.jsx)(Rn,{pane:t,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,onShowOtherFace:()=>s(x()),canEdit:h,editing:d&&h,onToggleEdit:()=>f(e=>!e)})]}),(0,N.jsx)(`div`,{ref:g,onScroll:v,className:`nc-content min-h-0 flex-1 overflow-auto`,children:n?(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}):(0,N.jsxs)(N.Fragment,{children:[t.kind===`empty`&&(c===null?(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}):c.unavailable===void 0?(0,N.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:`Select a file or commit.`}):(0,N.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:cn(c.unavailable)})),t.kind===`file`&&(0,N.jsxs)(N.Fragment,{children:[d&&h&&e!==null&&p!==null?(0,N.jsx)(er,{region:`preview`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Opening the editor`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}),children:(0,N.jsx)(pr,{repo:e,path:p})})},`edit:${p}`):On(t.value.path)&&r?(0,N.jsx)(er,{region:`preview`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Rendering`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}),children:Dn(t.value.path)&&e!==null?(0,N.jsx)(fr,{src:j.previewUrl(e,t.value.path,t.source?.kind===`commit`?t.source.oid:void 0)}):(0,N.jsx)(dr,{source:kn(t.value.lines)})})},t.value.path):t.value.lines.length>200?(0,N.jsx)(rr,{lines:t.value.lines,viewport:_}):(0,N.jsx)(nr,{lines:t.value.lines}),t.value.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`File truncated — it exceeded the server's size ceiling.`})]}),t.kind===`diff`&&(0,N.jsx)(Zn,{diff:t.value,split:u.layout===`split`,viewport:_})]})})]})}var hr=[{key:`files`,label:`Repo`,icon:He},{key:`diff`,label:`Content`,icon:Ue},{key:`terminal`,label:`Terminal`,icon:We}];function gr({view:e,onSelect:t}){return(0,N.jsx)(`nav`,{"aria-label":`Switch view`,className:`flex shrink-0 items-stretch border-t border-chrome-line bg-ink-900 md:hidden`,children:hr.map(({key:n,label:r,icon:i})=>(0,N.jsxs)(`button`,{onClick:()=>t(n),"aria-current":e===n?`page`:void 0,className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 py-1 text-xs ${e===n?`text-accent`:`text-ink-400`}`,children:[(0,N.jsx)(i,{className:`h-5 w-5`}),r]},n))})}var _r=(0,M.lazy)(()=>lr(()=>import(`./Terminal-BuLVJ0Wx.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([8,1,2,9,7]),import.meta.url));function vr({repository:{id:e,current:t,status:n},sidebar:r,filePane:i,layout:{sidebarWidth:a,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,upperRef:f,lowerRef:p,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v,maximized:y,setMaximized:b,mobileView:x,setMobileView:S}}){let C=y===`files`;(0,M.useEffect)(()=>d,[e,d]),(0,M.useEffect)(()=>v,[v]);let w=(0,M.useCallback)(()=>b(e=>e===`terminal`?`none`:`terminal`),[b]);return(0,N.jsxs)(N.Fragment,{children:[s&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`}),m&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-row-resize`}),(0,N.jsxs)(`main`,{ref:f,className:`grid min-h-0 grid-cols-1 md:grid-cols-[var(--nc-sidebar)_minmax(0,1fr)] ${x===`terminal`?`hidden md:grid`:``} ${s||m?`select-none`:``}`,style:{"--nc-sidebar":C?`0px`:`min(${a}px, ${bt*100}vw)`},children:[(0,N.jsx)(xn,{...r,repo:e,status:n,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,filesMax:C,mobileView:x},e),(0,N.jsx)(mr,{...i,filesMax:C,setMaximized:b,status:n,className:`nc-fade-in ${x===`diff`?`flex`:`hidden md:flex`}`})]}),(0,N.jsx)(er,{region:`terminal panel`,className:x===`terminal`?`flex`:`hidden md:flex`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`min-h-0 border-t border-chrome-line ${x===`terminal`?`block`:`hidden md:block`}`}),children:(0,N.jsx)(_r,{repo:e,maximized:y===`terminal`,onToggleMaximized:w,className:`nc-fade-in ${x===`terminal`?`flex`:`hidden md:flex`} ${y===`files`?`overflow-hidden`:``}`,sectionRef:p,showDivider:y===`none`,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v})})}),(0,N.jsx)(gr,{view:x,onSelect:S}),(0,N.jsxs)(`footer`,{className:`flex shrink-0 items-center gap-3 border-t border-chrome-line bg-ink-900 px-3 py-1 text-ink-400`,children:[(0,N.jsx)(`span`,{className:`min-w-0 shrink-[1000] truncate`,children:t?.display_path}),n?.branch&&(0,N.jsx)(`span`,{className:`max-w-[50%] shrink-0 truncate text-accent`,children:n.branch}),gn(n)&&(0,N.jsx)(`span`,{className:`shrink-0 font-medium text-removed`,role:`status`,children:gn(n)}),n?.tracking&&(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`↑`,n.tracking.ahead,` ↓`,n.tracking.behind]}),(0,N.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?(0,N.jsx)(`span`,{className:`text-added`,children:`● live`}):`connecting…`})]})]})}var yr=`0.1.27`;function br({settings:e}){let{leaderText:t,conflict:n,setLeader:r,disable:i,reset:a}=e,[o,s]=(0,M.useState)(t),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{s(t),l(null)},[t]);let u=()=>{r(o)?l(null):l(`"${o}" is not a chord. Write it as Ctrl+F, Alt+Space or Ctrl+Shift+ArrowLeft.`)};return(0,N.jsxs)(`section`,{className:`shrink-0 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsxs)(`p`,{className:`text-ink-400`,children:[`Leader chord:`,` `,t?(0,N.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:t}):(0,N.jsx)(`span`,{className:`text-ink-200`,children:`switched off`})]}),(0,N.jsxs)(`div`,{className:`mt-1.5 flex items-stretch gap-2`,children:[(0,N.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`Ctrl+F`,"aria-label":`leader chord`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 font-mono text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,N.jsx)(`button`,{type:`button`,onClick:u,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Rebind`}),(0,N.jsx)(`button`,{type:`button`,onClick:i,title:`Leave the leader unbound. Standalone chords keep working.`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Switch off`}),(0,N.jsx)(`button`,{type:`button`,onClick:a,title:`Back to the leader the TUI ships with`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Reset`})]}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`mt-1 text-removed`,children:c}),n&&(0,N.jsxs)(`p`,{role:`status`,className:`mt-1 text-accent`,children:[n,` Rebind it above if you would rather keep that key.`]})]})}function xr({keys:e}){return e?(0,N.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map((e,t)=>(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:`then`}),(0,N.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:e})]},e))}):(0,N.jsx)(`span`,{className:`shrink-0 text-ink-400`,children:`no key — the leader is switched off`})}function Sr({action:e,keys:t,ariaKeys:n,available:r,onRun:i}){let a=`flex w-full flex-col gap-0.5 rounded-sm px-3 py-1.5 text-left ${r?``:`opacity-50`}`,o=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`span`,{className:`flex w-full items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-50`,children:e.label}),e.support===`reinterpreted`&&(0,N.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`reinterpreted`}),e.support===`browserOnly`&&(0,N.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`browser only`}),!r&&(0,N.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-ink-400`,children:`not available here`}),(0,N.jsx)(xr,{keys:t})]}),e.note&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:e.note})]}),s={"data-shortcut-action":e.id,"aria-disabled":!r||void 0,"aria-keyshortcuts":n??void 0};return e.keyboardOnly?(0,N.jsx)(`li`,{children:(0,N.jsx)(`div`,{...s,className:a,children:o})}):(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{type:`button`,...s,onClick:()=>{r&&i()},className:`${a} ${r?`hover:bg-ink-850`:``}`,children:o})})}var Cr={terminal:`Terminal`,project:`Projects`,view:`Layout and views`,focus:`Focus`,session:`Session`,help:`Help`},wr=(()=>{let e=[];for(let t of S){let n=e.find(e=>e.group===t.group);n?n.actions.push(t):e.push({group:t.group,actions:[t]})}return e})(),Tr=`nc-shortcut-help-title`;function Er({onClose:e,leader:t}){let n=we(),r=ee(),i=(0,M.useRef)(null),a=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=document.activeElement;return i.current?.focus(),()=>{a.current||e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,M.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let o=t=>{a.current=!0,n?.runAction(t.id),e()};return(0,N.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e,children:(0,N.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Tr,tabIndex:-1,className:`nc-rise-in flex max-h-[85vh] w-[40rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900 focus:outline-none`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{id:Tr,className:`block font-medium text-ink-50`,children:`Keyboard shortcuts`}),(0,N.jsxs)(`span`,{className:`block text-caption text-ink-400`,children:[`nightcrow v`,yr]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,N.jsx)(ae,{})})]}),(0,N.jsx)(br,{settings:t}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[wr.map(({group:e,actions:n})=>(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:Cr[e]}),(0,N.jsx)(`ul`,{children:n.map(e=>(0,N.jsx)(Sr,{action:e,keys:C(e.id,t.leader),ariaKeys:_e(e.id,t.leader),available:r(e.id),onRun:()=>o(e)},e.id))})]},e)),(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:`Not bound in the browser`}),(0,N.jsx)(`ul`,{children:w.map(e=>(0,N.jsxs)(`li`,{className:`px-3 py-1.5`,children:[(0,N.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:e.label}),(0,N.jsx)(`kbd`,{className:`shrink-0 rounded-sm border border-ink-700 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-400`,children:e.leader})]}),(0,N.jsx)(`span`,{className:`text-ink-400`,children:e.reason})]},e.leader))})]})]})]})})}var Dr=[`terminal.newPane`,`terminal.closePane`,`view.toggleMaximize`,`project.openDialog`,`help.shortcuts`],Or={keys:`3-9,0`,label:`pane 1-8`,click:null},kr={keys:`3-9,0`,label:`swap active pane with this pane`,click:null},Ar={keys:`esc`,label:`cancel`,click:null};function jr(e,t,n){return e.armed&&e.swapPending?{chip:`SWAP`,segments:[kr,Ar]}:e.armed?{chip:`PREFIX`,segments:Nr(n)}:t?{chip:null,segments:Mr(t,n)}:{chip:null,segments:Pr(n)}}function Mr(e,t){let n=me(e),r=[{keys:n,label:`leader`,click:{kind:`arm`}}];for(let e of S)Dr.includes(e.id)&&t(e.id)&&r.push(Fr(e,`${n} ${e.leader}`));return r}function Nr(e){let t=[],n=!1;for(let i of S)i.leader!==void 0&&e(i.id)&&(r(i.id)===null?t.push(Fr(i,i.leader)):(n||t.push(Or),n=!0));return t.push(Ar),t}function Pr(e){let t=[{keys:`leader`,label:`switched off`,click:{kind:`run`,action:`help.shortcuts`}}];for(let n of S)n.chord!==void 0&&e(n.id)&&t.push(Fr(n,n.chord));return t}function Fr(e,t){return{keys:t,label:e.hint,click:{kind:`run`,action:e.id}}}var Ir=`shrink-0 whitespace-nowrap`;function Lr({state:e,onClick:t}){let n=jr(e,c(),ee());return(0,N.jsxs)(`div`,{role:`toolbar`,"aria-label":`Keyboard hints`,className:`hidden shrink-0 items-center gap-1 overflow-hidden border-t border-chrome-line bg-ink-900 px-2 py-0.5 text-xs text-ink-400 md:flex`,children:[n.chip&&(0,N.jsx)(`span`,{"data-hint-chip":n.chip,className:`shrink-0 bg-accent px-1 font-bold text-ink-950`,children:n.chip}),n.segments.map((e,n)=>(0,N.jsxs)(M.Fragment,{children:[n>0&&(0,N.jsx)(`span`,{className:`shrink-0 text-ink-600`,children:`|`}),(0,N.jsx)(Rr,{segment:e,onClick:t})]},`${e.keys} ${e.label}`))]})}function Rr({segment:e,onClick:t}){let n=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-ink-200`,children:e.keys}),`: `,e.label]});if(!e.click)return(0,N.jsx)(`span`,{className:Ir,children:n});let r=e.click;return(0,N.jsx)(`button`,{type:`button`,"data-hint-action":r.kind===`run`?r.action:`arm`,onPointerDown:e=>e.preventDefault(),onClick:()=>t(r),className:`${Ir} rounded-sm hover:text-accent`,children:n})}function zr(e,t){return e?`grid-rows-[minmax(0,1fr)_auto_auto] ${t===`terminal`?`md:grid-rows-[minmax(0,0fr)_minmax(0,1fr)_auto_auto]`:t===`files`?`md:grid-rows-[minmax(0,1fr)_minmax(0,0fr)_auto_auto]`:`md:grid-rows-[minmax(0,var(--nc-upper))_minmax(0,var(--nc-lower))_auto_auto]`}`:`grid-rows-[1fr]`}function Br(e,t){let n=Vr(e);if(n.length===0)return null;let r=e.at,i=r===null?-1:n.findIndex(e=>Hr(e,r)),a;return a=i===-1?t>0?n[0]:n[n.length-1]:n[(i+t+n.length)%n.length],r!==null&&Hr(a,r)?null:a}function Vr({paneCount:e,maximized:t,narrow:n,mobileView:r}){let i={kind:`list`},a={kind:`content`},o=Array.from({length:e},(e,t)=>({kind:`pane`,index:t}));if(n)switch(r){case`files`:return[i];case`diff`:return[a];case`terminal`:return o}switch(t){case`terminal`:return o;case`files`:return[i,a];case`none`:return[i,a,...o]}}function Hr(e,t){return e.kind===t.kind?e.kind!==`pane`||t.kind!==`pane`||e.index===t.index:!1}function Ur(e,t,n){if(e.length<=1||t===null)return null;let r=e.indexOf(t);return r<0?null:e[(r+n+e.length)%e.length]}var Wr={armed:!1},Gr={kind:`none`};function Kr(e=Gr){return{state:Wr,effect:e}}function qr(e,t){switch(t.kind){case`blur`:case`focusChange`:case`dialogOpen`:case`repoChange`:case`socketReconnect`:case`disabled`:case`suppressed`:case`cancel`:return Kr();case`consumed`:return Kr();case`arm`:return{state:{armed:!0,swapPending:!1},effect:Gr};case`literalLeader`:return Kr({kind:`sendLiteralLeader`,data:t.data});case`action`:return Jr(e,t.action.id);case`ignore`:return{state:e,effect:Gr}}}function Jr(e,t){if(e.armed&&e.swapPending){let e=r(t);return e===null?Kr():Kr({kind:`swapWith`,pane:e})}return t===`terminal.swapPanePrompt`?{state:{armed:!0,swapPending:!0},effect:Gr}:Kr({kind:`run`,action:t})}var Yr=S.flatMap(e=>{if(!e.chord)return[];let t=E(e.chord);return t?[{spec:t,action:e}]:[]}),Xr=new Set([`Shift`,`Control`,`Alt`,`Meta`]),Zr=229,Qr=new Set([`Process`,`Unidentified`]),$r={kind:`ignore`};function ei(e){return e.isComposing===!0||e.keyCode===Zr||Qr.has(e.key)}function ti(e){return e.key===`Escape`||e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&e.key.toLowerCase()===`c`}function ni(e,t){if(e.type!==`keydown`||ei(e)||e.repeat===!0||t.suppressed)return $r;if(t.armed){if(ti(e))return{kind:`cancel`};if(t.leader&&O(t.leader,e))return{kind:`literalLeader`,data:le(t.leader)??``};if(e.key.length===1){let t=_(e.key);if(t)return{kind:`action`,action:t}}return Xr.has(e.key)?$r:{kind:`consumed`}}if(t.leader&&O(t.leader,e))return{kind:`arm`};for(let{spec:t,action:n}of Yr)if(O(t,e))return{kind:`action`,action:n};return $r}var ri=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`range`,`color`,`file`]),ii=new Set([`textbox`,`searchbox`,`combobox`]);function ai(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;let t=e.role?.toLowerCase()??``;if(ii.has(t))return!0;switch(e.tagName.toUpperCase()){case`INPUT`:return!ri.has(e.type?.toLowerCase()??`text`);case`TEXTAREA`:case`SELECT`:return!0;default:return!1}}function oi(e){return e.dialogOpen||e.composing||e.target?.inDialog===!0?!0:ai(e.target)}function si(e,t=!0){let n=(0,M.useRef)(e);n.current=e,(0,M.useEffect)(()=>{if(!t)return;let e=e=>{n.current(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[t])}function ci({enabled:e,leader:t,dialogOpen:n,repo:r}){let i=we(),a=(0,M.useRef)(Wr),[o,s]=(0,M.useState)(Wr),c=(0,M.useRef)(i);c.current=i;let l=(0,M.useCallback)(e=>{let t=qr(a.current,e);a.current=t.state,s(t.state);let n=c.current;n&&li(t.effect,n)},[]);si((0,M.useCallback)(e=>{let r=oi({target:jt(e.target),dialogOpen:n,composing:e.isComposing===!0}),i=ni(e,{leader:t,armed:a.current.armed,suppressed:r});return r?(l({kind:`suppressed`}),!1):(l(i),i.kind!==`ignore`)},[n,t,l]),e&&i!==null),(0,M.useEffect)(()=>{if(!e)return;let t=()=>l({kind:`blur`}),n=e=>{let t=jt(e.target);(ai(t)||t?.inDialog===!0)&&l({kind:`focusChange`})};return window.addEventListener(`blur`,t),document.addEventListener(`focusin`,n,{capture:!0}),()=>{window.removeEventListener(`blur`,t),document.removeEventListener(`focusin`,n,{capture:!0})}},[e,l]),(0,M.useEffect)(()=>{n&&l({kind:`dialogOpen`})},[n,l]),(0,M.useEffect)(()=>{e||l({kind:`disabled`})},[e,l]);let u=(0,M.useRef)(r);return(0,M.useEffect)(()=>{u.current!==r&&(u.current=r,l({kind:`repoChange`}))},[r,l]),(0,M.useEffect)(()=>{if(i)return i.onDisarm(()=>l({kind:`socketReconnect`}))},[i,l]),(0,M.useEffect)(()=>{l({kind:`cancel`})},[t,l]),{state:o,arm:(0,M.useCallback)(()=>l({kind:`arm`}),[l]),disarm:(0,M.useCallback)(()=>l({kind:`cancel`}),[l])}}function li(e,t){switch(e.kind){case`none`:return;case`run`:t.runAction(e.action);return;case`swapWith`:t.swapPanes(e.pane);return;case`sendLiteralLeader`:e.data&&t.sendLiteralLeader(e.data);return}}var ui=`nightcrow.shortcut.leader`;function di(){let[e,t]=(0,M.useState)(fi),n=(0,M.useCallback)(e=>{t(e),mi(e===null?null:me(e))},[]),r=(0,M.useCallback)(e=>{let t=E(e);return t?(n(t),!0):!1},[n]),i=(0,M.useCallback)(()=>n(null),[n]),a=(0,M.useCallback)(()=>n(ie),[n]);return{leader:e,leaderText:e?me(e):``,conflict:e?ye(e):null,setLeader:r,disable:i,reset:a}}function fi(){let e=pi();return e?e.leader===null?null:E(e.leader)??ie:ie}function pi(){try{let e=localStorage.getItem(ui);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.leader;return n===null?{leader:null}:typeof n==`string`?{leader:n}:null}catch{return null}}function mi(e){try{localStorage.setItem(ui,JSON.stringify({leader:e}))}catch{}}function hi({enabled:e,repo:t,repos:n,selectRepo:r,closeRepo:i,openPicker:a,pickerOpen:o,cycleAccent:s,reloadConfig:c,tab:l,chooseTab:u,maximized:d,setMaximized:f,mobileView:p}){let m=we(),h=di(),[g,_]=(0,M.useState)(!1),v=(0,M.useCallback)(()=>_(!0),[]),y=(0,M.useCallback)(()=>_(!1),[]),b=(0,M.useCallback)(e=>{let i=Ur(n.map(e=>e.id),t,e);i!==null&&r(i)},[n,t,r]),x=m?.zoomActivePane,S=(0,M.useCallback)(()=>{Mt()?(f(e=>e===`terminal`?`none`:`terminal`),x?.()):f(e=>e===`files`?`none`:`files`)},[f,x]),C=(0,M.useCallback)(e=>{let t=m?.paneCursor()??null,n=Nt(),r=null;n===`terminal`?t&&t.index>=0&&(r={kind:`pane`,index:t.index}):n!==null&&(r={kind:n});let i=Br({at:r,paneCount:t?.count??0,maximized:d,narrow:window.innerWidth<768,mobileView:p},e);i!==null&&(i.kind===`pane`?m?.focusPaneAt(i.index):Pt(i.kind))},[m,d,p]),w=(0,M.useMemo)(()=>{let e={"project.openDialog":a,"session.cycleAccent":s,"session.reloadConfig":c,"help.shortcuts":v};return n.length>1&&(e[`project.previous`]=()=>b(-1),e[`project.next`]=()=>b(1)),t===null||(e[`project.close`]=()=>i(t),e[`view.toggleLog`]=()=>u(l===`log`?`status`:`log`),e[`view.toggleTree`]=()=>u(l===`tree`?`status`:`tree`),e[`view.toggleMaximize`]=S,e[`focus.list`]=()=>void Pt(`list`),e[`focus.content`]=()=>void Pt(`content`),e[`focus.previous`]=()=>C(-1),e[`focus.next`]=()=>C(1)),e},[a,s,c,v,n.length,b,t,l,i,u,S,C]);Te(w);let T=ci({enabled:e,leader:h.leader,dialogOpen:o||g,repo:t}),{arm:E,disarm:ee}=T,te=(0,M.useCallback)(e=>{e.kind===`arm`?E():(ee(),m?.runAction(e.action))},[E,ee,m]);return{shortcutHelp:{open:g,show:v,hide:y},settings:h,hint:{state:T.state,onClick:te}}}var gi=1e3,_i=3,vi=2e3;function yi(e,t){let[n,r]=(0,M.useState)(!1),i=(0,M.useRef)(!1),a=(0,M.useRef)(!1);(0,M.useEffect)(()=>(a.current=!1,()=>{a.current=!0}),[]);let o=(0,M.useCallback)(async t=>{for(;!a.current;){if(await new Promise(e=>setTimeout(e,gi)),a.current)return;let n;try{n=await j.cloneStatus(t)}catch(e){if(Me(e)){i.current=!1,a.current||r(!1);return}if(e instanceof De&&e.status===404){if(a.current)return;D.error(`the clone's progress is no longer available`),i.current=!1,r(!1);return}continue}if(a.current)return;if(n.state===`done`){try{let t=await j.open(n.path);if(a.current)return;e(t)}catch(e){if(a.current)return;D.error(e instanceof Error?e.message:`could not open`)}finally{i.current=!1,a.current||r(!1)}return}if(n.state===`failed`){D.error(n.message),i.current=!1,r(!1);return}}},[e]),s=(0,M.useCallback)(async(e=()=>!1)=>{for(let t=0;t<_i;t++){if(t>0&&await new Promise(e=>setTimeout(e,vi)),i.current||e()||a.current)return;let n;try{({job:n}=await j.runningClone())}catch(e){if(Me(e))return;continue}if(n===null||e()||a.current||i.current)return;i.current=!0,r(!0),o(n);return}},[o]);return(0,M.useEffect)(()=>{if(!t)return;let e=!1;return s(()=>e),()=>{e=!0}},[t,s]),{busy:n,start:(0,M.useCallback)(async(e,t)=>{if(t.trim()&&!i.current){i.current=!0,r(!0);try{let{job:n}=await j.clone(e,t.trim());await o(n)}catch(e){if(i.current=!1,a.current)return;let t=e instanceof De&&e.status>=400;D.error(t?e.message:`could not confirm the clone started — check this folder before retrying`),r(!1),s()}}},[o,s])}}function bi(e,t,n,r=!1){return r&&n&&t.includes(n)?n:e&&t.includes(e)?e:n&&t.includes(n)?n:t[0]??null}function xi(e){let t=!1,n=null,r=()=>{if(t||n===null)return;let i=n;n=null,t=!0,e(i).catch(()=>{}).finally(()=>{t=!1,r()})};return e=>{n=e,r()}}function Si(e,t){return e?.enabled===t.enabled&&e.window_secs===t.window_secs?e:t}function Ci(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.display_path===r.display_path})?e:t}var wi=`The viewer was updated on the server.`,Ti=null,Ei=null,Di=null;function Oi(e,t){return e===null||t===null?!1:e!==t}function ki(e){Ti=e}function Ai(e){Oi(Ti,e)?Ei!==e&&(Ei=e,Di=D.info(wi,{sticky:!0,action:{label:`Reload`,run:()=>window.location.reload()}})):e===Ti&&Ei!==null&&(Di!==null&&ge(Di),Ei=null,Di=null)}var ji=3e3;function Mi({authed:e,setAuthed:t,handle:n,adoptAccent:r,adoptUpperPct:i,adoptMaximized:a,adoptViews:o,upperDraggingRef:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:f,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}){let[_,v]=(0,M.useState)([]),[y,b]=(0,M.useState)(null),[x,S]=(0,M.useState)(null),[C,w]=(0,M.useState)(null),[T,E]=(0,M.useState)(!1),[ee,te]=(0,M.useState)(!0),{current:ne}=(0,M.useRef)(xi(j.setActiveRepo)),re=(0,M.useRef)(null),ie=(0,M.useRef)(null);return(0,M.useEffect)(()=>{if(e===!1)return;let f=!1,_,y=new AbortController,x=()=>{let e=c.current,C=l.current,T=u.current,ee=d.current,ne=p.current;return j.repos(y.signal).then(n=>{let{repos:y,hot:ae,accent:oe,upper_pct:se,active_repo:D,maximized:ce,last_view:le,now_ms:ue,can_clone:de,viewer_build:fe}=n;if(f)return;Ai(fe),S(e=>Si(e,ae)),te(de),w(e=>nn(e,ue,Date.now())),c.current===e&&r(oe),l.current===C&&!s.current&&i(se),u.current===T&&a(ce),d.current===ee&&o(le??{},y.map(e=>e.id)),t(!0),E(!0);let pe=h.current||g.current!==null;p.current===ne&&!m.current&&!pe?v(e=>Ci(e,y)):v(e=>{let t=be(y.map(e=>e.id),e.map(e=>e.id)),n=new Map(y.map(e=>[e.id,e]));return Ci(e,t.map(e=>n.get(e)).filter(Boolean))});let me=y.map(e=>e.id),he=D!==re.current;re.current=D??null,he&&D&&me.includes(D)&&(ie.current=D),b(e=>bi(e,me,D,he)),f||(_=setTimeout(x,ji))}).catch(e=>{f||(Me(e)?(t(!1),E(!1)):(Ae(e)||n(e),_=setTimeout(x,ji)))})};return x(),()=>{f=!0,y.abort(),_&&clearTimeout(_)}},[e,t,n,r,i,f,c,l,u,d,s,a,o,p,m,h,g]),(0,M.useEffect)(()=>{y?y!==ie.current&&(ie.current=null,ne(y)):ie.current=null},[y,ne]),{repos:_,setRepos:v,repo:y,setRepo:b,hot:x,clockSkewMs:C,reposLoaded:T,canClone:ee}}var Ni=4;function Pi({ids:e,onReorder:t,draggingRef:n}){let r=(0,M.useRef)(null),i=(0,M.useRef)(null),a=(0,M.useRef)(null),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null);return{dragging:o,target:c,onStart:(t,a)=>{t.target.closest(`button[data-tab-close]`)||t.button!==0||e.length<2||(r.current=a,i.current={x:t.clientX,y:t.clientY},n.current=!1)},onMove:e=>{let t=r.current,o=i.current;if(t===null||o===null)return;if(!n.current&&e.buttons===0){r.current=null,i.current=null;return}if(!n.current&&Math.hypot(e.clientX-o.x,e.clientY-o.y){let o=r.current,c=a.current;o!==null&&n.current&&c!==null&&t(te(e,o,c)),r.current=null,i.current=null,a.current=null,n.current=!1,s(null),l(null)}}}function Fi({repos:e,setRepos:t,handle:n,writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}){let s=(0,M.useCallback)(()=>{if(a.current||o.current===null)return;let e=o.current;o.current=null,a.current=!0;let i=r.current;j.reorderRepos(e).then(e=>{r.current===i&&t(e)}).catch(n).finally(()=>{a.current=!1,s()})},[n,t,a,o,r]),c=(0,M.useCallback)(e=>{r.current+=1,t(t=>{let n=be(t.map(e=>e.id),e),r=new Map(t.map(e=>[e.id,e]));return n.map(e=>r.get(e)).filter(Boolean)}),o.current=e,s()},[s,t,o,r]);return{...Pi({ids:e.map(e=>e.id),onReorder:c,draggingRef:i}),writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}}function Ii({authed:e,setAuthed:t,handle:n,resumeTick:r,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,upperDraggingRef:f}){let p=(0,M.useRef)(0),m=(0,M.useRef)(!1),h=(0,M.useRef)(!1),g=(0,M.useRef)(null),_=Mi({authed:e,setAuthed:t,handle:n,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,upperDraggingRef:f,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:r,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}),{dragging:v,target:y,onStart:b,onMove:x,onEnd:S}=Fi({repos:_.repos,setRepos:_.setRepos,handle:n,writesRef:p,draggingRef:m,inFlightRef:h,pendingRef:g});return{..._,orderWrites:p,draggingRepo:v,dragOverRepo:y,onRepoDragStart:b,onRepoDragMove:x,onRepoDragEnd:S}}function Li(){let[e,t]=(0,M.useState)(!1),n=(0,M.useRef)(!1);return{reload:(0,M.useCallback)(async()=>{if(!n.current){n.current=!0,t(!0);try{D.success(await j.reloadConfig())}catch(e){D.error(e instanceof Error?e.message:`could not reload the config`)}finally{n.current=!1,t(!1)}}},[]),pending:e}}function Ri(e,t){let n=e.indexOf(t);return n===-1?e[0]??null:e[n+1]??e[n-1]??null}function zi({repo:e,repos:t,setRepos:n,setRepo:r,setPane:i,setTab:a,setPickerOpen:o,handle:s,orderWrites:c}){let l=(0,M.useRef)(t);l.current=t;let u=(0,M.useRef)(e);return u.current=e,{selectOpenedRepo:(0,M.useCallback)(e=>{c.current+=1,n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),r(e.id),e.id!==u.current&&(i({kind:`empty`}),a(`status`)),o(!1)},[n,r,i,a,o,c]),closeRepo:(0,M.useCallback)(async e=>{try{await j.close(e),c.current+=1;let t=Ri(l.current.map(e=>e.id),e);n(t=>t.filter(t=>t.id!==e)),r(n=>n===e?t:n)}catch(e){s(e)}},[n,r,s,c])}}function Bi(e,t,n){return t!==e&&(n.bumpPaneRequest(),e===`log`&&n.leaveLog(),n.recordTab(t),n.forgetPane(),!0)}function Vi(e,t,n,r,i){(0,M.useLayoutEffect)(()=>{t&&(e.some(e=>e.oid===t.commit.oid)||(r(),n(null),i()))},[e,t,n,r,i])}var Hi=5e3,Ui={refs:{},ahead:[],behind:[],truncated:!1};function Wi({repo:e,authed:t,tab:n,head:r,branch:i,refs:a,upstream:o}){let[s,c]=(0,M.useState)({key:``,value:Ui}),[l,u]=(0,M.useState)(0),d=e&&r!==void 0?`${e}|${r??``}|${i??``}|${a??``}|${o??``}`:``,f=(0,M.useRef)(s.key);f.current=s.key,(0,M.useEffect)(()=>{if(!e||!t||n!==`log`||d===``||f.current===d)return;let r=new AbortController,i;return j.logDecorations(e,r.signal).then(e=>c({key:d,value:e})).catch(()=>{r.signal.aborted||(i=setTimeout(()=>u(e=>e+1),Hi))}),()=>{r.abort(),i&&clearTimeout(i)}},[e,t,n,d,l]);let p=s.key.startsWith(`${e}|`)?s.value:Ui;return(0,M.useMemo)(()=>{let e=new Set(p.ahead),t=new Set(p.behind);return{refsOf:e=>p.refs[e],divergenceOf:n=>e.has(n)?`ahead`:t.has(n)?`behind`:void 0,truncated:p.truncated}},[p])}function Gi(e,t,n){let r=!e.truncated||e.head===void 0,i=t[0]?.oid,a=i===void 0?-1:e.commits.findIndex(e=>e.oid===i),o=a<0?[]:e.commits.slice(a);return a>=0&&o.length<=t.length&&o.every((e,n)=>e.oid===t[n].oid)?{commits:a===0?t:[...e.commits.slice(0,a),...t],anchor:e.head??null,done:n||r,mode:`prepend`}:{commits:e.commits,anchor:e.head??null,done:r,mode:`replace`}}function Ki({repo:e,authed:t,tab:n,filter:r,head:i,handle:a}){let o=(0,M.useRef)([]),[,s]=(0,M.useState)(0),c=(0,M.useCallback)(()=>s(e=>e+1),[]),l=o.current,[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(null),h=(0,M.useRef)(!1),g=(0,M.useRef)(!1),_=(0,M.useRef)(0),v=(0,M.useRef)(void 0),y=(0,M.useRef)(void 0),b=(0,M.useCallback)(()=>{_.current+=1,h.current=!1,g.current=!1,o.current=[],c(),m.current=null,d(!1),p(!1),v.current=void 0,y.current=void 0},[c]),[x,S]=(0,M.useState)(null),C=(0,M.useRef)(u);C.current=u;let w=(0,M.useRef)(i);w.current=i;let T=(0,M.useCallback)(async t=>{if(!e)return;y.current=w.current,_.current+=1;let n=_.current;h.current=!0,g.current=!0;try{let r=await j.log(e);if(n!==_.current)return;let i=t??{commits:o.current,done:C.current},a=Gi(r,i.commits,i.done);o.current=a.commits,c(),m.current=a.anchor,v.current=a.anchor,a.anchor===w.current&&(y.current=void 0),d(a.done),p(!1)}catch(e){n===_.current&&(y.current=void 0,a(e),p(!0))}finally{n===_.current&&(h.current=!1,g.current=!1)}},[e,a,c]),E=(0,M.useCallback)(async()=>{if(!e||h.current)return;h.current=!0;let t=_.current;try{let n=m.current,r=await j.log(e,n===null?void 0:{from:n,skip:o.current.length});if(t!==_.current)return;if(o.current.push(...r.commits),c(),m.current=r.head??null,d(!r.truncated||r.head===void 0),n===null){v.current=r.head??null;let e=w.current;e!==void 0&&e!==(r.head??null)&&T({commits:r.commits,done:!r.truncated||r.head===void 0})}}catch(e){t===_.current&&(a(e),p(!0))}finally{t===_.current&&(h.current=!1)}},[e,a,T,c]);(0,M.useEffect)(()=>{e&&t&&n===`log`&&l.length===0&&!u&&!f&&E()},[e,t,n,l.length,u,f,E]),(0,M.useEffect)(()=>{if(!e||!t||n!==`log`||i===void 0||f)return;let r=v.current;r!==void 0&&(r===i?g.current||(y.current=void 0):y.current!==i&&T())},[e,t,n,i,f,T]);let ee=r.toLowerCase(),te=ee===``?l:l.filter(e=>e.summary.toLowerCase().includes(ee)),ne=r!==``,re=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let e=re.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&E()},{root:e.closest(`ul`),rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[E,u,f,ne,x,n,te.length]),{commits:l,logDone:u,logStalled:f,setLogStalled:p,commitDrillDown:x,setCommitDrillDown:S,resetLog:b,logSentinelRef:re,visibleCommits:te,logPagingPaused:ne}}function qi(e,t){return[t??``,e.index,e.worktree,e.mtime??``,e.old_path??``].join(`\0`)}function Ji({repo:e,authed:t,resumeTick:n,tab:r,pane:i,setPane:a,handle:o,paneRequestRef:s}){let[c,l]=(0,M.useState)(null),u=(0,M.useRef)(i);u.current=i;let d=(0,M.useRef)(r);d.current=r;let f=(0,M.useRef)(null),p=(0,M.useRef)(null);return(0,M.useLayoutEffect)(()=>{l(null),p.current=null},[e,t]),(0,M.useEffect)(()=>{if(e&&t)return ke(e,l,({reason:e})=>l({files:[],truncated:!1,unavailable:e}))},[e,t,n]),(0,M.useEffect)(()=>{if(!e||!c)return;let t=p.current;p.current=new Map(c.files.map(e=>[e.path,qi(e,c.head)]));let n=u.current;if(d.current!==`status`||n.kind!==`diff`){f.current=null;return}let r=n.value.path,i=c.files.find(e=>e.path===r);if(!i){f.current=null,a({kind:`empty`});return}let l=qi(i,c.head),m=f.current;if(m?.path===r&&m.key===l)return;if(m?.path!==r&&t?.get(r)===l){f.current={path:r,key:l};return}let h=s.current,g=!0,_=()=>{let e=u.current;return g&&h===s.current&&e.kind===`diff`&&e.value.path===r};return j.diff(e,r).then(e=>{_()&&(f.current={path:r,key:l},a({kind:`diff`,value:e,source:Fn(i)&&In(e)?{kind:`workdir`,path:r}:void 0}))}).catch(e=>{_()&&o(e)}),()=>{g=!1}},[c,e,o,u,d,s,a]),{status:c,paneRef:u,tabRef:d}}function Yi({repo:e,authed:t,hot:n,clockSkewMs:r,resumeTick:i,handle:a}){let[o,s]=(0,M.useState)(`status`),[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)({kind:`empty`}),[m,h]=(0,M.useState)(e);m!==e&&(h(e),p({kind:`empty`}),s(`status`));let g=(0,M.useRef)(0),_=(0,M.useCallback)(()=>{g.current+=1},[]),v=(0,M.useCallback)(()=>p({kind:`empty`}),[]),{status:y}=Ji({repo:e,authed:t,resumeTick:i,tab:o,pane:f,setPane:p,handle:a,paneRequestRef:g}),b=n?.enabled?n.window_secs*1e3:0,x=Ki({repo:e,authed:t,tab:o,filter:c,head:y?y.head??null:void 0,handle:a}),S=Wi({repo:e,authed:t,tab:o,head:y?y.head??null:void 0,branch:y?.branch,refs:y?.refs,upstream:y?.tracking?.upstream}),C=x.setCommitDrillDown,w=x.resetLog;(0,M.useLayoutEffect)(()=>{_(),C(null),w()},[e,_,C,w]);let T=c.toLowerCase(),E=(0,M.useMemo)(()=>(y?.files??[]).filter(e=>e.path.toLowerCase().includes(T)),[y?.files,T]),ee=(0,M.useMemo)(()=>(x.commitDrillDown?.files??[]).filter(e=>e.path.toLowerCase().includes(T)||e.old_path?.toLowerCase().includes(T)),[x.commitDrillDown?.files,T]);return{screen:{tab:o,setTab:s,filter:c,setFilter:l,filterOpen:u,setFilterOpen:d,pane:f,setPane:p},request:{paneRequestRef:g,bumpPaneRequest:_,clearPane:v},status:{value:y,files:E,hotWindowMs:b,clockSkewMs:r??0},log:{...x,decorations:S,visibleCommitFiles:ee}}}var Xi=`nightcrow.mobileView`;function Zi(e){return e===`diff`||e===`terminal`||e===`files`?e:`files`}function Qi(){return Zi(m(Xi))}function $i(){let[e,t]=(0,M.useState)(Qi);return{mobileView:e,setMobileView:(0,M.useCallback)(e=>{h(Xi,e),t(e)},[])}}function ea({repo:e,handle:t,setPane:n,paneRequestRef:r,setCommitDrillDown:i,setMobileView:a,setPreviewRendered:o,statusRef:s,track:c}){let l=(0,M.useCallback)(e=>{let t=s.current?.files.find(t=>t.path===e);return t?Fn(t):!1},[s]);return{openDiff:(0,M.useCallback)((i,o)=>{if(!e)return;o?.restoring||a(`diff`);let s=r.current+=1;c(s,j.diff(e,i)).then(e=>{s===r.current&&n({kind:`diff`,value:e,source:l(i)&&In(e)?{kind:`workdir`,path:i}:void 0})}).catch(e=>{if(s!==r.current)return Me(e)?t(e):void 0;if(!o?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,l,c]),openFile:(0,M.useCallback)((i,s)=>{if(!e)return;s?.restoring||a(`diff`),o(!0);let l=r.current+=1;c(l,j.file(e,i)).then(e=>{l===r.current&&n({kind:`file`,value:e})}).catch(e=>{if(l!==r.current)return Me(e)?t(e):void 0;if(!s?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,o,c]),openCommit:(0,M.useCallback)(i=>{if(!e)return;a(`diff`);let o=r.current+=1;c(o,j.commit(e,i)).then(e=>{o===r.current&&n({kind:`diff`,value:e})}).catch(e=>{o===r.current&&t(e)})},[e,t,n,r,a,c]),openCommitFileDiff:(0,M.useCallback)((i,o,s)=>{if(!e)return;s?.restoring||a(`diff`);let l=r.current+=1;c(l,j.commitFileDiff(e,i,o)).then(e=>{l===r.current&&n({kind:`diff`,value:e,source:In(e)?{kind:`commit`,oid:i,path:o}:void 0})}).catch(e=>{if(l!==r.current)return Me(e)?t(e):void 0;if(!s?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,c]),openCommitFiles:(0,M.useCallback)(async o=>{if(!e)return;a(`diff`);let s=r.current+=1;try{let t=await c(s,j.commitFiles(e,o.oid));if(s!==r.current)return;if(i({commit:o,...t}),t.files.length===0){n({kind:`empty`});return}let a=await c(s,j.commit(e,o.oid));s===r.current&&n({kind:`diff`,value:a})}catch(e){s===r.current&&t(e)}},[e,t,n,r,i,a,c]),showOtherFace:(0,M.useCallback)((i,a=0)=>{let s=Pn(i);if(!e||!s)return;let{source:u}=s,d=s.want===`file`,f=d&&i.kind===`diff`?An(i.value,a):null,p=r.current+=1,m=u.kind===`workdir`?d?j.file(e,u.path):j.diff(e,u.path):d?j.commitFile(e,u.oid,u.path):j.commitFileDiff(e,u.oid,u.path);d&&o(!1),c(p,m).then(e=>{p===r.current&&n(d?{kind:`file`,value:e,source:u,anchor:f===null?void 0:jn(f)+1}:{kind:`diff`,value:e,source:In(e)&&(u.kind!==`workdir`||l(u.path))?u:void 0})}).catch(e=>{p===r.current&&t(e)})},[e,t,n,r,o,l,c])}}function ta(){let[e,t]=(0,M.useState)(null),n=(0,M.useCallback)((e,n)=>{t(e);let r=()=>t(t=>t===e?null:t);return n.then(r,r),n},[]);return{loading:e!==null,track:n}}function na({repo:e,handle:t,pane:n,setPane:r,paneRequestRef:i,setCommitDrillDown:a,status:o}){let{mobileView:s,setMobileView:c}=$i(),[l,u]=(0,M.useState)(!0),{loading:d,track:f}=ta(),p=(0,M.useRef)(o);p.current=o;let{openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}=ea({repo:e,handle:t,setPane:r,paneRequestRef:i,setCommitDrillDown:a,setMobileView:c,setPreviewRendered:u,statusRef:p,track:f}),b=(0,M.useMemo)(()=>({openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}),[m,h,g,_,v,y]);return(0,M.useMemo)(()=>({openers:b,pane:n,setPane:r,paneLoading:d,previewRendered:l,setPreviewRendered:u,mobileView:s,setMobileView:c}),[b,n,r,d,l,s,c])}var ra=[`status`,`log`,`tree`];function ia(){return{tab:`status`,file:null,tree_expanded:[]}}function aa(e,t){return{path:e,commit:null,face:t}}function oa(e,t,n){return{path:t,commit:e,face:n}}function sa(e){return[...e].sort().slice(0,200)}function I(e){let t=e?.file;return!t||!t.path?{kind:`none`}:t.commit?{kind:`commitDiff`,oid:t.commit,path:t.path}:t.face===`source`?{kind:`file`,path:t.path}:{kind:`diff`,path:t.path}}function L(e){let t=e?.tab;return t&&ra.includes(t)?t:`status`}function ca(e,t){return e?e.tab===t.tab&&e.tree_expanded.length===t.tree_expanded.length&&e.tree_expanded.every((e,n)=>e===t.tree_expanded[n])&&la(e.file,t.file):!1}function la(e,t){return!e||!t?e===t:e.path===t.path&&e.commit===t.commit&&e.face===t.face}function ua({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:o,openFile:s,openCommitFileDiff:c}){let l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(new Map),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(!1);(0,M.useEffect)(()=>{if(u.current!==e&&(u.current=e,l.current=null,m.current=!1,p(!1)),!e||!t||l.current===e)return;l.current=e;let r=d.current.get(e);d.current.delete(e);let f=r?{...n??ia(),...r}:n;if(r&&i(e,f),m.current)return;a(L(f));let h=I(f);if(h.kind===`none`)return;let g={restoring:!0};h.kind===`diff`?o(h.path,g):h.kind===`file`?s(h.path,g):c(h.oid,h.path,g)},[e,t,n,i,a,o,s,c]);let h=(0,M.useCallback)(t=>{if(e){if(m.current=!0,p(!0),l.current!==e){let n=d.current.get(e);d.current.set(e,{...n,...t})}else i(e,{...r(e)??ia(),...t})}},[e,r,i]);return{touched:f,noteTab:(0,M.useCallback)(e=>h({tab:e}),[h]),noteFile:(0,M.useCallback)(e=>h({file:e}),[h]),noteTree:(0,M.useCallback)(e=>h({tree_expanded:sa(e)}),[h])}}function da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,clearPane:o,openers:s}){let c=ua({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:s.openDiff,openFile:s.openFile,openCommitFileDiff:s.openCommitFileDiff}),{noteFile:l,noteTab:u,noteTree:d}=c,f=(0,M.useCallback)(e=>{u(e),a(e)},[u,a]),p=(0,M.useCallback)(()=>{l(null),o()},[l,o]),m=(0,M.useMemo)(()=>({openDiff:e=>{l(aa(e,`diff`)),s.openDiff(e)},openFile:e=>{l(aa(e,`source`)),s.openFile(e)},openCommit:e=>{l(null),s.openCommit(e)},openCommitFiles:e=>(l(null),s.openCommitFiles(e)),openCommitFileDiff:(e,t)=>{l(oa(e,t,`diff`)),s.openCommitFileDiff(e,t)}}),[s,l]),h=(0,M.useCallback)((e,t)=>{l(e.kind===`commit`?oa(e.oid,e.path,t):aa(e.path,t))},[l]);return{...c,noteTree:d,chooseTab:f,forgetPane:p,asked:m,noteOtherFace:h}}function fa({project:e,view:t,layout:n}){let{repo:r,repos:i,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}=e,u=Yi({repo:r,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}),d=na({repo:r,handle:l,pane:u.screen.pane,setPane:u.screen.setPane,paneRequestRef:u.request.paneRequestRef,setCommitDrillDown:u.log.setCommitDrillDown,status:u.status.value}),f=da({repo:r,known:t.known,remembered:t.remembered,latest:t.latest,remember:t.remember,setTab:u.screen.setTab,clearPane:u.request.clearPane,openers:d.openers}),p=u.screen.tab,{bumpPaneRequest:m}=u.request,{setCommitDrillDown:h,resetLog:g}=u.log,{chooseTab:_,forgetPane:v}=f,y=(0,M.useCallback)(e=>void Bi(p,e,{bumpPaneRequest:m,leaveLog:()=>{h(null),g()},recordTab:_,forgetPane:v}),[p,m,h,g,_,v]);Vi(u.log.commits,u.log.commitDrillDown,u.log.setCommitDrillDown,u.request.bumpPaneRequest,f.forgetPane);let b=n.maximizedPanelOf(r),x=n.setMaximizedFor,S=(0,M.useCallback)(e=>x(r,e),[r,x]),C=d.pane,w=d.openers.showOtherFace,T=f.noteOtherFace,E=(0,M.useCallback)(e=>{let t=Pn(C);t&&T(t.source,t.want===`file`?`source`:`diff`),w(C,e)},[C,T,w]);return{setPane:d.setPane,setTab:u.screen.setTab,clearPane:u.request.clearPane,maximized:b,tab:p,chooseTab:y,setMaximized:S,repoShell:r?{repository:{id:r,current:i.find(e=>e.id===r),status:u.status.value},sidebar:{tab:u.screen.tab,filter:u.screen.filter,setFilter:u.screen.setFilter,filterOpen:u.screen.filterOpen,setFilterOpen:u.screen.setFilterOpen,files:u.status.files,hotWindowMs:u.status.hotWindowMs,clockSkewMs:u.status.clockSkewMs,...d.openers,...f.asked,chooseTab:y,authed:a,handle:l,bumpPaneRequest:u.request.bumpPaneRequest,...u.log,restoreTree:t.remembered?.tree_expanded??[],restoreKnown:t.known,onTreeExpanded:f.noteTree,clearPane:f.forgetPane,touched:f.touched},filePane:{repo:r,pane:d.pane,loading:d.paneLoading,previewRendered:d.previewRendered,setPreviewRendered:d.setPreviewRendered,showOtherFace:E},layout:{...n.shell,maximized:b,setMaximized:S,mobileView:d.mobileView,setMobileView:d.setMobileView}}:null}}function pa(){let[e,t]=(0,M.useState)(0);return(0,M.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&t(e=>e+1)};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,e)}},[]),e}var ma=[{name:`yellow`,color:`#d9a441`},{name:`cyan`,color:`#03c4db`},{name:`green`,color:`#77c47a`},{name:`magenta`,color:`#dc8fd5`},{name:`blue`,color:`#87acfd`}],ha=`nightcrow.viewer.accent`;function ga(e){if(!Number.isFinite(e))return 0;let t=ma.length;return(Math.trunc(e)%t+t)%t}function _a(){let e=m(ha);return e===null?0:ga(Number(e))}function va(e){h(ha,String(e))}function ya(){let[e,t]=(0,M.useState)(_a);(0,M.useLayoutEffect)(()=>{document.documentElement.style.setProperty(`--color-accent`,ma[e].color)},[e]);let n=(0,M.useCallback)(()=>{t(e=>{let t=ga(e+1);return va(t),j.setAccent(t).catch(()=>{}),t})},[]),r=(0,M.useCallback)(e=>{t(t=>{let n=ga(e);return n===t?t:(va(n),n)})},[]);return{accent:ma[e],next:ma[ga(e+1)],cycle:n,adopt:r}}function ba(e){return Number.isFinite(e)?Math.min(Math.max(e,20),85):55}function xa(e){return Math.round(ba(e))}function Sa(e,t,n,r){let i=n-t;return ba(i<=0?r:(e-t)/i*100)}var Ca=`nightcrow.upperPct`;function wa(){try{let e=Number(localStorage.getItem(Ca));return Number.isFinite(e)&&e>0?xa(e):55}catch{return 55}}function Ta(e){try{localStorage.setItem(Ca,String(e))}catch{}}function Ea(){let[e,t]=(0,M.useState)(wa);return{pct:e,resize:(0,M.useCallback)(e=>{t(ba(e))},[]),commit:(0,M.useCallback)(e=>{let n=xa(e);t(n),Ta(n),j.setUpperPct(n).catch(()=>{})},[]),reset:(0,M.useCallback)(()=>{t(55),Ta(55),j.setUpperPct(55).catch(()=>{})},[]),adopt:(0,M.useCallback)(e=>{t(t=>{let n=xa(e);return n===t?t:(Ta(n),n)})},[])}}function Da(){let[e,t]=(0,M.useState)({}),n=(0,M.useRef)(e),r=(0,M.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,M.useRef)(0),a=(0,M.useRef)(new Map),o=(0,M.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=xi(t=>j.setMaximized(e,t===`none`?null:t));return a.current.set(e,n),n},[]),s=(0,M.useCallback)((e,t)=>{if(e==null)return;let a=n.current,s=typeof t==`function`?t(a[e]??`none`):t;i.current+=1,o(e)(s);let{[e]:c,...l}=a;r(s===`none`?l:{...a,[e]:s})},[o,r]);return{panelOf:(0,M.useCallback)(t=>t!=null&&e[t]||`none`,[e]),setFor:s,adopt:(0,M.useCallback)(e=>{Oa(n.current,e)||r(e)},[r]),writes:i}}function Oa(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function ka(){let[e,t]=(0,M.useState)({}),n=(0,M.useRef)(e),r=(0,M.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,M.useRef)(0),a=(0,M.useRef)(new Map),o=(0,M.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=xi(t=>j.setRepoView(e,t));return a.current.set(e,n),n},[]),s=(0,M.useCallback)((e,t)=>{e!=null&&(ca(n.current[e],t)||(i.current+=1,o(e)(t),r({...n.current,[e]:t})))},[o,r]),c=(0,M.useCallback)(t=>t==null?void 0:e[t],[e]),l=(0,M.useCallback)(e=>n.current[e],[]),u=(0,M.useRef)(new Set),[d,f]=(0,M.useState)(0);return{viewOf:c,rememberedFor:l,remember:s,adopt:(0,M.useCallback)((e,t)=>{let i=u.current;(i.size!==t.length||t.some(e=>!i.has(e)))&&(u.current=new Set(t),f(e=>e+1)),!Aa(n.current,e)&&r(e)},[r]),covers:(0,M.useCallback)(e=>e!=null&&u.current.has(e),[d]),writes:i}}function Aa(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>t[n]!==void 0&&ca(e[n],t[n]))}function ja(){let{accent:e,next:t,cycle:n,adopt:r}=ya(),{width:i,resize:a,commit:o,reset:s}=Tt(),{pct:c,resize:l,commit:u,reset:d,adopt:f}=Ea(),p=Da(),m=ka(),h=(0,M.useRef)(0),g=(0,M.useRef)(0);return{accent:e,next:t,cycle:(0,M.useCallback)(()=>{h.current+=1,n()},[n]),adoptAccent:r,accentWrites:h,sidebarWidth:i,resizeSidebar:a,commitSidebarWidth:o,resetSidebarWidth:s,upperPct:c,resizeUpperPct:l,commitUpperPct:(0,M.useCallback)(e=>{g.current+=1,u(e)},[u]),resetUpperPct:(0,M.useCallback)(()=>{g.current+=1,d()},[d]),bumpUpperPctWrites:(0,M.useCallback)(()=>{g.current+=1},[]),adoptUpperPct:f,upperPctWrites:g,maximizedPanelOf:p.panelOf,setMaximizedFor:p.setFor,adoptMaximized:p.adopt,maximizedWrites:p.writes,viewOf:m.viewOf,rememberedViewFor:m.rememberedFor,rememberView:m.remember,adoptViews:m.adopt,viewCovers:m.covers,viewWrites:m.writes}}var Ma=400;function Na({value:e,valueAt:t,onGestureStart:n,resize:r,commit:i,reset:a,axis:o}){let s=(0,M.useRef)(0),c=(0,M.useRef)(0),l=(0,M.useRef)(!1),u=(0,M.useRef)(!1),d=(0,M.useRef)(0),[f,p]=(0,M.useState)(!1);return{dragging:f,onDragStart:(0,M.useCallback)(t=>{t.button===0&&t.isPrimary&&n()&&(s.current=o===`x`?t.clientX:t.clientY,c.current=e,l.current=!0,u.current=!1,p(!0),t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())},[e,n,o]),onDragMove:(0,M.useCallback)(e=>{if(!l.current)return;let n=o===`x`?e.clientX:e.clientY;if(!u.current&&Math.abs(n-s.current)<3)return;let i=t(e);i!==null&&(u.current=!0,c.current=i,r(i))},[t,r,o]),onDragEnd:(0,M.useCallback)(()=>{if(!l.current)return;if(l.current=!1,p(!1),u.current){i(c.current),d.current=0;return}let e=Date.now();e-d.current{l.current=!1,u.current=!1,d.current=0,p(!1)},[]),draggingRef:l}}function Pa({sidebarRef:e,sidebarWidth:t,resizeSidebar:n,commitSidebarWidth:r,resetSidebarWidth:i}){let a=(0,M.useRef)(0),o=(0,M.useCallback)(()=>{let t=e.current?.getBoundingClientRect().left;return t!==void 0&&(a.current=t,!0)},[e]),{dragging:s,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:d}=Na({value:t,valueAt:(0,M.useCallback)(e=>e.clientX-a.current,[]),onGestureStart:o,resize:n,commit:r,reset:i,axis:`x`});return{draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d}}function Fa({upperRef:e,lowerRef:t,upperPct:n,resizeUpperPct:r,commitUpperPct:i,resetUpperPct:a,bumpUpperPctWrites:o}){let s=(0,M.useRef)(0),c=(0,M.useRef)(0),l=(0,M.useCallback)(()=>{let n=e.current?.getBoundingClientRect().top,r=t.current?.getBoundingClientRect().bottom;return n===void 0||r===void 0?!1:(s.current=n,c.current=r,o(),!0)},[e,t,o]),{dragging:u,onDragStart:d,onDragMove:f,onDragEnd:p,onDragCancel:m,draggingRef:h}=Na({value:n,valueAt:(0,M.useCallback)(e=>Sa(e.clientY,s.current,c.current,n),[n]),onGestureStart:l,resize:r,commit:i,reset:a,axis:`y`});return{draggingUpper:u,onUpperDragStart:d,onUpperDragMove:f,onUpperDragEnd:p,onUpperDragCancel:m,upperDraggingRef:h}}function Ia(){let{accent:e,next:t,cycle:n,adoptAccent:r,accentWrites:i,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p,adoptUpperPct:m,upperPctWrites:h,maximizedPanelOf:g,setMaximizedFor:_,adoptMaximized:v,maximizedWrites:y,viewOf:b,rememberedViewFor:x,rememberView:S,adoptViews:C,viewCovers:w,viewWrites:T}=ja(),E=(0,M.useRef)(null),ee=(0,M.useRef)(null),te=(0,M.useRef)(null),ne=Pa({sidebarRef:E,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c}),re=Fa({upperRef:ee,lowerRef:te,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p});return{accent:e,next:t,cycle:n,upperPct:l,maximizedPanelOf:g,setMaximizedFor:_,viewOf:b,rememberedViewFor:x,rememberView:S,viewCovers:w,shell:{sidebarWidth:a,sidebarRef:E,upperRef:ee,lowerRef:te,draggingSidebar:ne.draggingSidebar,onSidebarDragStart:ne.onSidebarDragStart,onSidebarDragMove:ne.onSidebarDragMove,onSidebarDragEnd:ne.onSidebarDragEnd,onSidebarDragCancel:ne.onSidebarDragCancel,draggingUpper:re.draggingUpper,onUpperDragStart:re.onUpperDragStart,onUpperDragMove:re.onUpperDragMove,onUpperDragEnd:re.onUpperDragEnd,onUpperDragCancel:re.onUpperDragCancel},guards:{adoptAccent:r,adoptUpperPct:m,adoptMaximized:v,adoptViews:C,accentWrites:i,upperPctWrites:h,maximizedWrites:y,viewWrites:T,upperDraggingRef:re.upperDraggingRef}}}var La=`nightcrow.tabStripSide`;function Ra(){return dt(m(La))??`top`}function za(e){h(La,e)}function Ba(){let[e,t]=(0,M.useState)(Ra);return{side:e,toggle:(0,M.useCallback)(()=>{t(e=>{let t=ft(e);return za(t),t})},[])}}function Va(){let[e,t]=(0,M.useState)(null),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=(0,M.useCallback)(e=>{Me(e)?t(!1):D.error(e instanceof Error?e.message:`request failed`)},[]),s=pa(),c=Ia(),l=Ba(),u=Ii({authed:e,setAuthed:t,handle:o,resumeTick:s,...c.guards}),d=fa({project:{repo:u.repo,repos:u.repos,authed:e,hot:u.hot,clockSkewMs:u.clockSkewMs,resumeTick:s,handle:o},view:{known:c.viewCovers(u.repo),remembered:c.viewOf(u.repo),latest:c.rememberedViewFor,remember:c.rememberView},layout:{shell:c.shell,maximizedPanelOf:c.maximizedPanelOf,setMaximizedFor:c.setMaximizedFor}}),{selectOpenedRepo:f,closeRepo:p}=zi({repo:u.repo,repos:u.repos,setRepos:u.setRepos,setRepo:u.setRepo,setPane:d.setPane,setTab:d.setTab,setPickerOpen:r,handle:o,orderWrites:u.orderWrites}),{busy:m,start:h}=yi(f,e===!0),g=u.repo,_=u.setRepo,v=d.clearPane,y=(0,M.useCallback)(e=>{e!==g&&(_(e),v())},[g,_,v]),b=u.repos.find(e=>e.id===i),x=(0,M.useCallback)(()=>a(null),[]),S=(0,M.useCallback)(()=>r(!0),[]),C=(0,M.useCallback)(()=>r(!1),[]),w=Li(),T=hi({enabled:e===!0,repo:u.repo,repos:u.repos,selectRepo:y,closeRepo:p,openPicker:S,pickerOpen:n,cycleAccent:c.cycle,reloadConfig:w.reload,tab:d.tab,chooseTab:d.chooseTab,maximized:d.maximized,setMaximized:d.setMaximized,mobileView:d.repoShell?.layout.mobileView??`files`});return{authed:e,login:(0,M.useCallback)(()=>t(null),[]),reposLoaded:u.reposLoaded,rows:zr(u.repo,d.maximized),upperPct:c.upperPct,header:{repos:u.repos,repo:u.repo,onSelectRepo:y,onCloseRepo:a,onOpenPicker:S,cloning:m,accent:c.accent,next:c.next,cycle:c.cycle,draggingRepo:u.draggingRepo,dragOverRepo:u.dragOverRepo,onRepoDragStart:u.onRepoDragStart,onRepoDragMove:u.onRepoDragMove,onRepoDragEnd:u.onRepoDragEnd,onReloadConfig:w.reload,reloading:w.pending,tabStrip:l},tabStrip:l,shortcutHelp:T.shortcutHelp,leader:T.settings,hint:T.hint,repoShell:d.repoShell,closeConfirm:b?{label:b.name,detail:`Its terminals and the processes running in them will be terminated.`,onConfirm:()=>{a(null),p(b.id)},onCancel:x}:null,picker:n?{onClose:C,onOpened:f,canClone:u.canClone,cloning:m,onClone:h}:null}}function Ha(){let e=Va();return e.authed===null?(0,N.jsx)(_t,{}):e.authed?e.reposLoaded?(0,N.jsx)(g,{children:(0,N.jsx)(oe,{children:(0,N.jsx)(x,{leader:e.leader.leader,children:(0,N.jsxs)(`div`,{className:`nc-fade-in flex h-full flex-col`,children:[(0,N.jsx)(pt,{...e.header,onShowShortcuts:e.shortcutHelp.show}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e.tabStrip.side===`left`&&(0,N.jsx)(`aside`,{className:`hidden w-48 shrink-0 flex-col border-r border-chrome-line bg-ink-950 md:flex`,children:(0,N.jsx)(Ke,{side:`left`,...e.header})}),(0,N.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 grid-cols-[minmax(0,1fr)] ${e.rows}`,style:{"--nc-upper":`${e.upperPct}fr`,"--nc-lower":`${100-e.upperPct}fr`},children:[e.repoShell?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(vr,{...e.repoShell}),(0,N.jsx)(Lr,{...e.hint})]}):(0,N.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-center text-ink-400`,children:[(0,N.jsxs)(`span`,{className:`md:hidden`,children:[`No repository open. Tap`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`No project`}),` above, then`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),`, to add one.`]}),(0,N.jsxs)(`span`,{className:`hidden md:inline`,children:[`No repository open. Click`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),` `,e.tabStrip.side===`left`?`beside`:`above`,` to add one.`]})]}),e.picker&&(0,N.jsx)(Le,{...e.picker}),e.closeConfirm&&(0,N.jsx)(se,{...e.closeConfirm}),e.shortcutHelp.open&&(0,N.jsx)(Er,{onClose:e.shortcutHelp.hide,leader:e.leader})]})]})]})})})}):(0,N.jsx)(_t,{}):(0,N.jsx)(vt,{onSuccess:e.login})}var Ua={error:7e3,info:5e3,success:5e3},Wa={error:`text-removed`,info:`text-accent`,success:`text-added`};function Ga(){let[e,t]=(0,M.useState)([]);return(0,M.useEffect)(()=>pe(t),[]),e.length===0?null:(0,N.jsx)(`div`,{className:`pointer-events-none fixed right-3 top-3 z-[60] flex w-80 max-w-[calc(100vw-1.5rem)] flex-col gap-2`,"aria-live":`polite`,children:e.map(e=>(0,N.jsx)(Ka,{toast:e},e.id))})}function Ka({toast:e}){let[t,n]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{if(t||e.sticky)return;let n=setTimeout(()=>ge(e.id),Ua[e.kind]);return()=>clearTimeout(n)},[e.id,e.kind,e.bump,e.sticky,t]),(0,N.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:`nc-slide-in pointer-events-auto flex items-start gap-2 rounded-md border border-ink-700 bg-ink-850 px-3 py-2 text-xs shadow-lg`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 break-words ${Wa[e.kind]}`,children:e.message}),e.action&&(0,N.jsx)(`button`,{type:`button`,onClick:e.action.run,className:`shrink-0 rounded-sm border border-ink-700 px-1.5 py-0.5 text-ink-200 hover:border-accent hover:text-accent`,children:e.action.label}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),"aria-label":`dismiss`,className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-ink-200`,children:(0,N.jsx)(ae,{className:`h-3 w-3`})})]})}function qa(e){let t=new URLSearchParams(e),n=t.get(`notice-repo`);if(!n)return null;let r=t.get(`notice-pane`);return{repo:n,pane:r!==null&&/^\d+$/.test(r)?Number(r):null}}async function Ja(e,t,n){let r=qa(e.search);if(!r)return;let i=new URL(e.href);i.searchParams.delete(`notice-repo`),i.searchParams.delete(`notice-pane`),t.replaceState(t.state,``,i.pathname+i.search+i.hash),r.pane!==null&&ve(r.repo,r.pane),await n(r.repo).catch(()=>void 0)}ce(document.documentElement,window),de(i()),ki(document.querySelector(`meta[name="nightcrow-build"]`)?.getAttribute(`content`)||null),Xe(Je()),await Ja(window.location,window.history,j.setActiveRepo);var Ya=1500;await Promise.race([document.fonts?.load(`400 12px "JetBrains Mono"`).catch(()=>void 0),new Promise(e=>setTimeout(e,Ya))]),(0,Ie.createRoot)(document.getElementById(`root`)).render((0,N.jsxs)(M.StrictMode,{children:[(0,N.jsx)(er,{children:(0,N.jsx)(Se,{children:(0,N.jsx)(Ha,{})})}),(0,N.jsx)(Ga,{})]})); \ No newline at end of file +`)}function An(e,t=0){if(new Set(e.hunks.map(t=>t.file_path??e.path)).size>1)return null;for(let n of e.hunks.slice(Math.max(0,t)))for(let e of n.lines)if(e.new_lineno!==void 0)return e.new_lineno;return null}function jn(e){return Math.max(0,e-1-2)}function Mn(e,t){return t<=0?null:Math.min(e,t)}function Nn(e,t){let n=0;return e.forEach((e,r)=>{e<=t&&(n=r)}),n}function Pn(e){return e.kind===`empty`||!e.source?null:{want:e.kind===`diff`?`file`:`diff`,source:e.source}}function Fn(e){return e.index!==`D`&&e.worktree!==`D`}function In(e){return e.hunks.some(e=>e.lines.some(e=>e.old_lineno!==void 0||e.new_lineno!==void 0))}function Ln(e){return e.kind===`workdir`?`workdir:${e.path}`:`commit:${e.oid}:${e.path}`}function Rn({pane:e,previewRendered:t,setPreviewRendered:n,filesMax:r,setMaximized:i,onShowOtherFace:a,canEdit:o,editing:s,onToggleEdit:c}){let l=Cn(),d=f();return(0,N.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[Pn(e)&&(0,N.jsx)(`button`,{onClick:a,"aria-pressed":e.kind===`file`,title:e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,"aria-label":e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${e.kind===`file`?`text-accent`:``}`,children:(0,N.jsx)(b,{})}),e.kind===`diff`&&(0,N.jsx)(`button`,{onClick:l.toggle,"aria-pressed":l.layout===`split`,title:l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,"aria-label":l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${l.layout===`split`?`text-accent`:``}`,children:(0,N.jsx)(v,{})}),o&&(0,N.jsx)(`button`,{onClick:c,"aria-pressed":s,title:s?`Stop editing`:`Edit this page's text`,"aria-label":s?`Stop editing`:`Edit this page's text`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${s?`text-accent`:``}`,children:(0,N.jsx)(xe,{})}),e.kind===`file`&&On(e.value.path)&&!s&&(0,N.jsx)(`button`,{onClick:()=>n(e=>!e),"aria-pressed":t,title:t?`Show raw source`:`Show the rendered page`,"aria-label":t?`Show raw source`:`Show the rendered page`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${t?`text-accent`:``}`,children:(0,N.jsx)(p,{})}),(0,N.jsx)(`button`,{onClick:()=>i(r?`none`:`files`),"aria-pressed":r,...d(`view.toggleMaximize`,r?`Restore the layout`:`Maximize the file pane`),"aria-label":r?`Restore the layout`:`Maximize the file pane`,className:`hidden shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent md:flex`,children:(0,N.jsx)(u,{maximized:r})})]})}var zn=3;function Bn(e){let t=e<1?1:String(Math.floor(e)).length;return Math.max(t,zn)}function Vn(e){let t=0;for(let n of e)for(let e of n.lines)t=Math.max(t,e.old_lineno??0,e.new_lineno??0);return Bn(t)}function F({nos:e,digits:t,tint:n=``,stickyClass:r=`sticky left-0`}){return(0,N.jsx)(`span`,{className:`${r} shrink-0 select-none bg-ink-950`,children:(0,N.jsx)(`span`,{className:`flex gap-[1ch] px-[1ch] text-ink-400 ${n}`,children:e.map((e,n)=>(0,N.jsx)(`span`,{className:`text-right`,style:{width:`${t}ch`},children:e??``},n))})})}function Hn(){let e=`(min-width: 768px)`,[t,n]=(0,M.useState)(()=>window.matchMedia(e).matches);return(0,M.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function Un(e,t,n){return e.hunks.flatMap((e,r)=>{let i={kind:`header`,hunk:r,text:`${e.file_path?`${e.file_path} `:``}${e.header}`};if(!t)return[i,...e.lines.map(e=>({kind:`unified`,hunk:r,line:e}))];let a=Sn(e.lines);return n?[i,...a.map(({left:e,right:t})=>({kind:`pair`,hunk:r,left:e,right:t}))]:[i,...a.map(({left:e})=>({kind:`side`,hunk:r,line:e,side:`old`,border:!1})),...a.map(({right:e},t)=>({kind:`side`,hunk:r,line:e,side:`new`,border:t===0}))]})}function Wn({line:e}){return(0,N.jsxs)(`span`,{className:`whitespace-pre pr-3`,children:[(0,N.jsx)(`span`,{className:`select-none text-ink-400`,children:e.kind}),e.spans.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Gn({line:e,side:t,digits:n,stickyClass:r}){let i=e?un(e.kind):`bg-ink-900/40`;return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 ${i}`,children:[(0,N.jsx)(F,{nos:[e?t===`old`?e.old_lineno:e.new_lineno:void 0],digits:n,tint:i,stickyClass:r}),e?(0,N.jsx)(Wn,{line:e}):(0,N.jsx)(`span`,{className:`pr-3`,children:` `})]})}function Kn({diff:e,split:t,viewport:n}){let r=Hn(),i=(0,M.useMemo)(()=>Un(e,t,r),[e,t,r]),a=Vn(e.hunks),o=fn(i.length,n.scrollTop,n.height);return(0,N.jsxs)(`div`,{className:`min-w-full py-1`,"data-virtual-count":i.length,children:[(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.before}}),i.slice(o.start,o.end).map((e,t)=>{let n=o.start+t,r={"data-hunk":e.hunk,"data-virtual-row":n};if(e.kind===`header`)return(0,N.jsx)(`div`,{...r,className:`h-5 bg-ink-850 px-3 text-ink-400`,children:e.text},n);if(e.kind===`unified`){let t=un(e.line.kind);return(0,N.jsxs)(`div`,{...r,className:`flex h-5 w-max min-w-full ${t}`,children:[(0,N.jsx)(F,{nos:[e.line.old_lineno,e.line.new_lineno],digits:a,tint:t}),(0,N.jsx)(Wn,{line:e.line})]},n)}return e.kind===`pair`?(0,N.jsxs)(`div`,{...r,className:`flex h-5 min-w-full`,children:[(0,N.jsx)(Gn,{line:e.left,side:`old`,digits:a}),(0,N.jsx)(`div`,{className:`flex min-w-0 flex-1 border-l border-ink-800`,children:(0,N.jsx)(Gn,{line:e.right,side:`new`,digits:a,stickyClass:`sticky left-1/2`})})]},n):(0,N.jsx)(`div`,{...r,className:`flex h-5 min-w-full ${e.border?`border-t border-ink-800`:``}`,children:(0,N.jsx)(Gn,{line:e.line,side:e.side,digits:a})},n)}),(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.after}})]})}function qn({line:e}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-ink-400 select-none`,children:e.kind}),e.spans.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Jn({line:e,digits:t,side:n}){if(e===null)return(0,N.jsxs)(`div`,{className:`flex bg-ink-900/40`,children:[(0,N.jsx)(F,{nos:[void 0],digits:t,tint:`bg-ink-900/40`}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:` `})]});let r=un(e.kind);return(0,N.jsxs)(`div`,{className:`flex ${r}`,children:[(0,N.jsx)(F,{nos:[n===`old`?e.old_lineno:e.new_lineno],digits:t,tint:r}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,N.jsx)(qn,{line:e})})]})}function Yn({cells:e,digits:t,side:n,border:r}){return(0,N.jsx)(`div`,{className:`min-w-0 flex-none overflow-x-auto md:flex-1 md:basis-1/2 ${r?`border-t border-ink-800 md:border-t-0 md:border-l`:``}`,children:(0,N.jsx)(`div`,{className:`w-max min-w-full`,children:e.map((e,r)=>(0,N.jsx)(Jn,{line:e,digits:t,side:n},r))})})}function Xn({lines:e,digits:t}){let n=Sn(e);return(0,N.jsxs)(`div`,{className:`flex flex-col md:flex-row`,children:[(0,N.jsx)(Yn,{cells:n.map(e=>e.left),digits:t,side:`old`,border:!1}),(0,N.jsx)(Yn,{cells:n.map(e=>e.right),digits:t,side:`new`,border:!0})]})}function Zn({diff:e,split:t,viewport:n={scrollTop:0,height:600}}){if(e.hunks.reduce((e,t)=>e+t.lines.length,0)>200)return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Kn,{diff:e,split:t,viewport:n}),e.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]});let r=Vn(e.hunks);return(0,N.jsxs)(`div`,{className:`p-1`,children:[e.hunks.length===0&&(0,N.jsx)(`p`,{className:`p-3 text-ink-400`,children:`No changes.`}),e.hunks.map((e,n)=>{let i=(0,N.jsxs)(`div`,{className:`bg-ink-850 px-3 py-0.5 text-ink-400`,children:[e.file_path?`${e.file_path} `:``,e.header]});return(0,N.jsx)(`div`,{"data-hunk":n,className:`mb-2`,children:t?(0,N.jsxs)(N.Fragment,{children:[i,(0,N.jsx)(Xn,{lines:e.lines,digits:r})]}):(0,N.jsxs)(`div`,{className:`w-max min-w-full`,children:[i,e.lines.map((e,t)=>{let n=un(e.kind);return(0,N.jsxs)(`div`,{className:`flex ${n}`,children:[(0,N.jsx)(F,{nos:[e.old_lineno,e.new_lineno],digits:r,tint:n}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,N.jsx)(qn,{line:e})})]},t)})]})},n)}),e.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]})}var Qn=[`failed to fetch dynamically imported module`,`error loading dynamically imported module`,`importing a module script failed`,`unable to preload css`];function $n(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return Qn.some(e=>n.includes(e))}var er=class extends M.Component{state={error:null,failed:!1};static getDerivedStateFromError(e){return{error:e,failed:!0}}componentDidCatch(e,t){console.error(`nightcrow: a subtree failed to render`,e,t)}render(){return this.state.failed?(0,N.jsx)(tr,{chunk:$n(this.state.error),region:this.props.region,className:this.props.className}):this.props.children}};function tr({chunk:e,region:t,className:n}){return(0,N.jsxs)(`div`,{role:`alert`,className:`h-full min-h-0 flex-col items-start gap-3 p-4 text-ink-400 ${n??`flex`}`,children:[e?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`text-accent`,children:`Part of the app could not be loaded.`}),(0,N.jsx)(`p`,{children:`Most likely the server was updated while this tab was open, and reloading picks up the current version. If the reload fails too, the server is not reachable from here. Either way nothing on the server is affected — the session, its repositories, and its terminals are untouched.`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`text-removed`,children:t?`The ${t} could not be rendered.`:`Something went wrong.`}),(0,N.jsx)(`p`,{children:`The details are in the browser console.`})]}),(0,N.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:border-accent hover:text-accent`,children:`Reload`})]})}function nr({lines:e}){let t=Bn(e.length);return(0,N.jsx)(`pre`,{className:`w-max min-w-full py-2 text-ink-200`,children:e.map((e,n)=>(0,N.jsxs)(`div`,{"data-line":n+1,className:`flex`,children:[(0,N.jsx)(F,{nos:[n+1],digits:t}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},n))})}function rr({lines:e,viewport:t}){let n=Bn(e.length),r=fn(e.length,t.scrollTop,t.height);return(0,N.jsxs)(`pre`,{className:`w-max min-w-full`,"data-virtual-count":e.length,children:[(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.before}}),e.slice(r.start,r.end).map((e,t)=>{let i=r.start+t;return(0,N.jsxs)(`div`,{"data-line":i+1,"data-virtual-row":i,className:`flex h-5 text-ink-200`,children:[(0,N.jsx)(F,{nos:[i+1],digits:n}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},i)}),(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.after}})]})}var ir=`modulepreload`,ar=function(e,t){return new URL(e,t).href},or={},sr=function(e){return e.pathname.endsWith(`.css`)},cr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},lr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ar(t,n);let r=s(t),i=sr(r);return cr(or,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ir,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function ur(e,t){return`${e??``}\u0000${Ln(t)}`}var dr=(0,M.lazy)(()=>lr(()=>import(`./Markdown-DEJAds14.js`).then(e=>({default:e.MarkdownView})),__vite__mapDeps([0,1,2,3]),import.meta.url)),fr=(0,M.lazy)(()=>lr(()=>import(`./Html-DGFy4jGa.js`).then(e=>({default:e.HtmlView})),__vite__mapDeps([4,1]),import.meta.url)),pr=(0,M.lazy)(()=>lr(()=>import(`./HtmlEditor-DzgQSTDx.js`).then(e=>({default:e.HtmlEditor})),__vite__mapDeps([5,1,2,6,7]),import.meta.url));function mr({repo:e,pane:t,loading:n=!1,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,showOtherFace:s,status:c,className:l=``}){let u=Cn(),[d,f]=(0,M.useState)(!1),p=t.kind===`file`?t.value.path:null,m=t.kind===`file`&&t.source?.kind===`commit`,h=e!==null&&p!==null&&!m&&Dn(p),g=(0,M.useRef)(null),{viewport:_,refresh:v}=Rt(g),y=t.kind===`file`?t.anchor:void 0,b=(0,M.useRef)(null),x=()=>{let n=g.current;if(!n)return 0;let r=n.getBoundingClientRect().top,i=Array.from(n.querySelectorAll(`[data-hunk]`),e=>({offset:e.getBoundingClientRect().top-r+n.scrollTop,hunk:Number(e.dataset.hunk??0)}));return t.kind===`diff`&&t.source&&(b.current={key:ur(e,t.source),top:n.scrollTop,left:n.scrollLeft}),i[Nn(i.map(e=>e.offset),n.scrollTop)]?.hunk??0};return(0,M.useEffect)(()=>{let n=g.current;if(!n)return;if(t.kind===`diff`&&t.source){let r=b.current;r&&r.key===ur(e,t.source)&&(n.scrollTop=r.top,n.scrollLeft=r.left,b.current=null,v());return}if(y===void 0||t.kind!==`file`)return;let r=Mn(y,t.value.lines.length);if(r===null)return;if(t.value.lines.length>200){n.scrollTop=pn(r),v();return}let i=n.querySelector(`[data-line="${r}"]`);i&&(n.scrollTop+=i.getBoundingClientRect().top-n.getBoundingClientRect().top,v())},[t,y,e,v]),(0,M.useEffect)(()=>{f(!1)},[e,p,m]),(0,N.jsxs)(`section`,{...At(`content`),className:`min-h-0 min-w-0 flex-col ${l}`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-850 px-3 py-0.5 text-ink-400`,children:[t.kind===`file`&&(0,N.jsx)($t,{path:t.value.path,className:`min-w-0 truncate`}),(0,N.jsx)(Rn,{pane:t,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,onShowOtherFace:()=>s(x()),canEdit:h,editing:d&&h,onToggleEdit:()=>f(e=>!e)})]}),(0,N.jsx)(`div`,{ref:g,onScroll:v,className:`nc-content min-h-0 flex-1 overflow-auto`,children:n?(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}):(0,N.jsxs)(N.Fragment,{children:[t.kind===`empty`&&(c===null?(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}):c.unavailable===void 0?(0,N.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:`Select a file or commit.`}):(0,N.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:cn(c.unavailable)})),t.kind===`file`&&(0,N.jsxs)(N.Fragment,{children:[d&&h&&e!==null&&p!==null?(0,N.jsx)(er,{region:`preview`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Opening the editor`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}),children:(0,N.jsx)(pr,{repo:e,path:p})})},`edit:${p}`):On(t.value.path)&&r?(0,N.jsx)(er,{region:`preview`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Rendering`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}),children:Dn(t.value.path)&&e!==null?(0,N.jsx)(fr,{src:j.previewUrl(e,t.value.path,t.source?.kind===`commit`?t.source.oid:void 0)}):(0,N.jsx)(dr,{source:kn(t.value.lines)})})},t.value.path):t.value.lines.length>200?(0,N.jsx)(rr,{lines:t.value.lines,viewport:_}):(0,N.jsx)(nr,{lines:t.value.lines}),t.value.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`File truncated — it exceeded the server's size ceiling.`})]}),t.kind===`diff`&&(0,N.jsx)(Zn,{diff:t.value,split:u.layout===`split`,viewport:_})]})})]})}var hr=[{key:`files`,label:`Repo`,icon:He},{key:`diff`,label:`Content`,icon:Ue},{key:`terminal`,label:`Terminal`,icon:We}];function gr({view:e,onSelect:t}){return(0,N.jsx)(`nav`,{"aria-label":`Switch view`,className:`flex shrink-0 items-stretch border-t border-chrome-line bg-ink-900 md:hidden`,children:hr.map(({key:n,label:r,icon:i})=>(0,N.jsxs)(`button`,{onClick:()=>t(n),"aria-current":e===n?`page`:void 0,className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 py-1 text-xs ${e===n?`text-accent`:`text-ink-400`}`,children:[(0,N.jsx)(i,{className:`h-5 w-5`}),r]},n))})}var _r=(0,M.lazy)(()=>lr(()=>import(`./Terminal-N9POd-x9.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([8,1,2,9,7]),import.meta.url));function vr({repository:{id:e,current:t,status:n},sidebar:r,filePane:i,layout:{sidebarWidth:a,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,upperRef:f,lowerRef:p,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v,maximized:y,setMaximized:b,mobileView:x,setMobileView:S}}){let C=y===`files`;(0,M.useEffect)(()=>d,[e,d]),(0,M.useEffect)(()=>v,[v]);let w=(0,M.useCallback)(()=>b(e=>e===`terminal`?`none`:`terminal`),[b]);return(0,N.jsxs)(N.Fragment,{children:[s&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`}),m&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-row-resize`}),(0,N.jsxs)(`main`,{ref:f,className:`grid min-h-0 grid-cols-1 md:grid-cols-[var(--nc-sidebar)_minmax(0,1fr)] ${x===`terminal`?`hidden md:grid`:``} ${s||m?`select-none`:``}`,style:{"--nc-sidebar":C?`0px`:`min(${a}px, ${bt*100}vw)`},children:[(0,N.jsx)(xn,{...r,repo:e,status:n,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,filesMax:C,mobileView:x},e),(0,N.jsx)(mr,{...i,filesMax:C,setMaximized:b,status:n,className:`nc-fade-in ${x===`diff`?`flex`:`hidden md:flex`}`})]}),(0,N.jsx)(er,{region:`terminal panel`,className:x===`terminal`?`flex`:`hidden md:flex`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`min-h-0 border-t border-chrome-line ${x===`terminal`?`block`:`hidden md:block`}`}),children:(0,N.jsx)(_r,{repo:e,maximized:y===`terminal`,onToggleMaximized:w,className:`nc-fade-in ${x===`terminal`?`flex`:`hidden md:flex`} ${y===`files`?`overflow-hidden`:``}`,sectionRef:p,showDivider:y===`none`,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v})})}),(0,N.jsx)(gr,{view:x,onSelect:S}),(0,N.jsxs)(`footer`,{className:`flex shrink-0 items-center gap-3 border-t border-chrome-line bg-ink-900 px-3 py-1 text-ink-400`,children:[(0,N.jsx)(`span`,{className:`min-w-0 shrink-[1000] truncate`,children:t?.display_path}),n?.branch&&(0,N.jsx)(`span`,{className:`max-w-[50%] shrink-0 truncate text-accent`,children:n.branch}),gn(n)&&(0,N.jsx)(`span`,{className:`shrink-0 font-medium text-removed`,role:`status`,children:gn(n)}),n?.tracking&&(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`↑`,n.tracking.ahead,` ↓`,n.tracking.behind]}),(0,N.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?(0,N.jsx)(`span`,{className:`text-added`,children:`● live`}):`connecting…`})]})]})}var yr=`0.1.27`;function br({settings:e}){let{leaderText:t,conflict:n,setLeader:r,disable:i,reset:a}=e,[o,s]=(0,M.useState)(t),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{s(t),l(null)},[t]);let u=()=>{r(o)?l(null):l(`"${o}" is not a chord. Write it as Ctrl+F, Alt+Space or Ctrl+Shift+ArrowLeft.`)};return(0,N.jsxs)(`section`,{className:`shrink-0 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsxs)(`p`,{className:`text-ink-400`,children:[`Leader chord:`,` `,t?(0,N.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:t}):(0,N.jsx)(`span`,{className:`text-ink-200`,children:`switched off`})]}),(0,N.jsxs)(`div`,{className:`mt-1.5 flex items-stretch gap-2`,children:[(0,N.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`Ctrl+F`,"aria-label":`leader chord`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 font-mono text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,N.jsx)(`button`,{type:`button`,onClick:u,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Rebind`}),(0,N.jsx)(`button`,{type:`button`,onClick:i,title:`Leave the leader unbound. Standalone chords keep working.`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Switch off`}),(0,N.jsx)(`button`,{type:`button`,onClick:a,title:`Back to the leader the TUI ships with`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Reset`})]}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`mt-1 text-removed`,children:c}),n&&(0,N.jsxs)(`p`,{role:`status`,className:`mt-1 text-accent`,children:[n,` Rebind it above if you would rather keep that key.`]})]})}function xr({keys:e}){return e?(0,N.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map((e,t)=>(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:`then`}),(0,N.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:e})]},e))}):(0,N.jsx)(`span`,{className:`shrink-0 text-ink-400`,children:`no key — the leader is switched off`})}function Sr({action:e,keys:t,ariaKeys:n,available:r,onRun:i}){let a=`flex w-full flex-col gap-0.5 rounded-sm px-3 py-1.5 text-left ${r?``:`opacity-50`}`,o=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`span`,{className:`flex w-full items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-50`,children:e.label}),e.support===`reinterpreted`&&(0,N.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`reinterpreted`}),e.support===`browserOnly`&&(0,N.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`browser only`}),!r&&(0,N.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-ink-400`,children:`not available here`}),(0,N.jsx)(xr,{keys:t})]}),e.note&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:e.note})]}),s={"data-shortcut-action":e.id,"aria-disabled":!r||void 0,"aria-keyshortcuts":n??void 0};return e.keyboardOnly?(0,N.jsx)(`li`,{children:(0,N.jsx)(`div`,{...s,className:a,children:o})}):(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{type:`button`,...s,onClick:()=>{r&&i()},className:`${a} ${r?`hover:bg-ink-850`:``}`,children:o})})}var Cr={terminal:`Terminal`,project:`Projects`,view:`Layout and views`,focus:`Focus`,session:`Session`,help:`Help`},wr=(()=>{let e=[];for(let t of S){let n=e.find(e=>e.group===t.group);n?n.actions.push(t):e.push({group:t.group,actions:[t]})}return e})(),Tr=`nc-shortcut-help-title`;function Er({onClose:e,leader:t}){let n=we(),r=ee(),i=(0,M.useRef)(null),a=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=document.activeElement;return i.current?.focus(),()=>{a.current||e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,M.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let o=t=>{a.current=!0,n?.runAction(t.id),e()};return(0,N.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e,children:(0,N.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Tr,tabIndex:-1,className:`nc-rise-in flex max-h-[85vh] w-[40rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900 focus:outline-none`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{id:Tr,className:`block font-medium text-ink-50`,children:`Keyboard shortcuts`}),(0,N.jsxs)(`span`,{className:`block text-caption text-ink-400`,children:[`nightcrow v`,yr]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,N.jsx)(ae,{})})]}),(0,N.jsx)(br,{settings:t}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[wr.map(({group:e,actions:n})=>(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:Cr[e]}),(0,N.jsx)(`ul`,{children:n.map(e=>(0,N.jsx)(Sr,{action:e,keys:C(e.id,t.leader),ariaKeys:_e(e.id,t.leader),available:r(e.id),onRun:()=>o(e)},e.id))})]},e)),(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:`Not bound in the browser`}),(0,N.jsx)(`ul`,{children:w.map(e=>(0,N.jsxs)(`li`,{className:`px-3 py-1.5`,children:[(0,N.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:e.label}),(0,N.jsx)(`kbd`,{className:`shrink-0 rounded-sm border border-ink-700 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-400`,children:e.leader})]}),(0,N.jsx)(`span`,{className:`text-ink-400`,children:e.reason})]},e.leader))})]})]})]})})}var Dr=[`terminal.newPane`,`terminal.closePane`,`view.toggleMaximize`,`project.openDialog`,`help.shortcuts`],Or={keys:`3-9,0`,label:`pane 1-8`,click:null},kr={keys:`3-9,0`,label:`swap active pane with this pane`,click:null},Ar={keys:`esc`,label:`cancel`,click:null};function jr(e,t,n){return e.armed&&e.swapPending?{chip:`SWAP`,segments:[kr,Ar]}:e.armed?{chip:`PREFIX`,segments:Nr(n)}:t?{chip:null,segments:Mr(t,n)}:{chip:null,segments:Pr(n)}}function Mr(e,t){let n=me(e),r=[{keys:n,label:`leader`,click:{kind:`arm`}}];for(let e of S)Dr.includes(e.id)&&t(e.id)&&r.push(Fr(e,`${n} ${e.leader}`));return r}function Nr(e){let t=[],n=!1;for(let i of S)i.leader!==void 0&&e(i.id)&&(r(i.id)===null?t.push(Fr(i,i.leader)):(n||t.push(Or),n=!0));return t.push(Ar),t}function Pr(e){let t=[{keys:`leader`,label:`switched off`,click:{kind:`run`,action:`help.shortcuts`}}];for(let n of S)n.chord!==void 0&&e(n.id)&&t.push(Fr(n,n.chord));return t}function Fr(e,t){return{keys:t,label:e.hint,click:{kind:`run`,action:e.id}}}var Ir=`shrink-0 whitespace-nowrap`;function Lr({state:e,onClick:t}){let n=jr(e,c(),ee());return(0,N.jsxs)(`div`,{role:`toolbar`,"aria-label":`Keyboard hints`,className:`hidden shrink-0 items-center gap-1 overflow-hidden border-t border-chrome-line bg-ink-900 px-2 py-0.5 text-xs text-ink-400 md:flex`,children:[n.chip&&(0,N.jsx)(`span`,{"data-hint-chip":n.chip,className:`shrink-0 bg-accent px-1 font-bold text-ink-950`,children:n.chip}),n.segments.map((e,n)=>(0,N.jsxs)(M.Fragment,{children:[n>0&&(0,N.jsx)(`span`,{className:`shrink-0 text-ink-600`,children:`|`}),(0,N.jsx)(Rr,{segment:e,onClick:t})]},`${e.keys} ${e.label}`))]})}function Rr({segment:e,onClick:t}){let n=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-ink-200`,children:e.keys}),`: `,e.label]});if(!e.click)return(0,N.jsx)(`span`,{className:Ir,children:n});let r=e.click;return(0,N.jsx)(`button`,{type:`button`,"data-hint-action":r.kind===`run`?r.action:`arm`,onPointerDown:e=>e.preventDefault(),onClick:()=>t(r),className:`${Ir} rounded-sm hover:text-accent`,children:n})}function zr(e,t){return e?`grid-rows-[minmax(0,1fr)_auto_auto] ${t===`terminal`?`md:grid-rows-[minmax(0,0fr)_minmax(0,1fr)_auto_auto]`:t===`files`?`md:grid-rows-[minmax(0,1fr)_minmax(0,0fr)_auto_auto]`:`md:grid-rows-[minmax(0,var(--nc-upper))_minmax(0,var(--nc-lower))_auto_auto]`}`:`grid-rows-[1fr]`}function Br(e,t){let n=Vr(e);if(n.length===0)return null;let r=e.at,i=r===null?-1:n.findIndex(e=>Hr(e,r)),a;return a=i===-1?t>0?n[0]:n[n.length-1]:n[(i+t+n.length)%n.length],r!==null&&Hr(a,r)?null:a}function Vr({paneCount:e,maximized:t,narrow:n,mobileView:r}){let i={kind:`list`},a={kind:`content`},o=Array.from({length:e},(e,t)=>({kind:`pane`,index:t}));if(n)switch(r){case`files`:return[i];case`diff`:return[a];case`terminal`:return o}switch(t){case`terminal`:return o;case`files`:return[i,a];case`none`:return[i,a,...o]}}function Hr(e,t){return e.kind===t.kind?e.kind!==`pane`||t.kind!==`pane`||e.index===t.index:!1}function Ur(e,t,n){if(e.length<=1||t===null)return null;let r=e.indexOf(t);return r<0?null:e[(r+n+e.length)%e.length]}var Wr={armed:!1},Gr={kind:`none`};function Kr(e=Gr){return{state:Wr,effect:e}}function qr(e,t){switch(t.kind){case`blur`:case`focusChange`:case`dialogOpen`:case`repoChange`:case`socketReconnect`:case`disabled`:case`suppressed`:case`cancel`:return Kr();case`consumed`:return Kr();case`arm`:return{state:{armed:!0,swapPending:!1},effect:Gr};case`literalLeader`:return Kr({kind:`sendLiteralLeader`,data:t.data});case`action`:return Jr(e,t.action.id);case`ignore`:return{state:e,effect:Gr}}}function Jr(e,t){if(e.armed&&e.swapPending){let e=r(t);return e===null?Kr():Kr({kind:`swapWith`,pane:e})}return t===`terminal.swapPanePrompt`?{state:{armed:!0,swapPending:!0},effect:Gr}:Kr({kind:`run`,action:t})}var Yr=S.flatMap(e=>{if(!e.chord)return[];let t=E(e.chord);return t?[{spec:t,action:e}]:[]}),Xr=new Set([`Shift`,`Control`,`Alt`,`Meta`]),Zr=229,Qr=new Set([`Process`,`Unidentified`]),$r={kind:`ignore`};function ei(e){return e.isComposing===!0||e.keyCode===Zr||Qr.has(e.key)}function ti(e){return e.key===`Escape`||e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&e.key.toLowerCase()===`c`}function ni(e,t){if(e.type!==`keydown`||ei(e)||e.repeat===!0||t.suppressed)return $r;if(t.armed){if(ti(e))return{kind:`cancel`};if(t.leader&&O(t.leader,e))return{kind:`literalLeader`,data:le(t.leader)??``};if(e.key.length===1){let t=_(e.key);if(t)return{kind:`action`,action:t}}return Xr.has(e.key)?$r:{kind:`consumed`}}if(t.leader&&O(t.leader,e))return{kind:`arm`};for(let{spec:t,action:n}of Yr)if(O(t,e))return{kind:`action`,action:n};return $r}var ri=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`range`,`color`,`file`]),ii=new Set([`textbox`,`searchbox`,`combobox`]);function ai(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;let t=e.role?.toLowerCase()??``;if(ii.has(t))return!0;switch(e.tagName.toUpperCase()){case`INPUT`:return!ri.has(e.type?.toLowerCase()??`text`);case`TEXTAREA`:case`SELECT`:return!0;default:return!1}}function oi(e){return e.dialogOpen||e.composing||e.target?.inDialog===!0?!0:ai(e.target)}function si(e,t=!0){let n=(0,M.useRef)(e);n.current=e,(0,M.useEffect)(()=>{if(!t)return;let e=e=>{n.current(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[t])}function ci({enabled:e,leader:t,dialogOpen:n,repo:r}){let i=we(),a=(0,M.useRef)(Wr),[o,s]=(0,M.useState)(Wr),c=(0,M.useRef)(i);c.current=i;let l=(0,M.useCallback)(e=>{let t=qr(a.current,e);a.current=t.state,s(t.state);let n=c.current;n&&li(t.effect,n)},[]);si((0,M.useCallback)(e=>{let r=oi({target:jt(e.target),dialogOpen:n,composing:e.isComposing===!0}),i=ni(e,{leader:t,armed:a.current.armed,suppressed:r});return r?(l({kind:`suppressed`}),!1):(l(i),i.kind!==`ignore`)},[n,t,l]),e&&i!==null),(0,M.useEffect)(()=>{if(!e)return;let t=()=>l({kind:`blur`}),n=e=>{let t=jt(e.target);(ai(t)||t?.inDialog===!0)&&l({kind:`focusChange`})};return window.addEventListener(`blur`,t),document.addEventListener(`focusin`,n,{capture:!0}),()=>{window.removeEventListener(`blur`,t),document.removeEventListener(`focusin`,n,{capture:!0})}},[e,l]),(0,M.useEffect)(()=>{n&&l({kind:`dialogOpen`})},[n,l]),(0,M.useEffect)(()=>{e||l({kind:`disabled`})},[e,l]);let u=(0,M.useRef)(r);return(0,M.useEffect)(()=>{u.current!==r&&(u.current=r,l({kind:`repoChange`}))},[r,l]),(0,M.useEffect)(()=>{if(i)return i.onDisarm(()=>l({kind:`socketReconnect`}))},[i,l]),(0,M.useEffect)(()=>{l({kind:`cancel`})},[t,l]),{state:o,arm:(0,M.useCallback)(()=>l({kind:`arm`}),[l]),disarm:(0,M.useCallback)(()=>l({kind:`cancel`}),[l])}}function li(e,t){switch(e.kind){case`none`:return;case`run`:t.runAction(e.action);return;case`swapWith`:t.swapPanes(e.pane);return;case`sendLiteralLeader`:e.data&&t.sendLiteralLeader(e.data);return}}var ui=`nightcrow.shortcut.leader`;function di(){let[e,t]=(0,M.useState)(fi),n=(0,M.useCallback)(e=>{t(e),mi(e===null?null:me(e))},[]),r=(0,M.useCallback)(e=>{let t=E(e);return t?(n(t),!0):!1},[n]),i=(0,M.useCallback)(()=>n(null),[n]),a=(0,M.useCallback)(()=>n(ie),[n]);return{leader:e,leaderText:e?me(e):``,conflict:e?ye(e):null,setLeader:r,disable:i,reset:a}}function fi(){let e=pi();return e?e.leader===null?null:E(e.leader)??ie:ie}function pi(){try{let e=localStorage.getItem(ui);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.leader;return n===null?{leader:null}:typeof n==`string`?{leader:n}:null}catch{return null}}function mi(e){try{localStorage.setItem(ui,JSON.stringify({leader:e}))}catch{}}function hi({enabled:e,repo:t,repos:n,selectRepo:r,closeRepo:i,openPicker:a,pickerOpen:o,cycleAccent:s,reloadConfig:c,tab:l,chooseTab:u,maximized:d,setMaximized:f,mobileView:p}){let m=we(),h=di(),[g,_]=(0,M.useState)(!1),v=(0,M.useCallback)(()=>_(!0),[]),y=(0,M.useCallback)(()=>_(!1),[]),b=(0,M.useCallback)(e=>{let i=Ur(n.map(e=>e.id),t,e);i!==null&&r(i)},[n,t,r]),x=m?.zoomActivePane,S=(0,M.useCallback)(()=>{Mt()?(f(e=>e===`terminal`?`none`:`terminal`),x?.()):f(e=>e===`files`?`none`:`files`)},[f,x]),C=(0,M.useCallback)(e=>{let t=m?.paneCursor()??null,n=Nt(),r=null;n===`terminal`?t&&t.index>=0&&(r={kind:`pane`,index:t.index}):n!==null&&(r={kind:n});let i=Br({at:r,paneCount:t?.count??0,maximized:d,narrow:window.innerWidth<768,mobileView:p},e);i!==null&&(i.kind===`pane`?m?.focusPaneAt(i.index):Pt(i.kind))},[m,d,p]),w=(0,M.useMemo)(()=>{let e={"project.openDialog":a,"session.cycleAccent":s,"session.reloadConfig":c,"help.shortcuts":v};return n.length>1&&(e[`project.previous`]=()=>b(-1),e[`project.next`]=()=>b(1)),t===null||(e[`project.close`]=()=>i(t),e[`view.toggleLog`]=()=>u(l===`log`?`status`:`log`),e[`view.toggleTree`]=()=>u(l===`tree`?`status`:`tree`),e[`view.toggleMaximize`]=S,e[`focus.list`]=()=>void Pt(`list`),e[`focus.content`]=()=>void Pt(`content`),e[`focus.previous`]=()=>C(-1),e[`focus.next`]=()=>C(1)),e},[a,s,c,v,n.length,b,t,l,i,u,S,C]);Te(w);let T=ci({enabled:e,leader:h.leader,dialogOpen:o||g,repo:t}),{arm:E,disarm:ee}=T,te=(0,M.useCallback)(e=>{e.kind===`arm`?E():(ee(),m?.runAction(e.action))},[E,ee,m]);return{shortcutHelp:{open:g,show:v,hide:y},settings:h,hint:{state:T.state,onClick:te}}}var gi=1e3,_i=3,vi=2e3;function yi(e,t){let[n,r]=(0,M.useState)(!1),i=(0,M.useRef)(!1),a=(0,M.useRef)(!1);(0,M.useEffect)(()=>(a.current=!1,()=>{a.current=!0}),[]);let o=(0,M.useCallback)(async t=>{for(;!a.current;){if(await new Promise(e=>setTimeout(e,gi)),a.current)return;let n;try{n=await j.cloneStatus(t)}catch(e){if(Me(e)){i.current=!1,a.current||r(!1);return}if(e instanceof De&&e.status===404){if(a.current)return;D.error(`the clone's progress is no longer available`),i.current=!1,r(!1);return}continue}if(a.current)return;if(n.state===`done`){try{let t=await j.open(n.path);if(a.current)return;e(t)}catch(e){if(a.current)return;D.error(e instanceof Error?e.message:`could not open`)}finally{i.current=!1,a.current||r(!1)}return}if(n.state===`failed`){D.error(n.message),i.current=!1,r(!1);return}}},[e]),s=(0,M.useCallback)(async(e=()=>!1)=>{for(let t=0;t<_i;t++){if(t>0&&await new Promise(e=>setTimeout(e,vi)),i.current||e()||a.current)return;let n;try{({job:n}=await j.runningClone())}catch(e){if(Me(e))return;continue}if(n===null||e()||a.current||i.current)return;i.current=!0,r(!0),o(n);return}},[o]);return(0,M.useEffect)(()=>{if(!t)return;let e=!1;return s(()=>e),()=>{e=!0}},[t,s]),{busy:n,start:(0,M.useCallback)(async(e,t)=>{if(t.trim()&&!i.current){i.current=!0,r(!0);try{let{job:n}=await j.clone(e,t.trim());await o(n)}catch(e){if(i.current=!1,a.current)return;let t=e instanceof De&&e.status>=400;D.error(t?e.message:`could not confirm the clone started — check this folder before retrying`),r(!1),s()}}},[o,s])}}function bi(e,t,n,r=!1){return r&&n&&t.includes(n)?n:e&&t.includes(e)?e:n&&t.includes(n)?n:t[0]??null}function xi(e){let t=!1,n=null,r=()=>{if(t||n===null)return;let i=n;n=null,t=!0,e(i).catch(()=>{}).finally(()=>{t=!1,r()})};return e=>{n=e,r()}}function Si(e,t){return e?.enabled===t.enabled&&e.window_secs===t.window_secs?e:t}function Ci(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.display_path===r.display_path})?e:t}var wi=`The viewer was updated on the server.`,Ti=null,Ei=null,Di=null;function Oi(e,t){return e===null||t===null?!1:e!==t}function ki(e){Ti=e}function Ai(e){Oi(Ti,e)?Ei!==e&&(Ei=e,Di=D.info(wi,{sticky:!0,action:{label:`Reload`,run:()=>window.location.reload()}})):e===Ti&&Ei!==null&&(Di!==null&&ge(Di),Ei=null,Di=null)}var ji=3e3;function Mi({authed:e,setAuthed:t,handle:n,adoptAccent:r,adoptUpperPct:i,adoptMaximized:a,adoptViews:o,upperDraggingRef:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:f,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}){let[_,v]=(0,M.useState)([]),[y,b]=(0,M.useState)(null),[x,S]=(0,M.useState)(null),[C,w]=(0,M.useState)(null),[T,E]=(0,M.useState)(!1),[ee,te]=(0,M.useState)(!0),{current:ne}=(0,M.useRef)(xi(j.setActiveRepo)),re=(0,M.useRef)(null),ie=(0,M.useRef)(null);return(0,M.useEffect)(()=>{if(e===!1)return;let f=!1,_,y=new AbortController,x=()=>{let e=c.current,C=l.current,T=u.current,ee=d.current,ne=p.current;return j.repos(y.signal).then(n=>{let{repos:y,hot:ae,accent:oe,upper_pct:se,active_repo:D,maximized:ce,last_view:le,now_ms:ue,can_clone:de,viewer_build:fe}=n;if(f)return;Ai(fe),S(e=>Si(e,ae)),te(de),w(e=>nn(e,ue,Date.now())),c.current===e&&r(oe),l.current===C&&!s.current&&i(se),u.current===T&&a(ce),d.current===ee&&o(le??{},y.map(e=>e.id)),t(!0),E(!0);let pe=h.current||g.current!==null;p.current===ne&&!m.current&&!pe?v(e=>Ci(e,y)):v(e=>{let t=be(y.map(e=>e.id),e.map(e=>e.id)),n=new Map(y.map(e=>[e.id,e]));return Ci(e,t.map(e=>n.get(e)).filter(Boolean))});let me=y.map(e=>e.id),he=D!==re.current;re.current=D??null,he&&D&&me.includes(D)&&(ie.current=D),b(e=>bi(e,me,D,he)),f||(_=setTimeout(x,ji))}).catch(e=>{f||(Me(e)?(t(!1),E(!1)):(Ae(e)||n(e),_=setTimeout(x,ji)))})};return x(),()=>{f=!0,y.abort(),_&&clearTimeout(_)}},[e,t,n,r,i,f,c,l,u,d,s,a,o,p,m,h,g]),(0,M.useEffect)(()=>{y?y!==ie.current&&(ie.current=null,ne(y)):ie.current=null},[y,ne]),{repos:_,setRepos:v,repo:y,setRepo:b,hot:x,clockSkewMs:C,reposLoaded:T,canClone:ee}}var Ni=4;function Pi({ids:e,onReorder:t,draggingRef:n}){let r=(0,M.useRef)(null),i=(0,M.useRef)(null),a=(0,M.useRef)(null),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null);return{dragging:o,target:c,onStart:(t,a)=>{t.target.closest(`button[data-tab-close]`)||t.button!==0||e.length<2||(r.current=a,i.current={x:t.clientX,y:t.clientY},n.current=!1)},onMove:e=>{let t=r.current,o=i.current;if(t===null||o===null)return;if(!n.current&&e.buttons===0){r.current=null,i.current=null;return}if(!n.current&&Math.hypot(e.clientX-o.x,e.clientY-o.y){let o=r.current,c=a.current;o!==null&&n.current&&c!==null&&t(te(e,o,c)),r.current=null,i.current=null,a.current=null,n.current=!1,s(null),l(null)}}}function Fi({repos:e,setRepos:t,handle:n,writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}){let s=(0,M.useCallback)(()=>{if(a.current||o.current===null)return;let e=o.current;o.current=null,a.current=!0;let i=r.current;j.reorderRepos(e).then(e=>{r.current===i&&t(e)}).catch(n).finally(()=>{a.current=!1,s()})},[n,t,a,o,r]),c=(0,M.useCallback)(e=>{r.current+=1,t(t=>{let n=be(t.map(e=>e.id),e),r=new Map(t.map(e=>[e.id,e]));return n.map(e=>r.get(e)).filter(Boolean)}),o.current=e,s()},[s,t,o,r]);return{...Pi({ids:e.map(e=>e.id),onReorder:c,draggingRef:i}),writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}}function Ii({authed:e,setAuthed:t,handle:n,resumeTick:r,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,upperDraggingRef:f}){let p=(0,M.useRef)(0),m=(0,M.useRef)(!1),h=(0,M.useRef)(!1),g=(0,M.useRef)(null),_=Mi({authed:e,setAuthed:t,handle:n,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,upperDraggingRef:f,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:r,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}),{dragging:v,target:y,onStart:b,onMove:x,onEnd:S}=Fi({repos:_.repos,setRepos:_.setRepos,handle:n,writesRef:p,draggingRef:m,inFlightRef:h,pendingRef:g});return{..._,orderWrites:p,draggingRepo:v,dragOverRepo:y,onRepoDragStart:b,onRepoDragMove:x,onRepoDragEnd:S}}function Li(){let[e,t]=(0,M.useState)(!1),n=(0,M.useRef)(!1);return{reload:(0,M.useCallback)(async()=>{if(!n.current){n.current=!0,t(!0);try{D.success(await j.reloadConfig())}catch(e){D.error(e instanceof Error?e.message:`could not reload the config`)}finally{n.current=!1,t(!1)}}},[]),pending:e}}function Ri(e,t){let n=e.indexOf(t);return n===-1?e[0]??null:e[n+1]??e[n-1]??null}function zi({repo:e,repos:t,setRepos:n,setRepo:r,setPane:i,setTab:a,setPickerOpen:o,handle:s,orderWrites:c}){let l=(0,M.useRef)(t);l.current=t;let u=(0,M.useRef)(e);return u.current=e,{selectOpenedRepo:(0,M.useCallback)(e=>{c.current+=1,n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),r(e.id),e.id!==u.current&&(i({kind:`empty`}),a(`status`)),o(!1)},[n,r,i,a,o,c]),closeRepo:(0,M.useCallback)(async e=>{try{await j.close(e),c.current+=1;let t=Ri(l.current.map(e=>e.id),e);n(t=>t.filter(t=>t.id!==e)),r(n=>n===e?t:n)}catch(e){s(e)}},[n,r,s,c])}}function Bi(e,t,n){return t!==e&&(n.bumpPaneRequest(),e===`log`&&n.leaveLog(),n.recordTab(t),n.forgetPane(),!0)}function Vi(e,t,n,r,i){(0,M.useLayoutEffect)(()=>{t&&(e.some(e=>e.oid===t.commit.oid)||(r(),n(null),i()))},[e,t,n,r,i])}var Hi=5e3,Ui={refs:{},ahead:[],behind:[],truncated:!1};function Wi({repo:e,authed:t,tab:n,head:r,branch:i,refs:a,upstream:o}){let[s,c]=(0,M.useState)({key:``,value:Ui}),[l,u]=(0,M.useState)(0),d=e&&r!==void 0?`${e}|${r??``}|${i??``}|${a??``}|${o??``}`:``,f=(0,M.useRef)(s.key);f.current=s.key,(0,M.useEffect)(()=>{if(!e||!t||n!==`log`||d===``||f.current===d)return;let r=new AbortController,i;return j.logDecorations(e,r.signal).then(e=>c({key:d,value:e})).catch(()=>{r.signal.aborted||(i=setTimeout(()=>u(e=>e+1),Hi))}),()=>{r.abort(),i&&clearTimeout(i)}},[e,t,n,d,l]);let p=s.key.startsWith(`${e}|`)?s.value:Ui;return(0,M.useMemo)(()=>{let e=new Set(p.ahead),t=new Set(p.behind);return{refsOf:e=>p.refs[e],divergenceOf:n=>e.has(n)?`ahead`:t.has(n)?`behind`:void 0,truncated:p.truncated}},[p])}function Gi(e,t,n){let r=!e.truncated||e.head===void 0,i=t[0]?.oid,a=i===void 0?-1:e.commits.findIndex(e=>e.oid===i),o=a<0?[]:e.commits.slice(a);return a>=0&&o.length<=t.length&&o.every((e,n)=>e.oid===t[n].oid)?{commits:a===0?t:[...e.commits.slice(0,a),...t],anchor:e.head??null,done:n||r,mode:`prepend`}:{commits:e.commits,anchor:e.head??null,done:r,mode:`replace`}}function Ki({repo:e,authed:t,tab:n,filter:r,head:i,handle:a}){let o=(0,M.useRef)([]),[,s]=(0,M.useState)(0),c=(0,M.useCallback)(()=>s(e=>e+1),[]),l=o.current,[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(null),h=(0,M.useRef)(!1),g=(0,M.useRef)(!1),_=(0,M.useRef)(0),v=(0,M.useRef)(void 0),y=(0,M.useRef)(void 0),b=(0,M.useCallback)(()=>{_.current+=1,h.current=!1,g.current=!1,o.current=[],c(),m.current=null,d(!1),p(!1),v.current=void 0,y.current=void 0},[c]),[x,S]=(0,M.useState)(null),C=(0,M.useRef)(u);C.current=u;let w=(0,M.useRef)(i);w.current=i;let T=(0,M.useCallback)(async t=>{if(!e)return;y.current=w.current,_.current+=1;let n=_.current;h.current=!0,g.current=!0;try{let r=await j.log(e);if(n!==_.current)return;let i=t??{commits:o.current,done:C.current},a=Gi(r,i.commits,i.done);o.current=a.commits,c(),m.current=a.anchor,v.current=a.anchor,a.anchor===w.current&&(y.current=void 0),d(a.done),p(!1)}catch(e){n===_.current&&(y.current=void 0,a(e),p(!0))}finally{n===_.current&&(h.current=!1,g.current=!1)}},[e,a,c]),E=(0,M.useCallback)(async()=>{if(!e||h.current)return;h.current=!0;let t=_.current;try{let n=m.current,r=await j.log(e,n===null?void 0:{from:n,skip:o.current.length});if(t!==_.current)return;if(o.current.push(...r.commits),c(),m.current=r.head??null,d(!r.truncated||r.head===void 0),n===null){v.current=r.head??null;let e=w.current;e!==void 0&&e!==(r.head??null)&&T({commits:r.commits,done:!r.truncated||r.head===void 0})}}catch(e){t===_.current&&(a(e),p(!0))}finally{t===_.current&&(h.current=!1)}},[e,a,T,c]);(0,M.useEffect)(()=>{e&&t&&n===`log`&&l.length===0&&!u&&!f&&E()},[e,t,n,l.length,u,f,E]),(0,M.useEffect)(()=>{if(!e||!t||n!==`log`||i===void 0||f)return;let r=v.current;r!==void 0&&(r===i?g.current||(y.current=void 0):y.current!==i&&T())},[e,t,n,i,f,T]);let ee=r.toLowerCase(),te=ee===``?l:l.filter(e=>e.summary.toLowerCase().includes(ee)),ne=r!==``,re=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let e=re.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&E()},{root:e.closest(`ul`),rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[E,u,f,ne,x,n,te.length]),{commits:l,logDone:u,logStalled:f,setLogStalled:p,commitDrillDown:x,setCommitDrillDown:S,resetLog:b,logSentinelRef:re,visibleCommits:te,logPagingPaused:ne}}function qi(e,t){return[t??``,e.index,e.worktree,e.mtime??``,e.old_path??``].join(`\0`)}function Ji({repo:e,authed:t,resumeTick:n,tab:r,pane:i,setPane:a,handle:o,paneRequestRef:s}){let[c,l]=(0,M.useState)(null),u=(0,M.useRef)(i);u.current=i;let d=(0,M.useRef)(r);d.current=r;let f=(0,M.useRef)(null),p=(0,M.useRef)(null);return(0,M.useLayoutEffect)(()=>{l(null),p.current=null},[e,t]),(0,M.useEffect)(()=>{if(e&&t)return ke(e,l,({reason:e})=>l({files:[],truncated:!1,unavailable:e}))},[e,t,n]),(0,M.useEffect)(()=>{if(!e||!c)return;let t=p.current;p.current=new Map(c.files.map(e=>[e.path,qi(e,c.head)]));let n=u.current;if(d.current!==`status`||n.kind!==`diff`){f.current=null;return}let r=n.value.path,i=c.files.find(e=>e.path===r);if(!i){f.current=null,a({kind:`empty`});return}let l=qi(i,c.head),m=f.current;if(m?.path===r&&m.key===l)return;if(m?.path!==r&&t?.get(r)===l){f.current={path:r,key:l};return}let h=s.current,g=!0,_=()=>{let e=u.current;return g&&h===s.current&&e.kind===`diff`&&e.value.path===r};return j.diff(e,r).then(e=>{_()&&(f.current={path:r,key:l},a({kind:`diff`,value:e,source:Fn(i)&&In(e)?{kind:`workdir`,path:r}:void 0}))}).catch(e=>{_()&&o(e)}),()=>{g=!1}},[c,e,o,u,d,s,a]),{status:c,paneRef:u,tabRef:d}}function Yi({repo:e,authed:t,hot:n,clockSkewMs:r,resumeTick:i,handle:a}){let[o,s]=(0,M.useState)(`status`),[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)({kind:`empty`}),[m,h]=(0,M.useState)(e);m!==e&&(h(e),p({kind:`empty`}),s(`status`));let g=(0,M.useRef)(0),_=(0,M.useCallback)(()=>{g.current+=1},[]),v=(0,M.useCallback)(()=>p({kind:`empty`}),[]),{status:y}=Ji({repo:e,authed:t,resumeTick:i,tab:o,pane:f,setPane:p,handle:a,paneRequestRef:g}),b=n?.enabled?n.window_secs*1e3:0,x=Ki({repo:e,authed:t,tab:o,filter:c,head:y?y.head??null:void 0,handle:a}),S=Wi({repo:e,authed:t,tab:o,head:y?y.head??null:void 0,branch:y?.branch,refs:y?.refs,upstream:y?.tracking?.upstream}),C=x.setCommitDrillDown,w=x.resetLog;(0,M.useLayoutEffect)(()=>{_(),C(null),w()},[e,_,C,w]);let T=c.toLowerCase(),E=(0,M.useMemo)(()=>(y?.files??[]).filter(e=>e.path.toLowerCase().includes(T)),[y?.files,T]),ee=(0,M.useMemo)(()=>(x.commitDrillDown?.files??[]).filter(e=>e.path.toLowerCase().includes(T)||e.old_path?.toLowerCase().includes(T)),[x.commitDrillDown?.files,T]);return{screen:{tab:o,setTab:s,filter:c,setFilter:l,filterOpen:u,setFilterOpen:d,pane:f,setPane:p},request:{paneRequestRef:g,bumpPaneRequest:_,clearPane:v},status:{value:y,files:E,hotWindowMs:b,clockSkewMs:r??0},log:{...x,decorations:S,visibleCommitFiles:ee}}}var Xi=`nightcrow.mobileView`;function Zi(e){return e===`diff`||e===`terminal`||e===`files`?e:`files`}function Qi(){return Zi(m(Xi))}function $i(){let[e,t]=(0,M.useState)(Qi);return{mobileView:e,setMobileView:(0,M.useCallback)(e=>{h(Xi,e),t(e)},[])}}function ea({repo:e,handle:t,setPane:n,paneRequestRef:r,setCommitDrillDown:i,setMobileView:a,setPreviewRendered:o,statusRef:s,track:c}){let l=(0,M.useCallback)(e=>{let t=s.current?.files.find(t=>t.path===e);return t?Fn(t):!1},[s]);return{openDiff:(0,M.useCallback)((i,o)=>{if(!e)return;o?.restoring||a(`diff`);let s=r.current+=1;c(s,j.diff(e,i)).then(e=>{s===r.current&&n({kind:`diff`,value:e,source:l(i)&&In(e)?{kind:`workdir`,path:i}:void 0})}).catch(e=>{if(s!==r.current)return Me(e)?t(e):void 0;if(!o?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,l,c]),openFile:(0,M.useCallback)((i,s)=>{if(!e)return;s?.restoring||a(`diff`),o(!0);let l=r.current+=1;c(l,j.file(e,i)).then(e=>{l===r.current&&n({kind:`file`,value:e})}).catch(e=>{if(l!==r.current)return Me(e)?t(e):void 0;if(!s?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,o,c]),openCommit:(0,M.useCallback)(i=>{if(!e)return;a(`diff`);let o=r.current+=1;c(o,j.commit(e,i)).then(e=>{o===r.current&&n({kind:`diff`,value:e})}).catch(e=>{o===r.current&&t(e)})},[e,t,n,r,a,c]),openCommitFileDiff:(0,M.useCallback)((i,o,s)=>{if(!e)return;s?.restoring||a(`diff`);let l=r.current+=1;c(l,j.commitFileDiff(e,i,o)).then(e=>{l===r.current&&n({kind:`diff`,value:e,source:In(e)?{kind:`commit`,oid:i,path:o}:void 0})}).catch(e=>{if(l!==r.current)return Me(e)?t(e):void 0;if(!s?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,c]),openCommitFiles:(0,M.useCallback)(async o=>{if(!e)return;a(`diff`);let s=r.current+=1;try{let t=await c(s,j.commitFiles(e,o.oid));if(s!==r.current)return;if(i({commit:o,...t}),t.files.length===0){n({kind:`empty`});return}let a=await c(s,j.commit(e,o.oid));s===r.current&&n({kind:`diff`,value:a})}catch(e){s===r.current&&t(e)}},[e,t,n,r,i,a,c]),showOtherFace:(0,M.useCallback)((i,a=0)=>{let s=Pn(i);if(!e||!s)return;let{source:u}=s,d=s.want===`file`,f=d&&i.kind===`diff`?An(i.value,a):null,p=r.current+=1,m=u.kind===`workdir`?d?j.file(e,u.path):j.diff(e,u.path):d?j.commitFile(e,u.oid,u.path):j.commitFileDiff(e,u.oid,u.path);d&&o(!1),c(p,m).then(e=>{p===r.current&&n(d?{kind:`file`,value:e,source:u,anchor:f===null?void 0:jn(f)+1}:{kind:`diff`,value:e,source:In(e)&&(u.kind!==`workdir`||l(u.path))?u:void 0})}).catch(e=>{p===r.current&&t(e)})},[e,t,n,r,o,l,c])}}function ta(){let[e,t]=(0,M.useState)(null),n=(0,M.useCallback)((e,n)=>{t(e);let r=()=>t(t=>t===e?null:t);return n.then(r,r),n},[]);return{loading:e!==null,track:n}}function na({repo:e,handle:t,pane:n,setPane:r,paneRequestRef:i,setCommitDrillDown:a,status:o}){let{mobileView:s,setMobileView:c}=$i(),[l,u]=(0,M.useState)(!0),{loading:d,track:f}=ta(),p=(0,M.useRef)(o);p.current=o;let{openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}=ea({repo:e,handle:t,setPane:r,paneRequestRef:i,setCommitDrillDown:a,setMobileView:c,setPreviewRendered:u,statusRef:p,track:f}),b=(0,M.useMemo)(()=>({openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}),[m,h,g,_,v,y]);return(0,M.useMemo)(()=>({openers:b,pane:n,setPane:r,paneLoading:d,previewRendered:l,setPreviewRendered:u,mobileView:s,setMobileView:c}),[b,n,r,d,l,s,c])}var ra=[`status`,`log`,`tree`];function ia(){return{tab:`status`,file:null,tree_expanded:[]}}function aa(e,t){return{path:e,commit:null,face:t}}function oa(e,t,n){return{path:t,commit:e,face:n}}function sa(e){return[...e].sort().slice(0,200)}function I(e){let t=e?.file;return!t||!t.path?{kind:`none`}:t.commit?{kind:`commitDiff`,oid:t.commit,path:t.path}:t.face===`source`?{kind:`file`,path:t.path}:{kind:`diff`,path:t.path}}function L(e){let t=e?.tab;return t&&ra.includes(t)?t:`status`}function ca(e,t){return e?e.tab===t.tab&&e.tree_expanded.length===t.tree_expanded.length&&e.tree_expanded.every((e,n)=>e===t.tree_expanded[n])&&la(e.file,t.file):!1}function la(e,t){return!e||!t?e===t:e.path===t.path&&e.commit===t.commit&&e.face===t.face}function ua({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:o,openFile:s,openCommitFileDiff:c}){let l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(new Map),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(!1);(0,M.useEffect)(()=>{if(u.current!==e&&(u.current=e,l.current=null,m.current=!1,p(!1)),!e||!t||l.current===e)return;l.current=e;let r=d.current.get(e);d.current.delete(e);let f=r?{...n??ia(),...r}:n;if(r&&i(e,f),m.current)return;a(L(f));let h=I(f);if(h.kind===`none`)return;let g={restoring:!0};h.kind===`diff`?o(h.path,g):h.kind===`file`?s(h.path,g):c(h.oid,h.path,g)},[e,t,n,i,a,o,s,c]);let h=(0,M.useCallback)(t=>{if(e){if(m.current=!0,p(!0),l.current!==e){let n=d.current.get(e);d.current.set(e,{...n,...t})}else i(e,{...r(e)??ia(),...t})}},[e,r,i]);return{touched:f,noteTab:(0,M.useCallback)(e=>h({tab:e}),[h]),noteFile:(0,M.useCallback)(e=>h({file:e}),[h]),noteTree:(0,M.useCallback)(e=>h({tree_expanded:sa(e)}),[h])}}function da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,clearPane:o,openers:s}){let c=ua({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:s.openDiff,openFile:s.openFile,openCommitFileDiff:s.openCommitFileDiff}),{noteFile:l,noteTab:u,noteTree:d}=c,f=(0,M.useCallback)(e=>{u(e),a(e)},[u,a]),p=(0,M.useCallback)(()=>{l(null),o()},[l,o]),m=(0,M.useMemo)(()=>({openDiff:e=>{l(aa(e,`diff`)),s.openDiff(e)},openFile:e=>{l(aa(e,`source`)),s.openFile(e)},openCommit:e=>{l(null),s.openCommit(e)},openCommitFiles:e=>(l(null),s.openCommitFiles(e)),openCommitFileDiff:(e,t)=>{l(oa(e,t,`diff`)),s.openCommitFileDiff(e,t)}}),[s,l]),h=(0,M.useCallback)((e,t)=>{l(e.kind===`commit`?oa(e.oid,e.path,t):aa(e.path,t))},[l]);return{...c,noteTree:d,chooseTab:f,forgetPane:p,asked:m,noteOtherFace:h}}function fa({project:e,view:t,layout:n}){let{repo:r,repos:i,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}=e,u=Yi({repo:r,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}),d=na({repo:r,handle:l,pane:u.screen.pane,setPane:u.screen.setPane,paneRequestRef:u.request.paneRequestRef,setCommitDrillDown:u.log.setCommitDrillDown,status:u.status.value}),f=da({repo:r,known:t.known,remembered:t.remembered,latest:t.latest,remember:t.remember,setTab:u.screen.setTab,clearPane:u.request.clearPane,openers:d.openers}),p=u.screen.tab,{bumpPaneRequest:m}=u.request,{setCommitDrillDown:h,resetLog:g}=u.log,{chooseTab:_,forgetPane:v}=f,y=(0,M.useCallback)(e=>void Bi(p,e,{bumpPaneRequest:m,leaveLog:()=>{h(null),g()},recordTab:_,forgetPane:v}),[p,m,h,g,_,v]);Vi(u.log.commits,u.log.commitDrillDown,u.log.setCommitDrillDown,u.request.bumpPaneRequest,f.forgetPane);let b=n.maximizedPanelOf(r),x=n.setMaximizedFor,S=(0,M.useCallback)(e=>x(r,e),[r,x]),C=d.pane,w=d.openers.showOtherFace,T=f.noteOtherFace,E=(0,M.useCallback)(e=>{let t=Pn(C);t&&T(t.source,t.want===`file`?`source`:`diff`),w(C,e)},[C,T,w]);return{setPane:d.setPane,setTab:u.screen.setTab,clearPane:u.request.clearPane,maximized:b,tab:p,chooseTab:y,setMaximized:S,repoShell:r?{repository:{id:r,current:i.find(e=>e.id===r),status:u.status.value},sidebar:{tab:u.screen.tab,filter:u.screen.filter,setFilter:u.screen.setFilter,filterOpen:u.screen.filterOpen,setFilterOpen:u.screen.setFilterOpen,files:u.status.files,hotWindowMs:u.status.hotWindowMs,clockSkewMs:u.status.clockSkewMs,...d.openers,...f.asked,chooseTab:y,authed:a,handle:l,bumpPaneRequest:u.request.bumpPaneRequest,...u.log,restoreTree:t.remembered?.tree_expanded??[],restoreKnown:t.known,onTreeExpanded:f.noteTree,clearPane:f.forgetPane,touched:f.touched},filePane:{repo:r,pane:d.pane,loading:d.paneLoading,previewRendered:d.previewRendered,setPreviewRendered:d.setPreviewRendered,showOtherFace:E},layout:{...n.shell,maximized:b,setMaximized:S,mobileView:d.mobileView,setMobileView:d.setMobileView}}:null}}function pa(){let[e,t]=(0,M.useState)(0);return(0,M.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&t(e=>e+1)};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,e)}},[]),e}var ma=[{name:`yellow`,color:`#d9a441`},{name:`cyan`,color:`#03c4db`},{name:`green`,color:`#77c47a`},{name:`magenta`,color:`#dc8fd5`},{name:`blue`,color:`#87acfd`}],ha=`nightcrow.viewer.accent`;function ga(e){if(!Number.isFinite(e))return 0;let t=ma.length;return(Math.trunc(e)%t+t)%t}function _a(){let e=m(ha);return e===null?0:ga(Number(e))}function va(e){h(ha,String(e))}function ya(){let[e,t]=(0,M.useState)(_a);(0,M.useLayoutEffect)(()=>{document.documentElement.style.setProperty(`--color-accent`,ma[e].color)},[e]);let n=(0,M.useCallback)(()=>{t(e=>{let t=ga(e+1);return va(t),j.setAccent(t).catch(()=>{}),t})},[]),r=(0,M.useCallback)(e=>{t(t=>{let n=ga(e);return n===t?t:(va(n),n)})},[]);return{accent:ma[e],next:ma[ga(e+1)],cycle:n,adopt:r}}function ba(e){return Number.isFinite(e)?Math.min(Math.max(e,20),85):55}function xa(e){return Math.round(ba(e))}function Sa(e,t,n,r){let i=n-t;return ba(i<=0?r:(e-t)/i*100)}var Ca=`nightcrow.upperPct`;function wa(){try{let e=Number(localStorage.getItem(Ca));return Number.isFinite(e)&&e>0?xa(e):55}catch{return 55}}function Ta(e){try{localStorage.setItem(Ca,String(e))}catch{}}function Ea(){let[e,t]=(0,M.useState)(wa);return{pct:e,resize:(0,M.useCallback)(e=>{t(ba(e))},[]),commit:(0,M.useCallback)(e=>{let n=xa(e);t(n),Ta(n),j.setUpperPct(n).catch(()=>{})},[]),reset:(0,M.useCallback)(()=>{t(55),Ta(55),j.setUpperPct(55).catch(()=>{})},[]),adopt:(0,M.useCallback)(e=>{t(t=>{let n=xa(e);return n===t?t:(Ta(n),n)})},[])}}function Da(){let[e,t]=(0,M.useState)({}),n=(0,M.useRef)(e),r=(0,M.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,M.useRef)(0),a=(0,M.useRef)(new Map),o=(0,M.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=xi(t=>j.setMaximized(e,t===`none`?null:t));return a.current.set(e,n),n},[]),s=(0,M.useCallback)((e,t)=>{if(e==null)return;let a=n.current,s=typeof t==`function`?t(a[e]??`none`):t;i.current+=1,o(e)(s);let{[e]:c,...l}=a;r(s===`none`?l:{...a,[e]:s})},[o,r]);return{panelOf:(0,M.useCallback)(t=>t!=null&&e[t]||`none`,[e]),setFor:s,adopt:(0,M.useCallback)(e=>{Oa(n.current,e)||r(e)},[r]),writes:i}}function Oa(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function ka(){let[e,t]=(0,M.useState)({}),n=(0,M.useRef)(e),r=(0,M.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,M.useRef)(0),a=(0,M.useRef)(new Map),o=(0,M.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=xi(t=>j.setRepoView(e,t));return a.current.set(e,n),n},[]),s=(0,M.useCallback)((e,t)=>{e!=null&&(ca(n.current[e],t)||(i.current+=1,o(e)(t),r({...n.current,[e]:t})))},[o,r]),c=(0,M.useCallback)(t=>t==null?void 0:e[t],[e]),l=(0,M.useCallback)(e=>n.current[e],[]),u=(0,M.useRef)(new Set),[d,f]=(0,M.useState)(0);return{viewOf:c,rememberedFor:l,remember:s,adopt:(0,M.useCallback)((e,t)=>{let i=u.current;(i.size!==t.length||t.some(e=>!i.has(e)))&&(u.current=new Set(t),f(e=>e+1)),!Aa(n.current,e)&&r(e)},[r]),covers:(0,M.useCallback)(e=>e!=null&&u.current.has(e),[d]),writes:i}}function Aa(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>t[n]!==void 0&&ca(e[n],t[n]))}function ja(){let{accent:e,next:t,cycle:n,adopt:r}=ya(),{width:i,resize:a,commit:o,reset:s}=Tt(),{pct:c,resize:l,commit:u,reset:d,adopt:f}=Ea(),p=Da(),m=ka(),h=(0,M.useRef)(0),g=(0,M.useRef)(0);return{accent:e,next:t,cycle:(0,M.useCallback)(()=>{h.current+=1,n()},[n]),adoptAccent:r,accentWrites:h,sidebarWidth:i,resizeSidebar:a,commitSidebarWidth:o,resetSidebarWidth:s,upperPct:c,resizeUpperPct:l,commitUpperPct:(0,M.useCallback)(e=>{g.current+=1,u(e)},[u]),resetUpperPct:(0,M.useCallback)(()=>{g.current+=1,d()},[d]),bumpUpperPctWrites:(0,M.useCallback)(()=>{g.current+=1},[]),adoptUpperPct:f,upperPctWrites:g,maximizedPanelOf:p.panelOf,setMaximizedFor:p.setFor,adoptMaximized:p.adopt,maximizedWrites:p.writes,viewOf:m.viewOf,rememberedViewFor:m.rememberedFor,rememberView:m.remember,adoptViews:m.adopt,viewCovers:m.covers,viewWrites:m.writes}}var Ma=400;function Na({value:e,valueAt:t,onGestureStart:n,resize:r,commit:i,reset:a,axis:o}){let s=(0,M.useRef)(0),c=(0,M.useRef)(0),l=(0,M.useRef)(!1),u=(0,M.useRef)(!1),d=(0,M.useRef)(0),[f,p]=(0,M.useState)(!1);return{dragging:f,onDragStart:(0,M.useCallback)(t=>{t.button===0&&t.isPrimary&&n()&&(s.current=o===`x`?t.clientX:t.clientY,c.current=e,l.current=!0,u.current=!1,p(!0),t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())},[e,n,o]),onDragMove:(0,M.useCallback)(e=>{if(!l.current)return;let n=o===`x`?e.clientX:e.clientY;if(!u.current&&Math.abs(n-s.current)<3)return;let i=t(e);i!==null&&(u.current=!0,c.current=i,r(i))},[t,r,o]),onDragEnd:(0,M.useCallback)(()=>{if(!l.current)return;if(l.current=!1,p(!1),u.current){i(c.current),d.current=0;return}let e=Date.now();e-d.current{l.current=!1,u.current=!1,d.current=0,p(!1)},[]),draggingRef:l}}function Pa({sidebarRef:e,sidebarWidth:t,resizeSidebar:n,commitSidebarWidth:r,resetSidebarWidth:i}){let a=(0,M.useRef)(0),o=(0,M.useCallback)(()=>{let t=e.current?.getBoundingClientRect().left;return t!==void 0&&(a.current=t,!0)},[e]),{dragging:s,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:d}=Na({value:t,valueAt:(0,M.useCallback)(e=>e.clientX-a.current,[]),onGestureStart:o,resize:n,commit:r,reset:i,axis:`x`});return{draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d}}function Fa({upperRef:e,lowerRef:t,upperPct:n,resizeUpperPct:r,commitUpperPct:i,resetUpperPct:a,bumpUpperPctWrites:o}){let s=(0,M.useRef)(0),c=(0,M.useRef)(0),l=(0,M.useCallback)(()=>{let n=e.current?.getBoundingClientRect().top,r=t.current?.getBoundingClientRect().bottom;return n===void 0||r===void 0?!1:(s.current=n,c.current=r,o(),!0)},[e,t,o]),{dragging:u,onDragStart:d,onDragMove:f,onDragEnd:p,onDragCancel:m,draggingRef:h}=Na({value:n,valueAt:(0,M.useCallback)(e=>Sa(e.clientY,s.current,c.current,n),[n]),onGestureStart:l,resize:r,commit:i,reset:a,axis:`y`});return{draggingUpper:u,onUpperDragStart:d,onUpperDragMove:f,onUpperDragEnd:p,onUpperDragCancel:m,upperDraggingRef:h}}function Ia(){let{accent:e,next:t,cycle:n,adoptAccent:r,accentWrites:i,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p,adoptUpperPct:m,upperPctWrites:h,maximizedPanelOf:g,setMaximizedFor:_,adoptMaximized:v,maximizedWrites:y,viewOf:b,rememberedViewFor:x,rememberView:S,adoptViews:C,viewCovers:w,viewWrites:T}=ja(),E=(0,M.useRef)(null),ee=(0,M.useRef)(null),te=(0,M.useRef)(null),ne=Pa({sidebarRef:E,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c}),re=Fa({upperRef:ee,lowerRef:te,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p});return{accent:e,next:t,cycle:n,upperPct:l,maximizedPanelOf:g,setMaximizedFor:_,viewOf:b,rememberedViewFor:x,rememberView:S,viewCovers:w,shell:{sidebarWidth:a,sidebarRef:E,upperRef:ee,lowerRef:te,draggingSidebar:ne.draggingSidebar,onSidebarDragStart:ne.onSidebarDragStart,onSidebarDragMove:ne.onSidebarDragMove,onSidebarDragEnd:ne.onSidebarDragEnd,onSidebarDragCancel:ne.onSidebarDragCancel,draggingUpper:re.draggingUpper,onUpperDragStart:re.onUpperDragStart,onUpperDragMove:re.onUpperDragMove,onUpperDragEnd:re.onUpperDragEnd,onUpperDragCancel:re.onUpperDragCancel},guards:{adoptAccent:r,adoptUpperPct:m,adoptMaximized:v,adoptViews:C,accentWrites:i,upperPctWrites:h,maximizedWrites:y,viewWrites:T,upperDraggingRef:re.upperDraggingRef}}}var La=`nightcrow.tabStripSide`;function Ra(){return dt(m(La))??`top`}function za(e){h(La,e)}function Ba(){let[e,t]=(0,M.useState)(Ra);return{side:e,toggle:(0,M.useCallback)(()=>{t(e=>{let t=ft(e);return za(t),t})},[])}}function Va(){let[e,t]=(0,M.useState)(null),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=(0,M.useCallback)(e=>{Me(e)?t(!1):D.error(e instanceof Error?e.message:`request failed`)},[]),s=pa(),c=Ia(),l=Ba(),u=Ii({authed:e,setAuthed:t,handle:o,resumeTick:s,...c.guards}),d=fa({project:{repo:u.repo,repos:u.repos,authed:e,hot:u.hot,clockSkewMs:u.clockSkewMs,resumeTick:s,handle:o},view:{known:c.viewCovers(u.repo),remembered:c.viewOf(u.repo),latest:c.rememberedViewFor,remember:c.rememberView},layout:{shell:c.shell,maximizedPanelOf:c.maximizedPanelOf,setMaximizedFor:c.setMaximizedFor}}),{selectOpenedRepo:f,closeRepo:p}=zi({repo:u.repo,repos:u.repos,setRepos:u.setRepos,setRepo:u.setRepo,setPane:d.setPane,setTab:d.setTab,setPickerOpen:r,handle:o,orderWrites:u.orderWrites}),{busy:m,start:h}=yi(f,e===!0),g=u.repo,_=u.setRepo,v=d.clearPane,y=(0,M.useCallback)(e=>{e!==g&&(_(e),v())},[g,_,v]),b=u.repos.find(e=>e.id===i),x=(0,M.useCallback)(()=>a(null),[]),S=(0,M.useCallback)(()=>r(!0),[]),C=(0,M.useCallback)(()=>r(!1),[]),w=Li(),T=hi({enabled:e===!0,repo:u.repo,repos:u.repos,selectRepo:y,closeRepo:p,openPicker:S,pickerOpen:n,cycleAccent:c.cycle,reloadConfig:w.reload,tab:d.tab,chooseTab:d.chooseTab,maximized:d.maximized,setMaximized:d.setMaximized,mobileView:d.repoShell?.layout.mobileView??`files`});return{authed:e,login:(0,M.useCallback)(()=>t(null),[]),reposLoaded:u.reposLoaded,rows:zr(u.repo,d.maximized),upperPct:c.upperPct,header:{repos:u.repos,repo:u.repo,onSelectRepo:y,onCloseRepo:a,onOpenPicker:S,cloning:m,accent:c.accent,next:c.next,cycle:c.cycle,draggingRepo:u.draggingRepo,dragOverRepo:u.dragOverRepo,onRepoDragStart:u.onRepoDragStart,onRepoDragMove:u.onRepoDragMove,onRepoDragEnd:u.onRepoDragEnd,onReloadConfig:w.reload,reloading:w.pending,tabStrip:l},tabStrip:l,shortcutHelp:T.shortcutHelp,leader:T.settings,hint:T.hint,repoShell:d.repoShell,closeConfirm:b?{label:b.name,detail:`Its terminals and the processes running in them will be terminated.`,onConfirm:()=>{a(null),p(b.id)},onCancel:x}:null,picker:n?{onClose:C,onOpened:f,canClone:u.canClone,cloning:m,onClone:h}:null}}function Ha(){let e=Va();return e.authed===null?(0,N.jsx)(_t,{}):e.authed?e.reposLoaded?(0,N.jsx)(g,{children:(0,N.jsx)(oe,{children:(0,N.jsx)(x,{leader:e.leader.leader,children:(0,N.jsxs)(`div`,{className:`nc-fade-in flex h-full flex-col`,children:[(0,N.jsx)(pt,{...e.header,onShowShortcuts:e.shortcutHelp.show}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e.tabStrip.side===`left`&&(0,N.jsx)(`aside`,{className:`hidden w-48 shrink-0 flex-col border-r border-chrome-line bg-ink-950 md:flex`,children:(0,N.jsx)(Ke,{side:`left`,...e.header})}),(0,N.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 grid-cols-[minmax(0,1fr)] ${e.rows}`,style:{"--nc-upper":`${e.upperPct}fr`,"--nc-lower":`${100-e.upperPct}fr`},children:[e.repoShell?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(vr,{...e.repoShell}),(0,N.jsx)(Lr,{...e.hint})]}):(0,N.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-center text-ink-400`,children:[(0,N.jsxs)(`span`,{className:`md:hidden`,children:[`No repository open. Tap`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`No project`}),` above, then`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),`, to add one.`]}),(0,N.jsxs)(`span`,{className:`hidden md:inline`,children:[`No repository open. Click`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),` `,e.tabStrip.side===`left`?`beside`:`above`,` to add one.`]})]}),e.picker&&(0,N.jsx)(Le,{...e.picker}),e.closeConfirm&&(0,N.jsx)(se,{...e.closeConfirm}),e.shortcutHelp.open&&(0,N.jsx)(Er,{onClose:e.shortcutHelp.hide,leader:e.leader})]})]})]})})})}):(0,N.jsx)(_t,{}):(0,N.jsx)(vt,{onSuccess:e.login})}var Ua={error:7e3,info:5e3,success:5e3},Wa={error:`text-removed`,info:`text-accent`,success:`text-added`};function Ga(){let[e,t]=(0,M.useState)([]);return(0,M.useEffect)(()=>pe(t),[]),e.length===0?null:(0,N.jsx)(`div`,{className:`pointer-events-none fixed right-3 top-3 z-[60] flex w-80 max-w-[calc(100vw-1.5rem)] flex-col gap-2`,"aria-live":`polite`,children:e.map(e=>(0,N.jsx)(Ka,{toast:e},e.id))})}function Ka({toast:e}){let[t,n]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{if(t||e.sticky)return;let n=setTimeout(()=>ge(e.id),Ua[e.kind]);return()=>clearTimeout(n)},[e.id,e.kind,e.bump,e.sticky,t]),(0,N.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:`nc-slide-in pointer-events-auto flex items-start gap-2 rounded-md border border-ink-700 bg-ink-850 px-3 py-2 text-xs shadow-lg`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 break-words ${Wa[e.kind]}`,children:e.message}),e.action&&(0,N.jsx)(`button`,{type:`button`,onClick:e.action.run,className:`shrink-0 rounded-sm border border-ink-700 px-1.5 py-0.5 text-ink-200 hover:border-accent hover:text-accent`,children:e.action.label}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),"aria-label":`dismiss`,className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-ink-200`,children:(0,N.jsx)(ae,{className:`h-3 w-3`})})]})}function qa(e){let t=new URLSearchParams(e),n=t.get(`notice-repo`);if(!n)return null;let r=t.get(`notice-pane`);return{repo:n,pane:r!==null&&/^\d+$/.test(r)?Number(r):null}}async function Ja(e,t,n){let r=qa(e.search);if(!r)return;let i=new URL(e.href);i.searchParams.delete(`notice-repo`),i.searchParams.delete(`notice-pane`),t.replaceState(t.state,``,i.pathname+i.search+i.hash),r.pane!==null&&ve(r.repo,r.pane),await n(r.repo).catch(()=>void 0)}ce(document.documentElement,window),de(i()),ki(document.querySelector(`meta[name="nightcrow-build"]`)?.getAttribute(`content`)||null),Xe(Je()),await Ja(window.location,window.history,j.setActiveRepo);var Ya=1500;await Promise.race([document.fonts?.load(`400 12px "JetBrains Mono"`).catch(()=>void 0),new Promise(e=>setTimeout(e,Ya))]),(0,Ie.createRoot)(document.getElementById(`root`)).render((0,N.jsxs)(M.StrictMode,{children:[(0,N.jsx)(er,{children:(0,N.jsx)(Se,{children:(0,N.jsx)(Ha,{})})}),(0,N.jsx)(Ga,{})]})); \ No newline at end of file diff --git a/viewer-ui/dist/index.html b/viewer-ui/dist/index.html index 57a0873f..cbfcb654 100644 --- a/viewer-ui/dist/index.html +++ b/viewer-ui/dist/index.html @@ -14,7 +14,7 @@ nightcrow - + diff --git a/viewer-ui/src/components/terminal/TermKeyBar.test.tsx b/viewer-ui/src/components/terminal/TermKeyBar.test.tsx new file mode 100644 index 00000000..51f81633 --- /dev/null +++ b/viewer-ui/src/components/terminal/TermKeyBar.test.tsx @@ -0,0 +1,33 @@ +// @vitest-environment happy-dom + +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import type { ModifierLatch } from "../../hooks/terminal/useModifierLatch"; +import { TermKeyBar } from "./TermKeyBar"; + +afterEach(cleanup); + +function latch(): ModifierLatch { + return { + armed: false, + toggle: () => false, + clear: vi.fn(), + consume: (typed) => typed, + }; +} + +describe("TermKeyBar", () => { + it("sends Shift+Left to the active pane and clears modifier latches", () => { + const onKey = vi.fn(); + const ctrl = latch(); + const alt = latch(); + render(); + + fireEvent.click(screen.getByRole("button", { name: "Shift Left arrow" })); + + expect(onKey).toHaveBeenCalledTimes(1); + expect(onKey).toHaveBeenCalledWith("shift-left"); + expect(ctrl.clear).toHaveBeenCalledTimes(1); + expect(alt.clear).toHaveBeenCalledTimes(1); + }); +}); diff --git a/viewer-ui/src/lib/terminal/termKeys.test.ts b/viewer-ui/src/lib/terminal/termKeys.test.ts index 751d68c7..4dcd7fc6 100644 --- a/viewer-ui/src/lib/terminal/termKeys.test.ts +++ b/viewer-ui/src/lib/terminal/termKeys.test.ts @@ -26,6 +26,11 @@ describe("termKeySequence", () => { expect(termKeySequence("shift-tab", true)).toBe("\x1b[Z"); }); + it("Shift+Left sends the modified-arrow sequence in either cursor mode", () => { + expect(termKeySequence("shift-left")).toBe("\x1b[1;2D"); + expect(termKeySequence("shift-left", true)).toBe("\x1b[1;2D"); + }); + it("Ctrl combinations send control bytes based on alphabetic order", () => { // Ctrl-C = 3rd letter = 0x03, and so on down the list. expect(termKeySequence("ctrl-b")).toBe("\x02"); @@ -186,6 +191,11 @@ describe("TERM_KEY_BAR", () => { expect(labels[labels.indexOf("⇧Tab") + 1]).toBe("Alt"); }); + it("includes Shift+Left beside the ordinary Left arrow", () => { + const keys = TERM_KEY_BAR.filter((item) => item.kind === "key").map((item) => item.key); + expect(keys[keys.indexOf("left") - 1]).toBe("shift-left"); + }); + it("the bar has no duplicate keys", () => { const keys = TERM_KEY_BAR.map((k) => k.label); expect(new Set(keys).size).toBe(keys.length); diff --git a/viewer-ui/src/lib/terminal/termKeys.ts b/viewer-ui/src/lib/terminal/termKeys.ts index 7bc2cb78..53a4b8fd 100644 --- a/viewer-ui/src/lib/terminal/termKeys.ts +++ b/viewer-ui/src/lib/terminal/termKeys.ts @@ -17,6 +17,7 @@ export type TermKey = | "esc" | "tab" | "shift-tab" + | "shift-left" | "ctrl-b" | "ctrl-c" | "ctrl-d" @@ -37,6 +38,7 @@ export const TERM_KEY_SEQUENCES: Record = { esc: "\x1b", tab: "\t", "shift-tab": "\x1b[Z", + "shift-left": "\x1b[1;2D", "ctrl-b": "\x02", "ctrl-c": "\x03", "ctrl-d": "\x04", @@ -210,6 +212,7 @@ export const TERM_KEY_BAR: TermBarItem[] = [ { kind: "key", key: "ctrl-z", label: "^Z", aria: "Control Z" }, { kind: "key", key: "ctrl-l", label: "^L", aria: "Control L" }, { kind: "key", key: "ctrl-r", label: "^R", aria: "Control R" }, + { kind: "key", key: "shift-left", label: "⇧←", aria: "Shift Left arrow" }, { kind: "key", key: "left", label: "←", aria: "Left arrow" }, { kind: "key", key: "down", label: "↓", aria: "Down arrow" }, { kind: "key", key: "up", label: "↑", aria: "Up arrow" }, From 80e09b692fa0c6984e49628d402f9da83ed86574 Mon Sep 17 00:00:00 2001 From: whackur Date: Sat, 7 Nov 2026 13:16:54 +0900 Subject: [PATCH 2/2] test(web): verify Shift+Left terminal delivery --- viewer-ui/visual/viewer.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/viewer-ui/visual/viewer.spec.ts b/viewer-ui/visual/viewer.spec.ts index 54a57ad3..1df93cdc 100644 --- a/viewer-ui/visual/viewer.spec.ts +++ b/viewer-ui/visual/viewer.spec.ts @@ -23,6 +23,7 @@ test.afterEach(async () => { }); async function openViewer(page: Page, options: ApiMockOptions = {}) { + const terminalMessages: string[] = []; await page.clock.setFixedTime(FIXED_TIME); await page.addInitScript(() => { const style = document.createElement("style"); @@ -38,6 +39,7 @@ async function openViewer(page: Page, options: ApiMockOptions = {}) { }); mocks = await installApiMocks(page, { status, ...options }); await page.routeWebSocket("**/ws/term**", (socket) => { + socket.onMessage((message) => terminalMessages.push(message.toString())); socket.send(JSON.stringify({ type: "hello", client: 1, panes: 1 })); socket.send(JSON.stringify({ type: "created", pane: 1, rows: 24, cols: 80, client: 1, title: "shell", @@ -49,6 +51,7 @@ async function openViewer(page: Page, options: ApiMockOptions = {}) { if ((page.viewportSize()?.width ?? 0) >= 768) await expect(page.locator("[data-terminal-panel] .xterm-screen")).toBeAttached(); await page.evaluate(() => document.fonts.ready); + return terminalMessages; } async function capture(page: Page, name: string) { @@ -148,6 +151,21 @@ test("a non-repository status is shown in the repository view", async ({ page }) await capture(page, "unavailable-repository"); }); +test("the mobile key bar sends Shift+Left to the active terminal", async ({ page }) => { + await page.setViewportSize({ width: 390, height: 844 }); + const terminalMessages = await openViewer(page); + await page.getByRole("button", { name: "Terminal" }).click(); + await expect(page.locator("[data-terminal-panel] .xterm-screen")).toBeAttached(); + + await page.getByRole("button", { name: "Shift Left arrow" }).click(); + + await expect.poll(() => + terminalMessages + .map((raw) => JSON.parse(raw) as { type: string }) + .filter((message) => message.type === "input"), + ).toContainEqual({ type: "input", pane: 1, data: "\x1b[1;2D" }); +}); + test("the mobile compose dialog keeps image upload available while uploading", async ({ page }) => { await page.setViewportSize({ width: 390, height: 844 }); await openViewer(page, { deferImage: true });