@rubytech/create-maxy 1.0.472 → 1.0.473

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy",
3
- "version": "1.0.472",
3
+ "version": "1.0.473",
4
4
  "description": "Install Maxy — AI for Productive People",
5
5
  "bin": {
6
6
  "create-maxy": "./dist/index.js"
@@ -57,7 +57,7 @@ An optional image (avatar, icon, or logo) displayed in the public chat header in
57
57
 
58
58
  - `image` — URL path to the image (e.g. `/agent-assets/sales/agent-image.png`). Set automatically by the `agent-image` tool.
59
59
  - `imageShape` — `"circle"` for avatars and icons, `"rounded"` for logos. Controls the CSS border-radius applied to the image in the chat header.
60
- - `showAgentName` — when `true`, the chat header displays `displayName` instead of the business name. When `false` or absent, the header shows the business name from the account's branding data.
60
+ - `showAgentName` — `true`: chat header displays `displayName`; `false` (default): header shows the business name from branding data; `"none"`: no name displayed at all (logo-only header, useful when the logo already contains the brand name).
61
61
 
62
62
  **Fallback chain:** agent image → account brand logo → platform default icon. When no image is configured, the existing brand logo behaviour is preserved.
63
63
 
@@ -182,7 +182,7 @@ After creation, no template metadata persists in the agent's files. The resultin
182
182
  - `claude-haiku-4-5-20251001` — "Haiku — Fast, cost-effective. FAQ, routing, high-volume."
183
183
  - `claude-sonnet-4-6` — "Sonnet — Balanced. Nuanced conversation, qualification, support."
184
184
  - `claude-opus-4-6` — "Opus — Maximum intelligence. Complex sales, consultative selling."
185
- - `showAgentName` (`checkbox`): label "Show agent name in chat header", descriptionwhen enabled, the chat header displays the agent's display name instead of the business name
185
+ - `showAgentName` (`select`): label "Chat header title", options: `false` "Business name (default)", `true` "Agent display name", `"none"` "None (logo only)"
186
186
  The `model` field should have a `defaultValue` of `"claude-haiku-4-5-20251001"`.
187
187
  Wait for the user's response before proceeding.
188
188
  After the form is submitted, ask the user if they have an image (avatar, icon, or logo) for the agent. If yes, ask the user to provide the file and select the shape (circle for avatars/icons, rounded for logos), then use the `agent-image` tool to upload it.
@@ -222,7 +222,7 @@ For agent image changes:
222
222
  - Use the `agent-image` tool with `action: "set"` to upload or replace the image
223
223
  - Use the `agent-image` tool with `action: "remove"` to remove the image (falls back to brand logo)
224
224
  - To change the shape, use `agent-image` with `action: "set"` and the new `imageShape`
225
- - To toggle `showAgentName`, update `config.json` directly
225
+ - To change `showAgentName` (`true`, `false`, or `"none"`), update `config.json` directly
226
226
 
227
227
  For knowledge scope changes:
228
228
  - Show currently tagged nodes (search `memory-search` without `agentSlug`, identify results whose `agents` property contains the agent's slug) and active keyword subscriptions (from `config.json`).
@@ -50,7 +50,7 @@ else
50
50
  ACCOUNT_DIR="$ACCOUNTS_DIR/$ACCOUNT_ID"
51
51
  fi
52
52
 
53
- mkdir -p "$ACCOUNT_DIR/agents/admin" "$ACCOUNT_DIR/agents/public" "$ACCOUNT_DIR/.claude" "$ACCOUNT_DIR/specialists/.claude-plugin" "$ACCOUNT_DIR/specialists/agents"
53
+ mkdir -p "$ACCOUNT_DIR/agents/admin" "$ACCOUNT_DIR/.claude" "$ACCOUNT_DIR/specialists/.claude-plugin" "$ACCOUNT_DIR/specialists/agents"
54
54
 
55
55
  # Claude Code discovers project-level .claude/ (agents, settings) relative to the
56
56
  # nearest .git root. Without a .git in the account directory, Claude Code traverses
@@ -197,7 +197,11 @@ SETTINGS_EOF
197
197
 
198
198
  # Always overwrite IDENTITY.md — Rubytech-controlled, pure behaviour.
199
199
  cp "$TEMPLATES_DIR/agents/admin/IDENTITY.md" "$ACCOUNT_DIR/agents/admin/IDENTITY.md"
200
- cp "$TEMPLATES_DIR/agents/public/IDENTITY.md" "$ACCOUNT_DIR/agents/public/IDENTITY.md"
200
+ if [ -d "$ACCOUNT_DIR/agents/public" ]; then
201
+ cp "$TEMPLATES_DIR/agents/public/IDENTITY.md" "$ACCOUNT_DIR/agents/public/IDENTITY.md"
202
+ else
203
+ echo " Skipping agents/public — directory does not exist (user has not created a public agent)"
204
+ fi
201
205
 
202
206
  # Always overwrite specialist plugin — Rubytech-controlled, not user-editable.
203
207
  # Specialists are a Claude Code plugin loaded via --plugin-dir. The plugin lives at
@@ -215,11 +219,14 @@ rm -f "$ACCOUNT_DIR/.claude/agents/"*.md 2>/dev/null || true
215
219
 
216
220
  # SOUL.md — user-controlled personalisation. Only create if missing. Never overwrite.
217
221
  [ -f "$ACCOUNT_DIR/agents/admin/SOUL.md" ] || cp "$TEMPLATES_DIR/agents/admin/SOUL.md" "$ACCOUNT_DIR/agents/admin/SOUL.md"
218
- [ -f "$ACCOUNT_DIR/agents/public/SOUL.md" ] || cp "$TEMPLATES_DIR/agents/public/SOUL.md" "$ACCOUNT_DIR/agents/public/SOUL.md"
219
222
 
220
- # config.jsonuser-controlled agent config (model, plugins, status). Only create if missing.
221
- # Onboarding Step 7 overwrites with the user's choices.
222
- [ -f "$ACCOUNT_DIR/agents/public/config.json" ] || cp "$TEMPLATES_DIR/agents/public/config.json" "$ACCOUNT_DIR/agents/public/config.json"
223
+ # Public agent files only provision if the user has created a public agent (directory exists).
224
+ # config.json is what makes the agent visible in the sidebar; creating it here would
225
+ # resurrect an agent the user deliberately deleted.
226
+ if [ -d "$ACCOUNT_DIR/agents/public" ]; then
227
+ [ -f "$ACCOUNT_DIR/agents/public/SOUL.md" ] || cp "$TEMPLATES_DIR/agents/public/SOUL.md" "$ACCOUNT_DIR/agents/public/SOUL.md"
228
+ [ -f "$ACCOUNT_DIR/agents/public/config.json" ] || cp "$TEMPLATES_DIR/agents/public/config.json" "$ACCOUNT_DIR/agents/public/config.json"
229
+ fi
223
230
 
224
231
  # AGENTS.md — specialist registry. Pre-populated from templates, maintained by admin agent at runtime.
225
232
  # Always overwrite on re-seed (Rubytech-controlled initial state, like IDENTITY.md).
@@ -9,5 +9,5 @@
9
9
  "contextMode": "claude-code",
10
10
  "enabledPlugins": [],
11
11
  "purchasedPlugins": [],
12
- "defaultAgent": "public"
12
+ "defaultAgent": ""
13
13
  }
@@ -349,4 +349,4 @@ ${JSON.stringify(u.input,null,2)}`,f=ue.get(r),p=o?void 0:f??t;return(0,L.jsx)(j
349
349
 
350
350
  ---
351
351
 
352
- `)}function IT(e){let{selectionMode:n,selectedItems:r,copyToast:i,exitSelection:o,enterSelection:s,copySelected:c,showCopyToast:u,input:d,setInput:f,inputRef:p,pendingFiles:m,setPendingFiles:h,isDragOver:g,attachError:_,fileInputRef:v,addFiles:b,removeFile:x,onDragOver:S,onDragLeave:C,onDrop:k,isStreaming:A,wasPaused:j,messages:ee,messageQueueRef:te,setQueue:ne,sendMessage:re,stopStreaming:ie,disconnecting:ae,handleDisconnect:oe,claudeInfo:N,setClaudeInfo:se,setShowClaudeInfo:P}=e,[ce,F]=(0,I.useState)(!1),le=(0,I.useRef)(null),[ue,de]=(0,I.useState)(!1),fe=(0,I.useRef)(null),pe=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{n||de(!1)},[n]),(0,I.useEffect)(()=>{if(!ue)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||de(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[ue]),(0,I.useEffect)(()=>{if(!ce)return;let e=e=>{if(e.key===`Escape`){F(!1);return}if(e.key===`Tab`&&le.current){let t=le.current.querySelectorAll(`.actions-menu-items button:not([disabled])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}},t=e=>{le.current&&!le.current.contains(e.target)&&F(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[ce]),n?(0,L.jsx)(`div`,{className:`chat-input-area`,children:(0,L.jsxs)(`div`,{className:`selection-bar`,children:[(0,L.jsxs)(`span`,{className:`selection-count`,children:[r.size,` Selected`]}),(0,L.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(ue){de(!1);return}pe.current=!1,fe.current=setTimeout(()=>{pe.current=!0,de(!0),fe.current=null},500)},onPointerUp:()=>{fe.current!==null&&(clearTimeout(fe.current),fe.current=null)},onPointerLeave:()=>{fe.current!==null&&(clearTimeout(fe.current),fe.current=null)},onPointerCancel:()=>{fe.current!==null&&(clearTimeout(fe.current),fe.current=null)},onClick:async()=>{pe.current||await c(e=>PT(ee,e),(e,t)=>{let[n,r]=[e.slice(0,e.lastIndexOf(`_`)),e.slice(e.lastIndexOf(`_`)+1)],[i,a]=[t.slice(0,t.lastIndexOf(`_`)),t.slice(t.lastIndexOf(`_`)+1)],o=parseInt(n,10)-parseInt(i,10);return o===0?r===`admin`?-1:a===`admin`?1:parseInt(r,10)-parseInt(a,10):o})},children:[(0,L.jsx)(D,{size:18}),(0,L.jsx)(`span`,{children:`Copy`})]}),ue&&(0,L.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,L.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=FT(ee,e);t&&u(await E(t)),o()},children:t},e))})]}),(0,L.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:o,children:`Cancel`})]})}):(0,L.jsxs)(`div`,{className:`chat-input-area`,children:[(0,L.jsx)(`input`,{ref:v,type:`file`,multiple:!0,accept:nt,style:{display:`none`},onChange:e=>{e.target.files&&b([...e.target.files]),e.target.value=``}}),m.length>0&&(0,L.jsx)(`div`,{className:`attachment-strip`,children:m.map((e,n)=>(0,L.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,L.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,L.jsx)(a,{size:14}):(0,L.jsx)(t,{size:14}),(0,L.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,L.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>x(n),"aria-label":`Remove ${e.name}`,children:`×`})]},n))}),_&&(0,L.jsx)(`p`,{className:`attach-error`,children:_}),(0,L.jsx)(y,{inputRef:p}),(0,L.jsxs)(`form`,{className:`chat-form${g?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=d.trim()||(j?`continue`:``);if(!(!t&&m.length===0)){if(A){ne([...te.current,{text:t,files:[...m],timestamp:Date.now()}]),f(``),h([]),p.current?.resetHeight();return}re(t),p.current?.resetHeight()}},onDragOver:S,onDragLeave:C,onDrop:k,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&b(n)},children:[(0,L.jsx)(T,{variant:`icon`,type:`button`,onClick:()=>v.current?.click(),"aria-label":`Attach file`,children:(0,L.jsx)(O,{size:14})}),(0,L.jsx)(w,{ref:p,value:d,onChange:f}),A?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(T,{variant:`send`,type:`button`,onClick:()=>ie(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,L.jsx)(Fe,{size:14})}),(0,L.jsx)(T,{variant:`send`,type:`button`,onClick:()=>ie(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,L.jsx)(He,{size:14})})]}):(0,L.jsx)(T,{variant:`send`,type:`submit`,disabled:!d.trim()&&m.length===0&&!j,"aria-label":`Send message`,children:j?(0,L.jsx)(Ie,{size:14}):(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,L.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,L.jsxs)(`div`,{className:`chat-actions`,ref:le,children:[(0,L.jsx)(`button`,{className:`burger-trigger`,onClick:()=>F(e=>!e),"aria-expanded":ce,"aria-haspopup":`true`,"aria-label":`Actions menu`,children:(0,L.jsx)(ke,{size:16})}),(0,L.jsxs)(`div`,{className:`actions-menu-items${ce?` actions-menu-open`:``}`,children:[(0,L.jsxs)(`button`,{className:`chat-action`,disabled:ae,onClick:async()=>{F(!1),await oe()},children:[ae?(0,L.jsx)(Te,{size:14,className:`animate-spin`}):(0,L.jsx)(M,{size:14}),(0,L.jsx)(`span`,{className:`action-label`,children:ae?`Disconnecting...`:`Disconnect Claude`})]}),(0,L.jsxs)(`button`,{className:`chat-action`,onClick:()=>{F(!1);let e=document.createElement(`a`);e.href=`/api/admin/logs?type=stream&download=1`,e.click()},title:`Download stream log`,children:[(0,L.jsx)(Re,{size:14}),(0,L.jsx)(`span`,{className:`action-label`,children:`Stream log`})]}),(0,L.jsxs)(`button`,{className:`chat-action`,onClick:()=>{F(!1),s()},title:`Select messages`,children:[(0,L.jsx)(l,{size:14}),(0,L.jsx)(`span`,{className:`action-label`,children:`Select`})]})]}),(0,L.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(P(!0),!N){let e=await fetch(`/api/admin/claude-info`);e.ok&&se(await e.json())}},children:[(0,L.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,L.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}function LT(e){let{show:t,onClose:n,sessionsLoading:r,sessionsError:i,sessionsList:a,setSessionsList:o,sessionKey:s,resetSession:c,setMessages:l}=e;return t?(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,L.jsxs)(`div`,{className:`claude-info-modal sessions-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(we,{size:12}),`Sessions`,(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`sessions-list`,children:[r&&(0,L.jsxs)(`div`,{className:`sessions-empty`,children:[(0,L.jsx)(Te,{size:14,className:`spin`}),` Loading…`]}),i&&(0,L.jsx)(`div`,{className:`sessions-empty sessions-error`,children:i}),!r&&!i&&a.length===0&&(0,L.jsx)(`div`,{className:`sessions-empty`,children:`No recent sessions`}),!r&&!i&&a.map(e=>(0,L.jsxs)(`div`,{className:`sessions-row`,children:[(0,L.jsxs)(`div`,{className:`sessions-row-info`,children:[(0,L.jsx)(`span`,{className:`sessions-row-name`,children:e.name||e.conversationId.slice(0,12)+`…`}),(0,L.jsxs)(`span`,{className:`sessions-row-time`,children:[(0,L.jsx)(se,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]}),(0,L.jsxs)(`div`,{className:`sessions-row-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`sessions-action sessions-play`,title:`Resume session`,onClick:()=>{n(),c(),s&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/messages?session_key=${encodeURIComponent(s)}`).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to load history`))).then(e=>{let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&l(t)}).catch(e=>{console.error(`[chat] session resume failed:`,e),l([{role:`maxy`,events:[{type:`text`,content:`Could not load session history.`}],timestamp:Date.now()-1,historical:!0}])})},children:(0,L.jsx)(Ie,{size:13})}),(0,L.jsx)(`button`,{type:`button`,className:`sessions-action sessions-delete`,title:`Delete session`,onClick:()=>{o(t=>t.filter(t=>t.conversationId!==e.conversationId)),s&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(s)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] session delete failed:`,e))},children:(0,L.jsx)(Ge,{size:13})})]})]},e.conversationId))]})]})}):null}function RT({src:e,onClose:t}){return e?(0,L.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,L.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,L.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function zT({show:e,onClose:t,onConfirm:n}){return e?(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,L.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(`span`,{children:`Compact session?`}),(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,L.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,L.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,L.jsx)(T,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,L.jsx)(T,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function BT(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionKey:o,contextModeHint:s,handleContextModeToggle:c}=e;if(!t)return null;let l=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),u=l.at(-1),d=u?.peak_request_pct==null?u?.context_window?Math.round((u.input_tokens+u.cache_creation_tokens+u.cache_read_tokens)/u.context_window*100):0:Math.round(u.peak_request_pct*100),f=l.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),p=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),m=l.reduce((e,t)=>e+(t.total_cost_usd??0),0),h=r?.account?.subscriptionType,g=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,L.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,L.jsx)(`span`,{children:`Claude Code`}),(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`claude-info-section`,children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(h||p||m>0)&&(0,L.jsxs)(`div`,{className:`claude-info-section`,children:[h&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,L.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:h})]}),p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,L.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(p.utilization*100),`%`]})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:g(p.resetsAt)})]}),p.isUsingOverage&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),m>0&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,L.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,m<.01?m.toFixed(4):m.toFixed(2)]})]})]}),(0,L.jsxs)(`div`,{className:`claude-info-section`,children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Context mode`}),(0,L.jsxs)(`span`,{className:`claude-info-value claude-info-toggle`,role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},children:[r?.contextMode??`…`,s?` (next turn)`:``]})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:d>0?`${d}%`:`—`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:f>0?et(f):`—`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:$e(a)})]}),o&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Session ID`}),(0,L.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var VT=[{at:0,label:`Starting upgrade…`},{at:3,label:`Installing update…`},{at:12,label:`Restarting Maxy…`},{at:22,label:`Almost there…`}],HT=3e3,UT=12e4;function WT({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,I.useState)(`idle`),[s,c]=(0,I.useState)(null),[l,u]=(0,I.useState)(0),d=(0,I.useRef)(null),f=(0,I.useRef)(null),p=(0,I.useRef)(null),m=n?.latest??null,h=(0,I.useCallback)(()=>{d.current&&=(clearInterval(d.current),null),f.current&&=(clearInterval(f.current),null),p.current&&=(clearTimeout(p.current),null)},[]);(0,I.useEffect)(()=>{e||(h(),o(`idle`),c(null),u(0))},[e,h]),(0,I.useEffect)(()=>h,[h]);let g=VT.reduce((e,t)=>l>=t.at?t.label:e,VT[0].label),_=a===`success`?100:Math.min(l/30*90,90);function v(){d.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`);if(!e.ok)return;let t=await e.json();m&&t.installed===m&&(h(),o(`success`),i())}catch{o(e=>e===`upgrading`||e===`restarting`?`restarting`:e)}},HT)}async function y(){if(!r){console.warn(`[update] Upgrade blocked: no session key`),o(`error`),c(`Session expired — please log in again`);return}if(!m){console.warn(`[update] Upgrade blocked: no target version`),o(`error`),c(`Version data unavailable — close and try again`);return}o(`upgrading`),c(null),u(0),f.current=setInterval(()=>u(e=>e+1),1e3),p.current=setTimeout(()=>{h(),o(`error`),c(`Upgrade timed out. Check /tmp/maxy-upgrade.log on the device.`)},UT);try{let e=await(await fetch(`/api/admin/version/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:r})})).json();if(!e.ok){h(),o(`error`),c(e.error||`Upgrade failed`);return}v()}catch{h(),o(`error`),c(`Failed to start upgrade`)}}return e?(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`idle`||a===`success`||a===`error`)&&t()},children:(0,L.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(ue,{size:12}),`Software Update`,(a===`idle`||a===`success`||a===`error`)&&(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),a===`idle`&&(0,L.jsxs)(`div`,{className:`update-modal-body`,children:[(0,L.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,L.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,L.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,m??`…`]})]})]}),(0,L.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:y,children:`Upgrade`})]}),(a===`upgrading`||a===`restarting`)&&(0,L.jsx)(`div`,{className:`update-modal-body`,children:(0,L.jsxs)(`div`,{className:`update-modal-progress-wrap`,children:[(0,L.jsx)(`div`,{className:`update-modal-progress-bar`,children:(0,L.jsx)(`div`,{className:`update-modal-progress-fill`,style:{width:`${_}%`}})}),(0,L.jsxs)(`div`,{className:`update-modal-phase`,children:[(0,L.jsx)(Te,{size:12,className:`spin`}),g]})]})}),a===`success`&&(0,L.jsxs)(`div`,{className:`update-modal-body update-modal-result`,children:[(0,L.jsx)(ie,{size:20,className:`update-success-icon`}),(0,L.jsxs)(`span`,{children:[`Upgraded to v`,m]})]}),a===`error`&&(0,L.jsxs)(`div`,{className:`update-modal-body update-modal-result`,children:[(0,L.jsx)(Ke,{size:20,className:`update-error-icon`}),(0,L.jsx)(`span`,{children:s})]})]})}):null}function GT({onClose:e}){Qe();let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null),i=(0,I.useRef)(null),a=(0,I.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,I.useCallback)(()=>{let t=typeof window<`u`?window.location.hostname:``,o=`/vnc-popout.html?host=${encodeURIComponent(t)}&port=6080&title=Browser`,s=window.open(o,`maxy-vnc-overlay-popout`,`width=1024,height=768`);s&&(r.current=s,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,I.useCallback)(()=>{a(),e()},[a,e]);(0,I.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,I.useEffect)(()=>()=>a(),[a]);let c=bt({handlePopout:o,disabled:t}),l=`/vnc-viewer.html?host=${typeof window<`u`?window.location.hostname:``}&port=6080`;return t?(0,L.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,L.jsx)(_e,{className:`browser-viewer__icon`}),(0,L.jsx)(`span`,{className:`browser-viewer__title`,children:`Browser`}),(0,L.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:Me,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ye,onClick:s,"aria-label":`Close`})]}):(0,L.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,L.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...c,children:[(0,L.jsx)(_e,{className:`browser-viewer__icon`}),(0,L.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:`Browser`}),(0,L.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:de,onClick:o,"aria-label":`Pop out`}),(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ye,onClick:s,"aria-label":`Close`})]})]}),(0,L.jsx)(`iframe`,{src:l,className:`browser-viewer-fullscreen__iframe`,title:`Browser`})]})}function KT(){Qe();let e=(0,I.useRef)(null),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),[p,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(!1),[b,S]=(0,I.useState)([]),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(null),[A,j]=(0,I.useState)(!1),[ee,M]=(0,I.useState)(null),[te,ne]=(0,I.useState)(!1),[re,ie]=(0,I.useState)(!1),ae=(0,I.useRef)(!1),oe=(0,I.useRef)(null),N=k(),se=tt(),P=st(),ce=lt(),F=ct({sessionKey:P.sessionKey,setAppState:P.setAppState,startElapsedTimer:se.startElapsedTimer,stopElapsedTimer:se.stopElapsedTimer,resetTimerState:se.resetTimerState,pausedElapsedRef:se.pausedElapsedRef,expandAllDefaultRef:P.expandAllDefaultRef,setExpandAll:P.setExpandAll,getPendingFiles:()=>ce.pendingFiles,clearPendingFiles:ce.clearFiles,inputRef:e});return(0,I.useEffect)(()=>{c(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,I.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):N.selectionMode&&N.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,N.selectionMode]),(0,I.useEffect)(()=>{(P.appState===`set-pin`||P.appState===`enter-pin`)&&setTimeout(()=>P.pinInputRef.current?.focus(),100),P.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[P.appState,F.greetingGeneration]),(0,I.useEffect)(()=>{P.appState===`chat`&&P.onboardingComplete===!1&&(ae.current||(ae.current=!0,F.sendSystemPrompt(`[New session. Assess the current state and introduce yourself. Be proactive.]`)))},[P.appState,P.onboardingComplete]),(0,I.useEffect)(()=>{if(!l)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||O(t)}).catch(()=>{}),()=>{e=!0}},[l]),(0,I.useEffect)(()=>{if(!l){f(null),_(null),O(null);return}function e(e){oe.current&&!oe.current.contains(e.target)&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]),(0,I.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&F.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),P.appState===`loading`?(0,L.jsx)(`div`,{className:`chat-page admin-page`,children:(0,L.jsx)(`header`,{className:`chat-header`,children:(0,L.jsx)(`img`,{src:m,alt:x.productName,className:`chat-logo`})})}):P.appState===`set-pin`?(0,L.jsx)(dt,{pin:P.pin,setPin:P.setPin,confirmPin:P.confirmPin,setConfirmPin:P.setConfirmPin,showPin:P.showPin,setShowPin:P.setShowPin,pinLoading:P.pinLoading,pinError:P.pinError,pinInputRef:P.pinInputRef,confirmPinInputRef:P.confirmPinInputRef,setPinFormRef:P.setPinFormRef,onSubmit:P.handleSetPin}):P.appState===`connect-claude`?(0,L.jsx)(pt,{authPolling:P.authPolling,setAuthPolling:P.setAuthPolling,authLoading:P.authLoading,setAuthLoading:P.setAuthLoading,pinError:P.pinError,setPinError:P.setPinError,setAppState:P.setAppState}):P.appState===`enter-pin`?(0,L.jsx)(ft,{pin:P.pin,setPin:P.setPin,showPin:P.showPin,setShowPin:P.setShowPin,pinLoading:P.pinLoading,pinError:P.pinError,pinInputRef:P.pinInputRef,onSubmit:P.handleLogin,onChangePin:P.handleChangePin}):(0,L.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,L.jsxs)(`header`,{className:`chat-header`,children:[(0,L.jsx)(`img`,{src:m,alt:x.productName,className:`chat-logo`}),(0,L.jsx)(`div`,{children:(0,L.jsx)(`h1`,{className:`chat-tagline`,children:x.productName})}),(0,L.jsxs)(`div`,{className:`chat-burger-wrap`,ref:oe,children:[(0,L.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>u(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":l,children:(0,L.jsx)(ke,{size:20})}),l&&(0,L.jsxs)(`div`,{className:`chat-menu`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{u(!1),F.startNewSession()},disabled:F.isStreaming||F.isCompacting,children:[(0,L.jsx)(he,{size:14}),` New session`]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{u(!1),y(!0),w(!0),E(null);try{let e=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(P.sessionKey)}`);if(!e.ok)throw Error(`Failed to load sessions`);S((await e.json()).sessions??[])}catch{E(`Failed to load sessions`)}finally{w(!1)}},children:[(0,L.jsx)(we,{size:14}),` Sessions`]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(te||re)){ie(!0),u(!1);try{let e=await(await fetch(`/api/admin/browser/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch browser`);ne(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{ie(!1)}}},disabled:re,children:[(0,L.jsx)(_e,{size:14}),` Browser`,re&&(0,L.jsx)(Te,{size:12,className:`spin`})]}),(0,L.jsx)(`div`,{className:`chat-menu-divider`}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(d!==null){f(null);return}h(!0),_(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);f((await e.json()).agents??[])}catch{_(`Failed to load agents`)}finally{h(!1)}},children:[(0,L.jsx)(de,{size:14}),` Public`,p&&(0,L.jsx)(Te,{size:12,className:`spin`})]}),d!==null&&(0,L.jsxs)(`div`,{className:`chat-menu-agents`,children:[g&&(0,L.jsx)(`span`,{className:`chat-menu-agent-error`,children:g}),d.length===0&&!g&&(0,L.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),d.map(e=>(0,L.jsxs)(`a`,{href:`${s}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`chat-menu-item chat-menu-agent-item`,onClick:()=>u(!1),children:[(0,L.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,L.jsxs)(`span`,{className:`agent-text`,children:[(0,L.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,L.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]})]},e.slug))]}),(0,L.jsx)(`div`,{className:`chat-menu-divider`}),D?.updateAvailable?(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{D.latest&&(M(D),u(!1),j(!0))},children:[(0,L.jsx)(ye,{size:14}),(0,L.jsxs)(`span`,{className:`version-installed`,children:[`v`,D.installed,(0,L.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,L.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,L.jsx)(ye,{size:14}),(0,L.jsxs)(`span`,{className:`version-installed`,children:[D?`v${D.installed}`:`…`,D&&!D.updateAvailable&&(0,L.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{u(!1),P.handleLogout(),F.setMessages([])},children:[(0,L.jsx)(De,{size:14}),` Log out`]})]})]})]}),(0,L.jsx)(NT,{messages:F.messages,isStreaming:F.isStreaming,elapsedSeconds:se.elapsedSeconds,sessionTurnStart:se.sessionTurnStart,expandAll:P.expandAll,setExpandAll:P.setExpandAll,sessionCompacted:F.sessionCompacted,isCompacting:F.isCompacting,setShowCompactConfirm:o,handleComponentSubmit:F.handleComponentSubmit,effectiveSubmitted:F.effectiveSubmitted,selectionMode:N.selectionMode,selectedItems:N.selectedItems,toggleSelectItem:N.toggleSelectItem,sessionKey:P.sessionKey,setLightboxSrc:n,messageQueue:F.messageQueue,messageQueueRef:F.messageQueueRef,setQueue:F.setQueue,sendMessage:F.sendMessage,appState:P.appState,onboardingComplete:P.onboardingComplete}),(0,L.jsx)(IT,{selectionMode:N.selectionMode,selectedItems:N.selectedItems,copyToast:N.copyToast,exitSelection:N.exitSelection,enterSelection:N.enterSelection,copySelected:N.copySelected,showCopyToast:N.showCopyToast,input:F.input,setInput:F.setInput,inputRef:e,pendingFiles:ce.pendingFiles,setPendingFiles:ce.setPendingFiles,isDragOver:ce.isDragOver,attachError:ce.attachError,fileInputRef:ce.fileInputRef,addFiles:ce.addFiles,removeFile:ce.removeFile,onDragOver:ce.onDragOver,onDragLeave:ce.onDragLeave,onDrop:ce.onDrop,isStreaming:F.isStreaming,wasPaused:F.wasPaused,messages:F.messages,messageQueueRef:F.messageQueueRef,setQueue:F.setQueue,sendMessage:F.sendMessage,stopStreaming:F.stopStreaming,disconnecting:P.disconnecting,handleDisconnect:P.handleDisconnect,claudeInfo:P.claudeInfo,setClaudeInfo:P.setClaudeInfo,setShowClaudeInfo:i}),N.copyToast&&(0,L.jsx)(`span`,{className:`copy-toast${N.copyToast===`failed`?` copy-toast-failed`:``}`,children:N.copyToast===`copied`?`Copied`:`Copy failed`}),(0,L.jsx)(LT,{show:v,onClose:()=>y(!1),sessionsLoading:C,sessionsError:T,sessionsList:b,setSessionsList:S,sessionKey:P.sessionKey,resetSession:F.resetSession,setMessages:F.setMessages}),(0,L.jsx)(RT,{src:t,onClose:()=>n(null)}),(0,L.jsx)(zT,{show:a,onClose:()=>o(!1),onConfirm:F.handleCompactNow}),(0,L.jsx)(BT,{show:r,onClose:()=>{i(!1),P.setClaudeInfo(null)},claudeInfo:P.claudeInfo,messages:F.messages,sessionElapsed:se.sessionElapsed,sessionKey:P.sessionKey,contextModeHint:P.contextModeHint,handleContextModeToggle:P.handleContextModeToggle}),(0,L.jsx)(WT,{show:A,onClose:()=>j(!1),versionInfo:ee,sessionKey:P.sessionKey,onUpgradeComplete:()=>O(null)}),te&&(0,L.jsx)(GT,{onClose:()=>ne(!1)})]})}(0,Ze.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(KT,{}));
352
+ `)}function IT(e){let{selectionMode:n,selectedItems:r,copyToast:i,exitSelection:o,enterSelection:s,copySelected:c,showCopyToast:u,input:d,setInput:f,inputRef:p,pendingFiles:m,setPendingFiles:h,isDragOver:g,attachError:_,fileInputRef:v,addFiles:b,removeFile:x,onDragOver:S,onDragLeave:C,onDrop:k,isStreaming:A,wasPaused:j,messages:ee,messageQueueRef:te,setQueue:ne,sendMessage:re,stopStreaming:ie,disconnecting:ae,handleDisconnect:oe,claudeInfo:N,setClaudeInfo:se,setShowClaudeInfo:P}=e,[ce,F]=(0,I.useState)(!1),le=(0,I.useRef)(null),[ue,de]=(0,I.useState)(!1),fe=(0,I.useRef)(null),pe=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{n||de(!1)},[n]),(0,I.useEffect)(()=>{if(!ue)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||de(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[ue]),(0,I.useEffect)(()=>{if(!ce)return;let e=e=>{if(e.key===`Escape`){F(!1);return}if(e.key===`Tab`&&le.current){let t=le.current.querySelectorAll(`.actions-menu-items button:not([disabled])`);if(t.length===0)return;let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}},t=e=>{le.current&&!le.current.contains(e.target)&&F(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[ce]),n?(0,L.jsx)(`div`,{className:`chat-input-area`,children:(0,L.jsxs)(`div`,{className:`selection-bar`,children:[(0,L.jsxs)(`span`,{className:`selection-count`,children:[r.size,` Selected`]}),(0,L.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(ue){de(!1);return}pe.current=!1,fe.current=setTimeout(()=>{pe.current=!0,de(!0),fe.current=null},500)},onPointerUp:()=>{fe.current!==null&&(clearTimeout(fe.current),fe.current=null)},onPointerLeave:()=>{fe.current!==null&&(clearTimeout(fe.current),fe.current=null)},onPointerCancel:()=>{fe.current!==null&&(clearTimeout(fe.current),fe.current=null)},onClick:async()=>{pe.current||await c(e=>PT(ee,e),(e,t)=>{let[n,r]=[e.slice(0,e.lastIndexOf(`_`)),e.slice(e.lastIndexOf(`_`)+1)],[i,a]=[t.slice(0,t.lastIndexOf(`_`)),t.slice(t.lastIndexOf(`_`)+1)],o=parseInt(n,10)-parseInt(i,10);return o===0?r===`admin`?-1:a===`admin`?1:parseInt(r,10)-parseInt(a,10):o})},children:[(0,L.jsx)(D,{size:18}),(0,L.jsx)(`span`,{children:`Copy`})]}),ue&&(0,L.jsx)(`div`,{className:`copy-menu`,children:[[`all`,`All events`],[`text`,`Text messages only`],[`non-text`,`Non-text only`]].map(([e,t])=>(0,L.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let t=FT(ee,e);t&&u(await E(t)),o()},children:t},e))})]}),(0,L.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:o,children:`Cancel`})]})}):(0,L.jsxs)(`div`,{className:`chat-input-area`,children:[(0,L.jsx)(`input`,{ref:v,type:`file`,multiple:!0,accept:nt,style:{display:`none`},onChange:e=>{e.target.files&&b([...e.target.files]),e.target.value=``}}),m.length>0&&(0,L.jsx)(`div`,{className:`attachment-strip`,children:m.map((e,n)=>(0,L.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,L.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type===`application/pdf`?(0,L.jsx)(a,{size:14}):(0,L.jsx)(t,{size:14}),(0,L.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,L.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>x(n),"aria-label":`Remove ${e.name}`,children:`×`})]},n))}),_&&(0,L.jsx)(`p`,{className:`attach-error`,children:_}),(0,L.jsx)(y,{inputRef:p}),(0,L.jsxs)(`form`,{className:`chat-form${g?` drag-over`:``}`,onSubmit:e=>{e.preventDefault();let t=d.trim()||(j?`continue`:``);if(!(!t&&m.length===0)){if(A){ne([...te.current,{text:t,files:[...m],timestamp:Date.now()}]),f(``),h([]),p.current?.resetHeight();return}re(t),p.current?.resetHeight()}},onDragOver:S,onDragLeave:C,onDrop:k,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&b(n)},children:[(0,L.jsx)(T,{variant:`icon`,type:`button`,onClick:()=>v.current?.click(),"aria-label":`Attach file`,children:(0,L.jsx)(O,{size:14})}),(0,L.jsx)(w,{ref:p,value:d,onChange:f}),A?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(T,{variant:`send`,type:`button`,onClick:()=>ie(!0),"aria-label":`Pause`,style:{background:`var(--text-secondary)`},children:(0,L.jsx)(Fe,{size:14})}),(0,L.jsx)(T,{variant:`send`,type:`button`,onClick:()=>ie(!1),"aria-label":`Stop`,style:{background:`var(--danger)`},children:(0,L.jsx)(He,{size:14})})]}):(0,L.jsx)(T,{variant:`send`,type:`submit`,disabled:!d.trim()&&m.length===0&&!j,"aria-label":`Send message`,children:j?(0,L.jsx)(Ie,{size:14}):(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,L.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,L.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,L.jsxs)(`div`,{className:`chat-actions`,ref:le,children:[(0,L.jsx)(`button`,{className:`burger-trigger`,onClick:()=>F(e=>!e),"aria-expanded":ce,"aria-haspopup":`true`,"aria-label":`Actions menu`,children:(0,L.jsx)(ke,{size:16})}),(0,L.jsxs)(`div`,{className:`actions-menu-items${ce?` actions-menu-open`:``}`,children:[(0,L.jsxs)(`button`,{className:`chat-action`,disabled:ae,onClick:async()=>{F(!1),await oe()},children:[ae?(0,L.jsx)(Te,{size:14,className:`animate-spin`}):(0,L.jsx)(M,{size:14}),(0,L.jsx)(`span`,{className:`action-label`,children:ae?`Disconnecting...`:`Disconnect Claude`})]}),(0,L.jsxs)(`button`,{className:`chat-action`,onClick:()=>{F(!1);let e=document.createElement(`a`);e.href=`/api/admin/logs?type=stream&download=1`,e.click()},title:`Download stream log`,children:[(0,L.jsx)(Re,{size:14}),(0,L.jsx)(`span`,{className:`action-label`,children:`Stream log`})]}),(0,L.jsxs)(`button`,{className:`chat-action`,onClick:()=>{F(!1),s()},title:`Select messages`,children:[(0,L.jsx)(l,{size:14}),(0,L.jsx)(`span`,{className:`action-label`,children:`Select`})]})]}),(0,L.jsxs)(`div`,{className:`powered-by`,onClick:async()=>{if(P(!0),!N){let e=await fetch(`/api/admin/claude-info`);e.ok&&se(await e.json())}},children:[(0,L.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,L.jsx)(`span`,{children:`Powered by Claude Code`})]})]})]})}function LT(e){let{show:t,onClose:n,sessionsLoading:r,sessionsError:i,sessionsList:a,setSessionsList:o,sessionKey:s,resetSession:c,setMessages:l}=e;return t?(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,L.jsxs)(`div`,{className:`claude-info-modal sessions-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(we,{size:12}),`Sessions`,(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:n,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`sessions-list`,children:[r&&(0,L.jsxs)(`div`,{className:`sessions-empty`,children:[(0,L.jsx)(Te,{size:14,className:`spin`}),` Loading…`]}),i&&(0,L.jsx)(`div`,{className:`sessions-empty sessions-error`,children:i}),!r&&!i&&a.length===0&&(0,L.jsx)(`div`,{className:`sessions-empty`,children:`No recent sessions`}),!r&&!i&&a.map(e=>(0,L.jsxs)(`div`,{className:`sessions-row`,children:[(0,L.jsxs)(`div`,{className:`sessions-row-info`,children:[(0,L.jsx)(`span`,{className:`sessions-row-name`,children:e.name||e.conversationId.slice(0,12)+`…`}),(0,L.jsxs)(`span`,{className:`sessions-row-time`,children:[(0,L.jsx)(se,{size:10}),(()=>{try{let t=new Date(e.updatedAt),n=Date.now()-t.getTime();return n<6e4?`just now`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}catch{return``}})()]})]}),(0,L.jsxs)(`div`,{className:`sessions-row-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`sessions-action sessions-play`,title:`Resume session`,onClick:()=>{n(),c(),s&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}/messages?session_key=${encodeURIComponent(s)}`).then(e=>e.ok?e.json():Promise.reject(Error(`Failed to load history`))).then(e=>{let t=(e.messages??[]).map(e=>({role:e.role===`user`?`admin`:`maxy`,content:e.role===`user`?e.content:void 0,events:e.role===`assistant`?[{type:`text`,content:e.content}]:void 0,timestamp:new Date(e.createdAt).getTime()||0,historical:!0}));t.length>0&&l(t)}).catch(e=>{console.error(`[chat] session resume failed:`,e),l([{role:`maxy`,events:[{type:`text`,content:`Could not load session history.`}],timestamp:Date.now()-1,historical:!0}])})},children:(0,L.jsx)(Ie,{size:13})}),(0,L.jsx)(`button`,{type:`button`,className:`sessions-action sessions-delete`,title:`Delete session`,onClick:()=>{o(t=>t.filter(t=>t.conversationId!==e.conversationId)),s&&fetch(`/api/admin/sessions/${encodeURIComponent(e.conversationId)}?session_key=${encodeURIComponent(s)}`,{method:`DELETE`}).catch(e=>console.error(`[chat] session delete failed:`,e))},children:(0,L.jsx)(Ge,{size:13})})]})]},e.conversationId))]})]})}):null}function RT({src:e,onClose:t}){return e?(0,L.jsxs)(`div`,{className:`attachment-lightbox`,onClick:t,children:[(0,L.jsx)(`button`,{className:`attachment-lightbox-close`,onClick:t,"aria-label":`Close`,children:`×`}),(0,L.jsx)(`img`,{src:e,alt:`Attachment`,onClick:e=>e.stopPropagation()})]}):null}function zT({show:e,onClose:t,onConfirm:n}){return e?(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,L.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(`span`,{children:`Compact session?`}),(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,L.jsx)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:`Summarises the conversation history to free up context window space. The session continues with a compressed summary.`}),(0,L.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,L.jsx)(T,{variant:`secondary`,size:`sm`,style:{background:`var(--accent)`,flex:1},onClick:()=>{t(),n()},children:`Yes, compact`}),(0,L.jsx)(T,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:t,children:`No`})]})]})}):null}function BT(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionKey:o,contextModeHint:s,handleContextModeToggle:c}=e;if(!t)return null;let l=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),u=l.at(-1),d=u?.peak_request_pct==null?u?.context_window?Math.round((u.input_tokens+u.cache_creation_tokens+u.cache_read_tokens)/u.context_window*100):0:Math.round(u.peak_request_pct*100),f=l.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),p=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),m=l.reduce((e,t)=>e+(t.total_cost_usd??0),0),h=r?.account?.subscriptionType,g=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,L.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,L.jsx)(`span`,{children:`Claude Code`}),(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`claude-info-section`,children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(h||p||m>0)&&(0,L.jsxs)(`div`,{className:`claude-info-section`,children:[h&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,L.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:h})]}),p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,L.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(p.utilization*100),`%`]})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:g(p.resetsAt)})]}),p.isUsingOverage&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),m>0&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,L.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,m<.01?m.toFixed(4):m.toFixed(2)]})]})]}),(0,L.jsxs)(`div`,{className:`claude-info-section`,children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Context mode`}),(0,L.jsxs)(`span`,{className:`claude-info-value claude-info-toggle`,role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},children:[r?.contextMode??`…`,s?` (next turn)`:``]})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:d>0?`${d}%`:`—`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:f>0?et(f):`—`})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,L.jsx)(`span`,{className:`claude-info-value`,children:$e(a)})]}),o&&(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Session ID`}),(0,L.jsx)(`span`,{className:`claude-info-value`,style:{fontFamily:`monospace`,fontSize:10},children:o.slice(0,8)})]})]})]})})}var VT=[{at:0,label:`Starting upgrade…`},{at:3,label:`Installing update…`},{at:12,label:`Restarting Maxy…`},{at:22,label:`Almost there…`}],HT=3e3,UT=12e4;function WT({show:e,onClose:t,versionInfo:n,sessionKey:r,onUpgradeComplete:i}){let[a,o]=(0,I.useState)(`idle`),[s,c]=(0,I.useState)(null),[l,u]=(0,I.useState)(0),d=(0,I.useRef)(null),f=(0,I.useRef)(null),p=(0,I.useRef)(null),m=n?.latest??null,h=(0,I.useCallback)(()=>{d.current&&=(clearInterval(d.current),null),f.current&&=(clearInterval(f.current),null),p.current&&=(clearTimeout(p.current),null)},[]);(0,I.useEffect)(()=>{e||(h(),o(`idle`),c(null),u(0))},[e,h]),(0,I.useEffect)(()=>h,[h]);let g=VT.reduce((e,t)=>l>=t.at?t.label:e,VT[0].label),_=a===`success`?100:Math.min(l/30*90,90);function v(){d.current=setInterval(async()=>{try{let e=await fetch(`/api/admin/version`);if(!e.ok)return;let t=await e.json();m&&t.installed===m&&(h(),o(`success`),i())}catch{o(e=>e===`upgrading`||e===`restarting`?`restarting`:e)}},HT)}async function y(){if(!r){console.warn(`[update] Upgrade blocked: no session key`),o(`error`),c(`Session expired — please log in again`);return}if(!m){console.warn(`[update] Upgrade blocked: no target version`),o(`error`),c(`Version data unavailable — close and try again`);return}o(`upgrading`),c(null),u(0),f.current=setInterval(()=>u(e=>e+1),1e3),p.current=setTimeout(()=>{h(),o(`error`),c(`Upgrade timed out. Check /tmp/maxy-upgrade.log on the device.`)},UT);try{let e=await(await fetch(`/api/admin/version/upgrade`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:r})})).json();if(!e.ok){h(),o(`error`),c(e.error||`Upgrade failed`);return}v()}catch{h(),o(`error`),c(`Failed to start upgrade`)}}return e?(0,L.jsx)(`div`,{className:`claude-info-overlay`,onClick:()=>{(a===`idle`||a===`success`||a===`error`)&&t()},children:(0,L.jsxs)(`div`,{className:`claude-info-modal update-modal`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`div`,{className:`claude-info-header`,children:[(0,L.jsx)(ue,{size:12}),`Software Update`,(a===`idle`||a===`success`||a===`error`)&&(0,L.jsx)(`button`,{className:`claude-info-close`,onClick:t,children:`✕`})]}),a===`idle`&&(0,L.jsxs)(`div`,{className:`update-modal-body`,children:[(0,L.jsxs)(`div`,{className:`update-modal-versions`,children:[(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Installed`}),(0,L.jsxs)(`span`,{className:`claude-info-value`,children:[`v`,n?.installed??`…`]})]}),(0,L.jsxs)(`div`,{className:`claude-info-row`,children:[(0,L.jsx)(`span`,{className:`claude-info-label`,children:`Available`}),(0,L.jsxs)(`span`,{className:`claude-info-value update-version-new`,children:[`v`,m??`…`]})]})]}),(0,L.jsx)(`button`,{type:`button`,className:`update-modal-btn`,onClick:y,children:`Upgrade`})]}),(a===`upgrading`||a===`restarting`)&&(0,L.jsx)(`div`,{className:`update-modal-body`,children:(0,L.jsxs)(`div`,{className:`update-modal-progress-wrap`,children:[(0,L.jsx)(`div`,{className:`update-modal-progress-bar`,children:(0,L.jsx)(`div`,{className:`update-modal-progress-fill`,style:{width:`${_}%`}})}),(0,L.jsxs)(`div`,{className:`update-modal-phase`,children:[(0,L.jsx)(Te,{size:12,className:`spin`}),g]})]})}),a===`success`&&(0,L.jsxs)(`div`,{className:`update-modal-body update-modal-result`,children:[(0,L.jsx)(ie,{size:20,className:`update-success-icon`}),(0,L.jsxs)(`span`,{children:[`Upgraded to v`,m]})]}),a===`error`&&(0,L.jsxs)(`div`,{className:`update-modal-body update-modal-result`,children:[(0,L.jsx)(Ke,{size:20,className:`update-error-icon`}),(0,L.jsx)(`span`,{children:s})]})]})}):null}function GT({onClose:e}){Qe();let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null),i=(0,I.useRef)(null),a=(0,I.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),r.current&&!r.current.closed&&r.current.close(),r.current=null,n(!1)},[]),o=(0,I.useCallback)(()=>{let t=typeof window<`u`?window.location.hostname:``,o=`/vnc-popout.html?host=${encodeURIComponent(t)}&port=6080&title=Browser`,s=window.open(o,`maxy-vnc-overlay-popout`,`width=1024,height=768`);s&&(r.current=s,n(!0),i.current=setInterval(()=>{r.current?.closed&&(a(),e())},500))},[a,e]),s=(0,I.useCallback)(()=>{a(),e()},[a,e]);(0,I.useEffect)(()=>{if(t)return;let e=e=>{e.key===`Escape`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,s]),(0,I.useEffect)(()=>()=>a(),[a]);let c=bt({handlePopout:o,disabled:t}),l=`/vnc-viewer.html?host=${typeof window<`u`?window.location.hostname:``}&port=6080`;return t?(0,L.jsxs)(`div`,{className:`browser-overlay-popout`,children:[(0,L.jsx)(_e,{className:`browser-viewer__icon`}),(0,L.jsx)(`span`,{className:`browser-viewer__title`,children:`Browser`}),(0,L.jsx)(`span`,{className:`browser-viewer__popout-label`,children:`Popped out`}),(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:Me,onClick:()=>{a()},"aria-label":`Pop back in`}),(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ye,onClick:s,"aria-label":`Close`})]}):(0,L.jsxs)(`div`,{className:`browser-viewer-fullscreen`,children:[(0,L.jsxs)(`div`,{className:`browser-viewer-fullscreen__bar`,...c,children:[(0,L.jsx)(_e,{className:`browser-viewer__icon`}),(0,L.jsx)(`span`,{className:`browser-viewer-fullscreen__title`,children:`Browser`}),(0,L.jsxs)(`div`,{className:`browser-viewer-fullscreen__actions`,children:[(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:de,onClick:o,"aria-label":`Pop out`}),(0,L.jsx)(T,{variant:`ghost`,size:`sm`,icon:Ye,onClick:s,"aria-label":`Close`})]})]}),(0,L.jsx)(`iframe`,{src:l,className:`browser-viewer-fullscreen__iframe`,title:`Browser`})]})}function KT(){Qe();let e=(0,I.useRef)(null),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),[p,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(!1),[b,S]=(0,I.useState)([]),[C,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(null),[A,j]=(0,I.useState)(!1),[ee,M]=(0,I.useState)(null),[te,ne]=(0,I.useState)(!1),[re,ie]=(0,I.useState)(!1),ae=(0,I.useRef)(!1),oe=(0,I.useRef)(null),N=k(),se=tt(),P=st(),ce=lt(),F=ct({sessionKey:P.sessionKey,setAppState:P.setAppState,startElapsedTimer:se.startElapsedTimer,stopElapsedTimer:se.stopElapsedTimer,resetTimerState:se.resetTimerState,pausedElapsedRef:se.pausedElapsedRef,expandAllDefaultRef:P.expandAllDefaultRef,setExpandAll:P.setExpandAll,getPendingFiles:()=>ce.pendingFiles,clearPendingFiles:ce.clearFiles,inputRef:e});return(0,I.useEffect)(()=>{c(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,I.useEffect)(()=>{function e(e){e.key===`Escape`&&(t?n(null):N.selectionMode&&N.exitSelection())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,N.selectionMode]),(0,I.useEffect)(()=>{(P.appState===`set-pin`||P.appState===`enter-pin`)&&setTimeout(()=>P.pinInputRef.current?.focus(),100),P.appState===`chat`&&setTimeout(()=>e.current?.focus(),100)},[P.appState,F.greetingGeneration]),(0,I.useEffect)(()=>{P.appState===`chat`&&P.onboardingComplete===!1&&(ae.current||(ae.current=!0,F.sendSystemPrompt(`[New session. Assess the current state and introduce yourself. Be proactive.]`)))},[P.appState,P.onboardingComplete]),(0,I.useEffect)(()=>{if(!l)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||O(t)}).catch(()=>{}),()=>{e=!0}},[l]),(0,I.useEffect)(()=>{if(!l){f(null),_(null),O(null);return}function e(e){oe.current&&!oe.current.contains(e.target)&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]),(0,I.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`platform-onboarding`);return e.onmessage=e=>{e.data?.type===`remote-password-set`&&F.sendMessageRef.current(`I've set the remote password`)},()=>e.close()},[]),P.appState===`loading`?(0,L.jsx)(`div`,{className:`chat-page admin-page`,children:(0,L.jsx)(`header`,{className:`chat-header`,children:(0,L.jsx)(`img`,{src:m,alt:x.productName,className:`chat-logo`})})}):P.appState===`set-pin`?(0,L.jsx)(dt,{pin:P.pin,setPin:P.setPin,confirmPin:P.confirmPin,setConfirmPin:P.setConfirmPin,showPin:P.showPin,setShowPin:P.setShowPin,pinLoading:P.pinLoading,pinError:P.pinError,pinInputRef:P.pinInputRef,confirmPinInputRef:P.confirmPinInputRef,setPinFormRef:P.setPinFormRef,onSubmit:P.handleSetPin}):P.appState===`connect-claude`?(0,L.jsx)(pt,{authPolling:P.authPolling,setAuthPolling:P.setAuthPolling,authLoading:P.authLoading,setAuthLoading:P.setAuthLoading,pinError:P.pinError,setPinError:P.setPinError,setAppState:P.setAppState}):P.appState===`enter-pin`?(0,L.jsx)(ft,{pin:P.pin,setPin:P.setPin,showPin:P.showPin,setShowPin:P.setShowPin,pinLoading:P.pinLoading,pinError:P.pinError,pinInputRef:P.pinInputRef,onSubmit:P.handleLogin,onChangePin:P.handleChangePin}):(0,L.jsxs)(`div`,{className:`chat-page admin-page`,children:[(0,L.jsxs)(`header`,{className:`chat-header`,children:[(0,L.jsx)(`img`,{src:m,alt:x.productName,className:`chat-logo`}),!x.logoContainsName&&(0,L.jsx)(`div`,{children:(0,L.jsx)(`h1`,{className:`chat-tagline`,children:x.productName})}),(0,L.jsxs)(`div`,{className:`chat-burger-wrap`,ref:oe,children:[(0,L.jsx)(`button`,{type:`button`,className:`chat-burger`,onClick:()=>u(e=>!e),"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":l,children:(0,L.jsx)(ke,{size:20})}),l&&(0,L.jsxs)(`div`,{className:`chat-menu`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{u(!1),F.startNewSession()},disabled:F.isStreaming||F.isCompacting,children:[(0,L.jsx)(he,{size:14}),` New session`]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{u(!1),y(!0),w(!0),E(null);try{let e=await fetch(`/api/admin/sessions?session_key=${encodeURIComponent(P.sessionKey)}`);if(!e.ok)throw Error(`Failed to load sessions`);S((await e.json()).sessions??[])}catch{E(`Failed to load sessions`)}finally{w(!1)}},children:[(0,L.jsx)(we,{size:14}),` Sessions`]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(!(te||re)){ie(!0),u(!1);try{let e=await(await fetch(`/api/admin/browser/launch`,{method:`POST`})).json().catch(()=>({ok:!1,error:`Invalid response`}));if(!e.ok)throw Error(e.error??`Failed to launch browser`);ne(!0)}catch(e){console.error(`[browser] Launch failed:`,e),alert(e instanceof Error?e.message:`Failed to launch browser`)}finally{ie(!1)}}},disabled:re,children:[(0,L.jsx)(_e,{size:14}),` Browser`,re&&(0,L.jsx)(Te,{size:12,className:`spin`})]}),(0,L.jsx)(`div`,{className:`chat-menu-divider`}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:async()=>{if(d!==null){f(null);return}h(!0),_(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);f((await e.json()).agents??[])}catch{_(`Failed to load agents`)}finally{h(!1)}},children:[(0,L.jsx)(de,{size:14}),` Public`,p&&(0,L.jsx)(Te,{size:12,className:`spin`})]}),d!==null&&(0,L.jsxs)(`div`,{className:`chat-menu-agents`,children:[g&&(0,L.jsx)(`span`,{className:`chat-menu-agent-error`,children:g}),d.length===0&&!g&&(0,L.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),d.map(e=>(0,L.jsxs)(`a`,{href:`${s}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`chat-menu-item chat-menu-agent-item`,onClick:()=>u(!1),children:[(0,L.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,L.jsxs)(`span`,{className:`agent-text`,children:[(0,L.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,L.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]})]},e.slug))]}),(0,L.jsx)(`div`,{className:`chat-menu-divider`}),D?.updateAvailable?(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-version`,onClick:()=>{D.latest&&(M(D),u(!1),j(!0))},children:[(0,L.jsx)(ye,{size:14}),(0,L.jsxs)(`span`,{className:`version-installed`,children:[`v`,D.installed,(0,L.jsx)(`span`,{className:`version-update-dot`})]})]}):(0,L.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,L.jsx)(ye,{size:14}),(0,L.jsxs)(`span`,{className:`version-installed`,children:[D?`v${D.installed}`:`…`,D&&!D.updateAvailable&&(0,L.jsx)(`span`,{className:`version-uptodate-dot`})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,onClick:()=>{u(!1),P.handleLogout(),F.setMessages([])},children:[(0,L.jsx)(De,{size:14}),` Log out`]})]})]})]}),(0,L.jsx)(NT,{messages:F.messages,isStreaming:F.isStreaming,elapsedSeconds:se.elapsedSeconds,sessionTurnStart:se.sessionTurnStart,expandAll:P.expandAll,setExpandAll:P.setExpandAll,sessionCompacted:F.sessionCompacted,isCompacting:F.isCompacting,setShowCompactConfirm:o,handleComponentSubmit:F.handleComponentSubmit,effectiveSubmitted:F.effectiveSubmitted,selectionMode:N.selectionMode,selectedItems:N.selectedItems,toggleSelectItem:N.toggleSelectItem,sessionKey:P.sessionKey,setLightboxSrc:n,messageQueue:F.messageQueue,messageQueueRef:F.messageQueueRef,setQueue:F.setQueue,sendMessage:F.sendMessage,appState:P.appState,onboardingComplete:P.onboardingComplete}),(0,L.jsx)(IT,{selectionMode:N.selectionMode,selectedItems:N.selectedItems,copyToast:N.copyToast,exitSelection:N.exitSelection,enterSelection:N.enterSelection,copySelected:N.copySelected,showCopyToast:N.showCopyToast,input:F.input,setInput:F.setInput,inputRef:e,pendingFiles:ce.pendingFiles,setPendingFiles:ce.setPendingFiles,isDragOver:ce.isDragOver,attachError:ce.attachError,fileInputRef:ce.fileInputRef,addFiles:ce.addFiles,removeFile:ce.removeFile,onDragOver:ce.onDragOver,onDragLeave:ce.onDragLeave,onDrop:ce.onDrop,isStreaming:F.isStreaming,wasPaused:F.wasPaused,messages:F.messages,messageQueueRef:F.messageQueueRef,setQueue:F.setQueue,sendMessage:F.sendMessage,stopStreaming:F.stopStreaming,disconnecting:P.disconnecting,handleDisconnect:P.handleDisconnect,claudeInfo:P.claudeInfo,setClaudeInfo:P.setClaudeInfo,setShowClaudeInfo:i}),N.copyToast&&(0,L.jsx)(`span`,{className:`copy-toast${N.copyToast===`failed`?` copy-toast-failed`:``}`,children:N.copyToast===`copied`?`Copied`:`Copy failed`}),(0,L.jsx)(LT,{show:v,onClose:()=>y(!1),sessionsLoading:C,sessionsError:T,sessionsList:b,setSessionsList:S,sessionKey:P.sessionKey,resetSession:F.resetSession,setMessages:F.setMessages}),(0,L.jsx)(RT,{src:t,onClose:()=>n(null)}),(0,L.jsx)(zT,{show:a,onClose:()=>o(!1),onConfirm:F.handleCompactNow}),(0,L.jsx)(BT,{show:r,onClose:()=>{i(!1),P.setClaudeInfo(null)},claudeInfo:P.claudeInfo,messages:F.messages,sessionElapsed:se.sessionElapsed,sessionKey:P.sessionKey,contextModeHint:P.contextModeHint,handleContextModeToggle:P.handleContextModeToggle}),(0,L.jsx)(WT,{show:A,onClose:()=>j(!1),versionInfo:ee,sessionKey:P.sessionKey,onUpgradeComplete:()=>O(null)}),te&&(0,L.jsx)(GT,{onClose:()=>ne(!1)})]})}(0,Ze.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(KT,{}));
@@ -2,4 +2,4 @@ import{C as e,D as t,S as n,T as r,_ as i,a,b as o,d as s,f as c,h as l,i as u,j
2
2
 
3
3
  ---
4
4
 
5
- `)}T.useEffect(()=>{if(!a)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);function f(){s.current!==null&&(clearTimeout(s.current),s.current=null)}return(0,I.jsx)(`div`,{className:`chat-input-area`,children:(0,I.jsxs)(`div`,{className:`selection-bar`,children:[(0,I.jsxs)(`span`,{className:`selection-count`,children:[e.size,` Selected`]}),(0,I.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(a){o(!1);return}c.current=!1,s.current=setTimeout(()=>{c.current=!0,o(!0),s.current=null},500)},onPointerUp:f,onPointerLeave:f,onPointerCancel:f,onClick:async()=>{c.current||await n(l,u)},children:[(0,I.jsx)(x,{size:18}),(0,I.jsx)(`span`,{children:`Copy`})]}),a&&(0,I.jsx)(`div`,{className:`copy-menu`,children:(0,I.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let e=d();e&&i(await b(e)),r()},children:`Copy all`})})]}),(0,I.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:r,children:`Cancel`})]})})}function U({input:t,setInput:r,isStreaming:i,pendingFiles:a,setPendingFiles:o,attachError:s,setAttachError:c,isDragOver:l,setIsDragOver:u,inputRef:d,onSubmit:f}){let p=(0,T.useRef)(null);function h(e){c(null);let t=e.find(e=>!D.has(e.type));if(t){c(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV.`);return}let n=e.find(e=>e.size>O);if(n){c(`"${n.name}" exceeds the 20 MB limit.`);return}o(t=>[...t,...e].slice(0,5))}function g(e){e.preventDefault(),u(!0)}function _(){u(!1)}function b(e){e.preventDefault(),u(!1),h([...e.dataTransfer.files])}return(0,I.jsxs)(`div`,{className:`chat-input-area`,children:[(0,I.jsx)(`input`,{ref:p,type:`file`,multiple:!0,accept:E,style:{display:`none`},onChange:e=>{e.target.files&&h([...e.target.files]),e.target.value=``}}),a.length>0&&(0,I.jsx)(`div`,{className:`attachment-strip`,children:a.map((t,r)=>(0,I.jsxs)(`div`,{className:`attachment-chip`,children:[t.type.startsWith(`image/`)?(0,I.jsx)(`img`,{src:URL.createObjectURL(t),alt:t.name,className:`attachment-chip-thumb`}):t.type===`application/pdf`?(0,I.jsx)(n,{size:14}):(0,I.jsx)(e,{size:14}),(0,I.jsx)(`span`,{className:`attachment-chip-name`,children:t.name}),(0,I.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>o(e=>e.filter((e,t)=>t!==r)),"aria-label":`Remove ${t.name}`,children:`×`})]},r))}),s&&(0,I.jsx)(`p`,{className:`attach-error`,children:s}),(0,I.jsx)(m,{inputRef:d}),(0,I.jsxs)(`form`,{className:`chat-form${l?` drag-over`:``}`,onSubmit:f,onDragOver:g,onDragLeave:_,onDrop:b,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&h(n)},children:[(0,I.jsx)(y,{variant:`icon`,type:`button`,onClick:()=>p.current?.click(),disabled:i,"aria-label":`Attach file`,children:(0,I.jsx)(S,{size:14})}),(0,I.jsx)(v,{ref:d,value:t,onChange:r,placeholder:`Type a message...`}),(0,I.jsx)(y,{variant:`send`,type:`submit`,disabled:i||!t.trim()&&a.length===0,"aria-label":`Send message`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,I.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,I.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})]})}var W=[];function G(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)([]),[i,a]=(0,T.useState)(!1),[s,c]=(0,T.useState)(null),[u,d]=(0,T.useState)(W),[f,m]=(0,T.useState)(!0),g=(0,T.useRef)(null),{selectionMode:_,selectedItems:v,copyToast:y,exitSelection:b,enterSelection:x,toggleSelectItem:S,copySelected:w,showCopyToast:E}=C(),D=(0,T.useRef)(()=>{}),O=P((0,T.useCallback)(e=>{D.current(e)},[])),{sessionId:k,sessionKeyRef:A,sessionError:j,pageState:M,agentDisplayName:N,agentImage:L,agentImageShape:z,showAgentName:B,branding:G,ensureSession:K,resumedRef:q,resumeMessagesRef:J}=O,{messages:Y,setMessages:X,isStreaming:Z,sendMessage:ee,sendGreeting:Q,handleComponentSubmit:te}=F({sessionKeyRef:A,ensureSession:K,sessionError:j,pageState:M,inputRef:g});(0,T.useEffect)(()=>{D.current=Q},[Q]),(0,T.useEffect)(()=>{let e=!1;return(async()=>{let t=await K();if(!e&&t){if(q.current&&J.current&&J.current.length>0){X(J.current.map(e=>({role:e.role,content:e.content,timestamp:e.timestamp}))),J.current=null;return}Q(t)}})(),()=>{e=!0}},[]),(0,T.useEffect)(()=>{M===`chat`&&g.current?.focus()},[M]),(0,T.useEffect)(()=>{if(!G)return;let e=document.documentElement;if(G.primaryColor&&(e.style.setProperty(`--sage`,G.primaryColor),e.style.setProperty(`--sage-hover`,G.primaryColor),e.style.setProperty(`--sage-subtle`,G.primaryColor+`14`),e.style.setProperty(`--sage-glow`,G.primaryColor+`26`)),G.accentColor&&e.style.setProperty(`--visitor-bubble`,G.accentColor),G.backgroundColor&&e.style.setProperty(`--bg`,G.backgroundColor),document.title=G.name,G.primaryColor){let e=document.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e)),e.content=G.primaryColor}if(G.faviconUrl){let e=document.querySelector(`link[rel="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=G.faviconUrl}},[G]),(0,T.useEffect)(()=>{function e(e){e.key===`Escape`&&_&&b()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,b]);function $(e){if(!e&&n.length===0||Z)return;X(e=>e.map(e=>e.components?.some(e=>!e.submitted)?{...e,components:e.components.map(e=>e.submitted?e:{...e,submitted:!0})}:e)),d(t=>t.filter(t=>t!==e)),m(!0);let i=[...n];t(``),r([]),c(null),ee(e,{files:i})}function ne(t){t.preventDefault(),$(e.trim()),g.current?.resetHeight()}return(0,I.jsxs)(`div`,{className:`chat-page`,children:[(0,I.jsxs)(`header`,{className:`chat-header`,children:[(0,I.jsx)(`img`,{src:L||G?.logoUrl||l,alt:G?.name||h.productName,className:`chat-logo${L&&z===`circle`?` chat-logo--circle`:``}${L&&z===`rounded`?` chat-logo--rounded`:``}`,onError:e=>{e.target.src=G?.logoUrl||l}}),(0,I.jsx)(`h1`,{className:`chat-tagline`,children:B&&N||G?.name||h.productName}),(0,I.jsx)(`p`,{className:`chat-intro`,children:G?.tagline||``}),M===`chat`&&!_&&(0,I.jsx)(`button`,{className:`chat-header-select`,onClick:x,title:`Select messages`,"aria-label":`Select messages`,children:(0,I.jsx)(o,{size:16})})]}),M===`loading`&&(0,I.jsx)(`div`,{className:`gate-wrap`,children:(0,I.jsx)(`div`,{className:`gate-loading`,children:(0,I.jsx)(`span`,{className:`spinner`})})}),M===`auth-required`&&(0,I.jsx)(R,{gateState:O.gateState,setGateState:O.setGateState,grantInfo:O.grantInfo,setGrantInfo:O.setGrantInfo,gateSessionKeyRef:O.gateSessionKeyRef,resolvedSlugRef:O.resolvedSlugRef,onAuthenticated:O.enterChat}),M===`chat`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{messages:Y,isStreaming:Z,sessionError:j,selectionMode:_,selectedItems:v,toggleSelectItem:S,onComponentSubmit:te,remainingSuggestions:u,onSuggestionClick:$,isAtBottom:f,setIsAtBottom:m}),_?(0,I.jsx)(H,{selectedItems:v,messages:Y,copySelected:w,exitSelection:b,showCopyToast:E}):(0,I.jsx)(U,{input:e,setInput:t,isStreaming:Z,pendingFiles:n,setPendingFiles:r,attachError:s,setAttachError:c,isDragOver:i,setIsDragOver:a,inputRef:g,onSubmit:ne})]}),y&&(0,I.jsx)(`span`,{className:`copy-toast${y===`failed`?` copy-toast-failed`:``}`,children:y===`copied`?`Copied`:`Copy failed`}),(0,I.jsxs)(`footer`,{className:`chat-footer`,children:[(0,I.jsxs)(`a`,{href:p,children:[h.domain,` `,`↗`]}),k&&(0,I.jsxs)(`span`,{style:{opacity:.35,fontSize:`10px`,fontFamily:`monospace`,marginLeft:`1rem`},children:[`Session · `,k.slice(0,8)]})]})]})}(0,w.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(G,{}));
5
+ `)}T.useEffect(()=>{if(!a)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||o(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a]);function f(){s.current!==null&&(clearTimeout(s.current),s.current=null)}return(0,I.jsx)(`div`,{className:`chat-input-area`,children:(0,I.jsxs)(`div`,{className:`selection-bar`,children:[(0,I.jsxs)(`span`,{className:`selection-count`,children:[e.size,` Selected`]}),(0,I.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(a){o(!1);return}c.current=!1,s.current=setTimeout(()=>{c.current=!0,o(!0),s.current=null},500)},onPointerUp:f,onPointerLeave:f,onPointerCancel:f,onClick:async()=>{c.current||await n(l,u)},children:[(0,I.jsx)(x,{size:18}),(0,I.jsx)(`span`,{children:`Copy`})]}),a&&(0,I.jsx)(`div`,{className:`copy-menu`,children:(0,I.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let e=d();e&&i(await b(e)),r()},children:`Copy all`})})]}),(0,I.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:r,children:`Cancel`})]})})}function U({input:t,setInput:r,isStreaming:i,pendingFiles:a,setPendingFiles:o,attachError:s,setAttachError:c,isDragOver:l,setIsDragOver:u,inputRef:d,onSubmit:f}){let p=(0,T.useRef)(null);function h(e){c(null);let t=e.find(e=>!D.has(e.type));if(t){c(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV.`);return}let n=e.find(e=>e.size>O);if(n){c(`"${n.name}" exceeds the 20 MB limit.`);return}o(t=>[...t,...e].slice(0,5))}function g(e){e.preventDefault(),u(!0)}function _(){u(!1)}function b(e){e.preventDefault(),u(!1),h([...e.dataTransfer.files])}return(0,I.jsxs)(`div`,{className:`chat-input-area`,children:[(0,I.jsx)(`input`,{ref:p,type:`file`,multiple:!0,accept:E,style:{display:`none`},onChange:e=>{e.target.files&&h([...e.target.files]),e.target.value=``}}),a.length>0&&(0,I.jsx)(`div`,{className:`attachment-strip`,children:a.map((t,r)=>(0,I.jsxs)(`div`,{className:`attachment-chip`,children:[t.type.startsWith(`image/`)?(0,I.jsx)(`img`,{src:URL.createObjectURL(t),alt:t.name,className:`attachment-chip-thumb`}):t.type===`application/pdf`?(0,I.jsx)(n,{size:14}):(0,I.jsx)(e,{size:14}),(0,I.jsx)(`span`,{className:`attachment-chip-name`,children:t.name}),(0,I.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>o(e=>e.filter((e,t)=>t!==r)),"aria-label":`Remove ${t.name}`,children:`×`})]},r))}),s&&(0,I.jsx)(`p`,{className:`attach-error`,children:s}),(0,I.jsx)(m,{inputRef:d}),(0,I.jsxs)(`form`,{className:`chat-form${l?` drag-over`:``}`,onSubmit:f,onDragOver:g,onDragLeave:_,onDrop:b,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&h(n)},children:[(0,I.jsx)(y,{variant:`icon`,type:`button`,onClick:()=>p.current?.click(),disabled:i,"aria-label":`Attach file`,children:(0,I.jsx)(S,{size:14})}),(0,I.jsx)(v,{ref:d,value:t,onChange:r,placeholder:`Type a message...`}),(0,I.jsx)(y,{variant:`send`,type:`submit`,disabled:i||!t.trim()&&a.length===0,"aria-label":`Send message`,children:(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,I.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,I.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})]})}var W=[];function G(){let[e,t]=(0,T.useState)(``),[n,r]=(0,T.useState)([]),[i,a]=(0,T.useState)(!1),[s,c]=(0,T.useState)(null),[u,d]=(0,T.useState)(W),[f,m]=(0,T.useState)(!0),g=(0,T.useRef)(null),{selectionMode:_,selectedItems:v,copyToast:y,exitSelection:b,enterSelection:x,toggleSelectItem:S,copySelected:w,showCopyToast:E}=C(),D=(0,T.useRef)(()=>{}),O=P((0,T.useCallback)(e=>{D.current(e)},[])),{sessionId:k,sessionKeyRef:A,sessionError:j,pageState:M,agentDisplayName:N,agentImage:L,agentImageShape:z,showAgentName:B,branding:G,ensureSession:K,resumedRef:q,resumeMessagesRef:J}=O,{messages:Y,setMessages:X,isStreaming:Z,sendMessage:ee,sendGreeting:Q,handleComponentSubmit:te}=F({sessionKeyRef:A,ensureSession:K,sessionError:j,pageState:M,inputRef:g});(0,T.useEffect)(()=>{D.current=Q},[Q]),(0,T.useEffect)(()=>{let e=!1;return(async()=>{let t=await K();if(!e&&t){if(q.current&&J.current&&J.current.length>0){X(J.current.map(e=>({role:e.role,content:e.content,timestamp:e.timestamp}))),J.current=null;return}Q(t)}})(),()=>{e=!0}},[]),(0,T.useEffect)(()=>{M===`chat`&&g.current?.focus()},[M]),(0,T.useEffect)(()=>{if(!G)return;let e=document.documentElement;if(G.primaryColor&&(e.style.setProperty(`--sage`,G.primaryColor),e.style.setProperty(`--sage-hover`,G.primaryColor),e.style.setProperty(`--sage-subtle`,G.primaryColor+`14`),e.style.setProperty(`--sage-glow`,G.primaryColor+`26`)),G.accentColor&&e.style.setProperty(`--visitor-bubble`,G.accentColor),G.backgroundColor&&e.style.setProperty(`--bg`,G.backgroundColor),document.title=G.name,G.primaryColor){let e=document.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e)),e.content=G.primaryColor}if(G.faviconUrl){let e=document.querySelector(`link[rel="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=G.faviconUrl}},[G]),(0,T.useEffect)(()=>{function e(e){e.key===`Escape`&&_&&b()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,b]);function $(e){if(!e&&n.length===0||Z)return;X(e=>e.map(e=>e.components?.some(e=>!e.submitted)?{...e,components:e.components.map(e=>e.submitted?e:{...e,submitted:!0})}:e)),d(t=>t.filter(t=>t!==e)),m(!0);let i=[...n];t(``),r([]),c(null),ee(e,{files:i})}function ne(t){t.preventDefault(),$(e.trim()),g.current?.resetHeight()}return(0,I.jsxs)(`div`,{className:`chat-page`,children:[(0,I.jsxs)(`header`,{className:`chat-header`,children:[(0,I.jsx)(`img`,{src:L||G?.logoUrl||l,alt:G?.name||h.productName,className:`chat-logo${L&&z===`circle`?` chat-logo--circle`:``}${L&&z===`rounded`?` chat-logo--rounded`:``}`,onError:e=>{e.target.src=G?.logoUrl||l}}),B!==`none`&&(0,I.jsx)(`h1`,{className:`chat-tagline`,children:B&&N||G?.name||h.productName}),(0,I.jsx)(`p`,{className:`chat-intro`,children:G?.tagline||``}),M===`chat`&&!_&&(0,I.jsx)(`button`,{className:`chat-header-select`,onClick:x,title:`Select messages`,"aria-label":`Select messages`,children:(0,I.jsx)(o,{size:16})})]}),M===`loading`&&(0,I.jsx)(`div`,{className:`gate-wrap`,children:(0,I.jsx)(`div`,{className:`gate-loading`,children:(0,I.jsx)(`span`,{className:`spinner`})})}),M===`auth-required`&&(0,I.jsx)(R,{gateState:O.gateState,setGateState:O.setGateState,grantInfo:O.grantInfo,setGrantInfo:O.setGrantInfo,gateSessionKeyRef:O.gateSessionKeyRef,resolvedSlugRef:O.resolvedSlugRef,onAuthenticated:O.enterChat}),M===`chat`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{messages:Y,isStreaming:Z,sessionError:j,selectionMode:_,selectedItems:v,toggleSelectItem:S,onComponentSubmit:te,remainingSuggestions:u,onSuggestionClick:$,isAtBottom:f,setIsAtBottom:m}),_?(0,I.jsx)(H,{selectedItems:v,messages:Y,copySelected:w,exitSelection:b,showCopyToast:E}):(0,I.jsx)(U,{input:e,setInput:t,isStreaming:Z,pendingFiles:n,setPendingFiles:r,attachError:s,setAttachError:c,isDragOver:i,setIsDragOver:a,inputRef:g,onSubmit:ne})]}),y&&(0,I.jsx)(`span`,{className:`copy-toast${y===`failed`?` copy-toast-failed`:``}`,children:y===`copied`?`Copied`:`Copy failed`}),(0,I.jsxs)(`footer`,{className:`chat-footer`,children:[(0,I.jsxs)(`a`,{href:p,children:[h.domain,` `,`↗`]}),k&&(0,I.jsxs)(`span`,{style:{opacity:.35,fontSize:`10px`,fontFamily:`monospace`,marginLeft:`1rem`},children:[`Session · `,k.slice(0,8)]})]})]})}(0,w.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(G,{}));
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-B1CMS86q.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-BEbxw46k.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/ChatInput-Dnp1FLis.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/ChatInput-BEwQxFL9.css">
11
11
  <link rel="stylesheet" href="/brand-defaults.css">
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/public-ojODTkXT.js"></script>
8
+ <script type="module" crossorigin src="/assets/public-OdyNuhVE.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/ChatInput-Dnp1FLis.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/ChatInput-BEwQxFL9.css">
11
11
  <link rel="stylesheet" href="/brand-defaults.css">
@@ -4379,6 +4379,8 @@ function resolveAgentConfig(accountDir, agentName) {
4379
4379
  }
4380
4380
  if (parsed.showAgentName === true) {
4381
4381
  showAgentName = true;
4382
+ } else if (parsed.showAgentName === "none") {
4383
+ showAgentName = "none";
4382
4384
  }
4383
4385
  if (image || imageShape || showAgentName) {
4384
4386
  console.log(`[agent-config] ${agentName}: image=${image || "(none)"} imageShape=${imageShape || "(none)"} showAgentName=${showAgentName}`);