import{o as e}from"./rolldown-runtime-C_s2cVnS.js";import{d as t,h as n,m as r,n as i}from"./vendor-react-nmZsNlRz.js";import{t as a}from"./context-wCyjONh6.js";import{c as o,o as s,r as c}from"./quick-entry-CrkxD3xx.js";import{T as l}from"./index-DjNTYlku.js";var u=t(),d=i(),f=e(n(),1),p=e(r(),1);function m(){let e=(0,d.c)(32),t=(0,f.useRef)(null),[n,r]=(0,f.useReducer)(g,s),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=window.hermesDesktop?.quickEntry,n=e?.onShown(()=>{r({type:`shown`}),requestAnimationFrame(()=>t.current?.focus())}),i=e?.onState(e=>{r({connected:e?.connected===!0,sessions:Array.isArray(e?.sessions)?e.sessions:[],type:`state`})});return t.current?.focus(),()=>{n?.(),i?.()}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,f.useEffect)(i,a);let o,l,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={alignItems:`center`,background:`transparent`,display:`flex`,height:`100vh`,justifyContent:`center`,padding:12,width:`100vw`},l={background:`var(--ui-bg-elevated, var(--background))`,border:`1px solid var(--ui-stroke-secondary, rgba(127,127,127,0.35))`,borderRadius:12,boxShadow:`0 18px 48px rgba(0,0,0,0.38)`,display:`flex`,flexDirection:`column`,gap:8,padding:`10px 14px`,width:`100%`},u={alignItems:`center`,display:`flex`,gap:10},e[2]=o,e[3]=l,e[4]=u):(o=e[2],l=e[3],u=e[4]);let m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,p.jsx)(`span`,{"aria-hidden":!0,style:{color:`var(--muted-foreground, #8a8a8a)`,flexShrink:0,fontSize:15,lineHeight:1,userSelect:`none`},children:`›`}),e[5]=m):m=e[5];let _=!n.connected,v,y,b;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{e.relatedTarget||r({type:`blur`})},y=e=>r({draft:e.target.value,type:`edit`}),b=e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),r({type:`submit`})):e.key===`Escape`&&(e.preventDefault(),r({type:`dismiss`}))},e[6]=v,e[7]=y,e[8]=b):(v=e[6],y=e[7],b=e[8]);let x=n.connected?`Ask Hermes…`:`Not connected — open Hermes to reconnect`,S=n.connected?1:.55,C;e[9]===S?C=e[10]:(C={background:`transparent`,border:`none`,color:`var(--foreground, #eee)`,flex:1,fontFamily:`inherit`,fontSize:15,minWidth:0,opacity:S,outline:`none`},e[9]=S,e[10]=C);let w;e[11]!==n.draft||e[12]!==x||e[13]!==C||e[14]!==_?(w=(0,p.jsxs)(`div`,{style:u,children:[m,(0,p.jsx)(`input`,{"aria-label":`Quick Entry`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,disabled:_,onBlur:v,onChange:y,onKeyDown:b,placeholder:x,ref:t,spellCheck:!1,style:C,value:n.draft})]}),e[11]=n.draft,e[12]=x,e[13]=C,e[14]=_,e[15]=w):w=e[15];let T;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(T={alignItems:`center`,display:`flex`,gap:8},e[16]=T):T=e[16];let E;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`label`,{htmlFor:`quick-entry-target`,style:{color:`var(--muted-foreground, #8a8a8a)`,flexShrink:0,fontSize:11,userSelect:`none`},children:`Send to`}),e[17]=E):E=e[17];let D=!n.connected,O,k,A;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>r({target:e.target.value,type:`target`}),k=e=>{e.key===`Escape`&&(e.preventDefault(),r({type:`dismiss`}))},A={background:`transparent`,border:`1px solid var(--ui-stroke-secondary, rgba(127,127,127,0.35))`,borderRadius:6,color:`var(--foreground, #eee)`,fontSize:11,maxWidth:320,padding:`2px 6px`},e[18]=O,e[19]=k,e[20]=A):(O=e[18],k=e[19],A=e[20]);let j=n.target,M,N;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,p.jsx)(`option`,{value:c,children:`Current chat`}),N=(0,p.jsx)(`option`,{value:`new`,children:`New session`}),e[21]=M,e[22]=N):(M=e[21],N=e[22]);let P;e[23]===n.sessions?P=e[24]:(P=n.sessions.map(h),e[23]=n.sessions,e[24]=P);let F;e[25]!==n.target||e[26]!==D||e[27]!==P?(F=(0,p.jsxs)(`div`,{style:T,children:[E,(0,p.jsxs)(`select`,{"aria-label":`Target session`,disabled:D,id:`quick-entry-target`,onChange:O,onKeyDown:k,style:A,value:j,children:[M,N,P]})]}),e[25]=n.target,e[26]=D,e[27]=P,e[28]=F):F=e[28];let I;return e[29]!==w||e[30]!==F?(I=(0,p.jsx)(`div`,{style:o,children:(0,p.jsxs)(`div`,{style:l,children:[w,F]})}),e[29]=w,e[30]=F,e[31]=I):I=e[31],I}function h(e){return(0,p.jsx)(`option`,{value:e.id,children:e.title},e.id)}function g(e,t){let{send:n,state:r}=o(e,t),i=window.hermesDesktop?.quickEntry;return n?i?.submit(n):!r.visible&&e.visible&&i?.dismiss(),r}function _(){let e=document.createElement(`style`);e.textContent=`html,body,#root{background:transparent !important;}`,document.head.appendChild(e);let t=document.getElementById(`root`);t&&(0,u.createRoot)(t).render((0,p.jsx)(f.StrictMode,{children:(0,p.jsx)(l,{label:`quick-entry`,children:(0,p.jsx)(a,{children:(0,p.jsx)(m,{})})})}))}export{_ as mountQuickEntry};